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

The following examples show how to use com.sun.xml.internal.bind.v2.runtime.reflect.Lister. 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 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 #2
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 #3
Source File: Scope.java    From openjdk-jdk9 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 #4
Source File: Scope.java    From openjdk-jdk9 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 #5
Source File: Scope.java    From hottub 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 #6
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 #7
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 #8
Source File: Scope.java    From openjdk-8-source 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().target;
            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
Source File: Scope.java    From openjdk-jdk8u 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 #10
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 #11
Source File: Scope.java    From jdk8u60 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 #12
Source File: Scope.java    From jdk8u60 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 #13
Source File: Scope.java    From openjdk-8 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().target;
            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 #14
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 #15
Source File: Scope.java    From TencentKona-8 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 #16
Source File: Scope.java    From openjdk-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().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 #17
Source File: ArrayElementProperty.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
protected void serializeListBody(BeanT beanT, XMLSerializer w, ListT list) throws IOException, XMLStreamException, SAXException, AccessorException {
        ListIterator<ItemT> itr = lister.iterator(list, w);

        boolean isIdref = itr instanceof Lister.IDREFSIterator; // UGLY

        while(itr.hasNext()) {
            try {
                ItemT item = itr.next();
                if (item != null) {
                    Class itemType = item.getClass();
                    if(isIdref)
                        // This should be the only place where we need to be aware
                        // that the iterator is iterating IDREFS.
                        itemType = ((Lister.IDREFSIterator)itr).last().getClass();

                    // normally, this returns non-null
                    TagAndType tt = typeMap.get(itemType);
                    while(tt==null && itemType!=null) {
                        // otherwise we'll just have to try the slow way
                        itemType = itemType.getSuperclass();
                        tt = typeMap.get(itemType);
                    }

                    if(tt==null) {
                        // item is not of the expected type.
//                        w.reportError(new ValidationEventImpl(ValidationEvent.ERROR,
//                            Messages.UNEXPECTED_JAVA_TYPE.format(
//                                item.getClass().getName(),
//                                getExpectedClassNameList()
//                            ),
//                            w.getCurrentLocation(fieldName)));
//                        continue;

                        // see the similar code in SingleElementNodeProperty.
                        // for the purpose of simple type substitution, make it a non-error

                        w.startElement(typeMap.values().iterator().next().tagName,null);
                        w.childAsXsiType(item,fieldName,w.grammar.getBeanInfo(Object.class), false);
                    } else {
                        w.startElement(tt.tagName,null);
                        serializeItem(tt.beanInfo,item,w);
                    }

                    w.endElement();
                } else {
                    if(nillableTagName!=null) {
                        w.startElement(nillableTagName,null);
                        w.writeXsiNilTrue();
                        w.endElement();
                    }
                }
            } catch (JAXBException e) {
                w.reportError(fieldName,e);
                // recover by ignoring this item
            }
        }
    }
 
Example #18
Source File: ArrayElementProperty.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
protected void serializeListBody(BeanT beanT, XMLSerializer w, ListT list) throws IOException, XMLStreamException, SAXException, AccessorException {
        ListIterator<ItemT> itr = lister.iterator(list, w);

        boolean isIdref = itr instanceof Lister.IDREFSIterator; // UGLY

        while(itr.hasNext()) {
            try {
                ItemT item = itr.next();
                if (item != null) {
                    Class itemType = item.getClass();
                    if(isIdref)
                        // This should be the only place where we need to be aware
                        // that the iterator is iterating IDREFS.
                        itemType = ((Lister.IDREFSIterator)itr).last().getClass();

                    // normally, this returns non-null
                    TagAndType tt = typeMap.get(itemType);
                    while(tt==null && itemType!=null) {
                        // otherwise we'll just have to try the slow way
                        itemType = itemType.getSuperclass();
                        tt = typeMap.get(itemType);
                    }

                    if(tt==null) {
                        // item is not of the expected type.
//                        w.reportError(new ValidationEventImpl(ValidationEvent.ERROR,
//                            Messages.UNEXPECTED_JAVA_TYPE.format(
//                                item.getClass().getName(),
//                                getExpectedClassNameList()
//                            ),
//                            w.getCurrentLocation(fieldName)));
//                        continue;

                        // see the similar code in SingleElementNodeProperty.
                        // for the purpose of simple type substitution, make it a non-error

                        w.startElement(typeMap.values().iterator().next().tagName,null);
                        w.childAsXsiType(item,fieldName,w.grammar.getBeanInfo(Object.class), false);
                    } else {
                        w.startElement(tt.tagName,null);
                        serializeItem(tt.beanInfo,item,w);
                    }

                    w.endElement();
                } else {
                    if(nillableTagName!=null) {
                        w.startElement(nillableTagName,null);
                        w.writeXsiNilTrue();
                        w.endElement();
                    }
                }
            } catch (JAXBException e) {
                w.reportError(fieldName,e);
                // recover by ignoring this item
            }
        }
    }
 
