• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2010 Google Inc.
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 com.google.doclava;
18 
19 import com.google.doclava.apicheck.ApiCheck;
20 import com.google.doclava.apicheck.ApiInfo;
21 import com.google.doclava.apicheck.ApiParseException;
22 
23 import java.net.MalformedURLException;
24 import java.net.URL;
25 
26 /**
27  * A remote source of documentation that can be linked against. A federated
28  * site represents a library that has packages, classes, and members that may
29  * be referenced or shared across codebases.
30  */
31 public final class FederatedSite {
32   private final String name;
33   private final URL baseUrl;
34   private final ApiInfo apiInfo;
35 
FederatedSite(String name, URL baseUrl)36   public FederatedSite(String name, URL baseUrl) throws ApiParseException {
37     this.name = name;
38     this.baseUrl = baseUrl;
39 
40     try {
41       URL xmlUrl = new URL(baseUrl + "/xml/current.xml");
42       this.apiInfo = new ApiCheck().parseApi(xmlUrl);
43     } catch (MalformedURLException e) {
44       throw new AssertionError(e);
45     }
46   }
47 
48   /**
49    * Constructs a federated site using an api file not contained on
50    * the site itself.
51    */
FederatedSite(String name, URL baseUrl, String api)52   public FederatedSite(String name, URL baseUrl, String api) throws ApiParseException {
53     this.name = name;
54     this.baseUrl = baseUrl;
55     this.apiInfo = new ApiCheck().parseApi(api);
56   }
57 
linkFor(String htmlPage)58   public String linkFor(String htmlPage) {
59     return baseUrl + "/" + htmlPage;
60   }
61 
name()62   public String name() {
63     return name;
64   }
65 
apiInfo()66   public ApiInfo apiInfo() {
67     return apiInfo;
68   }
69 
baseUrl()70   public URL baseUrl() {
71     return baseUrl;
72   }
73 }