Java Code Examples for com.sun.xml.internal.bind.v2.runtime.XMLSerializer#reportError()

The following examples show how to use com.sun.xml.internal.bind.v2.runtime.XMLSerializer#reportError() . 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: ListTransducedAccessorImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public String print(BeanT o) throws AccessorException, SAXException {
    ListT list = acc.get(o);

    if(list==null)
        return null;

    StringBuilder buf = new StringBuilder();
    XMLSerializer w = XMLSerializer.getInstance();
    ListIterator<ItemT> itr = lister.iterator(list, w);

    while(itr.hasNext()) {
        try {
            ItemT item = itr.next();
            if (item != null) {
                if(buf.length()>0)  buf.append(' ');
                buf.append(xducer.print(item));
            }
        } catch (JAXBException e) {
            w.reportError(null,e);
        }
    }
    return buf.toString();
}
 
Example 2
Source File: ArrayReferenceNodeProperty.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
protected final void serializeListBody(BeanT o, XMLSerializer w, ListT list) throws IOException, XMLStreamException, SAXException {
    ListIterator<ItemT> itr = lister.iterator(list, w);

    while(itr.hasNext()) {
        try {
            ItemT item = itr.next();
            if (item != null) {
                if(isMixed && item.getClass()==String.class) {
                    w.text((String)item,null);
                } else {
                    JaxBeanInfo bi = w.grammar.getBeanInfo(item,true);
                    if(bi.jaxbType==Object.class && domHandler!=null)
                        // even if 'v' is a DOM node, it always derive from Object,
                        // so the getBeanInfo returns BeanInfo for Object
                        w.writeDom(item,domHandler,o,fieldName);
                    else
                        bi.serializeRoot(item,w);
                }
            }
        } catch (JAXBException e) {
            w.reportError(fieldName,e);
            // recover by ignoring this item
        }
    }
}
 
Example 3
Source File: ListTransducedAccessorImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public String print(BeanT o) throws AccessorException, SAXException {
    ListT list = acc.get(o);

    if(list==null)
        return null;

    StringBuilder buf = new StringBuilder();
    XMLSerializer w = XMLSerializer.getInstance();
    ListIterator<ItemT> itr = lister.iterator(list, w);

    while(itr.hasNext()) {
        try {
            ItemT item = itr.next();
            if (item != null) {
                if(buf.length()>0)  buf.append(' ');
                buf.append(xducer.print(item));
            }
        } catch (JAXBException e) {
            w.reportError(null,e);
        }
    }
    return buf.toString();
}
 
Example 4
Source File: ListTransducedAccessorImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public String print(BeanT o) throws AccessorException, SAXException {
    ListT list = acc.get(o);

    if(list==null)
        return null;

    StringBuilder buf = new StringBuilder();
    XMLSerializer w = XMLSerializer.getInstance();
    ListIterator<ItemT> itr = lister.iterator(list, w);

    while(itr.hasNext()) {
        try {
            ItemT item = itr.next();
            if (item != null) {
                if(buf.length()>0)  buf.append(' ');
                buf.append(xducer.print(item));
            }
        } catch (JAXBException e) {
            w.reportError(null,e);
        }
    }
    return buf.toString();
}
 
Example 5
Source File: ListTransducedAccessorImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public String print(BeanT o) throws AccessorException, SAXException {
    ListT list = acc.get(o);

    if(list==null)
        return null;

    StringBuilder buf = new StringBuilder();
    XMLSerializer w = XMLSerializer.getInstance();
    ListIterator<ItemT> itr = lister.iterator(list, w);

    while(itr.hasNext()) {
        try {
            ItemT item = itr.next();
            if (item != null) {
                if(buf.length()>0)  buf.append(' ');
                buf.append(xducer.print(item));
            }
        } catch (JAXBException e) {
            w.reportError(null,e);
        }
    }
    return buf.toString();
}
 