Example #19
Source File: ArrayERProperty.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public ItemsLoader(Accessor acc, Lister lister, QNameMap<ChildLoader> children) {
    super(false);
    this.acc = acc;
    this.lister = lister;
    this.children = children;
}
 
Example #20
Source File: ArrayERProperty.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public ItemsLoader(Accessor acc, Lister lister, QNameMap<ChildLoader> children) {
    super(false);
    this.acc = acc;
    this.lister = lister;
    this.children = children;
}
 
Example #21
Source File: ArrayElementProperty.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
protected void serializeListBody(BeanT beanT, XMLSerializer w, ListT list) throws IOException, XMLStreamException, SAXException, AccessorException {
        ListIterator<ItemT> itr = lister.iterator(list, w);

        boolean isIdref = itr instanceof Lister.IDREFSIterator; // UGLY

        while(itr.hasNext()) {
            try {
                ItemT item = itr.next();
                if (item != null) {
                    Class itemType = item.getClass();
                    if(isIdref)
                        // This should be the only place where we need to be aware
                        // that the iterator is iterating IDREFS.
                        itemType = ((Lister.IDREFSIterator)itr).last().getClass();

                    // normally, this returns non-null
                    TagAndType tt = typeMap.get(itemType);
                    while(tt==null && itemType!=null) {
                        // otherwise we'll just have to try the slow way
                        itemType = itemType.getSuperclass();
                        tt = typeMap.get(itemType);
                    }

                    if(tt==null) {
                        // item is not of the expected type.
//                        w.reportError(new ValidationEventImpl(ValidationEvent.ERROR,
//                            Messages.UNEXPECTED_JAVA_TYPE.format(
//                                item.getClass().getName(),
//                                getExpectedClassNameList()
//                            ),
//                            w.getCurrentLocation(fieldName)));
//                        continue;

                        // see the similar code in SingleElementNodeProperty.
                        // for the purpose of simple type substitution, make it a non-error

                        w.startElement(typeMap.values().iterator().next().tagName,null);
                        w.childAsXsiType(item,fieldName,w.grammar.getBeanInfo(Object.class), false);
                    } else {
                        w.startElement(tt.tagName,null);
                        serializeItem(tt.beanInfo,item,w);
                    }

                    w.endElement();
                } else {
                    if(nillableTagName!=null) {
                        w.startElement(nillableTagName,null);
                        w.writeXsiNilTrue();
                        w.endElement();
                    }
                }
            } catch (JAXBException e) {
                w.reportError(fieldName,e);
                // recover by ignoring this item
            }
        }
    }
 
Example #22
Source File: ArrayERProperty.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public ItemsLoader(Accessor acc, Lister lister, QNameMap<ChildLoader> children) {
    super(false);
    this.acc = acc;
    this.lister = lister;
    this.children = children;
}
 
