file_name stringlengths 6 86 | file_path stringlengths 45 249 | content stringlengths 47 6.26M | file_size int64 47 6.26M | language stringclasses 1 value | extension stringclasses 1 value | repo_name stringclasses 767 values | repo_stars int64 8 14.4k | repo_forks int64 0 1.17k | repo_open_issues int64 0 788 | repo_created_at stringclasses 767 values | repo_pushed_at stringclasses 767 values |
|---|---|---|---|---|---|---|---|---|---|---|---|
Trees.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/source/util/Trees.java | /*
* Copyright (c) 2005, 2011, 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.source.util;
import java.lang.reflect.Method;
import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.AnnotationValue;
import javax.lang.model.element.Element;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.TypeElement;
import javax.lang.model.type.DeclaredType;
import javax.lang.model.type.ErrorType;
import javax.lang.model.type.TypeMirror;
import javax.tools.Diagnostic;
import javax.tools.JavaCompiler.CompilationTask;
import com.sun.source.tree.CatchTree;
import com.sun.source.tree.ClassTree;
import com.sun.source.tree.CompilationUnitTree;
import com.sun.source.tree.MethodTree;
import com.sun.source.tree.Scope;
import com.sun.source.tree.Tree;
/**
* Bridges JSR 199, JSR 269, and the Tree API.
*
* @author Peter von der Ahé
*/
public abstract class Trees {
/**
* Gets a Trees object for a given CompilationTask.
* @param task the compilation task for which to get the Trees object
* @throws IllegalArgumentException if the task does not support the Trees API.
*/
public static Trees instance(CompilationTask task) {
if (!task.getClass().getName().equals("com.sun.tools.javac.api.JavacTaskImpl"))
throw new IllegalArgumentException();
return getJavacTrees(CompilationTask.class, task);
}
/**
* Gets a Trees object for a given ProcessingEnvironment.
* @param env the processing environment for which to get the Trees object
* @throws IllegalArgumentException if the env does not support the Trees API.
*/
public static Trees instance(ProcessingEnvironment env) {
if (!env.getClass().getName().equals("com.sun.tools.javac.processing.JavacProcessingEnvironment"))
throw new IllegalArgumentException();
return getJavacTrees(ProcessingEnvironment.class, env);
}
private static Trees getJavacTrees(Class<?> argType, Object arg) {
try {
ClassLoader cl = arg.getClass().getClassLoader();
Class<?> c = Class.forName("com.sun.tools.javac.api.JavacTrees", false, cl);
argType = Class.forName(argType.getName(), false, cl);
Method m = c.getMethod("instance", new Class<?>[] { argType });
return (Trees) m.invoke(null, new Object[] { arg });
} catch (Throwable e) {
throw new AssertionError(e);
}
}
/**
* Gets a utility object for obtaining source positions.
*/
public abstract SourcePositions getSourcePositions();
/**
* Gets the Tree node for a given Element.
* Returns null if the node can not be found.
*/
public abstract Tree getTree(Element element);
/**
* Gets the ClassTree node for a given TypeElement.
* Returns null if the node can not be found.
*/
public abstract ClassTree getTree(TypeElement element);
/**
* Gets the MethodTree node for a given ExecutableElement.
* Returns null if the node can not be found.
*/
public abstract MethodTree getTree(ExecutableElement method);
/**
* Gets the Tree node for an AnnotationMirror on a given Element.
* Returns null if the node can not be found.
*/
public abstract Tree getTree(Element e, AnnotationMirror a);
/**
* Gets the Tree node for an AnnotationValue for an AnnotationMirror on a given Element.
* Returns null if the node can not be found.
*/
public abstract Tree getTree(Element e, AnnotationMirror a, AnnotationValue v);
/**
* Gets the path to tree node within the specified compilation unit.
*/
public abstract TreePath getPath(CompilationUnitTree unit, Tree node);
/**
* Gets the TreePath node for a given Element.
* Returns null if the node can not be found.
*/
public abstract TreePath getPath(Element e);
/**
* Gets the TreePath node for an AnnotationMirror on a given Element.
* Returns null if the node can not be found.
*/
public abstract TreePath getPath(Element e, AnnotationMirror a);
/**
* Gets the TreePath node for an AnnotationValue for an AnnotationMirror on a given Element.
* Returns null if the node can not be found.
*/
public abstract TreePath getPath(Element e, AnnotationMirror a, AnnotationValue v);
/**
* Gets the Element for the Tree node identified by a given TreePath.
* Returns null if the element is not available.
* @throws IllegalArgumentException is the TreePath does not identify
* a Tree node that might have an associated Element.
*/
public abstract Element getElement(TreePath path);
/**
* Gets the TypeMirror for the Tree node identified by a given TreePath.
* Returns null if the TypeMirror is not available.
* @throws IllegalArgumentException is the TreePath does not identify
* a Tree node that might have an associated TypeMirror.
*/
public abstract TypeMirror getTypeMirror(TreePath path);
/**
* Gets the Scope for the Tree node identified by a given TreePath.
* Returns null if the Scope is not available.
*/
public abstract Scope getScope(TreePath path);
/**
* Gets the doc comment, if any, for the Tree node identified by a given TreePath.
* Returns null if no doc comment was found.
*/
public abstract String getDocComment(TreePath path);
/**
* Checks whether a given type is accessible in a given scope.
* @param scope the scope to be checked
* @param type the type to be checked
* @return true if {@code type} is accessible
*/
public abstract boolean isAccessible(Scope scope, TypeElement type);
/**
* Checks whether the given element is accessible as a member of the given
* type in a given scope.
* @param scope the scope to be checked
* @param member the member to be checked
* @param type the type for which to check if the member is accessible
* @return true if {@code member} is accessible in {@code type}
*/
public abstract boolean isAccessible(Scope scope, Element member, DeclaredType type);
/**
* Gets the original type from the ErrorType object.
* @param errorType The errorType for which we want to get the original type.
* @return javax.lang.model.type.TypeMirror corresponding to the original type, replaced by the ErrorType.
*/
public abstract TypeMirror getOriginalType(ErrorType errorType);
/**
* Prints a message of the specified kind at the location of the
* tree within the provided compilation unit
*
* @param kind the kind of message
* @param msg the message, or an empty string if none
* @param t the tree to use as a position hint
* @param root the compilation unit that contains tree
*/
public abstract void printMessage(Diagnostic.Kind kind, CharSequence msg,
com.sun.source.tree.Tree t,
com.sun.source.tree.CompilationUnitTree root);
/**
* Gets the lub of an exception parameter declared in a catch clause.
* @param tree the tree for the catch clause
* @return The lub of the exception parameter
*/
public abstract TypeMirror getLub(CatchTree tree);
}
| 8,542 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
SimpleTreeVisitor.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/source/util/SimpleTreeVisitor.java | /*
* Copyright (c) 2005, 2011, 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.source.util;
import com.sun.source.tree.*;
/**
* A simple visitor for tree nodes.
*
* @author Peter von der Ahé
* @since 1.6
*/
public class SimpleTreeVisitor <R,P> implements TreeVisitor<R,P> {
protected final R DEFAULT_VALUE;
protected SimpleTreeVisitor() {
DEFAULT_VALUE = null;
}
protected SimpleTreeVisitor(R defaultValue) {
DEFAULT_VALUE = defaultValue;
}
protected R defaultAction(Tree node, P p) {
return DEFAULT_VALUE;
}
public final R visit(Tree node, P p) {
return (node == null) ? null : node.accept(this, p);
}
public final R visit(Iterable<? extends Tree> nodes, P p) {
R r = null;
if (nodes != null)
for (Tree node : nodes)
r = visit(node, p);
return r;
}
public R visitCompilationUnit(CompilationUnitTree node, P p) {
return defaultAction(node, p);
}
public R visitImport(ImportTree node, P p) {
return defaultAction(node, p);
}
public R visitClass(ClassTree node, P p) {
return defaultAction(node, p);
}
public R visitMethod(MethodTree node, P p) {
return defaultAction(node, p);
}
public R visitVariable(VariableTree node, P p) {
return defaultAction(node, p);
}
public R visitEmptyStatement(EmptyStatementTree node, P p) {
return defaultAction(node, p);
}
public R visitBlock(BlockTree node, P p) {
return defaultAction(node, p);
}
public R visitDoWhileLoop(DoWhileLoopTree node, P p) {
return defaultAction(node, p);
}
public R visitWhileLoop(WhileLoopTree node, P p) {
return defaultAction(node, p);
}
public R visitForLoop(ForLoopTree node, P p) {
return defaultAction(node, p);
}
public R visitEnhancedForLoop(EnhancedForLoopTree node, P p) {
return defaultAction(node, p);
}
public R visitLabeledStatement(LabeledStatementTree node, P p) {
return defaultAction(node, p);
}
public R visitSwitch(SwitchTree node, P p) {
return defaultAction(node, p);
}
public R visitCase(CaseTree node, P p) {
return defaultAction(node, p);
}
public R visitSynchronized(SynchronizedTree node, P p) {
return defaultAction(node, p);
}
public R visitTry(TryTree node, P p) {
return defaultAction(node, p);
}
public R visitCatch(CatchTree node, P p) {
return defaultAction(node, p);
}
public R visitConditionalExpression(ConditionalExpressionTree node, P p) {
return defaultAction(node, p);
}
public R visitIf(IfTree node, P p) {
return defaultAction(node, p);
}
public R visitExpressionStatement(ExpressionStatementTree node, P p) {
return defaultAction(node, p);
}
public R visitBreak(BreakTree node, P p) {
return defaultAction(node, p);
}
public R visitContinue(ContinueTree node, P p) {
return defaultAction(node, p);
}
public R visitReturn(ReturnTree node, P p) {
return defaultAction(node, p);
}
public R visitThrow(ThrowTree node, P p) {
return defaultAction(node, p);
}
public R visitAssert(AssertTree node, P p) {
return defaultAction(node, p);
}
public R visitMethodInvocation(MethodInvocationTree node, P p) {
return defaultAction(node, p);
}
public R visitNewClass(NewClassTree node, P p) {
return defaultAction(node, p);
}
public R visitNewArray(NewArrayTree node, P p) {
return defaultAction(node, p);
}
public R visitParenthesized(ParenthesizedTree node, P p) {
return defaultAction(node, p);
}
public R visitAssignment(AssignmentTree node, P p) {
return defaultAction(node, p);
}
public R visitCompoundAssignment(CompoundAssignmentTree node, P p) {
return defaultAction(node, p);
}
public R visitUnary(UnaryTree node, P p) {
return defaultAction(node, p);
}
public R visitBinary(BinaryTree node, P p) {
return defaultAction(node, p);
}
public R visitTypeCast(TypeCastTree node, P p) {
return defaultAction(node, p);
}
public R visitInstanceOf(InstanceOfTree node, P p) {
return defaultAction(node, p);
}
public R visitArrayAccess(ArrayAccessTree node, P p) {
return defaultAction(node, p);
}
public R visitMemberSelect(MemberSelectTree node, P p) {
return defaultAction(node, p);
}
public R visitIdentifier(IdentifierTree node, P p) {
return defaultAction(node, p);
}
public R visitLiteral(LiteralTree node, P p) {
return defaultAction(node, p);
}
public R visitPrimitiveType(PrimitiveTypeTree node, P p) {
return defaultAction(node, p);
}
public R visitArrayType(ArrayTypeTree node, P p) {
return defaultAction(node, p);
}
public R visitParameterizedType(ParameterizedTypeTree node, P p) {
return defaultAction(node, p);
}
public R visitUnionType(UnionTypeTree node, P p) {
return defaultAction(node, p);
}
public R visitTypeParameter(TypeParameterTree node, P p) {
return defaultAction(node, p);
}
public R visitWildcard(WildcardTree node, P p) {
return defaultAction(node, p);
}
public R visitModifiers(ModifiersTree node, P p) {
return defaultAction(node, p);
}
public R visitAnnotation(AnnotationTree node, P p) {
return defaultAction(node, p);
}
public R visitErroneous(ErroneousTree node, P p) {
return defaultAction(node, p);
}
public R visitOther(Tree node, P p) {
return defaultAction(node, p);
}
}
| 7,038 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
SourcePositions.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/source/util/SourcePositions.java | /*
* Copyright (c) 2005, 2006, 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.source.util;
import com.sun.source.tree.*;
/**
* Provides methods to obtain the position of a Tree within a CompilationUnit.
* A position is defined as a simple character offset from the start of a
* CompilationUnit where the first character is at offset 0.
*
* @author Peter von der Ahé
* @since 1.6
*/
public interface SourcePositions {
/**
* Gets the starting position of tree within file. If tree is not found within
* file, or if the starting position is not available,
* return {@link javax.tools.Diagnostic#NOPOS}.
* The returned position must be at the start of the yield of this tree, that
* is for any sub-tree of this tree, the following must hold:
*
* <p>
* {@code tree.getStartPosition() <= subtree.getStartPosition()} or <br>
* {@code tree.getStartPosition() == NOPOS} or <br>
* {@code subtree.getStartPosition() == NOPOS}
* </p>
*
* @param file CompilationUnit in which to find tree.
* @param tree tree for which a position is sought.
* @return the start position of tree.
*/
long getStartPosition(CompilationUnitTree file, Tree tree);
/**
* Gets the ending position of tree within file. If tree is not found within
* file, or if the starting position is not available,
* return {@link javax.tools.Diagnostic#NOPOS}.
* The returned position must be at the end of the yield of this tree,
* that is for any sub-tree of this tree, the following must hold:
*
* <p>
* {@code tree.getEndPosition() >= subtree.getEndPosition()} or <br>
* {@code tree.getEndPosition() == NOPOS} or <br>
* {@code subtree.getEndPosition() == NOPOS}
* </p>
*
* In addition, the following must hold:
*
* <p>
* {@code tree.getStartPosition() <= tree.getEndPosition()} or <br>
* {@code tree.getStartPosition() == NOPOS} or <br>
* {@code tree.getEndPosition() == NOPOS}
* </p>
*
* @param file CompilationUnit in which to find tree.
* @param tree tree for which a position is sought.
* @return the end position of tree.
*/
long getEndPosition(CompilationUnitTree file, Tree tree);
}
| 3,435 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
TreePath.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/source/util/TreePath.java | /*
* Copyright (c) 2006, 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.source.util;
import com.sun.source.tree.*;
import java.util.Iterator;
/**
* A path of tree nodes, typically used to represent the sequence of ancestor
* nodes of a tree node up to the top level CompilationUnitTree node.
*
* @author Jonathan Gibbons
* @since 1.6
*/
public class TreePath implements Iterable<Tree> {
/**
* Gets a tree path for a tree node within a compilation unit.
* @return null if the node is not found
*/
public static TreePath getPath(CompilationUnitTree unit, Tree target) {
return getPath(new TreePath(unit), target);
}
/**
* Gets a tree path for a tree node within a subtree identified by a TreePath object.
* @return null if the node is not found
*/
public static TreePath getPath(TreePath path, Tree target) {
path.getClass();
target.getClass();
class Result extends Error {
static final long serialVersionUID = -5942088234594905625L;
TreePath path;
Result(TreePath path) {
this.path = path;
}
}
class PathFinder extends TreePathScanner<TreePath,Tree> {
public TreePath scan(Tree tree, Tree target) {
if (tree == target)
throw new Result(new TreePath(getCurrentPath(), target));
return super.scan(tree, target);
}
}
try {
new PathFinder().scan(path, target);
} catch (Result result) {
return result.path;
}
return null;
}
/**
* Creates a TreePath for a root node.
*/
public TreePath(CompilationUnitTree t) {
this(null, t);
}
/**
* Creates a TreePath for a child node.
*/
public TreePath(TreePath p, Tree t) {
if (t.getKind() == Tree.Kind.COMPILATION_UNIT) {
compilationUnit = (CompilationUnitTree) t;
parent = null;
}
else {
compilationUnit = p.compilationUnit;
parent = p;
}
leaf = t;
}
/**
* Get the compilation unit associated with this path.
*/
public CompilationUnitTree getCompilationUnit() {
return compilationUnit;
}
/**
* Get the leaf node for this path.
*/
public Tree getLeaf() {
return leaf;
}
/**
* Get the path for the enclosing node, or null if there is no enclosing node.
*/
public TreePath getParentPath() {
return parent;
}
public Iterator<Tree> iterator() {
return new Iterator<Tree>() {
public boolean hasNext() {
return next != null;
}
public Tree next() {
Tree t = next.leaf;
next = next.parent;
return t;
}
public void remove() {
throw new UnsupportedOperationException();
}
private TreePath next = TreePath.this;
};
}
private CompilationUnitTree compilationUnit;
private Tree leaf;
private TreePath parent;
}
| 4,338 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
JavacTask.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/source/util/JavacTask.java | /*
* Copyright (c) 2005, 2006, 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.source.util;
import com.sun.source.tree.CompilationUnitTree;
import com.sun.source.tree.Tree;
import java.io.IOException;
import javax.lang.model.element.Element;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
import javax.tools.JavaCompiler.CompilationTask;
import javax.tools.JavaFileObject;
/**
* Provides access to functionality specific to the JDK Java Compiler, javac.
*
* @author Peter von der Ahé
* @author Jonathan Gibbons
* @since 1.6
*/
public abstract class JavacTask implements CompilationTask {
/**
* Parse the specified files returning a list of abstract syntax trees.
*
* @return a list of abstract syntax trees
* @throws IOException if an unhandled I/O error occurred in the compiler.
*/
public abstract Iterable<? extends CompilationUnitTree> parse()
throws IOException;
/**
* Complete all analysis.
*
* @return a list of elements that were analyzed
* @throws IOException if an unhandled I/O error occurred in the compiler.
*/
public abstract Iterable<? extends Element> analyze() throws IOException;
/**
* Generate code.
*
* @return a list of files that were generated
* @throws IOException if an unhandled I/O error occurred in the compiler.
*/
public abstract Iterable<? extends JavaFileObject> generate() throws IOException;
/**
* The specified listener will receive events describing the progress of
* this compilation task.
*/
public abstract void setTaskListener(TaskListener taskListener);
/**
* Get a type mirror of the tree node determined by the specified path.
*/
public abstract TypeMirror getTypeMirror(Iterable<? extends Tree> path);
/**
* Get a utility object for dealing with program elements.
*/
public abstract Elements getElements();
/**
* Get a utility object for dealing with type mirrors.
*/
public abstract Types getTypes();
}
| 3,273 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
TreePathScanner.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/source/util/TreePathScanner.java | /*
* Copyright (c) 2006, 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.source.util;
import com.sun.source.tree.*;
/**
* A TreeVisitor that visits all the child tree nodes, and provides
* support for maintaining a path for the parent nodes.
* To visit nodes of a particular type, just override the
* corresponding visitorXYZ method.
* Inside your method, call super.visitXYZ to visit descendant
* nodes.
*
* @author Jonathan Gibbons
* @since 1.6
*/
public class TreePathScanner<R, P> extends TreeScanner<R, P> {
/**
* Scan a tree from a position identified by a TreePath.
*/
public R scan(TreePath path, P p) {
this.path = path;
try {
return path.getLeaf().accept(this, p);
} finally {
this.path = null;
}
}
/**
* Scan a single node.
* The current path is updated for the duration of the scan.
*/
@Override
public R scan(Tree tree, P p) {
if (tree == null)
return null;
TreePath prev = path;
path = new TreePath(path, tree);
try {
return tree.accept(this, p);
} finally {
path = prev;
}
}
/**
* Get the current path for the node, as built up by the currently
* active set of scan calls.
*/
public TreePath getCurrentPath() {
return path;
}
private TreePath path;
}
| 2,566 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
TaskEvent.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/source/util/TaskEvent.java | /*
* Copyright (c) 2005, 2006, 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.source.util;
import com.sun.source.tree.CompilationUnitTree;
import javax.lang.model.element.TypeElement;
import javax.tools.JavaFileObject;
/**
* Provides details about work that has been done by the JDK Java Compiler, javac.
*
* @author Jonathan Gibbons
* @since 1.6
*/
public final class TaskEvent
{
/**
* Kind of task event.
* @since 1.6
*/
public enum Kind {
/**
* For events related to the parsing of a file.
*/
PARSE,
/**
* For events relating to elements being entered.
**/
ENTER,
/**
* For events relating to elements being analyzed for errors.
**/
ANALYZE,
/**
* For events relating to class files being generated.
**/
GENERATE,
/**
* For events relating to overall annotaion processing.
**/
ANNOTATION_PROCESSING,
/**
* For events relating to an individual annotation processing round.
**/
ANNOTATION_PROCESSING_ROUND
};
public TaskEvent(Kind kind) {
this(kind, null, null, null);
}
public TaskEvent(Kind kind, JavaFileObject sourceFile) {
this(kind, sourceFile, null, null);
}
public TaskEvent(Kind kind, CompilationUnitTree unit) {
this(kind, unit.getSourceFile(), unit, null);
}
public TaskEvent(Kind kind, CompilationUnitTree unit, TypeElement clazz) {
this(kind, unit.getSourceFile(), unit, clazz);
}
private TaskEvent(Kind kind, JavaFileObject file, CompilationUnitTree unit, TypeElement clazz) {
this.kind = kind;
this.file = file;
this.unit = unit;
this.clazz = clazz;
}
public Kind getKind() {
return kind;
}
public JavaFileObject getSourceFile() {
return file;
}
public CompilationUnitTree getCompilationUnit() {
return unit;
}
public TypeElement getTypeElement() {
return clazz;
}
public String toString() {
return "TaskEvent["
+ kind + ","
+ file + ","
// the compilation unit is identified by the file
+ clazz + "]";
}
private Kind kind;
private JavaFileObject file;
private CompilationUnitTree unit;
private TypeElement clazz;
}
| 3,581 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Processor.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/annotation/processing/Processor.java | /*
* Copyright (c) 2005, 2006, 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 javax.annotation.processing;
import java.util.Set;
import javax.lang.model.element.*;
import javax.lang.model.SourceVersion;
/**
* The interface for an annotation processor.
*
* <p>Annotation processing happens in a sequence of {@linkplain
* javax.annotation.processing.RoundEnvironment rounds}. On each
* round, a processor may be asked to {@linkplain #process process} a
* subset of the annotations found on the source and class files
* produced by a prior round. The inputs to the first round of
* processing are the initial inputs to a run of the tool; these
* initial inputs can be regarded as the output of a virtual zeroth
* round of processing. If a processor was asked to process on a
* given round, it will be asked to process on subsequent rounds,
* including the last round, even if there are no annotations for it
* to process. The tool infrastructure may also ask a processor to
* process files generated implicitly by the tool's operation.
*
* <p> Each implementation of a {@code Processor} must provide a
* public no-argument constructor to be used by tools to instantiate
* the processor. The tool infrastructure will interact with classes
* implementing this interface as follows:
*
* <ol>
*
* <li>If an existing {@code Processor} object is not being used, to
* create an instance of a processor the tool calls the no-arg
* constructor of the processor class.
*
* <li>Next, the tool calls the {@link #init init} method with
* an appropriate {@code ProcessingEnvironment}.
*
* <li>Afterwards, the tool calls {@link #getSupportedAnnotationTypes
* getSupportedAnnotationTypes}, {@link #getSupportedOptions
* getSupportedOptions}, and {@link #getSupportedSourceVersion
* getSupportedSourceVersion}. These methods are only called once per
* run, not on each round.
*
* <li>As appropriate, the tool calls the {@link #process process}
* method on the {@code Processor} object; a new {@code Processor}
* object is <em>not</em> created for each round.
*
* </ol>
*
* If a processor object is created and used without the above
* protocol being followed, then the processor's behavior is not
* defined by this interface specification.
*
* <p> The tool uses a <i>discovery process</i> to find annotation
* processors and decide whether or not they should be run. By
* configuring the tool, the set of potential processors can be
* controlled. For example, for a {@link javax.tools.JavaCompiler
* JavaCompiler} the list of candidate processors to run can be
* {@linkplain javax.tools.JavaCompiler.CompilationTask#setProcessors
* set directly} or controlled by a {@linkplain
* javax.tools.StandardLocation#ANNOTATION_PROCESSOR_PATH search path}
* used for a {@linkplain java.util.ServiceLoader service-style}
* lookup. Other tool implementations may have different
* configuration mechanisms, such as command line options; for
* details, refer to the particular tool's documentation. Which
* processors the tool asks to {@linkplain #process run} is a function
* of what annotations are present on the {@linkplain
* RoundEnvironment#getRootElements root elements}, what {@linkplain
* #getSupportedAnnotationTypes annotation types a processor
* processes}, and whether or not a processor {@linkplain #process
* claims the annotations it processes}. A processor will be asked to
* process a subset of the annotation types it supports, possibly an
* empty set.
*
* For a given round, the tool computes the set of annotation types on
* the root elements. If there is at least one annotation type
* present, as processors claim annotation types, they are removed
* from the set of unmatched annotations. When the set is empty or no
* more processors are available, the round has run to completion. If
* there are no annotation types present, annotation processing still
* occurs but only <i>universal processors</i> which support
* processing {@code "*"} can claim the (empty) set of annotation
* types.
*
* <p>Note that if a processor supports {@code "*"} and returns {@code
* true}, all annotations are claimed. Therefore, a universal
* processor being used to, for example, implement additional validity
* checks should return {@code false} so as to not prevent other such
* checkers from being able to run.
*
* <p>If a processor throws an uncaught exception, the tool may cease
* other active annotation processors. If a processor raises an
* error, the current round will run to completion and the subsequent
* round will indicate an {@linkplain RoundEnvironment#errorRaised
* error was raised}. Since annotation processors are run in a
* cooperative environment, a processor should throw an uncaught
* exception only in situations where no error recovery or reporting
* is feasible.
*
* <p>The tool environment is not required to support annotation
* processors that access environmental resources, either {@linkplain
* RoundEnvironment per round} or {@linkplain ProcessingEnvironment
* cross-round}, in a multi-threaded fashion.
*
* <p>If the methods that return configuration information about the
* annotation processor return {@code null}, return other invalid
* input, or throw an exception, the tool infrastructure must treat
* this as an error condition.
*
* <p>To be robust when running in different tool implementations, an
* annotation processor should have the following properties:
*
* <ol>
*
* <li>The result of processing a given input is not a function of the presence or absence
* of other inputs (orthogonality).
*
* <li>Processing the same input produces the same output (consistency).
*
* <li>Processing input <i>A</i> followed by processing input <i>B</i>
* is equivalent to processing <i>B</i> then <i>A</i>
* (commutativity)
*
* <li>Processing an input does not rely on the presence of the output
* of other annotation processors (independence)
*
* </ol>
*
* <p>The {@link Filer} interface discusses restrictions on how
* processors can operate on files.
*
* <p>Note that implementors of this interface may find it convenient
* to extend {@link AbstractProcessor} rather than implementing this
* interface directly.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @since 1.6
*/
public interface Processor {
/**
* Returns the options recognized by this processor. An
* implementation of the processing tool must provide a way to
* pass processor-specific options distinctly from options passed
* to the tool itself, see {@link ProcessingEnvironment#getOptions
* getOptions}.
*
* <p>Each string returned in the set must be a period separated
* sequence of {@linkplain
* javax.lang.model.SourceVersion#isIdentifier identifiers}:
*
* <blockquote>
* <dl>
* <dt><i>SupportedOptionString:</i>
* <dd><i>Identifiers</i>
* <p>
* <dt><i>Identifiers:</i>
* <dd> <i>Identifier</i>
* <dd> <i>Identifier</i> {@code .} <i>Identifiers</i>
* <p>
* <dt><i>Identifier:</i>
* <dd>Syntactic identifier, including keywords and literals
* </dl>
* </blockquote>
*
* <p> A tool might use this information to determine if any
* options provided by a user are unrecognized by any processor,
* in which case it may wish to report a warning.
*
* @return the options recognized by this processor or an
* empty collection if none
* @see javax.annotation.processing.SupportedOptions
*/
Set<String> getSupportedOptions();
/**
* Returns the names of the annotation types supported by this
* processor. An element of the result may be the canonical
* (fully qualified) name of a supported annotation type.
* Alternately it may be of the form "<tt><i>name</i>.*</tt>"
* representing the set of all annotation types with canonical
* names beginning with "<tt><i>name.</i></tt>". Finally, {@code
* "*"} by itself represents the set of all annotation types,
* including the empty set. Note that a processor should not
* claim {@code "*"} unless it is actually processing all files;
* claiming unnecessary annotations may cause a performance
* slowdown in some environments.
*
* <p>Each string returned in the set must be accepted by the
* following grammar:
*
* <blockquote>
* <dl>
* <dt><i>SupportedAnnotationTypeString:</i>
* <dd><i>TypeName</i> <i>DotStar</i><sub><i>opt</i></sub>
* <dd><tt>*</tt>
* <p>
* <dt><i>DotStar:</i>
* <dd><tt>.</tt> <tt>*</tt>
* </dl>
* </blockquote>
*
* where <i>TypeName</i> is as defined in
* <cite>The Java™ Language Specification</cite>.
*
* @return the names of the annotation types supported by this processor
* @see javax.annotation.processing.SupportedAnnotationTypes
* @jls 3.8 Identifiers
* @jls 6.5.5 Meaning of Type Names
*/
Set<String> getSupportedAnnotationTypes();
/**
* Returns the latest source version supported by this annotation
* processor.
*
* @return the latest source version supported by this annotation
* processor.
* @see javax.annotation.processing.SupportedSourceVersion
* @see ProcessingEnvironment#getSourceVersion
*/
SourceVersion getSupportedSourceVersion();
/**
* Initializes the processor with the processing environment.
*
* @param processingEnv environment for facilities the tool framework
* provides to the processor
*/
void init(ProcessingEnvironment processingEnv);
/**
* Processes a set of annotation types on type elements
* originating from the prior round and returns whether or not
* these annotations are claimed by this processor. If {@code
* true} is returned, the annotations are claimed and subsequent
* processors will not be asked to process them; if {@code false}
* is returned, the annotations are unclaimed and subsequent
* processors may be asked to process them. A processor may
* always return the same boolean value or may vary the result
* based on chosen criteria.
*
* <p>The input set will be empty if the processor supports {@code
* "*"} and the root elements have no annotations. A {@code
* Processor} must gracefully handle an empty set of annotations.
*
* @param annotations the annotation types requested to be processed
* @param roundEnv environment for information about the current and prior round
* @return whether or not the set of annotations are claimed by this processor
*/
boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv);
/**
* Returns to the tool infrastructure an iterable of suggested
* completions to an annotation. Since completions are being asked
* for, the information provided about the annotation may be
* incomplete, as if for a source code fragment. A processor may
* return an empty iterable. Annotation processors should focus
* their efforts on providing completions for annotation members
* with additional validity constraints known to the processor, for
* example an {@code int} member whose value should lie between 1
* and 10 or a string member that should be recognized by a known
* grammar, such as a regular expression or a URL.
*
* <p>Since incomplete programs are being modeled, some of the
* parameters may only have partial information or may be {@code
* null}. At least one of {@code element} and {@code userText}
* must be non-{@code null}. If {@code element} is non-{@code
* null}, {@code annotation} and {@code member} may be {@code
* null}. Processors may not throw a {@code NullPointerException}
* if some parameters are {@code null}; if a processor has no
* completions to offer based on the provided information, an
* empty iterable can be returned. The processor may also return
* a single completion with an empty value string and a message
* describing why there are no completions.
*
* <p>Completions are informative and may reflect additional
* validity checks performed by annotation processors. For
* example, consider the simple annotation:
*
* <blockquote>
* <pre>
* @MersennePrime {
* int value();
* }
* </pre>
* </blockquote>
*
* (A Mersenne prime is prime number of the form
* 2<sup><i>n</i></sup> - 1.) Given an {@code AnnotationMirror}
* for this annotation type, a list of all such primes in the
* {@code int} range could be returned without examining any other
* arguments to {@code getCompletions}:
*
* <blockquote>
* <pre>
* import static javax.annotation.processing.Completions.*;
* ...
* return Arrays.asList({@link Completions#of(String) of}("3"),
* of("7"),
* of("31"),
* of("127"),
* of("8191"),
* of("131071"),
* of("524287"),
* of("2147483647"));
* </pre>
* </blockquote>
*
* A more informative set of completions would include the number
* of each prime:
*
* <blockquote>
* <pre>
* return Arrays.asList({@link Completions#of(String, String) of}("3", "M2"),
* of("7", "M3"),
* of("31", "M5"),
* of("127", "M7"),
* of("8191", "M13"),
* of("131071", "M17"),
* of("524287", "M19"),
* of("2147483647", "M31"));
* </pre>
* </blockquote>
*
* However, if the {@code userText} is available, it can be checked
* to see if only a subset of the Mersenne primes are valid. For
* example, if the user has typed
*
* <blockquote>
* <code>
* @MersennePrime(1
* </code>
* </blockquote>
*
* the value of {@code userText} will be {@code "1"}; and only
* two of the primes are possible completions:
*
* <blockquote>
* <pre>
* return Arrays.asList(of("127", "M7"),
* of("131071", "M17"));
* </pre>
* </blockquote>
*
* Sometimes no valid completion is possible. For example, there
* is no in-range Mersenne prime starting with 9:
*
* <blockquote>
* <code>
* @MersennePrime(9
* </code>
* </blockquote>
*
* An appropriate response in this case is to either return an
* empty list of completions,
*
* <blockquote>
* <pre>
* return Collections.emptyList();
* </pre>
* </blockquote>
*
* or a single empty completion with a helpful message
*
* <blockquote>
* <pre>
* return Arrays.asList(of("", "No in-range Mersenne primes start with 9"));
* </pre>
* </blockquote>
*
* @param element the element being annotated
* @param annotation the (perhaps partial) annotation being
* applied to the element
* @param member the annotation member to return possible completions for
* @param userText source code text to be completed
*
* @return suggested completions to the annotation
*/
Iterable<? extends Completion> getCompletions(Element element,
AnnotationMirror annotation,
ExecutableElement member,
String userText);
}
| 17,361 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
ProcessingEnvironment.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/annotation/processing/ProcessingEnvironment.java | /*
* Copyright (c) 2005, 2006, 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 javax.annotation.processing;
import java.util.Map;
import java.util.List;
import java.util.Locale;
import javax.lang.model.SourceVersion;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
import java.io.File;
/**
* An annotation processing tool framework will {@linkplain
* Processor#init provide an annotation processor with an object
* implementing this interface} so the processor can use facilities
* provided by the framework to write new files, report error
* messages, and find other utilities.
*
* <p>Third parties may wish to provide value-add wrappers around the
* facility objects from this interface, for example a {@code Filer}
* extension that allows multiple processors to coordinate writing out
* a single source file. To enable this, for processors running in a
* context where their side effects via the API could be visible to
* each other, the tool infrastructure must provide corresponding
* facility objects that are {@code .equals}, {@code Filer}s that are
* {@code .equals}, and so on. In addition, the tool invocation must
* be able to be configured such that from the perspective of the
* running annotation processors, at least the chosen subset of helper
* classes are viewed as being loaded by the same class loader.
* (Since the facility objects manage shared state, the implementation
* of a wrapper class must know whether or not the same base facility
* object has been wrapped before.)
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @since 1.6
*/
public interface ProcessingEnvironment {
/**
* Returns the processor-specific options passed to the annotation
* processing tool. Options are returned in the form of a map from
* option name to option value. For an option with no value, the
* corresponding value in the map is {@code null}.
*
* <p>See documentation of the particular tool infrastructure
* being used for details on how to pass in processor-specific
* options. For example, a command-line implementation may
* distinguish processor-specific options by prefixing them with a
* known string like {@code "-A"}; other tool implementations may
* follow different conventions or provide alternative mechanisms.
* A given implementation may also provide implementation-specific
* ways of finding options passed to the tool in addition to the
* processor-specific options.
*
* @return the processor-specific options passed to the tool
*/
Map<String,String> getOptions();
/**
* Returns the messager used to report errors, warnings, and other
* notices.
*
* @return the messager
*/
Messager getMessager();
/**
* Returns the filer used to create new source, class, or auxiliary
* files.
*
* @return the filer
*/
Filer getFiler();
/**
* Returns an implementation of some utility methods for
* operating on elements
*
* @return element utilities
*/
Elements getElementUtils();
/**
* Returns an implementation of some utility methods for
* operating on types.
*
* @return type utilities
*/
Types getTypeUtils();
/**
* Returns the source version that any generated {@linkplain
* Filer#createSourceFile source} and {@linkplain
* Filer#createClassFile class} files should conform to.
*
* @return the source version to which generated source and class
* files should conform to
* @see Processor#getSupportedSourceVersion
*/
SourceVersion getSourceVersion();
/**
* Returns the current locale or {@code null} if no locale is in
* effect. The locale can be be used to provide localized
* {@linkplain Messager messages}.
*
* @return the current locale or {@code null} if no locale is in
* effect
*/
Locale getLocale();
}
| 5,200 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
package-info.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/annotation/processing/package-info.java | /*
* Copyright (c) 2005, 2006, 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.
*/
/**
* Facilities for declaring annotation processors and for
* allowing annotation processors to communicate with an annotation processing
* tool environment.
*
* <p> Unless otherwise specified in a particular implementation, the
* collections returned by methods in this package should be expected
* to be unmodifiable by the caller and unsafe for concurrent access.
*
* <p> Unless otherwise specified, methods in this package will throw
* a {@code NullPointerException} if given a {@code null} argument.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @since 1.6
*/
package javax.annotation.processing;
| 1,877 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Filer.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/annotation/processing/Filer.java | /*
* Copyright (c) 2005, 2006, 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 javax.annotation.processing;
import javax.tools.JavaFileManager;
import javax.tools.*;
import javax.lang.model.element.Element;
import java.io.IOException;
/**
* This interface supports the creation of new files by an annotation
* processor. Files created in this way will be known to the
* annotation processing tool implementing this interface, better
* enabling the tool to manage them. Source and class files so
* created will be {@linkplain RoundEnvironment#getRootElements
* considered for processing} by the tool in a subsequent {@linkplain
* RoundEnvironment round of processing} after the {@code close}
* method has been called on the {@code Writer} or {@code
* OutputStream} used to write the contents of the file.
*
* Three kinds of files are distinguished: source files, class files,
* and auxiliary resource files.
*
* <p> There are two distinguished supported locations (subtrees
* within the logical file system) where newly created files are
* placed: one for {@linkplain
* javax.tools.StandardLocation#SOURCE_OUTPUT new source files}, and
* one for {@linkplain javax.tools.StandardLocation#CLASS_OUTPUT new
* class files}. (These might be specified on a tool's command line,
* for example, using flags such as {@code -s} and {@code -d}.) The
* actual locations for new source files and new class files may or
* may not be distinct on a particular run of the tool. Resource
* files may be created in either location. The methods for reading
* and writing resources take a relative name argument. A relative
* name is a non-null, non-empty sequence of path segments separated
* by {@code '/'}; {@code '.'} and {@code '..'} are invalid path
* segments. A valid relative name must match the
* "path-rootless" rule of <a
* href="http://www.ietf.org/rfc/rfc3986.txt">RFC 3986</a>, section
* 3.3.
*
* <p>The file creation methods take a variable number of arguments to
* allow the <em>originating elements</em> to be provided as hints to
* the tool infrastructure to better manage dependencies. The
* originating elements are the types or packages (representing {@code
* package-info} files) which caused an annotation processor to
* attempt to create a new file. For example, if an annotation
* processor tries to create a source file, {@code
* GeneratedFromUserSource}, in response to processing
*
* <blockquote><pre>
* @Generate
* public class UserSource {}
* </pre></blockquote>
*
* the type element for {@code UserSource} should be passed as part of
* the creation method call as in:
*
* <blockquote><pre>
* filer.createSourceFile("GeneratedFromUserSource",
* eltUtils.getTypeElement("UserSource"));
* </pre></blockquote>
*
* If there are no originating elements, none need to be passed. This
* information may be used in an incremental environment to determine
* the need to rerun processors or remove generated files.
* Non-incremental environments may ignore the originating element
* information.
*
* <p> During each run of an annotation processing tool, a file with a
* given pathname may be created only once. If that file already
* exists before the first attempt to create it, the old contents will
* be deleted. Any subsequent attempt to create the same file during
* a run will throw a {@link FilerException}, as will attempting to
* create both a class file and source file for the same type name or
* same package name. The {@linkplain Processor initial inputs} to
* the tool are considered to be created by the zeroth round;
* therefore, attempting to create a source or class file
* corresponding to one of those inputs will result in a {@link
* FilerException}.
*
* <p> In general, processors must not knowingly attempt to overwrite
* existing files that were not generated by some processor. A {@code
* Filer} may reject attempts to open a file corresponding to an
* existing type, like {@code java.lang.Object}. Likewise, the
* invoker of the annotation processing tool must not knowingly
* configure the tool such that the discovered processors will attempt
* to overwrite existing files that were not generated.
*
* <p> Processors can indicate a source or class file is generated by
* including an {@link javax.annotation.Generated @Generated}
* annotation.
*
* <p> Note that some of the effect of overwriting a file can be
* achieved by using a <i>decorator</i>-style pattern. Instead of
* modifying a class directly, the class is designed so that either
* its superclass is generated by annotation processing or subclasses
* of the class are generated by annotation processing. If the
* subclasses are generated, the parent class may be designed to use
* factories instead of public constructors so that only subclass
* instances would be presented to clients of the parent class.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @since 1.6
*/
public interface Filer {
/**
* Creates a new source file and returns an object to allow
* writing to it. The file's name and path (relative to the
* {@linkplain StandardLocation#SOURCE_OUTPUT root output location
* for source files}) are based on the type to be declared in that
* file. If more than one type is being declared, the name of the
* principal top-level type (the public one, for example) should
* be used. A source file can also be created to hold information
* about a package, including package annotations. To create a
* source file for a named package, have {@code name} be the
* package's name followed by {@code ".package-info"}; to create a
* source file for an unnamed package, use {@code "package-info"}.
*
* <p> Note that to use a particular {@linkplain
* java.nio.charset.Charset charset} to encode the contents of the
* file, an {@code OutputStreamWriter} with the chosen charset can
* be created from the {@code OutputStream} from the returned
* object. If the {@code Writer} from the returned object is
* directly used for writing, its charset is determined by the
* implementation. An annotation processing tool may have an
* {@code -encoding} flag or analogous option for specifying this;
* otherwise, it will typically be the platform's default
* encoding.
*
* <p>To avoid subsequent errors, the contents of the source file
* should be compatible with the {@linkplain
* ProcessingEnvironment#getSourceVersion source version} being used
* for this run.
*
* @param name canonical (fully qualified) name of the principal type
* being declared in this file or a package name followed by
* {@code ".package-info"} for a package information file
* @param originatingElements type or package elements causally
* associated with the creation of this file, may be elided or
* {@code null}
* @return a {@code JavaFileObject} to write the new source file
* @throws FilerException if the same pathname has already been
* created, the same type has already been created, or the name is
* not valid for a type
* @throws IOException if the file cannot be created
*/
JavaFileObject createSourceFile(CharSequence name,
Element... originatingElements) throws IOException;
/**
* Creates a new class file, and returns an object to allow
* writing to it. The file's name and path (relative to the
* {@linkplain StandardLocation#CLASS_OUTPUT root output location
* for class files}) are based on the name of the type being
* written. A class file can also be created to hold information
* about a package, including package annotations. To create a
* class file for a named package, have {@code name} be the
* package's name followed by {@code ".package-info"}; creating a
* class file for an unnamed package is not supported.
*
* <p>To avoid subsequent errors, the contents of the class file
* should be compatible with the {@linkplain
* ProcessingEnvironment#getSourceVersion source version} being used
* for this run.
*
* @param name binary name of the type being written or a package name followed by
* {@code ".package-info"} for a package information file
* @param originatingElements type or package elements causally
* associated with the creation of this file, may be elided or
* {@code null}
* @return a {@code JavaFileObject} to write the new class file
* @throws FilerException if the same pathname has already been
* created, the same type has already been created, or the name is
* not valid for a type
* @throws IOException if the file cannot be created
*/
JavaFileObject createClassFile(CharSequence name,
Element... originatingElements) throws IOException;
/**
* Creates a new auxiliary resource file for writing and returns a
* file object for it. The file may be located along with the
* newly created source files, newly created binary files, or
* other supported location. The locations {@link
* StandardLocation#CLASS_OUTPUT CLASS_OUTPUT} and {@link
* StandardLocation#SOURCE_OUTPUT SOURCE_OUTPUT} must be
* supported. The resource may be named relative to some package
* (as are source and class files), and from there by a relative
* pathname. In a loose sense, the full pathname of the new file
* will be the concatenation of {@code location}, {@code pkg}, and
* {@code relativeName}.
*
* <p>Files created via this method are not registered for
* annotation processing, even if the full pathname of the file
* would correspond to the full pathname of a new source file
* or new class file.
*
* @param location location of the new file
* @param pkg package relative to which the file should be named,
* or the empty string if none
* @param relativeName final pathname components of the file
* @param originatingElements type or package elements causally
* associated with the creation of this file, may be elided or
* {@code null}
* @return a {@code FileObject} to write the new resource
* @throws IOException if the file cannot be created
* @throws FilerException if the same pathname has already been
* created
* @throws IllegalArgumentException for an unsupported location
* @throws IllegalArgumentException if {@code relativeName} is not relative
*/
FileObject createResource(JavaFileManager.Location location,
CharSequence pkg,
CharSequence relativeName,
Element... originatingElements) throws IOException;
/**
* Returns an object for reading an existing resource. The
* locations {@link StandardLocation#CLASS_OUTPUT CLASS_OUTPUT}
* and {@link StandardLocation#SOURCE_OUTPUT SOURCE_OUTPUT} must
* be supported.
*
* @param location location of the file
* @param pkg package relative to which the file should be searched,
* or the empty string if none
* @param relativeName final pathname components of the file
* @return an object to read the file
* @throws FilerException if the same pathname has already been
* opened for writing
* @throws IOException if the file cannot be opened
* @throws IllegalArgumentException for an unsupported location
* @throws IllegalArgumentException if {@code relativeName} is not relative
*/
FileObject getResource(JavaFileManager.Location location,
CharSequence pkg,
CharSequence relativeName) throws IOException;
}
| 13,165 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
SupportedSourceVersion.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/annotation/processing/SupportedSourceVersion.java | /*
* Copyright (c) 2005, 2006, 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 javax.annotation.processing;
import java.lang.annotation.*;
import static java.lang.annotation.RetentionPolicy.*;
import static java.lang.annotation.ElementType.*;
import javax.lang.model.SourceVersion;
/**
* An annotation used to indicate the latest source version an
* annotation processor supports. The {@link
* Processor#getSupportedSourceVersion} method can construct its
* result from the value of this annotation, as done by {@link
* AbstractProcessor#getSupportedSourceVersion}.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @since 1.6
*/
@Documented
@Target(TYPE)
@Retention(RUNTIME)
public @interface SupportedSourceVersion {
SourceVersion value();
}
| 1,946 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Messager.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/annotation/processing/Messager.java | /*
* Copyright (c) 2005, 2006, 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 javax.annotation.processing;
import javax.annotation.*;
import javax.tools.Diagnostic;
import javax.lang.model.element.*;
/**
* A {@code Messager} provides the way for an annotation processor to
* report error messages, warnings, and other notices. Elements,
* annotations, and annotation values can be passed to provide a
* location hint for the message. However, such location hints may be
* unavailable or only approximate.
*
* <p>Printing a message with an {@linkplain
* javax.tools.Diagnostic.Kind#ERROR error kind} will {@linkplain
* RoundEnvironment#errorRaised raise an error}.
*
* <p>Note that the messages "printed" by methods in this
* interface may or may not appear as textual output to a location
* like {@link System#out} or {@link System#err}. Implementations may
* choose to present this information in a different fashion, such as
* messages in a window.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @see ProcessingEnvironment#getLocale
* @since 1.6
*/
public interface Messager {
/**
* Prints a message of the specified kind.
*
* @param kind the kind of message
* @param msg the message, or an empty string if none
*/
void printMessage(Diagnostic.Kind kind, CharSequence msg);
/**
* Prints a message of the specified kind at the location of the
* element.
*
* @param kind the kind of message
* @param msg the message, or an empty string if none
* @param e the element to use as a position hint
*/
void printMessage(Diagnostic.Kind kind, CharSequence msg, Element e);
/**
* Prints a message of the specified kind at the location of the
* annotation mirror of the annotated element.
*
* @param kind the kind of message
* @param msg the message, or an empty string if none
* @param e the annotated element
* @param a the annotation to use as a position hint
*/
void printMessage(Diagnostic.Kind kind, CharSequence msg, Element e, AnnotationMirror a);
/**
* Prints a message of the specified kind at the location of the
* annotation value inside the annotation mirror of the annotated
* element.
*
* @param kind the kind of message
* @param msg the message, or an empty string if none
* @param e the annotated element
* @param a the annotation containing the annotation value
* @param v the annotation value to use as a position hint
*/
void printMessage(Diagnostic.Kind kind,
CharSequence msg,
Element e,
AnnotationMirror a,
AnnotationValue v);
}
| 3,962 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
SupportedAnnotationTypes.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/annotation/processing/SupportedAnnotationTypes.java | /*
* Copyright (c) 2005, 2006, 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 javax.annotation.processing;
import java.lang.annotation.*;
import static java.lang.annotation.RetentionPolicy.*;
import static java.lang.annotation.ElementType.*;
/**
* An annotation used to indicate what annotation types an annotation
* processor supports. The {@link
* Processor#getSupportedAnnotationTypes} method can construct its
* result from the value of this annotation, as done by {@link
* AbstractProcessor#getSupportedAnnotationTypes}. Only {@linkplain
* Processor#getSupportedAnnotationTypes strings conforming to the
* grammar} should be used as values.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @since 1.6
*/
@Documented
@Target(TYPE)
@Retention(RUNTIME)
public @interface SupportedAnnotationTypes {
String [] value();
}
| 2,025 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
FilerException.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/annotation/processing/FilerException.java | /*
* Copyright (c) 2005, 2006, 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 javax.annotation.processing;
import java.io.IOException;
import javax.annotation.processing.Filer;
/**
* Indicates a {@link Filer} detected an attempt to open a file that
* would violate the guarantees provided by the {@code Filer}. Those
* guarantees include not creating the same file more than once, not
* creating multiple files corresponding to the same type, and not
* creating files for types with invalid names.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @since 1.6
*/
public class FilerException extends IOException {
static final long serialVersionUID = 8426423106453163293L;
/**
* Constructs an exception with the specified detail message.
* @param s the detail message, which should include the name of
* the file attempting to be opened; may be {@code null}
*/
public FilerException(String s) {
super(s);
}
}
| 2,149 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Completion.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/annotation/processing/Completion.java | /*
* Copyright (c) 2006, 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 javax.annotation.processing;
/**
* A suggested {@linkplain Processor#getCompletions <em>completion</em>} for an
* annotation. A completion is text meant to be inserted into a
* program as part of an annotation.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @since 1.6
*/
public interface Completion {
/**
* Returns the text of the suggested completion.
* @return the text of the suggested completion.
*/
String getValue();
/**
* Returns an informative message about the completion.
* @return an informative message about the completion.
*/
String getMessage();
}
| 1,882 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
SupportedOptions.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/annotation/processing/SupportedOptions.java | /*
* Copyright (c) 2005, 2006, 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 javax.annotation.processing;
import java.lang.annotation.*;
import static java.lang.annotation.RetentionPolicy.*;
import static java.lang.annotation.ElementType.*;
/**
* An annotation used to indicate what options an annotation processor
* supports. The {@link Processor#getSupportedOptions} method can
* construct its result from the value of this annotation, as done by
* {@link AbstractProcessor#getSupportedOptions}. Only {@linkplain
* Processor#getSupportedOptions strings conforming to the
* grammar} should be used as values.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @since 1.6
*/
@Documented
@Target(TYPE)
@Retention(RUNTIME)
public @interface SupportedOptions {
String [] value();
}
| 1,981 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
RoundEnvironment.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/annotation/processing/RoundEnvironment.java | /*
* Copyright (c) 2005, 2007, 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 javax.annotation.processing;
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
import java.util.Set;
import java.lang.annotation.Annotation;
/**
* An annotation processing tool framework will {@linkplain
* Processor#process provide an annotation processor with an object
* implementing this interface} so that the processor can query for
* information about a round of annotation processing.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @since 1.6
*/
public interface RoundEnvironment {
/**
* Returns {@code true} if types generated by this round will not
* be subject to a subsequent round of annotation processing;
* returns {@code false} otherwise.
*
* @return {@code true} if types generated by this round will not
* be subject to a subsequent round of annotation processing;
* returns {@code false} otherwise
*/
boolean processingOver();
/**
* Returns {@code true} if an error was raised in the prior round
* of processing; returns {@code false} otherwise.
*
* @return {@code true} if an error was raised in the prior round
* of processing; returns {@code false} otherwise
*/
boolean errorRaised();
/**
* Returns the root elements for annotation processing generated
* by the prior round.
*
* @return the root elements for annotation processing generated
* by the prior round, or an empty set if there were none
*/
Set<? extends Element> getRootElements();
/**
* Returns the elements annotated with the given annotation type.
* The annotation may appear directly or be inherited. Only
* package elements and type elements <i>included</i> in this
* round of annotation processing, or declarations of members,
* constructors, parameters, or type parameters declared within
* those, are returned. Included type elements are {@linkplain
* #getRootElements root types} and any member types nested within
* them. Elements in a package are not considered included simply
* because a {@code package-info} file for that package was
* created.
*
* @param a annotation type being requested
* @return the elements annotated with the given annotation type,
* or an empty set if there are none
* @throws IllegalArgumentException if the argument does not
* represent an annotation type
*/
Set<? extends Element> getElementsAnnotatedWith(TypeElement a);
/**
* Returns the elements annotated with the given annotation type.
* The annotation may appear directly or be inherited. Only
* package elements and type elements <i>included</i> in this
* round of annotation processing, or declarations of members,
* constructors, parameters, or type parameters declared within
* those, are returned. Included type elements are {@linkplain
* #getRootElements root types} and any member types nested within
* them. Elements in a package are not considered included simply
* because a {@code package-info} file for that package was
* created.
*
* @param a annotation type being requested
* @return the elements annotated with the given annotation type,
* or an empty set if there are none
* @throws IllegalArgumentException if the argument does not
* represent an annotation type
*/
Set<? extends Element> getElementsAnnotatedWith(Class<? extends Annotation> a);
}
| 4,779 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
AbstractProcessor.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/annotation/processing/AbstractProcessor.java | /*
* Copyright (c) 2005, 2006, 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 javax.annotation.processing;
import java.util.Set;
import java.util.HashSet;
import java.util.Collections;
import javax.lang.model.element.*;
import javax.lang.model.SourceVersion;
import javax.tools.Diagnostic;
/**
* An abstract annotation processor designed to be a convenient
* superclass for most concrete annotation processors. This class
* examines annotation values to compute the {@linkplain
* #getSupportedOptions options}, {@linkplain
* #getSupportedAnnotationTypes annotations}, and {@linkplain
* #getSupportedSourceVersion source version} supported by its
* subtypes.
*
* <p>The getter methods may {@linkplain Messager#printMessage issue
* warnings} about noteworthy conditions using the facilities available
* after the processor has been {@linkplain #isInitialized
* initialized}.
*
* <p>Subclasses are free to override the implementation and
* specification of any of the methods in this class as long as the
* general {@link javax.annotation.processing.Processor Processor}
* contract for that method is obeyed.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @since 1.6
*/
public abstract class AbstractProcessor implements Processor {
/**
* Processing environment providing by the tool framework.
*/
protected ProcessingEnvironment processingEnv;
private boolean initialized = false;
/**
* Constructor for subclasses to call.
*/
protected AbstractProcessor() {}
/**
* If the processor class is annotated with {@link
* SupportedOptions}, return an unmodifiable set with the same set
* of strings as the annotation. If the class is not so
* annotated, an empty set is returned.
*
* @return the options recognized by this processor, or an empty
* set if none
*/
public Set<String> getSupportedOptions() {
SupportedOptions so = this.getClass().getAnnotation(SupportedOptions.class);
if (so == null)
return Collections.emptySet();
else
return arrayToSet(so.value());
}
/**
* If the processor class is annotated with {@link
* SupportedAnnotationTypes}, return an unmodifiable set with the
* same set of strings as the annotation. If the class is not so
* annotated, an empty set is returned.
*
* @return the names of the annotation types supported by this
* processor, or an empty set if none
*/
public Set<String> getSupportedAnnotationTypes() {
SupportedAnnotationTypes sat = this.getClass().getAnnotation(SupportedAnnotationTypes.class);
if (sat == null) {
if (isInitialized())
processingEnv.getMessager().printMessage(Diagnostic.Kind.WARNING,
"No SupportedAnnotationTypes annotation " +
"found on " + this.getClass().getName() +
", returning an empty set.");
return Collections.emptySet();
}
else
return arrayToSet(sat.value());
}
/**
* If the processor class is annotated with {@link
* SupportedSourceVersion}, return the source version in the
* annotation. If the class is not so annotated, {@link
* SourceVersion#RELEASE_6} is returned.
*
* @return the latest source version supported by this processor
*/
public SourceVersion getSupportedSourceVersion() {
SupportedSourceVersion ssv = this.getClass().getAnnotation(SupportedSourceVersion.class);
SourceVersion sv = null;
if (ssv == null) {
sv = SourceVersion.RELEASE_6;
if (isInitialized())
processingEnv.getMessager().printMessage(Diagnostic.Kind.WARNING,
"No SupportedSourceVersion annotation " +
"found on " + this.getClass().getName() +
", returning " + sv + ".");
} else
sv = ssv.value();
return sv;
}
/**
* Initializes the processor with the processing environment by
* setting the {@code processingEnv} field to the value of the
* {@code processingEnv} argument. An {@code
* IllegalStateException} will be thrown if this method is called
* more than once on the same object.
*
* @param processingEnv environment to access facilities the tool framework
* provides to the processor
* @throws IllegalStateException if this method is called more than once.
*/
public synchronized void init(ProcessingEnvironment processingEnv) {
if (initialized)
throw new IllegalStateException("Cannot call init more than once.");
if (processingEnv == null)
throw new NullPointerException("Tool provided null ProcessingEnvironment");
this.processingEnv = processingEnv;
initialized = true;
}
/**
* {@inheritDoc}
*/
public abstract boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv);
/**
* Returns an empty iterable of completions.
*
* @param element {@inheritDoc}
* @param annotation {@inheritDoc}
* @param member {@inheritDoc}
* @param userText {@inheritDoc}
*/
public Iterable<? extends Completion> getCompletions(Element element,
AnnotationMirror annotation,
ExecutableElement member,
String userText) {
return Collections.emptyList();
}
/**
* Returns {@code true} if this object has been {@linkplain #init
* initialized}, {@code false} otherwise.
*
* @return {@code true} if this object has been initialized,
* {@code false} otherwise.
*/
protected synchronized boolean isInitialized() {
return initialized;
}
private static Set<String> arrayToSet(String[] array) {
assert array != null;
Set<String> set = new HashSet<String>(array.length);
for (String s : array)
set.add(s);
return Collections.unmodifiableSet(set);
}
}
| 7,726 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Completions.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/annotation/processing/Completions.java | /*
* Copyright (c) 2006, 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 javax.annotation.processing;
import java.util.Arrays;
/**
* Utility class for assembling {@link Completion} objects.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @since 1.6
*/
public class Completions {
// No instances for you.
private Completions() {}
private static class SimpleCompletion implements Completion {
private String value;
private String message;
SimpleCompletion(String value, String message) {
if (value == null || message == null)
throw new NullPointerException("Null completion strings not accepted.");
this.value = value;
this.message = message;
}
public String getValue() {
return value;
}
public String getMessage() {
return message;
}
@Override
public String toString() {
return "[\"" + value + "\", \"" + message + "\"]";
}
// Default equals and hashCode are fine.
}
/**
* Returns a completion of the value and message.
*
* @param value the text of the completion
* @param message a message about the completion
* @return a completion of the provided value and message
*/
public static Completion of(String value, String message) {
return new SimpleCompletion(value, message);
}
/**
* Returns a completion of the value and an empty message
*
* @param value the text of the completion
* @return a completion of the value and an empty message
*/
public static Completion of(String value) {
return new SimpleCompletion(value, "");
}
}
| 2,928 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
package-info.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/tools/package-info.java | /*
* Copyright (c) 2005, 2006, 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.
*/
/**
* Provides interfaces for tools which can be invoked from a program,
* for example, compilers.
*
* <p>These interfaces and classes are required as part of the
* Java™ Platform, Standard Edition (Java SE),
* but there is no requirement to provide any tools implementing them.
*
* <p>Unless explicitly allowed, all methods in this package might
* throw a {@linkplain java.lang.NullPointerException} if given a
* {@code null} argument or if given a
* {@linkplain java.lang.Iterable list or collection} containing
* {@code null} elements. Similarly, no method may return
* {@code null} unless explicitly allowed.
*
* <p>This package is the home of the Java programming language compiler framework. This
* framework allows clients of the framework to locate and run
* compilers from programs. The framework also provides Service
* Provider Interfaces (SPI) for structured access to diagnostics
* ({@linkplain javax.tools.DiagnosticListener}) as well as a file
* abstraction for overriding file access ({@linkplain
* javax.tools.JavaFileManager} and {@linkplain
* javax.tools.JavaFileObject}). See {@linkplain
* javax.tools.JavaCompiler} for more details on using the SPI.
*
* <p>There is no requirement for a compiler at runtime. However, if
* a default compiler is provided, it can be located using the
* {@linkplain javax.tools.ToolProvider}, for example:
*
* <p>{@code JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();}
*
* <p>It is possible to provide alternative compilers or tools
* through the {@linkplain java.util.ServiceLoader service provider
* mechanism}.
*
* <p>For example, if {@code com.vendor.VendorJavaCompiler} is a
* provider of the {@code JavaCompiler} tool then its jar file
* would contain the file {@code
* META-INF/services/javax.tools.JavaCompiler}. This file would
* contain the single line:
*
* <p>{@code com.vendor.VendorJavaCompiler}
*
* <p>If the jar file is on the class path, VendorJavaCompiler can be
* located using code like this:
*
* <p>{@code JavaCompiler compiler = ServiceLoader.load(JavaCompiler.class).iterator().next();}
*
* @author Peter von der Ahé
* @author Jonathan Gibbons
* @since 1.6
*/
package javax.tools;
| 3,452 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
OptionChecker.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/tools/OptionChecker.java | /*
* Copyright (c) 2006, 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 javax.tools;
/**
* Interface for recognizing options.
*
* @author Peter von der Ahé
* @since 1.6
*/
public interface OptionChecker {
/**
* Determines if the given option is supported and if so, the
* number of arguments the option takes.
*
* @param option an option
* @return the number of arguments the given option takes or -1 if
* the option is not supported
*/
int isSupportedOption(String option);
}
| 1,679 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
DiagnosticCollector.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/tools/DiagnosticCollector.java | /*
* Copyright (c) 2006, 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 javax.tools;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* Provides an easy way to collect diagnostics in a list.
*
* @param <S> the type of source objects used by diagnostics received
* by this object
*
* @author Peter von der Ahé
* @since 1.6
*/
public final class DiagnosticCollector<S> implements DiagnosticListener<S> {
private List<Diagnostic<? extends S>> diagnostics =
Collections.synchronizedList(new ArrayList<Diagnostic<? extends S>>());
public void report(Diagnostic<? extends S> diagnostic) {
diagnostic.getClass(); // null check
diagnostics.add(diagnostic);
}
/**
* Gets a list view of diagnostics collected by this object.
*
* @return a list view of diagnostics
*/
public List<Diagnostic<? extends S>> getDiagnostics() {
return Collections.unmodifiableList(diagnostics);
}
}
| 2,142 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
DiagnosticListener.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/tools/DiagnosticListener.java | /*
* Copyright (c) 2005, 2006, 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 javax.tools;
/**
* Interface for receiving diagnostics from tools.
*
* @param <S> the type of source objects used by diagnostics received
* by this listener
*
* @author Jonathan Gibbons
* @author Peter von der Ahé
* @since 1.6
*/
public interface DiagnosticListener<S> {
/**
* Invoked when a problem is found.
*
* @param diagnostic a diagnostic representing the problem that
* was found
* @throws NullPointerException if the diagnostic argument is
* {@code null} and the implementation cannot handle {@code null}
* arguments
*/
void report(Diagnostic<? extends S> diagnostic);
}
| 1,866 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Diagnostic.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/tools/Diagnostic.java | /*
* Copyright (c) 2005, 2006, 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 javax.tools;
import java.util.Locale;
/**
* Interface for diagnostics from tools. A diagnostic usually reports
* a problem at a specific position in a source file. However, not
* all diagnostics are associated with a position or a file.
*
* <p>A position is a zero-based character offset from the beginning of
* a file. Negative values (except {@link #NOPOS}) are not valid
* positions.
*
* <p>Line and column numbers begin at 1. Negative values (except
* {@link #NOPOS}) and 0 are not valid line or column numbers.
*
* @param <S> the type of source object used by this diagnostic
*
* @author Peter von der Ahé
* @author Jonathan Gibbons
* @since 1.6
*/
public interface Diagnostic<S> {
/**
* Kinds of diagnostics, for example, error or warning.
*/
enum Kind {
/**
* Problem which prevents the tool's normal completion.
*/
ERROR,
/**
* Problem which does not usually prevent the tool from
* completing normally.
*/
WARNING,
/**
* Problem similar to a warning, but is mandated by the tool's
* specification. For example, the Java™ Language
* Specification, 3rd Ed. mandates warnings on certain
* unchecked operations and the use of deprecated methods.
*/
MANDATORY_WARNING,
/**
* Informative message from the tool.
*/
NOTE,
/**
* Diagnostic which does not fit within the other kinds.
*/
OTHER,
}
/**
* Used to signal that no position is available.
*/
public final static long NOPOS = -1;
/**
* Gets the kind of this diagnostic, for example, error or
* warning.
* @return the kind of this diagnostic
*/
Kind getKind();
/**
* Gets the source object associated with this diagnostic.
*
* @return the source object associated with this diagnostic.
* {@code null} if no source object is associated with the
* diagnostic.
*/
S getSource();
/**
* Gets a character offset from the beginning of the source object
* associated with this diagnostic that indicates the location of
* the problem. In addition, the following must be true:
*
* <p>{@code getStartPostion() <= getPosition()}
* <p>{@code getPosition() <= getEndPosition()}
*
* @return character offset from beginning of source; {@link
* #NOPOS} if {@link #getSource()} would return {@code null} or if
* no location is suitable
*/
long getPosition();
/**
* Gets the character offset from the beginning of the file
* associated with this diagnostic that indicates the start of the
* problem.
*
* @return offset from beginning of file; {@link #NOPOS} if and
* only if {@link #getPosition()} returns {@link #NOPOS}
*/
long getStartPosition();
/**
* Gets the character offset from the beginning of the file
* associated with this diagnostic that indicates the end of the
* problem.
*
* @return offset from beginning of file; {@link #NOPOS} if and
* only if {@link #getPosition()} returns {@link #NOPOS}
*/
long getEndPosition();
/**
* Gets the line number of the character offset returned by
* {@linkplain #getPosition()}.
*
* @return a line number or {@link #NOPOS} if and only if {@link
* #getPosition()} returns {@link #NOPOS}
*/
long getLineNumber();
/**
* Gets the column number of the character offset returned by
* {@linkplain #getPosition()}.
*
* @return a column number or {@link #NOPOS} if and only if {@link
* #getPosition()} returns {@link #NOPOS}
*/
long getColumnNumber();
/**
* Gets a diagnostic code indicating the type of diagnostic. The
* code is implementation-dependent and might be {@code null}.
*
* @return a diagnostic code
*/
String getCode();
/**
* Gets a localized message for the given locale. The actual
* message is implementation-dependent. If the locale is {@code
* null} use the default locale.
*
* @param locale a locale; might be {@code null}
* @return a localized message
*/
String getMessage(Locale locale);
}
| 5,575 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
ForwardingJavaFileManager.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/tools/ForwardingJavaFileManager.java | /*
* Copyright (c) 2005, 2006, 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 javax.tools;
import java.io.IOException;
import java.net.URI;
import java.util.Iterator;
import java.util.Set;
import javax.tools.JavaFileObject.Kind;
/**
* Forwards calls to a given file manager. Subclasses of this class
* might override some of these methods and might also provide
* additional fields and methods.
*
* @param <M> the kind of file manager forwarded to by this object
* @author Peter von der Ahé
* @since 1.6
*/
public class ForwardingJavaFileManager<M extends JavaFileManager> implements JavaFileManager {
/**
* The file manager which all methods are delegated to.
*/
protected final M fileManager;
/**
* Creates a new instance of ForwardingJavaFileManager.
* @param fileManager delegate to this file manager
*/
protected ForwardingJavaFileManager(M fileManager) {
fileManager.getClass(); // null check
this.fileManager = fileManager;
}
/**
* @throws SecurityException {@inheritDoc}
* @throws IllegalStateException {@inheritDoc}
*/
public ClassLoader getClassLoader(Location location) {
return fileManager.getClassLoader(location);
}
/**
* @throws IOException {@inheritDoc}
* @throws IllegalStateException {@inheritDoc}
*/
public Iterable<JavaFileObject> list(Location location,
String packageName,
Set<Kind> kinds,
boolean recurse)
throws IOException
{
return fileManager.list(location, packageName, kinds, recurse);
}
/**
* @throws IllegalStateException {@inheritDoc}
*/
public String inferBinaryName(Location location, JavaFileObject file) {
return fileManager.inferBinaryName(location, file);
}
/**
* @throws IllegalArgumentException {@inheritDoc}
*/
public boolean isSameFile(FileObject a, FileObject b) {
return fileManager.isSameFile(a, b);
}
/**
* @throws IllegalArgumentException {@inheritDoc}
* @throws IllegalStateException {@inheritDoc}
*/
public boolean handleOption(String current, Iterator<String> remaining) {
return fileManager.handleOption(current, remaining);
}
public boolean hasLocation(Location location) {
return fileManager.hasLocation(location);
}
public int isSupportedOption(String option) {
return fileManager.isSupportedOption(option);
}
/**
* @throws IllegalArgumentException {@inheritDoc}
* @throws IllegalStateException {@inheritDoc}
*/
public JavaFileObject getJavaFileForInput(Location location,
String className,
Kind kind)
throws IOException
{
return fileManager.getJavaFileForInput(location, className, kind);
}
/**
* @throws IllegalArgumentException {@inheritDoc}
* @throws IllegalStateException {@inheritDoc}
*/
public JavaFileObject getJavaFileForOutput(Location location,
String className,
Kind kind,
FileObject sibling)
throws IOException
{
return fileManager.getJavaFileForOutput(location, className, kind, sibling);
}
/**
* @throws IllegalArgumentException {@inheritDoc}
* @throws IllegalStateException {@inheritDoc}
*/
public FileObject getFileForInput(Location location,
String packageName,
String relativeName)
throws IOException
{
return fileManager.getFileForInput(location, packageName, relativeName);
}
/**
* @throws IllegalArgumentException {@inheritDoc}
* @throws IllegalStateException {@inheritDoc}
*/
public FileObject getFileForOutput(Location location,
String packageName,
String relativeName,
FileObject sibling)
throws IOException
{
return fileManager.getFileForOutput(location, packageName, relativeName, sibling);
}
public void flush() throws IOException {
fileManager.flush();
}
public void close() throws IOException {
fileManager.close();
}
}
| 5,719 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Tool.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/tools/Tool.java | /*
* Copyright (c) 2005, 2006, 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 javax.tools;
import java.util.Set;
import java.io.InputStream;
import java.io.OutputStream;
import javax.lang.model.SourceVersion;
/**
* Common interface for tools that can be invoked from a program.
* A tool is traditionally a command line program such as a compiler.
* The set of tools available with a platform is defined by the
* vendor.
*
* <p>Tools can be located using {@link
* java.util.ServiceLoader#load(Class)}.
*
* @author Neal M Gafter
* @author Peter von der Ahé
* @author Jonathan Gibbons
* @since 1.6
*/
public interface Tool {
/**
* Run the tool with the given I/O channels and arguments. By
* convention a tool returns 0 for success and nonzero for errors.
* Any diagnostics generated will be written to either {@code out}
* or {@code err} in some unspecified format.
*
* @param in "standard" input; use System.in if null
* @param out "standard" output; use System.out if null
* @param err "standard" error; use System.err if null
* @param arguments arguments to pass to the tool
* @return 0 for success; nonzero otherwise
* @throws NullPointerException if the array of arguments contains
* any {@code null} elements.
*/
int run(InputStream in, OutputStream out, OutputStream err, String... arguments);
/**
* Gets the source versions of the Java™ programming language
* supported by this tool.
* @return a set of supported source versions
*/
Set<SourceVersion> getSourceVersions();
}
| 2,756 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
StandardJavaFileManager.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/tools/StandardJavaFileManager.java | /*
* Copyright (c) 2006, 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 javax.tools;
import java.io.File;
import java.io.IOException;
import java.util.*;
/**
* File manager based on {@linkplain File java.io.File}. A common way
* to obtain an instance of this class is using {@linkplain
* JavaCompiler#getStandardFileManager
* getStandardFileManager}, for example:
*
* <pre>
* JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
* {@code DiagnosticCollector<JavaFileObject>} diagnostics =
* new {@code DiagnosticCollector<JavaFileObject>()};
* StandardJavaFileManager fm = compiler.getStandardFileManager(diagnostics, null, null);
* </pre>
*
* This file manager creates file objects representing regular
* {@linkplain File files},
* {@linkplain java.util.zip.ZipEntry zip file entries}, or entries in
* similar file system based containers. Any file object returned
* from a file manager implementing this interface must observe the
* following behavior:
*
* <ul>
* <li>
* File names need not be canonical.
* </li>
* <li>
* For file objects representing regular files
* <ul>
* <li>
* the method <code>{@linkplain FileObject#delete()}</code>
* is equivalent to <code>{@linkplain File#delete()}</code>,
* </li>
* <li>
* the method <code>{@linkplain FileObject#getLastModified()}</code>
* is equivalent to <code>{@linkplain File#lastModified()}</code>,
* </li>
* <li>
* the methods <code>{@linkplain FileObject#getCharContent(boolean)}</code>,
* <code>{@linkplain FileObject#openInputStream()}</code>, and
* <code>{@linkplain FileObject#openReader(boolean)}</code>
* must succeed if the following would succeed (ignoring
* encoding issues):
* <blockquote>
* <pre>new {@linkplain java.io.FileInputStream#FileInputStream(File) FileInputStream}(new {@linkplain File#File(java.net.URI) File}({@linkplain FileObject fileObject}.{@linkplain FileObject#toUri() toUri}()))</pre>
* </blockquote>
* </li>
* <li>
* and the methods
* <code>{@linkplain FileObject#openOutputStream()}</code>, and
* <code>{@linkplain FileObject#openWriter()}</code> must
* succeed if the following would succeed (ignoring encoding
* issues):
* <blockquote>
* <pre>new {@linkplain java.io.FileOutputStream#FileOutputStream(File) FileOutputStream}(new {@linkplain File#File(java.net.URI) File}({@linkplain FileObject fileObject}.{@linkplain FileObject#toUri() toUri}()))</pre>
* </blockquote>
* </li>
* </ul>
* </li>
* <li>
* The {@linkplain java.net.URI URI} returned from
* <code>{@linkplain FileObject#toUri()}</code>
* <ul>
* <li>
* must be {@linkplain java.net.URI#isAbsolute() absolute} (have a schema), and
* </li>
* <li>
* must have a {@linkplain java.net.URI#normalize() normalized}
* {@linkplain java.net.URI#getPath() path component} which
* can be resolved without any process-specific context such
* as the current directory (file names must be absolute).
* </li>
* </ul>
* </li>
* </ul>
*
* According to these rules, the following URIs, for example, are
* allowed:
* <ul>
* <li>
* <code>file:///C:/Documents%20and%20Settings/UncleBob/BobsApp/Test.java</code>
* </li>
* <li>
* <code>jar:///C:/Documents%20and%20Settings/UncleBob/lib/vendorA.jar!com/vendora/LibraryClass.class</code>
* </li>
* </ul>
* Whereas these are not (reason in parentheses):
* <ul>
* <li>
* <code>file:BobsApp/Test.java</code> (the file name is relative
* and depend on the current directory)
* </li>
* <li>
* <code>jar:lib/vendorA.jar!com/vendora/LibraryClass.class</code>
* (the first half of the path depends on the current directory,
* whereas the component after ! is legal)
* </li>
* <li>
* <code>Test.java</code> (this URI depends on the current
* directory and does not have a schema)
* </li>
* <li>
* <code>jar:///C:/Documents%20and%20Settings/UncleBob/BobsApp/../lib/vendorA.jar!com/vendora/LibraryClass.class</code>
* (the path is not normalized)
* </li>
* </ul>
*
* @author Peter von der Ahé
* @since 1.6
*/
public interface StandardJavaFileManager extends JavaFileManager {
/**
* Compares two file objects and return true if they represent the
* same canonical file, zip file entry, or entry in any file
* system based container.
*
* @param a a file object
* @param b a file object
* @return true if the given file objects represent the same
* canonical file or zip file entry; false otherwise
*
* @throws IllegalArgumentException if either of the arguments
* were created with another file manager implementation
*/
boolean isSameFile(FileObject a, FileObject b);
/**
* Gets file objects representing the given files.
*
* @param files a list of files
* @return a list of file objects
* @throws IllegalArgumentException if the list of files includes
* a directory
*/
Iterable<? extends JavaFileObject> getJavaFileObjectsFromFiles(
Iterable<? extends File> files);
/**
* Gets file objects representing the given files.
* Convenience method equivalent to:
*
* <pre>
* getJavaFileObjectsFromFiles({@linkplain java.util.Arrays#asList Arrays.asList}(files))
* </pre>
*
* @param files an array of files
* @return a list of file objects
* @throws IllegalArgumentException if the array of files includes
* a directory
* @throws NullPointerException if the given array contains null
* elements
*/
Iterable<? extends JavaFileObject> getJavaFileObjects(File... files);
/**
* Gets file objects representing the given file names.
*
* @param names a list of file names
* @return a list of file objects
* @throws IllegalArgumentException if the list of file names
* includes a directory
*/
Iterable<? extends JavaFileObject> getJavaFileObjectsFromStrings(
Iterable<String> names);
/**
* Gets file objects representing the given file names.
* Convenience method equivalent to:
*
* <pre>
* getJavaFileObjectsFromStrings({@linkplain java.util.Arrays#asList Arrays.asList}(names))
* </pre>
*
* @param names a list of file names
* @return a list of file objects
* @throws IllegalArgumentException if the array of file names
* includes a directory
* @throws NullPointerException if the given array contains null
* elements
*/
Iterable<? extends JavaFileObject> getJavaFileObjects(String... names);
/**
* Associates the given path with the given location. Any
* previous value will be discarded.
*
* @param location a location
* @param path a list of files, if {@code null} use the default
* path for this location
* @see #getLocation
* @throws IllegalArgumentException if location is an output
* location and path does not contain exactly one element
* @throws IOException if location is an output location and path
* does not represent an existing directory
*/
void setLocation(Location location, Iterable<? extends File> path)
throws IOException;
/**
* Gets the path associated with the given location.
*
* @param location a location
* @return a list of files or {@code null} if this location has no
* associated path
* @see #setLocation
*/
Iterable<? extends File> getLocation(Location location);
}
| 8,977 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
SimpleJavaFileObject.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/tools/SimpleJavaFileObject.java | /*
* Copyright (c) 2005, 2006, 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 javax.tools;
import java.io.*;
import java.net.URI;
import java.nio.CharBuffer;
import javax.lang.model.element.Modifier;
import javax.lang.model.element.NestingKind;
import javax.tools.JavaFileObject.Kind;
/**
* Provides simple implementations for most methods in JavaFileObject.
* This class is designed to be subclassed and used as a basis for
* JavaFileObject implementations. Subclasses can override the
* implementation and specification of any method of this class as
* long as the general contract of JavaFileObject is obeyed.
*
* @author Peter von der Ahé
* @since 1.6
*/
public class SimpleJavaFileObject implements JavaFileObject {
/**
* A URI for this file object.
*/
protected final URI uri;
/**
* The kind of this file object.
*/
protected final Kind kind;
/**
* Construct a SimpleJavaFileObject of the given kind and with the
* given URI.
*
* @param uri the URI for this file object
* @param kind the kind of this file object
*/
protected SimpleJavaFileObject(URI uri, Kind kind) {
// null checks
uri.getClass();
kind.getClass();
if (uri.getPath() == null)
throw new IllegalArgumentException("URI must have a path: " + uri);
this.uri = uri;
this.kind = kind;
}
public URI toUri() {
return uri;
}
public String getName() {
return toUri().getPath();
}
/**
* This implementation always throws {@linkplain
* UnsupportedOperationException}. Subclasses can change this
* behavior as long as the contract of {@link FileObject} is
* obeyed.
*/
public InputStream openInputStream() throws IOException {
throw new UnsupportedOperationException();
}
/**
* This implementation always throws {@linkplain
* UnsupportedOperationException}. Subclasses can change this
* behavior as long as the contract of {@link FileObject} is
* obeyed.
*/
public OutputStream openOutputStream() throws IOException {
throw new UnsupportedOperationException();
}
/**
* Wraps the result of {@linkplain #getCharContent} in a Reader.
* Subclasses can change this behavior as long as the contract of
* {@link FileObject} is obeyed.
*
* @param ignoreEncodingErrors {@inheritDoc}
* @return a Reader wrapping the result of getCharContent
* @throws IllegalStateException {@inheritDoc}
* @throws UnsupportedOperationException {@inheritDoc}
* @throws IOException {@inheritDoc}
*/
public Reader openReader(boolean ignoreEncodingErrors) throws IOException {
CharSequence charContent = getCharContent(ignoreEncodingErrors);
if (charContent == null)
throw new UnsupportedOperationException();
if (charContent instanceof CharBuffer) {
CharBuffer buffer = (CharBuffer)charContent;
if (buffer.hasArray())
return new CharArrayReader(buffer.array());
}
return new StringReader(charContent.toString());
}
/**
* This implementation always throws {@linkplain
* UnsupportedOperationException}. Subclasses can change this
* behavior as long as the contract of {@link FileObject} is
* obeyed.
*/
public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
throw new UnsupportedOperationException();
}
/**
* Wraps the result of openOutputStream in a Writer. Subclasses
* can change this behavior as long as the contract of {@link
* FileObject} is obeyed.
*
* @return a Writer wrapping the result of openOutputStream
* @throws IllegalStateException {@inheritDoc}
* @throws UnsupportedOperationException {@inheritDoc}
* @throws IOException {@inheritDoc}
*/
public Writer openWriter() throws IOException {
return new OutputStreamWriter(openOutputStream());
}
/**
* This implementation returns {@code 0L}. Subclasses can change
* this behavior as long as the contract of {@link FileObject} is
* obeyed.
*
* @return {@code 0L}
*/
public long getLastModified() {
return 0L;
}
/**
* This implementation does nothing. Subclasses can change this
* behavior as long as the contract of {@link FileObject} is
* obeyed.
*
* @return {@code false}
*/
public boolean delete() {
return false;
}
/**
* @return {@code this.kind}
*/
public Kind getKind() {
return kind;
}
/**
* This implementation compares the path of its URI to the given
* simple name. This method returns true if the given kind is
* equal to the kind of this object, and if the path is equal to
* {@code simpleName + kind.extension} or if it ends with {@code
* "/" + simpleName + kind.extension}.
*
* <p>This method calls {@link #getKind} and {@link #toUri} and
* does not access the fields {@link #uri} and {@link #kind}
* directly.
*
* <p>Subclasses can change this behavior as long as the contract
* of {@link JavaFileObject} is obeyed.
*/
public boolean isNameCompatible(String simpleName, Kind kind) {
String baseName = simpleName + kind.extension;
return kind.equals(getKind())
&& (baseName.equals(toUri().getPath())
|| toUri().getPath().endsWith("/" + baseName));
}
/**
* This implementation returns {@code null}. Subclasses can
* change this behavior as long as the contract of
* {@link JavaFileObject} is obeyed.
*/
public NestingKind getNestingKind() { return null; }
/**
* This implementation returns {@code null}. Subclasses can
* change this behavior as long as the contract of
* {@link JavaFileObject} is obeyed.
*/
public Modifier getAccessLevel() { return null; }
@Override
public String toString() {
return getClass().getName() + "[" + toUri() + "]";
}
}
| 7,324 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
ForwardingFileObject.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/tools/ForwardingFileObject.java | /*
* Copyright (c) 2006, 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 javax.tools;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
import java.io.Writer;
import java.net.URI;
/**
* Forwards calls to a given file object. Subclasses of this class
* might override some of these methods and might also provide
* additional fields and methods.
*
* @param <F> the kind of file object forwarded to by this object
* @author Peter von der Ahé
* @since 1.6
*/
public class ForwardingFileObject<F extends FileObject> implements FileObject {
/**
* The file object which all methods are delegated to.
*/
protected final F fileObject;
/**
* Creates a new instance of ForwardingFileObject.
* @param fileObject delegate to this file object
*/
protected ForwardingFileObject(F fileObject) {
fileObject.getClass(); // null check
this.fileObject = fileObject;
}
public URI toUri() {
return fileObject.toUri();
}
public String getName() {
return fileObject.getName();
}
/**
* @throws IllegalStateException {@inheritDoc}
* @throws UnsupportedOperationException {@inheritDoc}
* @throws IOException {@inheritDoc}
*/
public InputStream openInputStream() throws IOException {
return fileObject.openInputStream();
}
/**
* @throws IllegalStateException {@inheritDoc}
* @throws UnsupportedOperationException {@inheritDoc}
* @throws IOException {@inheritDoc}
*/
public OutputStream openOutputStream() throws IOException {
return fileObject.openOutputStream();
}
/**
* @throws IllegalStateException {@inheritDoc}
* @throws UnsupportedOperationException {@inheritDoc}
* @throws IOException {@inheritDoc}
*/
public Reader openReader(boolean ignoreEncodingErrors) throws IOException {
return fileObject.openReader(ignoreEncodingErrors);
}
/**
* @throws IllegalStateException {@inheritDoc}
* @throws UnsupportedOperationException {@inheritDoc}
* @throws IOException {@inheritDoc}
*/
public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
return fileObject.getCharContent(ignoreEncodingErrors);
}
/**
* @throws IllegalStateException {@inheritDoc}
* @throws UnsupportedOperationException {@inheritDoc}
* @throws IOException {@inheritDoc}
*/
public Writer openWriter() throws IOException {
return fileObject.openWriter();
}
public long getLastModified() {
return fileObject.getLastModified();
}
public boolean delete() {
return fileObject.delete();
}
}
| 3,908 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
JavaFileObject.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/tools/JavaFileObject.java | /*
* Copyright (c) 2005, 2006, 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 javax.tools;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
import java.io.Writer;
import java.nio.CharBuffer;
import javax.lang.model.element.NestingKind;
import javax.lang.model.element.Modifier;
/**
* File abstraction for tools operating on Java™ programming language
* source and class files.
*
* <p>All methods in this interface might throw a SecurityException if
* a security exception occurs.
*
* <p>Unless explicitly allowed, all methods in this interface might
* throw a NullPointerException if given a {@code null} argument.
*
* @author Peter von der Ahé
* @author Jonathan Gibbons
* @see JavaFileManager
* @since 1.6
*/
public interface JavaFileObject extends FileObject {
/**
* Kinds of JavaFileObjects.
*/
enum Kind {
/**
* Source files written in the Java programming language. For
* example, regular files ending with {@code .java}.
*/
SOURCE(".java"),
/**
* Class files for the Java Virtual Machine. For example,
* regular files ending with {@code .class}.
*/
CLASS(".class"),
/**
* HTML files. For example, regular files ending with {@code
* .html}.
*/
HTML(".html"),
/**
* Any other kind.
*/
OTHER("");
/**
* The extension which (by convention) is normally used for
* this kind of file object. If no convention exists, the
* empty string ({@code ""}) is used.
*/
public final String extension;
private Kind(String extension) {
extension.getClass(); // null check
this.extension = extension;
}
};
/**
* Gets the kind of this file object.
*
* @return the kind
*/
Kind getKind();
/**
* Checks if this file object is compatible with the specified
* simple name and kind. A simple name is a single identifier
* (not qualified) as defined in
* <cite>The Java™ Language Specification</cite>,
* section 6.2 "Names and Identifiers".
*
* @param simpleName a simple name of a class
* @param kind a kind
* @return {@code true} if this file object is compatible; false
* otherwise
*/
boolean isNameCompatible(String simpleName, Kind kind);
/**
* Provides a hint about the nesting level of the class
* represented by this file object. This method may return
* {@link NestingKind#MEMBER} to mean
* {@link NestingKind#LOCAL} or {@link NestingKind#ANONYMOUS}.
* If the nesting level is not known or this file object does not
* represent a class file this method returns {@code null}.
*
* @return the nesting kind, or {@code null} if the nesting kind
* is not known
*/
NestingKind getNestingKind();
/**
* Provides a hint about the access level of the class represented
* by this file object. If the access level is not known or if
* this file object does not represent a class file this method
* returns {@code null}.
*
* @return the access level
*/
Modifier getAccessLevel();
}
| 4,482 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
JavaCompiler.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/tools/JavaCompiler.java | /*
* Copyright (c) 2005, 2011, 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 javax.tools;
import java.io.File;
import java.io.Writer;
import java.nio.charset.Charset;
import java.util.Locale;
import java.util.concurrent.Callable;
import javax.annotation.processing.Processor;
/**
* Interface to invoke Java™ programming language compilers from
* programs.
*
* <p>The compiler might generate diagnostics during compilation (for
* example, error messages). If a diagnostic listener is provided,
* the diagnostics will be supplied to the listener. If no listener
* is provided, the diagnostics will be formatted in an unspecified
* format and written to the default output, which is {@code
* System.err} unless otherwise specified. Even if a diagnostic
* listener is supplied, some diagnostics might not fit in a {@code
* Diagnostic} and will be written to the default output.
*
* <p>A compiler tool has an associated standard file manager, which
* is the file manager that is native to the tool (or built-in). The
* standard file manager can be obtained by calling {@linkplain
* #getStandardFileManager getStandardFileManager}.
*
* <p>A compiler tool must function with any file manager as long as
* any additional requirements as detailed in the methods below are
* met. If no file manager is provided, the compiler tool will use a
* standard file manager such as the one returned by {@linkplain
* #getStandardFileManager getStandardFileManager}.
*
* <p>An instance implementing this interface must conform to
* <cite>The Java™ Language Specification</cite>
* and generate class files conforming to
* <cite>The Java™ Virtual Machine Specification</cite>.
* The versions of these
* specifications are defined in the {@linkplain Tool} interface.
*
* Additionally, an instance of this interface supporting {@link
* javax.lang.model.SourceVersion#RELEASE_6 SourceVersion.RELEASE_6}
* or higher must also support {@linkplain javax.annotation.processing
* annotation processing}.
*
* <p>The compiler relies on two services: {@linkplain
* DiagnosticListener diagnostic listener} and {@linkplain
* JavaFileManager file manager}. Although most classes and
* interfaces in this package defines an API for compilers (and
* tools in general) the interfaces {@linkplain DiagnosticListener},
* {@linkplain JavaFileManager}, {@linkplain FileObject}, and
* {@linkplain JavaFileObject} are not intended to be used in
* applications. Instead these interfaces are intended to be
* implemented and used to provide customized services for a
* compiler and thus defines an SPI for compilers.
*
* <p>There are a number of classes and interfaces in this package
* which are designed to ease the implementation of the SPI to
* customize the behavior of a compiler:
*
* <dl>
* <dt>{@link StandardJavaFileManager}</dt>
* <dd>
*
* Every compiler which implements this interface provides a
* standard file manager for operating on regular {@linkplain
* java.io.File files}. The StandardJavaFileManager interface
* defines additional methods for creating file objects from
* regular files.
*
* <p>The standard file manager serves two purposes:
*
* <ul>
* <li>basic building block for customizing how a compiler reads
* and writes files</li>
* <li>sharing between multiple compilation tasks</li>
* </ul>
*
* <p>Reusing a file manager can potentially reduce overhead of
* scanning the file system and reading jar files. Although there
* might be no reduction in overhead, a standard file manager must
* work with multiple sequential compilations making the following
* example a recommended coding pattern:
*
* <pre>
* Files[] files1 = ... ; // input for first compilation task
* Files[] files2 = ... ; // input for second compilation task
*
* JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
* StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null);
*
* {@code Iterable<? extends JavaFileObject>} compilationUnits1 =
* fileManager.getJavaFileObjectsFromFiles({@linkplain java.util.Arrays#asList Arrays.asList}(files1));
* compiler.getTask(null, fileManager, null, null, null, compilationUnits1).call();
*
* {@code Iterable<? extends JavaFileObject>} compilationUnits2 =
* fileManager.getJavaFileObjects(files2); // use alternative method
* // reuse the same file manager to allow caching of jar files
* compiler.getTask(null, fileManager, null, null, null, compilationUnits2).call();
*
* fileManager.close();</pre>
*
* </dd>
*
* <dt>{@link DiagnosticCollector}</dt>
* <dd>
* Used to collect diagnostics in a list, for example:
* <pre>
* {@code Iterable<? extends JavaFileObject>} compilationUnits = ...;
* JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
* {@code DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<JavaFileObject>();}
* StandardJavaFileManager fileManager = compiler.getStandardFileManager(diagnostics, null, null);
* compiler.getTask(null, fileManager, diagnostics, null, null, compilationUnits).call();
*
* for (Diagnostic<? extends JavaFileObject> diagnostic : diagnostics.getDiagnostics())
* System.out.format("Error on line %d in %s%n",
* diagnostic.getLineNumber(),
* diagnostic.getSource().toUri());
*
* fileManager.close();</pre>
* </dd>
*
* <dt>
* {@link ForwardingJavaFileManager}, {@link ForwardingFileObject}, and
* {@link ForwardingJavaFileObject}
* </dt>
* <dd>
*
* Subclassing is not available for overriding the behavior of a
* standard file manager as it is created by calling a method on a
* compiler, not by invoking a constructor. Instead forwarding
* (or delegation) should be used. These classes makes it easy to
* forward most calls to a given file manager or file object while
* allowing customizing behavior. For example, consider how to
* log all calls to {@linkplain JavaFileManager#flush}:
*
* <pre>
* final {@linkplain java.util.logging.Logger Logger} logger = ...;
* {@code Iterable<? extends JavaFileObject>} compilationUnits = ...;
* JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
* StandardJavaFileManager stdFileManager = compiler.getStandardFileManager(null, null, null);
* JavaFileManager fileManager = new ForwardingJavaFileManager(stdFileManager) {
* public void flush() {
* logger.entering(StandardJavaFileManager.class.getName(), "flush");
* super.flush();
* logger.exiting(StandardJavaFileManager.class.getName(), "flush");
* }
* };
* compiler.getTask(null, fileManager, null, null, null, compilationUnits).call();</pre>
* </dd>
*
* <dt>{@link SimpleJavaFileObject}</dt>
* <dd>
*
* This class provides a basic file object implementation which
* can be used as building block for creating file objects. For
* example, here is how to define a file object which represent
* source code stored in a string:
*
* <pre>
* /**
* * A file object used to represent source coming from a string.
* {@code *}/
* public class JavaSourceFromString extends SimpleJavaFileObject {
* /**
* * The source code of this "file".
* {@code *}/
* final String code;
*
* /**
* * Constructs a new JavaSourceFromString.
* * {@code @}param name the name of the compilation unit represented by this file object
* * {@code @}param code the source code for the compilation unit represented by this file object
* {@code *}/
* JavaSourceFromString(String name, String code) {
* super({@linkplain java.net.URI#create URI.create}("string:///" + name.replace('.','/') + Kind.SOURCE.extension),
* Kind.SOURCE);
* this.code = code;
* }
*
* {@code @}Override
* public CharSequence getCharContent(boolean ignoreEncodingErrors) {
* return code;
* }
* }</pre>
* </dd>
* </dl>
*
* @author Peter von der Ahé
* @author Jonathan Gibbons
* @see DiagnosticListener
* @see Diagnostic
* @see JavaFileManager
* @since 1.6
*/
public interface JavaCompiler extends Tool, OptionChecker {
/**
* Creates a future for a compilation task with the given
* components and arguments. The compilation might not have
* completed as described in the CompilationTask interface.
*
* <p>If a file manager is provided, it must be able to handle all
* locations defined in {@link StandardLocation}.
*
* <p>Note that annotation processing can process both the
* compilation units of source code to be compiled, passed with
* the {@code compilationUnits} parameter, as well as class
* files, whose names are passed with the {@code classes}
* parameter.
*
* @param out a Writer for additional output from the compiler;
* use {@code System.err} if {@code null}
* @param fileManager a file manager; if {@code null} use the
* compiler's standard filemanager
* @param diagnosticListener a diagnostic listener; if {@code
* null} use the compiler's default method for reporting
* diagnostics
* @param options compiler options, {@code null} means no options
* @param classes names of classes to be processed by annotation
* processing, {@code null} means no class names
* @param compilationUnits the compilation units to compile, {@code
* null} means no compilation units
* @return an object representing the compilation
* @throws RuntimeException if an unrecoverable error
* occurred in a user supplied component. The
* {@linkplain Throwable#getCause() cause} will be the error in
* user code.
* @throws IllegalArgumentException if any of the given
* compilation units are of other kind than
* {@linkplain JavaFileObject.Kind#SOURCE source}
*/
CompilationTask getTask(Writer out,
JavaFileManager fileManager,
DiagnosticListener<? super JavaFileObject> diagnosticListener,
Iterable<String> options,
Iterable<String> classes,
Iterable<? extends JavaFileObject> compilationUnits);
/**
* Gets a new instance of the standard file manager implementation
* for this tool. The file manager will use the given diagnostic
* listener for producing any non-fatal diagnostics. Fatal errors
* will be signalled with the appropriate exceptions.
*
* <p>The standard file manager will be automatically reopened if
* it is accessed after calls to {@code flush} or {@code close}.
* The standard file manager must be usable with other tools.
*
* @param diagnosticListener a diagnostic listener for non-fatal
* diagnostics; if {@code null} use the compiler's default method
* for reporting diagnostics
* @param locale the locale to apply when formatting diagnostics;
* {@code null} means the {@linkplain Locale#getDefault() default locale}.
* @param charset the character set used for decoding bytes; if
* {@code null} use the platform default
* @return the standard file manager
*/
StandardJavaFileManager getStandardFileManager(
DiagnosticListener<? super JavaFileObject> diagnosticListener,
Locale locale,
Charset charset);
/**
* Interface representing a future for a compilation task. The
* compilation task has not yet started. To start the task, call
* the {@linkplain #call call} method.
*
* <p>Before calling the call method, additional aspects of the
* task can be configured, for example, by calling the
* {@linkplain #setProcessors setProcessors} method.
*/
interface CompilationTask extends Callable<Boolean> {
/**
* Sets processors (for annotation processing). This will
* bypass the normal discovery mechanism.
*
* @param processors processors (for annotation processing)
* @throws IllegalStateException if the task has started
*/
void setProcessors(Iterable<? extends Processor> processors);
/**
* Set the locale to be applied when formatting diagnostics and
* other localized data.
*
* @param locale the locale to apply; {@code null} means apply no
* locale
* @throws IllegalStateException if the task has started
*/
void setLocale(Locale locale);
/**
* Performs this compilation task. The compilation may only
* be performed once. Subsequent calls to this method throw
* IllegalStateException.
*
* @return true if and only all the files compiled without errors;
* false otherwise
*
* @throws RuntimeException if an unrecoverable error occurred
* in a user-supplied component. The
* {@linkplain Throwable#getCause() cause} will be the error
* in user code.
* @throws IllegalStateException if called more than once
*/
Boolean call();
}
}
| 14,835 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
JavaFileManager.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/tools/JavaFileManager.java | /*
* Copyright (c) 2005, 2006, 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 javax.tools;
import java.io.Closeable;
import java.io.Flushable;
import java.io.IOException;
import java.util.Iterator;
import java.util.Set;
import static javax.tools.JavaFileObject.Kind;
/**
* File manager for tools operating on Java™ programming language
* source and class files. In this context, <em>file</em> means an
* abstraction of regular files and other sources of data.
*
* <p>When constructing new JavaFileObjects, the file manager must
* determine where to create them. For example, if a file manager
* manages regular files on a file system, it would most likely have a
* current/working directory to use as default location when creating
* or finding files. A number of hints can be provided to a file
* manager as to where to create files. Any file manager might choose
* to ignore these hints.
*
* <p>Some methods in this interface use class names. Such class
* names must be given in the Java Virtual Machine internal form of
* fully qualified class and interface names. For convenience '.'
* and '/' are interchangeable. The internal form is defined in
* chapter four of
* <cite>The Java™ Virtual Machine Specification</cite>.
* <blockquote><p>
* <i>Discussion:</i> this means that the names
* "java/lang.package-info", "java/lang/package-info",
* "java.lang.package-info", are valid and equivalent. Compare to
* binary name as defined in
* <cite>The Java™ Language Specification</cite>,
* section 13.1 "The Form of a Binary".
* </p></blockquote>
*
* <p>The case of names is significant. All names should be treated
* as case-sensitive. For example, some file systems have
* case-insensitive, case-aware file names. File objects representing
* such files should take care to preserve case by using {@link
* java.io.File#getCanonicalFile} or similar means. If the system is
* not case-aware, file objects must use other means to preserve case.
*
* <p><em><a name="relative_name">Relative names</a>:</em> some
* methods in this interface use relative names. A relative name is a
* non-null, non-empty sequence of path segments separated by '/'.
* '.' or '..' are invalid path segments. A valid relative name must
* match the "path-rootless" rule of <a
* href="http://www.ietf.org/rfc/rfc3986.txt">RFC 3986</a>,
* section 3.3. Informally, this should be true:
*
* <!-- URI.create(relativeName).normalize().getPath().equals(relativeName) -->
* <pre> URI.{@linkplain java.net.URI#create create}(relativeName).{@linkplain java.net.URI#normalize normalize}().{@linkplain java.net.URI#getPath getPath}().equals(relativeName)</pre>
*
* <p>All methods in this interface might throw a SecurityException.
*
* <p>An object of this interface is not required to support
* multi-threaded access, that is, be synchronized. However, it must
* support concurrent access to different file objects created by this
* object.
*
* <p><em>Implementation note:</em> a consequence of this requirement
* is that a trivial implementation of output to a {@linkplain
* java.util.jar.JarOutputStream} is not a sufficient implementation.
* That is, rather than creating a JavaFileObject that returns the
* JarOutputStream directly, the contents must be cached until closed
* and then written to the JarOutputStream.
*
* <p>Unless explicitly allowed, all methods in this interface might
* throw a NullPointerException if given a {@code null} argument.
*
* @author Peter von der Ahé
* @author Jonathan Gibbons
* @see JavaFileObject
* @see FileObject
* @since 1.6
*/
public interface JavaFileManager extends Closeable, Flushable, OptionChecker {
/**
* Interface for locations of file objects. Used by file managers
* to determine where to place or search for file objects.
*/
interface Location {
/**
* Gets the name of this location.
*
* @return a name
*/
String getName();
/**
* Determines if this is an output location. An output
* location is a location that is conventionally used for
* output.
*
* @return true if this is an output location, false otherwise
*/
boolean isOutputLocation();
}
/**
* Gets a class loader for loading plug-ins from the given
* location. For example, to load annotation processors, a
* compiler will request a class loader for the {@link
* StandardLocation#ANNOTATION_PROCESSOR_PATH
* ANNOTATION_PROCESSOR_PATH} location.
*
* @param location a location
* @return a class loader for the given location; or {@code null}
* if loading plug-ins from the given location is disabled or if
* the location is not known
* @throws SecurityException if a class loader can not be created
* in the current security context
* @throws IllegalStateException if {@link #close} has been called
* and this file manager cannot be reopened
*/
ClassLoader getClassLoader(Location location);
/**
* Lists all file objects matching the given criteria in the given
* location. List file objects in "subpackages" if recurse is
* true.
*
* <p>Note: even if the given location is unknown to this file
* manager, it may not return {@code null}. Also, an unknown
* location may not cause an exception.
*
* @param location a location
* @param packageName a package name
* @param kinds return objects only of these kinds
* @param recurse if true include "subpackages"
* @return an Iterable of file objects matching the given criteria
* @throws IOException if an I/O error occurred, or if {@link
* #close} has been called and this file manager cannot be
* reopened
* @throws IllegalStateException if {@link #close} has been called
* and this file manager cannot be reopened
*/
Iterable<JavaFileObject> list(Location location,
String packageName,
Set<Kind> kinds,
boolean recurse)
throws IOException;
/**
* Infers a binary name of a file object based on a location. The
* binary name returned might not be a valid binary name according to
* <cite>The Java™ Language Specification</cite>.
*
* @param location a location
* @param file a file object
* @return a binary name or {@code null} the file object is not
* found in the given location
* @throws IllegalStateException if {@link #close} has been called
* and this file manager cannot be reopened
*/
String inferBinaryName(Location location, JavaFileObject file);
/**
* Compares two file objects and return true if they represent the
* same underlying object.
*
* @param a a file object
* @param b a file object
* @return true if the given file objects represent the same
* underlying object
*
* @throws IllegalArgumentException if either of the arguments
* were created with another file manager and this file manager
* does not support foreign file objects
*/
boolean isSameFile(FileObject a, FileObject b);
/**
* Handles one option. If {@code current} is an option to this
* file manager it will consume any arguments to that option from
* {@code remaining} and return true, otherwise return false.
*
* @param current current option
* @param remaining remaining options
* @return true if this option was handled by this file manager,
* false otherwise
* @throws IllegalArgumentException if this option to this file
* manager is used incorrectly
* @throws IllegalStateException if {@link #close} has been called
* and this file manager cannot be reopened
*/
boolean handleOption(String current, Iterator<String> remaining);
/**
* Determines if a location is known to this file manager.
*
* @param location a location
* @return true if the location is known
*/
boolean hasLocation(Location location);
/**
* Gets a {@linkplain JavaFileObject file object} for input
* representing the specified class of the specified kind in the
* given location.
*
* @param location a location
* @param className the name of a class
* @param kind the kind of file, must be one of {@link
* JavaFileObject.Kind#SOURCE SOURCE} or {@link
* JavaFileObject.Kind#CLASS CLASS}
* @return a file object, might return {@code null} if the
* file does not exist
* @throws IllegalArgumentException if the location is not known
* to this file manager and the file manager does not support
* unknown locations, or if the kind is not valid
* @throws IOException if an I/O error occurred, or if {@link
* #close} has been called and this file manager cannot be
* reopened
* @throws IllegalStateException if {@link #close} has been called
* and this file manager cannot be reopened
*/
JavaFileObject getJavaFileForInput(Location location,
String className,
Kind kind)
throws IOException;
/**
* Gets a {@linkplain JavaFileObject file object} for output
* representing the specified class of the specified kind in the
* given location.
*
* <p>Optionally, this file manager might consider the sibling as
* a hint for where to place the output. The exact semantics of
* this hint is unspecified. The JDK compiler, javac, for
* example, will place class files in the same directories as
* originating source files unless a class file output directory
* is provided. To facilitate this behavior, javac might provide
* the originating source file as sibling when calling this
* method.
*
* @param location a location
* @param className the name of a class
* @param kind the kind of file, must be one of {@link
* JavaFileObject.Kind#SOURCE SOURCE} or {@link
* JavaFileObject.Kind#CLASS CLASS}
* @param sibling a file object to be used as hint for placement;
* might be {@code null}
* @return a file object for output
* @throws IllegalArgumentException if sibling is not known to
* this file manager, or if the location is not known to this file
* manager and the file manager does not support unknown
* locations, or if the kind is not valid
* @throws IOException if an I/O error occurred, or if {@link
* #close} has been called and this file manager cannot be
* reopened
* @throws IllegalStateException {@link #close} has been called
* and this file manager cannot be reopened
*/
JavaFileObject getJavaFileForOutput(Location location,
String className,
Kind kind,
FileObject sibling)
throws IOException;
/**
* Gets a {@linkplain FileObject file object} for input
* representing the specified <a href="JavaFileManager.html#relative_name">relative
* name</a> in the specified package in the given location.
*
* <p>If the returned object represents a {@linkplain
* JavaFileObject.Kind#SOURCE source} or {@linkplain
* JavaFileObject.Kind#CLASS class} file, it must be an instance
* of {@link JavaFileObject}.
*
* <p>Informally, the file object returned by this method is
* located in the concatenation of the location, package name, and
* relative name. For example, to locate the properties file
* "resources/compiler.properties" in the package
* "com.sun.tools.javac" in the {@linkplain
* StandardLocation#SOURCE_PATH SOURCE_PATH} location, this method
* might be called like so:
*
* <pre>getFileForInput(SOURCE_PATH, "com.sun.tools.javac", "resources/compiler.properties");</pre>
*
* <p>If the call was executed on Windows, with SOURCE_PATH set to
* <code>"C:\Documents and Settings\UncleBob\src\share\classes"</code>,
* a valid result would be a file object representing the file
* <code>"C:\Documents and Settings\UncleBob\src\share\classes\com\sun\tools\javac\resources\compiler.properties"</code>.
*
* @param location a location
* @param packageName a package name
* @param relativeName a relative name
* @return a file object, might return {@code null} if the file
* does not exist
* @throws IllegalArgumentException if the location is not known
* to this file manager and the file manager does not support
* unknown locations, or if {@code relativeName} is not valid
* @throws IOException if an I/O error occurred, or if {@link
* #close} has been called and this file manager cannot be
* reopened
* @throws IllegalStateException if {@link #close} has been called
* and this file manager cannot be reopened
*/
FileObject getFileForInput(Location location,
String packageName,
String relativeName)
throws IOException;
/**
* Gets a {@linkplain FileObject file object} for output
* representing the specified <a href="JavaFileManager.html#relative_name">relative
* name</a> in the specified package in the given location.
*
* <p>Optionally, this file manager might consider the sibling as
* a hint for where to place the output. The exact semantics of
* this hint is unspecified. The JDK compiler, javac, for
* example, will place class files in the same directories as
* originating source files unless a class file output directory
* is provided. To facilitate this behavior, javac might provide
* the originating source file as sibling when calling this
* method.
*
* <p>If the returned object represents a {@linkplain
* JavaFileObject.Kind#SOURCE source} or {@linkplain
* JavaFileObject.Kind#CLASS class} file, it must be an instance
* of {@link JavaFileObject}.
*
* <p>Informally, the file object returned by this method is
* located in the concatenation of the location, package name, and
* relative name or next to the sibling argument. See {@link
* #getFileForInput getFileForInput} for an example.
*
* @param location a location
* @param packageName a package name
* @param relativeName a relative name
* @param sibling a file object to be used as hint for placement;
* might be {@code null}
* @return a file object
* @throws IllegalArgumentException if sibling is not known to
* this file manager, or if the location is not known to this file
* manager and the file manager does not support unknown
* locations, or if {@code relativeName} is not valid
* @throws IOException if an I/O error occurred, or if {@link
* #close} has been called and this file manager cannot be
* reopened
* @throws IllegalStateException if {@link #close} has been called
* and this file manager cannot be reopened
*/
FileObject getFileForOutput(Location location,
String packageName,
String relativeName,
FileObject sibling)
throws IOException;
/**
* Flushes any resources opened for output by this file manager
* directly or indirectly. Flushing a closed file manager has no
* effect.
*
* @throws IOException if an I/O error occurred
* @see #close
*/
void flush() throws IOException;
/**
* Releases any resources opened by this file manager directly or
* indirectly. This might render this file manager useless and
* the effect of subsequent calls to methods on this object or any
* objects obtained through this object is undefined unless
* explicitly allowed. However, closing a file manager which has
* already been closed has no effect.
*
* @throws IOException if an I/O error occurred
* @see #flush
*/
void close() throws IOException;
}
| 17,597 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
FileObject.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/tools/FileObject.java | /*
* Copyright (c) 2006, 2008, 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 javax.tools;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
import java.io.Writer;
import java.net.URI;
/**
* File abstraction for tools. In this context, <em>file</em> means
* an abstraction of regular files and other sources of data. For
* example, a file object can be used to represent regular files,
* memory cache, or data in databases.
*
* <p>All methods in this interface might throw a SecurityException if
* a security exception occurs.
*
* <p>Unless explicitly allowed, all methods in this interface might
* throw a NullPointerException if given a {@code null} argument.
*
* @author Peter von der Ahé
* @author Jonathan Gibbons
* @since 1.6
*/
public interface FileObject {
/**
* Returns a URI identifying this file object.
* @return a URI
*/
URI toUri();
/**
* Gets a user-friendly name for this file object. The exact
* value returned is not specified but implementations should take
* care to preserve names as given by the user. For example, if
* the user writes the filename {@code "BobsApp\Test.java"} on
* the command line, this method should return {@code
* "BobsApp\Test.java"} whereas the {@linkplain #toUri toUri}
* method might return {@code
* file:///C:/Documents%20and%20Settings/UncleBob/BobsApp/Test.java}.
*
* @return a user-friendly name
*/
String getName();
/**
* Gets an InputStream for this file object.
*
* @return an InputStream
* @throws IllegalStateException if this file object was
* opened for writing and does not support reading
* @throws UnsupportedOperationException if this kind of file
* object does not support byte access
* @throws IOException if an I/O error occurred
*/
InputStream openInputStream() throws IOException;
/**
* Gets an OutputStream for this file object.
*
* @return an OutputStream
* @throws IllegalStateException if this file object was
* opened for reading and does not support writing
* @throws UnsupportedOperationException if this kind of
* file object does not support byte access
* @throws IOException if an I/O error occurred
*/
OutputStream openOutputStream() throws IOException;
/**
* Gets a reader for this object. The returned reader will
* replace bytes that cannot be decoded with the default
* translation character. In addition, the reader may report a
* diagnostic unless {@code ignoreEncodingErrors} is true.
*
* @param ignoreEncodingErrors ignore encoding errors if true
* @return a Reader
* @throws IllegalStateException if this file object was
* opened for writing and does not support reading
* @throws UnsupportedOperationException if this kind of
* file object does not support character access
* @throws IOException if an I/O error occurred
*/
Reader openReader(boolean ignoreEncodingErrors) throws IOException;
/**
* Gets the character content of this file object, if available.
* Any byte that cannot be decoded will be replaced by the default
* translation character. In addition, a diagnostic may be
* reported unless {@code ignoreEncodingErrors} is true.
*
* @param ignoreEncodingErrors ignore encoding errors if true
* @return a CharSequence if available; {@code null} otherwise
* @throws IllegalStateException if this file object was
* opened for writing and does not support reading
* @throws UnsupportedOperationException if this kind of
* file object does not support character access
* @throws IOException if an I/O error occurred
*/
CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException;
/**
* Gets a Writer for this file object.
*
* @return a Writer
* @throws IllegalStateException if this file object was
* opened for reading and does not support writing
* @throws UnsupportedOperationException if this kind of
* file object does not support character access
* @throws IOException if an I/O error occurred
*/
Writer openWriter() throws IOException;
/**
* Gets the time this file object was last modified. The time is
* measured in milliseconds since the epoch (00:00:00 GMT, January
* 1, 1970).
*
* @return the time this file object was last modified; or 0 if
* the file object does not exist, if an I/O error occurred, or if
* the operation is not supported
*/
long getLastModified();
/**
* Deletes this file object. In case of errors, returns false.
* @return true if and only if this file object is successfully
* deleted; false otherwise
*/
boolean delete();
}
| 6,082 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
ToolProvider.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/tools/ToolProvider.java | /*
* Copyright (c) 2005, 2011, 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 javax.tools;
import java.io.File;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.net.URL;
import java.net.URLClassLoader;
import java.net.MalformedURLException;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.logging.Logger;
import java.util.logging.Level;
import static java.util.logging.Level.*;
/**
* Provides methods for locating tool providers, for example,
* providers of compilers. This class complements the
* functionality of {@link java.util.ServiceLoader}.
*
* @author Peter von der Ahé
* @since 1.6
*/
public class ToolProvider {
private static final String propertyName = "sun.tools.ToolProvider";
private static final String loggerName = "javax.tools";
/*
* Define the system property "sun.tools.ToolProvider" to enable
* debugging:
*
* java ... -Dsun.tools.ToolProvider ...
*/
static <T> T trace(Level level, Object reason) {
// NOTE: do not make this method private as it affects stack traces
try {
if (System.getProperty(propertyName) != null) {
StackTraceElement[] st = Thread.currentThread().getStackTrace();
String method = "???";
String cls = ToolProvider.class.getName();
if (st.length > 2) {
StackTraceElement frame = st[2];
method = String.format((Locale)null, "%s(%s:%s)",
frame.getMethodName(),
frame.getFileName(),
frame.getLineNumber());
cls = frame.getClassName();
}
Logger logger = Logger.getLogger(loggerName);
if (reason instanceof Throwable) {
logger.logp(level, cls, method,
reason.getClass().getName(), (Throwable)reason);
} else {
logger.logp(level, cls, method, String.valueOf(reason));
}
}
} catch (SecurityException ex) {
System.err.format((Locale)null, "%s: %s; %s%n",
ToolProvider.class.getName(),
reason,
ex.getLocalizedMessage());
}
return null;
}
private static final String defaultJavaCompilerName
= "com.sun.tools.javac.api.JavacTool";
/**
* Gets the Java™ programming language compiler provided
* with this platform.
* @return the compiler provided with this platform or
* {@code null} if no compiler is provided
*/
public static JavaCompiler getSystemJavaCompiler() {
return instance().getSystemTool(JavaCompiler.class, defaultJavaCompilerName);
}
/**
* Returns the class loader for tools provided with this platform.
* This does not include user-installed tools. Use the
* {@linkplain java.util.ServiceLoader service provider mechanism}
* for locating user installed tools.
*
* @return the class loader for tools provided with this platform
* or {@code null} if no tools are provided
*/
public static ClassLoader getSystemToolClassLoader() {
try {
Class<? extends JavaCompiler> c =
instance().getSystemToolClass(JavaCompiler.class, defaultJavaCompilerName);
return c.getClassLoader();
} catch (Throwable e) {
return trace(WARNING, e);
}
}
private static ToolProvider instance;
private static synchronized ToolProvider instance() {
if (instance == null)
instance = new ToolProvider();
return instance;
}
// Cache for tool classes.
// Use weak references to avoid keeping classes around unnecessarily
private Map<String, Reference<Class<?>>> toolClasses = new HashMap<String, Reference<Class<?>>>();
// Cache for tool classloader.
// Use a weak reference to avoid keeping it around unnecessarily
private Reference<ClassLoader> refToolClassLoader = null;
private ToolProvider() { }
private <T> T getSystemTool(Class<T> clazz, String name) {
Class<? extends T> c = getSystemToolClass(clazz, name);
try {
return c.asSubclass(clazz).newInstance();
} catch (Throwable e) {
trace(WARNING, e);
return null;
}
}
private <T> Class<? extends T> getSystemToolClass(Class<T> clazz, String name) {
Reference<Class<?>> refClass = toolClasses.get(name);
Class<?> c = (refClass == null ? null : refClass.get());
if (c == null) {
try {
c = findSystemToolClass(name);
} catch (Throwable e) {
return trace(WARNING, e);
}
toolClasses.put(name, new WeakReference<Class<?>>(c));
}
return c.asSubclass(clazz);
}
private static final String[] defaultToolsLocation = { "lib", "tools.jar" };
private Class<?> findSystemToolClass(String toolClassName)
throws MalformedURLException, ClassNotFoundException
{
// try loading class directly, in case tool is on the bootclasspath
try {
return Class.forName(toolClassName, false, null);
} catch (ClassNotFoundException e) {
trace(FINE, e);
// if tool not on bootclasspath, look in default tools location (tools.jar)
ClassLoader cl = (refToolClassLoader == null ? null : refToolClassLoader.get());
if (cl == null) {
File file = new File(System.getProperty("java.home"));
if (file.getName().equalsIgnoreCase("jre"))
file = file.getParentFile();
for (String name : defaultToolsLocation)
file = new File(file, name);
// if tools not found, no point in trying a URLClassLoader
// so rethrow the original exception.
if (!file.exists())
throw e;
URL[] urls = { file.toURI().toURL() };
trace(FINE, urls[0].toString());
cl = URLClassLoader.newInstance(urls);
refToolClassLoader = new WeakReference<ClassLoader>(cl);
}
return Class.forName(toolClassName, false, cl);
}
}
}
| 7,712 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
ForwardingJavaFileObject.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/tools/ForwardingJavaFileObject.java | /*
* Copyright (c) 2005, 2006, 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 javax.tools;
import javax.lang.model.element.Modifier;
import javax.lang.model.element.NestingKind;
/**
* Forwards calls to a given file object. Subclasses of this class
* might override some of these methods and might also provide
* additional fields and methods.
*
* @param <F> the kind of file object forwarded to by this object
* @author Peter von der Ahé
* @since 1.6
*/
public class ForwardingJavaFileObject<F extends JavaFileObject>
extends ForwardingFileObject<F>
implements JavaFileObject
{
/**
* Creates a new instance of ForwardingJavaFileObject.
* @param fileObject delegate to this file object
*/
protected ForwardingJavaFileObject(F fileObject) {
super(fileObject);
}
public Kind getKind() {
return fileObject.getKind();
}
public boolean isNameCompatible(String simpleName, Kind kind) {
return fileObject.isNameCompatible(simpleName, kind);
}
public NestingKind getNestingKind() { return fileObject.getNestingKind(); }
public Modifier getAccessLevel() { return fileObject.getAccessLevel(); }
}
| 2,338 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
StandardLocation.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/tools/StandardLocation.java | /*
* Copyright (c) 2006, 2008, 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 javax.tools;
import javax.tools.JavaFileManager.Location;
import java.util.concurrent.*;
/**
* Standard locations of file objects.
*
* @author Peter von der Ahé
* @since 1.6
*/
public enum StandardLocation implements Location {
/**
* Location of new class files.
*/
CLASS_OUTPUT,
/**
* Location of new source files.
*/
SOURCE_OUTPUT,
/**
* Location to search for user class files.
*/
CLASS_PATH,
/**
* Location to search for existing source files.
*/
SOURCE_PATH,
/**
* Location to search for annotation processors.
*/
ANNOTATION_PROCESSOR_PATH,
/**
* Location to search for platform classes. Sometimes called
* the boot class path.
*/
PLATFORM_CLASS_PATH;
/**
* Gets a location object with the given name. The following
* property must hold: {@code locationFor(x) ==
* locationFor(y)} if and only if {@code x.equals(y)}.
* The returned location will be an output location if and only if
* name ends with {@code "_OUTPUT"}.
*
* @param name a name
* @return a location
*/
public static Location locationFor(final String name) {
if (locations.isEmpty()) {
// can't use valueOf which throws IllegalArgumentException
for (Location location : values())
locations.putIfAbsent(location.getName(), location);
}
locations.putIfAbsent(name.toString(/* null-check */), new Location() {
public String getName() { return name; }
public boolean isOutputLocation() { return name.endsWith("_OUTPUT"); }
});
return locations.get(name);
}
//where
private static ConcurrentMap<String,Location> locations
= new ConcurrentHashMap<String,Location>();
public String getName() { return name(); }
public boolean isOutputLocation() {
return this == CLASS_OUTPUT || this == SOURCE_OUTPUT;
}
}
| 3,244 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
package-info.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/package-info.java | /*
* Copyright (c) 2005, 2006, 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.
*/
/**
* Classes and hierarchies of packages used to model the Java
* programming language.
*
* The members of this package and its subpackages are for use in
* language modeling and language processing tasks and APIs including,
* but not limited to, the {@linkplain javax.annotation.processing
* annotation processing} framework.
*
* <p> This language model follows a <i>mirror</i>-based design; see
*
* <blockquote>
* Gilad Bracha and David Ungar. <i>Mirrors: Design Principles for
* Meta-level Facilities of Object-Oriented Programming Languages</i>.
* In Proc. of the ACM Conf. on Object-Oriented Programming, Systems,
* Languages and Applications, October 2004.
* </blockquote>
*
* In particular, the model makes a distinction between static
* language constructs, like the {@linkplain javax.lang.model.element
* element} representing {@code java.util.Set}, and the family of
* {@linkplain javax.lang.model.type types} that may be associated
* with an element, like the raw type {@code java.util.Set}, {@code
* java.util.Set<String>}, and {@code java.util.Set<T>}.
*
* <p> Unless otherwise specified, methods in this package will throw
* a {@code NullPointerException} if given a {@code null} argument.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @since 1.6
*/
package javax.lang.model;
| 2,582 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
UnknownEntityException.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/UnknownEntityException.java | /*
* Copyright (c) 2009, 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 javax.lang.model;
/**
* Superclass of exceptions which indicate that an unknown kind of
* entity was encountered. This situation can occur if the language
* evolves and new kinds of constructs are introduced. Subclasses of
* this exception may be thrown by visitors to indicate that the
* visitor was created for a prior version of the language.
*
* <p>A common superclass for those exceptions allows a single catch
* block to have code handling them uniformly.
*
* @author Joseph D. Darcy
* @see javax.lang.model.element.UnknownElementException
* @see javax.lang.model.element.UnknownAnnotationValueException
* @see javax.lang.model.type.UnknownTypeException
* @since 1.7
*/
public class UnknownEntityException extends RuntimeException {
private static final long serialVersionUID = 269L;
/**
* Creates a new {@code UnknownEntityException} with the specified
* detail message.
*
* @param message the detail message
*/
protected UnknownEntityException(String message) {
super(message);
}
}
| 2,275 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
SourceVersion.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/SourceVersion.java | /*
* Copyright (c) 2005, 2006, 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 javax.lang.model;
import java.util.Collections;
import java.util.Set;
import java.util.HashSet;
/**
* Source versions of the Java™ programming language.
*
* See the appropriate edition of
* <cite>The Java™ Language Specification</cite>
* for information about a particular source version.
*
* <p>Note that additional source version constants will be added to
* model future releases of the language.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @since 1.6
*/
public enum SourceVersion {
/*
* Summary of language evoluation
* 1.1: nested classes
* 1.2: strictfp
* 1.3: no changes
* 1.4: assert
* 1.5: annotations, generics, autoboxing, var-args...
* 1.6: no changes
*/
/**
* The original version.
*
* The language described in
* <cite>The Java™ Language Specification, First Edition</cite>.
*/
RELEASE_0,
/**
* The version recognized by the Java Platform 1.1.
*
* The language is {@code RELEASE_0} augmented with nested classes as described in the 1.1 update to
* <cite>The Java™ Language Specification, First Edition</cite>.
*/
RELEASE_1,
/**
* The version recognized by the Java 2 Platform, Standard Edition,
* v 1.2.
*
* The language described in
* <cite>The Java™ Language Specification,
* Second Edition</cite>, which includes the {@code
* strictfp} modifier.
*/
RELEASE_2,
/**
* The version recognized by the Java 2 Platform, Standard Edition,
* v 1.3.
*
* No major changes from {@code RELEASE_2}.
*/
RELEASE_3,
/**
* The version recognized by the Java 2 Platform, Standard Edition,
* v 1.4.
*
* Added a simple assertion facility.
*/
RELEASE_4,
/**
* The version recognized by the Java 2 Platform, Standard
* Edition 5.0.
*
* The language described in
* <cite>The Java™ Language Specification,
* Third Edition</cite>. First release to support
* generics, annotations, autoboxing, var-args, enhanced {@code
* for} loop, and hexadecimal floating-point literals.
*/
RELEASE_5,
/**
* The version recognized by the Java Platform, Standard Edition
* 6.
*
* No major changes from {@code RELEASE_5}.
*/
RELEASE_6,
/**
* The version recognized by the Java Platform, Standard Edition
* 7.
*
* @since 1.7
*/
RELEASE_7;
// Note that when adding constants for newer releases, the
// behavior of latest() and latestSupported() must be updated too.
/**
* Returns the latest source version that can be modeled.
*
* @return the latest source version that can be modeled
*/
public static SourceVersion latest() {
return RELEASE_7;
}
private static final SourceVersion latestSupported = getLatestSupported();
private static SourceVersion getLatestSupported() {
try {
String specVersion = System.getProperty("java.specification.version");
if ("1.7".equals(specVersion))
return RELEASE_7;
else if ("1.6".equals(specVersion))
return RELEASE_6;
} catch (SecurityException se) {}
return RELEASE_5;
}
/**
* Returns the latest source version fully supported by the
* current execution environment. {@code RELEASE_5} or later must
* be returned.
*
* @return the latest source version that is fully supported
*/
public static SourceVersion latestSupported() {
return latestSupported;
}
/**
* Returns whether or not {@code name} is a syntactically valid
* identifier (simple name) or keyword in the latest source
* version. The method returns {@code true} if the name consists
* of an initial character for which {@link
* Character#isJavaIdentifierStart(int)} returns {@code true},
* followed only by characters for which {@link
* Character#isJavaIdentifierPart(int)} returns {@code true}.
* This pattern matches regular identifiers, keywords, and the
* literals {@code "true"}, {@code "false"}, and {@code "null"}.
* The method returns {@code false} for all other strings.
*
* @param name the string to check
* @return {@code true} if this string is a
* syntactically valid identifier or keyword, {@code false}
* otherwise.
*/
public static boolean isIdentifier(CharSequence name) {
String id = name.toString();
if (id.length() == 0) {
return false;
}
int cp = id.codePointAt(0);
if (!Character.isJavaIdentifierStart(cp)) {
return false;
}
for (int i = Character.charCount(cp);
i < id.length();
i += Character.charCount(cp)) {
cp = id.codePointAt(i);
if (!Character.isJavaIdentifierPart(cp)) {
return false;
}
}
return true;
}
/**
* Returns whether or not {@code name} is a syntactically valid
* qualified name in the latest source version. Unlike {@link
* #isIdentifier isIdentifier}, this method returns {@code false}
* for keywords and literals.
*
* @param name the string to check
* @return {@code true} if this string is a
* syntactically valid name, {@code false} otherwise.
* @jls 6.2 Names and Identifiers
*/
public static boolean isName(CharSequence name) {
String id = name.toString();
for(String s : id.split("\\.", -1)) {
if (!isIdentifier(s) || isKeyword(s))
return false;
}
return true;
}
private final static Set<String> keywords;
static {
Set<String> s = new HashSet<String>();
String [] kws = {
"abstract", "continue", "for", "new", "switch",
"assert", "default", "if", "package", "synchronized",
"boolean", "do", "goto", "private", "this",
"break", "double", "implements", "protected", "throw",
"byte", "else", "import", "public", "throws",
"case", "enum", "instanceof", "return", "transient",
"catch", "extends", "int", "short", "try",
"char", "final", "interface", "static", "void",
"class", "finally", "long", "strictfp", "volatile",
"const", "float", "native", "super", "while",
// literals
"null", "true", "false"
};
for(String kw : kws)
s.add(kw);
keywords = Collections.unmodifiableSet(s);
}
/**
* Returns whether or not {@code s} is a keyword or literal in the
* latest source version.
*
* @param s the string to check
* @return {@code true} if {@code s} is a keyword or literal, {@code false} otherwise.
*/
public static boolean isKeyword(CharSequence s) {
String keywordOrLiteral = s.toString();
return keywords.contains(keywordOrLiteral);
}
}
| 8,628 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
package-info.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/element/package-info.java | /*
* Copyright (c) 2005, 2010, 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.
*/
/**
* Interfaces used to model elements of the Java programming language.
*
* The term "element" in this package is used to refer to program
* elements, the declared entities that make up a program. Elements
* include classes, interfaces, methods, constructors, and fields.
* The interfaces in this package do not model the structure of a
* program inside a method body; for example there is no
* representation of a {@code for} loop or {@code try}-{@code finally}
* block. However, the interfaces can model some structures only
* appearing inside method bodies, such as local variables and
* anonymous classes.
*
* <p>When used in the context of annotation processing, an accurate
* model of the element being represented must be returned. As this
* is a language model, the source code provides the fiducial
* (reference) representation of the construct in question rather than
* a representation in an executable output like a class file.
* Executable output may serve as the basis for creating a modeling
* element. However, the process of translating source code to
* executable output may not permit recovering some aspects of the
* source code representation. For example, annotations with
* {@linkplain java.lang.annotation.RetentionPolicy#SOURCE source}
* {@linkplain java.lang.annotation.Retention retention} cannot be
* recovered from class files and class files might not be able to
* provide source position information. The {@linkplain
* javax.lang.model.element.Modifier modifiers} on an element may
* differ in some cases including
*
* <ul>
* <li> {@code strictfp} on a class or interface
* <li> {@code final} on a parameter
* <li> {@code protected}, {@code private}, and {@code static} on classes and interfaces
* </ul>
*
* Additionally, synthetic constructs in a class file, such as
* accessor methods used in implementing nested classes and bridge
* methods used in implementing covariant returns, are translation
* artifacts outside of this model.
*
* <p>During annotation processing, operating on incomplete or
* erroneous programs is necessary; however, there are fewer
* guarantees about the nature of the resulting model. If the source
* code is not syntactically well-formed or has some other
* irrecoverable error that could not be removed by the generation of
* new types, a model may or may not be provided as a quality of
* implementation issue.
* If a program is syntactically valid but erroneous in some other
* fashion, any returned model must have no less information than if
* all the method bodies in the program were replaced by {@code "throw
* new RuntimeException();"}. If a program refers to a missing type XYZ,
* the returned model must contain no less information than if the
* declaration of type XYZ were assumed to be {@code "class XYZ {}"},
* {@code "interface XYZ {}"}, {@code "enum XYZ {}"}, or {@code
* "@interface XYZ {}"}. If a program refers to a missing type {@code
* XYZ<K1, ... ,Kn>}, the returned model must contain no less
* information than if the declaration of XYZ were assumed to be
* {@code "class XYZ<T1, ... ,Tn> {}"} or {@code "interface XYZ<T1,
* ... ,Tn> {}"}
*
* <p> Unless otherwise specified in a particular implementation, the
* collections returned by methods in this package should be expected
* to be unmodifiable by the caller and unsafe for concurrent access.
*
* <p> Unless otherwise specified, methods in this package will throw
* a {@code NullPointerException} if given a {@code null} argument.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @since 1.6
*/
package javax.lang.model.element;
| 4,904 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
UnknownElementException.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/element/UnknownElementException.java | /*
* Copyright (c) 2005, 2009, 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 javax.lang.model.element;
import javax.lang.model.UnknownEntityException;
/**
* Indicates that an unknown kind of element was encountered. This
* can occur if the language evolves and new kinds of elements are
* added to the {@code Element} hierarchy. May be thrown by an
* {@linkplain ElementVisitor element visitor} to indicate that the
* visitor was created for a prior version of the language.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @see ElementVisitor#visitUnknown
* @since 1.6
*/
public class UnknownElementException extends UnknownEntityException {
private static final long serialVersionUID = 269L;
private transient Element element;
private transient Object parameter;
/**
* Creates a new {@code UnknownElementException}. The {@code p}
* parameter may be used to pass in an additional argument with
* information about the context in which the unknown element was
* encountered; for example, the visit methods of {@link
* ElementVisitor} may pass in their additional parameter.
*
* @param e the unknown element, may be {@code null}
* @param p an additional parameter, may be {@code null}
*/
public UnknownElementException(Element e, Object p) {
super("Unknown element: " + e);
element = e;
this.parameter = p;
}
/**
* Returns the unknown element.
* The value may be unavailable if this exception has been
* serialized and then read back in.
*
* @return the unknown element, or {@code null} if unavailable
*/
public Element getUnknownElement() {
return element;
}
/**
* Returns the additional argument.
*
* @return the additional argument
*/
public Object getArgument() {
return parameter;
}
}
| 3,080 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
AnnotationValueVisitor.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/element/AnnotationValueVisitor.java | /*
* Copyright (c) 2005, 2006, 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 javax.lang.model.element;
import java.util.List;
import javax.lang.model.type.TypeMirror;
/**
* A visitor of the values of annotation type elements, using a
* variant of the visitor design pattern. Unlike a standard visitor
* which dispatches based on the concrete type of a member of a type
* hierarchy, this visitor dispatches based on the type of data
* stored; there are no distinct subclasses for storing, for example,
* {@code boolean} values versus {@code int} values. Classes
* implementing this interface are used to operate on a value when the
* type of that value is unknown at compile time. When a visitor is
* passed to a value's {@link AnnotationValue#accept accept} method,
* the <tt>visit<i>XYZ</i></tt> method applicable to that value is
* invoked.
*
* <p> Classes implementing this interface may or may not throw a
* {@code NullPointerException} if the additional parameter {@code p}
* is {@code null}; see documentation of the implementing class for
* details.
*
* <p> <b>WARNING:</b> It is possible that methods will be added to
* this interface to accommodate new, currently unknown, language
* structures added to future versions of the Java™ programming
* language. Therefore, visitor classes directly implementing this
* interface may be source incompatible with future versions of the
* platform. To avoid this source incompatibility, visitor
* implementations are encouraged to instead extend the appropriate
* abstract visitor class that implements this interface. However, an
* API should generally use this visitor interface as the type for
* parameters, return type, etc. rather than one of the abstract
* classes.
*
* @param <R> the return type of this visitor's methods
* @param <P> the type of the additional parameter to this visitor's methods.
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @since 1.6
*/
public interface AnnotationValueVisitor<R, P> {
/**
* Visits an annotation value.
* @param av the value to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
*/
R visit(AnnotationValue av, P p);
/**
* A convenience method equivalent to {@code v.visit(av, null)}.
* @param av the value to visit
* @return a visitor-specified result
*/
R visit(AnnotationValue av);
/**
* Visits a {@code boolean} value in an annotation.
* @param b the value being visited
* @param p a visitor-specified parameter
* @return the result of the visit
*/
R visitBoolean(boolean b, P p);
/**
* Visits a {@code byte} value in an annotation.
* @param b the value being visited
* @param p a visitor-specified parameter
* @return the result of the visit
*/
R visitByte(byte b, P p);
/**
* Visits a {@code char} value in an annotation.
* @param c the value being visited
* @param p a visitor-specified parameter
* @return the result of the visit
*/
R visitChar(char c, P p);
/**
* Visits a {@code double} value in an annotation.
* @param d the value being visited
* @param p a visitor-specified parameter
* @return the result of the visit
*/
R visitDouble(double d, P p);
/**
* Visits a {@code float} value in an annotation.
* @param f the value being visited
* @param p a visitor-specified parameter
* @return the result of the visit
*/
R visitFloat(float f, P p);
/**
* Visits an {@code int} value in an annotation.
* @param i the value being visited
* @param p a visitor-specified parameter
* @return the result of the visit
*/
R visitInt(int i, P p);
/**
* Visits a {@code long} value in an annotation.
* @param i the value being visited
* @param p a visitor-specified parameter
* @return the result of the visit
*/
R visitLong(long i, P p);
/**
* Visits a {@code short} value in an annotation.
* @param s the value being visited
* @param p a visitor-specified parameter
* @return the result of the visit
*/
R visitShort(short s, P p);
/**
* Visits a string value in an annotation.
* @param s the value being visited
* @param p a visitor-specified parameter
* @return the result of the visit
*/
R visitString(String s, P p);
/**
* Visits a type value in an annotation.
* @param t the value being visited
* @param p a visitor-specified parameter
* @return the result of the visit
*/
R visitType(TypeMirror t, P p);
/**
* Visits an {@code enum} value in an annotation.
* @param c the value being visited
* @param p a visitor-specified parameter
* @return the result of the visit
*/
R visitEnumConstant(VariableElement c, P p);
/**
* Visits an annotation value in an annotation.
* @param a the value being visited
* @param p a visitor-specified parameter
* @return the result of the visit
*/
R visitAnnotation(AnnotationMirror a, P p);
/**
* Visits an array value in an annotation.
* @param vals the value being visited
* @param p a visitor-specified parameter
* @return the result of the visit
*/
R visitArray(List<? extends AnnotationValue> vals, P p);
/**
* Visits an unknown kind of annotation value.
* This can occur if the language evolves and new kinds
* of value can be stored in an annotation.
* @param av the unknown value being visited
* @param p a visitor-specified parameter
* @return the result of the visit
* @throws UnknownAnnotationValueException
* a visitor implementation may optionally throw this exception
*/
R visitUnknown(AnnotationValue av, P p);
}
| 7,120 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
VariableElement.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/element/VariableElement.java | /*
* Copyright (c) 2005, 2011, 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 javax.lang.model.element;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.Elements;
/**
* Represents a field, {@code enum} constant, method or constructor
* parameter, local variable, resource variable, or exception
* parameter.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @since 1.6
*/
public interface VariableElement extends Element {
/**
* Returns the value of this variable if this is a {@code final}
* field initialized to a compile-time constant. Returns {@code
* null} otherwise. The value will be of a primitive type or a
* {@code String}. If the value is of a primitive type, it is
* wrapped in the appropriate wrapper class (such as {@link
* Integer}).
*
* <p>Note that not all {@code final} fields will have
* constant values. In particular, {@code enum} constants are
* <em>not</em> considered to be compile-time constants. To have a
* constant value, a field's type must be either a primitive type
* or {@code String}.
*
* @return the value of this variable if this is a {@code final}
* field initialized to a compile-time constant, or {@code null}
* otherwise
*
* @see Elements#getConstantExpression(Object)
* @jls 15.28 Constant Expression
* @jls 4.12.4 final Variables
*/
Object getConstantValue();
}
| 2,638 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
UnknownAnnotationValueException.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/element/UnknownAnnotationValueException.java | /*
* Copyright (c) 2005, 2009, 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 javax.lang.model.element;
import javax.lang.model.UnknownEntityException;
/**
* Indicates that an unknown kind of annotation value was encountered.
* This can occur if the language evolves and new kinds of annotation
* values can be stored in an annotation. May be thrown by an
* {@linkplain AnnotationValueVisitor annotation value visitor} to
* indicate that the visitor was created for a prior version of the
* language.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @see AnnotationValueVisitor#visitUnknown
* @since 1.6
*/
public class UnknownAnnotationValueException extends UnknownEntityException {
private static final long serialVersionUID = 269L;
private transient AnnotationValue av;
private transient Object parameter;
/**
* Creates a new {@code UnknownAnnotationValueException}. The
* {@code p} parameter may be used to pass in an additional
* argument with information about the context in which the
* unknown annotation value was encountered; for example, the
* visit methods of {@link AnnotationValueVisitor} may pass in
* their additional parameter.
*
* @param av the unknown annotation value, may be {@code null}
* @param p an additional parameter, may be {@code null}
*/
public UnknownAnnotationValueException(AnnotationValue av, Object p) {
super("Unknown annotation value: " + av);
this.av = av;
this.parameter = p;
}
/**
* Returns the unknown annotation value.
* The value may be unavailable if this exception has been
* serialized and then read back in.
*
* @return the unknown element, or {@code null} if unavailable
*/
public AnnotationValue getUnknownAnnotationValue() {
return av;
}
/**
* Returns the additional argument.
*
* @return the additional argument
*/
public Object getArgument() {
return parameter;
}
}
| 3,214 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
AnnotationMirror.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/element/AnnotationMirror.java | /*
* Copyright (c) 2005, 2006, 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 javax.lang.model.element;
import java.util.Map;
import javax.lang.model.type.DeclaredType;
/**
* Represents an annotation. An annotation associates a value with
* each element of an annotation type.
*
* <p> Annotations should be compared using the {@code equals}
* method. There is no guarantee that any particular annotation will
* always be represented by the same object.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @since 1.6
*/
public interface AnnotationMirror {
/**
* Returns the type of this annotation.
*
* @return the type of this annotation
*/
DeclaredType getAnnotationType();
/**
* Returns the values of this annotation's elements.
* This is returned in the form of a map that associates elements
* with their corresponding values.
* Only those elements with values explicitly present in the
* annotation are included, not those that are implicitly assuming
* their default values.
* The order of the map matches the order in which the
* values appear in the annotation's source.
*
* <p>Note that an annotation mirror of a marker annotation type
* will by definition have an empty map.
*
* <p>To fill in default values, use {@link
* javax.lang.model.util.Elements#getElementValuesWithDefaults
* getElementValuesWithDefaults}.
*
* @return the values of this annotation's elements,
* or an empty map if there are none
*/
Map<? extends ExecutableElement, ? extends AnnotationValue> getElementValues();
}
| 2,840 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
AnnotationValue.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/element/AnnotationValue.java | /*
* Copyright (c) 2005, 2006, 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 javax.lang.model.element;
import java.util.List;
import javax.lang.model.type.*;
/**
* Represents a value of an annotation type element.
* A value is of one of the following types:
* <ul><li> a wrapper class (such as {@link Integer}) for a primitive type
* <li> {@code String}
* <li> {@code TypeMirror}
* <li> {@code VariableElement} (representing an enum constant)
* <li> {@code AnnotationMirror}
* <li> {@code List<? extends AnnotationValue>}
* (representing the elements, in declared order, if the value is an array)
* </ul>
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @since 1.6
*/
public interface AnnotationValue {
/**
* Returns the value.
*
* @return the value
*/
Object getValue();
/**
* Returns a string representation of this value.
* This is returned in a form suitable for representing this value
* in the source code of an annotation.
*
* @return a string representation of this value
*/
String toString();
/**
* Applies a visitor to this value.
*
* @param <R> the return type of the visitor's methods
* @param <P> the type of the additional parameter to the visitor's methods
* @param v the visitor operating on this value
* @param p additional parameter to the visitor
* @return a visitor-specified result
*/
<R, P> R accept(AnnotationValueVisitor<R, P> v, P p);
}
| 2,721 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
NestingKind.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/element/NestingKind.java | /*
* Copyright (c) 2005, 2006, 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 javax.lang.model.element;
/**
* The <i>nesting kind</i> of a type element.
* Type elements come in four varieties:
* top-level, member, local, and anonymous.
* <i>Nesting kind</i> is a non-standard term used here to denote this
* classification.
*
* <p>Note that it is possible additional nesting kinds will be added
* in future versions of the platform.
*
* <p><b>Example:</b> The classes below are annotated with their nesting kind.
* <blockquote><pre>
*
* import java.lang.annotation.*;
* import static java.lang.annotation.RetentionPolicy.*;
* import javax.lang.model.element.*;
* import static javax.lang.model.element.NestingKind.*;
*
* @Nesting(TOP_LEVEL)
* public class NestingExamples {
* @Nesting(MEMBER)
* static class MemberClass1{}
*
* @Nesting(MEMBER)
* class MemberClass2{}
*
* public static void main(String... argv) {
* @Nesting(LOCAL)
* class LocalClass{};
*
* Class<?>[] classes = {
* NestingExamples.class,
* MemberClass1.class,
* MemberClass2.class,
* LocalClass.class
* };
*
* for(Class<?> clazz : classes) {
* System.out.format("%s is %s%n",
* clazz.getName(),
* clazz.getAnnotation(Nesting.class).value());
* }
* }
* }
*
* @Retention(RUNTIME)
* @interface Nesting {
* NestingKind value();
* }
* </pre></blockquote>
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @since 1.6
*/
public enum NestingKind {
TOP_LEVEL,
MEMBER,
LOCAL,
ANONYMOUS;
/**
* Does this constant correspond to a nested type element?
* A <i>nested</i> type element is any that is not top-level.
* An <i>inner</i> type element is any nested type element that
* is not {@linkplain Modifier#STATIC static}.
*/
public boolean isNested() {
return this != TOP_LEVEL;
}
}
| 3,271 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
QualifiedNameable.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/element/QualifiedNameable.java | /*
* Copyright (c) 2009, 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 javax.lang.model.element;
/**
* A mixin interface for an element that has a qualified name.
*
* @author Joseph D. Darcy
* @since 1.7
*/
public interface QualifiedNameable extends Element {
/**
* Returns the fully qualified name of an element.
*
* @return the fully qualified name of an element
*/
Name getQualifiedName();
}
| 1,574 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Element.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/element/Element.java | /*
* Copyright (c) 2005, 2011, 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 javax.lang.model.element;
import java.lang.annotation.Annotation;
import java.lang.annotation.AnnotationTypeMismatchException;
import java.lang.annotation.IncompleteAnnotationException;
import java.util.List;
import java.util.Set;
import javax.lang.model.element.Modifier;
import javax.lang.model.type.*;
import javax.lang.model.util.*;
/**
* Represents a program element such as a package, class, or method.
* Each element represents a static, language-level construct
* (and not, for example, a runtime construct of the virtual machine).
*
* <p> Elements should be compared using the {@link #equals(Object)}
* method. There is no guarantee that any particular element will
* always be represented by the same object.
*
* <p> To implement operations based on the class of an {@code
* Element} object, either use a {@linkplain ElementVisitor visitor} or
* use the result of the {@link #getKind} method. Using {@code
* instanceof} is <em>not</em> necessarily a reliable idiom for
* determining the effective class of an object in this modeling
* hierarchy since an implementation may choose to have a single object
* implement multiple {@code Element} subinterfaces.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @see Elements
* @see TypeMirror
* @since 1.6
*/
public interface Element {
/**
* Returns the type defined by this element.
*
* <p> A generic element defines a family of types, not just one.
* If this is a generic element, a <i>prototypical</i> type is
* returned. This is the element's invocation on the
* type variables corresponding to its own formal type parameters.
* For example,
* for the generic class element {@code C<N extends Number>},
* the parameterized type {@code C<N>} is returned.
* The {@link Types} utility interface has more general methods
* for obtaining the full range of types defined by an element.
*
* @see Types
*
* @return the type defined by this element
*/
TypeMirror asType();
/**
* Returns the {@code kind} of this element.
*
* @return the kind of this element
*/
ElementKind getKind();
/**
* Returns the annotations that are directly present on this element.
*
* <p> To get inherited annotations as well, use
* {@link Elements#getAllAnnotationMirrors(Element) getAllAnnotationMirrors}.
*
* @see ElementFilter
*
* @return the annotations directly present on this element;
* an empty list if there are none
*/
List<? extends AnnotationMirror> getAnnotationMirrors();
/**
* Returns this element's annotation for the specified type if
* such an annotation is present, else {@code null}. The
* annotation may be either inherited or directly present on this
* element.
*
* <p> The annotation returned by this method could contain an element
* whose value is of type {@code Class}.
* This value cannot be returned directly: information necessary to
* locate and load a class (such as the class loader to use) is
* not available, and the class might not be loadable at all.
* Attempting to read a {@code Class} object by invoking the relevant
* method on the returned annotation
* will result in a {@link MirroredTypeException},
* from which the corresponding {@link TypeMirror} may be extracted.
* Similarly, attempting to read a {@code Class[]}-valued element
* will result in a {@link MirroredTypesException}.
*
* <blockquote>
* <i>Note:</i> This method is unlike others in this and related
* interfaces. It operates on runtime reflective information —
* representations of annotation types currently loaded into the
* VM — rather than on the representations defined by and used
* throughout these interfaces. Consequently, calling methods on
* the returned annotation object can throw many of the exceptions
* that can be thrown when calling methods on an annotation object
* returned by core reflection. This method is intended for
* callers that are written to operate on a known, fixed set of
* annotation types.
* </blockquote>
*
* @param <A> the annotation type
* @param annotationType the {@code Class} object corresponding to
* the annotation type
* @return this element's annotation for the specified annotation
* type if present on this element, else {@code null}
*
* @see #getAnnotationMirrors()
* @see java.lang.reflect.AnnotatedElement#getAnnotation
* @see EnumConstantNotPresentException
* @see AnnotationTypeMismatchException
* @see IncompleteAnnotationException
* @see MirroredTypeException
* @see MirroredTypesException
*/
<A extends Annotation> A getAnnotation(Class<A> annotationType);
/**
* Returns the modifiers of this element, excluding annotations.
* Implicit modifiers, such as the {@code public} and {@code static}
* modifiers of interface members, are included.
*
* @return the modifiers of this element, or an empty set if there are none
*/
Set<Modifier> getModifiers();
/**
* Returns the simple (unqualified) name of this element. The
* name of a generic type does not include any reference to its
* formal type parameters.
*
* For example, the simple name of the type element {@code
* java.util.Set<E>} is {@code "Set"}.
*
* If this element represents an unnamed {@linkplain
* PackageElement#getSimpleName package}, an empty name is
* returned.
*
* If it represents a {@linkplain ExecutableElement#getSimpleName
* constructor}, the name "{@code <init>}" is returned. If it
* represents a {@linkplain ExecutableElement#getSimpleName static
* initializer}, the name "{@code <clinit>}" is returned.
*
* If it represents an {@linkplain TypeElement#getSimpleName
* anonymous class} or {@linkplain ExecutableElement#getSimpleName
* instance initializer}, an empty name is returned.
*
* @return the simple name of this element
*/
Name getSimpleName();
/**
* Returns the innermost element
* within which this element is, loosely speaking, enclosed.
* <ul>
* <li> If this element is one whose declaration is lexically enclosed
* immediately within the declaration of another element, that other
* element is returned.
*
* <li> If this is a {@linkplain TypeElement#getEnclosingElement
* top-level type}, its package is returned.
*
* <li> If this is a {@linkplain
* PackageElement#getEnclosingElement package}, {@code null} is
* returned.
*
* <li> If this is a {@linkplain
* TypeParameterElement#getEnclosingElement type parameter},
* {@linkplain TypeParameterElement#getGenericElement the
* generic element} of the type parameter is returned.
*
* </ul>
*
* @return the enclosing element, or {@code null} if there is none
* @see Elements#getPackageOf
*/
Element getEnclosingElement();
/**
* Returns the elements that are, loosely speaking, directly
* enclosed by this element.
*
* A class or interface is considered to enclose the fields,
* methods, constructors, and member types that it directly
* declares. This includes any (implicit) default constructor and
* the implicit {@code values} and {@code valueOf} methods of an
* enum type.
*
* A package encloses the top-level classes and interfaces within
* it, but is not considered to enclose subpackages.
*
* Other kinds of elements are not currently considered to enclose
* any elements; however, that may change as this API or the
* programming language evolves.
*
* <p>Note that elements of certain kinds can be isolated using
* methods in {@link ElementFilter}.
*
* @return the enclosed elements, or an empty list if none
* @see Elements#getAllMembers
* @jls 8.8.9 Default Constructor
* @jls 8.9 Enums
*/
List<? extends Element> getEnclosedElements();
/**
* Returns {@code true} if the argument represents the same
* element as {@code this}, or {@code false} otherwise.
*
* <p>Note that the identity of an element involves implicit state
* not directly accessible from the element's methods, including
* state about the presence of unrelated types. Element objects
* created by different implementations of these interfaces should
* <i>not</i> be expected to be equal even if "the same"
* element is being modeled; this is analogous to the inequality
* of {@code Class} objects for the same class file loaded through
* different class loaders.
*
* @param obj the object to be compared with this element
* @return {@code true} if the specified object represents the same
* element as this
*/
boolean equals(Object obj);
/**
* Obeys the general contract of {@link Object#hashCode Object.hashCode}.
*
* @see #equals
*/
int hashCode();
/**
* Applies a visitor to this element.
*
* @param <R> the return type of the visitor's methods
* @param <P> the type of the additional parameter to the visitor's methods
* @param v the visitor operating on this element
* @param p additional parameter to the visitor
* @return a visitor-specified result
*/
<R, P> R accept(ElementVisitor<R, P> v, P p);
}
| 10,963 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Name.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/element/Name.java | /*
* Copyright (c) 2006, 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 javax.lang.model.element;
/**
* An immutable sequence of characters. When created by the same
* implementation, objects implementing this interface must obey the
* general {@linkplain Object#equals equals contract} when compared
* with each other. Therefore, {@code Name} objects from the same
* implementation are usable in collections while {@code Name}s from
* different implementations may not work properly in collections.
*
* <p>An empty {@code Name} has a length of zero.
*
* <p>In the context of {@linkplain
* javax.annotation.processing.ProcessingEnvironment annotation
* processing}, the guarantees for "the same" implementation must
* include contexts where the {@linkplain javax.annotation.processing
* API mediated} side effects of {@linkplain
* javax.annotation.processing.Processor processors} could be visible
* to each other, including successive annotation processing
* {@linkplain javax.annotation.processing.RoundEnvironment rounds}.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @see javax.lang.model.util.Elements#getName
* @since 1.6
*/
public interface Name extends CharSequence {
/**
* Returns {@code true} if the argument represents the same
* name as {@code this}, and {@code false} otherwise.
*
* <p>Note that the identity of a {@code Name} is a function both
* of its content in terms of a sequence of characters as well as
* the implementation which created it.
*
* @param obj the object to be compared with this element
* @return {@code true} if the specified object represents the same
* name as this
* @see Element#equals
*/
boolean equals(Object obj);
/**
* Obeys the general contract of {@link Object#hashCode Object.hashCode}.
*
* @see #equals
*/
int hashCode();
/**
* Compares this name to the specified {@code CharSequence}. The result
* is {@code true} if and only if this name represents the same sequence
* of {@code char} values as the specified sequence.
*
* @return {@code true} if this name represents the same sequence
* of {@code char} values as the specified sequence, {@code false}
* otherwise
*
* @param cs The sequence to compare this name against
* @see String#contentEquals(CharSequence)
*/
boolean contentEquals(CharSequence cs);
}
| 3,644 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
PackageElement.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/element/PackageElement.java | /*
* Copyright (c) 2005, 2011, 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 javax.lang.model.element;
/**
* Represents a package program element. Provides access to information
* about the package and its members.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @see javax.lang.model.util.Elements#getPackageOf
* @since 1.6
*/
public interface PackageElement extends Element, QualifiedNameable {
/**
* Returns the fully qualified name of this package.
* This is also known as the package's <i>canonical</i> name.
*
* @return the fully qualified name of this package, or an
* empty name if this is an unnamed package
* @jls 6.7 Fully Qualified Names and Canonical Names
*/
Name getQualifiedName();
/**
* Returns the simple name of this package. For an unnamed
* package, an empty name is returned
*
* @return the simple name of this package or an empty name if
* this is an unnamed package
*/
@Override
Name getSimpleName();
/**
* Returns {@code true} is this is an unnamed package and {@code
* false} otherwise.
*
* @return {@code true} is this is an unnamed package and {@code
* false} otherwise
* @jls 7.4.2 Unnamed Packages
*/
boolean isUnnamed();
/**
* Returns {@code null} since a package is not enclosed by another
* element.
*
* @return {@code null}
*/
@Override
Element getEnclosingElement();
}
| 2,672 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
TypeParameterElement.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/element/TypeParameterElement.java | /*
* Copyright (c) 2005, 2011, 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 javax.lang.model.element;
import java.util.List;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.type.TypeVariable;
/**
* Represents a formal type parameter of a generic class, interface, method,
* or constructor element.
* A type parameter declares a {@link TypeVariable}.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @see TypeVariable
* @since 1.6
*/
public interface TypeParameterElement extends Element {
/**
* Returns the generic class, interface, method, or constructor that is
* parameterized by this type parameter.
*
* @return the generic class, interface, method, or constructor that is
* parameterized by this type parameter
*/
Element getGenericElement();
/**
* Returns the bounds of this type parameter.
* These are the types given by the {@code extends} clause
* used to declare this type parameter.
* If no explicit {@code extends} clause was used,
* then {@code java.lang.Object} is considered to be the sole bound.
*
* @return the bounds of this type parameter, or an empty list if
* there are none
*/
List<? extends TypeMirror> getBounds();
/**
* Returns the {@linkplain TypeParameterElement#getGenericElement generic element} of this type parameter.
*
* @return the generic element of this type parameter
*/
@Override
Element getEnclosingElement();
}
| 2,692 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
ElementVisitor.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/element/ElementVisitor.java | /*
* Copyright (c) 2005, 2010, 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 javax.lang.model.element;
import javax.lang.model.util.*;
/**
* A visitor of program elements, in the style of the visitor design
* pattern. Classes implementing this interface are used to operate
* on an element when the kind of element is unknown at compile time.
* When a visitor is passed to an element's {@link Element#accept
* accept} method, the <tt>visit<i>XYZ</i></tt> method most applicable
* to that element is invoked.
*
* <p> Classes implementing this interface may or may not throw a
* {@code NullPointerException} if the additional parameter {@code p}
* is {@code null}; see documentation of the implementing class for
* details.
*
* <p> <b>WARNING:</b> It is possible that methods will be added to
* this interface to accommodate new, currently unknown, language
* structures added to future versions of the Java™ programming
* language. Therefore, visitor classes directly implementing this
* interface may be source incompatible with future versions of the
* platform. To avoid this source incompatibility, visitor
* implementations are encouraged to instead extend the appropriate
* abstract visitor class that implements this interface. However, an
* API should generally use this visitor interface as the type for
* parameters, return type, etc. rather than one of the abstract
* classes.
*
* @param <R> the return type of this visitor's methods. Use {@link
* Void} for visitors that do not need to return results.
* @param <P> the type of the additional parameter to this visitor's
* methods. Use {@code Void} for visitors that do not need an
* additional parameter.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @see AbstractElementVisitor6
* @see AbstractElementVisitor7
* @since 1.6
*/
public interface ElementVisitor<R, P> {
/**
* Visits an element.
* @param e the element to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
*/
R visit(Element e, P p);
/**
* A convenience method equivalent to {@code v.visit(e, null)}.
* @param e the element to visit
* @return a visitor-specified result
*/
R visit(Element e);
/**
* Visits a package element.
* @param e the element to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
*/
R visitPackage(PackageElement e, P p);
/**
* Visits a type element.
* @param e the element to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
*/
R visitType(TypeElement e, P p);
/**
* Visits a variable element.
* @param e the element to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
*/
R visitVariable(VariableElement e, P p);
/**
* Visits an executable element.
* @param e the element to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
*/
R visitExecutable(ExecutableElement e, P p);
/**
* Visits a type parameter element.
* @param e the element to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
*/
R visitTypeParameter(TypeParameterElement e, P p);
/**
* Visits an unknown kind of element.
* This can occur if the language evolves and new kinds
* of elements are added to the {@code Element} hierarchy.
*
* @param e the element to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
* @throws UnknownElementException
* a visitor implementation may optionally throw this exception
*/
R visitUnknown(Element e, P p);
}
| 5,073 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Parameterizable.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/element/Parameterizable.java | /*
* Copyright (c) 2009, 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 javax.lang.model.element;
import java.util.List;
/**
* A mixin interface for an element that has type parameters.
*
* @author Joseph D. Darcy
* @since 1.7
*/
public interface Parameterizable extends Element {
/**
* Returns the formal type parameters of the type element in
* declaration order.
*
* @return the formal type parameters, or an empty list
* if there are none
*/
List<? extends TypeParameterElement> getTypeParameters();
}
| 1,695 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
TypeElement.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/element/TypeElement.java | /*
* Copyright (c) 2005, 2011, 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 javax.lang.model.element;
import java.util.List;
import javax.lang.model.type.*;
import javax.lang.model.util.*;
/**
* Represents a class or interface program element. Provides access
* to information about the type and its members. Note that an enum
* type is a kind of class and an annotation type is a kind of
* interface.
*
* <p> <a name="ELEM_VS_TYPE"></a>
* While a {@code TypeElement} represents a class or interface
* <i>element</i>, a {@link DeclaredType} represents a class
* or interface <i>type</i>, the latter being a use
* (or <i>invocation</i>) of the former.
* The distinction is most apparent with generic types,
* for which a single element can define a whole
* family of types. For example, the element
* {@code java.util.Set} corresponds to the parameterized types
* {@code java.util.Set<String>} and {@code java.util.Set<Number>}
* (and many others), and to the raw type {@code java.util.Set}.
*
* <p> Each method of this interface that returns a list of elements
* will return them in the order that is natural for the underlying
* source of program information. For example, if the underlying
* source of information is Java source code, then the elements will be
* returned in source code order.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @see DeclaredType
* @since 1.6
*/
public interface TypeElement extends Element, Parameterizable, QualifiedNameable {
/**
* {@inheritDoc}
*
* <p> Note that as a particular instance of the {@linkplain
* javax.lang.model.element general accuracy requirements} and the
* ordering behavior required of this interface, the list of
* enclosed elements will be returned in the natural order for the
* originating source of information about the type. For example,
* if the information about the type is originating from a source
* file, the elements will be returned in source code order.
* (However, in that case the the ordering of synthesized
* elements, such as a default constructor, is not specified.)
*
* @return the enclosed elements in proper order, or an empty list if none
*/
List<? extends Element> getEnclosedElements();
/**
* Returns the <i>nesting kind</i> of this type element.
*
* @return the nesting kind of this type element
*/
NestingKind getNestingKind();
/**
* Returns the fully qualified name of this type element.
* More precisely, it returns the <i>canonical</i> name.
* For local and anonymous classes, which do not have canonical names,
* an empty name is returned.
*
* <p>The name of a generic type does not include any reference
* to its formal type parameters.
* For example, the fully qualified name of the interface
* {@code java.util.Set<E>} is "{@code java.util.Set}".
* Nested types use "{@code .}" as a separator, as in
* "{@code java.util.Map.Entry}".
*
* @return the fully qualified name of this class or interface, or
* an empty name if none
*
* @see Elements#getBinaryName
* @jls 6.7 Fully Qualified Names and Canonical Names
*/
Name getQualifiedName();
/**
* Returns the simple name of this type element.
*
* For an anonymous class, an empty name is returned.
*
* @return the simple name of this class or interface,
* an empty name for an anonymous class
*
*/
@Override
Name getSimpleName();
/**
* Returns the direct superclass of this type element.
* If this type element represents an interface or the class
* {@code java.lang.Object}, then a {@link NoType}
* with kind {@link TypeKind#NONE NONE} is returned.
*
* @return the direct superclass, or a {@code NoType} if there is none
*/
TypeMirror getSuperclass();
/**
* Returns the interface types directly implemented by this class
* or extended by this interface.
*
* @return the interface types directly implemented by this class
* or extended by this interface, or an empty list if there are none
*/
List<? extends TypeMirror> getInterfaces();
/**
* Returns the formal type parameters of this type element
* in declaration order.
*
* @return the formal type parameters, or an empty list
* if there are none
*/
List<? extends TypeParameterElement> getTypeParameters();
/**
* Returns the package of a top-level type and returns the
* immediately lexically enclosing element for a {@linkplain
* NestingKind#isNested nested} type.
*
* @return the package of a top-level type, the immediately
* lexically enclosing element for a nested type
*/
@Override
Element getEnclosingElement();
}
| 6,069 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
ExecutableElement.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/element/ExecutableElement.java | /*
* Copyright (c) 2005, 2011, 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 javax.lang.model.element;
import java.util.List;
import javax.lang.model.util.Types;
import javax.lang.model.type.*;
/**
* Represents a method, constructor, or initializer (static or
* instance) of a class or interface, including annotation type
* elements.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @see ExecutableType
* @since 1.6
*/
public interface ExecutableElement extends Element, Parameterizable {
/**
* Returns the formal type parameters of this executable
* in declaration order.
*
* @return the formal type parameters, or an empty list
* if there are none
*/
List<? extends TypeParameterElement> getTypeParameters();
/**
* Returns the return type of this executable.
* Returns a {@link NoType} with kind {@link TypeKind#VOID VOID}
* if this executable is not a method, or is a method that does not
* return a value.
*
* @return the return type of this executable
*/
TypeMirror getReturnType();
/**
* Returns the formal parameters of this executable.
* They are returned in declaration order.
*
* @return the formal parameters,
* or an empty list if there are none
*/
List<? extends VariableElement> getParameters();
/**
* Returns {@code true} if this method or constructor accepts a variable
* number of arguments and returns {@code false} otherwise.
*
* @return {@code true} if this method or constructor accepts a variable
* number of arguments and {@code false} otherwise
*/
boolean isVarArgs();
/**
* Returns the exceptions and other throwables listed in this
* method or constructor's {@code throws} clause in declaration
* order.
*
* @return the exceptions and other throwables listed in the
* {@code throws} clause, or an empty list if there are none
*/
List<? extends TypeMirror> getThrownTypes();
/**
* Returns the default value if this executable is an annotation
* type element. Returns {@code null} if this method is not an
* annotation type element, or if it is an annotation type element
* with no default value.
*
* @return the default value, or {@code null} if none
*/
AnnotationValue getDefaultValue();
/**
* Returns the simple name of a constructor, method, or
* initializer. For a constructor, the name {@code "<init>"} is
* returned, for a static initializer, the name {@code "<clinit>"}
* is returned, and for an anonymous class or instance
* initializer, an empty name is returned.
*
* @return the simple name of a constructor, method, or
* initializer
*/
@Override
Name getSimpleName();
}
| 4,013 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
ElementKind.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/element/ElementKind.java | /*
* Copyright (c) 2005, 2010, 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 javax.lang.model.element;
/**
* The {@code kind} of an element.
*
* <p>Note that it is possible additional element kinds will be added
* to accommodate new, currently unknown, language structures added to
* future versions of the Java™ programming language.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @see Element
* @since 1.6
*/
public enum ElementKind {
/** A package. */
PACKAGE,
// Declared types
/** An enum type. */
ENUM,
/** A class not described by a more specific kind (like {@code ENUM}). */
CLASS,
/** An annotation type. */
ANNOTATION_TYPE,
/**
* An interface not described by a more specific kind (like
* {@code ANNOTATION_TYPE}).
*/
INTERFACE,
// Variables
/** An enum constant. */
ENUM_CONSTANT,
/**
* A field not described by a more specific kind (like
* {@code ENUM_CONSTANT}).
*/
FIELD,
/** A parameter of a method or constructor. */
PARAMETER,
/** A local variable. */
LOCAL_VARIABLE,
/** A parameter of an exception handler. */
EXCEPTION_PARAMETER,
// Executables
/** A method. */
METHOD,
/** A constructor. */
CONSTRUCTOR,
/** A static initializer. */
STATIC_INIT,
/** An instance initializer. */
INSTANCE_INIT,
/** A type parameter. */
TYPE_PARAMETER,
/**
* An implementation-reserved element. This is not the element
* you are looking for.
*/
OTHER,
/**
* A resource variable.
* @since 1.7
*/
RESOURCE_VARIABLE;
/**
* Returns {@code true} if this is a kind of class:
* either {@code CLASS} or {@code ENUM}.
*
* @return {@code true} if this is a kind of class
*/
public boolean isClass() {
return this == CLASS || this == ENUM;
}
/**
* Returns {@code true} if this is a kind of interface:
* either {@code INTERFACE} or {@code ANNOTATION_TYPE}.
*
* @return {@code true} if this is a kind of interface
*/
public boolean isInterface() {
return this == INTERFACE || this == ANNOTATION_TYPE;
}
/**
* Returns {@code true} if this is a kind of field:
* either {@code FIELD} or {@code ENUM_CONSTANT}.
*
* @return {@code true} if this is a kind of field
*/
public boolean isField() {
return this == FIELD || this == ENUM_CONSTANT;
}
}
| 3,691 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Modifier.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/element/Modifier.java | /*
* Copyright (c) 2005, 2006, 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 javax.lang.model.element;
/**
* Represents a modifier on a program element such
* as a class, method, or field.
*
* <p>Not all modifiers are applicable to all kinds of elements.
* When two or more modifiers appear in the source code of an element
* then it is customary, though not required, that they appear in the same
* order as the constants listed in the detail section below.
*
* <p>Note that it is possible additional modifiers will be added in
* future versions of the platform.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @since 1.6
*/
public enum Modifier {
// See JLS sections 8.1.1, 8.3.1, 8.4.3, 8.8.3, and 9.1.1.
// java.lang.reflect.Modifier includes INTERFACE, but that's a VMism.
/** The modifier {@code public} */ PUBLIC,
/** The modifier {@code protected} */ PROTECTED,
/** The modifier {@code private} */ PRIVATE,
/** The modifier {@code abstract} */ ABSTRACT,
/** The modifier {@code static} */ STATIC,
/** The modifier {@code final} */ FINAL,
/** The modifier {@code transient} */ TRANSIENT,
/** The modifier {@code volatile} */ VOLATILE,
/** The modifier {@code synchronized} */ SYNCHRONIZED,
/** The modifier {@code native} */ NATIVE,
/** The modifier {@code strictfp} */ STRICTFP;
private String lowercase = null; // modifier name in lowercase
/**
* Returns this modifier's name in lowercase.
*/
public String toString() {
if (lowercase == null) {
lowercase = name().toLowerCase(java.util.Locale.US);
}
return lowercase;
}
}
| 2,939 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
TypeVariable.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/type/TypeVariable.java | /*
* Copyright (c) 2005, 2006, 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 javax.lang.model.type;
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeParameterElement;
import javax.lang.model.util.Types;
/**
* Represents a type variable.
* A type variable may be explicitly declared by a
* {@linkplain TypeParameterElement type parameter} of a
* type, method, or constructor.
* A type variable may also be declared implicitly, as by
* the capture conversion of a wildcard type argument
* (see chapter 5 of
* <cite>The Java™ Language Specification</cite>).
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @see TypeParameterElement
* @since 1.6
*/
public interface TypeVariable extends ReferenceType {
/**
* Returns the element corresponding to this type variable.
*
* @return the element corresponding to this type variable
*/
Element asElement();
/**
* Returns the upper bound of this type variable.
*
* <p> If this type variable was declared with no explicit
* upper bounds, the result is {@code java.lang.Object}.
* If it was declared with multiple upper bounds,
* the result is an intersection type (modeled as a
* {@link DeclaredType}).
* Individual bounds can be found by examining the result's
* {@linkplain Types#directSupertypes(TypeMirror) supertypes}.
*
* @return the upper bound of this type variable
*/
TypeMirror getUpperBound();
/**
* Returns the lower bound of this type variable. While a type
* parameter cannot include an explicit lower bound declaration,
* capture conversion can produce a type variable with a
* non-trivial lower bound. Type variables otherwise have a
* lower bound of {@link NullType}.
*
* @return the lower bound of this type variable
*/
TypeMirror getLowerBound();
}
| 3,094 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
package-info.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/type/package-info.java | /*
* Copyright (c) 2005, 2006, 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.
*/
/**
* Interfaces used to model Java programming language types.
*
* <p> Unless otherwise specified in a particular implementation, the
* collections returned by methods in this package should be expected
* to be unmodifiable by the caller and unsafe for concurrent access.
*
* <p> Unless otherwise specified, methods in this package will throw
* a {@code NullPointerException} if given a {@code null} argument.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @since 1.6
*/
package javax.lang.model.type;
| 1,774 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
DeclaredType.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/type/DeclaredType.java | /*
* Copyright (c) 2005, 2006, 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 javax.lang.model.type;
import java.util.List;
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
import javax.lang.model.util.Types;
/**
* Represents a declared type, either a class type or an interface type.
* This includes parameterized types such as {@code java.util.Set<String>}
* as well as raw types.
*
* <p> While a {@code TypeElement} represents a class or interface
* <i>element</i>, a {@code DeclaredType} represents a class
* or interface <i>type</i>, the latter being a use
* (or <i>invocation</i>) of the former.
* See {@link TypeElement} for more on this distinction.
*
* <p> The supertypes (both class and interface types) of a declared
* type may be found using the {@link
* Types#directSupertypes(TypeMirror)} method. This returns the
* supertypes with any type arguments substituted in.
*
* <p> This interface is also used to represent intersection types.
* An intersection type is implicit in a program rather than being
* explictly declared. For example, the bound of the type parameter
* {@code <T extends Number & Runnable>}
* is an intersection type. It is represented by a {@code DeclaredType}
* with {@code Number} as its superclass and {@code Runnable} as its
* lone superinterface.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @see TypeElement
* @since 1.6
*/
public interface DeclaredType extends ReferenceType {
/**
* Returns the element corresponding to this type.
*
* @return the element corresponding to this type
*/
Element asElement();
/**
* Returns the type of the innermost enclosing instance or a
* {@code NoType} of kind {@code NONE} if there is no enclosing
* instance. Only types corresponding to inner classes have an
* enclosing instance.
*
* @return a type mirror for the enclosing type
* @jls 8.1.3 Inner Classes and Enclosing Instances
* @jls 15.9.2 Determining Enclosing Instances
*/
TypeMirror getEnclosingType();
/**
* Returns the actual type arguments of this type.
* For a type nested within a parameterized type
* (such as {@code Outer<String>.Inner<Number>}), only the type
* arguments of the innermost type are included.
*
* @return the actual type arguments of this type, or an empty list
* if none
*/
List<? extends TypeMirror> getTypeArguments();
}
| 3,687 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
TypeMirror.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/type/TypeMirror.java | /*
* Copyright (c) 2005, 2006, 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 javax.lang.model.type;
import javax.lang.model.element.*;
import javax.lang.model.util.Types;
/**
* Represents a type in the Java programming language.
* Types include primitive types, declared types (class and interface types),
* array types, type variables, and the null type.
* Also represented are wildcard type arguments,
* the signature and return types of executables,
* and pseudo-types corresponding to packages and to the keyword {@code void}.
*
* <p> Types should be compared using the utility methods in {@link
* Types}. There is no guarantee that any particular type will always
* be represented by the same object.
*
* <p> To implement operations based on the class of an {@code
* TypeMirror} object, either use a {@linkplain TypeVisitor visitor}
* or use the result of the {@link #getKind} method. Using {@code
* instanceof} is <em>not</em> necessarily a reliable idiom for
* determining the effective class of an object in this modeling
* hierarchy since an implementation may choose to have a single
* object implement multiple {@code TypeMirror} subinterfaces.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @see Element
* @see Types
* @since 1.6
*/
public interface TypeMirror {
/**
* Returns the {@code kind} of this type.
*
* @return the kind of this type
*/
TypeKind getKind();
/**
* Obeys the general contract of {@link Object#equals Object.equals}.
* This method does not, however, indicate whether two types represent
* the same type.
* Semantic comparisons of type equality should instead use
* {@link Types#isSameType(TypeMirror, TypeMirror)}.
* The results of {@code t1.equals(t2)} and
* {@code Types.isSameType(t1, t2)} may differ.
*
* @param obj the object to be compared with this type
* @return {@code true} if the specified object is equal to this one
*/
boolean equals(Object obj);
/**
* Obeys the general contract of {@link Object#hashCode Object.hashCode}.
*
* @see #equals
*/
int hashCode();
/**
* Returns an informative string representation of this type. If
* possible, the string should be of a form suitable for
* representing this type in source code. Any names embedded in
* the result are qualified if possible.
*
* @return a string representation of this type
*/
String toString();
/**
* Applies a visitor to this type.
*
* @param <R> the return type of the visitor's methods
* @param <P> the type of the additional parameter to the visitor's methods
* @param v the visitor operating on this type
* @param p additional parameter to the visitor
* @return a visitor-specified result
*/
<R, P> R accept(TypeVisitor<R, P> v, P p);
}
| 4,091 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
TypeKind.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/type/TypeKind.java | /*
* Copyright (c) 2005, 2011, 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 javax.lang.model.type;
/**
* The kind of a type mirror.
*
* <p>Note that it is possible additional type kinds will be added to
* accommodate new, currently unknown, language structures added to
* future versions of the Java™ programming language.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @see TypeMirror
* @since 1.6
*/
public enum TypeKind {
/**
* The primitive type {@code boolean}.
*/
BOOLEAN,
/**
* The primitive type {@code byte}.
*/
BYTE,
/**
* The primitive type {@code short}.
*/
SHORT,
/**
* The primitive type {@code int}.
*/
INT,
/**
* The primitive type {@code long}.
*/
LONG,
/**
* The primitive type {@code char}.
*/
CHAR,
/**
* The primitive type {@code float}.
*/
FLOAT,
/**
* The primitive type {@code double}.
*/
DOUBLE,
/**
* The pseudo-type corresponding to the keyword {@code void}.
* @see NoType
*/
VOID,
/**
* A pseudo-type used where no actual type is appropriate.
* @see NoType
*/
NONE,
/**
* The null type.
*/
NULL,
/**
* An array type.
*/
ARRAY,
/**
* A class or interface type.
*/
DECLARED,
/**
* A class or interface type that could not be resolved.
*/
ERROR,
/**
* A type variable.
*/
TYPEVAR,
/**
* A wildcard type argument.
*/
WILDCARD,
/**
* A pseudo-type corresponding to a package element.
* @see NoType
*/
PACKAGE,
/**
* A method, constructor, or initializer.
*/
EXECUTABLE,
/**
* An implementation-reserved type.
* This is not the type you are looking for.
*/
OTHER,
/**
* A union type.
*
* @since 1.7
*/
UNION;
/**
* Returns {@code true} if this kind corresponds to a primitive
* type and {@code false} otherwise.
* @return {@code true} if this kind corresponds to a primitive type
*/
public boolean isPrimitive() {
switch(this) {
case BOOLEAN:
case BYTE:
case SHORT:
case INT:
case LONG:
case CHAR:
case FLOAT:
case DOUBLE:
return true;
default:
return false;
}
}
}
| 3,655 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
MirroredTypesException.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/type/MirroredTypesException.java | /*
* Copyright (c) 2005, 2010, 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 javax.lang.model.type;
import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.List;
import java.util.Collections;
import java.io.ObjectInputStream;
import java.io.IOException;
import javax.lang.model.element.Element;
/**
* Thrown when an application attempts to access a sequence of {@link
* Class} objects each corresponding to a {@link TypeMirror}.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @see MirroredTypeException
* @see Element#getAnnotation(Class)
* @since 1.6
*/
public class MirroredTypesException extends RuntimeException {
private static final long serialVersionUID = 269;
transient List<? extends TypeMirror> types; // cannot be serialized
/*
* Trusted constructor to be called by MirroredTypeException.
*/
MirroredTypesException(String message, TypeMirror type) {
super(message);
List<TypeMirror> tmp = (new ArrayList<TypeMirror>());
tmp.add(type);
types = Collections.unmodifiableList(tmp);
}
/**
* Constructs a new MirroredTypesException for the specified types.
*
* @param types the types being accessed
*/
public MirroredTypesException(List<? extends TypeMirror> types) {
super("Attempt to access Class objects for TypeMirrors " +
(types = // defensive copy
new ArrayList<TypeMirror>(types)).toString() );
this.types = Collections.unmodifiableList(types);
}
/**
* Returns the type mirrors corresponding to the types being accessed.
* The type mirrors may be unavailable if this exception has been
* serialized and then read back in.
*
* @return the type mirrors in construction order, or {@code null} if unavailable
*/
public List<? extends TypeMirror> getTypeMirrors() {
return types;
}
/**
* Explicitly set all transient fields.
*/
private void readObject(ObjectInputStream s)
throws IOException, ClassNotFoundException {
s.defaultReadObject();
types = null;
}
}
| 3,338 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
UnionType.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/type/UnionType.java | /*
* Copyright (c) 2010, 2011, 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 javax.lang.model.type;
import java.util.List;
/**
* Represents a union type.
*
* As of the {@link javax.lang.model.SourceVersion#RELEASE_7
* RELEASE_7} source version, union types can appear as the type
* of a multi-catch exception parameter.
*
* @since 1.7
*/
public interface UnionType extends TypeMirror {
/**
* Return the alternatives comprising this union type.
*
* @return the alternatives comprising this union type.
*/
List<? extends TypeMirror> getAlternatives();
}
| 1,736 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
UnknownTypeException.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/type/UnknownTypeException.java | /*
* Copyright (c) 2005, 2009, 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 javax.lang.model.type;
import javax.lang.model.UnknownEntityException;
/**
* Indicates that an unknown kind of type was encountered. This can
* occur if the language evolves and new kinds of types are added to
* the {@code TypeMirror} hierarchy. May be thrown by a {@linkplain
* TypeVisitor type visitor} to indicate that the visitor was created
* for a prior version of the language.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @see TypeVisitor#visitUnknown
* @since 1.6
*/
public class UnknownTypeException extends UnknownEntityException {
private static final long serialVersionUID = 269L;
private transient TypeMirror type;
private transient Object parameter;
/**
* Creates a new {@code UnknownTypeException}.The {@code p}
* parameter may be used to pass in an additional argument with
* information about the context in which the unknown type was
* encountered; for example, the visit methods of {@link
* TypeVisitor} may pass in their additional parameter.
*
* @param t the unknown type, may be {@code null}
* @param p an additional parameter, may be {@code null}
*/
public UnknownTypeException(TypeMirror t, Object p) {
super("Unknown type: " + t);
type = t;
this.parameter = p;
}
/**
* Returns the unknown type.
* The value may be unavailable if this exception has been
* serialized and then read back in.
*
* @return the unknown type, or {@code null} if unavailable
*/
public TypeMirror getUnknownType() {
return type;
}
/**
* Returns the additional argument.
*
* @return the additional argument
*/
public Object getArgument() {
return parameter;
}
}
| 3,032 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
WildcardType.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/type/WildcardType.java | /*
* Copyright (c) 2005, 2006, 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 javax.lang.model.type;
/**
* Represents a wildcard type argument.
* Examples include: <pre><tt>
* ?
* ? extends Number
* ? super T
* </tt></pre>
*
* <p> A wildcard may have its upper bound explicitly set by an
* {@code extends} clause, its lower bound explicitly set by a
* {@code super} clause, or neither (but not both).
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @since 1.6
*/
public interface WildcardType extends TypeMirror {
/**
* Returns the upper bound of this wildcard.
* If no upper bound is explicitly declared,
* {@code null} is returned.
*
* @return the upper bound of this wildcard
*/
TypeMirror getExtendsBound();
/**
* Returns the lower bound of this wildcard.
* If no lower bound is explicitly declared,
* {@code null} is returned.
*
* @return the lower bound of this wildcard
*/
TypeMirror getSuperBound();
}
| 2,201 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
TypeVisitor.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/type/TypeVisitor.java | /*
* Copyright (c) 2005, 2011, 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 javax.lang.model.type;
import javax.lang.model.element.*;
/**
* A visitor of types, in the style of the
* visitor design pattern. Classes implementing this
* interface are used to operate on a type when the kind of
* type is unknown at compile time. When a visitor is passed to a
* type's {@link TypeMirror#accept accept} method, the <tt>visit<i>XYZ</i></tt>
* method most applicable to that type is invoked.
*
* <p> Classes implementing this interface may or may not throw a
* {@code NullPointerException} if the additional parameter {@code p}
* is {@code null}; see documentation of the implementing class for
* details.
*
* <p> <b>WARNING:</b> It is possible that methods will be added to
* this interface to accommodate new, currently unknown, language
* structures added to future versions of the Java™ programming
* language. Therefore, visitor classes directly implementing this
* interface may be source incompatible with future versions of the
* platform. To avoid this source incompatibility, visitor
* implementations are encouraged to instead extend the appropriate
* abstract visitor class that implements this interface. However, an
* API should generally use this visitor interface as the type for
* parameters, return type, etc. rather than one of the abstract
* classes.
*
* @param <R> the return type of this visitor's methods. Use {@link
* Void} for visitors that do not need to return results.
* @param <P> the type of the additional parameter to this visitor's
* methods. Use {@code Void} for visitors that do not need an
* additional parameter.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @since 1.6
*/
public interface TypeVisitor<R, P> {
/**
* Visits a type.
* @param t the type to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
*/
R visit(TypeMirror t, P p);
/**
* A convenience method equivalent to {@code v.visit(t, null)}.
* @param t the element to visit
* @return a visitor-specified result
*/
R visit(TypeMirror t);
/**
* Visits a primitive type.
* @param t the type to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
*/
R visitPrimitive(PrimitiveType t, P p);
/**
* Visits the null type.
* @param t the type to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
*/
R visitNull(NullType t, P p);
/**
* Visits an array type.
* @param t the type to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
*/
R visitArray(ArrayType t, P p);
/**
* Visits a declared type.
* @param t the type to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
*/
R visitDeclared(DeclaredType t, P p);
/**
* Visits an error type.
* @param t the type to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
*/
R visitError(ErrorType t, P p);
/**
* Visits a type variable.
* @param t the type to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
*/
R visitTypeVariable(TypeVariable t, P p);
/**
* Visits a wildcard type.
* @param t the type to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
*/
R visitWildcard(WildcardType t, P p);
/**
* Visits an executable type.
* @param t the type to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
*/
R visitExecutable(ExecutableType t, P p);
/**
* Visits a {@link NoType} instance.
* @param t the type to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
*/
R visitNoType(NoType t, P p);
/**
* Visits an unknown kind of type.
* This can occur if the language evolves and new kinds
* of types are added to the {@code TypeMirror} hierarchy.
* @param t the type to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
* @throws UnknownTypeException
* a visitor implementation may optionally throw this exception
*/
R visitUnknown(TypeMirror t, P p);
/**
* Visits a union type.
*
* @param t the type to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
* @since 1.7
*/
R visitUnion(UnionType t, P p);
}
| 5,982 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
ExecutableType.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/type/ExecutableType.java | /*
* Copyright (c) 2005, 2006, 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 javax.lang.model.type;
import java.util.List;
import javax.lang.model.element.ExecutableElement;
/**
* Represents the type of an executable. An <i>executable</i>
* is a method, constructor, or initializer.
*
* <p> The executable is
* represented as when viewed as a method (or constructor or
* initializer) of some reference type.
* If that reference type is parameterized, then its actual
* type arguments are substituted into any types returned by the methods of
* this interface.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @see ExecutableElement
* @since 1.6
*/
public interface ExecutableType extends TypeMirror {
/**
* Returns the type variables declared by the formal type parameters
* of this executable.
*
* @return the type variables declared by the formal type parameters,
* or an empty list if there are none
*/
List<? extends TypeVariable> getTypeVariables();
/**
* Returns the return type of this executable.
* Returns a {@link NoType} with kind {@link TypeKind#VOID VOID}
* if this executable is not a method, or is a method that does not
* return a value.
*
* @return the return type of this executable
*/
TypeMirror getReturnType();
/**
* Returns the types of this executable's formal parameters.
*
* @return the types of this executable's formal parameters,
* or an empty list if there are none
*/
List<? extends TypeMirror> getParameterTypes();
/**
* Returns the exceptions and other throwables listed in this
* executable's {@code throws} clause.
*
* @return the exceptions and other throwables listed in this
* executable's {@code throws} clause,
* or an empty list if there are none.
*/
List<? extends TypeMirror> getThrownTypes();
}
| 3,143 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
MirroredTypeException.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/type/MirroredTypeException.java | /*
* Copyright (c) 2005, 2010, 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 javax.lang.model.type;
import java.io.ObjectInputStream;
import java.io.IOException;
import java.lang.annotation.Annotation;
import javax.lang.model.element.Element;
/**
* Thrown when an application attempts to access the {@link Class} object
* corresponding to a {@link TypeMirror}.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @see MirroredTypesException
* @see Element#getAnnotation(Class)
* @since 1.6
*/
public class MirroredTypeException extends MirroredTypesException {
private static final long serialVersionUID = 269;
private transient TypeMirror type; // cannot be serialized
/**
* Constructs a new MirroredTypeException for the specified type.
*
* @param type the type being accessed
*/
public MirroredTypeException(TypeMirror type) {
super("Attempt to access Class object for TypeMirror " + type.toString(), type);
this.type = type;
}
/**
* Returns the type mirror corresponding to the type being accessed.
* The type mirror may be unavailable if this exception has been
* serialized and then read back in.
*
* @return the type mirror, or {@code null} if unavailable
*/
public TypeMirror getTypeMirror() {
return type;
}
/**
* Explicitly set all transient fields.
*/
private void readObject(ObjectInputStream s)
throws IOException, ClassNotFoundException {
s.defaultReadObject();
type = null;
types = null;
}
}
| 2,778 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
PrimitiveType.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/type/PrimitiveType.java | /*
* Copyright (c) 2005, 2006, 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 javax.lang.model.type;
/**
* Represents a primitive type. These include
* {@code boolean}, {@code byte}, {@code short}, {@code int},
* {@code long}, {@code char}, {@code float}, and {@code double}.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @since 1.6
*/
public interface PrimitiveType extends TypeMirror {
}
| 1,590 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
ReferenceType.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/type/ReferenceType.java | /*
* Copyright (c) 2005, 2006, 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 javax.lang.model.type;
/**
* Represents a reference type.
* These include class and interface types, array types, type variables,
* and the null type.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @since 1.6
*/
public interface ReferenceType extends TypeMirror {
}
| 1,542 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
NullType.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/type/NullType.java | /*
* Copyright (c) 2005, 2006, 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 javax.lang.model.type;
/**
* Represents the null type.
* This is the type of the expression {@code null},
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @since 1.6
*/
public interface NullType extends ReferenceType {
}
| 1,495 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
ArrayType.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/type/ArrayType.java | /*
* Copyright (c) 2005, 2006, 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 javax.lang.model.type;
/**
* Represents an array type.
* A multidimensional array type is represented as an array type
* whose component type is also an array type.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @since 1.6
*/
public interface ArrayType extends ReferenceType {
/**
* Returns the component type of this array type.
*
* @return the component type of this array type
*/
TypeMirror getComponentType();
}
| 1,721 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
NoType.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/type/NoType.java | /*
* Copyright (c) 2005, 2006, 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 javax.lang.model.type;
import javax.lang.model.element.ExecutableElement;
/**
* A pseudo-type used where no actual type is appropriate.
* The kinds of {@code NoType} are:
* <ul>
* <li>{@link TypeKind#VOID VOID} - corresponds to the keyword {@code void}.
* <li>{@link TypeKind#PACKAGE PACKAGE} - the pseudo-type of a package element.
* <li>{@link TypeKind#NONE NONE} - used in other cases
* where no actual type is appropriate; for example, the superclass
* of {@code java.lang.Object}.
* </ul>
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @see ExecutableElement#getReturnType()
* @since 1.6
*/
public interface NoType extends TypeMirror {
}
| 1,932 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
ErrorType.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/type/ErrorType.java | /*
* Copyright (c) 2005, 2008, 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 javax.lang.model.type;
/**
* Represents a class or interface type that cannot be properly modeled.
* This may be the result of a processing error,
* such as a missing class file or erroneous source code.
* Most queries for
* information derived from such a type (such as its members or its
* supertype) will not, in general, return meaningful results.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @since 1.6
*/
public interface ErrorType extends DeclaredType {
}
| 1,743 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
AbstractAnnotationValueVisitor6.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor6.java | /*
* Copyright (c) 2005, 2010, 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 javax.lang.model.util;
import java.util.List;
import javax.lang.model.element.*;
import javax.lang.model.type.TypeMirror;
import static javax.lang.model.SourceVersion.*;
import javax.lang.model.SourceVersion;
import javax.annotation.processing.SupportedSourceVersion;
/**
* A skeletal visitor for annotation values with default behavior
* appropriate for the {@link SourceVersion#RELEASE_6 RELEASE_6}
* source version.
*
* <p> <b>WARNING:</b> The {@code AnnotationValueVisitor} interface
* implemented by this class may have methods added to it in the
* future to accommodate new, currently unknown, language structures
* added to future versions of the Java™ programming language.
* Therefore, methods whose names begin with {@code "visit"} may be
* added to this class in the future; to avoid incompatibilities,
* classes which extend this class should not declare any instance
* methods with names beginning with {@code "visit"}.
*
* <p>When such a new visit method is added, the default
* implementation in this class will be to call the {@link
* #visitUnknown visitUnknown} method. A new abstract annotation
* value visitor class will also be introduced to correspond to the
* new language level; this visitor will have different default
* behavior for the visit method in question. When the new visitor is
* introduced, all or portions of this visitor may be deprecated.
*
* @param <R> the return type of this visitor's methods
* @param <P> the type of the additional parameter to this visitor's methods.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
*
* @see AbstractAnnotationValueVisitor7
* @since 1.6
*/
@SupportedSourceVersion(RELEASE_6)
public abstract class AbstractAnnotationValueVisitor6<R, P>
implements AnnotationValueVisitor<R, P> {
/**
* Constructor for concrete subclasses to call.
*/
protected AbstractAnnotationValueVisitor6() {}
/**
* Visits an annotation value as if by passing itself to that
* value's {@link AnnotationValue#accept accept}. The invocation
* {@code v.visit(av)} is equivalent to {@code av.accept(v, p)}.
* @param av {@inheritDoc}
* @param p {@inheritDoc}
*/
public final R visit(AnnotationValue av, P p) {
return av.accept(this, p);
}
/**
* Visits an annotation value as if by passing itself to that
* value's {@link AnnotationValue#accept accept} method passing
* {@code null} for the additional parameter. The invocation
* {@code v.visit(av)} is equivalent to {@code av.accept(v,
* null)}.
* @param av {@inheritDoc}
*/
public final R visit(AnnotationValue av) {
return av.accept(this, null);
}
/**
* {@inheritDoc}
*
* <p>The default implementation of this method in {@code
* AbstractAnnotationValueVisitor6} will always throw {@code
* UnknownAnnotationValueException}. This behavior is not
* required of a subclass.
*
* @param av {@inheritDoc}
* @param p {@inheritDoc}
*/
public R visitUnknown(AnnotationValue av, P p) {
throw new UnknownAnnotationValueException(av, p);
}
}
| 4,431 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
SimpleTypeVisitor6.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/util/SimpleTypeVisitor6.java | /*
* Copyright (c) 2005, 2011, 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 javax.lang.model.util;
import javax.lang.model.type.*;
import javax.annotation.processing.SupportedSourceVersion;
import javax.lang.model.SourceVersion;
import static javax.lang.model.SourceVersion.*;
/**
* A simple visitor of types with default behavior appropriate for the
* {@link SourceVersion#RELEASE_6 RELEASE_6} source version.
*
* Visit methods corresponding to {@code RELEASE_6} language
* constructs call {@link #defaultAction defaultAction}, passing their
* arguments to {@code defaultAction}'s corresponding parameters.
*
* For constructs introduced in {@code RELEASE_7} and later, {@code
* visitUnknown} is called instead.
*
* <p> Methods in this class may be overridden subject to their
* general contract. Note that annotating methods in concrete
* subclasses with {@link java.lang.Override @Override} will help
* ensure that methods are overridden as intended.
*
* <p> <b>WARNING:</b> The {@code TypeVisitor} interface implemented
* by this class may have methods added to it in the future to
* accommodate new, currently unknown, language structures added to
* future versions of the Java™ programming language.
* Therefore, methods whose names begin with {@code "visit"} may be
* added to this class in the future; to avoid incompatibilities,
* classes which extend this class should not declare any instance
* methods with names beginning with {@code "visit"}.
*
* <p>When such a new visit method is added, the default
* implementation in this class will be to call the {@link
* #visitUnknown visitUnknown} method. A new simple type visitor
* class will also be introduced to correspond to the new language
* level; this visitor will have different default behavior for the
* visit method in question. When the new visitor is introduced, all
* or portions of this visitor may be deprecated.
*
* @param <R> the return type of this visitor's methods. Use {@link
* Void} for visitors that do not need to return results.
* @param <P> the type of the additional parameter to this visitor's
* methods. Use {@code Void} for visitors that do not need an
* additional parameter.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
*
* @see SimpleTypeVisitor7
* @since 1.6
*/
@SupportedSourceVersion(RELEASE_6)
public class SimpleTypeVisitor6<R, P> extends AbstractTypeVisitor6<R, P> {
/**
* Default value to be returned; {@link #defaultAction
* defaultAction} returns this value unless the method is
* overridden.
*/
protected final R DEFAULT_VALUE;
/**
* Constructor for concrete subclasses; uses {@code null} for the
* default value.
*/
protected SimpleTypeVisitor6(){
DEFAULT_VALUE = null;
}
/**
* Constructor for concrete subclasses; uses the argument for the
* default value.
*
* @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
*/
protected SimpleTypeVisitor6(R defaultValue){
DEFAULT_VALUE = defaultValue;
}
/**
* The default action for visit methods. The implementation in
* this class just returns {@link #DEFAULT_VALUE}; subclasses will
* commonly override this method.
*/
protected R defaultAction(TypeMirror e, P p) {
return DEFAULT_VALUE;
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param t {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
public R visitPrimitive(PrimitiveType t, P p) {
return defaultAction(t, p);
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param t {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
public R visitNull(NullType t, P p){
return defaultAction(t, p);
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param t {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
public R visitArray(ArrayType t, P p){
return defaultAction(t, p);
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param t {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
public R visitDeclared(DeclaredType t, P p){
return defaultAction(t, p);
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param t {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
public R visitError(ErrorType t, P p){
return defaultAction(t, p);
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param t {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
public R visitTypeVariable(TypeVariable t, P p){
return defaultAction(t, p);
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param t {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
public R visitWildcard(WildcardType t, P p){
return defaultAction(t, p);
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param t {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
public R visitExecutable(ExecutableType t, P p) {
return defaultAction(t, p);
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param t {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
public R visitNoType(NoType t, P p){
return defaultAction(t, p);
}
}
| 7,242 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
SimpleElementVisitor6.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/util/SimpleElementVisitor6.java | /*
* Copyright (c) 2005, 2011, 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 javax.lang.model.util;
import javax.lang.model.element.*;
import javax.annotation.processing.SupportedSourceVersion;
import static javax.lang.model.element.ElementKind.*;
import javax.lang.model.SourceVersion;
import static javax.lang.model.SourceVersion.*;
/**
* A simple visitor of program elements with default behavior
* appropriate for the {@link SourceVersion#RELEASE_6 RELEASE_6}
* source version.
*
* Visit methods corresponding to {@code RELEASE_6} language
* constructs call {@link #defaultAction defaultAction}, passing their
* arguments to {@code defaultAction}'s corresponding parameters.
*
* For constructs introduced in {@code RELEASE_7} and later, {@code
* visitUnknown} is called instead.
*
* <p> Methods in this class may be overridden subject to their
* general contract. Note that annotating methods in concrete
* subclasses with {@link java.lang.Override @Override} will help
* ensure that methods are overridden as intended.
*
* <p> <b>WARNING:</b> The {@code ElementVisitor} interface
* implemented by this class may have methods added to it in the
* future to accommodate new, currently unknown, language structures
* added to future versions of the Java™ programming language.
* Therefore, methods whose names begin with {@code "visit"} may be
* added to this class in the future; to avoid incompatibilities,
* classes which extend this class should not declare any instance
* methods with names beginning with {@code "visit"}.
*
* <p>When such a new visit method is added, the default
* implementation in this class will be to call the {@link
* #visitUnknown visitUnknown} method. A new simple element visitor
* class will also be introduced to correspond to the new language
* level; this visitor will have different default behavior for the
* visit method in question. When the new visitor is introduced, all
* or portions of this visitor may be deprecated.
*
* @param <R> the return type of this visitor's methods. Use {@code Void}
* for visitors that do not need to return results.
* @param <P> the type of the additional parameter to this visitor's methods. Use {@code Void}
* for visitors that do not need an additional parameter.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
*
* @see SimpleElementVisitor7
* @since 1.6
*/
@SupportedSourceVersion(RELEASE_6)
public class SimpleElementVisitor6<R, P> extends AbstractElementVisitor6<R, P> {
/**
* Default value to be returned; {@link #defaultAction
* defaultAction} returns this value unless the method is
* overridden.
*/
protected final R DEFAULT_VALUE;
/**
* Constructor for concrete subclasses; uses {@code null} for the
* default value.
*/
protected SimpleElementVisitor6(){
DEFAULT_VALUE = null;
}
/**
* Constructor for concrete subclasses; uses the argument for the
* default value.
*
* @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
*/
protected SimpleElementVisitor6(R defaultValue){
DEFAULT_VALUE = defaultValue;
}
/**
* The default action for visit methods. The implementation in
* this class just returns {@link #DEFAULT_VALUE}; subclasses will
* commonly override this method.
*
* @param e the element to process
* @param p a visitor-specified parameter
* @return {@code DEFAULT_VALUE} unless overridden
*/
protected R defaultAction(Element e, P p) {
return DEFAULT_VALUE;
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param e {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
public R visitPackage(PackageElement e, P p) {
return defaultAction(e, p);
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param e {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
public R visitType(TypeElement e, P p) {
return defaultAction(e, p);
}
/**
* {@inheritDoc}
*
* This implementation calls {@code defaultAction}, unless the
* element is a {@code RESOURCE_VARIABLE} in which case {@code
* visitUnknown} is called.
*
* @param e {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction} or {@code visitUnknown}
*/
public R visitVariable(VariableElement e, P p) {
if (e.getKind() != ElementKind.RESOURCE_VARIABLE)
return defaultAction(e, p);
else
return visitUnknown(e, p);
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param e {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
public R visitExecutable(ExecutableElement e, P p) {
return defaultAction(e, p);
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param e {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
public R visitTypeParameter(TypeParameterElement e, P p) {
return defaultAction(e, p);
}
}
| 6,580 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
package-info.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/util/package-info.java | /*
* Copyright (c) 2005, 2006, 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.
*/
/**
* Utilities to assist in the processing of
* {@linkplain javax.lang.model.element program elements} and
* {@linkplain javax.lang.model.type types}.
*
* <p> Unless otherwise specified in a particular implementation, the
* collections returned by methods in this package should be expected
* to be unmodifiable by the caller and unsafe for concurrent access.
*
* <p> Unless otherwise specified, methods in this package will throw
* a {@code NullPointerException} if given a {@code null} argument.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @since 1.6
*/
package javax.lang.model.util;
| 1,864 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
AbstractAnnotationValueVisitor7.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor7.java | /*
* Copyright (c) 2010, 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 javax.lang.model.util;
import java.util.List;
import javax.lang.model.element.*;
import javax.lang.model.type.TypeMirror;
import static javax.lang.model.SourceVersion.*;
import javax.lang.model.SourceVersion;
import javax.annotation.processing.SupportedSourceVersion;
/**
* A skeletal visitor for annotation values with default behavior
* appropriate for the {@link SourceVersion#RELEASE_7 RELEASE_7}
* source version.
*
* <p> <b>WARNING:</b> The {@code AnnotationValueVisitor} interface
* implemented by this class may have methods added to it in the
* future to accommodate new, currently unknown, language structures
* added to future versions of the Java™ programming language.
* Therefore, methods whose names begin with {@code "visit"} may be
* added to this class in the future; to avoid incompatibilities,
* classes which extend this class should not declare any instance
* methods with names beginning with {@code "visit"}.
*
* <p>When such a new visit method is added, the default
* implementation in this class will be to call the {@link
* #visitUnknown visitUnknown} method. A new abstract annotation
* value visitor class will also be introduced to correspond to the
* new language level; this visitor will have different default
* behavior for the visit method in question. When the new visitor is
* introduced, all or portions of this visitor may be deprecated.
*
* @param <R> the return type of this visitor's methods
* @param <P> the type of the additional parameter to this visitor's methods.
*
* @see AbstractAnnotationValueVisitor6
* @since 1.7
*/
@SupportedSourceVersion(RELEASE_7)
public abstract class AbstractAnnotationValueVisitor7<R, P> extends AbstractAnnotationValueVisitor6<R, P> {
/**
* Constructor for concrete subclasses to call.
*/
protected AbstractAnnotationValueVisitor7() {
super();
}
}
| 3,109 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
SimpleElementVisitor7.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/util/SimpleElementVisitor7.java | /*
* Copyright (c) 2010, 2011, 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 javax.lang.model.util;
import javax.lang.model.element.*;
import javax.annotation.processing.SupportedSourceVersion;
import static javax.lang.model.element.ElementKind.*;
import javax.lang.model.SourceVersion;
import static javax.lang.model.SourceVersion.*;
/**
* A simple visitor of program elements with default behavior
* appropriate for the {@link SourceVersion#RELEASE_7 RELEASE_7}
* source version.
*
* Visit methods corresponding to {@code RELEASE_7} and earlier
* language constructs call {@link #defaultAction defaultAction},
* passing their arguments to {@code defaultAction}'s corresponding
* parameters.
*
* <p> Methods in this class may be overridden subject to their
* general contract. Note that annotating methods in concrete
* subclasses with {@link java.lang.Override @Override} will help
* ensure that methods are overridden as intended.
*
* <p> <b>WARNING:</b> The {@code ElementVisitor} interface
* implemented by this class may have methods added to it in the
* future to accommodate new, currently unknown, language structures
* added to future versions of the Java™ programming language.
* Therefore, methods whose names begin with {@code "visit"} may be
* added to this class in the future; to avoid incompatibilities,
* classes which extend this class should not declare any instance
* methods with names beginning with {@code "visit"}.
*
* <p>When such a new visit method is added, the default
* implementation in this class will be to call the {@link
* #visitUnknown visitUnknown} method. A new simple element visitor
* class will also be introduced to correspond to the new language
* level; this visitor will have different default behavior for the
* visit method in question. When the new visitor is introduced, all
* or portions of this visitor may be deprecated.
*
* @param <R> the return type of this visitor's methods. Use {@code Void}
* for visitors that do not need to return results.
* @param <P> the type of the additional parameter to this visitor's methods. Use {@code Void}
* for visitors that do not need an additional parameter.
*
* @see SimpleElementVisitor6
* @since 1.7
*/
@SupportedSourceVersion(RELEASE_7)
public class SimpleElementVisitor7<R, P> extends SimpleElementVisitor6<R, P> {
/**
* Constructor for concrete subclasses; uses {@code null} for the
* default value.
*/
protected SimpleElementVisitor7(){
super(null);
}
/**
* Constructor for concrete subclasses; uses the argument for the
* default value.
*
* @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
*/
protected SimpleElementVisitor7(R defaultValue){
super(defaultValue);
}
/**
* This implementation calls {@code defaultAction}.
*
* @param e {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
@Override
public R visitVariable(VariableElement e, P p) {
return defaultAction(e, p);
}
}
| 4,287 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
SimpleTypeVisitor7.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/util/SimpleTypeVisitor7.java | /*
* Copyright (c) 2010, 2011, 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 javax.lang.model.util;
import javax.lang.model.type.*;
import javax.annotation.processing.SupportedSourceVersion;
import javax.lang.model.SourceVersion;
import static javax.lang.model.SourceVersion.*;
/**
* A simple visitor of types with default behavior appropriate for the
* {@link SourceVersion#RELEASE_7 RELEASE_7} source version.
*
* Visit methods corresponding to {@code RELEASE_7} and earlier
* language constructs call {@link #defaultAction defaultAction},
* passing their arguments to {@code defaultAction}'s corresponding
* parameters.
*
* <p> Methods in this class may be overridden subject to their
* general contract. Note that annotating methods in concrete
* subclasses with {@link java.lang.Override @Override} will help
* ensure that methods are overridden as intended.
*
* <p> <b>WARNING:</b> The {@code TypeVisitor} interface implemented
* by this class may have methods added to it in the future to
* accommodate new, currently unknown, language structures added to
* future versions of the Java™ programming language.
* Therefore, methods whose names begin with {@code "visit"} may be
* added to this class in the future; to avoid incompatibilities,
* classes which extend this class should not declare any instance
* methods with names beginning with {@code "visit"}.
*
* <p>When such a new visit method is added, the default
* implementation in this class will be to call the {@link
* #visitUnknown visitUnknown} method. A new simple type visitor
* class will also be introduced to correspond to the new language
* level; this visitor will have different default behavior for the
* visit method in question. When the new visitor is introduced, all
* or portions of this visitor may be deprecated.
*
* @param <R> the return type of this visitor's methods. Use {@link
* Void} for visitors that do not need to return results.
* @param <P> the type of the additional parameter to this visitor's
* methods. Use {@code Void} for visitors that do not need an
* additional parameter.
*
* @see SimpleTypeVisitor6
* @since 1.7
*/
@SupportedSourceVersion(RELEASE_7)
public class SimpleTypeVisitor7<R, P> extends SimpleTypeVisitor6<R, P> {
/**
* Constructor for concrete subclasses; uses {@code null} for the
* default value.
*/
protected SimpleTypeVisitor7(){
super(null);
}
/**
* Constructor for concrete subclasses; uses the argument for the
* default value.
*
* @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
*/
protected SimpleTypeVisitor7(R defaultValue){
super(defaultValue);
}
/**
* This implementation visits a {@code UnionType} by calling
* {@code defaultAction}.
*
* @param t {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
@Override
public R visitUnion(UnionType t, P p) {
return defaultAction(t, p);
}
}
| 4,237 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
ElementKindVisitor7.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/util/ElementKindVisitor7.java | /*
* Copyright (c) 2010, 2011, 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 javax.lang.model.util;
import javax.lang.model.element.*;
import static javax.lang.model.element.ElementKind.*;
import javax.annotation.processing.SupportedSourceVersion;
import static javax.lang.model.SourceVersion.*;
import javax.lang.model.SourceVersion;
/**
* A visitor of program elements based on their {@linkplain
* ElementKind kind} with default behavior appropriate for the {@link
* SourceVersion#RELEASE_7 RELEASE_7} source version. For {@linkplain
* Element elements} <tt><i>XYZ</i></tt> that may have more than one
* kind, the <tt>visit<i>XYZ</i></tt> methods in this class delegate
* to the <tt>visit<i>XYZKind</i></tt> method corresponding to the
* first argument's kind. The <tt>visit<i>XYZKind</i></tt> methods
* call {@link #defaultAction defaultAction}, passing their arguments
* to {@code defaultAction}'s corresponding parameters.
*
* <p> Methods in this class may be overridden subject to their
* general contract. Note that annotating methods in concrete
* subclasses with {@link java.lang.Override @Override} will help
* ensure that methods are overridden as intended.
*
* <p> <b>WARNING:</b> The {@code ElementVisitor} interface
* implemented by this class may have methods added to it or the
* {@code ElementKind} {@code enum} used in this case may have
* constants added to it in the future to accommodate new, currently
* unknown, language structures added to future versions of the
* Java™ programming language. Therefore, methods whose names
* begin with {@code "visit"} may be added to this class in the
* future; to avoid incompatibilities, classes which extend this class
* should not declare any instance methods with names beginning with
* {@code "visit"}.
*
* <p>When such a new visit method is added, the default
* implementation in this class will be to call the {@link
* #visitUnknown visitUnknown} method. A new abstract element kind
* visitor class will also be introduced to correspond to the new
* language level; this visitor will have different default behavior
* for the visit method in question. When the new visitor is
* introduced, all or portions of this visitor may be deprecated.
*
* @param <R> the return type of this visitor's methods. Use {@link
* Void} for visitors that do not need to return results.
* @param <P> the type of the additional parameter to this visitor's
* methods. Use {@code Void} for visitors that do not need an
* additional parameter.
*
* @see ElementKindVisitor6
* @since 1.7
*/
@SupportedSourceVersion(RELEASE_7)
public class ElementKindVisitor7<R, P> extends ElementKindVisitor6<R, P> {
/**
* Constructor for concrete subclasses; uses {@code null} for the
* default value.
*/
protected ElementKindVisitor7() {
super(null);
}
/**
* Constructor for concrete subclasses; uses the argument for the
* default value.
*
* @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
*/
protected ElementKindVisitor7(R defaultValue) {
super(defaultValue);
}
/**
* Visits a {@code RESOURCE_VARIABLE} variable element by calling
* {@code defaultAction}.
*
* @param e {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
@Override
public R visitVariableAsResourceVariable(VariableElement e, P p) {
return defaultAction(e, p);
}
}
| 4,693 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
ElementScanner6.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/util/ElementScanner6.java | /*
* Copyright (c) 2005, 2011, 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 javax.lang.model.util;
import javax.lang.model.element.*;
import javax.annotation.processing.SupportedSourceVersion;
import static javax.lang.model.element.ElementKind.*;
import javax.lang.model.SourceVersion;
import static javax.lang.model.SourceVersion.*;
/**
* A scanning visitor of program elements with default behavior
* appropriate for the {@link SourceVersion#RELEASE_6 RELEASE_6}
* source version. The <tt>visit<i>XYZ</i></tt> methods in this
* class scan their component elements by calling {@code scan} on
* their {@linkplain Element#getEnclosedElements enclosed elements},
* {@linkplain ExecutableElement#getParameters parameters}, etc., as
* indicated in the individual method specifications. A subclass can
* control the order elements are visited by overriding the
* <tt>visit<i>XYZ</i></tt> methods. Note that clients of a scanner
* may get the desired behavior be invoking {@code v.scan(e, p)} rather
* than {@code v.visit(e, p)} on the root objects of interest.
*
* <p>When a subclass overrides a <tt>visit<i>XYZ</i></tt> method, the
* new method can cause the enclosed elements to be scanned in the
* default way by calling <tt>super.visit<i>XYZ</i></tt>. In this
* fashion, the concrete visitor can control the ordering of traversal
* over the component elements with respect to the additional
* processing; for example, consistently calling
* <tt>super.visit<i>XYZ</i></tt> at the start of the overridden
* methods will yield a preorder traversal, etc. If the component
* elements should be traversed in some other order, instead of
* calling <tt>super.visit<i>XYZ</i></tt>, an overriding visit method
* should call {@code scan} with the elements in the desired order.
*
* <p> Methods in this class may be overridden subject to their
* general contract. Note that annotating methods in concrete
* subclasses with {@link java.lang.Override @Override} will help
* ensure that methods are overridden as intended.
*
* <p> <b>WARNING:</b> The {@code ElementVisitor} interface
* implemented by this class may have methods added to it in the
* future to accommodate new, currently unknown, language structures
* added to future versions of the Java™ programming language.
* Therefore, methods whose names begin with {@code "visit"} may be
* added to this class in the future; to avoid incompatibilities,
* classes which extend this class should not declare any instance
* methods with names beginning with {@code "visit"}.
*
* <p>When such a new visit method is added, the default
* implementation in this class will be to call the {@link
* #visitUnknown visitUnknown} method. A new element scanner visitor
* class will also be introduced to correspond to the new language
* level; this visitor will have different default behavior for the
* visit method in question. When the new visitor is introduced, all
* or portions of this visitor may be deprecated.
*
* @param <R> the return type of this visitor's methods. Use {@link
* Void} for visitors that do not need to return results.
* @param <P> the type of the additional parameter to this visitor's
* methods. Use {@code Void} for visitors that do not need an
* additional parameter.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
*
* @see ElementScanner7
* @since 1.6
*/
@SupportedSourceVersion(RELEASE_6)
public class ElementScanner6<R, P> extends AbstractElementVisitor6<R, P> {
/**
* The specified default value.
*/
protected final R DEFAULT_VALUE;
/**
* Constructor for concrete subclasses; uses {@code null} for the
* default value.
*/
protected ElementScanner6(){
DEFAULT_VALUE = null;
}
/**
* Constructor for concrete subclasses; uses the argument for the
* default value.
*/
protected ElementScanner6(R defaultValue){
DEFAULT_VALUE = defaultValue;
}
/**
* Iterates over the given elements and calls {@link
* #scan(Element, Object) scan(Element, P)} on each one. Returns
* the result of the last call to {@code scan} or {@code
* DEFAULT_VALUE} for an empty iterable.
*
* @param iterable the elements to scan
* @param p additional parameter
* @return the scan of the last element or {@code DEFAULT_VALUE} if no elements
*/
public final R scan(Iterable<? extends Element> iterable, P p) {
R result = DEFAULT_VALUE;
for(Element e : iterable)
result = scan(e, p);
return result;
}
/**
* Processes an element by calling {@code e.accept(this, p)};
* this method may be overridden by subclasses.
* @return the result of visiting {@code e}.
*/
public R scan(Element e, P p) {
return e.accept(this, p);
}
/**
* Convenience method equivalent to {@code v.scan(e, null)}.
* @return the result of scanning {@code e}.
*/
public final R scan(Element e) {
return scan(e, null);
}
/**
* {@inheritDoc} This implementation scans the enclosed elements.
*
* @param e {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of scanning
*/
public R visitPackage(PackageElement e, P p) {
return scan(e.getEnclosedElements(), p);
}
/**
* {@inheritDoc} This implementation scans the enclosed elements.
*
* @param e {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of scanning
*/
public R visitType(TypeElement e, P p) {
return scan(e.getEnclosedElements(), p);
}
/**
* {@inheritDoc}
*
* This implementation scans the enclosed elements, unless the
* element is a {@code RESOURCE_VARIABLE} in which case {@code
* visitUnknown} is called.
*
* @param e {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of scanning
*/
public R visitVariable(VariableElement e, P p) {
if (e.getKind() != ElementKind.RESOURCE_VARIABLE)
return scan(e.getEnclosedElements(), p);
else
return visitUnknown(e, p);
}
/**
* {@inheritDoc} This implementation scans the parameters.
*
* @param e {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of scanning
*/
public R visitExecutable(ExecutableElement e, P p) {
return scan(e.getParameters(), p);
}
/**
* {@inheritDoc} This implementation scans the enclosed elements.
*
* @param e {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of scanning
*/
public R visitTypeParameter(TypeParameterElement e, P p) {
return scan(e.getEnclosedElements(), p);
}
}
| 8,016 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
SimpleAnnotationValueVisitor7.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor7.java | /*
* Copyright (c) 2010, 2011, 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 javax.lang.model.util;
import java.util.List;
import javax.lang.model.element.*;
import javax.lang.model.type.TypeMirror;
import static javax.lang.model.SourceVersion.*;
import javax.lang.model.SourceVersion;
import javax.annotation.processing.SupportedSourceVersion;
/**
* A simple visitor for annotation values with default behavior
* appropriate for the {@link SourceVersion#RELEASE_7 RELEASE_7}
* source version. Visit methods call {@link #defaultAction
* defaultAction} passing their arguments to {@code defaultAction}'s
* corresponding parameters.
*
* <p> Methods in this class may be overridden subject to their
* general contract. Note that annotating methods in concrete
* subclasses with {@link java.lang.Override @Override} will help
* ensure that methods are overridden as intended.
*
* <p> <b>WARNING:</b> The {@code AnnotationValueVisitor} interface
* implemented by this class may have methods added to it in the
* future to accommodate new, currently unknown, language structures
* added to future versions of the Java™ programming language.
* Therefore, methods whose names begin with {@code "visit"} may be
* added to this class in the future; to avoid incompatibilities,
* classes which extend this class should not declare any instance
* methods with names beginning with {@code "visit"}.
*
* <p>When such a new visit method is added, the default
* implementation in this class will be to call the {@link
* #visitUnknown visitUnknown} method. A new simple annotation
* value visitor class will also be introduced to correspond to the
* new language level; this visitor will have different default
* behavior for the visit method in question. When the new visitor is
* introduced, all or portions of this visitor may be deprecated.
*
* @param <R> the return type of this visitor's methods
* @param <P> the type of the additional parameter to this visitor's methods.
*
* @see SimpleAnnotationValueVisitor6
* @since 1.7
*/
@SupportedSourceVersion(RELEASE_7)
public class SimpleAnnotationValueVisitor7<R, P> extends SimpleAnnotationValueVisitor6<R, P> {
/**
* Constructor for concrete subclasses; uses {@code null} for the
* default value.
*/
protected SimpleAnnotationValueVisitor7() {
super(null);
}
/**
* Constructor for concrete subclasses; uses the argument for the
* default value.
*
* @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
*/
protected SimpleAnnotationValueVisitor7(R defaultValue) {
super(defaultValue);
}
}
| 3,810 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
ElementFilter.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/util/ElementFilter.java | /*
* Copyright (c) 2005, 2006, 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 javax.lang.model.util;
import java.lang.Iterable;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.EnumSet;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.NoSuchElementException;
import javax.lang.model.element.*;
import javax.lang.model.type.*;
/**
* Filters for selecting just the elements of interest from a
* collection of elements. The returned sets and lists are new
* collections and do use the argument as a backing store. The
* methods in this class do not make any attempts to guard against
* concurrent modifications of the arguments. The returned sets and
* lists are mutable but unsafe for concurrent access. A returned set
* has the same iteration order as the argument set to a method.
*
* <p>If iterables and sets containing {@code null} are passed as
* arguments to methods in this class, a {@code NullPointerException}
* will be thrown.
*
* <p>Note that a <i>static import</i> statement can make the text of
* calls to the methods in this class more concise; for example:
*
* <blockquote><pre>
* import static javax.lang.model.util.ElementFilter.*;
* ...
* {@code List<VariableElement>} fs = fieldsIn(someClass.getEnclosedElements());
* </pre></blockquote>
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @author Martin Buchholz
* @since 1.6
*/
public class ElementFilter {
private ElementFilter() {} // Do not instantiate.
private static Set<ElementKind> CONSTRUCTOR_KIND =
Collections.unmodifiableSet(EnumSet.of(ElementKind.CONSTRUCTOR));
private static Set<ElementKind> FIELD_KINDS =
Collections.unmodifiableSet(EnumSet.of(ElementKind.FIELD,
ElementKind.ENUM_CONSTANT));
private static Set<ElementKind> METHOD_KIND =
Collections.unmodifiableSet(EnumSet.of(ElementKind.METHOD));
private static Set<ElementKind> PACKAGE_KIND =
Collections.unmodifiableSet(EnumSet.of(ElementKind.PACKAGE));
private static Set<ElementKind> TYPE_KINDS =
Collections.unmodifiableSet(EnumSet.of(ElementKind.CLASS,
ElementKind.ENUM,
ElementKind.INTERFACE,
ElementKind.ANNOTATION_TYPE));
/**
* Returns a list of fields in {@code elements}.
* @return a list of fields in {@code elements}
* @param elements the elements to filter
*/
public static List<VariableElement>
fieldsIn(Iterable<? extends Element> elements) {
return listFilter(elements, FIELD_KINDS, VariableElement.class);
}
/**
* Returns a set of fields in {@code elements}.
* @return a set of fields in {@code elements}
* @param elements the elements to filter
*/
public static Set<VariableElement>
fieldsIn(Set<? extends Element> elements) {
return setFilter(elements, FIELD_KINDS, VariableElement.class);
}
/**
* Returns a list of constructors in {@code elements}.
* @return a list of constructors in {@code elements}
* @param elements the elements to filter
*/
public static List<ExecutableElement>
constructorsIn(Iterable<? extends Element> elements) {
return listFilter(elements, CONSTRUCTOR_KIND, ExecutableElement.class);
}
/**
* Returns a set of constructors in {@code elements}.
* @return a set of constructors in {@code elements}
* @param elements the elements to filter
*/
public static Set<ExecutableElement>
constructorsIn(Set<? extends Element> elements) {
return setFilter(elements, CONSTRUCTOR_KIND, ExecutableElement.class);
}
/**
* Returns a list of methods in {@code elements}.
* @return a list of methods in {@code elements}
* @param elements the elements to filter
*/
public static List<ExecutableElement>
methodsIn(Iterable<? extends Element> elements) {
return listFilter(elements, METHOD_KIND, ExecutableElement.class);
}
/**
* Returns a set of methods in {@code elements}.
* @return a set of methods in {@code elements}
* @param elements the elements to filter
*/
public static Set<ExecutableElement>
methodsIn(Set<? extends Element> elements) {
return setFilter(elements, METHOD_KIND, ExecutableElement.class);
}
/**
* Returns a list of types in {@code elements}.
* @return a list of types in {@code elements}
* @param elements the elements to filter
*/
public static List<TypeElement>
typesIn(Iterable<? extends Element> elements) {
return listFilter(elements, TYPE_KINDS, TypeElement.class);
}
/**
* Returns a set of types in {@code elements}.
* @return a set of types in {@code elements}
* @param elements the elements to filter
*/
public static Set<TypeElement>
typesIn(Set<? extends Element> elements) {
return setFilter(elements, TYPE_KINDS, TypeElement.class);
}
/**
* Returns a list of packages in {@code elements}.
* @return a list of packages in {@code elements}
* @param elements the elements to filter
*/
public static List<PackageElement>
packagesIn(Iterable<? extends Element> elements) {
return listFilter(elements, PACKAGE_KIND, PackageElement.class);
}
/**
* Returns a set of packages in {@code elements}.
* @return a set of packages in {@code elements}
* @param elements the elements to filter
*/
public static Set<PackageElement>
packagesIn(Set<? extends Element> elements) {
return setFilter(elements, PACKAGE_KIND, PackageElement.class);
}
// Assumes targetKinds and E are sensible.
private static <E extends Element> List<E> listFilter(Iterable<? extends Element> elements,
Set<ElementKind> targetKinds,
Class<E> clazz) {
List<E> list = new ArrayList<E>();
for (Element e : elements) {
if (targetKinds.contains(e.getKind()))
list.add(clazz.cast(e));
}
return list;
}
// Assumes targetKinds and E are sensible.
private static <E extends Element> Set<E> setFilter(Set<? extends Element> elements,
Set<ElementKind> targetKinds,
Class<E> clazz) {
// Return set preserving iteration order of input set.
Set<E> set = new LinkedHashSet<E>();
for (Element e : elements) {
if (targetKinds.contains(e.getKind()))
set.add(clazz.cast(e));
}
return set;
}
}
| 8,230 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
AbstractTypeVisitor6.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/util/AbstractTypeVisitor6.java | /*
* Copyright (c) 2005, 2011, 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 javax.lang.model.util;
import javax.lang.model.type.*;
/**
* A skeletal visitor of types with default behavior appropriate for
* the {@link javax.lang.model.SourceVersion#RELEASE_6 RELEASE_6}
* source version.
*
* <p> <b>WARNING:</b> The {@code TypeVisitor} interface implemented
* by this class may have methods added to it in the future to
* accommodate new, currently unknown, language structures added to
* future versions of the Java™ programming language.
* Therefore, methods whose names begin with {@code "visit"} may be
* added to this class in the future; to avoid incompatibilities,
* classes which extend this class should not declare any instance
* methods with names beginning with {@code "visit"}.
*
* <p>When such a new visit method is added, the default
* implementation in this class will be to call the {@link
* #visitUnknown visitUnknown} method. A new abstract type visitor
* class will also be introduced to correspond to the new language
* level; this visitor will have different default behavior for the
* visit method in question. When the new visitor is introduced, all
* or portions of this visitor may be deprecated.
*
* @param <R> the return type of this visitor's methods. Use {@link
* Void} for visitors that do not need to return results.
* @param <P> the type of the additional parameter to this visitor's
* methods. Use {@code Void} for visitors that do not need an
* additional parameter.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
*
* @see AbstractTypeVisitor7
* @since 1.6
*/
public abstract class AbstractTypeVisitor6<R, P> implements TypeVisitor<R, P> {
/**
* Constructor for concrete subclasses to call.
*/
protected AbstractTypeVisitor6() {}
/**
* Visits any type mirror as if by passing itself to that type
* mirror's {@link TypeMirror#accept accept} method. The
* invocation {@code v.visit(t, p)} is equivalent to {@code
* t.accept(v, p)}.
*
* @param t the type to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
*/
public final R visit(TypeMirror t, P p) {
return t.accept(this, p);
}
/**
* Visits any type mirror as if by passing itself to that type
* mirror's {@link TypeMirror#accept accept} method and passing
* {@code null} for the additional parameter. The invocation
* {@code v.visit(t)} is equivalent to {@code t.accept(v, null)}.
*
* @param t the type to visit
* @return a visitor-specified result
*/
public final R visit(TypeMirror t) {
return t.accept(this, null);
}
/**
* Visits a {@code UnionType} element by calling {@code
* visitUnknown}.
* @param t {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code visitUnknown}
*
* @since 1.7
*/
public R visitUnion(UnionType t, P p) {
return visitUnknown(t, p);
}
/**
* {@inheritDoc}
*
* <p> The default implementation of this method in {@code
* AbstractTypeVisitor6} will always throw {@code
* UnknownTypeException}. This behavior is not required of a
* subclass.
*
* @param t the type to visit
* @return a visitor-specified result
* @throws UnknownTypeException
* a visitor implementation may optionally throw this exception
*/
public R visitUnknown(TypeMirror t, P p) {
throw new UnknownTypeException(t, p);
}
}
| 4,811 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Types.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/util/Types.java | /*
* Copyright (c) 2005, 2011, 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 javax.lang.model.util;
import java.util.List;
import javax.lang.model.element.*;
import javax.lang.model.type.*;
/**
* Utility methods for operating on types.
*
* <p><b>Compatibility Note:</b> Methods may be added to this interface
* in future releases of the platform.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @see javax.annotation.processing.ProcessingEnvironment#getTypeUtils
* @since 1.6
*/
public interface Types {
/**
* Returns the element corresponding to a type.
* The type may be a {@code DeclaredType} or {@code TypeVariable}.
* Returns {@code null} if the type is not one with a
* corresponding element.
*
* @return the element corresponding to the given type
*/
Element asElement(TypeMirror t);
/**
* Tests whether two {@code TypeMirror} objects represent the same type.
*
* <p>Caveat: if either of the arguments to this method represents a
* wildcard, this method will return false. As a consequence, a wildcard
* is not the same type as itself. This might be surprising at first,
* but makes sense once you consider that an example like this must be
* rejected by the compiler:
* <pre>
* {@code List<?> list = new ArrayList<Object>();}
* {@code list.add(list.get(0));}
* </pre>
*
* @param t1 the first type
* @param t2 the second type
* @return {@code true} if and only if the two types are the same
*/
boolean isSameType(TypeMirror t1, TypeMirror t2);
/**
* Tests whether one type is a subtype of another.
* Any type is considered to be a subtype of itself.
*
* @param t1 the first type
* @param t2 the second type
* @return {@code true} if and only if the first type is a subtype
* of the second
* @throws IllegalArgumentException if given an executable or package type
* @jls 4.10 Subtyping
*/
boolean isSubtype(TypeMirror t1, TypeMirror t2);
/**
* Tests whether one type is assignable to another.
*
* @param t1 the first type
* @param t2 the second type
* @return {@code true} if and only if the first type is assignable
* to the second
* @throws IllegalArgumentException if given an executable or package type
* @jls 5.2 Assignment Conversion
*/
boolean isAssignable(TypeMirror t1, TypeMirror t2);
/**
* Tests whether one type argument <i>contains</i> another.
*
* @param t1 the first type
* @param t2 the second type
* @return {@code true} if and only if the first type contains the second
* @throws IllegalArgumentException if given an executable or package type
* @jls 4.5.1.1 Type Argument Containment and Equivalence
*/
boolean contains(TypeMirror t1, TypeMirror t2);
/**
* Tests whether the signature of one method is a <i>subsignature</i>
* of another.
*
* @param m1 the first method
* @param m2 the second method
* @return {@code true} if and only if the first signature is a
* subsignature of the second
* @jls 8.4.2 Method Signature
*/
boolean isSubsignature(ExecutableType m1, ExecutableType m2);
/**
* Returns the direct supertypes of a type. The interface types, if any,
* will appear last in the list.
*
* @param t the type being examined
* @return the direct supertypes, or an empty list if none
* @throws IllegalArgumentException if given an executable or package type
*/
List<? extends TypeMirror> directSupertypes(TypeMirror t);
/**
* Returns the erasure of a type.
*
* @param t the type to be erased
* @return the erasure of the given type
* @throws IllegalArgumentException if given a package type
* @jls 4.6 Type Erasure
*/
TypeMirror erasure(TypeMirror t);
/**
* Returns the class of a boxed value of a given primitive type.
* That is, <i>boxing conversion</i> is applied.
*
* @param p the primitive type to be converted
* @return the class of a boxed value of type {@code p}
* @jls 5.1.7 Boxing Conversion
*/
TypeElement boxedClass(PrimitiveType p);
/**
* Returns the type (a primitive type) of unboxed values of a given type.
* That is, <i>unboxing conversion</i> is applied.
*
* @param t the type to be unboxed
* @return the type of an unboxed value of type {@code t}
* @throws IllegalArgumentException if the given type has no
* unboxing conversion
* @jls 5.1.8 Unboxing Conversion
*/
PrimitiveType unboxedType(TypeMirror t);
/**
* Applies capture conversion to a type.
*
* @param t the type to be converted
* @return the result of applying capture conversion
* @throws IllegalArgumentException if given an executable or package type
* @jls 5.1.10 Capture Conversion
*/
TypeMirror capture(TypeMirror t);
/**
* Returns a primitive type.
*
* @param kind the kind of primitive type to return
* @return a primitive type
* @throws IllegalArgumentException if {@code kind} is not a primitive kind
*/
PrimitiveType getPrimitiveType(TypeKind kind);
/**
* Returns the null type. This is the type of {@code null}.
*
* @return the null type
*/
NullType getNullType();
/**
* Returns a pseudo-type used where no actual type is appropriate.
* The kind of type to return may be either
* {@link TypeKind#VOID VOID} or {@link TypeKind#NONE NONE}.
* For packages, use
* {@link Elements#getPackageElement(CharSequence)}{@code .asType()}
* instead.
*
* @param kind the kind of type to return
* @return a pseudo-type of kind {@code VOID} or {@code NONE}
* @throws IllegalArgumentException if {@code kind} is not valid
*/
NoType getNoType(TypeKind kind);
/**
* Returns an array type with the specified component type.
*
* @param componentType the component type
* @return an array type with the specified component type.
* @throws IllegalArgumentException if the component type is not valid for
* an array
*/
ArrayType getArrayType(TypeMirror componentType);
/**
* Returns a new wildcard type argument. Either of the wildcard's
* bounds may be specified, or neither, but not both.
*
* @param extendsBound the extends (upper) bound, or {@code null} if none
* @param superBound the super (lower) bound, or {@code null} if none
* @return a new wildcard
* @throws IllegalArgumentException if bounds are not valid
*/
WildcardType getWildcardType(TypeMirror extendsBound,
TypeMirror superBound);
/**
* Returns the type corresponding to a type element and
* actual type arguments.
* Given the type element for {@code Set} and the type mirror
* for {@code String},
* for example, this method may be used to get the
* parameterized type {@code Set<String>}.
*
* <p> The number of type arguments must either equal the
* number of the type element's formal type parameters, or must be
* zero. If zero, and if the type element is generic,
* then the type element's raw type is returned.
*
* <p> If a parameterized type is being returned, its type element
* must not be contained within a generic outer class.
* The parameterized type {@code Outer<String>.Inner<Number>},
* for example, may be constructed by first using this
* method to get the type {@code Outer<String>}, and then invoking
* {@link #getDeclaredType(DeclaredType, TypeElement, TypeMirror...)}.
*
* @param typeElem the type element
* @param typeArgs the actual type arguments
* @return the type corresponding to the type element and
* actual type arguments
* @throws IllegalArgumentException if too many or too few
* type arguments are given, or if an inappropriate type
* argument or type element is provided
*/
DeclaredType getDeclaredType(TypeElement typeElem, TypeMirror... typeArgs);
/**
* Returns the type corresponding to a type element
* and actual type arguments, given a
* {@linkplain DeclaredType#getEnclosingType() containing type}
* of which it is a member.
* The parameterized type {@code Outer<String>.Inner<Number>},
* for example, may be constructed by first using
* {@link #getDeclaredType(TypeElement, TypeMirror...)}
* to get the type {@code Outer<String>}, and then invoking
* this method.
*
* <p> If the containing type is a parameterized type,
* the number of type arguments must equal the
* number of {@code typeElem}'s formal type parameters.
* If it is not parameterized or if it is {@code null}, this method is
* equivalent to {@code getDeclaredType(typeElem, typeArgs)}.
*
* @param containing the containing type, or {@code null} if none
* @param typeElem the type element
* @param typeArgs the actual type arguments
* @return the type corresponding to the type element and
* actual type arguments, contained within the given type
* @throws IllegalArgumentException if too many or too few
* type arguments are given, or if an inappropriate type
* argument, type element, or containing type is provided
*/
DeclaredType getDeclaredType(DeclaredType containing,
TypeElement typeElem, TypeMirror... typeArgs);
/**
* Returns the type of an element when that element is viewed as
* a member of, or otherwise directly contained by, a given type.
* For example,
* when viewed as a member of the parameterized type {@code Set<String>},
* the {@code Set.add} method is an {@code ExecutableType}
* whose parameter is of type {@code String}.
*
* @param containing the containing type
* @param element the element
* @return the type of the element as viewed from the containing type
* @throws IllegalArgumentException if the element is not a valid one
* for the given type
*/
TypeMirror asMemberOf(DeclaredType containing, Element element);
}
| 11,695 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
AbstractElementVisitor7.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/util/AbstractElementVisitor7.java | /*
* Copyright (c) 2010, 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 javax.lang.model.util;
import javax.lang.model.element.*;
import javax.annotation.processing.SupportedSourceVersion;
import javax.lang.model.element.*;
import static javax.lang.model.element.ElementKind.*;
import static javax.lang.model.SourceVersion.*;
import javax.lang.model.SourceVersion;
/**
* A skeletal visitor of program elements with default behavior
* appropriate for the {@link SourceVersion#RELEASE_7 RELEASE_7}
* source version.
*
* <p> <b>WARNING:</b> The {@code ElementVisitor} interface
* implemented by this class may have methods added to it in the
* future to accommodate new, currently unknown, language structures
* added to future versions of the Java™ programming language.
* Therefore, methods whose names begin with {@code "visit"} may be
* added to this class in the future; to avoid incompatibilities,
* classes which extend this class should not declare any instance
* methods with names beginning with {@code "visit"}.
*
* <p>When such a new visit method is added, the default
* implementation in this class will be to call the {@link
* #visitUnknown visitUnknown} method. A new abstract element visitor
* class will also be introduced to correspond to the new language
* level; this visitor will have different default behavior for the
* visit method in question. When the new visitor is introduced, all
* or portions of this visitor may be deprecated.
*
* @param <R> the return type of this visitor's methods. Use {@link
* Void} for visitors that do not need to return results.
* @param <P> the type of the additional parameter to this visitor's
* methods. Use {@code Void} for visitors that do not need an
* additional parameter.
*
* @see AbstractElementVisitor6
* @since 1.7
*/
@SupportedSourceVersion(RELEASE_7)
public abstract class AbstractElementVisitor7<R, P> extends AbstractElementVisitor6<R, P> {
/**
* Constructor for concrete subclasses to call.
*/
protected AbstractElementVisitor7(){
super();
}
}
| 3,264 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
TypeKindVisitor6.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/util/TypeKindVisitor6.java | /*
* Copyright (c) 2005, 2010, 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 javax.lang.model.util;
import javax.lang.model.type.*;
import javax.annotation.processing.SupportedSourceVersion;
import static javax.lang.model.element.ElementKind.*;
import static javax.lang.model.SourceVersion.*;
import javax.lang.model.SourceVersion;
/**
* A visitor of types based on their {@linkplain TypeKind kind} with
* default behavior appropriate for the {@link SourceVersion#RELEASE_6
* RELEASE_6} source version. For {@linkplain
* TypeMirror types} <tt><i>XYZ</i></tt> that may have more than one
* kind, the <tt>visit<i>XYZ</i></tt> methods in this class delegate
* to the <tt>visit<i>XYZKind</i></tt> method corresponding to the
* first argument's kind. The <tt>visit<i>XYZKind</i></tt> methods
* call {@link #defaultAction defaultAction}, passing their arguments
* to {@code defaultAction}'s corresponding parameters.
*
* <p> Methods in this class may be overridden subject to their
* general contract. Note that annotating methods in concrete
* subclasses with {@link java.lang.Override @Override} will help
* ensure that methods are overridden as intended.
*
* <p> <b>WARNING:</b> The {@code TypeVisitor} interface implemented
* by this class may have methods added to it in the future to
* accommodate new, currently unknown, language structures added to
* future versions of the Java™ programming language.
* Therefore, methods whose names begin with {@code "visit"} may be
* added to this class in the future; to avoid incompatibilities,
* classes which extend this class should not declare any instance
* methods with names beginning with {@code "visit"}.
*
* <p>When such a new visit method is added, the default
* implementation in this class will be to call the {@link
* #visitUnknown visitUnknown} method. A new type kind visitor class
* will also be introduced to correspond to the new language level;
* this visitor will have different default behavior for the visit
* method in question. When the new visitor is introduced, all or
* portions of this visitor may be deprecated.
*
* @param <R> the return type of this visitor's methods. Use {@link
* Void} for visitors that do not need to return results.
* @param <P> the type of the additional parameter to this visitor's
* methods. Use {@code Void} for visitors that do not need an
* additional parameter.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
*
* @see TypeKindVisitor7
* @since 1.6
*/
@SupportedSourceVersion(RELEASE_6)
public class TypeKindVisitor6<R, P> extends SimpleTypeVisitor6<R, P> {
/**
* Constructor for concrete subclasses to call; uses {@code null}
* for the default value.
*/
protected TypeKindVisitor6() {
super(null);
}
/**
* Constructor for concrete subclasses to call; uses the argument
* for the default value.
*
* @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
*/
protected TypeKindVisitor6(R defaultValue) {
super(defaultValue);
}
/**
* Visits a primitive type, dispatching to the visit method for
* the specific {@linkplain TypeKind kind} of primitive type:
* {@code BOOLEAN}, {@code BYTE}, etc.
*
* @param t {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of the kind-specific visit method
*/
@Override
public R visitPrimitive(PrimitiveType t, P p) {
TypeKind k = t.getKind();
switch (k) {
case BOOLEAN:
return visitPrimitiveAsBoolean(t, p);
case BYTE:
return visitPrimitiveAsByte(t, p);
case SHORT:
return visitPrimitiveAsShort(t, p);
case INT:
return visitPrimitiveAsInt(t, p);
case LONG:
return visitPrimitiveAsLong(t, p);
case CHAR:
return visitPrimitiveAsChar(t, p);
case FLOAT:
return visitPrimitiveAsFloat(t, p);
case DOUBLE:
return visitPrimitiveAsDouble(t, p);
default:
throw new AssertionError("Bad kind " + k + " for PrimitiveType" + t);
}
}
/**
* Visits a {@code BOOLEAN} primitive type by calling
* {@code defaultAction}.
*
* @param t the type to visit
* @param p a visitor-specified parameter
* @return the result of {@code defaultAction}
*/
public R visitPrimitiveAsBoolean(PrimitiveType t, P p) {
return defaultAction(t, p);
}
/**
* Visits a {@code BYTE} primitive type by calling
* {@code defaultAction}.
*
* @param t the type to visit
* @param p a visitor-specified parameter
* @return the result of {@code defaultAction}
*/
public R visitPrimitiveAsByte(PrimitiveType t, P p) {
return defaultAction(t, p);
}
/**
* Visits a {@code SHORT} primitive type by calling
* {@code defaultAction}.
*
* @param t the type to visit
* @param p a visitor-specified parameter
* @return the result of {@code defaultAction}
*/
public R visitPrimitiveAsShort(PrimitiveType t, P p) {
return defaultAction(t, p);
}
/**
* Visits an {@code INT} primitive type by calling
* {@code defaultAction}.
*
* @param t the type to visit
* @param p a visitor-specified parameter
* @return the result of {@code defaultAction}
*/
public R visitPrimitiveAsInt(PrimitiveType t, P p) {
return defaultAction(t, p);
}
/**
* Visits a {@code LONG} primitive type by calling
* {@code defaultAction}.
*
* @param t the type to visit
* @param p a visitor-specified parameter
* @return the result of {@code defaultAction}
*/
public R visitPrimitiveAsLong(PrimitiveType t, P p) {
return defaultAction(t, p);
}
/**
* Visits a {@code CHAR} primitive type by calling
* {@code defaultAction}.
*
* @param t the type to visit
* @param p a visitor-specified parameter
* @return the result of {@code defaultAction}
*/
public R visitPrimitiveAsChar(PrimitiveType t, P p) {
return defaultAction(t, p);
}
/**
* Visits a {@code FLOAT} primitive type by calling
* {@code defaultAction}.
*
* @param t the type to visit
* @param p a visitor-specified parameter
* @return the result of {@code defaultAction}
*/
public R visitPrimitiveAsFloat(PrimitiveType t, P p) {
return defaultAction(t, p);
}
/**
* Visits a {@code DOUBLE} primitive type by calling
* {@code defaultAction}.
*
* @param t the type to visit
* @param p a visitor-specified parameter
* @return the result of {@code defaultAction}
*/
public R visitPrimitiveAsDouble(PrimitiveType t, P p) {
return defaultAction(t, p);
}
/**
* Visits a {@link NoType} instance, dispatching to the visit method for
* the specific {@linkplain TypeKind kind} of pseudo-type:
* {@code VOID}, {@code PACKAGE}, or {@code NONE}.
*
* @param t {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of the kind-specific visit method
*/
@Override
public R visitNoType(NoType t, P p) {
TypeKind k = t.getKind();
switch (k) {
case VOID:
return visitNoTypeAsVoid(t, p);
case PACKAGE:
return visitNoTypeAsPackage(t, p);
case NONE:
return visitNoTypeAsNone(t, p);
default:
throw new AssertionError("Bad kind " + k + " for NoType" + t);
}
}
/**
* Visits a {@link TypeKind#VOID VOID} pseudo-type by calling
* {@code defaultAction}.
*
* @param t the type to visit
* @param p a visitor-specified parameter
* @return the result of {@code defaultAction}
*/
public R visitNoTypeAsVoid(NoType t, P p) {
return defaultAction(t, p);
}
/**
* Visits a {@link TypeKind#PACKAGE PACKAGE} pseudo-type by calling
* {@code defaultAction}.
*
* @param t the type to visit
* @param p a visitor-specified parameter
* @return the result of {@code defaultAction}
*/
public R visitNoTypeAsPackage(NoType t, P p) {
return defaultAction(t, p);
}
/**
* Visits a {@link TypeKind#NONE NONE} pseudo-type by calling
* {@code defaultAction}.
*
* @param t the type to visit
* @param p a visitor-specified parameter
* @return the result of {@code defaultAction}
*/
public R visitNoTypeAsNone(NoType t, P p) {
return defaultAction(t, p);
}
}
| 9,938 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
ElementKindVisitor6.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/util/ElementKindVisitor6.java | /*
* Copyright (c) 2005, 2011, 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 javax.lang.model.util;
import javax.lang.model.element.*;
import static javax.lang.model.element.ElementKind.*;
import javax.annotation.processing.SupportedSourceVersion;
import static javax.lang.model.SourceVersion.*;
import javax.lang.model.SourceVersion;
/**
* A visitor of program elements based on their {@linkplain
* ElementKind kind} with default behavior appropriate for the {@link
* SourceVersion#RELEASE_6 RELEASE_6} source version. For {@linkplain
* Element elements} <tt><i>XYZ</i></tt> that may have more than one
* kind, the <tt>visit<i>XYZ</i></tt> methods in this class delegate
* to the <tt>visit<i>XYZKind</i></tt> method corresponding to the
* first argument's kind. The <tt>visit<i>XYZKind</i></tt> methods
* call {@link #defaultAction defaultAction}, passing their arguments
* to {@code defaultAction}'s corresponding parameters.
*
* <p> Methods in this class may be overridden subject to their
* general contract. Note that annotating methods in concrete
* subclasses with {@link java.lang.Override @Override} will help
* ensure that methods are overridden as intended.
*
* <p> <b>WARNING:</b> The {@code ElementVisitor} interface
* implemented by this class may have methods added to it or the
* {@code ElementKind} {@code enum} used in this case may have
* constants added to it in the future to accommodate new, currently
* unknown, language structures added to future versions of the
* Java™ programming language. Therefore, methods whose names
* begin with {@code "visit"} may be added to this class in the
* future; to avoid incompatibilities, classes which extend this class
* should not declare any instance methods with names beginning with
* {@code "visit"}.
*
* <p>When such a new visit method is added, the default
* implementation in this class will be to call the {@link
* #visitUnknown visitUnknown} method. A new abstract element kind
* visitor class will also be introduced to correspond to the new
* language level; this visitor will have different default behavior
* for the visit method in question. When the new visitor is
* introduced, all or portions of this visitor may be deprecated.
*
* @param <R> the return type of this visitor's methods. Use {@link
* Void} for visitors that do not need to return results.
* @param <P> the type of the additional parameter to this visitor's
* methods. Use {@code Void} for visitors that do not need an
* additional parameter.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
*
* @see ElementKindVisitor7
* @since 1.6
*/
@SupportedSourceVersion(RELEASE_6)
public class ElementKindVisitor6<R, P>
extends SimpleElementVisitor6<R, P> {
/**
* Constructor for concrete subclasses; uses {@code null} for the
* default value.
*/
protected ElementKindVisitor6() {
super(null);
}
/**
* Constructor for concrete subclasses; uses the argument for the
* default value.
*
* @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
*/
protected ElementKindVisitor6(R defaultValue) {
super(defaultValue);
}
/**
* {@inheritDoc}
*
* The element argument has kind {@code PACKAGE}.
*
* @param e {@inheritDoc}
* @param p {@inheritDoc}
* @return {@inheritDoc}
*/
@Override
public R visitPackage(PackageElement e, P p) {
assert e.getKind() == PACKAGE: "Bad kind on PackageElement";
return defaultAction(e, p);
}
/**
* Visits a type element, dispatching to the visit method for the
* specific {@linkplain ElementKind kind} of type, {@code
* ANNOTATION_TYPE}, {@code CLASS}, {@code ENUM}, or {@code
* INTERFACE}.
*
* @param e {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of the kind-specific visit method
*/
@Override
public R visitType(TypeElement e, P p) {
ElementKind k = e.getKind();
switch(k) {
case ANNOTATION_TYPE:
return visitTypeAsAnnotationType(e, p);
case CLASS:
return visitTypeAsClass(e, p);
case ENUM:
return visitTypeAsEnum(e, p);
case INTERFACE:
return visitTypeAsInterface(e, p);
default:
throw new AssertionError("Bad kind " + k + " for TypeElement" + e);
}
}
/**
* Visits an {@code ANNOTATION_TYPE} type element by calling
* {@code defaultAction}.
*
* @param e the element to visit
* @param p a visitor-specified parameter
* @return the result of {@code defaultAction}
*/
public R visitTypeAsAnnotationType(TypeElement e, P p) {
return defaultAction(e, p);
}
/**
* Visits a {@code CLASS} type element by calling {@code
* defaultAction}.
*
* @param e the element to visit
* @param p a visitor-specified parameter
* @return the result of {@code defaultAction}
*/
public R visitTypeAsClass(TypeElement e, P p) {
return defaultAction(e, p);
}
/**
* Visits an {@code ENUM} type element by calling {@code
* defaultAction}.
*
* @param e the element to visit
* @param p a visitor-specified parameter
* @return the result of {@code defaultAction}
*/
public R visitTypeAsEnum(TypeElement e, P p) {
return defaultAction(e, p);
}
/**
* Visits an {@code INTERFACE} type element by calling {@code
* defaultAction}.
*.
* @param e the element to visit
* @param p a visitor-specified parameter
* @return the result of {@code defaultAction}
*/
public R visitTypeAsInterface(TypeElement e, P p) {
return defaultAction(e, p);
}
/**
* Visits a variable element, dispatching to the visit method for
* the specific {@linkplain ElementKind kind} of variable, {@code
* ENUM_CONSTANT}, {@code EXCEPTION_PARAMETER}, {@code FIELD},
* {@code LOCAL_VARIABLE}, {@code PARAMETER}, or {@code RESOURCE_VARIABLE}.
*
* @param e {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of the kind-specific visit method
*/
@Override
public R visitVariable(VariableElement e, P p) {
ElementKind k = e.getKind();
switch(k) {
case ENUM_CONSTANT:
return visitVariableAsEnumConstant(e, p);
case EXCEPTION_PARAMETER:
return visitVariableAsExceptionParameter(e, p);
case FIELD:
return visitVariableAsField(e, p);
case LOCAL_VARIABLE:
return visitVariableAsLocalVariable(e, p);
case PARAMETER:
return visitVariableAsParameter(e, p);
case RESOURCE_VARIABLE:
return visitVariableAsResourceVariable(e, p);
default:
throw new AssertionError("Bad kind " + k + " for VariableElement" + e);
}
}
/**
* Visits an {@code ENUM_CONSTANT} variable element by calling
* {@code defaultAction}.
*
* @param e the element to visit
* @param p a visitor-specified parameter
* @return the result of {@code defaultAction}
*/
public R visitVariableAsEnumConstant(VariableElement e, P p) {
return defaultAction(e, p);
}
/**
* Visits an {@code EXCEPTION_PARAMETER} variable element by calling
* {@code defaultAction}.
*
* @param e the element to visit
* @param p a visitor-specified parameter
* @return the result of {@code defaultAction}
*/
public R visitVariableAsExceptionParameter(VariableElement e, P p) {
return defaultAction(e, p);
}
/**
* Visits a {@code FIELD} variable element by calling
* {@code defaultAction}.
*
* @param e the element to visit
* @param p a visitor-specified parameter
* @return the result of {@code defaultAction}
*/
public R visitVariableAsField(VariableElement e, P p) {
return defaultAction(e, p);
}
/**
* Visits a {@code LOCAL_VARIABLE} variable element by calling
* {@code defaultAction}.
*
* @param e the element to visit
* @param p a visitor-specified parameter
* @return the result of {@code defaultAction}
*/
public R visitVariableAsLocalVariable(VariableElement e, P p) {
return defaultAction(e, p);
}
/**
* Visits a {@code PARAMETER} variable element by calling
* {@code defaultAction}.
*
* @param e the element to visit
* @param p a visitor-specified parameter
* @return the result of {@code defaultAction}
*/
public R visitVariableAsParameter(VariableElement e, P p) {
return defaultAction(e, p);
}
/**
* Visits a {@code RESOURCE_VARIABLE} variable element by calling
* {@code visitUnknown}.
*
* @param e the element to visit
* @param p a visitor-specified parameter
* @return the result of {@code visitUnknown}
*
* @since 1.7
*/
public R visitVariableAsResourceVariable(VariableElement e, P p) {
return visitUnknown(e, p);
}
/**
* Visits an executable element, dispatching to the visit method
* for the specific {@linkplain ElementKind kind} of executable,
* {@code CONSTRUCTOR}, {@code INSTANCE_INIT}, {@code METHOD}, or
* {@code STATIC_INIT}.
*
* @param e {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of the kind-specific visit method
*/
@Override
public R visitExecutable(ExecutableElement e, P p) {
ElementKind k = e.getKind();
switch(k) {
case CONSTRUCTOR:
return visitExecutableAsConstructor(e, p);
case INSTANCE_INIT:
return visitExecutableAsInstanceInit(e, p);
case METHOD:
return visitExecutableAsMethod(e, p);
case STATIC_INIT:
return visitExecutableAsStaticInit(e, p);
default:
throw new AssertionError("Bad kind " + k + " for ExecutableElement" + e);
}
}
/**
* Visits a {@code CONSTRUCTOR} executable element by calling
* {@code defaultAction}.
*
* @param e the element to visit
* @param p a visitor-specified parameter
* @return the result of {@code defaultAction}
*/
public R visitExecutableAsConstructor(ExecutableElement e, P p) {
return defaultAction(e, p);
}
/**
* Visits an {@code INSTANCE_INIT} executable element by calling
* {@code defaultAction}.
*
* @param e the element to visit
* @param p a visitor-specified parameter
* @return the result of {@code defaultAction}
*/
public R visitExecutableAsInstanceInit(ExecutableElement e, P p) {
return defaultAction(e, p);
}
/**
* Visits a {@code METHOD} executable element by calling
* {@code defaultAction}.
*
* @param e the element to visit
* @param p a visitor-specified parameter
* @return the result of {@code defaultAction}
*/
public R visitExecutableAsMethod(ExecutableElement e, P p) {
return defaultAction(e, p);
}
/**
* Visits a {@code STATIC_INIT} executable element by calling
* {@code defaultAction}.
*
* @param e the element to visit
* @param p a visitor-specified parameter
* @return the result of {@code defaultAction}
*/
public R visitExecutableAsStaticInit(ExecutableElement e, P p) {
return defaultAction(e, p);
}
/**
* {@inheritDoc}
*
* The element argument has kind {@code TYPE_PARAMETER}.
*
* @param e {@inheritDoc}
* @param p {@inheritDoc}
* @return {@inheritDoc}
*/
@Override
public R visitTypeParameter(TypeParameterElement e, P p) {
assert e.getKind() == TYPE_PARAMETER: "Bad kind on TypeParameterElement";
return defaultAction(e, p);
}
}
| 13,255 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
ElementScanner7.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/util/ElementScanner7.java | /*
* Copyright (c) 2010, 2011, 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 javax.lang.model.util;
import javax.lang.model.element.*;
import javax.annotation.processing.SupportedSourceVersion;
import static javax.lang.model.element.ElementKind.*;
import javax.lang.model.SourceVersion;
import static javax.lang.model.SourceVersion.*;
/**
* A scanning visitor of program elements with default behavior
* appropriate for the {@link SourceVersion#RELEASE_7 RELEASE_7}
* source version. The <tt>visit<i>XYZ</i></tt> methods in this
* class scan their component elements by calling {@code scan} on
* their {@linkplain Element#getEnclosedElements enclosed elements},
* {@linkplain ExecutableElement#getParameters parameters}, etc., as
* indicated in the individual method specifications. A subclass can
* control the order elements are visited by overriding the
* <tt>visit<i>XYZ</i></tt> methods. Note that clients of a scanner
* may get the desired behavior be invoking {@code v.scan(e, p)} rather
* than {@code v.visit(e, p)} on the root objects of interest.
*
* <p>When a subclass overrides a <tt>visit<i>XYZ</i></tt> method, the
* new method can cause the enclosed elements to be scanned in the
* default way by calling <tt>super.visit<i>XYZ</i></tt>. In this
* fashion, the concrete visitor can control the ordering of traversal
* over the component elements with respect to the additional
* processing; for example, consistently calling
* <tt>super.visit<i>XYZ</i></tt> at the start of the overridden
* methods will yield a preorder traversal, etc. If the component
* elements should be traversed in some other order, instead of
* calling <tt>super.visit<i>XYZ</i></tt>, an overriding visit method
* should call {@code scan} with the elements in the desired order.
*
* <p> Methods in this class may be overridden subject to their
* general contract. Note that annotating methods in concrete
* subclasses with {@link java.lang.Override @Override} will help
* ensure that methods are overridden as intended.
*
* <p> <b>WARNING:</b> The {@code ElementVisitor} interface
* implemented by this class may have methods added to it in the
* future to accommodate new, currently unknown, language structures
* added to future versions of the Java™ programming language.
* Therefore, methods whose names begin with {@code "visit"} may be
* added to this class in the future; to avoid incompatibilities,
* classes which extend this class should not declare any instance
* methods with names beginning with {@code "visit"}.
*
* <p>When such a new visit method is added, the default
* implementation in this class will be to call the {@link
* #visitUnknown visitUnknown} method. A new element scanner visitor
* class will also be introduced to correspond to the new language
* level; this visitor will have different default behavior for the
* visit method in question. When the new visitor is introduced, all
* or portions of this visitor may be deprecated.
*
* @param <R> the return type of this visitor's methods. Use {@link
* Void} for visitors that do not need to return results.
* @param <P> the type of the additional parameter to this visitor's
* methods. Use {@code Void} for visitors that do not need an
* additional parameter.
*
* @see ElementScanner6
* @since 1.7
*/
@SupportedSourceVersion(RELEASE_7)
public class ElementScanner7<R, P> extends ElementScanner6<R, P> {
/**
* Constructor for concrete subclasses; uses {@code null} for the
* default value.
*/
protected ElementScanner7(){
super(null);
}
/**
* Constructor for concrete subclasses; uses the argument for the
* default value.
*/
protected ElementScanner7(R defaultValue){
super(defaultValue);
}
/**
* This implementation scans the enclosed elements.
*
* @param e {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of scanning
*/
@Override
public R visitVariable(VariableElement e, P p) {
return scan(e.getEnclosedElements(), p);
}
}
| 5,285 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
AbstractElementVisitor6.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/util/AbstractElementVisitor6.java | /*
* Copyright (c) 2005, 2010, 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 javax.lang.model.util;
import javax.lang.model.element.*;
import javax.annotation.processing.SupportedSourceVersion;
import javax.lang.model.element.*;
import static javax.lang.model.element.ElementKind.*;
import static javax.lang.model.SourceVersion.*;
import javax.lang.model.SourceVersion;
/**
* A skeletal visitor of program elements with default behavior
* appropriate for the {@link SourceVersion#RELEASE_6 RELEASE_6}
* source version.
*
* <p> <b>WARNING:</b> The {@code ElementVisitor} interface
* implemented by this class may have methods added to it in the
* future to accommodate new, currently unknown, language structures
* added to future versions of the Java™ programming language.
* Therefore, methods whose names begin with {@code "visit"} may be
* added to this class in the future; to avoid incompatibilities,
* classes which extend this class should not declare any instance
* methods with names beginning with {@code "visit"}.
*
* <p>When such a new visit method is added, the default
* implementation in this class will be to call the {@link
* #visitUnknown visitUnknown} method. A new abstract element visitor
* class will also be introduced to correspond to the new language
* level; this visitor will have different default behavior for the
* visit method in question. When the new visitor is introduced, all
* or portions of this visitor may be deprecated.
*
* @param <R> the return type of this visitor's methods. Use {@link
* Void} for visitors that do not need to return results.
* @param <P> the type of the additional parameter to this visitor's
* methods. Use {@code Void} for visitors that do not need an
* additional parameter.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
*
* @see AbstractElementVisitor7
* @since 1.6
*/
@SupportedSourceVersion(RELEASE_6)
public abstract class AbstractElementVisitor6<R, P> implements ElementVisitor<R, P> {
/**
* Constructor for concrete subclasses to call.
*/
protected AbstractElementVisitor6(){}
/**
* Visits any program element as if by passing itself to that
* element's {@link Element#accept accept} method. The invocation
* {@code v.visit(elem)} is equivalent to {@code elem.accept(v,
* p)}.
*
* @param e the element to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
*/
public final R visit(Element e, P p) {
return e.accept(this, p);
}
/**
* Visits any program element as if by passing itself to that
* element's {@link Element#accept accept} method and passing
* {@code null} for the additional parameter. The invocation
* {@code v.visit(elem)} is equivalent to {@code elem.accept(v,
* null)}.
*
* @param e the element to visit
* @return a visitor-specified result
*/
public final R visit(Element e) {
return e.accept(this, null);
}
/**
* {@inheritDoc}
*
* <p> The default implementation of this method in
* {@code AbstractElementVisitor6} will always throw
* {@code UnknownElementException}.
* This behavior is not required of a subclass.
*
* @param e the element to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
* @throws UnknownElementException
* a visitor implementation may optionally throw this exception
*/
public R visitUnknown(Element e, P p) {
throw new UnknownElementException(e, p);
}
}
| 4,851 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
AbstractTypeVisitor7.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/util/AbstractTypeVisitor7.java | /*
* Copyright (c) 2010, 2011, 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 javax.lang.model.util;
import javax.lang.model.type.*;
/**
* A skeletal visitor of types with default behavior appropriate for
* the {@link javax.lang.model.SourceVersion#RELEASE_7 RELEASE_7}
* source version.
*
* <p> <b>WARNING:</b> The {@code TypeVisitor} interface implemented
* by this class may have methods added to it in the future to
* accommodate new, currently unknown, language structures added to
* future versions of the Java™ programming language.
* Therefore, methods whose names begin with {@code "visit"} may be
* added to this class in the future; to avoid incompatibilities,
* classes which extend this class should not declare any instance
* methods with names beginning with {@code "visit"}.
*
* <p>When such a new visit method is added, the default
* implementation in this class will be to call the {@link
* #visitUnknown visitUnknown} method. A new abstract type visitor
* class will also be introduced to correspond to the new language
* level; this visitor will have different default behavior for the
* visit method in question. When the new visitor is introduced, all
* or portions of this visitor may be deprecated.
*
* @param <R> the return type of this visitor's methods. Use {@link
* Void} for visitors that do not need to return results.
* @param <P> the type of the additional parameter to this visitor's
* methods. Use {@code Void} for visitors that do not need an
* additional parameter.
*
* @see AbstractTypeVisitor6
* @since 1.7
*/
public abstract class AbstractTypeVisitor7<R, P> extends AbstractTypeVisitor6<R, P> {
/**
* Constructor for concrete subclasses to call.
*/
protected AbstractTypeVisitor7() {
super();
}
/**
* Visits a {@code UnionType} in a manner defined by a subclass.
*
* @param t {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of the visit as defined by a subclass
*/
public abstract R visitUnion(UnionType t, P p);
}
| 3,256 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
TypeKindVisitor7.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/util/TypeKindVisitor7.java | /*
* Copyright (c) 2010, 2011, 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 javax.lang.model.util;
import javax.lang.model.type.*;
import javax.annotation.processing.SupportedSourceVersion;
import static javax.lang.model.element.ElementKind.*;
import static javax.lang.model.SourceVersion.*;
import javax.lang.model.SourceVersion;
/**
* A visitor of types based on their {@linkplain TypeKind kind} with
* default behavior appropriate for the {@link SourceVersion#RELEASE_7
* RELEASE_7} source version. For {@linkplain
* TypeMirror types} <tt><i>XYZ</i></tt> that may have more than one
* kind, the <tt>visit<i>XYZ</i></tt> methods in this class delegate
* to the <tt>visit<i>XYZKind</i></tt> method corresponding to the
* first argument's kind. The <tt>visit<i>XYZKind</i></tt> methods
* call {@link #defaultAction defaultAction}, passing their arguments
* to {@code defaultAction}'s corresponding parameters.
*
* <p> Methods in this class may be overridden subject to their
* general contract. Note that annotating methods in concrete
* subclasses with {@link java.lang.Override @Override} will help
* ensure that methods are overridden as intended.
*
* <p> <b>WARNING:</b> The {@code TypeVisitor} interface implemented
* by this class may have methods added to it in the future to
* accommodate new, currently unknown, language structures added to
* future versions of the Java™ programming language.
* Therefore, methods whose names begin with {@code "visit"} may be
* added to this class in the future; to avoid incompatibilities,
* classes which extend this class should not declare any instance
* methods with names beginning with {@code "visit"}.
*
* <p>When such a new visit method is added, the default
* implementation in this class will be to call the {@link
* #visitUnknown visitUnknown} method. A new type kind visitor class
* will also be introduced to correspond to the new language level;
* this visitor will have different default behavior for the visit
* method in question. When the new visitor is introduced, all or
* portions of this visitor may be deprecated.
*
* @param <R> the return type of this visitor's methods. Use {@link
* Void} for visitors that do not need to return results.
* @param <P> the type of the additional parameter to this visitor's
* methods. Use {@code Void} for visitors that do not need an
* additional parameter.
*
* @see TypeKindVisitor6
* @since 1.7
*/
@SupportedSourceVersion(RELEASE_7)
public class TypeKindVisitor7<R, P> extends TypeKindVisitor6<R, P> {
/**
* Constructor for concrete subclasses to call; uses {@code null}
* for the default value.
*/
protected TypeKindVisitor7() {
super(null);
}
/**
* Constructor for concrete subclasses to call; uses the argument
* for the default value.
*
* @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
*/
protected TypeKindVisitor7(R defaultValue) {
super(defaultValue);
}
/**
* This implementation visits a {@code UnionType} by calling
* {@code defaultAction}.
*
* @param t {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
@Override
public R visitUnion(UnionType t, P p) {
return defaultAction(t, p);
}
}
| 4,535 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Elements.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/util/Elements.java | /*
* Copyright (c) 2005, 2006, 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 javax.lang.model.util;
import java.util.List;
import java.util.Map;
import javax.lang.model.element.*;
import javax.lang.model.type.*;
/**
* Utility methods for operating on program elements.
*
* <p><b>Compatibility Note:</b> Methods may be added to this interface
* in future releases of the platform.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @see javax.annotation.processing.ProcessingEnvironment#getElementUtils
* @since 1.6
*/
public interface Elements {
/**
* Returns a package given its fully qualified name.
*
* @param name fully qualified package name, or "" for an unnamed package
* @return the named package, or {@code null} if it cannot be found
*/
PackageElement getPackageElement(CharSequence name);
/**
* Returns a type element given its canonical name.
*
* @param name the canonical name
* @return the named type element, or {@code null} if it cannot be found
*/
TypeElement getTypeElement(CharSequence name);
/**
* Returns the values of an annotation's elements, including defaults.
*
* @see AnnotationMirror#getElementValues()
* @param a annotation to examine
* @return the values of the annotation's elements, including defaults
*/
Map<? extends ExecutableElement, ? extends AnnotationValue>
getElementValuesWithDefaults(AnnotationMirror a);
/**
* Returns the text of the documentation ("Javadoc")
* comment of an element.
*
* <p> A documentation comment of an element is a comment that
* begins with "{@code /**}" , ends with a separate
* "<code>*/</code>", and immediately precedes the element,
* ignoring white space. Therefore, a documentation comment
* contains at least three"{@code *}" characters. The text
* returned for the documentation comment is a processed form of
* the comment as it appears in source code. The leading "{@code
* /**}" and trailing "<code>*/</code>" are removed. For lines
* of the comment starting after the initial "{@code /**}",
* leading white space characters are discarded as are any
* consecutive "{@code *}" characters appearing after the white
* space or starting the line. The processed lines are then
* concatenated together (including line terminators) and
* returned.
*
* @param e the element being examined
* @return the documentation comment of the element, or {@code null}
* if there is none
* @jls 3.6 White Space
*/
String getDocComment(Element e);
/**
* Returns {@code true} if the element is deprecated, {@code false} otherwise.
*
* @param e the element being examined
* @return {@code true} if the element is deprecated, {@code false} otherwise
*/
boolean isDeprecated(Element e);
/**
* Returns the <i>binary name</i> of a type element.
*
* @param type the type element being examined
* @return the binary name
*
* @see TypeElement#getQualifiedName
* @jls 13.1 The Form of a Binary
*/
Name getBinaryName(TypeElement type);
/**
* Returns the package of an element. The package of a package is
* itself.
*
* @param type the element being examined
* @return the package of an element
*/
PackageElement getPackageOf(Element type);
/**
* Returns all members of a type element, whether inherited or
* declared directly. For a class the result also includes its
* constructors, but not local or anonymous classes.
*
* <p>Note that elements of certain kinds can be isolated using
* methods in {@link ElementFilter}.
*
* @param type the type being examined
* @return all members of the type
* @see Element#getEnclosedElements
*/
List<? extends Element> getAllMembers(TypeElement type);
/**
* Returns all annotations of an element, whether
* inherited or directly present.
*
* @param e the element being examined
* @return all annotations of the element
* @see Element#getAnnotationMirrors
*/
List<? extends AnnotationMirror> getAllAnnotationMirrors(Element e);
/**
* Tests whether one type, method, or field hides another.
*
* @param hider the first element
* @param hidden the second element
* @return {@code true} if and only if the first element hides
* the second
*/
boolean hides(Element hider, Element hidden);
/**
* Tests whether one method, as a member of a given type,
* overrides another method.
* When a non-abstract method overrides an abstract one, the
* former is also said to <i>implement</i> the latter.
*
* <p> In the simplest and most typical usage, the value of the
* {@code type} parameter will simply be the class or interface
* directly enclosing {@code overrider} (the possibly-overriding
* method). For example, suppose {@code m1} represents the method
* {@code String.hashCode} and {@code m2} represents {@code
* Object.hashCode}. We can then ask whether {@code m1} overrides
* {@code m2} within the class {@code String} (it does):
*
* <blockquote>
* {@code assert elements.overrides(m1, m2,
* elements.getTypeElement("java.lang.String")); }
* </blockquote>
*
* A more interesting case can be illustrated by the following example
* in which a method in type {@code A} does not override a
* like-named method in type {@code B}:
*
* <blockquote>
* {@code class A { public void m() {} } }<br>
* {@code interface B { void m(); } }<br>
* ...<br>
* {@code m1 = ...; // A.m }<br>
* {@code m2 = ...; // B.m }<br>
* {@code assert ! elements.overrides(m1, m2,
* elements.getTypeElement("A")); }
* </blockquote>
*
* When viewed as a member of a third type {@code C}, however,
* the method in {@code A} does override the one in {@code B}:
*
* <blockquote>
* {@code class C extends A implements B {} }<br>
* ...<br>
* {@code assert elements.overrides(m1, m2,
* elements.getTypeElement("C")); }
* </blockquote>
*
* @param overrider the first method, possible overrider
* @param overridden the second method, possibly being overridden
* @param type the type of which the first method is a member
* @return {@code true} if and only if the first method overrides
* the second
* @jls 8.4.8 Inheritance, Overriding, and Hiding
* @jls 9.4.1 Inheritance and Overriding
*/
boolean overrides(ExecutableElement overrider, ExecutableElement overridden,
TypeElement type);
/**
* Returns the text of a <i>constant expression</i> representing a
* primitive value or a string.
* The text returned is in a form suitable for representing the value
* in source code.
*
* @param value a primitive value or string
* @return the text of a constant expression
* @throws IllegalArgumentException if the argument is not a primitive
* value or string
*
* @see VariableElement#getConstantValue()
*/
String getConstantExpression(Object value);
/**
* Prints a representation of the elements to the given writer in
* the specified order. The main purpose of this method is for
* diagnostics. The exact format of the output is <em>not</em>
* specified and is subject to change.
*
* @param w the writer to print the output to
* @param elements the elements to print
*/
void printElements(java.io.Writer w, Element... elements);
/**
* Return a name with the same sequence of characters as the
* argument.
*
* @param cs the character sequence to return as a name
*/
Name getName(CharSequence cs);
}
| 9,284 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
SimpleAnnotationValueVisitor6.java | /FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor6.java | /*
* Copyright (c) 2005, 2010, 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 javax.lang.model.util;
import java.util.List;
import javax.lang.model.element.*;
import javax.lang.model.type.TypeMirror;
import static javax.lang.model.SourceVersion.*;
import javax.lang.model.SourceVersion;
import javax.annotation.processing.SupportedSourceVersion;
/**
* A simple visitor for annotation values with default behavior
* appropriate for the {@link SourceVersion#RELEASE_6 RELEASE_6}
* source version. Visit methods call {@link
* #defaultAction} passing their arguments to {@code defaultAction}'s
* corresponding parameters.
*
* <p> Methods in this class may be overridden subject to their
* general contract. Note that annotating methods in concrete
* subclasses with {@link java.lang.Override @Override} will help
* ensure that methods are overridden as intended.
*
* <p> <b>WARNING:</b> The {@code AnnotationValueVisitor} interface
* implemented by this class may have methods added to it in the
* future to accommodate new, currently unknown, language structures
* added to future versions of the Java™ programming language.
* Therefore, methods whose names begin with {@code "visit"} may be
* added to this class in the future; to avoid incompatibilities,
* classes which extend this class should not declare any instance
* methods with names beginning with {@code "visit"}.
*
* <p>When such a new visit method is added, the default
* implementation in this class will be to call the {@link
* #visitUnknown visitUnknown} method. A new simple annotation
* value visitor class will also be introduced to correspond to the
* new language level; this visitor will have different default
* behavior for the visit method in question. When the new visitor is
* introduced, all or portions of this visitor may be deprecated.
*
* @param <R> the return type of this visitor's methods
* @param <P> the type of the additional parameter to this visitor's methods.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
*
* @see SimpleAnnotationValueVisitor7
* @since 1.6
*/
@SupportedSourceVersion(RELEASE_6)
public class SimpleAnnotationValueVisitor6<R, P>
extends AbstractAnnotationValueVisitor6<R, P> {
/**
* Default value to be returned; {@link #defaultAction
* defaultAction} returns this value unless the method is
* overridden.
*/
protected final R DEFAULT_VALUE;
/**
* Constructor for concrete subclasses; uses {@code null} for the
* default value.
*/
protected SimpleAnnotationValueVisitor6() {
super();
DEFAULT_VALUE = null;
}
/**
* Constructor for concrete subclasses; uses the argument for the
* default value.
*
* @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
*/
protected SimpleAnnotationValueVisitor6(R defaultValue) {
super();
DEFAULT_VALUE = defaultValue;
}
/**
* The default action for visit methods. The implementation in
* this class just returns {@link #DEFAULT_VALUE}; subclasses will
* commonly override this method.
*
* @param o the value of the annotation
* @param p a visitor-specified parameter
* @return {@code DEFAULT_VALUE} unless overridden
*/
protected R defaultAction(Object o, P p) {
return DEFAULT_VALUE;
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param b {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
public R visitBoolean(boolean b, P p) {
return defaultAction(b, p);
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param b {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
public R visitByte(byte b, P p) {
return defaultAction(b, p);
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param c {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
public R visitChar(char c, P p) {
return defaultAction(c, p);
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param d {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
public R visitDouble(double d, P p) {
return defaultAction(d, p);
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param f {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
public R visitFloat(float f, P p) {
return defaultAction(f, p);
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param i {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
public R visitInt(int i, P p) {
return defaultAction(i, p);
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param i {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
public R visitLong(long i, P p) {
return defaultAction(i, p);
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param s {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
public R visitShort(short s, P p) {
return defaultAction(s, p);
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param s {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
public R visitString(String s, P p) {
return defaultAction(s, p);
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param t {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
public R visitType(TypeMirror t, P p) {
return defaultAction(t, p);
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param c {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
public R visitEnumConstant(VariableElement c, P p) {
return defaultAction(c, p);
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param a {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
public R visitAnnotation(AnnotationMirror a, P p) {
return defaultAction(a, p);
}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param vals {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*/
public R visitArray(List<? extends AnnotationValue> vals, P p) {
return defaultAction(vals, p);
}
}
| 8,385 | Java | .java | openjdk-mirror/jdk7u-langtools | 9 | 3 | 0 | 2012-05-07T19:45:34Z | 2012-05-08T17:47:06Z |
Launcher.java | /FileExtraction/Java_unseen/praalhans_DaViz/src/java/com/aexiz/daviz/Launcher.java | package com.aexiz.daviz;
import java.awt.EventQueue;
import javax.swing.UIManager;
import javax.swing.plaf.metal.MetalLookAndFeel;
import com.aexiz.daviz.ui.ControlFrame;
public final class Launcher {
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
UIManager.put("swing.boldMetal", Boolean.FALSE);
MetalLookAndFeel.setCurrentTheme(new DavizTheme());
UIManager.setLookAndFeel(new MetalLookAndFeel());
ControlFrame.launch();
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
}
});
}
} | 616 | Java | .java | praalhans/DaViz | 10 | 2 | 0 | 2019-12-09T10:03:20Z | 2020-03-19T17:32:03Z |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.