Java源码示例:org.apache.ws.commons.schema.XmlSchemaAnnotated
示例1
/**
* If the object is an attribute or an anyAttribute,
* return the 'Annotated'. If it's not one of those, or it's a group,
* throw. We're not ready for groups yet.
* @param object
*/
public static XmlSchemaAnnotated getObjectAnnotated(XmlSchemaObject object, QName contextName) {
if (!(object instanceof XmlSchemaAnnotated)) {
unsupportedConstruct("NON_ANNOTATED_ATTRIBUTE",
object.getClass().getSimpleName(),
contextName, object);
}
if (!(object instanceof XmlSchemaAttribute)
&& !(object instanceof XmlSchemaAnyAttribute)) {
unsupportedConstruct("EXOTIC_ATTRIBUTE",
object.getClass().getSimpleName(), contextName,
object);
}
return (XmlSchemaAnnotated) object;
}
示例2
public static List<XmlSchemaAnnotated> getContentAttributes(XmlSchemaComplexType type,
SchemaCollection collection) {
List<XmlSchemaAnnotated> results = new ArrayList<>();
QName baseTypeName = getBaseType(type);
if (baseTypeName != null) {
XmlSchemaComplexType baseType = (XmlSchemaComplexType)collection.getTypeByQName(baseTypeName);
// recurse onto the base type ...
results.addAll(getContentAttributes(baseType, collection));
// and now process our sequence.
List<XmlSchemaAttributeOrGroupRef> extAttrs = getContentAttributes(type);
results.addAll(extAttrs);
return results;
}
// no base type, the simple case.
List<XmlSchemaAttributeOrGroupRef> attrs = type.getAttributes();
results.addAll(attrs);
return results;
}
示例3
/**
* Fill in an AttributeInfo for an attribute or anyAttribute from a sequence.
*
* @param sequenceObject
* @param currentSchema
* @param schemaCollection
* @param prefixAccumulator
* @param contextName
* @return
*/
public static AttributeInfo forLocalItem(XmlSchemaObject sequenceObject,
XmlSchema currentSchema,
SchemaCollection schemaCollection,
NamespacePrefixAccumulator prefixAccumulator, QName contextName) {
XmlSchemaAnnotated annotated = JavascriptUtils.getObjectAnnotated(sequenceObject, contextName);
AttributeInfo attributeInfo = new AttributeInfo();
XmlSchemaAnnotated realAnnotated = annotated;
if (annotated instanceof XmlSchemaAttribute) {
XmlSchemaAttribute attribute = (XmlSchemaAttribute)annotated;
attributeInfo.use = attribute.getUse();
if (attribute.getRef().getTarget() != null) {
realAnnotated = attribute.getRef().getTarget();
attributeInfo.global = true;
}
} else if (annotated instanceof XmlSchemaAnyAttribute) {
attributeInfo.any = true;
attributeInfo.xmlName = null; // unknown until runtime.
attributeInfo.javascriptName = "any";
attributeInfo.type = null; // runtime for any.
attributeInfo.use = XmlSchemaUse.OPTIONAL;
} else {
throw new UnsupportedConstruct(LOG, "UNSUPPORTED_ATTRIBUTE_ITEM", annotated, contextName);
}
factoryCommon(realAnnotated, currentSchema, schemaCollection, prefixAccumulator, attributeInfo);
attributeInfo.annotated = realAnnotated;
return attributeInfo;
}
示例4
private static void factoryCommon(XmlSchemaAnnotated annotated, XmlSchema currentSchema,
SchemaCollection schemaCollection,
NamespacePrefixAccumulator prefixAccumulator,
AttributeInfo attributeInfo) {
if (annotated instanceof XmlSchemaAttribute) {
XmlSchemaAttribute attribute = (XmlSchemaAttribute)annotated;
String attributeNamespaceURI = attribute.getQName().getNamespaceURI();
boolean attributeNoNamespace = "".equals(attributeNamespaceURI);
XmlSchema attributeSchema = null;
if (!attributeNoNamespace) {
attributeSchema = schemaCollection.getSchemaByTargetNamespace(attributeNamespaceURI);
if (attributeSchema == null) {
throw new RuntimeException("Missing schema " + attributeNamespaceURI);
}
}
boolean qualified = !attributeNoNamespace
&& XmlSchemaUtils.isAttributeQualified(attribute, true, currentSchema,
attributeSchema);
attributeInfo.xmlName = prefixAccumulator.xmlAttributeString(attribute, qualified);
// we are assuming here that we are not dealing, in close proximity,
// with elements with identical local names and different
// namespaces.
attributeInfo.javascriptName = attribute.getQName().getLocalPart();
attributeInfo.defaultValue = attribute.getDefaultValue();
attributeInfo.fixedValue = attribute.getFixedValue();
attributeInfo.use = attribute.getUse();
factorySetupType(attribute, schemaCollection, attributeInfo);
} else { // any
attributeInfo.any = true;
attributeInfo.xmlName = null; // unknown until runtime.
attributeInfo.javascriptName = "any";
attributeInfo.type = null; // runtime for any.
attributeInfo.use = XmlSchemaUse.OPTIONAL;
}
}
示例5
public static List<String> getOperationInputPartNames(OperationInfo operation) {
List<String> names = new ArrayList<>();
List<MessagePartInfo> parts = operation.getInput().getMessageParts();
if (parts == null || parts.isEmpty()) {
return names;
}
for (MessagePartInfo part : parts) {
XmlSchemaAnnotated schema = part.getXmlSchema();
if (schema instanceof XmlSchemaElement
&& ((XmlSchemaElement)schema).getSchemaType() instanceof XmlSchemaComplexType) {
XmlSchemaElement element = (XmlSchemaElement)schema;
XmlSchemaComplexType cplxType = (XmlSchemaComplexType)element.getSchemaType();
XmlSchemaSequence seq = (XmlSchemaSequence)cplxType.getParticle();
if (seq == null || seq.getItems() == null) {
return names;
}
for (int i = 0; i < seq.getItems().size(); i++) {
XmlSchemaElement elChild = (XmlSchemaElement)seq.getItems().get(i);
names.add(elChild.getName());
}
} else {
names.add(part.getConcreteName().getLocalPart());
}
}
return names;
}
示例6
/**
* The xs:annotation is parsed into {@link TaggedValue} with one entry per
* xs:documentation or xs:appinfo.
*/
private static final List<TaggedValue> annotations(final XmlSchemaAnnotated schemaType, final Xsd2UmlConfig config) {
if (schemaType == null) {
return EMPTY_TAGGED_VALUES;
}
final XmlSchemaAnnotation annotation = schemaType.getAnnotation();
if (annotation == null) {
return EMPTY_TAGGED_VALUES;
} else {
final List<TaggedValue> taggedValues = new LinkedList<TaggedValue>();
final XmlSchemaObjectCollection children = annotation.getItems();
for (int childIdx = 0; childIdx < children.getCount(); ++childIdx) {
final XmlSchemaObject child = children.getItem(childIdx);
if (child instanceof XmlSchemaDocumentation) {
final XmlSchemaDocumentation documentation = (XmlSchemaDocumentation) child;
taggedValues.add(documentation(documentation, config));
} else if (child instanceof XmlSchemaAppInfo) {
final XmlSchemaAppInfo appInfo = (XmlSchemaAppInfo) child;
taggedValues.addAll(config.getPlugin().tagsFromAppInfo(appInfo, config));
} else {
throw new AssertionError(child);
}
}
return taggedValues;
}
}
示例7
public XmlSchemaAnnotated getXmlSchema() {
return xmlSchema;
}
示例8
public void setXmlSchema(XmlSchemaAnnotated xmlSchema) {
this.xmlSchema = xmlSchema;
}
示例9
/**
* Return the object for the Attribute or the anyAttribute.
* @return
*/
public XmlSchemaAnnotated getAnnotated() {
return annotated;
}