|
ESC/Java2 © 2003,2004,2005 David Cok and Joseph Kiniry © 2005 UCD Dublin © 2003,2004 Radboud University Nijmegen © 1999,2000 Compaq Computer Corporation © 1997,1998,1999 Digital Equipment Corporation All Rights Reserved |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavafe.filespace.Tree
javafe.filespace.HashTree
javafe.filespace.PreloadedTree
javafe.filespace.PkgTree
A PkgTree is a filtered representation of a filespace Tree
(cf PathComponent
) where some files and directories that
are clearly not part of the Java namespace have been filtered out;
the remaining nodes can be divided into two categories: (a)
(usually interior) nodes that correspond to potential Java
packages, and (b) exterior nodes that correspond to files that
reside in one of the potential Java packages and that have an
extension (e.g., .java).
A function, isPackage(Tree)
, is provided to distinguish
the two categories. A convenience function, packages(Tree)
, is provided to enumerate all the potential Java
packages in a PkgTree.
isPackage(Tree)
depends only on a node's label; this
ensures that a UnionTree
of several PkgTree's never
combines package and non-package nodes into a single node. (This
is why (b) excludes files without extensions.) Accordingly,
PkgTree's accessors and enumerators can also be used on UnionTree
s of PkgTrees.
This module is meant to do a reasonable job of identifying potential packages. It is not 100% accurate, however, erring on the side of admitting too many packages. For example, it does not attempt to disallow package names containing Java keywords.
Field Summary | |
protected java.util.Hashtable |
edges
The mapping between our outgoing edge's labels and the subTrees they point to. |
protected static int |
IGNORE
ignore the node and its children |
protected static int |
INCLUDE_NODE
include the node but not its children |
protected static int |
INCLUDE_TREE
include the node and its children |
static java.lang.String |
rootPackageName
The name to use for root packages |
protected Tree |
underlyingTree
The non-null filespace Tree we are filtering |
Fields inherited from class javafe.filespace.Tree |
data |
Constructor Summary | |
|
PkgTree(Tree underlyingTree)
Filter a non-null filespace Tree, leaving potential Java packages and files. |
protected |
PkgTree(Tree parent,
java.lang.String label,
Tree underlyingTree)
Create a non-root node. |
Method Summary | |
java.util.Enumeration |
children()
* Fetching and counting children: * * |
static java.util.Enumeration |
components(Tree P,
java.lang.String E)
Enumerate all the components of package P with extension E in sorted order (of labels). |
void |
ensureEdgesLoaded()
Ensure that the edges map is ready for use |
Tree |
getChild(java.lang.String label)
Fetch our direct child along the edge labelled label. |
static java.lang.String |
getPackageName(Tree node)
Return the human-readable name of a package. |
protected static int |
getStatus(Tree node)
Decide what to do with a node of the underlying filespace, returning one of the following codes: IGNORE, INCLUDE_NODE, or INCLUDE_TREE. |
static boolean |
isPackage(Tree node)
Is a node of a PkgTree (or a union of PkgTree's) a potential Java package? |
protected void |
loadEdges()
Load the edges map for use. |
static void |
main(java.lang.String[] args)
A simple test driver |
static java.util.Enumeration |
packages(Tree node)
Enumerate all the potential packages of a PkgTree (or a union of PkgTree's) in depth-first pre-order using lexical ordering on siblings (cf. |
void |
printDetails(java.lang.String prefix)
Extend printDetails to include our isPackage status |
Methods inherited from class javafe.filespace.Tree |
getChildrenCount, getLabel, getParent, getQualifiedChild, getQualifiedName, getRootNode, getSimpleName, isLeaf, print |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected Tree underlyingTree
protected static final int IGNORE
protected static final int INCLUDE_NODE
protected static final int INCLUDE_TREE
public static java.lang.String rootPackageName
protected java.util.Hashtable edges
Invariant: all elements of edges are Trees and all keys are Strings.
Constructor Detail |
public PkgTree(Tree underlyingTree)
protected PkgTree(Tree parent, java.lang.String label, Tree underlyingTree)
Method Detail |
protected static int getStatus(Tree node)
protected void loadEdges()
loadEdges
in class PreloadedTree
public static boolean isPackage(Tree node)
public static java.lang.String getPackageName(Tree node)
Note: the resulting name will only make sense if node is a package.
public static java.util.Enumeration packages(Tree node)
public static java.util.Enumeration components(Tree P, java.lang.String E)
For a PkgTree (or a union of PkgTrees), if E is "", then all direct potential subpackages will be selected. Otherwise, only non-subpackages will be selected.
public void printDetails(java.lang.String prefix)
printDetails
in class Tree
public static void main(java.lang.String[] args) throws java.io.IOException
java.io.IOException
public final void ensureEdgesLoaded()
public final java.util.Enumeration children()
children
in class HashTree
public final Tree getChild(java.lang.String label)
HashTree
getChild
in class HashTree
|
ESC/Java2 © 2003,2004,2005 David Cok and Joseph Kiniry © 2005 UCD Dublin © 2003,2004 Radboud University Nijmegen © 1999,2000 Compaq Computer Corporation © 1997,1998,1999 Digital Equipment Corporation All Rights Reserved |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |