com.sun.xml.internal.bind.v2.runtime.reflect.Accessor Java Examples

The following examples show how to use com.sun.xml.internal.bind.v2.runtime.reflect.Accessor. 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: Scope.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Starts the packing scope, without adding any item.
 *
 * This allows us to return an empty pack, thereby allowing the user
 * to distinguish empty array vs null array.
 */
public void start( Accessor<BeanT,PropT> acc, Lister<BeanT,PropT,ItemT,PackT> lister) throws SAXException{
    try {
        if(!hasStarted()) {
            this.bean = (BeanT)context.getCurrentState().getTarget();
            this.acc = acc;
            this.lister = lister;
            this.pack = lister.startPacking(bean,acc);
        }
    } catch (AccessorException e) {
        Loader.handleGenericException(e,true);
        // recover from this error by ignoring future items.
        this.lister = Lister.getErrorInstance();
        this.acc = Accessor.getErrorInstance();
    }
}
 
Example #2
Source File: ArrayElementProperty.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public Accessor getElementPropertyAccessor(String nsUri, String localName) {
    if(wrapperTagName!=null) {
        if(wrapperTagName.equals(nsUri,localName))
            return acc;
    } else {
        for (TagAndType tt : typeMap.values()) {
            if(tt.tagName.equals(nsUri,localName))
                // when we can't distinguish null and empty list, JAX-WS doesn't want to see
                // null (just like any user apps), but since we are providing a raw accessor,
                // which just grabs the value from the field, we wrap it so that it won't return
                // null.
                return new NullSafeAccessor<BeanT,ListT,Object>(acc,lister);
        }
    }
    return null;
}
 
Example #3
Source File: Scope.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Adds a new item to this packing scope.
 */
public void add( Accessor<BeanT,PropT> acc, Lister<BeanT,PropT,ItemT,PackT> lister, ItemT value) throws SAXException{
    try {
        if(!hasStarted()) {
            this.bean = (BeanT)context.getCurrentState().getTarget();
            this.acc = acc;
            this.lister = lister;
            this.pack = lister.startPacking(bean,acc);
        }

        lister.addToPack(pack,value);
    } catch (AccessorException e) {
        Loader.handleGenericException(e,true);
        // recover from this error by ignoring future items.
        this.lister = Lister.getErrorInstance();
        this.acc = Accessor.getErrorInstance();
    }
}
 
Example #4
Source File: Scope.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Starts the packing scope, without adding any item.
 *
 * This allows us to return an empty pack, thereby allowing the user
 * to distinguish empty array vs null array.
 */
public void start( Accessor<BeanT,PropT> acc, Lister<BeanT,PropT,ItemT,PackT> lister) throws SAXException{
    try {
        if(!hasStarted()) {
            this.bean = (BeanT)context.getCurrentState().getTarget();
            this.acc = acc;
            this.lister = lister;
            this.pack = lister.startPacking(bean,acc);
        }
    } catch (AccessorException e) {
        Loader.handleGenericException(e,true);
        // recover from this error by ignoring future items.
        this.lister = Lister.getErrorInstance();
        this.acc = Accessor.getErrorInstance();
    }
}
 
Example #5
Source File: Scope.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Starts the packing scope, without adding any item.
 *
 * This allows us to return an empty pack, thereby allowing the user
 * to distinguish empty array vs null array.
 */
public void start( Accessor<BeanT,PropT> acc, Lister<BeanT,PropT,ItemT,PackT> lister) throws SAXException{
    try {
        if(!hasStarted()) {
            this.bean = (BeanT)context.getCurrentState().target;
            this.acc = acc;
            this.lister = lister;
            this.pack = lister.startPacking(bean,acc);
        }
    } catch (AccessorException e) {
        Loader.handleGenericException(e,true);
        // recover from this error by ignoring future items.
        this.lister = Lister.getErrorInstance();
        this.acc = Accessor.getErrorInstance();
    }
}
 
Example #6
Source File: Scope.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Adds a new item to this packing scope.
 */
public void add( Accessor<BeanT,PropT> acc, Lister<BeanT,PropT,ItemT,PackT> lister, ItemT value) throws SAXException{
    try {
        if(!hasStarted()) {
            this.bean = (BeanT)context.getCurrentState().getTarget();
            this.acc = acc;
            this.lister = lister;
            this.pack = lister.startPacking(bean,acc);
        }

        lister.addToPack(pack,value);
    } catch (AccessorException e) {
        Loader.handleGenericException(e,true);
        // recover from this error by ignoring future items.
        this.lister = Lister.getErrorInstance();
        this.acc = Accessor.getErrorInstance();
    }
}
 
Example #7
Source File: Scope.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Adds a new item to this packing scope.
 */
public void add( Accessor<BeanT,PropT> acc, Lister<BeanT,PropT,ItemT,PackT> lister, ItemT value) throws SAXException{
    try {
        if(!hasStarted()) {
            this.bean = (BeanT)context.getCurrentState().getTarget();
            this.acc = acc;
            this.lister = lister;
            this.pack = lister.startPacking(bean,acc);
        }

        lister.addToPack(pack,value);
    } catch (AccessorException e) {
        Loader.handleGenericException(e,true);
        // recover from this error by ignoring future items.
        this.lister = Lister.getErrorInstance();
        this.acc = Accessor.getErrorInstance();
    }
}
 
