Subversion Repositories general

Compare Revisions

Ignore whitespace Rev 1006 → Rev 1007

/zpath/trunk/src/ak/zpath/PathCreator.java
302,6 → 302,15
pos = stateConditionSecond(tokens, pos);
break;
 
case Token.TOKEN_CLOSE_BRACKET:
pos = stateConditionEnd(tokens, pos);
break;
 
case Token.TOKEN_AND:
pos++; // go to next token for stateLogicalCondition
pos = stateLogicalCondition(tokens, pos);
break;
 
default:
throw new PathCreateException("Compare operation expected", token);
}
/zpath/trunk/src/ak/zpath/DocumentTree.java
309,7 → 309,7
Element e = (Element)subnode;
 
if(testElement(element, params, e)) {
if(element.getIndex() >= 0)
if(element.getIndex() > 0)
idxElements.add(0, e); // if index specified then collect all desired nodes to list
else
return doStep(path, ++pos, params, e, update); // otherwise go to the node immed.
317,9 → 317,9
}
 
// if index specified, test the collected desired items
if(element.getIndex() >= 0) {
if(element.getIndex() < idxElements.size()) // go to the node
return doStep(path, ++pos, params, (Element)idxElements.get(element.getIndex()), update);
if(element.getIndex() > 0) {
if(element.getIndex() <= idxElements.size()) // go to the node
return doStep(path, ++pos, params, (Element)idxElements.get(element.getIndex()-1), update);
}
}
 
330,8 → 330,8
 
Element newElement = null;
 
if(element.getIndex() >= 0) {
for(int i = idxElements.size(); i <= element.getIndex(); i++) {
if(element.getIndex() > 0) {
for(int i = idxElements.size()+1; i <= element.getIndex(); i++) {
newElement = createNewElement(element, params, node); // we need the last one only
}
}
385,6 → 385,10
 
// get second value
switch(condition.getSecondOperandType()) {
case PathElement.OPERAND_NONE:
value = null;
break;
 
case PathElement.OPERAND_VARIABLE:
value = (String)params.get(condition.getSecondOperandValue());
break;
400,6 → 404,10
 
// set
switch(condition.getOperation()) {
case PathElement.OPERATION_EXIST:
subnode.setNodeValue("");
break;
 
case PathElement.OPERATION_EQUAL:
subnode.setNodeValue(value);
break;
439,7 → 447,11
break;
 
case PathElement.OPERAND_ATTRIBUTE:
firstValue = node.getAttribute(condition.getFirstOperandValue());
Attr attr = node.getAttributeNode(condition.getFirstOperandValue());
if(attr == null)
firstValue = null;
else
firstValue = node.getAttribute(condition.getFirstOperandValue());
break;
 
default:
449,6 → 461,10
 
// get second value
switch(condition.getSecondOperandType()) {
case PathElement.OPERAND_NONE:
secondValue = null;
break;
 
case PathElement.OPERAND_VARIABLE:
secondValue = (String)params.get(condition.getSecondOperandValue());
break;
464,8 → 480,13
 
// compare
switch(condition.getOperation()) {
case PathElement.OPERATION_EXIST:
if(firstValue == null) return false;
break;
 
case PathElement.OPERATION_EQUAL:
if(!firstValue.equals(secondValue)) return false;
if(firstValue == null || secondValue == null || !firstValue.equals(secondValue))
return false;
break;
 
default:
566,10 → 587,10
 
// text indices
tree.updateDocument(
"/Vertrag/i# := '0'",
"/Vertrag/i# := '1'",
null);
tree.updateDocument(
"/Vertrag/i[1]# := '1'",
"/Vertrag/i[2]@id := '2'",
null);
tree.updateDocument(
"/Vertrag/i[7]# := '7'",
578,6 → 599,15
"/Vertrag/i[4]# := '4'",
null);
 
// test existence of attributes
tree.updateDocument(
"/Vertrag/i[@id]# := '2_2'",
null);
 
tree.updateDocument(
"/Vertrag/i[@id2]# := '2_2'",
null);
 
// test search -------------------------------------------------------------
 
tree.searchElement("/Vertrag/Sparten", (Object[])null);
/zpath/trunk/src/ak/zpath/PathCondition.java
2,11 → 2,11
 
public class PathCondition
{
private int firstOperandType;
private int firstOperandType = PathElement.OPERAND_NONE;
private String firstOperandValue;
private int secondOperandType;
private int secondOperandType = PathElement.OPERAND_NONE;
private String secondOperandValue;
private int operationType;
private int operationType = PathElement.OPERATION_EXIST;
 
public int getFirstOperandType()
{
/zpath/trunk/src/ak/zpath/PathElement.java
13,10 → 13,11
public static final int OPERATION_ASSIGN = 5;
public static final int OPERATION_EQUAL = 6;
public static final int OPERATION_APPEND = 7;
public static final int OPERATION_EXIST = 8;
 
private String name;
private boolean isNew = false;
private int index = -1;
private int index = 0;
private List conditions = new ArrayList();
private PathCondition condition;
private int firstOperandType = OPERAND_NONE;