コード例 #1
0
ファイル: DocImpl.java プロジェクト: Quetzaloid/DPJ
 /** Utility for subclasses which read HTML documentation files. */
 String readHTMLDocumentation(InputStream input, String filename) throws IOException {
   int filesize = input.available();
   byte[] filecontents = new byte[filesize];
   input.read(filecontents, 0, filesize);
   input.close();
   String encoding = env.getEncoding();
   String rawDoc =
       (encoding != null) ? new String(filecontents, encoding) : new String(filecontents);
   String upper = null;
   int bodyIdx = rawDoc.indexOf("<body");
   if (bodyIdx == -1) {
     bodyIdx = rawDoc.indexOf("<BODY");
     if (bodyIdx == -1) {
       upper = rawDoc.toUpperCase();
       bodyIdx = upper.indexOf("<BODY");
       if (bodyIdx == -1) {
         env.error(
             SourcePositionImpl.make(filename, Position.NOPOS, null),
             "javadoc.Body_missing_from_html_file");
         return "";
       }
     }
   }
   bodyIdx = rawDoc.indexOf('>', bodyIdx);
   if (bodyIdx == -1) {
     env.error(
         SourcePositionImpl.make(filename, Position.NOPOS, null),
         "javadoc.Body_missing_from_html_file");
     return "";
   }
   ++bodyIdx;
   int endIdx = rawDoc.indexOf("</body", bodyIdx);
   if (endIdx == -1) {
     endIdx = rawDoc.indexOf("</BODY", bodyIdx);
     if (endIdx == -1) {
       if (upper == null) {
         upper = rawDoc.toUpperCase();
       }
       endIdx = upper.indexOf("</BODY", bodyIdx);
       if (endIdx == -1) {
         env.error(
             SourcePositionImpl.make(filename, Position.NOPOS, null),
             "javadoc.End_body_missing_from_html_file");
         return "";
       }
     }
   }
   return rawDoc.substring(bodyIdx, endIdx);
 }
コード例 #2
0
 /** Return the source position of the entity, or null if no position is available. */
 @Override
 public SourcePosition position() {
   if (sym.enclClass().sourcefile == null) return null;
   return SourcePositionImpl.make(
       sym.enclClass().sourcefile, (tree == null) ? 0 : tree.pos, lineMap);
 }