use of javax.xml.bind.annotation.XmlSchema in project platformlayer by platformlayer.
the class XmlHelper method getXmlElementInfo.
public static ElementInfo getXmlElementInfo(Class<?> clazz) {
String elementName = null;
String namespace = null;
XmlType xmlType = clazz.getAnnotation(XmlType.class);
if (xmlType != null) {
elementName = xmlType.name();
namespace = xmlType.namespace();
} else {
XmlRootElement xmlRootElement = clazz.getAnnotation(XmlRootElement.class);
if (xmlRootElement != null) {
elementName = xmlRootElement.name();
namespace = xmlRootElement.namespace();
}
}
if ("##default".equals(elementName)) {
elementName = StringUtils.uncapitalize(clazz.getSimpleName());
}
if ("##default".equals(namespace)) {
namespace = null;
}
if (namespace == null) {
Package itemPackage = clazz.getPackage();
XmlSchema xmlSchema = itemPackage.getAnnotation(XmlSchema.class);
if (xmlSchema != null) {
namespace = getXmlNamespace(xmlSchema);
}
}
if (elementName != null && namespace != null) {
return new ElementInfo(namespace, elementName);
}
return null;
}
use of javax.xml.bind.annotation.XmlSchema in project midpoint by Evolveum.
the class PrismBeanInspector method determineNamespaceUncached.
private String determineNamespaceUncached(Class<? extends Object> beanClass) {
XmlType xmlType = beanClass.getAnnotation(XmlType.class);
if (xmlType == null) {
return null;
}
String namespace = xmlType.namespace();
if (BeanMarshaller.DEFAULT_PLACEHOLDER.equals(namespace)) {
XmlSchema xmlSchema = beanClass.getPackage().getAnnotation(XmlSchema.class);
namespace = xmlSchema.namespace();
}
if (StringUtils.isBlank(namespace) || BeanMarshaller.DEFAULT_PLACEHOLDER.equals(namespace)) {
return null;
}
return namespace;
}
use of javax.xml.bind.annotation.XmlSchema in project midpoint by Evolveum.
the class PrismBeanInspector method determineTypeForClassUncached.
private QName determineTypeForClassUncached(Class<? extends Object> beanClass) {
XmlType xmlType = beanClass.getAnnotation(XmlType.class);
if (xmlType == null) {
return null;
}
String namespace = xmlType.namespace();
if (BeanMarshaller.DEFAULT_PLACEHOLDER.equals(namespace)) {
XmlSchema xmlSchema = beanClass.getPackage().getAnnotation(XmlSchema.class);
namespace = xmlSchema.namespace();
}
if (StringUtils.isBlank(namespace) || BeanMarshaller.DEFAULT_PLACEHOLDER.equals(namespace)) {
return null;
}
return new QName(namespace, xmlType.name());
}
use of javax.xml.bind.annotation.XmlSchema in project zm-mailbox by Zimbra.
the class WsdlDocGenerator method getNamespace.
private static String getNamespace(Class<?> jaxbClass, Map<Package, String> pkgToNamespace) {
Package pkg = jaxbClass.getPackage();
String namespace = pkgToNamespace.get(pkg);
if (namespace == null) {
XmlSchema schemaAnnot = pkg.getAnnotation(XmlSchema.class);
if (schemaAnnot != null) {
namespace = schemaAnnot.namespace();
// XmlNs[] xmlns = schemaAnnot.xmlns(); Useful if we need prefix for namespace
pkgToNamespace.put(pkg, namespace);
}
}
return namespace;
}
use of javax.xml.bind.annotation.XmlSchema in project zm-mailbox by Zimbra.
the class JaxbInfo method getQName.
private org.dom4j.QName getQName(JaxbNodeInfo elemNode) {
String elemNs = elemNode.getNamespace();
if (DEFAULT_MARKER.equals(elemNs)) {
XmlSchema xmlSchemaAnnot = jaxbClass.getPackage().getAnnotation(XmlSchema.class);
elemNs = XmlNsForm.QUALIFIED.equals(xmlSchemaAnnot.elementFormDefault()) ? xmlSchemaAnnot.namespace() : "";
}
org.dom4j.Namespace dom4jNS = new org.dom4j.Namespace("", elemNs);
return new org.dom4j.QName(elemNode.getName(), dom4jNS);
}
Aggregations