Пример #1
0
 static <T extends NamedReferenceable> T resolveUpwards(
     SchemaModelImpl sModel,
     String namespace,
     String localName,
     Class<T> type,
     ResolveSession session) {
   //
   // The sought namespace is used here!
   Collection<SchemaModelImpl> models = getMegaIncludedModels(sModel, namespace, session);
   for (SchemaModelImpl sm : models) {
     Checked checked = session.getChecked(sm);
     if (sm != null && !checked.itself) {
       T found = sm.findByNameAndType(localName, type);
       if (found != null) {
         return found;
       }
       checked.itself = true;
     }
   }
   //
   return null;
 }
Пример #2
0
 static <T extends NamedReferenceable> T resolveRecursiveDown(
     SchemaModelImpl sModel, String localName, Class<T> type, ResolveSession session) {
   //
   T found = null;
   //
   // Find locally first
   Checked checked = session.getChecked(sModel);
   if (!checked.itself) {
     found = sModel.findByNameAndType(localName, type);
     if (found != null) {
       return found;
     }
     checked.itself = true;
   }
   //
   // Find in sub-includes and sub-redefines
   if (!checked.included) {
     checked.included = true;
     //
     Collection<SchemaModelReference> modelRefs = sModel.getNotImportRefrences();
     for (SchemaModelReference ref : modelRefs) {
       assert !(ref instanceof Import);
       //
       SchemaModelImpl resolvedRef = sModel.resolve(ref);
       if (resolvedRef != null) {
         // Look inside of imported or redefied schema
         // Recursion is used here.
         found = resolveRecursiveDown(resolvedRef, localName, type, session);
         if (found != null) {
           return found;
         }
       }
     }
   }
   //
   return null;
 }