OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [classpath/] [tools/] [gnu/] [classpath/] [tools/] [doclets/] [htmldoclet/] [ExternalDocSet.java] - Blame information for rev 779

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 779 jeremybenn
/* gnu.classpath.tools.doclets.htmldoclet.ExternalDocSet
2
   Copyright (C) 2004 Free Software Foundation, Inc.
3
 
4
This file is part of GNU Classpath.
5
 
6
GNU Classpath is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2, or (at your option)
9
any later version.
10
 
11
GNU Classpath is distributed in the hope that it will be useful, but
12
WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
General Public License for more details.
15
 
16
You should have received a copy of the GNU General Public License
17
along with GNU Classpath; see the file COPYING.  If not, write to the
18
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19
02111-1307 USA.
20
 
21
Linking this library statically or dynamically with other modules is
22
making a combined work based on this library.  Thus, the terms and
23
conditions of the GNU General Public License cover the whole
24
combination.
25
 
26
As a special exception, the copyright holders of this library give you
27
permission to link this library with independent modules to produce an
28
executable, regardless of the license terms of these independent
29
modules, and to copy and distribute the resulting executable under
30
terms of your choice, provided that you also meet, for each linked
31
independent module, the terms and conditions of the license of that
32
module.  An independent module is a module which is not derived from
33
or based on this library.  If you modify this library, you may extend
34
this exception to your version of the library, but you are not
35
obligated to do so.  If you do not wish to do so, delete this
36
exception statement from your version. */
37
 
38
package gnu.classpath.tools.doclets.htmldoclet;
39
 
40
import java.io.BufferedReader;
41
import java.io.File;
42
import java.io.FileNotFoundException;
43
import java.io.IOException;
44
import java.io.InputStream;
45
import java.io.InputStreamReader;
46
 
47
import java.net.MalformedURLException;
48
import java.net.URL;
49
 
50
import java.util.HashSet;
51
import java.util.Properties;
52
import java.util.Set;
53
 
54
import com.sun.javadoc.ClassDoc;
55
 
56
public class ExternalDocSet
57
{
58
   private String url;
59
   private String packageListDir;
60
   private URL docSetDirectoryURL;
61
 
62
   public String getPackageListDir()
63
   {
64
      return packageListDir;
65
   }
66
 
67
   public ExternalDocSet(String url,
68
                         String packageListDir)
69
   {
70
      this.url = url;
71
      this.packageListDir = packageListDir;
72
   }
73
 
74
   private Set packageNames = new HashSet();
75
   private boolean javadocCompatible;
76
 
77
   public void load(File targetDirectory)
78
      throws IOException, MalformedURLException
79
   {
80
      if (!url.endsWith("/")) {
81
         url += "/";
82
      }
83
 
84
      this.docSetDirectoryURL = new URL(targetDirectory.toURL(),
85
                                        url);
86
 
87
      URL packageListDirURL;
88
      if (null != packageListDir) {
89
         if (!packageListDir.endsWith("/")) {
90
           packageListDir += "/";
91
         }
92
         packageListDirURL = new URL(new File(System.getProperty("user.dir")).toURL(),
93
                                     packageListDir);
94
      }
95
      else {
96
         packageListDirURL = docSetDirectoryURL;
97
      }
98
 
99
      URL packageListURL = new URL(packageListDirURL,
100
                                    "package-list");
101
      InputStream in = packageListURL.openStream();
102
      if (null != in) {
103
         readPackages(in);
104
         in.close();
105
      }
106
      else {
107
         throw new FileNotFoundException(packageListURL.toString());
108
      }
109
 
110
      URL gjdocPropertiesURL = new URL(packageListDirURL,
111
                                       "gjdoc.properties");
112
      try {
113
          InputStream propertiesIn = gjdocPropertiesURL.openStream();
114
          if (null != in) {
115
              Properties properties = new Properties();
116
              properties.load(propertiesIn);
117
              propertiesIn.close();
118
 
119
              String gjdocCompatProperty = properties.getProperty("gjdoc.compat");
120
              if (null != gjdocCompatProperty) {
121
                  javadocCompatible = "true".equals(properties.getProperty("gjdoc.compat"));
122
              }
123
              else {
124
                  javadocCompatible = true;
125
              }
126
          }
127
          else {
128
              javadocCompatible = true;
129
          }
130
      }
131
      catch (FileNotFoundException e) {
132
          javadocCompatible = true;
133
      }
134
   }
135
 
136
   public String getPackageDocURL(String packageName)
137
   {
138
      try {
139
         URL packageURL = new URL(docSetDirectoryURL,
140
                                  packageName.replace('.', '/'));
141
         return packageURL.toString();
142
      }
143
      catch (MalformedURLException e) {
144
         // This should not happen since we know that packageName is a
145
         // proper Java identifiers, so the resulting URL can't be
146
         // invalid
147
         throw new RuntimeException(e);
148
      }
149
   }
150
 
151
   public String getClassDocURL(String packageName, String typeName)
152
   {
153
      try {
154
         URL fileURL = new URL(docSetDirectoryURL,
155
                               packageName.replace('.', '/') + "/" + typeName + ".html");
156
         return fileURL.toString();
157
      }
158
      catch (MalformedURLException e) {
159
         // This should not happen since we know that packageName and
160
         // typeName are proper Java identifiers, so the resulting URL
161
         // can't be invalid
162
         throw new RuntimeException(e);
163
      }
164
   }
165
 
166
   protected void readPackages(InputStream in)
167
      throws IOException
168
   {
169
      BufferedReader reader
170
         = new BufferedReader(new InputStreamReader(in, "UTF-8"));
171
      String line;
172
      while ((line = reader.readLine()) != null) {
173
         line = line.trim();
174
         packageNames.add(line);
175
      }
176
   }
177
 
178
   public Set getPackageNames()
179
   {
180
      return packageNames;
181
   }
182
 
183
   public boolean isJavadocCompatible()
184
   {
185
      return javadocCompatible;
186
   }
187
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.