Java Code Examples for com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl

The following examples show how to use com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl. These examples are extracted from open source projects. 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
/**
 *
 * @param classes
 * @param typeRefs
 * @param subclassReplacements
 * @param defaultNsUri
 * @param c14nSupport
 * @param ar
 * @param xmlAccessorFactorySupport
 * @param allNillable
 * @param retainPropertyInfo
 * @param improvedXsiTypeHandling
 * @return
 * @throws JAXBException
 * @deprecated use createContext( Class[] classes, Map<String,Object> properties) method instead
 */
@Deprecated
public static JAXBRIContext createContext( Class[] classes,
        Collection<TypeReference> typeRefs, Map<Class,Class> subclassReplacements,
        String defaultNsUri, boolean c14nSupport, RuntimeAnnotationReader ar,
        boolean xmlAccessorFactorySupport, boolean allNillable, boolean retainPropertyInfo, boolean improvedXsiTypeHandling) throws JAXBException {

    JAXBContextImpl.JAXBContextBuilder builder = new JAXBContextImpl.JAXBContextBuilder();
    builder.setClasses(classes);
    builder.setTypeRefs(typeRefs);
    builder.setSubclassReplacements(subclassReplacements);
    builder.setDefaultNsUri(defaultNsUri);
    builder.setC14NSupport(c14nSupport);
    builder.setAnnotationReader(ar);
    builder.setXmlAccessorFactorySupport(xmlAccessorFactorySupport);
    builder.setAllNillable(allNillable);
    builder.setRetainPropertyInfo(retainPropertyInfo);
    builder.setImprovedXsiTypeHandling(improvedXsiTypeHandling);
    return builder.build();
}
 
Example 2
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
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 4
public SingleMapNodeProperty(JAXBContextImpl context, RuntimeMapPropertyInfo prop) {
    super(context, prop);
    acc = prop.getAccessor().optimize(context);
    this.tagName = context.nameBuilder.createElementName(prop.getXmlName());
    this.entryTag = context.nameBuilder.createElementName("","entry");
    this.keyTag = context.nameBuilder.createElementName("","key");
    this.valueTag = context.nameBuilder.createElementName("","value");
    this.nillable = prop.isCollectionNillable();
    this.keyBeanInfo = context.getOrCreate(prop.getKeyType());
    this.valueBeanInfo = context.getOrCreate(prop.getValueType());

    // infer the implementation class
    //noinspection unchecked
    Class<ValueT> sig = (Class<ValueT>) Utils.REFLECTION_NAVIGATOR.erasure(prop.getRawType());
    mapImplClass = ClassFactory.inferImplClass(sig,knownImplClasses);
    // TODO: error check for mapImplClass==null
    // what is the error reporting path for this part of the code?
}
 
Example 5
protected ArrayElementProperty(JAXBContextImpl grammar, RuntimeElementPropertyInfo prop) {
    super(grammar, prop, prop.getXmlName(), prop.isCollectionNillable());
    this.prop = prop;

    List<? extends RuntimeTypeRef> types = prop.getTypes();

    Name n = null;

    for (RuntimeTypeRef typeRef : types) {
        Class type = (Class)typeRef.getTarget().getType();
        if(type.isPrimitive())
            type = RuntimeUtil.primitiveToBox.get(type);

        JaxBeanInfo beanInfo = grammar.getOrCreate(typeRef.getTarget());
        TagAndType tt = new TagAndType(
                            grammar.nameBuilder.createElementName(typeRef.getTagName()),
                            beanInfo);
        typeMap.put(type,tt);
        refs.put(typeRef,beanInfo);
        if(typeRef.isNillable() && n==null)
            n = tt.tagName;
    }

    nillableTagName = n;
}
 
Example 6
public SingleElementNodeProperty(JAXBContextImpl context, RuntimeElementPropertyInfo prop) {
    super(context,prop);
    acc = prop.getAccessor().optimize(context);
    this.prop = prop;

    QName nt = null;
    boolean nil = false;

    acceptedElements = new QName[prop.getTypes().size()];
    for( int i=0; i<acceptedElements.length; i++ )
        acceptedElements[i] = prop.getTypes().get(i).getTagName();

    for (RuntimeTypeRef e : prop.getTypes()) {
        JaxBeanInfo beanInfo = context.getOrCreate(e.getTarget());
        if(nt==null)    nt = e.getTagName();
        typeNames.put( beanInfo.jaxbType, new TagAndType(
            context.nameBuilder.createElementName(e.getTagName()),beanInfo) );
        nil |= e.isNillable();
    }

    nullTagName = context.nameBuilder.createElementName(nt);

    nillable = nil;
}
 
