类javax.xml.bind.JAXBIntrospector源码实例Demo

下面列出了怎么用javax.xml.bind.JAXBIntrospector的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: TencentKona-8   文件: JAXBContextImpl.java
@Override
public JAXBIntrospector createJAXBIntrospector() {
    return new JAXBIntrospector() {
        public boolean isElement(Object object) {
            return getElementName(object)!=null;
        }

        public QName getElementName(Object jaxbElement) {
            try {
                return JAXBContextImpl.this.getElementName(jaxbElement);
            } catch (JAXBException e) {
                return null;
            }
        }
    };
}
 
源代码2 项目: jdk8u60   文件: JAXBContextImpl.java
@Override
public JAXBIntrospector createJAXBIntrospector() {
    return new JAXBIntrospector() {
        public boolean isElement(Object object) {
            return getElementName(object)!=null;
        }

        public QName getElementName(Object jaxbElement) {
            try {
                return JAXBContextImpl.this.getElementName(jaxbElement);
            } catch (JAXBException e) {
                return null;
            }
        }
    };
}
 
源代码3 项目: openjdk-jdk8u   文件: JAXBContextImpl.java
@Override
public JAXBIntrospector createJAXBIntrospector() {
    return new JAXBIntrospector() {
        public boolean isElement(Object object) {
            return getElementName(object)!=null;
        }

        public QName getElementName(Object jaxbElement) {
            try {
                return JAXBContextImpl.this.getElementName(jaxbElement);
            } catch (JAXBException e) {
                return null;
            }
        }
    };
}
 
源代码4 项目: validator   文件: ConversionService.java
public <T> String writeXml(final T model, final Schema schema, final ValidationEventHandler handler) {
    if (model == null) {
        throw new ConversionExeption("Can not serialize null");
    }
    try ( final StringWriter w = new StringWriter() ) {
        final JAXBIntrospector introspector = getJaxbContext().createJAXBIntrospector();
        final Marshaller marshaller = getJaxbContext().createMarshaller();
        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
        marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
        marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
        marshaller.setSchema(schema);
        marshaller.setEventHandler(handler);
        final XMLOutputFactory xof = XMLOutputFactory.newFactory();
        final XMLStreamWriter xmlStreamWriter = xof.createXMLStreamWriter(w);
        if (null == introspector.getElementName(model)) {
            final JAXBElement jaxbElement = new JAXBElement(createQName(model), model.getClass(), model);
            marshaller.marshal(jaxbElement, xmlStreamWriter);
        } else {
            marshaller.marshal(model, xmlStreamWriter);
        }
        xmlStreamWriter.flush();
        return w.toString();
    } catch (final JAXBException | IOException | XMLStreamException e) {
        throw new ConversionExeption(String.format("Error serializing Object %s", model.getClass().getName()), e);
    }
}
 
源代码5 项目: openjdk-jdk8u-backup   文件: JAXBContextImpl.java
@Override
public JAXBIntrospector createJAXBIntrospector() {
    return new JAXBIntrospector() {
        public boolean isElement(Object object) {
            return getElementName(object)!=null;
        }

        public QName getElementName(Object jaxbElement) {
            try {
                return JAXBContextImpl.this.getElementName(jaxbElement);
            } catch (JAXBException e) {
                return null;
            }
        }
    };
}
 
源代码6 项目: openjdk-jdk9   文件: JAXBContextImpl.java
@Override
public JAXBIntrospector createJAXBIntrospector() {
    return new JAXBIntrospector() {
        public boolean isElement(Object object) {
            return getElementName(object)!=null;
        }

        public QName getElementName(Object jaxbElement) {
            try {
                return JAXBContextImpl.this.getElementName(jaxbElement);
            } catch (JAXBException e) {
                return null;
            }
        }
    };
}
 
源代码7 项目: hottub   文件: JAXBContextImpl.java
@Override
public JAXBIntrospector createJAXBIntrospector() {
    return new JAXBIntrospector() {
        public boolean isElement(Object object) {
            return getElementName(object)!=null;
        }

        public QName getElementName(Object jaxbElement) {
            try {
                return JAXBContextImpl.this.getElementName(jaxbElement);
            } catch (JAXBException e) {
                return null;
            }
        }
    };
}
 
源代码8 项目: openjdk-8-source   文件: JAXBContextImpl.java
@Override
public JAXBIntrospector createJAXBIntrospector() {
    return new JAXBIntrospector() {
        public boolean isElement(Object object) {
            return getElementName(object)!=null;
        }

        public QName getElementName(Object jaxbElement) {
            try {
                return JAXBContextImpl.this.getElementName(jaxbElement);
            } catch (JAXBException e) {
                return null;
            }
        }
    };
}
 
源代码9 项目: openjdk-8   文件: JAXBContextImpl.java
@Override
public JAXBIntrospector createJAXBIntrospector() {
    return new JAXBIntrospector() {
        public boolean isElement(Object object) {
            return getElementName(object)!=null;
        }

        public QName getElementName(Object jaxbElement) {
            try {
                return JAXBContextImpl.this.getElementName(jaxbElement);
            } catch (JAXBException e) {
                return null;
            }
        }
    };
}
 
源代码10 项目: wadl-tools   文件: QNameBuilder.java
private QName discoverQNameFromJaxb(Class<?> classType) {
    QName qName = null;
    try {
        final JAXBIntrospector jaxbIntrospector = JAXBContext.newInstance(classType).createJAXBIntrospector();
        qName = jaxbIntrospector.getElementName(classType.getConstructor().newInstance());

    } catch (Exception e) {
        // Add e to the logger message because JAXB Exceptions has a lot of information in the toString().
        // and some loggers implementations just print the getMessage();
        logger.warn("Cannot discover QName from JAXB annotations for class: " + classType.getName()
                + ". Preparing generic QName." + e, e);
    }

    if (qName == null) {
        // Could be null if getElementName returned null, or a exception was thrown.
        return EMPTY_Q_NAME;
    }
    return qName;
}