com.sun.tools.xjc.reader.gbind

Class Element

public abstract class Element extends Expression implements ElementSet

Expression that represents an alphabet of a regular language.

Since this package is about a regular expression over element declarations, this represents an XML element declaration (hence the name.) Element needs to be interned, meaning one Element per one tag name.

Implements ElementSet to represent a self.

Field Summary
Set<Element>backEdges
Set<Element>foreEdges
Once we build a graph from Expression, we represent an edge e1 -> e2 by {@code e1.foreEdges.contains(e2)} and {@code e2.backEdges.contains(e1)}.
ElementprevPostOrder
Previous element in the DFS post-order traveral of the element graph.
Constructor Summary
protected Element()
Method Summary
voidaddNext(Element element)
ElementassignDfsPostOrder(Element prev)
Traverses the Element graph with DFS and set prevPostOrder.
voidbuildDAG(ElementSet incoming)
voidbuildStronglyConnectedComponents(List<ConnectedComponent> ccs)
Builds a set of strongly connected components and puts them all into the given set.
booleancheckCutSet(ConnectedComponent cc, Set<Element> visited)
Checks if the given ConnectedComponent forms a cut-set of a graph.
booleancontains(ElementSet rhs)
booleanhasSelfLoop()
booleanisNullable()
booleanisSink()
True if this Element is SinkNode.
booleanisSource()
True if this Element is SourceNode.
Iterator<Element>iterator()
Just to satisfy the ElementSet contract.
ElementSetlastSet()

Field Detail

backEdges

final Set<Element> backEdges

foreEdges

final Set<Element> foreEdges
Once we build a graph from Expression, we represent an edge e1 -> e2 by {@code e1.foreEdges.contains(e2)} and {@code e2.backEdges.contains(e1)}.

Element prevPostOrder
Previous element in the DFS post-order traveral of the element graph.

We use {@code prevPostOrder==null} as a check if the element is visted in DFS, so this chain terminates by a self-reference, not by having null. Set in assignDfsPostOrder

Constructor Detail

Element

protected Element()

Method Detail

addNext

public void addNext(Element element)

assignDfsPostOrder

Element assignDfsPostOrder(Element prev)
Traverses the Element graph with DFS and set prevPostOrder. Should be first invoked on the source node of the graph.

buildDAG

void buildDAG(ElementSet incoming)

buildStronglyConnectedComponents

public void buildStronglyConnectedComponents(List<ConnectedComponent> ccs)
Builds a set of strongly connected components and puts them all into the given set.

checkCutSet

final boolean checkCutSet(ConnectedComponent cc, Set<Element> visited)
Checks if the given ConnectedComponent forms a cut-set of a graph.

Parameters: visited Used to keep track of visited nodes.

Returns: true if it is indeed a cut-set. false if not.

contains

public boolean contains(ElementSet rhs)

hasSelfLoop

public boolean hasSelfLoop()

isNullable

boolean isNullable()

isSink

boolean isSink()
True if this Element is SinkNode.

isSource

boolean isSource()
True if this Element is SourceNode.

iterator

public Iterator<Element> iterator()

Deprecated: if you statically call this method, there's something wrong.

Just to satisfy the ElementSet contract.

lastSet

ElementSet lastSet()