@Override public void initModel(EnunciateFreemarkerModel model) { super.initModel(model); if (!isDisabled()) { for (SchemaInfo schemaInfo : model.getNamespacesToSchemas().values()) { for (TypeDefinition typeDefinition : schemaInfo.getTypeDefinitions()) { String pckg = typeDefinition.getPackage().getQualifiedName(); if (!this.packageToModuleConversions.containsKey(pckg)) { this.packageToModuleConversions.put(pckg, packageToModule(pckg)); } } } } }
Set<String> referencedNamespaces = new HashSet<String>(); for (TypeDefinition typeDefinition : getTypeDefinitions()) { addReferencedNamespaces(typeDefinition, referencedNamespaces); for (RootElementDeclaration rootElement : getGlobalElements()) { referencedNamespaces.add(rootElement.getNamespace()); referencedNamespaces.add(rootElement.getTypeDefinition().getNamespace()); addReferencedNamespaces(childElement.getXmlType(), referencedNamespaces); referencedNamespaces.add(getNamespace());
/** * Add an XML registry. * * @param registry The registry to add. */ public void add(Registry registry) { add(registry.getSchema()); String namespace = registry.getSchema().getNamespace(); String prefix = addNamespace(namespace); SchemaInfo schemaInfo = namespacesToSchemas.get(namespace); if (schemaInfo == null) { schemaInfo = new SchemaInfo(); schemaInfo.setId(prefix); schemaInfo.setNamespace(namespace); namespacesToSchemas.put(namespace, schemaInfo); } schemaInfo.getRegistries().add(registry); REFERENCE_STACK.get().addFirst("registry " + registry.getQualifiedName()); addReferencedTypeDefinitions(registry); for (LocalElementDeclaration led : registry.getLocalElementDeclarations()) { REFERENCE_STACK.get().addFirst("method " + led.getSimpleName()); add(led); REFERENCE_STACK.get().removeFirst(); } REFERENCE_STACK.get().removeFirst(); }
/** * The list of imported schemas. * * @return The list of imported schemas. */ public List<SchemaInfo> getImportedSchemas() { Set<String> importedNamespaces = getReferencedNamespaces(); importedNamespaces.remove(getNamespace() == null ? "" : getNamespace()); List<SchemaInfo> schemas = new ArrayList<SchemaInfo>(); for (String ns : importedNamespaces) { SchemaInfo schema = lookupSchema(ns); if (schema != null) { schemas.add(schema); } else { SchemaInfo schemaInfo = new SchemaInfo(); schemaInfo.setNamespace(ns); schemas.add(schemaInfo); } } return schemas; }
public void add(LocalElementDeclaration led) { String namespace = led.getNamespace(); String prefix = addNamespace(namespace); SchemaInfo schemaInfo = namespacesToSchemas.get(namespace); if (schemaInfo == null) { schemaInfo = new SchemaInfo(); schemaInfo.setId(prefix); schemaInfo.setNamespace(namespace); namespacesToSchemas.put(namespace, schemaInfo); } schemaInfo.getLocalElementDeclarations().add(led); addReferencedTypeDefinitions(led); }
/** * Add a root element to the model. * * @param rootElement The root element to add. */ public void add(RootElementDeclaration rootElement) { add(rootElement.getSchema()); String namespace = rootElement.getNamespace(); String prefix = addNamespace(namespace); SchemaInfo schemaInfo = namespacesToSchemas.get(namespace); if (schemaInfo == null) { schemaInfo = new SchemaInfo(); schemaInfo.setId(prefix); schemaInfo.setNamespace(namespace); namespacesToSchemas.put(namespace, schemaInfo); } schemaInfo.getGlobalElements().add(rootElement); int position = Collections.binarySearch(this.rootElements, rootElement, CLASS_COMPARATOR); if (position < 0) { this.rootElements.add(-position - 1, rootElement); } }
schemaInfo = new SchemaInfo(); schemaInfo.setId(prefix); schemaInfo.setNamespace(namespace); namespacesToSchemas.put(namespace, schemaInfo); SchemaInfo referencedSchemaInfo = namespacesToSchemas.get(implicitElementNamespace); if (referencedSchemaInfo == null) { referencedSchemaInfo = new SchemaInfo(); referencedSchemaInfo.setId(addNamespace(implicitElementNamespace)); referencedSchemaInfo.setNamespace(implicitElementNamespace); namespacesToSchemas.put(implicitElementNamespace, referencedSchemaInfo); referencedSchemaInfo.getImplicitSchemaElements().add(implicitElement); SchemaInfo referencedSchemaInfo = namespacesToSchemas.get(implicitAttributeNamespace); if (referencedSchemaInfo == null) { referencedSchemaInfo = new SchemaInfo(); referencedSchemaInfo.setId(addNamespace(implicitAttributeNamespace)); referencedSchemaInfo.setNamespace(implicitAttributeNamespace); namespacesToSchemas.put(implicitAttributeNamespace, referencedSchemaInfo); referencedSchemaInfo.getImplicitSchemaAttributes().add(implicitAttribute); schemaInfo.getTypeDefinitions().add(typeDef);
if (SchemaInfo.class.isInstance(unwrapped)) { SchemaInfo info = (SchemaInfo) unwrapped; for (TypeDefinition typeDef : info.getTypeDefinitions()) { facets.addAll(typeDef.getFacets()); for (RootElementDeclaration element : info.getGlobalElements()) { facets.addAll(element.getFacets());
for (TypeDefinition typeDefinition : schemaInfo.getTypeDefinitions()) { exportedClasses.add(typeDefinition.getQualifiedName()); for (RootElementDeclaration rootElementDeclaration : schemaInfo.getGlobalElements()) { exportedClasses.add(rootElementDeclaration.getQualifiedName()); for (Registry registry : schemaInfo.getRegistries()) { exportedClasses.add(registry.getQualifiedName());
Set<String> referencedNamespaces = new HashSet<String>(); for (TypeDefinition typeDefinition : getTypeDefinitions()) { addReferencedNamespaces(typeDefinition, referencedNamespaces); for (RootElementDeclaration rootElement : getGlobalElements()) { referencedNamespaces.add(rootElement.getNamespace()); referencedNamespaces.add(rootElement.getTypeDefinition().getNamespace()); addReferencedNamespaces(childElement.getXmlType(), referencedNamespaces);
for (TypeDefinition typeDefinition : schemaInfo.getTypeDefinitions()) { if (FacetFilter.accept(typeDefinition)) { if (useServerSide(typeDefinition, matcher)) { for (Registry registry : schemaInfo.getRegistries()) { model.put("registry", registry); processTemplate(registryTemplate, model); for (TypeDefinition typeDefinition : schemaInfo.getTypeDefinitions()) { if (FacetFilter.accept(typeDefinition)) { model.put("type", typeDefinition);
SchemaInfo schemaInfo = namespacesToSchemas.get(namespace); if (schemaInfo == null) { schemaInfo = new SchemaInfo(); schemaInfo.setId(prefix); schemaInfo.setNamespace(namespace); namespacesToSchemas.put(namespace, schemaInfo); for (Schema pckg : schemaInfo.getPackages()) { if ((pckg.getElementFormDefault() != null) && (schema.getElementFormDefault() != pckg.getElementFormDefault())) { throw new ValidationException(schema.getPosition(), "Inconsistent elementFormDefault declarations: " + pckg.getPosition()); for (Schema pckg : schemaInfo.getPackages()) { if ((pckg.getAttributeFormDefault() != null) && (schema.getAttributeFormDefault() != pckg.getAttributeFormDefault())) { throw new ValidationException(schema.getPosition(), "Inconsistent attributeFormDefault declarations: " + pckg.getPosition()); schemaInfo.getPackages().add(schema);
SchemaInfo schemaInfo = namespacesToSchemas.get(particleNamespace); if (schemaInfo == null) { schemaInfo = new SchemaInfo(); schemaInfo.setId(addNamespace(particleNamespace)); schemaInfo.setNamespace(particleNamespace); namespacesToSchemas.put(particleNamespace, schemaInfo); schemaInfo.getImplicitSchemaElements().add(implicitElement);
for (RootElementDeclaration rootElementDeclaration : schemaInfo.getGlobalElements()) { if (rootElementDeclaration.getName().equals(name)) { return true; for (ImplicitSchemaElement implicitSchemaElement : schemaInfo.getImplicitSchemaElements()) { if (implicitSchemaElement.getElementName().equals(name)) { return true;
addReferencedNamespaces(attribute.getBaseType(), referencedNamespaces); addReferencedNamespaces(element.getBaseType(), referencedNamespaces); addReferencedNamespaces(value.getBaseType(), referencedNamespaces); addReferencedNamespaces(typeDefinition.getBaseType(), referencedNamespaces);
/** * Finds the local element declaration for the specified class declaration. * * @param declaration The declaration for which to find the local element declaration. * @return The local element declaration, or null if none found. */ public LocalElementDeclaration findLocalElementDeclaration(ClassDeclaration declaration) { if (declaration.getPackage() != null) { String packageName = declaration.getPackage().getQualifiedName(); for (SchemaInfo schemaInfo : namespacesToSchemas.values()) { for (Registry registry : schemaInfo.getRegistries()) { if (registry.getSchema().getQualifiedName().equals(packageName)) { //find the registry for the declaration. for (LocalElementDeclaration localElement : registry.getLocalElementDeclarations()) { if (localElement.getElementTypeDeclaration() != null && localElement.getElementTypeDeclaration().getQualifiedName().equals(declaration.getQualifiedName())) { return localElement; } } } } } } return null; }
schemaInfo = new SchemaInfo(); schemaInfo.setId(prefix); schemaInfo.setNamespace(namespace); namespacesToSchemas.put(namespace, schemaInfo); schemaInfo.getTypeDefinitions().add(typeDef); SchemaInfo referencedSchemaInfo = namespacesToSchemas.get(implicitElementNamespace); if (referencedSchemaInfo == null) { referencedSchemaInfo = new SchemaInfo(); referencedSchemaInfo.setId(addNamespace(implicitElementNamespace)); referencedSchemaInfo.setNamespace(implicitElementNamespace); namespacesToSchemas.put(implicitElementNamespace, referencedSchemaInfo); referencedSchemaInfo.getImplicitSchemaElements().add(implicitElement); SchemaInfo referencedSchemaInfo = namespacesToSchemas.get(implicitAttributeNamespace); if (referencedSchemaInfo == null) { referencedSchemaInfo = new SchemaInfo(); referencedSchemaInfo.setId(addNamespace(implicitAttributeNamespace)); referencedSchemaInfo.setNamespace(implicitAttributeNamespace); namespacesToSchemas.put(implicitAttributeNamespace, referencedSchemaInfo); referencedSchemaInfo.getImplicitSchemaAttributes().add(implicitAttribute);
for (TypeDefinition typeDefinition : schemaInfo.getTypeDefinitions()) { model.put("type", typeDefinition); RootElementDeclaration rootElement = model.findRootElementDeclaration(typeDefinition); for (RootElementDeclaration rootElementDeclaration : schemaInfo.getGlobalElements()) { addExplicitAnnotations(rootElementDeclaration, classnameFor); for (TypeDefinition typeDefinition : schemaInfo.getTypeDefinitions()) { model.put("type", typeDefinition); URL template = typeDefinition.isEnum() ? jdk14EnumTypeTemplate : typeDefinition.isSimple() ? simpleTypeTemplate : complexTypeTemplate; for (TypeDefinition typeDefinition : schemaInfo.getTypeDefinitions()) { model.put("type", typeDefinition); URL template = typeDefinition.isEnum() ? jdk15EnumTypeTemplate : typeDefinition.isSimple() ? simpleTypeTemplate : complexTypeTemplate;
/** * Add a root element to the model. * * @param rootElement The root element to add. */ public void add(RootElementDeclaration rootElement) { int position = Collections.binarySearch(this.rootElements, rootElement, CLASS_COMPARATOR); if (position < 0) { this.rootElements.add(-position - 1, rootElement); add(rootElement.getSchema()); String namespace = rootElement.getNamespace(); String prefix = addNamespace(namespace); SchemaInfo schemaInfo = namespacesToSchemas.get(namespace); if (schemaInfo == null) { schemaInfo = new SchemaInfo(); schemaInfo.setId(prefix); schemaInfo.setNamespace(namespace); namespacesToSchemas.put(namespace, schemaInfo); } schemaInfo.getGlobalElements().add(rootElement); if (includeReferencedClasses()) { REFERENCE_STACK.get().addFirst("root element " + rootElement.getQualifiedName()); addReferencedTypeDefinitions(rootElement); REFERENCE_STACK.get().removeFirst(); } } }
/** * The list of imported schemas. * * @return The list of imported schemas. */ public List<SchemaInfo> getImportedSchemas() { Set<String> importedNamespaces = getReferencedNamespaces(); importedNamespaces.remove(getNamespace()); List<SchemaInfo> schemas = new ArrayList<SchemaInfo>(); for (String ns : importedNamespaces) { SchemaInfo schema = lookupSchema(ns); if (schema != null) { schemas.add(schema); } else { SchemaInfo schemaInfo = new SchemaInfo(); schemaInfo.setNamespace(ns); schemas.add(schemaInfo); } } return schemas; }