/** * Copy constructor */ protected Unmarshaller(Unmarshaller unmarshaller) { this.context = (CONTEXT) unmarshaller.getContext(); this.unmarshalListener = (UNMARSHALLER_LISTENER) unmarshaller.getUnmarshalListener(); }
/** * Copy constructor */ protected Unmarshaller(Unmarshaller unmarshaller) { this.context = (CONTEXT) unmarshaller.getContext(); this.unmarshalListener = (UNMARSHALLER_LISTENER) unmarshaller.getUnmarshalListener(); }
private boolean isPrimitiveWrapper(Class clazz) { return ((ConversionManager) xmlUnmarshaller.getContext().getSession().getDatasourcePlatform().getConversionManager()).schemaType(clazz) != null || CoreClassConstants.XML_GREGORIAN_CALENDAR.isAssignableFrom(clazz) || CoreClassConstants.DURATION.isAssignableFrom(clazz); }
private boolean isPrimitiveWrapper(Class clazz){ return ((ConversionManager) xmlUnmarshaller.getContext().getSession().getDatasourcePlatform().getConversionManager()).schemaType(clazz) != null ||CoreClassConstants.XML_GREGORIAN_CALENDAR.isAssignableFrom(clazz) ||CoreClassConstants.DURATION.isAssignableFrom(clazz); }
public Object unmarshal(Reader reader) { if (xmlUnmarshaller.getContext().hasDocumentPreservation()) { Node domElement = getXMLParser().parse(reader).getDocumentElement(); return unmarshal(domElement); } InputSource inputSource = new InputSource(reader); return unmarshal(inputSource); }
public Object unmarshal(Reader reader, Class clazz) { if (xmlUnmarshaller.getContext().hasDocumentPreservation()) { Node domElement = getXMLParser().parse(reader).getDocumentElement(); return unmarshal(domElement, clazz); } InputSource inputSource = new InputSource(reader); return unmarshal(inputSource, clazz); }
@Override public Object unmarshal(InputStream inputStream) { if (xmlUnmarshaller.getContext().hasDocumentPreservation()) { Node domElement = getXMLParser().parse(inputStream).getDocumentElement(); return unmarshal(domElement); } InputSource inputSource = new InputSource(inputStream); return unmarshal(inputSource); }
@Override public Object unmarshal(Reader reader) { if (xmlUnmarshaller.getContext().hasDocumentPreservation()) { Node domElement = getXMLParser().parse(reader).getDocumentElement(); return unmarshal(domElement); } InputSource inputSource = new InputSource(reader); return unmarshal(inputSource); }
public Object unmarshal(InputStream inputStream) { if (xmlUnmarshaller.getContext().hasDocumentPreservation()) { Node domElement = getXMLParser().parse(inputStream).getDocumentElement(); return unmarshal(domElement); } InputSource inputSource = new InputSource(inputStream); return unmarshal(inputSource); }
@Override public Object unmarshal(InputStream inputStream, Class clazz) { if (xmlUnmarshaller.getContext().hasDocumentPreservation()) { Node domElement = getXMLParser().parse(inputStream).getDocumentElement(); return unmarshal(domElement, clazz); } InputSource inputSource = new InputSource(inputStream); return unmarshal(inputSource, clazz); }
@Override public Object unmarshal(Reader reader, Class clazz) { if (xmlUnmarshaller.getContext().hasDocumentPreservation()) { Node domElement = getXMLParser().parse(reader).getDocumentElement(); return unmarshal(domElement, clazz); } InputSource inputSource = new InputSource(reader); return unmarshal(inputSource, clazz); }
public Object unmarshal(InputStream inputStream, Class clazz) { if (xmlUnmarshaller.getContext().hasDocumentPreservation()) { Node domElement = getXMLParser().parse(inputStream).getDocumentElement(); return unmarshal(domElement, clazz); } InputSource inputSource = new InputSource(inputStream); return unmarshal(inputSource, clazz); }
@Override public Object unmarshal(File file, Class clazz) { try { if (xmlUnmarshaller.getContext().hasDocumentPreservation()) { Node domElement = getXMLParser().parse(file).getDocumentElement(); return unmarshal(domElement, clazz); } this.systemId = file.toURI().toURL().toExternalForm(); FileInputStream inputStream = new FileInputStream(file); try { return unmarshal(inputStream, clazz); } finally { inputStream.close(); } } catch (FileNotFoundException e) { throw XMLMarshalException.unmarshalException(e); } catch (IOException e) { throw XMLMarshalException.unmarshalException(e); } finally { xmlUnmarshaller.getStringBuffer().reset(); } }
private void setDeclaredTypeOnXMLRoot(Root xmlRoot, String elementNamespaceUri, String elementLocalName, boolean isNamespaceAware, Unmarshaller unmarshaller){ XPathQName xpathQName = new XPathQName(elementNamespaceUri, elementLocalName, isNamespaceAware); Descriptor desc = unmarshaller.getContext().getDescriptor(xpathQName); if(desc != null){ xmlRoot.setDeclaredType(desc.getJavaClass()); } }
private void setDeclaredTypeOnXMLRoot(Root xmlRoot, String elementNamespaceUri, String elementLocalName, boolean isNamespaceAware, Unmarshaller unmarshaller){ XPathQName xpathQName = new XPathQName(elementNamespaceUri, elementLocalName, isNamespaceAware); Descriptor desc = unmarshaller.getContext().getDescriptor(xpathQName); if(desc != null){ xmlRoot.setDeclaredType(desc.getJavaClass()); } }
public Object unmarshal(InputSource inputSource, XMLReader xmlReader) { try { if (inputSource != null && null == inputSource.getSystemId()) { inputSource.setSystemId(this.systemId); } SAXUnmarshallerHandler saxUnmarshallerHandler = new SAXUnmarshallerHandler(xmlUnmarshaller.getContext()); saxUnmarshallerHandler.setXMLReader(xmlReader); saxUnmarshallerHandler.setUnmarshaller(xmlUnmarshaller); setContentHandler(xmlReader, saxUnmarshallerHandler); xmlReader.parse(inputSource); // resolve any mapping references saxUnmarshallerHandler.resolveReferences(); return saxUnmarshallerHandler.getObject(); } catch (IOException e) { throw XMLMarshalException.unmarshalException(e); } catch (SAXException e) { throw convertSAXException(e); } finally { xmlUnmarshaller.getStringBuffer().reset(); } }
@Override protected Descriptor findReferenceDescriptor(XPathFragment xPathFragment, UnmarshalRecord unmarshalRecord, Attributes atts, Mapping mapping, UnmarshalKeepAsElementPolicy policy) { Descriptor referenceDescriptor = super.findReferenceDescriptor(xPathFragment, unmarshalRecord, atts, mapping, policy); if (referenceDescriptor == null) { Context xmlContext = unmarshalRecord.getUnmarshaller().getContext(); XPathQName xpathQName = new XPathQName(xPathFragment.getNamespaceURI(), xPathFragment.getLocalName(), unmarshalRecord.isNamespaceAware()); referenceDescriptor = (Descriptor) xmlContext.getDescriptor(xpathQName); // Check if descriptor is for a wrapper, if it is null it out and let continue if (referenceDescriptor != null && referenceDescriptor.isWrapper()) { referenceDescriptor = null; } } return referenceDescriptor; }
@Override protected Descriptor findReferenceDescriptor(XPathFragment xPathFragment, UnmarshalRecord unmarshalRecord, Attributes atts, Mapping mapping, UnmarshalKeepAsElementPolicy policy) { Descriptor referenceDescriptor = super.findReferenceDescriptor(xPathFragment, unmarshalRecord, atts, mapping, policy); if (referenceDescriptor == null) { Context xmlContext = unmarshalRecord.getUnmarshaller().getContext(); XPathQName xpathQName = new XPathQName(xPathFragment.getNamespaceURI(), xPathFragment.getLocalName(), unmarshalRecord.isNamespaceAware()); referenceDescriptor = (Descriptor) xmlContext.getDescriptor(xpathQName); // Check if descriptor is for a wrapper, if it is null it out and let continue if (referenceDescriptor != null && referenceDescriptor.isWrapper()) { referenceDescriptor = null; } } return referenceDescriptor; }
public Object unmarshal(DOMReader reader, Node node) { try { SAXUnmarshallerHandler handler = new SAXUnmarshallerHandler(xmlUnmarshaller.getContext()); setContentHandler(reader, handler); handler.setXMLReader(reader); handler.setUnmarshaller(xmlUnmarshaller); reader.parse(node); handler.resolveReferences(); return handler.getObject(); } catch (SAXException e) { throw convertSAXException(e); } finally { xmlUnmarshaller.getStringBuffer().reset(); } }
public Object unmarshal(DOMReader reader, Node node) { try { SAXUnmarshallerHandler handler = new SAXUnmarshallerHandler(xmlUnmarshaller.getContext()); setContentHandler(reader, handler); handler.setXMLReader(reader); handler.setUnmarshaller(xmlUnmarshaller); reader.parse(node); handler.resolveReferences(); return handler.getObject(); } catch (SAXException e) { throw convertSAXException(e); } finally { xmlUnmarshaller.getStringBuffer().reset(); } }