Example 6
Source File: SingleReferenceNodeProperty.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public void serializeBody(BeanT o, XMLSerializer w, Object outerPeer) throws SAXException, AccessorException, IOException, XMLStreamException {
    ValueT v = acc.get(o);
    if(v!=null) {
        try {
            JaxBeanInfo bi = w.grammar.getBeanInfo(v,true);
            if(bi.jaxbType==Object.class && domHandler!=null)
                // even if 'v' is a DOM node, it always derive from Object,
                // so the getBeanInfo returns BeanInfo for Object
                w.writeDom(v,domHandler,o,fieldName);
            else
                bi.serializeRoot(v,w);
        } catch (JAXBException e) {
            w.reportError(fieldName,e);
            // recover by ignoring this property
        }
    }
}
 
Example 7
Source File: ArrayReferenceNodeProperty.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
protected final void serializeListBody(BeanT o, XMLSerializer w, ListT list) throws IOException, XMLStreamException, SAXException {
    ListIterator<ItemT> itr = lister.iterator(list, w);

    while(itr.hasNext()) {
        try {
            ItemT item = itr.next();
            if (item != null) {
                if(isMixed && item.getClass()==String.class) {
                    w.text((String)item,null);
                } else {
                    JaxBeanInfo bi = w.grammar.getBeanInfo(item,true);
                    if(bi.jaxbType==Object.class && domHandler!=null)
                        // even if 'v' is a DOM node, it always derive from Object,
                        // so the getBeanInfo returns BeanInfo for Object
                        w.writeDom(item,domHandler,o,fieldName);
                    else
                        bi.serializeRoot(item,w);
                }
            }
        } catch (JAXBException e) {
            w.reportError(fieldName,e);
            // recover by ignoring this item
        }
    }
}
 
Example 8
Source File: ListTransducedAccessorImpl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public String print(BeanT o) throws AccessorException, SAXException {
    ListT list = acc.get(o);

    if(list==null)
        return null;

    StringBuilder buf = new StringBuilder();
    XMLSerializer w = XMLSerializer.getInstance();
    ListIterator<ItemT> itr = lister.iterator(list, w);

    while(itr.hasNext()) {
        try {
            ItemT item = itr.next();
            if (item != null) {
                if(buf.length()>0)  buf.append(' ');
                buf.append(xducer.print(item));
            }
        } catch (JAXBException e) {
            w.reportError(null,e);
        }
    }
    return buf.toString();
}
 
Example 9
Source File: SingleReferenceNodeProperty.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public void serializeBody(BeanT o, XMLSerializer w, Object outerPeer) throws SAXException, AccessorException, IOException, XMLStreamException {
    ValueT v = acc.get(o);
    if(v!=null) {
        try {
            JaxBeanInfo bi = w.grammar.getBeanInfo(v,true);
            if(bi.jaxbType==Object.class && domHandler!=null)
                // even if 'v' is a DOM node, it always derive from Object,
                // so the getBeanInfo returns BeanInfo for Object
                w.writeDom(v,domHandler,o,fieldName);
            else
                bi.serializeRoot(v,w);
        } catch (JAXBException e) {
            w.reportError(fieldName,e);
            // recover by ignoring this property
        }
    }
}
 
Example 10
Source File: ListTransducedAccessorImpl.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public String print(BeanT o) throws AccessorException, SAXException {
    ListT list = acc.get(o);

    if(list==null)
        return null;

    StringBuilder buf = new StringBuilder();
    XMLSerializer w = XMLSerializer.getInstance();
    ListIterator<ItemT> itr = lister.iterator(list, w);

    while(itr.hasNext()) {
        try {
            ItemT item = itr.next();
            if (item != null) {
                if(buf.length()>0)  buf.append(' ');
                buf.append(xducer.print(item));
            }
        } catch (JAXBException e) {
            w.reportError(null,e);
        }
    }
    return buf.toString();
}
 
