use of commonj.sdo.Type in project metro-jax-ws by eclipse-ee4j.
the class SDOUtils method validateSupportedType.
public static boolean validateSupportedType(HelperContext hc, String javaType, QName qname) {
TypeHelper typeHelper = hc.getTypeHelper();
if (qname != null) {
Type type = typeHelper.getType(qname.getNamespaceURI(), qname.getLocalPart());
String java = ((SDOType) type).getInstanceClassName();
if (java != null) {
return java.equals(javaType);
}
return false;
} else {
if (isPrimitive(javaType)) {
return true;
}
try {
Class cls = Thread.currentThread().getContextClassLoader().loadClass(javaType);
Type type = typeHelper.getType(cls);
return type != null;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
}
use of commonj.sdo.Type in project metro-jax-ws by eclipse-ee4j.
the class SDOWrapperAccessor method initBuilders.
protected void initBuilders() {
HashMap<Object, PropertySetter> setByQName = new HashMap<>();
HashMap<Object, PropertyGetter> getByQName = new HashMap<>();
HashMap<Object, PropertySetter> setByLocalpart = new HashMap<>();
HashMap<Object, PropertyGetter> getByLocalpart = new HashMap<>();
HashSet<String> elementLocalNames = new HashSet<>();
TypeHelper helper = contextWrapper.getHelperContext().getTypeHelper();
Type type = helper.getType(contentClass);
@SuppressWarnings("unchecked") List<Property> properties = (List<Property>) type.getDeclaredProperties();
for (Property p : properties) {
QName qname = SDOUtils.getPropertyElementName(contextWrapper.getHelperContext(), p);
SDOPropertyBuilder pBuilder = new SDOPropertyBuilder(qname, p.getType().getInstanceClass());
setByQName.put(qname, pBuilder);
getByQName.put(qname, pBuilder);
setByLocalpart.put(qname.getLocalPart(), pBuilder);
getByLocalpart.put(qname.getLocalPart(), pBuilder);
if (elementLocalNames.contains(qname.getLocalPart())) {
elementLocalNameCollision = true;
} else {
elementLocalNames.add(qname.getLocalPart());
}
}
if (elementLocalNameCollision) {
propertySetters = setByQName;
propertyGetters = getByQName;
} else {
propertySetters = setByLocalpart;
propertyGetters = getByLocalpart;
}
}
use of commonj.sdo.Type in project metro-jax-ws by eclipse-ee4j.
the class Xsd2JavaSDOModel method getJavaTypeForElementName.
/**
* return the java type used for the element, only Global elements can be located.
* Containing types are not searched
*/
public String getJavaTypeForElementName(QName qname) {
XSDHelper xsdHelper = context.getXSDHelper();
Property globalProperty = xsdHelper.getGlobalProperty(qname.getNamespaceURI(), qname.getLocalPart(), true);
if (globalProperty == null) {
throw new RuntimeException("Given element with name: " + qname + "is not found.");
}
Type elementType = globalProperty.getType();
if (elementType == null) {
throw new RuntimeException("Given element with name: " + qname + "is not found.");
}
return ((SDOType) elementType).getInstanceClassName();
}
use of commonj.sdo.Type in project metro-jax-ws by eclipse-ee4j.
the class SDOBond method serializePrimitive.
private String serializePrimitive(Object obj, Class<?> contentClass) {
if (logger.isLoggable(Level.FINEST)) {
logger.log(Level.FINEST, "Primitive class to be serialized ==> {0}", contentClass);
}
HelperContext context = parent.getHelperContext();
Type type = context.getTypeHelper().getType(contentClass);
if (type != null) {
return ((SDODataHelper) context.getDataHelper()).convertToStringValue(obj, type);
}
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, "Invalid SDO primitive type: {0}", contentClass.getClass().getName());
}
throw new SDODatabindingException("Invalid SDO primitive type: " + contentClass.getClass().getName());
}
use of commonj.sdo.Type in project metro-jax-ws by eclipse-ee4j.
the class SDOContextWrapper method getTypeName.
@Override
public QName getTypeName(TypeInfo tr) {
QName res = model.getXsdTypeName(((Class<?>) tr.type).getName());
if (res != null) {
return res;
}
HelperContext hc = contextResolver.getHelperContext(isClient, serviceName, properties);
TypeHelper th = hc.getTypeHelper();
Type t = th.getType((Class<?>) tr.type);
XSDHelper helper = hc.getXSDHelper();
String localName = helper.getLocalName(t);
String namespaceURI = helper.getNamespaceURI(t);
if (namespaceURI == null) {
namespaceURI = t.getURI();
}
if (localName == null) {
localName = t.getName();
}
return new QName(namespaceURI == null ? "" : namespaceURI, localName);
}
Aggregations