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

The following examples show how to use com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl. 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: SingleElementLeafProperty.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 #2
Source File: SingleElementLeafProperty.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 #3
Source File: ContextFactory.java    From openjdk-8-source with 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 #4
Source File: ContextFactory.java    From jdk8u60 with 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 #5
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 #6
Source File: ArrayReferenceNodeProperty.java    From hottub 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: SingleMapNodeProperty.java    From TencentKona-8 with 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 #8
Source File: ArrayElementProperty.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
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 #9
Source File: SingleElementLeafProperty.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 #10
Source File: TransducedAccessor.java    From openjdk-jdk8u-backup with 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 #11
Source File: DomLoader.java    From openjdk-jdk9 with 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 #12
Source File: DomLoader.java    From hottub with 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 #13
Source File: SingleReferenceNodeProperty.java    From openjdk-jdk8u 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 #14
Source File: ContextFactory.java    From openjdk-jdk8u with 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
Source File: SingleMapNodeProperty.java    From openjdk-8 with 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 #16
Source File: ContextFactory.java    From openjdk-jdk9 with 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 #17
Source File: TransducedAccessor.java    From jdk8u60 with 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 #18
Source File: SingleElementNodeProperty.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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 #19
Source File: ArrayReferenceNodeProperty.java    From openjdk-8-source 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 #20
Source File: SingleMapNodeProperty.java    From hottub with 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 #21
Source File: SingleMapNodeProperty.java    From openjdk-jdk8u-backup with 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
Source File: SingleElementNodeProperty.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
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 #23
Source File: StructureLoader.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 #24
Source File: ArrayElementLeafProperty.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
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 #25
Source File: ArrayElementLeafProperty.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
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 #26
Source File: Accessor.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Accessor<BeanT, ValueT> optimize(JAXBContextImpl context) {
    if (getter == null || setter == null)
        // if we aren't complete, OptimizedAccessor won't always work
        return this;
    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(getter, setter);
    if (acc != null)
        return acc;
    else
        return this;
}
 
Example #27
Source File: StructureLoader.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 #28
Source File: FastInfosetStreamWriterOutput.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a new set of tables for a JAXB context.
 * <p>
 * @param context the JAXB context.
 * @param initialIndexOffset the initial index offset to calculate
 *                           the maximum possible index
 *
 */
TablesPerJAXBContext(JAXBContextImpl context, int initialIndexOffset) {
    elementIndexes = new int[context.getNumberOfElementNames()];
    elementIndexPrefixes = new int[context.getNumberOfElementNames()];
    attributeIndexes = new int[context.getNumberOfAttributeNames()];
    localNameIndexes = new int[context.getNumberOfLocalNames()];

    indexOffset = 1;
    maxIndex = initialIndexOffset + elementIndexes.length + attributeIndexes.length;
}
 
Example #29
Source File: XMLStreamWriterOutput.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
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;
    }
}
 
Example #30
Source File: FastInfosetStreamWriterOutput.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a new set of tables for a JAXB context.
 * <p>
 * @param content the JAXB context.
 * @param initialIndexOffset the initial index offset to calculate
 *                           the maximum possible index
 *
 */
TablesPerJAXBContext(JAXBContextImpl context, int initialIndexOffset) {
    elementIndexes = new int[context.getNumberOfElementNames()];
    elementIndexPrefixes = new int[context.getNumberOfElementNames()];
    attributeIndexes = new int[context.getNumberOfAttributeNames()];
    localNameIndexes = new int[context.getNumberOfLocalNames()];

    indexOffset = 1;
    maxIndex = initialIndexOffset + elementIndexes.length + attributeIndexes.length;
}