Example 7
Source Project: hottub   Source File: DomLoader.java    License: GNU General Public License v2.0 6 votes vote down vote up
public State( UnmarshallingContext context ) throws SAXException {
    handler = JAXBContextImpl.createTransformerHandler(context.getJAXBContext().disableSecurityProcessing);
    result = dom.createUnmarshaller(context);

    handler.setResult(result);

    // emulate the start of documents
    try {
        handler.setDocumentLocator(context.getLocator());
        handler.startDocument();
        declarePrefixes( context, context.getAllDeclaredPrefixes() );
    } catch( SAXException e ) {
        context.handleError(e);
        throw e;
    }
}
 
Example 8
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 9
public SingleMapNodeProperty(JAXBContextImpl context, RuntimeMapPropertyInfo prop) {
    super(context, prop);
    acc = prop.getAccessor().optimize(context);
    this.tagName = context.nameBuilder.createElementName(prop.getXmlName());
    this.entryTag = context.nameBuilder.createElementName("","entry");
    this.keyTag = context.nameBuilder.createElementName("","key");
    this.valueTag = context.nameBuilder.createElementName("","value");
    this.nillable = prop.isCollectionNillable();
    this.keyBeanInfo = context.getOrCreate(prop.getKeyType());
    this.valueBeanInfo = context.getOrCreate(prop.getValueType());

    // infer the implementation class
    //noinspection unchecked
    Class<ValueT> sig = (Class<ValueT>) Utils.REFLECTION_NAVIGATOR.erasure(prop.getRawType());
    mapImplClass = ClassFactory.inferImplClass(sig,knownImplClasses);
    // TODO: error check for mapImplClass==null
    // what is the error reporting path for this part of the code?
}
 
Example 10
Source Project: openjdk-jdk8u   Source File: ContextFactory.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 *
 * @param classes
 * @param typeRefs
 * @param subclassReplacements
 * @param defaultNsUri
 * @param c14nSupport
 * @param ar
 * @param xmlAccessorFactorySupport
 * @param allNillable
 * @param retainPropertyInfo
 * @param improvedXsiTypeHandling
 * @return
 * @throws JAXBException
 * @deprecated use createContext( Class[] classes, Map<String,Object> properties) method instead
 */
@Deprecated
public static JAXBRIContext createContext( Class[] classes,
        Collection<TypeReference> typeRefs, Map<Class,Class> subclassReplacements,
        String defaultNsUri, boolean c14nSupport, RuntimeAnnotationReader ar,
        boolean xmlAccessorFactorySupport, boolean allNillable, boolean retainPropertyInfo, boolean improvedXsiTypeHandling) throws JAXBException {

    JAXBContextImpl.JAXBContextBuilder builder = new JAXBContextImpl.JAXBContextBuilder();
    builder.setClasses(classes);
    builder.setTypeRefs(typeRefs);
    builder.setSubclassReplacements(subclassReplacements);
    builder.setDefaultNsUri(defaultNsUri);
    builder.setC14NSupport(c14nSupport);
    builder.setAnnotationReader(ar);
    builder.setXmlAccessorFactorySupport(xmlAccessorFactorySupport);
    builder.setAllNillable(allNillable);
    builder.setRetainPropertyInfo(retainPropertyInfo);
    builder.setImprovedXsiTypeHandling(improvedXsiTypeHandling);
    return builder.build();
}
 
Example 11
/**
 * Checks if element is nillable and represented by abstract class.
 */
private boolean isNillableAbstract(BeanT bean, JAXBContextImpl context, Object value, Class valueTypeClass) {
    if (!nillable) // check if element is nillable
        return false;
    if (valueTypeClass != Object.class) // required type wasn't recognized
        return false;
    if (bean.getClass() != JAXBElement.class) // is JAXBElement
        return false;
    JAXBElement jaxbElement = (JAXBElement) bean;
    Class valueClass = value.getClass();
    Class declaredTypeClass = jaxbElement.getDeclaredType();
    if (declaredTypeClass.equals(valueClass)) // JAXBElement<class> is different from unadapted class)
        return false;
    if (!declaredTypeClass.isAssignableFrom(valueClass)) // and is subclass from it
        return false;
    if (!Modifier.isAbstract(declaredTypeClass.getModifiers())) // declared class is abstract
        return false;
    return acc.isAbstractable(declaredTypeClass); // and is not builtin type
}
 
