use of com.webcohesion.enunciate.modules.jaxb.model.SchemaInfo in project enunciate by stoicflame.
the class CXMLClientModule method usesUnmappableElements.
protected boolean usesUnmappableElements() {
boolean usesUnmappableElements = false;
if (this.jaxbModule != null && this.jaxbModule.getJaxbContext() != null && !this.jaxbModule.getJaxbContext().getSchemas().isEmpty()) {
for (SchemaInfo schemaInfo : this.jaxbModule.getJaxbContext().getSchemas().values()) {
for (TypeDefinition complexType : schemaInfo.getTypeDefinitions()) {
for (Attribute attribute : complexType.getAttributes()) {
if (attribute.isXmlList()) {
info("%s: The C client code won't serialize xml lists as an array, instead passing the list as a string that will need to be parsed. This may cause confusion to C consumers.", positionOf(attribute));
}
if (attribute.isCollectionType() && attribute.isBinaryData()) {
warn("%s: The C client code doesn't support a collection of items that are binary data. You'll have to define separate accessors for each item or disable the C module.", positionOf(attribute));
usesUnmappableElements = true;
}
}
if (complexType.getValue() != null) {
if (complexType.getValue().isXmlList()) {
info("%s: The C client code won't serialize xml lists as an array, instead passing the list as a string that will need to be parsed. This may cause confusion to C consumers.", positionOf(complexType.getValue()));
}
if (complexType.getValue().isCollectionType() && complexType.getValue().isBinaryData()) {
warn("%s: The C client code doesn't support a collection of items that are binary data.", positionOf(complexType.getValue()));
usesUnmappableElements = true;
}
}
for (Element element : complexType.getElements()) {
if (element.isXmlList()) {
info("%s: The C client code won't serialize xml lists as an array, instead passing the list as a string that will need to be parsed. This may cause confusion to C consumers.", positionOf(element));
}
if (element.getAccessorType() instanceof MapType && !element.isAdapted()) {
warn("%s: The C client doesn't have a built-in way of serializing a Map. Use @XmlJavaTypeAdapter to supply your own adapter for the Map.", positionOf(element));
usesUnmappableElements = true;
}
if (element.isCollectionType()) {
if (element.getChoices().size() > 1) {
info("%s: The C client code doesn't fully support multiple choices for a collection. It has to separate each choice into its own array. " + "This makes the C API a bit awkward to use and makes it impossible to preserve the order of the collection. If order is relevant, consider breaking out " + "the choices into their own collection or otherwise refactoring the API.", positionOf(element));
}
if (element.isBinaryData()) {
warn("%s: The C client code doesn't support a collection of items that are binary data.", positionOf(element));
usesUnmappableElements = true;
}
for (Element choice : element.getChoices()) {
if (choice.isNillable()) {
info("%s: The C client code doesn't support nillable items in a collection (the nil items will be skipped). This may cause confusion to C consumers.", positionOf(choice));
}
}
}
}
}
}
}
return usesUnmappableElements;
}
use of com.webcohesion.enunciate.modules.jaxb.model.SchemaInfo in project enunciate by stoicflame.
the class NamespacePropertiesArtifact method exportTo.
@Override
public void exportTo(File fileOrDirectory, Enunciate enunciate) throws IOException {
Properties properties = new Properties();
for (Map.Entry<String, String> ns2prefix : this.jaxbContext.getNamespacePrefixes().entrySet()) {
if (ns2prefix.getKey() != null) {
properties.put(ns2prefix.getKey(), ns2prefix.getValue());
}
}
String defaultNs = jaxbContext.getContext().getConfiguration().getDefaultNamespace();
if (defaultNs == null) {
SchemaInfo schemaWithTheMostTypes = null;
for (SchemaInfo schemaInfo : this.jaxbContext.getSchemas().values()) {
if (schemaWithTheMostTypes == null) {
schemaWithTheMostTypes = schemaInfo;
} else if (schemaWithTheMostTypes.getTypeDefinitions().size() < schemaInfo.getTypeDefinitions().size()) {
schemaWithTheMostTypes = schemaInfo;
}
}
if (schemaWithTheMostTypes != null && schemaWithTheMostTypes.getNamespace() != null && !properties.containsValue(schemaWithTheMostTypes.getNamespace())) {
defaultNs = schemaWithTheMostTypes.getNamespace();
}
}
if (defaultNs != null) {
properties.put("{default}", defaultNs);
}
FileOutputStream out = new FileOutputStream(fileOrDirectory.isDirectory() ? new File(fileOrDirectory, getName()) : fileOrDirectory);
properties.store(out, "Namespace properties, generated by Enunciate.");
out.flush();
out.close();
}
Aggregations