Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
Main |
|
| 3.0;3 |
1 | /* | |
2 | * Copyright 1999,2004 The Apache Software Foundation. | |
3 | * | |
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 | |
7 | * | |
8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | * | |
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. | |
15 | */ | |
16 | ||
17 | package org.apache.commons.feedparser; | |
18 | ||
19 | import java.io.FileInputStream; | |
20 | import java.io.InputStream; | |
21 | import java.net.URL; | |
22 | ||
23 | import org.apache.commons.feedparser.impl.DebugFeedParserListener; | |
24 | ||
25 | /** | |
26 | * Provides a mechanism to quickly test feed parsing from the command line. | |
27 | * | |
28 | * @author <a href="mailto:burton@apache.org">Kevin A. Burton (burtonator)</a> | |
29 | * @version $Id: Main.java 373614 2006-01-30 22:31:21Z mvdb $ | |
30 | */ | |
31 | 0 | public class Main { |
32 | ||
33 | public static void main( String[] args ) throws Exception { | |
34 | ||
35 | 0 | FeedParser parser = FeedParserFactory.newFeedParser(); |
36 | ||
37 | 0 | FeedParserListener listener = new DebugFeedParserListener(); |
38 | ||
39 | 0 | if ( args.length != 1 ) { |
40 | ||
41 | 0 | System.err.println( "SYNTAX: " + Main.class.getName() + " file|url" ); |
42 | ||
43 | 0 | System.exit( 1 ); |
44 | ||
45 | } | |
46 | ||
47 | 0 | String resource = args[0]; |
48 | ||
49 | 0 | InputStream is = null; |
50 | ||
51 | 0 | if ( resource.startsWith( "http://" ) ) { |
52 | 0 | is = new URL( resource ).openStream(); |
53 | } else { | |
54 | ||
55 | 0 | System.out.println( "Opening from file: " + resource ); |
56 | 0 | is = new FileInputStream( resource ); |
57 | } | |
58 | ||
59 | 0 | parser.parse( listener, is, resource ); |
60 | ||
61 | 0 | } |
62 | ||
63 | } |