Ejemplo n.º 1
0
 private Entry _sibling(Entry current, N name) throws StaxNavException {
   if (current != null) {
     Entry element = current;
     while (true) {
       Entry next = element.next();
       if (next != null && next.getElement().getDepth() >= current.getElement().getDepth()) {
         if (next.getElement().getDepth() == current.getElement().getDepth()) {
           if (name == null) {
             current = next;
             return current;
           } else {
             N siblingName = naming.getName(next.getElement().getName());
             if (name.equals(siblingName)) {
               current = next;
               return current;
             } else {
               element = next;
             }
           }
         } else {
           element = next;
         }
       } else {
         break;
       }
     }
   }
   return null;
 }
Ejemplo n.º 2
0
 private Entry _current(Entry current, N name) throws StaxNavException {
   if (current != null) {
     if (name == null || name.equals(naming.getName(current.getElement().getName()))) {
       return current;
     }
   }
   return null;
 }
Ejemplo n.º 3
0
 public boolean find(N name) throws StaxNavException {
   if (name == null) {
     throw new NullPointerException("No null name accepted");
   }
   if (name.equals(naming.getName(current.getElement().getName()))) {
     return true;
   } else {
     return navigate(Axis.FOLLOWING, name);
   }
 }
Ejemplo n.º 4
0
 private Entry _next(Entry current, N name) throws StaxNavException {
   if (current != null) {
     Entry next = current.next(depth);
     if (next != null
         && (name == null || name.equals(naming.getName(next.getElement().getName())))) {
       current = next;
       return current;
     }
   }
   return null;
 }
Ejemplo n.º 5
0
 public N next(Set<N> names) throws StaxNavException {
   if (names == null) {
     throw new NullPointerException();
   }
   Entry next = current.next(depth);
   if (next != null) {
     N name = naming.getName(next.getElement().getName());
     if (names.contains(name)) {
       current = next;
       return name;
     }
   }
   return null;
 }
Ejemplo n.º 6
0
 private Entry _following(Entry current, N name) throws StaxNavException {
   if (name == null) {
     throw new UnsupportedOperationException("todo");
   }
   if (current != null) {
     Entry entry = current.next();
     while (entry != null) {
       N findName = naming.getName(entry.getElement().getName());
       if (name.equals(findName)) {
         current = entry;
         return current;
       } else {
         entry = entry.next();
       }
     }
   }
   return null;
 }
Ejemplo n.º 7
0
 private int _descendant(N name) throws StaxNavException {
   Entry element = current;
   while (true) {
     Entry next = element.next();
     if (next != null && next.getElement().getDepth() >= current.getElement().getDepth()) {
       N descendantName = naming.getName(next.getElement().getName());
       if (name.equals(descendantName)) {
         int diff = next.getElement().getDepth() - current.getElement().getDepth();
         current = next;
         return diff;
       } else {
         element = next;
       }
     } else {
       break;
     }
   }
   return -1;
 }
Ejemplo n.º 8
0
 protected <N> N getName(Naming<N> naming) {
   return naming.getName(getName());
 }