Example 11
Source File: ListTransducedAccessorImpl.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public void declareNamespace(BeanT bean, XMLSerializer w) throws AccessorException, SAXException {
    ListT list = acc.get(bean);

    if(list!=null) {
       ListIterator<ItemT> itr = lister.iterator(list, w);

        while(itr.hasNext()) {
            try {
                ItemT item = itr.next();
                if (item != null) {
                    xducer.declareNamespace(item,w);
                }
            } catch (JAXBException e) {
                w.reportError(null,e);
            }
        }
    }
}
 
Example 12
Source File: ListTransducedAccessorImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public String print(BeanT o) throws AccessorException, SAXException {
    ListT list = acc.get(o);

    if(list==null)
        return null;

    StringBuilder buf = new StringBuilder();
    XMLSerializer w = XMLSerializer.getInstance();
    ListIterator<ItemT> itr = lister.iterator(list, w);

    while(itr.hasNext()) {
        try {
            ItemT item = itr.next();
            if (item != null) {
                if(buf.length()>0)  buf.append(' ');
                buf.append(xducer.print(item));
            }
        } catch (JAXBException e) {
            w.reportError(null,e);
        }
    }
    return buf.toString();
}
 
Example 13
Source File: ListTransducedAccessorImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void declareNamespace(BeanT bean, XMLSerializer w) throws AccessorException, SAXException {
    ListT list = acc.get(bean);

    if(list!=null) {
       ListIterator<ItemT> itr = lister.iterator(list, w);

        while(itr.hasNext()) {
            try {
                ItemT item = itr.next();
                if (item != null) {
                    xducer.declareNamespace(item,w);
                }
            } catch (JAXBException e) {
                w.reportError(null,e);
            }
        }
    }
}
 
Example 14
Source File: SingleReferenceNodeProperty.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public void serializeBody(BeanT o, XMLSerializer w, Object outerPeer) throws SAXException, AccessorException, IOException, XMLStreamException {
    ValueT v = acc.get(o);
    if(v!=null) {
        try {
            JaxBeanInfo bi = w.grammar.getBeanInfo(v,true);
            if(bi.jaxbType==Object.class && domHandler!=null)
                // even if 'v' is a DOM node, it always derive from Object,
                // so the getBeanInfo returns BeanInfo for Object
                w.writeDom(v,domHandler,o,fieldName);
            else
                bi.serializeRoot(v,w);
        } catch (JAXBException e) {
            w.reportError(fieldName,e);
            // recover by ignoring this property
        }
    }
}
 
Example 15
Source File: TransducedAccessor.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public String print(BeanT bean) throws AccessorException, SAXException {
    TargetT target = acc.get(bean);
    if(target==null)    return null;

    XMLSerializer w = XMLSerializer.getInstance();
    try {
        String id = w.grammar.getBeanInfo(target,true).getId(target,w);
        if(id==null)
            w.errorMissingId(target);
        return id;
    } catch (JAXBException e) {
        w.reportError(null,e);
        return null;
    }
}
 
Example 16
Source File: TransducedAccessor.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public String print(BeanT bean) throws AccessorException, SAXException {
    TargetT target = acc.get(bean);
    if(target==null)    return null;

    XMLSerializer w = XMLSerializer.getInstance();
    try {
        String id = w.grammar.getBeanInfo(target,true).getId(target,w);
        if(id==null)
            w.errorMissingId(target);
        return id;
    } catch (JAXBException e) {
        w.reportError(null,e);
        return null;
    }
}
 
Example 17
Source File: TransducedAccessor.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public String print(BeanT bean) throws AccessorException, SAXException {
    TargetT target = acc.get(bean);
    if(target==null)    return null;

    XMLSerializer w = XMLSerializer.getInstance();
    try {
        String id = w.grammar.getBeanInfo(target,true).getId(target,w);
        if(id==null)
            w.errorMissingId(target);
        return id;
    } catch (JAXBException e) {
        w.reportError(null,e);
        return null;
    }
}
 
Example 18
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 19
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 20
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
            }
        }
    }