public String getName() {
   StringBuilder sb = new StringBuilder();
   boolean first = true;
   for (NamePart np : def.getNameList()) {
     if (np.getType() == Type.ARRAY) {
       sb.append("[]");
     } else {
       if (first) {
         first = false;
       } else {
         sb.append(".");
       }
       sb.append(np.getName());
     }
   }
   return sb.toString();
 }
  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();
  }