Example 12
public SingleMapNodeProperty(JAXBContextImpl context, RuntimeMapPropertyInfo prop) {
    super(context, prop);
    acc = prop.getAccessor().optimize(context);
    this.tagName = context.nameBuilder.createElementName(prop.getXmlName());
    this.entryTag = context.nameBuilder.createElementName("","entry");
    this.keyTag = context.nameBuilder.createElementName("","key");
    this.valueTag = context.nameBuilder.createElementName("","value");
    this.nillable = prop.isCollectionNillable();
    this.keyBeanInfo = context.getOrCreate(prop.getKeyType());
    this.valueBeanInfo = context.getOrCreate(prop.getValueType());

    // infer the implementation class
    //noinspection unchecked
    Class<ValueT> sig = (Class<ValueT>) Utils.REFLECTION_NAVIGATOR.erasure(prop.getRawType());
    mapImplClass = ClassFactory.inferImplClass(sig,knownImplClasses);
    // TODO: error check for mapImplClass==null
    // what is the error reporting path for this part of the code?
}
 
Example 13
Source Project: openjdk-jdk9   Source File: DomLoader.java    License: GNU General Public License v2.0 6 votes vote down vote up
public State( UnmarshallingContext context ) throws SAXException {
    handler = JAXBContextImpl.createTransformerHandler(context.getJAXBContext().disableSecurityProcessing);
    result = dom.createUnmarshaller(context);

    handler.setResult(result);

    // emulate the start of documents
    try {
        handler.setDocumentLocator(context.getLocator());
        handler.startDocument();
        declarePrefixes( context, context.getAllDeclaredPrefixes() );
    } catch( SAXException e ) {
        context.handleError(e);
        throw e;
    }
}
 
Example 14
Source Project: jdk8u60   Source File: ContextFactory.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 *
 * @param classes
 * @param typeRefs
 * @param subclassReplacements
 * @param defaultNsUri
 * @param c14nSupport
 * @param ar
 * @param xmlAccessorFactorySupport
 * @param allNillable
 * @param retainPropertyInfo
 * @param improvedXsiTypeHandling
 * @return
 * @throws JAXBException
 * @deprecated use createContext( Class[] classes, Map<String,Object> properties) method instead
 */
@Deprecated
public static JAXBRIContext createContext( Class[] classes,
        Collection<TypeReference> typeRefs, Map<Class,Class> subclassReplacements,
        String defaultNsUri, boolean c14nSupport, RuntimeAnnotationReader ar,
        boolean xmlAccessorFactorySupport, boolean allNillable, boolean retainPropertyInfo, boolean improvedXsiTypeHandling) throws JAXBException {

    JAXBContextImpl.JAXBContextBuilder builder = new JAXBContextImpl.JAXBContextBuilder();
    builder.setClasses(classes);
    builder.setTypeRefs(typeRefs);
    builder.setSubclassReplacements(subclassReplacements);
    builder.setDefaultNsUri(defaultNsUri);
    builder.setC14NSupport(c14nSupport);
    builder.setAnnotationReader(ar);
    builder.setXmlAccessorFactorySupport(xmlAccessorFactorySupport);
    builder.setAllNillable(allNillable);
    builder.setRetainPropertyInfo(retainPropertyInfo);
    builder.setImprovedXsiTypeHandling(improvedXsiTypeHandling);
    return builder.build();
}
 
Example 15
public SingleElementNodeProperty(JAXBContextImpl context, RuntimeElementPropertyInfo prop) {
    super(context,prop);
    acc = prop.getAccessor().optimize(context);
    this.prop = prop;

    QName nt = null;
    boolean nil = false;

    acceptedElements = new QName[prop.getTypes().size()];
    for( int i=0; i<acceptedElements.length; i++ )
        acceptedElements[i] = prop.getTypes().get(i).getTagName();

    for (RuntimeTypeRef e : prop.getTypes()) {
        JaxBeanInfo beanInfo = context.getOrCreate(e.getTarget());
        if(nt==null)    nt = e.getTagName();
        typeNames.put( beanInfo.jaxbType, new TagAndType(
            context.nameBuilder.createElementName(e.getTagName()),beanInfo) );
        nil |= e.isNillable();
    }

    nullTagName = context.nameBuilder.createElementName(nt);

    nillable = nil;
}
 