Example #23
Source File: ArrayElementProperty.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
protected void serializeListBody(BeanT beanT, XMLSerializer w, ListT list) throws IOException, XMLStreamException, SAXException, AccessorException {
        ListIterator<ItemT> itr = lister.iterator(list, w);

        boolean isIdref = itr instanceof Lister.IDREFSIterator; // UGLY

        while(itr.hasNext()) {
            try {
                ItemT item = itr.next();
                if (item != null) {
                    Class itemType = item.getClass();
                    if(isIdref)
                        // This should be the only place where we need to be aware
                        // that the iterator is iterating IDREFS.
                        itemType = ((Lister.IDREFSIterator)itr).last().getClass();

                    // normally, this returns non-null
                    TagAndType tt = typeMap.get(itemType);
                    while(tt==null && itemType!=null) {
                        // otherwise we'll just have to try the slow way
                        itemType = itemType.getSuperclass();
                        tt = typeMap.get(itemType);
                    }

                    if(tt==null) {
                        // item is not of the expected type.
//                        w.reportError(new ValidationEventImpl(ValidationEvent.ERROR,
//                            Messages.UNEXPECTED_JAVA_TYPE.format(
//                                item.getClass().getName(),
//                                getExpectedClassNameList()
//                            ),
//                            w.getCurrentLocation(fieldName)));
//                        continue;

                        // see the similar code in SingleElementNodeProperty.
                        // for the purpose of simple type substitution, make it a non-error

                        w.startElement(typeMap.values().iterator().next().tagName,null);
                        w.childAsXsiType(item,fieldName,w.grammar.getBeanInfo(Object.class), false);
                    } else {
                        w.startElement(tt.tagName,null);
                        serializeItem(tt.beanInfo,item,w);
                    }

                    w.endElement();
                } else {
                    if(nillableTagName!=null) {
                        w.startElement(nillableTagName,null);
                        w.writeXsiNilTrue();
                        w.endElement();
                    }
                }
            } catch (JAXBException e) {
                w.reportError(fieldName,e);
                // recover by ignoring this item
            }
        }
    }
 
Example #24
Source File: ArrayERProperty.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public ItemsLoader(Accessor acc, Lister lister, QNameMap<ChildLoader> children) {
    super(false);
    this.acc = acc;
    this.lister = lister;
    this.children = children;
}
 
Example #25
Source File: ArrayElementProperty.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
protected void serializeListBody(BeanT beanT, XMLSerializer w, ListT list) throws IOException, XMLStreamException, SAXException, AccessorException {
        ListIterator<ItemT> itr = lister.iterator(list, w);

        boolean isIdref = itr instanceof Lister.IDREFSIterator; // UGLY

        while(itr.hasNext()) {
            try {
                ItemT item = itr.next();
                if (item != null) {
                    Class itemType = item.getClass();
                    if(isIdref)
                        // This should be the only place where we need to be aware
                        // that the iterator is iterating IDREFS.
                        itemType = ((Lister.IDREFSIterator)itr).last().getClass();

                    // normally, this returns non-null
                    TagAndType tt = typeMap.get(itemType);
                    while(tt==null && itemType!=null) {
                        // otherwise we'll just have to try the slow way
                        itemType = itemType.getSuperclass();
                        tt = typeMap.get(itemType);
                    }

                    if(tt==null) {
                        // item is not of the expected type.
//                        w.reportError(new ValidationEventImpl(ValidationEvent.ERROR,
//                            Messages.UNEXPECTED_JAVA_TYPE.format(
//                                item.getClass().getName(),
//                                getExpectedClassNameList()
//                            ),
//                            w.getCurrentLocation(fieldName)));
//                        continue;

                        // see the similar code in SingleElementNodeProperty.
                        // for the purpose of simple type substitution, make it a non-error

                        w.startElement(typeMap.values().iterator().next().tagName,null);
                        w.childAsXsiType(item,fieldName,w.grammar.getBeanInfo(Object.class), false);
                    } else {
                        w.startElement(tt.tagName,null);
                        serializeItem(tt.beanInfo,item,w);
                    }

                    w.endElement();
                } else {
                    if(nillableTagName!=null) {
                        w.startElement(nillableTagName,null);
                        w.writeXsiNilTrue();
                        w.endElement();
                    }
                }
            } catch (JAXBException e) {
                w.reportError(fieldName,e);
                // recover by ignoring this item
            }
        }
    }
 
Example #26
Source File: ArrayERProperty.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public ItemsLoader(Accessor acc, Lister lister, QNameMap<ChildLoader> children) {
    super(false);
    this.acc = acc;
    this.lister = lister;
    this.children = children;
}
 
