By making it immutable, it becomes possible to share subexpressions among expressions. This is very important for regular-expression-derivation based validation algorithm, as well as for smaller memory footprint. This sharing is automatically achieved by ExpressionPool.
ReferebceExp, ElementExp, and OtherExp are also placed in the pool, but these are not unified. Since they are not unified, application can derive classes from these expressions and mix them into AGM. This technique is heavily used to introduce schema language specific primitives into AGM. See various sub-packages of this package for examples.
The equals method must be implemented by the derived type. equals method will be used to unify the expressions. equals method can safely assume that its children are already unified (therefore == can be used to test the equality, rather than equals method).
To achieve unification, we overload the equals method so that
o1.equals(o2) is true if o1 and o2 are identical.
There, those two objects must return the same hash code. For this purpose,
the hash code is calculated statically and cached internally.
| Modifier and Type | Class and Description |
|---|---|
| private static class | |
| private static class | |
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| public static final Expression | anyString
special expression object that represents "any string". |
| private transient int | cachedHashCode
Hash code of this object. |
| public static final Expression | epsilon
Special expression object that represents epsilon (ε). |
| private Boolean | epsilonReducibility
cached value of epsilon reducibility. |
| private Expression | expandedExp
Cached value of the expression after ReferenceExps are removed. |
| public static final Expression | nullSet
special expression object that represents the empty set (Φ). |
| private static final long | |
| public transient Object | verifierTag
this field can be used by Verifier implementation to speed up validation. |
| Access | Constructor and Description |
|---|---|
| protected | |
| protected |
| Modifier and Type | Method and Description |
|---|---|
| protected abstract boolean | |
| protected abstract int | |
| public abstract boolean | equals(Object
the reference object with which to compare. o)Overrides java. |
| public Expression | getExpandedExp(ExpressionPool pool)
Gets the expression after removing all ReferenceExps, until child AttributeExp or ElementExp. |
| public final int | |
| protected static int | |
| protected static int | |
| public boolean | |
| public final Expression | |
| protected Object | |
| private final void | |
| public abstract Object | |
| public abstract Expression | |
| public abstract boolean | |
| public abstract void | |
| public Object | |
| public Expression | |
| public boolean | |
| public void |
| anyString | back to summary |
|---|---|
| public static final Expression anyString special expression object that represents "any string". It is close to xsd:string datatype, but they have different semantics in several things. This object is used as <anyString/> pattern of TREX and <text/> pattern of RELAX NG. | |
| cachedHashCode | back to summary |
|---|---|
| private transient int cachedHashCode Hash code of this object. To memorize every sub expression, hash code is frequently used. And computation of the hash code requires full-traversal of the expression. Therefore, hash code is computed when the object is constructed, and kept cached thereafter. This field is essentially final, but because of the serialization support, we cannot declare it as such. | |
| epsilon | back to summary |
|---|---|
| public static final Expression epsilon Special expression object that represents epsilon (ε). This expression matches to "empty". Epsilon can be thought as an empty sequence. | |
| epsilonReducibility | back to summary |
|---|---|
| private Boolean epsilonReducibility cached value of epsilon reducibility. Epsilon reducibility can only be calculated after parsing the entire expression, because of forward reference to other pattern. | |
| expandedExp | back to summary |
|---|---|
| private Expression expandedExp Cached value of the expression after ReferenceExps are removed. This value is computed on demand. | |
| nullSet | back to summary |
|---|---|
| public static final Expression nullSet special expression object that represents the empty set (Φ). This expression doesn't match to anything. NullSet can be thought as an empty choice. | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID | |
| verifierTag | back to summary |
|---|---|
| public transient Object verifierTag this field can be used by Verifier implementation to speed up validation. Due to its nature, this field is not serialized. TODO: revisit this decision of not to serialize this field. | |
| Expression | back to summary |
|---|---|
| protected Expression(int hashCode) | |
| Expression | back to summary |
|---|---|
| protected Expression() this constructor can be used for the ununified expressions. the only reason there are two parameters is to prevent unintentional use of the default constructor. | |
| calcEpsilonReducibility | back to summary |
|---|---|
| protected abstract boolean calcEpsilonReducibility() computes epsilon reducibility | |
| calcHashCode | back to summary |
|---|---|
| protected abstract int calcHashCode() Computes the hashCode again. This method and the parameter to the constructor has to be the same. This method is used when the object is being read from the stream. | |
| equals | back to summary |
|---|---|
| public abstract boolean equals(Object o) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.
| |
| getExpandedExp | back to summary |
|---|---|
| public Expression getExpandedExp(ExpressionPool pool) Gets the expression after removing all ReferenceExps, until child AttributeExp or ElementExp. | |
| hashCode | back to summary |
|---|---|
| public final int hashCode() Overrides java. Doc from java. Returns a hash code value for the object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| hashCode | back to summary |
|---|---|
| protected static int hashCode(Object o1, Object o2, int hashKey) | |
| hashCode | back to summary |
|---|---|
| protected static int hashCode(Object o, int hashKey) | |
| isEpsilonReducible | back to summary |
|---|---|
| public boolean isEpsilonReducible() returns true if this expression accepts empty sequence. If this method is called while creating Expressions, then this method may return approximated value. When this method is used while validation, this method is guaranteed to return the correct value. | |
| peelOccurence | back to summary |
|---|---|
| public final Expression peelOccurence() Peels the occurence expressions from this expression. In AGM, 'X?','X+' and 'X*' are represented by using other primitives. This method returns the 'X' part by removing occurence related expressions. | |
| readResolve | back to summary |
|---|---|
| protected Object readResolve() | |
| setHashCode | back to summary |
|---|---|
| private final void setHashCode(int hashCode) | |
| visit | back to summary |
|---|---|
| public abstract Object visit(ExpressionVisitor visitor) | |
| visit | back to summary |
|---|---|
| public abstract Expression visit(ExpressionVisitorExpression visitor) | |
| visit | back to summary |
|---|---|
| public abstract boolean visit(ExpressionVisitorBoolean visitor) | |
| visit | back to summary |
|---|---|
| public abstract void visit(ExpressionVisitorVoid visitor) | |
| visit | back to summary |
|---|---|
| public Object visit(RELAXExpressionVisitor visitor) | |
| visit | back to summary |
|---|---|
| public Expression visit(RELAXExpressionVisitorExpression visitor) | |
| visit | back to summary |
|---|---|
| public boolean visit(RELAXExpressionVisitorBoolean visitor) | |
| visit | back to summary |
|---|---|
| public void visit(RELAXExpressionVisitorVoid visitor) | |
| Modifier and Type | Field and Description |
|---|---|
| private static final long |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| protected boolean | calcEpsilonReducibility()
Implements abstract com. |
| protected final int | calcHashCode()
Implements abstract com. |
| public boolean | equals(Object
the reference object with which to compare. o)Implements abstract com. |
| protected Object | |
| public Object | |
| public Expression | |
| public boolean | |
| public void |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID | |
| AnyStringExpression | back to summary |
|---|---|
| pack-priv AnyStringExpression() | |
| calcEpsilonReducibility | back to summary |
|---|---|
| protected boolean calcEpsilonReducibility() Implements abstract com. Doc from com. computes epsilon reducibility | |
| calcHashCode | back to summary |
|---|---|
| protected final int calcHashCode() Implements abstract com. Doc from com. Computes the hashCode again. This method and the parameter to the constructor has to be the same. This method is used when the object is being read from the stream. | |
| equals | back to summary |
|---|---|
| public boolean equals(Object o) Implements abstract com. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.
| |
| readResolve | back to summary |
|---|---|
| protected Object readResolve() Overrides com. | |
| visit | back to summary |
|---|---|
| public Object visit(ExpressionVisitor visitor) Implements abstract com. | |
| visit | back to summary |
|---|---|
| public Expression visit(ExpressionVisitorExpression visitor) Implements abstract com. | |
| visit | back to summary |
|---|---|
| public boolean visit(ExpressionVisitorBoolean visitor) Implements abstract com. | |
| visit | back to summary |
|---|---|
| public void visit(ExpressionVisitorVoid visitor) Implements abstract com. | |
| Modifier and Type | Field and Description |
|---|---|
| private static final long |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| protected boolean | calcEpsilonReducibility()
Implements abstract com. |
| protected final int | calcHashCode()
Implements abstract com. |
| public boolean | equals(Object
the reference object with which to compare. o)Implements abstract com. |
| protected Object | |
| public Object | |
| public Expression | |
| public boolean | |
| public void |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID | |
| EpsilonExpression | back to summary |
|---|---|
| pack-priv EpsilonExpression() | |
| calcEpsilonReducibility | back to summary |
|---|---|
| protected boolean calcEpsilonReducibility() Implements abstract com. Doc from com. computes epsilon reducibility | |
| calcHashCode | back to summary |
|---|---|
| protected final int calcHashCode() Implements abstract com. Doc from com. Computes the hashCode again. This method and the parameter to the constructor has to be the same. This method is used when the object is being read from the stream. | |
| equals | back to summary |
|---|---|
| public boolean equals(Object o) Implements abstract com. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.
| |
| readResolve | back to summary |
|---|---|
| protected Object readResolve() Overrides com. | |
| visit | back to summary |
|---|---|
| public Object visit(ExpressionVisitor visitor) Implements abstract com. | |
| visit | back to summary |
|---|---|
| public Expression visit(ExpressionVisitorExpression visitor) Implements abstract com. | |
| visit | back to summary |
|---|---|
| public boolean visit(ExpressionVisitorBoolean visitor) Implements abstract com. | |
| visit | back to summary |
|---|---|
| public void visit(ExpressionVisitorVoid visitor) Implements abstract com. | |
| Modifier and Type | Field and Description |
|---|---|
| private static final long |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| protected boolean | calcEpsilonReducibility()
Implements abstract com. |
| protected final int | calcHashCode()
Implements abstract com. |
| public boolean | equals(Object
the reference object with which to compare. o)Implements abstract com. |
| protected Object | |
| public Object | |
| public Expression | |
| public boolean | |
| public void |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID | |
| NullSetExpression | back to summary |
|---|---|
| pack-priv NullSetExpression() | |
| calcEpsilonReducibility | back to summary |
|---|---|
| protected boolean calcEpsilonReducibility() Implements abstract com. Doc from com. computes epsilon reducibility | |
| calcHashCode | back to summary |
|---|---|
| protected final int calcHashCode() Implements abstract com. Doc from com. Computes the hashCode again. This method and the parameter to the constructor has to be the same. This method is used when the object is being read from the stream. | |
| equals | back to summary |
|---|---|
| public boolean equals(Object o) Implements abstract com. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.
| |
| readResolve | back to summary |
|---|---|
| protected Object readResolve() Overrides com. | |
| visit | back to summary |
|---|---|
| public Object visit(ExpressionVisitor visitor) Implements abstract com. | |
| visit | back to summary |
|---|---|
| public Expression visit(ExpressionVisitorExpression visitor) Implements abstract com. | |
| visit | back to summary |
|---|---|
| public boolean visit(ExpressionVisitorBoolean visitor) Implements abstract com. | |
| visit | back to summary |
|---|---|
| public void visit(ExpressionVisitorVoid visitor) Implements abstract com. | |