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 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 public String linkFor(String htmlPage) { 49 return baseUrl + "/" + htmlPage; 50 } 51 52 public String name() { 53 return name; 54 } 55 56 public ApiInfo apiInfo() { 57 return apiInfo; 58 } 59 60 public URL baseUrl() { 61 return baseUrl; 62 } 63 }