コード例 #1
0
 private static void addSchemaPathToFieldDef(SchemaPath path, FieldDef.Builder builder) {
   for (PathSegment p = path.getRootSegment(); ; p = p.getChild()) {
     NamePart.Builder b = NamePart.newBuilder();
     if (p.isArray()) {
       b.setType(Type.ARRAY);
     } else {
       b.setName(p.getNameSegment().getPath().toString());
       b.setType(Type.NAME);
     }
     builder.addName(b.build());
     if (p.isLastPath()) break;
   }
 }
コード例 #2
0
  public boolean matches(SchemaPath path) {
    Iterator<NamePart> iter = def.getNameList().iterator();

    for (PathSegment p = path.getRootSegment(); ; p = p.getChild()) {
      if (p == null) break;
      if (!iter.hasNext()) return false;
      NamePart n = iter.next();

      if (p.isArray()) {
        if (n.getType() == Type.ARRAY) continue;
        return false;
      } else {
        if (p.getNameSegment().getPath().equals(n.getName())) continue;
        return false;
      }
    }
    // we've reviewed all path segments. confirm that we don't have any extra name parts.
    return !iter.hasNext();
  }