|
Java example source code file (PackageDocImpl.java)
The PackageDocImpl.java Java example source code
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.tools.javadoc;
import java.io.IOException;
import java.io.InputStream;
import javax.tools.FileObject;
import com.sun.javadoc.*;
import com.sun.source.util.TreePath;
import com.sun.tools.javac.code.Attribute;
import com.sun.tools.javac.code.Scope;
import com.sun.tools.javac.code.Symbol.ClassSymbol;
import com.sun.tools.javac.code.Symbol.PackageSymbol;
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
import com.sun.tools.javac.util.List;
import com.sun.tools.javac.util.ListBuffer;
import com.sun.tools.javac.util.Name;
import com.sun.tools.javac.util.Position;
/**
* Represents a java package. Provides access to information
* about the package, the package's comment and tags, and the
* classes in the package.
*
* <p>This is NOT part of any supported API.
* If you write code that depends on this, you do so at your own risk.
* This code and its internal interfaces are subject to change or
* deletion without notice.</b>
*
* @since 1.2
* @author Kaiyang Liu (original)
* @author Robert Field (rewrite)
* @author Neal Gafter (rewrite)
* @author Scott Seligman (package-info.java)
*/
public class PackageDocImpl extends DocImpl implements PackageDoc {
protected PackageSymbol sym;
private JCCompilationUnit tree = null; // for source position
public FileObject docPath = null;
private boolean foundDoc; // found a doc comment in either
// package.html or package-info.java
boolean isIncluded = false; // Set in RootDocImpl.
public boolean setDocPath = false; //Flag to avoid setting doc path multiple times.
/**
* Constructor
*/
public PackageDocImpl(DocEnv env, PackageSymbol sym) {
this(env, sym, null);
}
/**
* Constructor
*/
public PackageDocImpl(DocEnv env, PackageSymbol sym, TreePath treePath) {
super(env, treePath);
this.sym = sym;
this.tree = (treePath == null) ? null : (JCCompilationUnit) treePath.getCompilationUnit();
foundDoc = (documentation != null);
}
void setTree(JCTree tree) {
this.tree = (JCCompilationUnit) tree;
}
public void setTreePath(TreePath treePath) {
super.setTreePath(treePath);
checkDoc();
}
/**
* Do lazy initialization of "documentation" string.
*/
protected String documentation() {
if (documentation != null)
return documentation;
if (docPath != null) {
// read from file
try {
InputStream s = docPath.openInputStream();
documentation = readHTMLDocumentation(s, docPath);
} catch (IOException exc) {
documentation = "";
env.error(null, "javadoc.File_Read_Error", docPath.getName());
}
} else {
// no doc file to be had
documentation = "";
}
return documentation;
}
/**
* Cache of all classes contained in this package, including
* member classes of those classes, and their member classes, etc.
* Includes only those classes at the specified protection level
* and weaker.
*/
private List<ClassDocImpl> allClassesFiltered = null;
/**
* Cache of all classes contained in this package, including
* member classes of those classes, and their member classes, etc.
*/
private List<ClassDocImpl> allClasses = null;
/**
* Return a list of all classes contained in this package, including
* member classes of those classes, and their member classes, etc.
*/
private List<ClassDocImpl> getClasses(boolean filtered) {
if (allClasses != null && !filtered) {
return allClasses;
}
if (allClassesFiltered != null && filtered) {
return allClassesFiltered;
}
ListBuffer<ClassDocImpl> classes = new ListBuffer
Other Java examples (source code examples)Here is a short list of links related to this Java PackageDocImpl.java source code file: |
| ... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.