private class PreferredListGen.Graph extends Object
PKG
nodes represent package wildcards
NAMESPACE
nodes represent namespace wildcards
DEFAULT
nodes represent the default preference. Only
the root node of the graph can be of this type.
INHERIT
nodes inherit their preference values from
their parent nodes. For the case where there is no default
preferred value, the root of the graph will be of this type.
CLASS
leaf node representing a class
RESOURCE
leaf node representing a non-class resource
STALE
an entry which has been marked for deletion
Modifier and Type | Field and Description |
---|---|
(package private) static int |
CLASS
type value for a class node
|
(package private) static int |
DEFAULT
type value for the default preference (root) node
|
(package private) Boolean |
impliedPref
the preferred value implied for child nodes
|
(package private) static int |
INHERIT
type value when non-leaf node inherits preference from its parent
|
(package private) String |
name
the name of this node (e.g. com or sun, not com.sun)
|
(package private) static int |
NAMESPACE
type value for namespace wildcard nodes
|
(package private) HashSet |
nodes
the set of child nodes of this node
|
(package private) PreferredListGen.Graph |
parent
the parent of this node, or null for the root node
|
(package private) static int |
PKG
type value for package wildcard nodes
|
(package private) boolean |
preferred
the preferred state, only meaningful to leaf (class) nodes
|
(package private) static int |
RESOURCE
type value for a resource (non-class JAR entry) node
|
(package private) File |
sourceJar
the source JAR causing creation of this node, or null
|
(package private) static int |
STALE
type value for a stale node (marked for deletion)
|
(package private) int |
type
the type of the node
|
Constructor and Description |
---|
PreferredListGen.Graph()
Create the root node of the graph, setting implied pref to TRUE
|
PreferredListGen.Graph(PreferredListGen.Graph parent,
String name,
int type,
boolean preferred,
File sourceJar)
Create a node of the graph having the given name, parent, type and
preferred value.
|
PreferredListGen.Graph(PreferredListGen.Graph parent,
String name,
int type,
File sourceJar)
Create a node of the graph having the given name and parent.
|
Modifier and Type | Method and Description |
---|---|
(package private) void |
add(String name,
int type,
File sourceJar)
Add a child node to this node having the given name. the name
may have multiple '.' separated components, in which case a
hierarchy of child nodes will be added.
|
(package private) void |
addEntries(Collection entries)
Add preferred list entries (represented by
PrefData
objects) to the given Collection . |
(package private) void |
addLeaves(Collection leaves) |
(package private) void |
addRoots(Collection roots)
Add roots from this subtree of the graph to the given
collection of roots.
|
(package private) void |
addWithPreference(String name,
int type,
boolean preferred,
File sourceJar)
Add a child node to this node having the given name. the name may
have multiple '.' separated components, in which case a hierarchy of
child nodes will be added.
|
(package private) boolean |
childPref()
Return the implied preference of the parent node if the parent is a
package wildcard.
|
(package private) boolean |
contains(String name)
Return
true if the graph contains a node having
the given name. |
(package private) boolean |
containsLeavesOnly()
Test whether all of the immediate child nodes of this
node are leaf (class) nodes.
|
(package private) int |
countEntries(int type,
Boolean pref)
Count the number of entries which would be created
by this node for the given node type and preference.
|
(package private) int |
countImpliedFailures()
Count the number of child leaf (class) nodes which have a preferred
state which differs from the value implied by * its ancestors.
|
(package private) int |
countLeafNodes()
Count the number of child leaf nodes.
|
(package private) int |
countPreferred(boolean value)
Count the number of child leaf nodes which
have a preferred state matching the given value.
|
(package private) void |
deleteStaleNodes()
Recursively remove child nodes of type STALE.
|
(package private) PreferredListGen.Graph |
getChild(String name)
Get the child node having the given name.
|
(package private) String |
getFullName()
Return the full name of this node expressed as a relative
path.
|
(package private) PreferredListGen.Graph |
getOuter()
Return the node for the outer class for this class if this is a nested
class.
|
(package private) boolean |
impliedChildPref()
Return the implied preference as determined by the nearest
parent namespace wildcard, or the default preference if
there are no parent namespace wildcards.
|
(package private) void |
initialize(String arg,
boolean preferred,
File sourceJar)
Determines whether
arg represents a path reference to a
class, a resource, a package wildcard, or a namespace wild card, and
add the value, converted to a '.' separated name, to the graph with
the given preferred value and appropriate type. |
(package private) boolean |
isFrozen(String name)
Return the frozen state of the class node having the
given name.
|
(package private) void |
markStaleInnerClasses()
If this node is of type CLASS and is an inner class, mark this node
as STALE if the outer class has the same preferred value.
|
(package private) void |
merge(PreferredListGen.Graph g) |
(package private) void |
reset()
For non-leaf nodes,
Reset the type and implied preference value for this node
and all child nodes recursively.
|
(package private) void |
setDefaultPref(boolean value)
Set the default preferred value for the graph.
|
(package private) boolean |
setPreferred(String name,
boolean value,
boolean force)
Set the preferred state of the leaf (class) child node having the
given '.' qualified name to the given value.
|
String |
toString() |
static final int INHERIT
static final int PKG
static final int NAMESPACE
static final int DEFAULT
static final int CLASS
static final int RESOURCE
static final int STALE
String name
HashSet nodes
boolean preferred
PreferredListGen.Graph parent
int type
Boolean impliedPref
File sourceJar
PreferredListGen.Graph()
PreferredListGen.Graph(PreferredListGen.Graph parent, String name, int type, File sourceJar)
parent
- the parent of this node, or null
if
this is the root node.name
- the (possibly dot-separated) name for this node (and
child nodes).type
- the node type, must be CLASS or RESOURCEsourceJar
- source of this node definition, or null defined
through the -api or -impl optionsPreferredListGen.Graph(PreferredListGen.Graph parent, String name, int type, boolean preferred, File sourceJar)
parent
- the parent of this node, or null
if
this is the root node.name
- the (possibly dot-separated) name for this node (and
child nodes).type
- the node type, must not be INHERITpreferred
- the preferred state of this nodesourceJar
- source of this node definition, or null defined
through the -api or -impl optionsIllegalStateException
- if type is INHERITvoid initialize(String arg, boolean preferred, File sourceJar)
arg
represents a path reference to a
class, a resource, a package wildcard, or a namespace wild card, and
add the value, converted to a '.' separated name, to the graph with
the given preferred value and appropriate type. If arg
contains at least one '.' character and no '/' characters, assume it
is a class name and add the value to the graph with the given
preferred value and a type of Graph.CLASS
.arg
- the name of the component to add to the graphpreferred
- the preferred value of the componentIllegalArgumentException
- if arg
is not
a recognized form.void addRoots(Collection roots)
false
and was defined
by a command line option or was supplied by the first JAR file,
add this node to the collection.roots
- the collection to add tovoid reset()
boolean impliedChildPref()
childPref
.boolean childPref()
void setDefaultPref(boolean value)
value
- the default preferred value, which may be
null
to indicate that no default is definedvoid add(String name, int type, File sourceJar)
name
- the name of the child node to addtype
- the node type, must be CLASS or RESOURCEsourceJar
- the JAR file causing this class or resource to be addedboolean contains(String name)
true
if the graph contains a node having
the given name.name
- the name of the node to test forboolean isFrozen(String name)
-api
or -impl
options.name
- the dot-separate namevoid addWithPreference(String name, int type, boolean preferred, File sourceJar)
name
- the name of the child node to addboolean setPreferred(String name, boolean value, boolean force)
name
is null
, set the preferred value for this node.
If the target name does not exist in the graph, this method
is a noop.
This method enforces the requirement that the ultimate target node for the call must be a leaf node.
name
- the name of the child node to set, or null
to represent this nodevalue
- the preferred value to set.force
- if true, ignore frozen statevalue
or is changed to value
or if the named
node does not exist in the graph. Returns
false
if the values don't match and
the node is frozen and force is false.int countPreferred(boolean value)
value
- the preferred value to search forint countImpliedFailures()
int countLeafNodes()
String getFullName()
void markStaleInnerClasses()
System.err
if they do not have the same
value. If there is no outer class corresponding to the inner class,
this node is retained. Call this method on all children.PreferredListGen.Graph getOuter()
null
if this is
not a nested class, or if the outer class is not in the graphvoid deleteStaleNodes()
PreferredListGen.Graph getChild(String name)
name
- the child nameGraph
object, or null if the
no child named name
existsboolean containsLeavesOnly()
true
if all a the nodes are leaf nodesvoid addLeaves(Collection leaves)
void merge(PreferredListGen.Graph g)
void addEntries(Collection entries)
PrefData
objects) to the given Collection
. One of the following
cases is handled:
addEntries
is
called on each of the child nodes. Otherwise:
addEntries
on the child to generate a more
qualified entry. Otherwise:
addEntries
on all children.
int countEntries(int type, Boolean pref)
type
and impliedPref
class attributes
are side-affected by this method.type
- the node type to assignpref
- the node's implied preference valueCopyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.