Search in sources :

Example 1 with Type

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;
        }
    }
}
Also used : TypeHelper(commonj.sdo.helper.TypeHelper) Type(commonj.sdo.Type) SDOType(org.eclipse.persistence.sdo.SDOType) SDOType(org.eclipse.persistence.sdo.SDOType) TransformerException(javax.xml.transform.TransformerException) TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException) IOException(java.io.IOException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException)

Example 2 with Type

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;
    }
}
Also used : TypeHelper(commonj.sdo.helper.TypeHelper) HashMap(java.util.HashMap) PropertySetter(com.sun.xml.ws.spi.db.PropertySetter) QName(javax.xml.namespace.QName) Type(commonj.sdo.Type) PropertyGetter(com.sun.xml.ws.spi.db.PropertyGetter) DataObject(commonj.sdo.DataObject) List(java.util.List) Property(commonj.sdo.Property) HashSet(java.util.HashSet)

Example 3 with Type

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();
}
Also used : SDOType(org.eclipse.persistence.sdo.SDOType) Type(commonj.sdo.Type) SDOType(org.eclipse.persistence.sdo.SDOType) XSDHelper(commonj.sdo.helper.XSDHelper) Property(commonj.sdo.Property)

Example 4 with Type

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());
}
Also used : Type(commonj.sdo.Type) HelperContext(commonj.sdo.helper.HelperContext) SDODataHelper(org.eclipse.persistence.sdo.helper.SDODataHelper)

Example 5 with Type

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);
}
Also used : TypeHelper(commonj.sdo.helper.TypeHelper) Type(commonj.sdo.Type) HelperContext(commonj.sdo.helper.HelperContext) SDOHelperContext(org.eclipse.persistence.sdo.helper.SDOHelperContext) QName(javax.xml.namespace.QName) XSDHelper(commonj.sdo.helper.XSDHelper)

Aggregations

Type (commonj.sdo.Type)5 TypeHelper (commonj.sdo.helper.TypeHelper)3 Property (commonj.sdo.Property)2 HelperContext (commonj.sdo.helper.HelperContext)2 XSDHelper (commonj.sdo.helper.XSDHelper)2 QName (javax.xml.namespace.QName)2 SDOType (org.eclipse.persistence.sdo.SDOType)2 PropertyGetter (com.sun.xml.ws.spi.db.PropertyGetter)1 PropertySetter (com.sun.xml.ws.spi.db.PropertySetter)1 DataObject (commonj.sdo.DataObject)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 TransformerConfigurationException (javax.xml.transform.TransformerConfigurationException)1 TransformerException (javax.xml.transform.TransformerException)1 SDODataHelper (org.eclipse.persistence.sdo.helper.SDODataHelper)1 SDOHelperContext (org.eclipse.persistence.sdo.helper.SDOHelperContext)1