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

The following examples show how to use com.sun.xml.internal.bind.v2.runtime.reflect.Accessor. 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
Source Project: openjdk-jdk8u-backup   Source File: Scope.java    License: 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 Project: openjdk-8-source   Source File: Scope.java    License: 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 3
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 4
Source Project: openjdk-jdk8u   Source File: Scope.java    License: 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 5
Source Project: hottub   Source File: Scope.java    License: 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 6
Source Project: TencentKona-8   Source File: Scope.java    License: 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 7
Source Project: jdk8u60   Source File: ArrayElementProperty.java    License: 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 8
Source Project: openjdk-jdk8u-backup   Source File: Scope.java    License: 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 9
@Override
public Accessor getElementPropertyAccessor(String nsUri, String localName) {
    if(tagName!=null) {
        if(tagName.equals(nsUri,localName))
            return acc;
    }
    return null;
}
 
Example 10
public Accessor getAccessor() {
    if(adapterType==null)
        return Accessor.JAXB_ELEMENT_VALUE;
    else
        return Accessor.JAXB_ELEMENT_VALUE.adapt(
                (Class)getAdapter().defaultType,(Class)adapterType);
}
 
Example 11
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 12
@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 13
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 14
@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 15
public Accessor getAccessor() {
    if(adapterType==null)
        return Accessor.JAXB_ELEMENT_VALUE;
    else
        return Accessor.JAXB_ELEMENT_VALUE.adapt(
                (Class)getAdapter().defaultType,(Class)adapterType);
}
 
Example 16
@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
@Override
public Accessor getElementPropertyAccessor(String nsUri, String localName) {
    if (tagName.equals(nsUri, localName))
        return acc;
    else
        return null;
}
 
Example 18
@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 19
@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 20
@Override
public Accessor getElementPropertyAccessor(String nsUri, String localName) {
    if (tagName.equals(nsUri, localName))
        return acc;
    else
        return null;
}
 
Example 21
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 22
@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 23
@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 24
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 25
Source Project: jdk8u60   Source File: RuntimeClassInfoImpl.java    License: 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 26
@Override
public Accessor getElementPropertyAccessor(String nsUri, String localName) {
    if(tagName!=null) {
        if(tagName.equals(nsUri,localName))
            return acc;
    }
    return null;
}
 
Example 27
@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 28
@Override
public Accessor getElementPropertyAccessor(String nsUri, String localName) {
    if (tagName.equals(nsUri, localName))
        return acc;
    else
        return null;
}
 
Example 29
@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 30
@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;
}