Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
PMachine |
|
| 1.0;1 |
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.locate.blogservice; | |
18 | ||
19 | import org.apache.commons.feedparser.FeedParserException; | |
20 | import org.apache.commons.feedparser.locate.*; | |
21 | ||
22 | import java.util.regex.*; | |
23 | ||
24 | /** | |
25 | * Models the PMachine blog service, encapsulating whether a given weblog | |
26 | * is this type of service and where it usually keeps its feeds. | |
27 | * | |
28 | * @author Brad Neuberg, bkn3@columbia.edu | |
29 | */ | |
30 | 0 | public class PMachine extends BlogService { |
31 | ||
32 | /** A pattern used to discover PMachine blogs. */ | |
33 | 0 | private static Pattern pmachinePattern = |
34 | Pattern.compile("pmachine", Pattern.CASE_INSENSITIVE); | |
35 | ||
36 | /** Returns whether we can trust the results of this blog service's | |
37 | * autodiscovery links. For example, TextAmerica returns invalid | |
38 | * autodiscovery results. | |
39 | */ | |
40 | public boolean hasValidAutoDiscovery() { | |
41 | 0 | return true; |
42 | } | |
43 | ||
44 | /** Returns whether we should follow HTTP redirects for this blog service. | |
45 | * Some services don't implement HTTP redirects correctly, while others, | |
46 | * like Xanga, require it. | |
47 | */ | |
48 | public boolean followRedirects() { | |
49 | 0 | return false; |
50 | } | |
51 | ||
52 | /** Determines if the weblog at the given resource and with the given | |
53 | * content is this blog service. | |
54 | * @param resource A full URI to this resource, such as | |
55 | * "http://www.codinginparadise.org". | |
56 | * @param content The full HTML content at the resource's URL. | |
57 | * @throws FeedParserException Thrown if an error occurs while | |
58 | * determining the type of this weblog. | |
59 | */ | |
60 | public boolean isThisService(String resource, String content) | |
61 | throws FeedParserException { | |
62 | 0 | boolean results = false; |
63 | ||
64 | 0 | Matcher pmachineMatcher = pmachinePattern.matcher(resource); |
65 | ||
66 | 0 | results = pmachineMatcher.find(); |
67 | ||
68 | 0 | return results; |
69 | } | |
70 | ||
71 | /** | |
72 | * Returns an array of FeedReferences that contains information on the | |
73 | * usual locations this blog service contains its feed. The feeds should | |
74 | * be ordered by quality, so that higher quality feeds come before lower | |
75 | * quality ones (i.e. you would want to have an Atom FeedReference | |
76 | * object come before an RSS 0.91 FeedReference object in this list). | |
77 | * @param resource A URL to the given weblog that might be used to build | |
78 | * up where feeds are usually located. | |
79 | * @param content The full content of the resource URL, which might | |
80 | * be useful to determine where feeds are usually located. This can be | |
81 | * null. | |
82 | * @throws FeedParserException Thrown if an error occurs while trying | |
83 | * to determine the usual locations of feeds for this service. | |
84 | */ | |
85 | public FeedReference[] getFeedLocations(String resource, | |
86 | String content) | |
87 | throws FeedParserException { | |
88 | 0 | FeedReference pmachineLocations[] = |
89 | { new FeedReference("index.xml", FeedReference.RSS_MEDIA_TYPE) }; | |
90 | ||
91 | 0 | return pmachineLocations; |
92 | } | |
93 | } |