Exemplo n.º 1
0
 public void write(Path path, ByteArrayOutputStream os) throws IOException {
   boolean first = true;
   for (Part p : path.parts) {
     if (!first) {
       path_seperator.writeTo(os);
     }
     new AsciiBuffer(p.toString(this)).writeTo(os);
     first = false;
   }
 }
Exemplo n.º 2
0
 /**
  * Converts the path back to the string representation.
  *
  * @return
  */
 public String toString(Path path) {
   StringBuffer buffer = new StringBuffer();
   boolean first = true;
   for (Part p : path.parts) {
     if (!first) {
       buffer.append(path_seperator);
     }
     buffer.append(p.toString(this));
     first = false;
   }
   return buffer.toString();
 }
Exemplo n.º 3
0
 public PathFilter parseFilter(AsciiBuffer path) {
   ArrayList<Part> parts = new ArrayList<Part>(parsePath(path).parts);
   Collections.reverse(parts);
   PartFilter last = null;
   for (Part p : parts) {
     if (p.isLiteral()) {
       last = new LitteralPathFilter(last, (LiteralPart) p);
     } else if (p == ANY_CHILD) {
       last = new AnyChildPathFilter(last);
     } else if (p == ANY_DESCENDANT) {
       last = new AnyDecendentPathFilter(last);
     }
   }
   final PartFilter filter = last;
   return new PathFilter() {
     public boolean matches(Path path) {
       return filter.matches(new LinkedList(path.parts));
     }
   };
 }