Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
BlogServiceDiscovery |
|
| 2.5;2.5 |
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; | |
18 | ||
19 | import org.apache.commons.feedparser.FeedParserException; | |
20 | import org.apache.commons.feedparser.locate.blogservice.BlogService; | |
21 | import org.apache.commons.feedparser.locate.blogservice.Unknown; | |
22 | ||
23 | /** | |
24 | * Determines what blog provider a given URI is using, | |
25 | * such as whether it is hosted on Blogspot, Radio Userland, etc. | |
26 | * | |
27 | * @author <a href="mailto:bkn3@columbia.edu">Brad Neuberg/a> | |
28 | */ | |
29 | 0 | public class BlogServiceDiscovery { |
30 | ||
31 | public static BlogService discover( String resource ) | |
32 | throws FeedParserException { | |
33 | 0 | return discover(resource, null); |
34 | } | |
35 | ||
36 | public static BlogService discover( String resource, | |
37 | String content ) | |
38 | throws FeedParserException { | |
39 | // Some services, such as AOL LiveJournal, are case sensitive | |
40 | // on their resource names; can't do a toLowerCase. | |
41 | // Brad Neuberg, bkn3@columbia.edu | |
42 | //resource = resource.toLowerCase(); | |
43 | 0 | BlogService[] blogServices = BlogService.getBlogServices(); |
44 | ||
45 | 0 | for (int i = 0; i < blogServices.length; i++) { |
46 | 0 | if (blogServices[i].isThisService(resource, content)) { |
47 | 0 | return blogServices[i]; |
48 | } | |
49 | } | |
50 | ||
51 | 0 | return new Unknown(); |
52 | } | |
53 | } |