]>
git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.support.gis/src/main/java/org/argeo/slc/gpsbabel/GpsBabelCall.java
2 * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org
.argeo
.slc
.gpsbabel
;
19 import java
.util
.ArrayList
;
20 import java
.util
.List
;
22 import org
.argeo
.slc
.SlcException
;
23 import org
.argeo
.slc
.core
.execution
.tasks
.SystemCall
;
24 import org
.springframework
.beans
.factory
.InitializingBean
;
26 public class GpsBabelCall
extends SystemCall
implements InitializingBean
{
27 private String executable
= "/usr/bin/gpsbabel";
28 private String inputFormat
;
29 private String inputFile
;
30 private String outputFormat
;
31 private String outputFile
;
33 public GpsBabelCall() {
37 public GpsBabelCall(String inputFormat
, String inputFile
,
38 String outputFormat
, String outputFile
) {
40 this.inputFormat
= inputFormat
;
41 this.inputFile
= inputFile
;
42 this.outputFormat
= outputFormat
;
43 this.outputFile
= outputFile
;
46 } catch (Exception e
) {
47 throw new SlcException("Cannot configure gpsbabel call", e
);
51 public void afterPropertiesSet() throws Exception
{
52 List
<Object
> command
= new ArrayList
<Object
>();
53 command
.add(executable
);
55 command
.add(inputFormat
);
57 command
.add(inputFile
);
59 command
.add(outputFormat
);
61 command
.add(outputFile
);
64 setStdOutLogLevel(LOG_STDOUT
);
65 setExceptionOnFailed(true);
68 public final static void main(String
[] args
) {
69 String output
= new GpsBabelCall("garmin,get_posn", "usb:", "csv", "-")
71 System
.out
.println("output='" + output
+ "'");