Example #27
Source File: ArrayElementProperty.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
protected void serializeListBody(BeanT beanT, XMLSerializer w, ListT list) throws IOException, XMLStreamException, SAXException, AccessorException {
        ListIterator<ItemT> itr = lister.iterator(list, w);

        boolean isIdref = itr instanceof Lister.IDREFSIterator; // UGLY

        while(itr.hasNext()) {
            try {
                ItemT item = itr.next();
                if (item != null) {
                    Class itemType = item.getClass();
                    if(isIdref)
                        // This should be the only place where we need to be aware
                        // that the iterator is iterating IDREFS.
                        itemType = ((Lister.IDREFSIterator)itr).last().getClass();

                    // normally, this returns non-null
                    TagAndType tt = typeMap.get(itemType);
                    while(tt==null && itemType!=null) {
                        // otherwise we'll just have to try the slow way
                        itemType = itemType.getSuperclass();
                        tt = typeMap.get(itemType);
                    }

                    if(tt==null) {
                        // item is not of the expected type.
//                        w.reportError(new ValidationEventImpl(ValidationEvent.ERROR,
//                            Messages.UNEXPECTED_JAVA_TYPE.format(
//                                item.getClass().getName(),
//                                getExpectedClassNameList()
//                            ),
//                            w.getCurrentLocation(fieldName)));
//                        continue;

                        // see the similar code in SingleElementNodeProperty.
                        // for the purpose of simple type substitution, make it a non-error

                        w.startElement(typeMap.values().iterator().next().tagName,null);
                        w.childAsXsiType(item,fieldName,w.grammar.getBeanInfo(Object.class), false);
                    } else {
                        w.startElement(tt.tagName,null);
                        serializeItem(tt.beanInfo,item,w);
                    }

                    w.endElement();
                } else {
                    if(nillableTagName!=null) {
                        w.startElement(nillableTagName,null);
                        w.writeXsiNilTrue();
                        w.endElement();
                    }
                }
            } catch (JAXBException e) {
                w.reportError(fieldName,e);
                // recover by ignoring this item
            }
        }
    }
 
Example #28
Source File: ArrayERProperty.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public ItemsLoader(Accessor acc, Lister lister, QNameMap<ChildLoader> children) {
    super(false);
    this.acc = acc;
    this.lister = lister;
    this.children = children;
}
 
Example #29
Source File: ArrayElementProperty.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
protected void serializeListBody(BeanT beanT, XMLSerializer w, ListT list) throws IOException, XMLStreamException, SAXException, AccessorException {
        ListIterator<ItemT> itr = lister.iterator(list, w);

        boolean isIdref = itr instanceof Lister.IDREFSIterator; // UGLY

        while(itr.hasNext()) {
            try {
                ItemT item = itr.next();
                if (item != null) {
                    Class itemType = item.getClass();
                    if(isIdref)
                        // This should be the only place where we need to be aware
                        // that the iterator is iterating IDREFS.
                        itemType = ((Lister.IDREFSIterator)itr).last().getClass();

                    // normally, this returns non-null
                    TagAndType tt = typeMap.get(itemType);
                    while(tt==null && itemType!=null) {
                        // otherwise we'll just have to try the slow way
                        itemType = itemType.getSuperclass();
                        tt = typeMap.get(itemType);
                    }

                    if(tt==null) {
                        // item is not of the expected type.
//                        w.reportError(new ValidationEventImpl(ValidationEvent.ERROR,
//                            Messages.UNEXPECTED_JAVA_TYPE.format(
//                                item.getClass().getName(),
//                                getExpectedClassNameList()
//                            ),
//                            w.getCurrentLocation(fieldName)));
//                        continue;

                        // see the similar code in SingleElementNodeProperty.
                        // for the purpose of simple type substitution, make it a non-error

                        w.startElement(typeMap.values().iterator().next().tagName,null);
                        w.childAsXsiType(item,fieldName,w.grammar.getBeanInfo(Object.class), false);
                    } else {
                        w.startElement(tt.tagName,null);
                        serializeItem(tt.beanInfo,item,w);
                    }

                    w.endElement();
                } else {
                    if(nillableTagName!=null) {
                        w.startElement(nillableTagName,null);
                        w.writeXsiNilTrue();
                        w.endElement();
                    }
                }
            } catch (JAXBException e) {
                w.reportError(fieldName,e);
                // recover by ignoring this item
            }
        }
    }
 
Example #30
Source File: ArrayERProperty.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public ItemsLoader(Accessor acc, Lister lister, QNameMap<ChildLoader> children) {
    super(false);
    this.acc = acc;
    this.lister = lister;
    this.children = children;
}