Example #8
Source File: ArrayElementProperty.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public Accessor getElementPropertyAccessor(String nsUri, String localName) {
    if(wrapperTagName!=null) {
        if(wrapperTagName.equals(nsUri,localName))
            return acc;
    } else {
        for (TagAndType tt : typeMap.values()) {
            if(tt.tagName.equals(nsUri,localName))
                // when we can't distinguish null and empty list, JAX-WS doesn't want to see
                // null (just like any user apps), but since we are providing a raw accessor,
                // which just grabs the value from the field, we wrap it so that it won't return
                // null.
                return new NullSafeAccessor<BeanT,ListT,Object>(acc,lister);
        }
    }
    return null;
}
 
Example #9
Source File: RuntimeClassInfoImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void checkFieldXmlLocation(Field f) {
    if(reader().hasFieldAnnotation(XmlLocation.class,f))
        // TODO: check for XmlLocation signature
        // TODO: check a collision with the super class
        xmlLocationAccessor = new Accessor.FieldReflection<Object,Locator>(f);
}
 
Example #10
Source File: ArrayReferenceNodeProperty.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Accessor getElementPropertyAccessor(String nsUri, String localName) {
    // TODO: unwrap JAXBElement
    if(wrapperTagName!=null) {
        if(wrapperTagName.equals(nsUri,localName))
            return acc;
    } else {
        if(expectedElements.containsKey(nsUri,localName))
            return acc;
    }
    return null;
}
 
Example #11
Source File: RuntimeElementInfoImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public Accessor getAccessor() {
    if(adapterType==null)
        return Accessor.JAXB_ELEMENT_VALUE;
    else
        return Accessor.JAXB_ELEMENT_VALUE.adapt(
                (Class)getAdapter().defaultType,(Class)adapterType);
}
 
Example #12
Source File: RuntimeClassInfoImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public <B> Accessor<B,Map<QName,String>> getAttributeWildcard() {
    for( RuntimeClassInfoImpl c=this; c!=null; c=c.getBaseClass() ) {
        if(c.attributeWildcard!=null) {
            if(c.attributeWildcardAccessor==null)
                c.attributeWildcardAccessor = c.createAttributeWildcardAccessor();
            return (Accessor<B,Map<QName,String>>)c.attributeWildcardAccessor;
        }
    }
    return null;
}
 
Example #13
Source File: ArrayReferenceNodeProperty.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Accessor getElementPropertyAccessor(String nsUri, String localName) {
    // TODO: unwrap JAXBElement
    if(wrapperTagName!=null) {
        if(wrapperTagName.equals(nsUri,localName))
            return acc;
    } else {
        if(expectedElements.containsKey(nsUri,localName))
            return acc;
    }
    return null;
}
 
Example #14
Source File: SingleElementNodeProperty.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Accessor getElementPropertyAccessor(String nsUri, String localName) {
    for( QName n : acceptedElements) {
        if(n.getNamespaceURI().equals(nsUri) && n.getLocalPart().equals(localName))
            return acc;
    }
    return null;
}
 
Example #15
Source File: SingleElementLeafProperty.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Accessor getElementPropertyAccessor(String nsUri, String localName) {
    if (tagName.equals(nsUri, localName))
        return acc;
    else
        return null;
}
 
Example #16
Source File: SingleElementNodeProperty.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Accessor getElementPropertyAccessor(String nsUri, String localName) {
    for( QName n : acceptedElements) {
        if(n.getNamespaceURI().equals(nsUri) && n.getLocalPart().equals(localName))
            return acc;
    }
    return null;
}
 
Example #17
Source File: ListElementProperty.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Accessor getElementPropertyAccessor(String nsUri, String localName) {
    if(tagName!=null) {
        if(tagName.equals(nsUri,localName))
            return acc;
    }
    return null;
}
 
Example #18
Source File: RuntimeElementInfoImpl.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public Accessor getAccessor() {
    if(adapterType==null)
        return Accessor.JAXB_ELEMENT_VALUE;
    else
        return Accessor.JAXB_ELEMENT_VALUE.adapt(
                (Class)getAdapter().defaultType,(Class)adapterType);
}
 
Example #19
Source File: SingleTypePropertyInfoImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public SingleTypePropertyInfoImpl(ClassInfoImpl<T,C,F,M> classInfo, PropertySeed<T,C,F,M> seed) {
    super(classInfo, seed);
    if(this instanceof RuntimePropertyInfo) {
        Accessor rawAcc = ((RuntimeClassInfoImpl.RuntimePropertySeed)seed).getAccessor();
        if(getAdapter()!=null && !isCollection())
            // adapter for a single-value property is handled by accessor.
            // adapter for a collection property is handled by lister.
            rawAcc = rawAcc.adapt(((RuntimePropertyInfo)this).getAdapter());
        this.acc = rawAcc;
    } else
        this.acc = null;
}
 
