Skip to content

Commit

Permalink
XPTH-80 XPathNode subtypes finals added (#61)
Browse files Browse the repository at this point in the history
Signed-off-by: Wojciech Diakowski <wojciech.diakowski@fingo.pl>
  • Loading branch information
wojciech-diakowski authored Jul 19, 2023
1 parent 70930ef commit 2b87174
Show file tree
Hide file tree
Showing 12 changed files with 93 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@
* Class for Context Item Expresions.
*/
public class CntxItemExpr extends PrimaryExpr {

/**
* Support for Visitor interface.
*
* @return Result of Visitor operation.
*/
@Override
public Object accept(XPathVisitor v) {
return v.visit(this);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,29 @@
import info.fingo.xactus.processor.internal.types.*;

/**
*The value of a numeric literal containing "." but no e or E character is an
* The value of a numeric literal containing "." but no e or E character is an
* atomic value of type xs:decimal
*
*/
public class DecimalLiteral extends NumericLiteral {
private XSDecimal _value;

private final XSDecimal value;

/**
* Constructor for DecimalLiteral
*
* @param value
* double value
* @param value double value
*/
public DecimalLiteral(BigDecimal value) {
_value = new XSDecimal(value);
this.value = new XSDecimal(value);
}

/**
* Support for Visitor interface.
*
* @return Result of Visitor operation.
*/
@Override
public Object accept(XPathVisitor v) {
return v.visit(this);
}
Expand All @@ -49,6 +50,7 @@ public Object accept(XPathVisitor v) {
* @return xs:decimal value
*/
public XSDecimal value() {
return _value;
return value;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,29 @@
import info.fingo.xactus.processor.internal.types.*;

/**
*The value of a numeric literal containing an e or E character is an atomic
* The value of a numeric literal containing an e or E character is an atomic
* value of type xs:double
*
*/
public class DoubleLiteral extends NumericLiteral {
private XSDouble _value;

private final XSDouble value;

/**
* Constructor for Doubleiteral
*
* @param value
* double value
* @param value double value
*/
public DoubleLiteral(double value) {
_value = new XSDouble(value);
this.value = new XSDouble(value);
}

/**
* Support for Visitor interface.
*
* @return Result of Visitor operation.
*/
@Override
public Object accept(XPathVisitor v) {
return v.visit(this);
}
Expand All @@ -47,7 +48,7 @@ public Object accept(XPathVisitor v) {
* @return xs:double value
*/
public XSDouble value() {
return _value;
return value;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* Class for Forward stepping support for Step operations.
*/
public class ForwardStep extends Step {

/**
* Set internal value for NONE.
*/
Expand Down Expand Up @@ -125,10 +126,8 @@ private void update_iterator() {
/**
* Constructor for ForwardStep.
*
* @param axis
* Axis number.
* @param node_test
* Node test.
* @param axis Axis number.
* @param node_test Node test.
*/
public ForwardStep(int axis, NodeTest node_test) {
super(node_test);
Expand All @@ -143,6 +142,7 @@ public ForwardStep(int axis, NodeTest node_test) {
*
* @return Result of Visitor operation.
*/
@Override
public Object accept(XPathVisitor v) {
return v.visit(this);
}
Expand All @@ -159,8 +159,7 @@ public int axis() {
/**
* Set Axis to current.
*
* @param axis
* Axis to set.
* @param axis Axis to set.
*/
public void set_axis(int axis) {
_axis = axis;
Expand All @@ -175,4 +174,5 @@ public void set_axis(int axis) {
public ForwardAxis iterator() {
return _iterator;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,24 @@
*
*/
public class IntegerLiteral extends NumericLiteral {
private XSInteger _value;

private final XSInteger value;

/**
* Constructor for IntegerLiteral
*
* @param i
* integer value
* @param i integer value
*/
public IntegerLiteral(BigInteger i) {
_value = new XSInteger(i);
value = new XSInteger(i);
}

/**
* Support for Visitor interface.
*
* @return Result of Visitor operation.
*/
@Override
public Object accept(XPathVisitor v) {
return v.visit(this);
}
Expand All @@ -50,6 +51,7 @@ public Object accept(XPathVisitor v) {
* @return xs:integer value
*/
public XSInteger value() {
return _value;
return value;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,33 +32,35 @@ public class ItemType extends XPathNode {
* Set internal value for KINDTEST.
*/
public static final int KINDTEST = 2;
private int _type;

private QName _qname;
private KindTest _ktest;
private final int _type;

private final QName _qname;
private final KindTest _ktest;

// XXX: polymorphism
/**
* Constructor for ItemType.
*
* @param type
* Type.
* @param value
* Object value.
* @param type Type.
* @param value Object value.
*/
public ItemType(int type, Object value) {
_qname = null;
_ktest = null;

_type = type;

switch (type) {
case QNAME:
_ktest = null;
_qname = (QName) value;
break;
case KINDTEST:
_ktest = (KindTest) value;
_qname = null;
break;
default:
_ktest = null;
_qname = null;
}
}

Expand All @@ -67,6 +69,7 @@ public ItemType(int type, Object value) {
*
* @return Result of Visitor operation.
*/
@Override
public Object accept(XPathVisitor v) {
return v.visit(this);
}
Expand Down Expand Up @@ -97,4 +100,5 @@ public QName qname() {
public KindTest kind_test() {
return _ktest;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,8 @@ private void update_iterator() {
/**
* Constructor for ReverseStep.
*
* @param axis
* Axis number.
* @param node_test
* Node test.
* @param axis Axis number.
* @param node_test Node test.
*/
public ReverseStep(int axis, NodeTest node_test) {
super(node_test);
Expand All @@ -98,6 +96,7 @@ public ReverseStep(int axis, NodeTest node_test) {
*
* @return Result of Visitor operation.
*/
@Override
public Object accept(XPathVisitor v) {
return v.visit(this);
}
Expand All @@ -119,4 +118,5 @@ public int axis() {
public ReverseAxis iterator() {
return _iterator;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* Support for Sequence type.
*/
public class SequenceType extends XPathNode {

/**
* Set internal value for EMPTY.
*/
Expand All @@ -40,16 +41,14 @@ public class SequenceType extends XPathNode {
*/
public static final int PLUS = 4;

private int _occ;
private ItemType _it;
private final int _occ;
private final ItemType _it;

/**
* Constructor for SequenceType.
*
* @param occ
* Occurence.
* @param it
* Item type.
* @param occ Occurence.
* @param it Item type.
*/
public SequenceType(int occ, ItemType it) {
_occ = occ;
Expand All @@ -61,6 +60,7 @@ public SequenceType(int occ, ItemType it) {
*
* @return Result of Visitor operation.
*/
@Override
public Object accept(XPathVisitor v) {
return v.visit(this);
}
Expand All @@ -85,14 +85,20 @@ public ItemType item_type() {

public boolean isLengthValid(int length) {
switch (occurrence()) {
case EMPTY: return length == 0;
case NONE: return length == 1;
case QUESTION: return length <= 1;
case STAR: return true;
case PLUS: return length >= 1;
case EMPTY:
return length == 0;
case NONE:
return length == 1;
case QUESTION:
return length <= 1;
case STAR:
return true;
case PLUS:
return length >= 1;
default:
assert false;
return false;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,18 @@
*/
public class SingleType extends XPathNode {

private QName _type;
private boolean _qmark;
private final QName type;
private final boolean qmark;

/**
* Constructor for SingleType.
*
* @param type
* QName type.
* @param qmark
* optional type? (true/false).
* @param type QName type.
* @param qmark optional type? (true/false).
*/
public SingleType(QName type, boolean qmark) {
_type = type;
_qmark = qmark;
this.type = type;
this.qmark = qmark;
}

/**
Expand All @@ -49,6 +47,7 @@ public SingleType(QName type) {
*
* @return Result of Visitor operation.
*/
@Override
public Object accept(XPathVisitor v) {
return v.visit(this);
}
Expand All @@ -59,7 +58,7 @@ public Object accept(XPathVisitor v) {
* @return optional type value.
*/
public boolean qmark() {
return _qmark;
return qmark;
}

/**
Expand All @@ -68,6 +67,7 @@ public boolean qmark() {
* @return Result of QName operation.
*/
public QName type() {
return _type;
return type;
}

}
Loading

0 comments on commit 2b87174

Please sign in to comment.