Java Code Examples for com.sun.xml.internal.bind.v2.ClassFactory#create()

The following examples show how to use com.sun.xml.internal.bind.v2.ClassFactory#create() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ArrayReferenceNodeProperty.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public ArrayReferenceNodeProperty(JAXBContextImpl p, RuntimeReferencePropertyInfo prop) {
    super(p, prop, prop.getXmlName(), prop.isCollectionNillable());

    for (RuntimeElement e : prop.getElements()) {
        JaxBeanInfo bi = p.getOrCreate(e);
        expectedElements.put( e.getElementName().getNamespaceURI(),e.getElementName().getLocalPart(), bi );
    }

    isMixed = prop.isMixed();

    if(prop.getWildcard()!=null) {
        domHandler = (DomHandler) ClassFactory.create(prop.getDOMHandler());
        wcMode = prop.getWildcard();
    } else {
        domHandler = null;
        wcMode = null;
    }
}
 
Example 2
Source File: ArrayReferenceNodeProperty.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public ArrayReferenceNodeProperty(JAXBContextImpl p, RuntimeReferencePropertyInfo prop) {
    super(p, prop, prop.getXmlName(), prop.isCollectionNillable());

    for (RuntimeElement e : prop.getElements()) {
        JaxBeanInfo bi = p.getOrCreate(e);
        expectedElements.put( e.getElementName().getNamespaceURI(),e.getElementName().getLocalPart(), bi );
    }

    isMixed = prop.isMixed();

    if(prop.getWildcard()!=null) {
        domHandler = (DomHandler) ClassFactory.create(prop.getDOMHandler());
        wcMode = prop.getWildcard();
    } else {
        domHandler = null;
        wcMode = null;
    }
}
 
Example 3
Source File: TypeUseImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public JExpression createConstant(Outline outline, XmlString lexical) {
    if(isCollection())  return null;

    if(adapter==null)     return coreType.createConstant(outline, lexical);

    // [RESULT] new Adapter().unmarshal(CONSTANT);
    JExpression cons = coreType.createConstant(outline, lexical);
    Class<? extends XmlAdapter> atype = adapter.getAdapterIfKnown();

    // try to run the adapter now rather than later.
    if(cons instanceof JStringLiteral && atype!=null) {
        JStringLiteral scons = (JStringLiteral) cons;
        XmlAdapter a = ClassFactory.create(atype);
        try {
            Object value = a.unmarshal(scons.str);
            if(value instanceof String) {
                return JExpr.lit((String)value);
            }
        } catch (Exception e) {
            // assume that we can't eagerly bind this
        }
    }

    return JExpr._new(adapter.getAdapterClass(outline)).invoke("unmarshal").arg(cons);
}
 
Example 4
Source File: SingleReferenceNodeProperty.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public SingleReferenceNodeProperty(JAXBContextImpl context, RuntimeReferencePropertyInfo prop) {
    super(context,prop);
    acc = prop.getAccessor().optimize(context);

    for (RuntimeElement e : prop.getElements()) {
        expectedElements.put( e.getElementName(), context.getOrCreate(e) );
    }

    if(prop.getWildcard()!=null) {
        domHandler = (DomHandler) ClassFactory.create(prop.getDOMHandler());
        wcMode = prop.getWildcard();
    } else {
        domHandler = null;
        wcMode = null;
    }
}
 
Example 5
Source File: ClassBeanInfoImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public BeanT createInstance(UnmarshallingContext context) throws IllegalAccessException, InvocationTargetException, InstantiationException, SAXException {

        BeanT bean = null;
        if (factoryMethod == null){
           bean = ClassFactory.create0(jaxbType);
        }else {
            Object o = ClassFactory.create(factoryMethod);
            if( jaxbType.isInstance(o) ){
                bean = (BeanT)o;
            } else {
                throw new InstantiationException("The factory method didn't return a correct object");
            }
        }

        if(xmlLocatorField!=null)
            // need to copy because Locator is mutable
            try {
                xmlLocatorField.set(bean,new LocatorImpl(context.getLocator()));
            } catch (AccessorException e) {
                context.handleError(e);
            }
        return bean;
    }
 