Example #20
Source File: ArrayReferenceNodeProperty.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Accessor getElementPropertyAccessor(String nsUri, String localName) {
    // TODO: unwrap JAXBElement
    if(wrapperTagName!=null) {
        if(wrapperTagName.equals(nsUri,localName))
            return acc;
    } else {
        if(expectedElements.containsKey(nsUri,localName))
            return acc;
    }
    return null;
}
 
Example #21
Source File: SingleElementNodeProperty.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Accessor getElementPropertyAccessor(String nsUri, String localName) {
    for( QName n : acceptedElements) {
        if(n.getNamespaceURI().equals(nsUri) && n.getLocalPart().equals(localName))
            return acc;
    }
    return null;
}
 
Example #22
Source File: SingleElementLeafProperty.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Accessor getElementPropertyAccessor(String nsUri, String localName) {
    if (tagName.equals(nsUri, localName))
        return acc;
    else
        return null;
}
 
Example #23
Source File: RuntimeReferencePropertyInfoImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public RuntimeReferencePropertyInfoImpl(RuntimeClassInfoImpl classInfo, PropertySeed<Type,Class,Field,Method> seed) {
    super(classInfo,seed);
    Accessor rawAcc = ((RuntimeClassInfoImpl.RuntimePropertySeed)seed).getAccessor();
    if(getAdapter()!=null && !isCollection())
        // adapter for a single-value property is handled by accessor.
        // adapter for a collection property is handled by lister.
        rawAcc = rawAcc.adapt(getAdapter());
    this.acc = rawAcc;
}
 
Example #24
Source File: RuntimeClassInfoImpl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public RuntimePropertySeed createAccessorSeed(Method getter, Method setter) {
    Accessor acc;
    try {
        acc = accessorFactory.createPropertyAccessor(clazz, getter, setter);
    } catch(JAXBException e) {
        builder.reportError(new IllegalAnnotationException(
            Messages.CUSTOM_ACCESSORFACTORY_PROPERTY_ERROR.format(
            nav().getClassName(clazz), e.toString()), this ));
        acc = Accessor.getErrorInstance(); // error recovery
    }
    return new RuntimePropertySeed( super.createAccessorSeed(getter,setter),
      acc );
}
 
Example #25
Source File: ArrayReferenceNodeProperty.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Accessor getElementPropertyAccessor(String nsUri, String localName) {
    // TODO: unwrap JAXBElement
    if(wrapperTagName!=null) {
        if(wrapperTagName.equals(nsUri,localName))
            return acc;
    } else {
        if(expectedElements.containsKey(nsUri,localName))
            return acc;
    }
    return null;
}
 
Example #26
Source File: ArrayReferenceNodeProperty.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Accessor getElementPropertyAccessor(String nsUri, String localName) {
    // TODO: unwrap JAXBElement
    if(wrapperTagName!=null) {
        if(wrapperTagName.equals(nsUri,localName))
            return acc;
    } else {
        if(expectedElements.containsKey(nsUri,localName))
            return acc;
    }
    return null;
}
 
Example #27
Source File: SingleElementLeafProperty.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Accessor getElementPropertyAccessor(String nsUri, String localName) {
    if (tagName.equals(nsUri, localName))
        return acc;
    else
        return null;
}
 
Example #28
Source File: RuntimeClassInfoImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public <B> Accessor<B,Map<QName,String>> getAttributeWildcard() {
    for( RuntimeClassInfoImpl c=this; c!=null; c=c.getBaseClass() ) {
        if(c.attributeWildcard!=null) {
            if(c.attributeWildcardAccessor==null)
                c.attributeWildcardAccessor = c.createAttributeWildcardAccessor();
            return (Accessor<B,Map<QName,String>>)c.attributeWildcardAccessor;
        }
    }
    return null;
}
 
Example #29
Source File: SingleTypePropertyInfoImpl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public SingleTypePropertyInfoImpl(ClassInfoImpl<T,C,F,M> classInfo, PropertySeed<T,C,F,M> seed) {
    super(classInfo, seed);
    if(this instanceof RuntimePropertyInfo) {
        Accessor rawAcc = ((RuntimeClassInfoImpl.RuntimePropertySeed)seed).getAccessor();
        if(getAdapter()!=null && !isCollection())
            // adapter for a single-value property is handled by accessor.
            // adapter for a collection property is handled by lister.
            rawAcc = rawAcc.adapt(((RuntimePropertyInfo)this).getAdapter());
        this.acc = rawAcc;
    } else
        this.acc = null;
}
 
Example #30
Source File: RuntimeClassInfoImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public RuntimePropertySeed createAccessorSeed(Method getter, Method setter) {
    Accessor acc;
    try {
        acc = accessorFactory.createPropertyAccessor(clazz, getter, setter);
    } catch(JAXBException e) {
        builder.reportError(new IllegalAnnotationException(
            Messages.CUSTOM_ACCESSORFACTORY_PROPERTY_ERROR.format(
            nav().getClassName(clazz), e.toString()), this ));
        acc = Accessor.getErrorInstance(); // error recovery
    }
    return new RuntimePropertySeed( super.createAccessorSeed(getter,setter),
      acc );
}