Example 16
/**
 * Checks if element is nillable and represented by abstract class.
 */
private boolean isNillableAbstract(BeanT bean, JAXBContextImpl context, Object value, Class valueTypeClass) {
    if (!nillable) // check if element is nillable
        return false;
    if (valueTypeClass != Object.class) // required type wasn't recognized
        return false;
    if (bean.getClass() != JAXBElement.class) // is JAXBElement
        return false;
    JAXBElement jaxbElement = (JAXBElement) bean;
    Class valueClass = value.getClass();
    Class declaredTypeClass = jaxbElement.getDeclaredType();
    if (declaredTypeClass.equals(valueClass)) // JAXBElement<class> is different from unadapted class)
        return false;
    if (!declaredTypeClass.isAssignableFrom(valueClass)) // and is subclass from it
        return false;
    if (!Modifier.isAbstract(declaredTypeClass.getModifiers())) // declared class is abstract
        return false;
    return acc.isAbstractable(declaredTypeClass); // and is not builtin type
}
 
Example 17
/**
 * Gets the {@link TransducedAccessor} appropriately configured for
 * the given property.
 *
 * <p>
 * This allows the implementation to use an optimized code.
 */
public static <T> TransducedAccessor<T> get(JAXBContextImpl context, RuntimeNonElementRef ref) {
    Transducer xducer = RuntimeModelBuilder.createTransducer(ref);
    RuntimePropertyInfo prop = ref.getSource();

    if(prop.isCollection()) {
        return new ListTransducedAccessorImpl(xducer,prop.getAccessor(),
                Lister.create(Utils.REFLECTION_NAVIGATOR.erasure(prop.getRawType()), prop.id(), prop.getAdapter()));
    }

    if(prop.id()==ID.IDREF)
        return new IDREFTransducedAccessorImpl(prop.getAccessor());

    if(xducer.isDefault() && context != null && !context.fastBoot) {
        TransducedAccessor xa = OptimizedTransducedAccessorFactory.get(prop);
        if(xa!=null)    return xa;
    }

    if(xducer.useNamespace())
        return new CompositeContextDependentTransducedAccessorImpl( context, xducer, prop.getAccessor() );
    else
        return new CompositeTransducedAccessorImpl( context, xducer, prop.getAccessor() );
}
 
Example 18
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 19
Source Project: jdk8u60   Source File: TransducedAccessor.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Gets the {@link TransducedAccessor} appropriately configured for
 * the given property.
 *
 * <p>
 * This allows the implementation to use an optimized code.
 */
public static <T> TransducedAccessor<T> get(JAXBContextImpl context, RuntimeNonElementRef ref) {
    Transducer xducer = RuntimeModelBuilder.createTransducer(ref);
    RuntimePropertyInfo prop = ref.getSource();

    if(prop.isCollection()) {
        return new ListTransducedAccessorImpl(xducer,prop.getAccessor(),
                Lister.create(Utils.REFLECTION_NAVIGATOR.erasure(prop.getRawType()), prop.id(), prop.getAdapter()));
    }

    if(prop.id()==ID.IDREF)
        return new IDREFTransducedAccessorImpl(prop.getAccessor());

    if(xducer.isDefault() && context != null && !context.fastBoot) {
        TransducedAccessor xa = OptimizedTransducedAccessorFactory.get(prop);
        if(xa!=null)    return xa;
    }

    if(xducer.useNamespace())
        return new CompositeContextDependentTransducedAccessorImpl( context, xducer, prop.getAccessor() );
    else
        return new CompositeTransducedAccessorImpl( context, xducer, prop.getAccessor() );
}
 
Example 20
Source Project: openjdk-jdk9   Source File: ContextFactory.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 *
 * @param classes
 * @param typeRefs
 * @param subclassReplacements
 * @param defaultNsUri
 * @param c14nSupport
 * @param ar
 * @param xmlAccessorFactorySupport
 * @param allNillable
 * @param retainPropertyInfo
 * @param improvedXsiTypeHandling
 * @return
 * @throws JAXBException
 * @deprecated use {@code createContext( Class[] classes, Map<String,Object> properties)} method instead
 */
