feat: Import of project at 2014-03-16
This commit is contained in:
commit
de11a550eb
36 changed files with 2321 additions and 0 deletions
73
build.xml
Normal file
73
build.xml
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!-- You may freely edit this file. See commented blocks below for -->
|
||||||
|
<!-- some examples of how to customize the build. -->
|
||||||
|
<!-- (If you delete it and reopen the project it will be recreated.) -->
|
||||||
|
<!-- By default, only the Clean and Build commands use this build script. -->
|
||||||
|
<!-- Commands such as Run, Debug, and Test only use this build script if -->
|
||||||
|
<!-- the Compile on Save feature is turned off for the project. -->
|
||||||
|
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
|
||||||
|
<!-- in the project's Project Properties dialog box.-->
|
||||||
|
<project name="SBBCommandLine" default="default" basedir=".">
|
||||||
|
<description>Builds, tests, and runs the project SBBCommandLine.</description>
|
||||||
|
<import file="nbproject/build-impl.xml"/>
|
||||||
|
<!--
|
||||||
|
|
||||||
|
There exist several targets which are by default empty and which can be
|
||||||
|
used for execution of your tasks. These targets are usually executed
|
||||||
|
before and after some main targets. They are:
|
||||||
|
|
||||||
|
-pre-init: called before initialization of project properties
|
||||||
|
-post-init: called after initialization of project properties
|
||||||
|
-pre-compile: called before javac compilation
|
||||||
|
-post-compile: called after javac compilation
|
||||||
|
-pre-compile-single: called before javac compilation of single file
|
||||||
|
-post-compile-single: called after javac compilation of single file
|
||||||
|
-pre-compile-test: called before javac compilation of JUnit tests
|
||||||
|
-post-compile-test: called after javac compilation of JUnit tests
|
||||||
|
-pre-compile-test-single: called before javac compilation of single JUnit test
|
||||||
|
-post-compile-test-single: called after javac compilation of single JUunit test
|
||||||
|
-pre-jar: called before JAR building
|
||||||
|
-post-jar: called after JAR building
|
||||||
|
-post-clean: called after cleaning build products
|
||||||
|
|
||||||
|
(Targets beginning with '-' are not intended to be called on their own.)
|
||||||
|
|
||||||
|
Example of inserting an obfuscator after compilation could look like this:
|
||||||
|
|
||||||
|
<target name="-post-compile">
|
||||||
|
<obfuscate>
|
||||||
|
<fileset dir="${build.classes.dir}"/>
|
||||||
|
</obfuscate>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
For list of available properties check the imported
|
||||||
|
nbproject/build-impl.xml file.
|
||||||
|
|
||||||
|
|
||||||
|
Another way to customize the build is by overriding existing main targets.
|
||||||
|
The targets of interest are:
|
||||||
|
|
||||||
|
-init-macrodef-javac: defines macro for javac compilation
|
||||||
|
-init-macrodef-junit: defines macro for junit execution
|
||||||
|
-init-macrodef-debug: defines macro for class debugging
|
||||||
|
-init-macrodef-java: defines macro for class execution
|
||||||
|
-do-jar: JAR building
|
||||||
|
run: execution of project
|
||||||
|
-javadoc-build: Javadoc generation
|
||||||
|
test-report: JUnit report generation
|
||||||
|
|
||||||
|
An example of overriding the target for project execution could look like this:
|
||||||
|
|
||||||
|
<target name="run" depends="SBBCommandLine-impl.jar">
|
||||||
|
<exec dir="bin" executable="launcher.exe">
|
||||||
|
<arg file="${dist.jar}"/>
|
||||||
|
</exec>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
Notice that the overridden target depends on the jar target and not only on
|
||||||
|
the compile target as the regular run target does. Again, for a list of available
|
||||||
|
properties which you can use, check the target you are overriding in the
|
||||||
|
nbproject/build-impl.xml file.
|
||||||
|
|
||||||
|
-->
|
||||||
|
</project>
|
BIN
lib/commons-codec-1.6.jar
Normal file
BIN
lib/commons-codec-1.6.jar
Normal file
Binary file not shown.
BIN
lib/commons-io-2.4-javadoc.jar
Normal file
BIN
lib/commons-io-2.4-javadoc.jar
Normal file
Binary file not shown.
BIN
lib/commons-io-2.4-sources.jar
Normal file
BIN
lib/commons-io-2.4-sources.jar
Normal file
Binary file not shown.
BIN
lib/commons-io-2.4-test-sources.jar
Normal file
BIN
lib/commons-io-2.4-test-sources.jar
Normal file
Binary file not shown.
BIN
lib/commons-io-2.4-tests.jar
Normal file
BIN
lib/commons-io-2.4-tests.jar
Normal file
Binary file not shown.
BIN
lib/commons-io-2.4.jar
Normal file
BIN
lib/commons-io-2.4.jar
Normal file
Binary file not shown.
BIN
lib/commons-logging-1.1.3.jar
Normal file
BIN
lib/commons-logging-1.1.3.jar
Normal file
Binary file not shown.
BIN
lib/fluent-hc-4.3.1.jar
Normal file
BIN
lib/fluent-hc-4.3.1.jar
Normal file
Binary file not shown.
BIN
lib/httpclient-4.3.1.jar
Normal file
BIN
lib/httpclient-4.3.1.jar
Normal file
Binary file not shown.
BIN
lib/httpclient-cache-4.3.1.jar
Normal file
BIN
lib/httpclient-cache-4.3.1.jar
Normal file
Binary file not shown.
BIN
lib/httpcore-4.3.jar
Normal file
BIN
lib/httpcore-4.3.jar
Normal file
Binary file not shown.
BIN
lib/httpmime-4.3.1.jar
Normal file
BIN
lib/httpmime-4.3.1.jar
Normal file
Binary file not shown.
54
lib/jdom205/LICENSE.txt
Normal file
54
lib/jdom205/LICENSE.txt
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
/*--
|
||||||
|
|
||||||
|
Copyright (C) 2000-2012 Jason Hunter & Brett McLaughlin.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions
|
||||||
|
are met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions, and the following disclaimer.
|
||||||
|
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions, and the disclaimer that follows
|
||||||
|
these conditions in the documentation and/or other materials
|
||||||
|
provided with the distribution.
|
||||||
|
|
||||||
|
3. The name "JDOM" must not be used to endorse or promote products
|
||||||
|
derived from this software without prior written permission. For
|
||||||
|
written permission, please contact <request_AT_jdom_DOT_org>.
|
||||||
|
|
||||||
|
4. Products derived from this software may not be called "JDOM", nor
|
||||||
|
may "JDOM" appear in their name, without prior written permission
|
||||||
|
from the JDOM Project Management <request_AT_jdom_DOT_org>.
|
||||||
|
|
||||||
|
In addition, we request (but do not require) that you include in the
|
||||||
|
end-user documentation provided with the redistribution and/or in the
|
||||||
|
software itself an acknowledgement equivalent to the following:
|
||||||
|
"This product includes software developed by the
|
||||||
|
JDOM Project (http://www.jdom.org/)."
|
||||||
|
Alternatively, the acknowledgment may be graphical using the logos
|
||||||
|
available at http://www.jdom.org/images/logos.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
||||||
|
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL THE JDOM AUTHORS OR THE PROJECT
|
||||||
|
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||||
|
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGE.
|
||||||
|
|
||||||
|
This software consists of voluntary contributions made by many
|
||||||
|
individuals on behalf of the JDOM Project and was originally
|
||||||
|
created by Jason Hunter <jhunter_AT_jdom_DOT_org> and
|
||||||
|
Brett McLaughlin <brett_AT_jdom_DOT_org>. For more information
|
||||||
|
on the JDOM Project, please see <http://www.jdom.org/>.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
119
lib/jdom205/README.txt
Normal file
119
lib/jdom205/README.txt
Normal file
|
@ -0,0 +1,119 @@
|
||||||
|
Introduction to the JDOM project
|
||||||
|
================================
|
||||||
|
|
||||||
|
Please see the JDOM web site at http://jdom.org/
|
||||||
|
and GitHub repository at https://github.com/hunterhacker/jdom/
|
||||||
|
|
||||||
|
Quick-Start for JDOM
|
||||||
|
=====================
|
||||||
|
See the github wiki for a Primer on using JDOM:
|
||||||
|
https://github.com/hunterhacker/jdom/wiki/JDOM2-A-Primer
|
||||||
|
|
||||||
|
Also see the web site http://jdom.org/downloads/docs.html. It has links to
|
||||||
|
numerous articles and books covering JDOM.
|
||||||
|
|
||||||
|
|
||||||
|
Installing the build tools
|
||||||
|
==========================
|
||||||
|
|
||||||
|
The JDOM build system is based on Apache Ant. Ant is a little but very
|
||||||
|
handy tool that uses a build file written in XML (build.xml) as building
|
||||||
|
instructions. For more information refer to "http://ant.apache.org".
|
||||||
|
|
||||||
|
The only thing that you have to make sure of is that the "JAVA_HOME"
|
||||||
|
environment property is set to match the top level directory containing the
|
||||||
|
JVM you want to use. For example:
|
||||||
|
|
||||||
|
C:\> set JAVA_HOME=C:\jdk1.6
|
||||||
|
|
||||||
|
or on Mac:
|
||||||
|
|
||||||
|
% setenv JAVA_HOME /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home
|
||||||
|
(csh)
|
||||||
|
> JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home; export JAVA_HOME
|
||||||
|
(ksh, bash)
|
||||||
|
|
||||||
|
or on Unix:
|
||||||
|
|
||||||
|
% setenv JAVA_HOME /usr/local/java
|
||||||
|
(csh)
|
||||||
|
> JAVA_HOME=/usr/java; export JAVA_HOME
|
||||||
|
(ksh, bash)
|
||||||
|
|
||||||
|
That's it!
|
||||||
|
|
||||||
|
|
||||||
|
Building instructions
|
||||||
|
=====================
|
||||||
|
|
||||||
|
If you do not have the full source code it can be cloned from GitHub. The JDOM
|
||||||
|
project at https://github.com/hunterhacker/jdom has the instructions and source
|
||||||
|
URL to make the git clone easy.
|
||||||
|
|
||||||
|
You will need to have Apache Ant 1.8.2 or later, and you will need Java JDK 1.6
|
||||||
|
or later.
|
||||||
|
|
||||||
|
Ok, let's build the code. First, make sure your current working directory is
|
||||||
|
where the build.xml file is located. Then run "ant".
|
||||||
|
|
||||||
|
If everything is right and all the required packages are visible, this action
|
||||||
|
will generate a file called "jdom-2.x-20yy.mm.dd.HH.MM.zip" in the
|
||||||
|
"./build/package" directory. This is the same 'zip' file that is distributed
|
||||||
|
as the official JDOM distribution.
|
||||||
|
|
||||||
|
The name of the zip file (and the jar names inside the zip) is controlled by
|
||||||
|
the two ant properties 'name' and 'version'. The package is called
|
||||||
|
"${name}-${version}.zip". The 'official' JDOM Build process is done by
|
||||||
|
creating a file 'build.properties' in the 'top' folder of the JDOM code, and
|
||||||
|
it contains the single line (or whatever the appropriate version is):
|
||||||
|
|
||||||
|
version=2.0.0
|
||||||
|
|
||||||
|
If your favourite Java IDE happens to be Eclipse, you can run the 'eclipse' ant
|
||||||
|
target, and that will configure your Eclipse project to have all the right
|
||||||
|
'source' folders, and 'Referenced Libraries'. After running the 'ant eclipse'
|
||||||
|
target, you should refresh your Eclipse project, and you should have a project
|
||||||
|
with no errors or warnings.
|
||||||
|
|
||||||
|
|
||||||
|
Build targets
|
||||||
|
=============
|
||||||
|
|
||||||
|
The build system is not only responsible for compiling JDOM into a jar file,
|
||||||
|
but is also responsible for creating the HTML documentation in the form of
|
||||||
|
javadocs.
|
||||||
|
|
||||||
|
These are the meaningful targets for this build file:
|
||||||
|
|
||||||
|
- package [default] -> generates ./build/package/jdom*.zip
|
||||||
|
- compile -> compiles the source code
|
||||||
|
- javadoc -> generates the API documentation in ./build/javadocs
|
||||||
|
- junit -> runs the JUnit tests
|
||||||
|
- coverage -> generates test coverage metrics
|
||||||
|
- eclipse -> generates an Eclipse project (source folders, jars, etc)
|
||||||
|
- clean -> restores the distribution to its original and clean state
|
||||||
|
- maven -> generates the package, and makes a 'bundle' for maven-central
|
||||||
|
|
||||||
|
To learn the details of what each target does, read the build.xml file. It is
|
||||||
|
quite understandable.
|
||||||
|
|
||||||
|
|
||||||
|
Bug Reports
|
||||||
|
===========
|
||||||
|
|
||||||
|
Bug reports go to the jdom-interest list at jdom.org. But *BEFORE YOU POST*
|
||||||
|
make sure you've tested against the LATEST code available from GitHub (or the
|
||||||
|
daily snapshot). Odds are good your bug has already been fixed. If it hasn't
|
||||||
|
been fixed in the latest version, then when posting *BE SURE TO SAY* which
|
||||||
|
code version you tested against. For example, "GitHub from October 3rd". Also
|
||||||
|
be sure to include enough information to reproduce the bug and full exception
|
||||||
|
stack traces. You might also want to read the FAQ at http://jdom.org to find
|
||||||
|
out if your problem is not really a bug and just a common misunderstanding
|
||||||
|
about how XML or JDOM works.
|
||||||
|
|
||||||
|
|
||||||
|
Searching for Information
|
||||||
|
=========================
|
||||||
|
|
||||||
|
The JDOM mailing lists are archived and easily searched at
|
||||||
|
http://jdom.markmail.org.
|
BIN
lib/jdom205/jdom-2.0.5-contrib.jar
Normal file
BIN
lib/jdom205/jdom-2.0.5-contrib.jar
Normal file
Binary file not shown.
BIN
lib/jdom205/jdom-2.0.5-javadoc.jar
Normal file
BIN
lib/jdom205/jdom-2.0.5-javadoc.jar
Normal file
Binary file not shown.
BIN
lib/jdom205/jdom-2.0.5-junit.jar
Normal file
BIN
lib/jdom205/jdom-2.0.5-junit.jar
Normal file
Binary file not shown.
BIN
lib/jdom205/jdom-2.0.5-sources.jar
Normal file
BIN
lib/jdom205/jdom-2.0.5-sources.jar
Normal file
Binary file not shown.
BIN
lib/jdom205/jdom-2.0.5.jar
Normal file
BIN
lib/jdom205/jdom-2.0.5.jar
Normal file
Binary file not shown.
33
lib/jdom205/lib/jaxen-1.1.6.LICENSE.txt
Normal file
33
lib/jdom205/lib/jaxen-1.1.6.LICENSE.txt
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
/*
|
||||||
|
$Id: LICENSE.txt 1128 2006-02-05 21:49:04Z elharo $
|
||||||
|
|
||||||
|
Copyright 2003-2006 The Werken Company. All Rights Reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are
|
||||||
|
met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the Jaxen Project nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived
|
||||||
|
from this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
*/
|
BIN
lib/jdom205/lib/jaxen-1.1.6.jar
Normal file
BIN
lib/jdom205/lib/jaxen-1.1.6.jar
Normal file
Binary file not shown.
202
lib/jdom205/lib/xerces.2.11.LICENSE
Normal file
202
lib/jdom205/lib/xerces.2.11.LICENSE
Normal file
|
@ -0,0 +1,202 @@
|
||||||
|
|
||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following
|
||||||
|
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||||
|
replaced with your own identifying information. (Don't include
|
||||||
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
|
comment syntax for the file format. We also recommend that a
|
||||||
|
file or class name and description of purpose be included on the
|
||||||
|
same "printed page" as the copyright notice for easier
|
||||||
|
identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright [yyyy] [name of copyright owner]
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
17
lib/jdom205/lib/xerces.2.11.NOTICE
Normal file
17
lib/jdom205/lib/xerces.2.11.NOTICE
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
=========================================================================
|
||||||
|
== NOTICE file corresponding to section 4(d) of the Apache License, ==
|
||||||
|
== Version 2.0, in this case for the Apache Xerces Java distribution. ==
|
||||||
|
=========================================================================
|
||||||
|
|
||||||
|
Apache Xerces Java
|
||||||
|
Copyright 1999-2010 The Apache Software Foundation
|
||||||
|
|
||||||
|
This product includes software developed at
|
||||||
|
The Apache Software Foundation (http://www.apache.org/).
|
||||||
|
|
||||||
|
Portions of this software were originally based on the following:
|
||||||
|
- software copyright (c) 1999, IBM Corporation., http://www.ibm.com.
|
||||||
|
- software copyright (c) 1999, Sun Microsystems., http://www.sun.com.
|
||||||
|
- voluntary contributions made by Paul Eng on behalf of the
|
||||||
|
Apache Software Foundation that were originally developed at iClick, Inc.,
|
||||||
|
software copyright (c) 1999.
|
BIN
lib/jdom205/lib/xercesImpl.jar
Normal file
BIN
lib/jdom205/lib/xercesImpl.jar
Normal file
Binary file not shown.
BIN
lib/jdom205/lib/xml-apis.jar
Normal file
BIN
lib/jdom205/lib/xml-apis.jar
Normal file
Binary file not shown.
3
manifest.mf
Normal file
3
manifest.mf
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
Manifest-Version: 1.0
|
||||||
|
X-COMMENT: Main-Class will be added automatically by build
|
||||||
|
|
1407
nbproject/build-impl.xml
Normal file
1407
nbproject/build-impl.xml
Normal file
File diff suppressed because it is too large
Load diff
8
nbproject/genfiles.properties
Normal file
8
nbproject/genfiles.properties
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
build.xml.data.CRC32=10763fbf
|
||||||
|
build.xml.script.CRC32=6dfdbbcc
|
||||||
|
build.xml.stylesheet.CRC32=8064a381@1.68.1.46
|
||||||
|
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
|
||||||
|
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
|
||||||
|
nbproject/build-impl.xml.data.CRC32=10763fbf
|
||||||
|
nbproject/build-impl.xml.script.CRC32=44a2d1b4
|
||||||
|
nbproject/build-impl.xml.stylesheet.CRC32=5a01deb7@1.68.1.46
|
0
nbproject/private/config.properties
Normal file
0
nbproject/private/config.properties
Normal file
6
nbproject/private/private.properties
Normal file
6
nbproject/private/private.properties
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
compile.on.save=true
|
||||||
|
do.depend=false
|
||||||
|
do.jar=true
|
||||||
|
javac.debug=true
|
||||||
|
javadoc.preview=true
|
||||||
|
user.properties.file=/home/valdor/.netbeans/7.4/build.properties
|
7
nbproject/private/private.xml
Normal file
7
nbproject/private/private.xml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
|
||||||
|
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
|
||||||
|
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
|
||||||
|
<group/>
|
||||||
|
</open-files>
|
||||||
|
</project-private>
|
113
nbproject/project.properties
Normal file
113
nbproject/project.properties
Normal file
|
@ -0,0 +1,113 @@
|
||||||
|
annotation.processing.enabled=true
|
||||||
|
annotation.processing.enabled.in.editor=false
|
||||||
|
annotation.processing.processors.list=
|
||||||
|
annotation.processing.run.all.processors=true
|
||||||
|
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
|
||||||
|
application.title=SBBCommandLine
|
||||||
|
application.vendor=valdor
|
||||||
|
build.classes.dir=${build.dir}/classes
|
||||||
|
build.classes.excludes=**/*.java,**/*.form
|
||||||
|
# This directory is removed when the project is cleaned:
|
||||||
|
build.dir=build
|
||||||
|
build.generated.dir=${build.dir}/generated
|
||||||
|
build.generated.sources.dir=${build.dir}/generated-sources
|
||||||
|
# Only compile against the classpath explicitly listed here:
|
||||||
|
build.sysclasspath=ignore
|
||||||
|
build.test.classes.dir=${build.dir}/test/classes
|
||||||
|
build.test.results.dir=${build.dir}/test/results
|
||||||
|
# Uncomment to specify the preferred debugger connection transport:
|
||||||
|
#debug.transport=dt_socket
|
||||||
|
debug.classpath=\
|
||||||
|
${run.classpath}
|
||||||
|
debug.test.classpath=\
|
||||||
|
${run.test.classpath}
|
||||||
|
# Files in build.classes.dir which should be excluded from distribution jar
|
||||||
|
dist.archive.excludes=
|
||||||
|
# This directory is removed when the project is cleaned:
|
||||||
|
dist.dir=dist
|
||||||
|
dist.jar=${dist.dir}/SBBCommandLine.jar
|
||||||
|
dist.javadoc.dir=${dist.dir}/javadoc
|
||||||
|
endorsed.classpath=
|
||||||
|
excludes=
|
||||||
|
file.reference.commons-codec-1.6.jar=lib/commons-codec-1.6.jar
|
||||||
|
file.reference.commons-io-2.4-javadoc.jar=lib/commons-io-2.4-javadoc.jar
|
||||||
|
file.reference.commons-io-2.4-sources.jar=lib/commons-io-2.4-sources.jar
|
||||||
|
file.reference.commons-io-2.4-test-sources.jar=lib/commons-io-2.4-test-sources.jar
|
||||||
|
file.reference.commons-io-2.4-tests.jar=lib/commons-io-2.4-tests.jar
|
||||||
|
file.reference.commons-io-2.4.jar=lib/commons-io-2.4.jar
|
||||||
|
file.reference.commons-logging-1.1.3.jar=lib/commons-logging-1.1.3.jar
|
||||||
|
file.reference.fluent-hc-4.3.1.jar=lib/fluent-hc-4.3.1.jar
|
||||||
|
file.reference.httpclient-4.3.1.jar=lib/httpclient-4.3.1.jar
|
||||||
|
file.reference.httpclient-cache-4.3.1.jar=lib/httpclient-cache-4.3.1.jar
|
||||||
|
file.reference.httpcore-4.3.jar=lib/httpcore-4.3.jar
|
||||||
|
file.reference.httpmime-4.3.1.jar=lib/httpmime-4.3.1.jar
|
||||||
|
file.reference.jaxen-1.1.6.jar=lib/jdom205/lib/jaxen-1.1.6.jar
|
||||||
|
file.reference.jdom-2.0.5-contrib.jar=lib/jdom205/jdom-2.0.5-contrib.jar
|
||||||
|
file.reference.jdom-2.0.5-javadoc.jar=lib/jdom205/jdom-2.0.5-javadoc.jar
|
||||||
|
file.reference.jdom-2.0.5-sources.jar=lib/jdom205/jdom-2.0.5-sources.jar
|
||||||
|
file.reference.jdom-2.0.5.jar=lib/jdom205/jdom-2.0.5.jar
|
||||||
|
file.reference.xercesImpl.jar=lib/jdom205/lib/xercesImpl.jar
|
||||||
|
file.reference.xml-apis.jar=lib/jdom205/lib/xml-apis.jar
|
||||||
|
includes=**
|
||||||
|
jar.compress=false
|
||||||
|
javac.classpath=\
|
||||||
|
${file.reference.commons-codec-1.6.jar}:\
|
||||||
|
${file.reference.commons-io-2.4-javadoc.jar}:\
|
||||||
|
${file.reference.commons-io-2.4-sources.jar}:\
|
||||||
|
${file.reference.commons-io-2.4-test-sources.jar}:\
|
||||||
|
${file.reference.commons-io-2.4-tests.jar}:\
|
||||||
|
${file.reference.commons-io-2.4.jar}:\
|
||||||
|
${file.reference.commons-logging-1.1.3.jar}:\
|
||||||
|
${file.reference.fluent-hc-4.3.1.jar}:\
|
||||||
|
${file.reference.httpclient-4.3.1.jar}:\
|
||||||
|
${file.reference.httpclient-cache-4.3.1.jar}:\
|
||||||
|
${file.reference.httpcore-4.3.jar}:\
|
||||||
|
${file.reference.httpmime-4.3.1.jar}:\
|
||||||
|
${file.reference.jaxen-1.1.6.jar}:\
|
||||||
|
${file.reference.jdom-2.0.5-contrib.jar}:\
|
||||||
|
${file.reference.jdom-2.0.5-javadoc.jar}:\
|
||||||
|
${file.reference.jdom-2.0.5-sources.jar}:\
|
||||||
|
${file.reference.jdom-2.0.5.jar}:\
|
||||||
|
${file.reference.xercesImpl.jar}:\
|
||||||
|
${file.reference.xml-apis.jar}
|
||||||
|
# Space-separated list of extra javac options
|
||||||
|
javac.compilerargs=
|
||||||
|
javac.deprecation=false
|
||||||
|
javac.processorpath=\
|
||||||
|
${javac.classpath}
|
||||||
|
javac.source=1.7
|
||||||
|
javac.target=1.7
|
||||||
|
javac.test.classpath=\
|
||||||
|
${javac.classpath}:\
|
||||||
|
${build.classes.dir}
|
||||||
|
javac.test.processorpath=\
|
||||||
|
${javac.test.classpath}
|
||||||
|
javadoc.additionalparam=
|
||||||
|
javadoc.author=false
|
||||||
|
javadoc.encoding=${source.encoding}
|
||||||
|
javadoc.noindex=false
|
||||||
|
javadoc.nonavbar=false
|
||||||
|
javadoc.notree=false
|
||||||
|
javadoc.private=false
|
||||||
|
javadoc.splitindex=true
|
||||||
|
javadoc.use=true
|
||||||
|
javadoc.version=false
|
||||||
|
javadoc.windowtitle=
|
||||||
|
main.class=sbbcommandline.SBBCommandLine
|
||||||
|
manifest.file=manifest.mf
|
||||||
|
meta.inf.dir=${src.dir}/META-INF
|
||||||
|
mkdist.disabled=false
|
||||||
|
platform.active=default_platform
|
||||||
|
run.classpath=\
|
||||||
|
${javac.classpath}:\
|
||||||
|
${build.classes.dir}
|
||||||
|
# Space-separated list of JVM arguments used when running the project.
|
||||||
|
# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
|
||||||
|
# To set system properties for unit tests define test-sys-prop.name=value:
|
||||||
|
run.jvmargs=
|
||||||
|
run.test.classpath=\
|
||||||
|
${javac.test.classpath}:\
|
||||||
|
${build.test.classes.dir}
|
||||||
|
source.encoding=UTF-8
|
||||||
|
src.dir=src
|
||||||
|
test.src.dir=test
|
15
nbproject/project.xml
Normal file
15
nbproject/project.xml
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://www.netbeans.org/ns/project/1">
|
||||||
|
<type>org.netbeans.modules.java.j2seproject</type>
|
||||||
|
<configuration>
|
||||||
|
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
|
||||||
|
<name>SBBCommandLine</name>
|
||||||
|
<source-roots>
|
||||||
|
<root id="src.dir"/>
|
||||||
|
</source-roots>
|
||||||
|
<test-roots>
|
||||||
|
<root id="test.src.dir"/>
|
||||||
|
</test-roots>
|
||||||
|
</data>
|
||||||
|
</configuration>
|
||||||
|
</project>
|
214
src/sbbcommandline/SBBCommandLine.java
Normal file
214
src/sbbcommandline/SBBCommandLine.java
Normal file
|
@ -0,0 +1,214 @@
|
||||||
|
package sbbcommandline;
|
||||||
|
|
||||||
|
import java.io.BufferedInputStream;
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.io.StringReader;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.zip.GZIPInputStream;
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
|
import org.apache.http.Header;
|
||||||
|
import org.apache.http.HttpEntity;
|
||||||
|
import org.apache.http.HttpResponse;
|
||||||
|
import org.apache.http.client.methods.HttpPost;
|
||||||
|
import org.apache.http.entity.BasicHttpEntity;
|
||||||
|
import org.apache.http.impl.client.DefaultHttpClient;
|
||||||
|
import org.jdom2.Content;
|
||||||
|
import org.jdom2.Document;
|
||||||
|
import org.jdom2.Element;
|
||||||
|
import org.jdom2.JDOMException;
|
||||||
|
import org.jdom2.input.SAXBuilder;
|
||||||
|
import sbbcommandline.objects.SBBStation;
|
||||||
|
|
||||||
|
public class SBBCommandLine {
|
||||||
|
|
||||||
|
private final static String BASE_URL = "http://xmlfahrplan.sbb.ch/bin/extxml.exe/";
|
||||||
|
private final static String USER_AGENT = "SBBMobile/%1$s (Android/%2$s %3$s; SDK/%4$s; fr)";
|
||||||
|
|
||||||
|
private final static String STATION_QUERY = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n"
|
||||||
|
+ "<ReqC lang=\"EN\" prod=\"unknown alien_jolla_bionic, Android OS: 4.1.2 (SDK:16) \" ver=\"3.0.5\" accessId=\"sbuR5gsaDCEzWpCzSuEnxJOmDbb5vEM1vf0tWwjY3s6eab2uj8dAiLvjisGKDnN\">\n"
|
||||||
|
+ " <LocValReq id=\"START\" maxNr=\"25\">\n"
|
||||||
|
+ " <ReqLoc match=\"%1$s\" type=\"ST\" />\n"
|
||||||
|
+ " </LocValReq>\n"
|
||||||
|
+ "</ReqC>";
|
||||||
|
|
||||||
|
private final static String CONNECTION_QUERY = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"
|
||||||
|
+ "<ReqC lang=\"EN\" prod=\"unknown alien_jolla_bionic, Android OS: 4.1.2 (SDK:16) \" ver=\"3.0.5\" accessId=\"sbuR5gsaDCEzWpCzSuEnxJOmDbb5vEM1vf0tWwjY3s6eab2uj8dAiLvjisGKDnN\">\n"
|
||||||
|
+ " <ConReq>\n"
|
||||||
|
+ " <Start>\n"
|
||||||
|
+ " <Station name=\"%1$s\" externalId=\"%2$s\" />\n"
|
||||||
|
+ " <Prod prod=\"1111111111000000\" />\n"
|
||||||
|
+ " </Start>\n"
|
||||||
|
+ " <Dest>\n"
|
||||||
|
+ " <Station name=\"%3$s\" externalId=\"%4$s\" />\n"
|
||||||
|
+ " </Dest>\n"
|
||||||
|
+ " <ReqT a=\"0\" date=\"%5$s\" time=\"%6$s\" />\n"
|
||||||
|
+ " <RFlags b=\"0\" f=\"6\" sMode=\"N\" />\n"
|
||||||
|
+ " </ConReq>\n"
|
||||||
|
+ "</ReqC>";
|
||||||
|
|
||||||
|
public static void main(String[] args) throws IOException, JDOMException {
|
||||||
|
|
||||||
|
SBBStation startStation = getStation("Icogne poste");
|
||||||
|
SBBStation endStation = getStation("Lausanne jordils");
|
||||||
|
|
||||||
|
getConnections(startStation, endStation, new Date());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static SBBStation getStation(String stationName) throws IOException, JDOMException {
|
||||||
|
String request = String.format(STATION_QUERY, stationName);
|
||||||
|
|
||||||
|
Element rootElement = getResponse(request);
|
||||||
|
Element stationListElement = rootElement.getChild("LocValRes");
|
||||||
|
|
||||||
|
Element stationElement = stationListElement.getChild("Station");
|
||||||
|
|
||||||
|
SBBStation startStation = new SBBStation(stationName);
|
||||||
|
startStation.fillFromXML(stationElement);
|
||||||
|
|
||||||
|
return startStation;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Element getResponse(String requestXML) throws IOException, JDOMException {
|
||||||
|
byte[] requestBytes = requestXML.getBytes();
|
||||||
|
String response = new SBBCommandLine().testDL(requestBytes);
|
||||||
|
|
||||||
|
System.out.println("Got response " + response);
|
||||||
|
|
||||||
|
Document doc = new SAXBuilder().build(new StringReader(response));
|
||||||
|
|
||||||
|
//ConRes is the root element of the response.
|
||||||
|
Element rootElement = doc.getRootElement();
|
||||||
|
|
||||||
|
return rootElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void getConnections(SBBStation start, SBBStation end, Date departure) throws IOException, JDOMException {
|
||||||
|
|
||||||
|
String date = new SimpleDateFormat("yyyyMMdd").format(departure);
|
||||||
|
String time = new SimpleDateFormat("HH:mm").format(departure);
|
||||||
|
|
||||||
|
String request = String.format(CONNECTION_QUERY, start.getName(), start.getExternalId(), end.getName(), end.getExternalId(), date, time);
|
||||||
|
|
||||||
|
System.out.println("Request is " + request);
|
||||||
|
//if (request != null) return;
|
||||||
|
|
||||||
|
Element rootElement = getResponse(request);
|
||||||
|
|
||||||
|
Element conResElement = rootElement.getChild("ConRes");
|
||||||
|
|
||||||
|
if (conResElement.getChild("Err") != null) {
|
||||||
|
// We encountered an error, print it out and abort, no more info is included
|
||||||
|
// in the response.
|
||||||
|
|
||||||
|
Element errorElem = conResElement.getChild("Err");
|
||||||
|
System.out.println("Got error code (" + errorElem.getAttributeValue("code") + "): " + errorElem.getAttributeValue("text"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//ConResCtxt is a "Cookie" that has to be sent if we want to "scroll".
|
||||||
|
Element conResCtxtElement = conResElement.getChild("ConResCtxt");
|
||||||
|
|
||||||
|
// ConnectionList contains the list of connections
|
||||||
|
Element connectionListElement = conResElement.getChild("ConnectionList");
|
||||||
|
for (Element elem : connectionListElement.getChildren()) {
|
||||||
|
dumpConnection(elem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void dumpConnection(Element connectionElement) {
|
||||||
|
Element overviewElement = connectionElement.getChild("Overview");
|
||||||
|
Element conSectionListElement = connectionElement.getChild("ConSectionList");
|
||||||
|
|
||||||
|
String time = overviewElement.getChild("Departure").getChild("BasicStop").getChild("Dep").getChild("Time").getValue();
|
||||||
|
String station = overviewElement.getChild("Departure").getChild("BasicStop").getChild("Station").getAttributeValue("name");
|
||||||
|
|
||||||
|
System.out.println();
|
||||||
|
System.out.println();
|
||||||
|
System.out.println("Departure from " + station + " at " + time);
|
||||||
|
|
||||||
|
for (Element elem : conSectionListElement.getChildren()) {
|
||||||
|
|
||||||
|
Element departureElement = elem.getChild("Departure");
|
||||||
|
Element arrivalElement = elem.getChild("Arrival");
|
||||||
|
|
||||||
|
String depName = departureElement.getChild("BasicStop").getChild("Station").getAttributeValue("name");
|
||||||
|
String arrName = arrivalElement.getChild("BasicStop").getChild("Station").getAttributeValue("name");
|
||||||
|
System.out.println("From " + depName + " to " + arrName);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static String getUserAgent() {
|
||||||
|
String str = USER_AGENT;
|
||||||
|
Object[] arrayOfObject = new Object[4];
|
||||||
|
arrayOfObject[0] = "2.3.2";
|
||||||
|
arrayOfObject[1] = "4.1.2";
|
||||||
|
arrayOfObject[2] = "Fusion Cookie";
|
||||||
|
arrayOfObject[3] = "12";
|
||||||
|
return String.format(str, arrayOfObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String testDL(byte[] paramArrayOfByte) throws IOException {
|
||||||
|
DefaultHttpClient localDefaultHttpClient = new DefaultHttpClient();
|
||||||
|
HttpPost localHttpPost = new HttpPost(BASE_URL);
|
||||||
|
BasicHttpEntity localBasicHttpEntity = new BasicHttpEntity();
|
||||||
|
localBasicHttpEntity.setContentType("application/xml");
|
||||||
|
ByteArrayInputStream localByteArrayInputStream = new ByteArrayInputStream(paramArrayOfByte);
|
||||||
|
localBasicHttpEntity.setContent(localByteArrayInputStream);
|
||||||
|
localBasicHttpEntity.setContentLength(paramArrayOfByte.length);
|
||||||
|
localHttpPost.setEntity(localBasicHttpEntity);
|
||||||
|
|
||||||
|
localHttpPost.setHeader("User-Agent", getUserAgent());
|
||||||
|
|
||||||
|
localHttpPost.setHeader("Accept", "application/xml");
|
||||||
|
|
||||||
|
localHttpPost.setHeader("Accept-Language", "FR");
|
||||||
|
|
||||||
|
localHttpPost.getParams().setBooleanParameter("http.protocol.expect-continue", false);
|
||||||
|
localHttpPost.setHeader("Accept-Encoding", "gzip");
|
||||||
|
|
||||||
|
String str1 = null; // No cookies ...
|
||||||
|
if (str1 != null) {
|
||||||
|
localHttpPost.setHeader("Cookie", "AL_LB=" + str1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// No redirect ?
|
||||||
|
//localDefaultHttpClient.setRedirectHandler(EnvironmentUtil.getRedirectHandler());
|
||||||
|
HttpResponse localHttpResponse = localDefaultHttpClient.execute(localHttpPost);
|
||||||
|
int i = localHttpResponse.getStatusLine().getStatusCode();
|
||||||
|
|
||||||
|
InputStream content = localHttpResponse.getEntity().getContent();
|
||||||
|
HttpEntity localHttpEntity = localHttpResponse.getEntity();
|
||||||
|
|
||||||
|
//System.out.println("Got response status " + i + " of size " + localBasicHttpEntity.getContentLength() + " bytes.");
|
||||||
|
|
||||||
|
byte[] arrayOfByte = new byte[1024];
|
||||||
|
InputStream is;
|
||||||
|
if ((localHttpEntity.getContentEncoding() != null) && ("gzip".equals(localHttpEntity.getContentEncoding().getValue()))) {
|
||||||
|
is = new GZIPInputStream(localHttpResponse.getEntity().getContent());
|
||||||
|
} else {
|
||||||
|
is = new BufferedInputStream(localHttpResponse.getEntity().getContent());
|
||||||
|
}
|
||||||
|
|
||||||
|
OutputStream baos = new ByteArrayOutputStream();
|
||||||
|
while (true) {
|
||||||
|
int k = is.read(arrayOfByte, 0, 1024);
|
||||||
|
if (k == -1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
baos.write(arrayOfByte, 0, k);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ((ByteArrayOutputStream) baos).toString();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
50
src/sbbcommandline/objects/SBBStation.java
Normal file
50
src/sbbcommandline/objects/SBBStation.java
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
package sbbcommandline.objects;
|
||||||
|
|
||||||
|
import org.jdom2.Element;
|
||||||
|
|
||||||
|
public class SBBStation {
|
||||||
|
|
||||||
|
/** Name of the station */
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/** Identifier of the station in the HAFAS system */
|
||||||
|
private String externalId;
|
||||||
|
|
||||||
|
/** UNKNOWN */
|
||||||
|
private String externalStationNr;
|
||||||
|
|
||||||
|
/** Always WGS84 */
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
/** GPS Coordinates */
|
||||||
|
private int x;
|
||||||
|
|
||||||
|
/** GPS Coordinates */
|
||||||
|
private int y;
|
||||||
|
|
||||||
|
private final static String ELEMENT_NAME = "Station";
|
||||||
|
|
||||||
|
public SBBStation(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fillFromXML(Element elem) {
|
||||||
|
if (!elem.getName().equals(ELEMENT_NAME)) throw new IllegalArgumentException("XML Element must be " + ELEMENT_NAME);
|
||||||
|
|
||||||
|
this.name = elem.getAttributeValue("name");
|
||||||
|
this.externalId = elem.getAttributeValue("externalId");
|
||||||
|
this.externalStationNr = elem.getAttributeValue("externalStationNr");
|
||||||
|
this.type = elem.getAttributeValue("type");
|
||||||
|
this.x = Integer.parseInt(elem.getAttributeValue("x"));
|
||||||
|
this.y = Integer.parseInt(elem.getAttributeValue("y"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getExternalId() {
|
||||||
|
return externalId;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Reference in a new issue