KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > joseki > ping


1 /*
2  * (c) Copyright 2003, 2004 Hewlett-Packard Development Company, LP
3  * [See end of file]
4  */

5
6 package joseki;
7
8 import jena.cmdline.*;
9 import com.hp.hpl.jena.joseki.* ;
10 import com.hp.hpl.jena.rdf.model.* ;
11
12 /** Command line application to issue a ping on a remote model.
13  *
14  * @author Andy Seaborne
15  * @version $Id: ping.java,v 1.2 2004/04/30 14:13:14 andy_seaborne Exp $
16  */

17
18
19 public class ping
20 {
21     public static final String JavaDoc defaultURL = "http://localhost:2020/rdfserver/rdf" ;
22     
23     public static boolean VERBOSE = false ;
24     public static boolean DEBUG = false ;
25     
26     public static void main (String JavaDoc args[])
27     {
28         try {
29             String JavaDoc usageMessage = ping.class.getName()+
30                                     " [--verbose] --model modelURL";
31
32             CommandLine cmd = new CommandLine() ;
33             cmd.setUsage(usageMessage) ;
34
35             ArgDecl verboseDecl = new ArgDecl(false, "-v", "--verbose") ;
36             ArgDecl modelDecl = new ArgDecl(true, "model", "url") ;
37             
38             cmd.add(verboseDecl) ;
39             cmd.add(modelDecl) ;
40             
41             cmd.add("--debug", false) ;
42
43             // No addition arguments after the flags
44
cmd.process(args) ;
45
46             if ( cmd.contains("--debug") )
47                 DEBUG = true ;
48
49             if ( cmd.contains("--help") )
50             {
51                 System.err.println(usageMessage) ;
52                 System.exit(0) ;
53             }
54
55             if ( cmd.contains(verboseDecl) )
56                 VERBOSE = true ;
57             
58                 
59             if ( ! cmd.contains(modelDecl) )
60             {
61                 System.err.println(usageMessage) ;
62                 System.err.println("Required argument: --model") ;
63                 System.exit(8) ;
64             }
65
66             String JavaDoc modelStr = cmd.getArg(modelDecl).getValue() ;
67             
68             HttpPing pingOp = new HttpPing(modelStr) ;
69             Model obj = pingOp.exec() ;
70             
71             //obj.write(System.out, format) ;
72

73         }
74         catch (Exception JavaDoc e)
75         {
76             e.printStackTrace(System.err) ;
77             System.exit(9) ;
78         }
79     }
80 }
81
82 /*
83  * (c) Copyright 2003, 2004 Hewlett-Packard Development Company, LP
84  * All rights reserved.
85  *
86  * Redistribution and use in source and binary forms, with or without
87  * modification, are permitted provided that the following conditions
88  * are met:
89  * 1. Redistributions of source code must retain the above copyright
90  * notice, this list of conditions and the following disclaimer.
91  * 2. Redistributions in binary form must reproduce the above copyright
92  * notice, this list of conditions and the following disclaimer in the
93  * documentation and/or other materials provided with the distribution.
94  * 3. The name of the author may not be used to endorse or promote products
95  * derived from this software without specific prior written permission.
96  *
97  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
98  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
99  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
100  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
101  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
102  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
103  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
104  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
105  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
106  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
107  */

108
Popular Tags