public class ClassHierarchyImpl extends Object implements JavaClassHierarchy
| Constructor and Description |
|---|
ClassHierarchyImpl() |
ClassHierarchyImpl(URL... jars) |
ClassHierarchyImpl(URL[] jars,
Class<? extends ExternalConstructor<?>>[] parameterParsers) |
| Modifier and Type | Method and Description |
|---|---|
Class<?> |
classForName(String name)
Helper method that converts a String to a Class using this
ClassHierarchy's classloader.
|
PackageNode |
getNamespace()
Return a reference to the root of the ClassHierarchy.
|
Node |
getNode(Class<?> clazz)
Look up a class object in this ClassHierarchy.
|
Node |
getNode(String name)
Lookup a node in this class hierarchy.
|
ParameterParser |
getParameterParser() |
boolean |
isImplementation(ClassNode<?> inter,
ClassNode<?> impl)
Return whether the impl is a subclass of inter.
|
ClassHierarchy |
merge(ClassHierarchy ch)
Merge the contents of this ClassHierarchy and the provided one into a new
class hierarchy.
|
<T> T |
parse(NamedParameterNode<T> np,
String value)
Parse a string, assuming that it is of the type expected by a given NamedParameter.
|
<T> T |
parseDefaultValue(NamedParameterNode<T> name)
A helper method that returns the parsed default value of a given
NamedParameter.
|
public ClassHierarchyImpl()
public ClassHierarchyImpl(URL... jars)
public ClassHierarchyImpl(URL[] jars, Class<? extends ExternalConstructor<?>>[] parameterParsers)
public <T> T parseDefaultValue(NamedParameterNode<T> name)
parseDefaultValue in interface JavaClassHierarchyT - A typename - The named parameter that should be checked for a default instance.ClassHierarchyException - if a default value was specified, but could not be parsed, or if a set of
values were specified for a non-set parameter.public <T> T parse(NamedParameterNode<T> np, String value) throws ParseException
This method does not deal with sets; if the NamedParameter is set valued, then the provided string should correspond to a single member of the set. It is up to the caller to call parse once for each value that should be parsed as a member of the set.
parse in interface JavaClassHierarchyT - A typenp - The named parameter that will receive the value.value - A string value to be validated and parsed.ParseException - if the value failed to parse, or parsed to the
wrong type (such as when it specifies a class that does not implement
or extend T).public Class<?> classForName(String name) throws ClassNotFoundException
classForName in interface JavaClassHierarchyClassNotFoundExceptionpublic Node getNode(Class<?> clazz)
JavaClassHierarchyThe behavior of this method is undefined if the provided Class object is not from the ClassLoader (or an ancestor of the ClassLoader) associated with this JavaClassHierarchy. By default, Tang uses the default runtime ClassLoader as its root ClassLoader, so static references (expressions like getNode(Foo.class)) are safe.
getNode in interface JavaClassHierarchyclazz - The class to be looked up in the class hierarchy.public Node getNode(String name) throws NameResolutionException
ClassHierarchygetNode in interface ClassHierarchyname - The full name of the class that will be looked up.NameResolutionException - If the class is not found.public PackageNode getNamespace()
ClassHierarchyNormal callers (all use cases except ClassHierarchy serialization) should use getNode(String) to lookup classes, since getNamespace() can not support lazy loading of unknown classes.
getNamespace in interface ClassHierarchypublic ParameterParser getParameterParser()
public boolean isImplementation(ClassNode<?> inter, ClassNode<?> impl)
ClassHierarchyisImplementation in interface ClassHierarchyinter - a interface classimpl - a implementation classpublic ClassHierarchy merge(ClassHierarchy ch)
ClassHierarchyClassHierarchies derived from applications written in different languages cannot be merged.
merge in interface ClassHierarchych - a class hierarchy to be mergedCopyright © 2017 The Apache Software Foundation. All rights reserved.