Example 6
Source File: ArrayReferenceNodeProperty.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public ArrayReferenceNodeProperty(JAXBContextImpl p, RuntimeReferencePropertyInfo prop) {
    super(p, prop, prop.getXmlName(), prop.isCollectionNillable());

    for (RuntimeElement e : prop.getElements()) {
        JaxBeanInfo bi = p.getOrCreate(e);
        expectedElements.put( e.getElementName().getNamespaceURI(),e.getElementName().getLocalPart(), bi );
    }

    isMixed = prop.isMixed();

    if(prop.getWildcard()!=null) {
        domHandler = (DomHandler) ClassFactory.create(prop.getDOMHandler());
        wcMode = prop.getWildcard();
    } else {
        domHandler = null;
        wcMode = null;
    }
}
 
Example 7
Source File: ArrayReferenceNodeProperty.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public ArrayReferenceNodeProperty(JAXBContextImpl p, RuntimeReferencePropertyInfo prop) {
    super(p, prop, prop.getXmlName(), prop.isCollectionNillable());

    for (RuntimeElement e : prop.getElements()) {
        JaxBeanInfo bi = p.getOrCreate(e);
        expectedElements.put( e.getElementName().getNamespaceURI(),e.getElementName().getLocalPart(), bi );
    }

    isMixed = prop.isMixed();

    if(prop.getWildcard()!=null) {
        domHandler = (DomHandler) ClassFactory.create(prop.getDOMHandler());
        wcMode = prop.getWildcard();
    } else {
        domHandler = null;
        wcMode = null;
    }
}
 
Example 8
Source File: SingleReferenceNodeProperty.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public SingleReferenceNodeProperty(JAXBContextImpl context, RuntimeReferencePropertyInfo prop) {
    super(context,prop);
    acc = prop.getAccessor().optimize(context);

    for (RuntimeElement e : prop.getElements()) {
        expectedElements.put( e.getElementName(), context.getOrCreate(e) );
    }

    if(prop.getWildcard()!=null) {
        domHandler = (DomHandler) ClassFactory.create(prop.getDOMHandler());
        wcMode = prop.getWildcard();
    } else {
        domHandler = null;
        wcMode = null;
    }
}
 
Example 9
Source File: AdaptedAccessor.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private XmlAdapter<OnWireValueT, InMemValueT> getAdapter() {
    Coordinator coordinator = Coordinator._getInstance();
    if(coordinator!=null)
        return coordinator.getAdapter(adapter);
    else {
        synchronized(this) {
            if(staticAdapter==null)
                staticAdapter = ClassFactory.create(adapter);
        }
        return staticAdapter;
    }
}
 
Example 10
Source File: RuntimeClassInfoImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public BeanT parse(CharSequence lexical) throws AccessorException, SAXException {
    UnmarshallingContext ctxt = UnmarshallingContext.getInstance();
    BeanT inst;
    if(ctxt!=null)
        inst = (BeanT)ctxt.createInstance(ownerClass);
    else
        // when this runs for parsing enum constants,
        // there's no UnmarshallingContext.
        inst = ClassFactory.create(ownerClass);

    xacc.parse(inst,lexical);
    return inst;
}
 
Example 11
Source File: RuntimeClassInfoImpl.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public BeanT parse(CharSequence lexical) throws AccessorException, SAXException {
    UnmarshallingContext ctxt = UnmarshallingContext.getInstance();
    BeanT inst;
    if(ctxt!=null)
        inst = (BeanT)ctxt.createInstance(ownerClass);
    else
        // when this runs for parsing enum constants,
        // there's no UnmarshallingContext.
        inst = ClassFactory.create(ownerClass);

    xacc.parse(inst,lexical);
    return inst;
}
 
