com.sun.xml.internal.bind.v2.ClassFactory Java Examples

The following examples show how to use com.sun.xml.internal.bind.v2.ClassFactory. 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-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 #2
Source File: ClassBeanInfoImpl.java    From openjdk-8-source 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 #3
Source File: SingleReferenceNodeProperty.java    From hottub 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 #4
Source File: SingleMapNodeProperty.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void startElement(UnmarshallingContext.State state, TagName ea) throws SAXException {
    // create or obtain the Map object
    try {
        target.set((BeanT)state.prev.target);
        map.set(acc.get(target.get()));
        depthCounter++;
        if(map.get() == null) {
            map.set(ClassFactory.create(mapImplClass));
        }
        map.get().clear();
        state.target = map.get();
    } catch (AccessorException e) {
        // recover from error by setting a dummy Map that receives and discards the values
        handleGenericException(e,true);
        state.target = new HashMap();
    }
}
 
Example #5
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 #6
Source File: SingleReferenceNodeProperty.java    From openjdk-8-source 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 #7
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 #8
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 #9
Source File: SingleMapNodeProperty.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void startElement(UnmarshallingContext.State state, TagName ea) throws SAXException {
    // create or obtain the Map object
    try {
        target.set((BeanT)state.getPrev().getTarget());
        map.set(acc.get(target.get()));
        depthCounter++;
        if(map.get() == null) {
            map.set(ClassFactory.create(mapImplClass));
        }
        map.get().clear();
        state.setTarget(map.get());
    } catch (AccessorException e) {
        // recover from error by setting a dummy Map that receives and discards the values
        handleGenericException(e,true);
        state.setTarget(new HashMap());
    }
}
 
Example #10
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 #11
Source File: ClassBeanInfoImpl.java    From TencentKona-8 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 #12
Source File: ClassBeanInfoImpl.java    From jdk8u60 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 #13
Source File: SingleMapNodeProperty.java    From openjdk-8-source 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 #14
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 #15
Source File: TypeUseImpl.java    From jdk8u60 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 #16
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 #17
Source File: SingleMapNodeProperty.java    From openjdk-jdk8u 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 #18
Source File: SingleMapNodeProperty.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void startElement(UnmarshallingContext.State state, TagName ea) throws SAXException {
    // create or obtain the Map object
    try {
        target.set((BeanT)state.getPrev().getTarget());
        map.set(acc.get(target.get()));
        depthCounter++;
        if(map.get() == null) {
            map.set(ClassFactory.create(mapImplClass));
        }
        map.get().clear();
        state.setTarget(map.get());
    } catch (AccessorException e) {
        // recover from error by setting a dummy Map that receives and discards the values
        handleGenericException(e,true);
        state.setTarget(new HashMap());
    }
}
 
Example #19
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 #20
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 #21
Source File: SingleMapNodeProperty.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void startElement(UnmarshallingContext.State state, TagName ea) throws SAXException {
    // create or obtain the Map object
    try {
        BeanT target = (BeanT) state.getPrev().getTarget();
        ValueT mapValue = acc.get(target);
        if(mapValue == null)
            mapValue = ClassFactory.create(mapImplClass);
        else
            mapValue.clear();

        Stack.push(this.target, target);
        Stack.push(map, mapValue);
        state.setTarget(mapValue);
    } catch (AccessorException e) {
        // recover from error by setting a dummy Map that receives and discards the values
        handleGenericException(e,true);
        state.setTarget(new HashMap());
    }
}
 
Example #22
Source File: ClassBeanInfoImpl.java    From openjdk-jdk8u 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 #23
Source File: SingleMapNodeProperty.java    From openjdk-jdk9 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 #24
Source File: TypeUseImpl.java    From openjdk-jdk9 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 #25
Source File: TypeUseImpl.java    From openjdk-jdk8u-backup 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 #26
Source File: ClassBeanInfoImpl.java    From openjdk-jdk8u-backup 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 #27
Source File: TypeUseImpl.java    From hottub 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 #28
Source File: SingleMapNodeProperty.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void startElement(UnmarshallingContext.State state, TagName ea) throws SAXException {
    // create or obtain the Map object
    try {
        target.set((BeanT)state.getPrev().getTarget());
        map.set(acc.get(target.get()));
        depthCounter++;
        if(map.get() == null) {
            map.set(ClassFactory.create(mapImplClass));
        }
        map.get().clear();
        state.setTarget(map.get());
    } catch (AccessorException e) {
        // recover from error by setting a dummy Map that receives and discards the values
        handleGenericException(e,true);
        state.setTarget(new HashMap());
    }
}
 
Example #29
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 #30
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;
    }
}