@Deprecated
public static JAXBRIContext createContext( Class[] classes,
        Collection<TypeReference> typeRefs, Map<Class,Class> subclassReplacements,
        String defaultNsUri, boolean c14nSupport, RuntimeAnnotationReader ar,
        boolean xmlAccessorFactorySupport, boolean allNillable, boolean retainPropertyInfo, boolean improvedXsiTypeHandling) throws JAXBException {

    JAXBContextImpl.JAXBContextBuilder builder = new JAXBContextImpl.JAXBContextBuilder();
    builder.setClasses(classes);
    builder.setTypeRefs(typeRefs);
    builder.setSubclassReplacements(subclassReplacements);
    builder.setDefaultNsUri(defaultNsUri);
    builder.setC14NSupport(c14nSupport);
    builder.setAnnotationReader(ar);
    builder.setXmlAccessorFactorySupport(xmlAccessorFactorySupport);
    builder.setAllNillable(allNillable);
    builder.setRetainPropertyInfo(retainPropertyInfo);
    builder.setImprovedXsiTypeHandling(improvedXsiTypeHandling);
    return builder.build();
}
 
Example 21
Source Project: hottub   Source File: SingleMapNodeProperty.java    License: GNU General Public License v2.0 6 votes vote down vote up
public SingleMapNodeProperty(JAXBContextImpl context, RuntimeMapPropertyInfo prop) {
    super(context, prop);
    acc = prop.getAccessor().optimize(context);
    this.tagName = context.nameBuilder.createElementName(prop.getXmlName());
    this.entryTag = context.nameBuilder.createElementName("","entry");
    this.keyTag = context.nameBuilder.createElementName("","key");
    this.valueTag = context.nameBuilder.createElementName("","value");
    this.nillable = prop.isCollectionNillable();
    this.keyBeanInfo = context.getOrCreate(prop.getKeyType());
    this.valueBeanInfo = context.getOrCreate(prop.getValueType());

    // infer the implementation class
    //noinspection unchecked
    Class<ValueT> sig = (Class<ValueT>) Utils.REFLECTION_NAVIGATOR.erasure(prop.getRawType());
    mapImplClass = ClassFactory.inferImplClass(sig,knownImplClasses);
    // TODO: error check for mapImplClass==null
    // what is the error reporting path for this part of the code?
}
 
Example 22
/**
 * Checks if element is nillable and represented by abstract class.
 */
private boolean isNillableAbstract(BeanT bean, JAXBContextImpl context, Object value, Class valueTypeClass) {
    if (!nillable) // check if element is nillable
        return false;
    if (valueTypeClass != Object.class) // required type wasn't recognized
        return false;
    if (bean.getClass() != JAXBElement.class) // is JAXBElement
        return false;
    JAXBElement jaxbElement = (JAXBElement) bean;
    Class valueClass = value.getClass();
    Class declaredTypeClass = jaxbElement.getDeclaredType();
    if (declaredTypeClass.equals(valueClass)) // JAXBElement<class> is different from unadapted class)
        return false;
    if (!declaredTypeClass.isAssignableFrom(valueClass)) // and is subclass from it
        return false;
    if (!Modifier.isAbstract(declaredTypeClass.getModifiers())) // declared class is abstract
        return false;
    return acc.isAbstractable(declaredTypeClass); // and is not builtin type
}
 
Example 23
Source Project: hottub   Source File: Accessor.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public Accessor<BeanT, ValueT> optimize(JAXBContextImpl context) {
    if (context != null && context.fastBoot)
        // let's not waste time on doing this for the sake of faster boot.
        return this;
    Accessor<BeanT, ValueT> acc = OptimizedAccessorFactory.get(f);
    if (acc != null)
        return acc;
    else
        return this;
}
 
Example 24
Source Project: openjdk-8   Source File: ArrayProperty.java    License: GNU General Public License v2.0 5 votes vote down vote up
protected ArrayProperty(JAXBContextImpl context, RuntimePropertyInfo prop) {
    super(context,prop);

    assert prop.isCollection();
    lister = Lister.create(
        Utils.REFLECTION_NAVIGATOR.erasure(prop.getRawType()),prop.id(),prop.getAdapter());
    assert lister!=null;
    acc = prop.getAccessor().optimize(context);
    assert acc!=null;
}
 