Example 12
Source File: Coordinator.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets the instance of the adapter.
 *
 * @return
 *      always non-null.
 */
public final <T extends XmlAdapter> T getAdapter(Class<T> key) {
    T v = key.cast(adapters.get(key));
    if(v==null) {
        v = ClassFactory.create(key);
        putAdapter(key,v);
    }
    return v;
}
 
Example 13
Source File: RuntimeClassInfoImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public BeanT parse(CharSequence lexical) throws AccessorException, SAXException {
    UnmarshallingContext ctxt = UnmarshallingContext.getInstance();
    BeanT inst;
    if(ctxt!=null)
        inst = (BeanT)ctxt.createInstance(ownerClass);
    else
        // when this runs for parsing enum constants,
        // there's no UnmarshallingContext.
        inst = ClassFactory.create(ownerClass);

    xacc.parse(inst,lexical);
    return inst;
}
 
Example 14
Source File: UnmarshallingContext.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a new instance of the specified class.
 * In the unmarshaller, we need to check the user-specified factory class.
 */
public Object createInstance( Class<?> clazz ) throws SAXException {
    if(!factories.isEmpty()) {
        Factory factory = factories.get(clazz);
        if(factory!=null)
            return factory.createInstance();
    }
    return ClassFactory.create(clazz);
}
 
Example 15
Source File: UnmarshallingContext.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a new instance of the specified class.
 * In the unmarshaller, we need to check the user-specified factory class.
 */
public Object createInstance( Class<?> clazz ) throws SAXException {
    if(!factories.isEmpty()) {
        Factory factory = factories.get(clazz);
        if(factory!=null)
            return factory.createInstance();
    }
    return ClassFactory.create(clazz);
}
 
Example 16
Source File: Coordinator.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets the instance of the adapter.
 *
 * @return
 *      always non-null.
 */
public final <T extends XmlAdapter> T getAdapter(Class<T> key) {
    T v = key.cast(adapters.get(key));
    if(v==null) {
        v = ClassFactory.create(key);
        putAdapter(key,v);
    }
    return v;
}
 
Example 17
Source File: Lister.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public T startPacking(BeanT bean, Accessor<BeanT, T> acc) throws AccessorException {
    T collection = acc.get(bean);
    if(collection==null) {
        collection = ClassFactory.create(implClass);
        if(!acc.isAdapted())
            acc.set(bean,collection);
    }
    collection.clear();
    return collection;
}
 
Example 18
Source File: Lister.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public T startPacking(BeanT bean, Accessor<BeanT, T> acc) throws AccessorException {
    T collection = acc.get(bean);
    if(collection==null) {
        collection = ClassFactory.create(implClass);
        if(!acc.isAdapted())
            acc.set(bean,collection);
    }
    collection.clear();
    return collection;
}
 
Example 19
Source File: AdaptedAccessor.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private XmlAdapter<OnWireValueT, InMemValueT> getAdapter() {
    Coordinator coordinator = Coordinator._getInstance();
    if(coordinator!=null)
        return coordinator.getAdapter(adapter);
    else {
        synchronized(this) {
            if(staticAdapter==null)
                staticAdapter = ClassFactory.create(adapter);
        }
        return staticAdapter;
    }
}
 
Example 20
Source File: RuntimeClassInfoImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public BeanT parse(CharSequence lexical) throws AccessorException, SAXException {
    UnmarshallingContext ctxt = UnmarshallingContext.getInstance();
    BeanT inst;
    if(ctxt!=null)
        inst = (BeanT)ctxt.createInstance(ownerClass);
    else
        // when this runs for parsing enum constants,
        // there's no UnmarshallingContext.
        inst = ClassFactory.create(ownerClass);

    xacc.parse(inst,lexical);
    return inst;
}