示例#1
0
  protected DocumentType recomputeDocumentType(
      String name, Set<String> stack, Map<String, DocumentTypeDescriptor> dtds) {
    DocumentTypeImpl docType = documentTypes.get(name);
    if (docType != null) {
      // already done
      return docType;
    }
    if (stack.contains(name)) {
      log.error("Document type: " + name + " used in parent inheritance loop: " + stack);
      return null;
    }
    DocumentTypeDescriptor dtd = dtds.get(name);
    if (dtd == null) {
      log.error("Document type: " + name + " does not exist, used as parent by type: " + stack);
      return null;
    }

    // find and recompute the parent first
    DocumentType parent;
    String parentName = dtd.superTypeName;
    if (parentName == null) {
      parent = null;
    } else {
      parent = documentTypes.get(parentName);
      if (parent == null) {
        stack.add(name);
        parent = recomputeDocumentType(parentName, stack, dtds);
        stack.remove(name);
      }
    }

    // what it extends
    for (Type p = parent; p != null; p = p.getSuperType()) {
      Set<String> set = documentTypesExtending.get(p.getName());
      set.add(name);
    }

    return recomputeDocumentType(name, dtd, parent);
  }
示例#2
0
 protected void registerType(Type type) {
   types.put(type.getName(), type);
 }