KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jena > rdfparse


1 /*
2   (c) Copyright 2002, 2003, 2004, 2005 Hewlett-Packard Development Company, LP
3   [See end of file]
4   $Id: rdfparse.java,v 1.6 2005/04/06 08:12:43 chris-dollin Exp $
5 */

6
7 package jena;
8
9 import java.lang.reflect.Constructor JavaDoc;
10
11 import com.hp.hpl.jena.rdf.arp.NTriple;
12 import com.hp.hpl.jena.shared.Command;
13
14 /** A command line interface into ARP.
15  * Creates NTriple's or just error messages.
16  * <pre>
17  * java &lt;class-path&gt; jena.rdfparse ( [ -[xstfu]][ -b xmlBase -[eiw] NNN[,NNN...] ] [ file ] [ url ] )...
18  *
19  * java &lt;class-path&gt; jena.rdfparse --test
20  *
21  * java &lt;class-path&gt; jena.rdfparse --internal-test
22  * </pre>
23  * <p>
24  * &lt;class-path&gt; should contain <code>jena.jar</code>, <code>xerces.jar</code>, <code>junit.jar</code>, and <code>icu4j.jar</code> or equivalents.
25  * </p>
26  * <p>
27  * The last two forms are for testing. <code>--test</code> runs ARP
28  * against the RDF Core Working Group tests found at w3.org.
29  * <code>--internal-test</code> uses a cached copy from within the jena.jar.
30  * </p>
31  * All options, files and URLs can be intemingled in any order.
32  * They are processed from left-to-right.
33  * <dl>
34  * file </dt><dd> Converts (embedded) RDF in XML file into N-triples
35  * </dd><dt>
36  * url </dt><dd> Converts (embedded) RDF from URL into N-triples
37  * </dd><dt>
38  * -b uri </dt><dd> Sets XML Base to the absolute URI.
39  * </dd><dt>
40  * -r </dt><dd> Content is RDF (no embedding, rdf:RDF tag may be omitted).
41  * </dd><dt>
42  * -t </dt><dd> No n-triple output, error checking only.
43  * </dd><dt>
44  * -x </dt><dd> Lax mode - warnings are suppressed.
45  * </dd><dt>
46  * -s </dt><dd> Strict mode - most warnings are errors.
47  * </dd><dt>
48  * -u </dt><dd> Allow unqualified attributes (defaults to warning).
49  * </dd><dt>
50  * -f </dt><dd> All errors are fatal - report first one only.
51  * </dd><dt>
52  * -b url </dt><dd> Sets XML Base to the absolute url.
53  * </dd><dt>
54  * -e NNN[,NNN...]</dt><dd>
55  * Treats numbered warning conditions as errrors.
56  * </dd><dt>
57  * -w NNN[,NNN...]</dt><dd>
58  * Treats numbered error conditions as warnings.
59  * </dd><dt>
60  * -i NNN[,NNN...]
61  * </dt><dd>
62  * Ignores numbered error/warning conditions.
63  * </dl>
64  * @author jjc
65  */

66
67 public class rdfparse {
68
69     /** Either start an RDF/XML to NTriple converter, or run test suite.
70      * @param args The command-line arguments.
71      */

72     public static void main( String JavaDoc[] args ) throws Exception JavaDoc {
73         if (args.length == 1 && (args[0].equals( "--test" ) || args[0].equals( "--internal-test" )))
74             runTests( args[0].equals( "--test" ) );
75         else
76             NTriple.main( args );
77     }
78
79     /**
80          wrapped this way so JUnit not a compile-time requirement.
81     */

82     protected static void runTests( boolean internetTest ) throws Exception JavaDoc {
83         Class JavaDoc rdfparse = Class.forName( "jena.test.rdfparse" );
84         Constructor JavaDoc constructor = rdfparse.getConstructor( new Class JavaDoc[] {boolean.class} );
85         Command c = (Command) constructor.newInstance( new Object JavaDoc[] {new Boolean JavaDoc( internetTest ) } );
86         c.execute();
87 // ARPTests.internet = internetTest;
88
// TestRunner.main( new String[] { "-noloading", ARPTests.class.getName()});
89
}
90 }
91
92 /*
93     (c) Copyright 2002, 2003, 2004, 2005 Hewlett-Packard Development Company, LP
94     All rights reserved.
95
96     Redistribution and use in source and binary forms, with or without
97     modification, are permitted provided that the following conditions
98     are met:
99
100     1. Redistributions of source code must retain the above copyright
101        notice, this list of conditions and the following disclaimer.
102
103     2. Redistributions in binary form must reproduce the above copyright
104        notice, this list of conditions and the following disclaimer in the
105        documentation and/or other materials provided with the distribution.
106
107     3. The name of the author may not be used to endorse or promote products
108        derived from this software without specific prior written permission.
109
110     THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
111     IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
112     OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
113     IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
114     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
115     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
116     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
117     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
118     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
119     THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
120 */

121
Popular Tags