Search in sources :

Example 1 with XSDHelper

use of commonj.sdo.helper.XSDHelper 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 2 with XSDHelper

use of commonj.sdo.helper.XSDHelper in project eclipselink by eclipse-ee4j.

the class RedefineTestCases method doTest.

private void doTest(String resource, int numberOfTypes) throws Exception {
    SDOHelperContext sdoHelperContext = new SDOHelperContext();
    XSDHelper xsdHelper = sdoHelperContext.getXSDHelper();
    InputStream xsd;
    List types;
    xsd = getSchema(resource);
    types = xsdHelper.define(xsd, null);
    assertEquals(numberOfTypes, types.size());
    xsd.close();
    xsd = getSchema(resource);
    types = xsdHelper.define(xsd, null);
    assertEquals(0, types.size());
    xsd.close();
}
Also used : SDOHelperContext(org.eclipse.persistence.sdo.helper.SDOHelperContext) InputStream(java.io.InputStream) XSDHelper(commonj.sdo.helper.XSDHelper) List(java.util.List)

Example 3 with XSDHelper

use of commonj.sdo.helper.XSDHelper in project metro-jax-ws by eclipse-ee4j.

the class SDOUtils method getPropertyElementName.

/**
 * get the element name represented by this property
 */
public static QName getPropertyElementName(HelperContext context, Property p) {
    XSDHelper helper = context.getXSDHelper();
    String localName = p.getName();
    String ns = helper.getNamespaceURI(p);
    return new QName(ns, localName);
}
Also used : QName(javax.xml.namespace.QName) SDOXSDHelper(org.eclipse.persistence.sdo.helper.SDOXSDHelper) XSDHelper(commonj.sdo.helper.XSDHelper)

Example 4 with XSDHelper

use of commonj.sdo.helper.XSDHelper 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

XSDHelper (commonj.sdo.helper.XSDHelper)4 Type (commonj.sdo.Type)2 QName (javax.xml.namespace.QName)2 SDOHelperContext (org.eclipse.persistence.sdo.helper.SDOHelperContext)2 Property (commonj.sdo.Property)1 HelperContext (commonj.sdo.helper.HelperContext)1 TypeHelper (commonj.sdo.helper.TypeHelper)1 InputStream (java.io.InputStream)1 List (java.util.List)1 SDOType (org.eclipse.persistence.sdo.SDOType)1 SDOXSDHelper (org.eclipse.persistence.sdo.helper.SDOXSDHelper)1