blob: e904c53eb6953eb7c3e0e85c761f404c67b5f4da [file] [log] [blame]
Ben Dodson920dbbb2010-08-04 15:21:06 -07001/*
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
17package com.google.doclava;
18
19import com.google.doclava.apicheck.ApiCheck;
20import com.google.doclava.apicheck.ApiInfo;
21import com.google.doclava.apicheck.ApiParseException;
22
23import java.net.MalformedURLException;
24import 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 */
31public final class FederatedSite {
32 private final String name;
33 private final URL baseUrl;
34 private final ApiInfo apiInfo;
35
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
Jeff Hamilton1e0d3702012-06-21 04:21:54 -050048 /**
49 * Constructs a federated site using an api file not contained on
50 * the site itself.
51 */
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
Ben Dodson920dbbb2010-08-04 15:21:06 -070058 public String linkFor(String htmlPage) {
59 return baseUrl + "/" + htmlPage;
60 }
61
62 public String name() {
63 return name;
64 }
65
66 public ApiInfo apiInfo() {
67 return apiInfo;
68 }
69
70 public URL baseUrl() {
71 return baseUrl;
72 }
73}