Example 25
Source Project: openjdk-jdk9   Source File: Accessor.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public Accessor<BeanT, ValueT> optimize(JAXBContextImpl context) {
    if (context != null && context.fastBoot)
        // let's not waste time on doing this for the sake of faster boot.
        return this;
    Accessor<BeanT, ValueT> acc = OptimizedAccessorFactory.get(f);
    if (acc != null)
        return acc;
    else
        return this;
}
 
Example 26
public ListElementProperty(JAXBContextImpl grammar, RuntimeElementPropertyInfo prop) {
    super(grammar, prop);

    assert prop.isValueList();
    assert prop.getTypes().size()==1;   // required by the contract of isValueList
    RuntimeTypeRef ref = prop.getTypes().get(0);

    tagName = grammar.nameBuilder.createElementName(ref.getTagName());
    defaultValue = ref.getDefaultValue();

    // transducer for each item
    Transducer xducer = ref.getTransducer();
    // transduced accessor for the whole thing
    xacc = new ListTransducedAccessorImpl(xducer,acc,lister);
}
 
Example 27
public SingleElementLeafProperty(JAXBContextImpl context, RuntimeElementPropertyInfo prop) {
    super(context, prop);
    RuntimeTypeRef ref = prop.getTypes().get(0);
    tagName = context.nameBuilder.createElementName(ref.getTagName());
    assert tagName != null;
    nillable = ref.isNillable();
    defaultValue = ref.getDefaultValue();
    this.acc = prop.getAccessor().optimize(context);

    xacc = TransducedAccessor.get(context, ref);
    assert xacc != null;

    improvedXsiTypeHandling = context.improvedXsiTypeHandling;
    idRef = ref.getSource().id() == ID.IDREF;
}
 
Example 28
public ArrayElementLeafProperty(JAXBContextImpl p, RuntimeElementPropertyInfo prop) {
        super(p, prop);

        // unless those are true, use the ArrayElementNodeProperty.
        assert prop.getTypes().size()==1;
//        assert prop.getTypes().get(0).getType().isLeaf(); // this assertion is incorrect in case it's IDREF

        xducer = prop.getTypes().get(0).getTransducer();
        assert xducer!=null;
    }
 
Example 29
/**
 * Completes the initialization.
 *
 * <p>
 * To fix the cyclic reference issue, the main part of the initialization needs to be done
 * after a {@link StructureLoader} is set to {@link ClassBeanInfoImpl#loader}.
 */
public void init( JAXBContextImpl context, ClassBeanInfoImpl beanInfo, Accessor<?,Map<QName,String>> attWildcard) {
    UnmarshallerChain chain = new UnmarshallerChain(context);
    for (ClassBeanInfoImpl bi = beanInfo; bi != null; bi = bi.superClazz) {
        for (int i = bi.properties.length - 1; i >= 0; i--) {
            Property p = bi.properties[i];

            switch(p.getKind()) {
            case ATTRIBUTE:
                if(attUnmarshallers==null)
                    attUnmarshallers = new QNameMap<TransducedAccessor>();
                AttributeProperty ap = (AttributeProperty) p;
                attUnmarshallers.put(ap.attName.toQName(),ap.xacc);
                break;
            case ELEMENT:
            case REFERENCE:
            case MAP:
            case VALUE:
                p.buildChildElementUnmarshallers(chain,childUnmarshallers);
                break;
            }
        }
    }

    this.frameSize = chain.getScopeSize();

    textHandler = childUnmarshallers.get(StructureLoaderBuilder.TEXT_HANDLER);
    catchAll = childUnmarshallers.get(StructureLoaderBuilder.CATCH_ALL);

    if(attWildcard!=null) {
        attCatchAll = (Accessor<Object,Map<QName,String>>) attWildcard;
        // we use attUnmarshallers==null as a sign to skip the attribute processing
        // altogether, so if we have an att wildcard we need to have an empty qname map.
        if(attUnmarshallers==null)
            attUnmarshallers = EMPTY;
    } else {
        attCatchAll = null;
    }
}
 
Example 30
private static Constructor<? extends XmlOutput> initFastInfosetOutputClass() {
    try {
        if (FI_STAX_WRITER_CLASS == null)
            return null;
        Class c = Class.forName("com.sun.xml.internal.bind.v2.runtime.output.FastInfosetStreamWriterOutput");
        return c.getConstructor(FI_STAX_WRITER_CLASS, JAXBContextImpl.class);
    } catch (Throwable e) {
        return null;
    }
}