Package org.eclipse.persistence.internal.oxm.record

Examples of org.eclipse.persistence.internal.oxm.record.XMLReader


    }

    public Object unmarshal(Source source, Class clazz) {
        if (source instanceof SAXSource) {
            SAXSource saxSource = (SAXSource) source;
            XMLReader xmlReader = null;
            if (saxSource.getXMLReader() != null) {
                xmlReader = new XMLReader(saxSource.getXMLReader());
            }
            if (null == saxSource.getXMLReader()) {
                return unmarshal(saxSource.getInputSource(), clazz);
            } else {
                return unmarshal(saxSource.getInputSource(), clazz, xmlReader);
View Full Code Here


                SAXDocumentBuilder saxDocumentBuilder = new SAXDocumentBuilder();
                xmlReader.setContentHandler(saxDocumentBuilder);
                xmlReader.parse(inputSource);               
                return unmarshal(saxDocumentBuilder.getDocument().getDocumentElement());
            }
            XMLReader extendedXMLReader;
            if(xmlReader instanceof XMLReader) {
                extendedXMLReader = (XMLReader) xmlReader;
            } else {
                extendedXMLReader = new XMLReader(xmlReader);
            }
            SAXUnmarshallerHandler saxUnmarshallerHandler = new SAXUnmarshallerHandler(xmlContext);
            saxUnmarshallerHandler.setXMLReader(extendedXMLReader);
            saxUnmarshallerHandler.setUnmarshaller(xmlUnmarshaller);
            extendedXMLReader.setContentHandler(saxUnmarshallerHandler);
            extendedXMLReader.parse(inputSource);

            // resolve any mapping references
            saxUnmarshallerHandler.resolveReferences();
            return saxUnmarshallerHandler.getObject();
        } catch (IOException e) {
View Full Code Here

                // try and get a Unit Of Work from the XMLContext
                session = xmlContext.getReadSession(clazz);
                xmlDescriptor = (XMLDescriptor) session.getDescriptor(clazz);
                unmarshalRecord = (UnmarshalRecord) xmlDescriptor.getObjectBuilder().createRecord(session);
            }
            XMLReader extendedXMLReader;
            if(xmlReader instanceof XMLReader) {
                extendedXMLReader = (XMLReader) xmlReader;
            } else {
                extendedXMLReader = new XMLReader(xmlReader);
            }
            unmarshalRecord.setXMLReader(extendedXMLReader);
            unmarshalRecord.setUnmarshaller(xmlUnmarshaller);
            extendedXMLReader.setContentHandler(unmarshalRecord);
            try {
                extendedXMLReader.setProperty("http://xml.org/sax/properties/lexical-handler", unmarshalRecord);
            } catch (SAXNotRecognizedException ex) {
            } catch (SAXNotSupportedException ex) {
                //if lexical handling is not supported by this parser, just ignore.
            }
            extendedXMLReader.parse(inputSource);

            // resolve mapping references
            xmlUnmarshaller.resolveReferences(session);

            if (isPrimitiveWrapper || clazz == ClassConstants.OBJECT) {
View Full Code Here

    public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException {
        if(XMLConstants.XOP_URL.equals(namespaceURI) && (INCLUDE_ELEMENT_NAME.equals(localName) || INCLUDE_ELEMENT_NAME.equals(qName))) {
            this.c_id = atts.getValue("", HREF_ATTRIBUTE_NAME);
        } else {
            //Return control to the UnmarshalRecord
            XMLReader xmlReader = record.getXMLReader();
            xmlReader.setContentHandler(record);
            xmlReader.setLexicalHandler(record);
            record.startElement(namespaceURI, localName, qName, atts);
        }
    }
View Full Code Here

            } else {
                record.setAttributeValue(data, mapping);
            }
            //Return control to the UnmarshalRecord
            if(!xmlField.isSelfField()){
                XMLReader xmlReader = record.getXMLReader();
                xmlReader.setContentHandler(record);
                xmlReader.setLexicalHandler(record);
            }
        } else {
            if(!xmlField.isSelfField()){
                //Return control to the parent record
                XMLReader xmlReader = record.getXMLReader();
                xmlReader.setContentHandler(record);
                xmlReader.setLexicalHandler(record);
                record.endElement(namespaceURI, localName, qName);
            }
        }
    }
View Full Code Here

                 String qnameString = xPathFragment.getLocalName();
                 if (xPathFragment.getPrefix() != null) {
                     qnameString = xPathFragment.getPrefix() + XMLConstants.COLON + qnameString;
                 }
                 handler.startElement(xPathFragment.getNamespaceURI(), xPathFragment.getLocalName(), qnameString, atts);
                 XMLReader xmlReader = unmarshalRecord.getXMLReader();
                 xmlReader.setContentHandler(handler);
                 xmlReader.setLexicalHandler(handler);
            } else if (lastFragment.isAttribute()) {
                //handle swaRef and inline attribute cases here:
                String value = atts.getValue(lastFragment.getNamespaceURI(), lastFragment.getLocalName());
                Object fieldValue = null;
                if (xmlBinaryDataCollectionMapping.isSwaRef()) {
View Full Code Here

                }
            }

            saxParser = saxParserFactory.newSAXParser();

            xmlReader = new XMLReader(saxParser.getXMLReader());
            xmlReader.setErrorHandler(new DefaultErrorHandler());
            xmlParser = XMLPlatformFactory.getInstance().getXMLPlatform().newXMLParser();
            xmlParser.setNamespaceAware(true);
            xmlParser.setValidationMode(XMLParser.NONVALIDATING);
View Full Code Here

    public void setSchema(Schema schema) {
        saxParserFactory.setSchema(schema);
        try {
            saxParser = saxParserFactory.newSAXParser();
            XMLReader newXmlReader = new XMLReader(saxParser.getXMLReader());
            newXmlReader.setFeature(VALIDATING, xmlReader.getFeature(VALIDATING));
            newXmlReader.setEntityResolver(xmlReader.getEntityResolver());
            newXmlReader.setErrorHandler(xmlReader.getErrorHandler());
            xmlReader = newXmlReader;
            xmlParser.setXMLSchema(schema);
        } catch (Exception e) {
            throw XMLMarshalException.errorInstantiatingSchemaPlatform(e);
        }
View Full Code Here

    }

    public Object unmarshal(Source source) {
        if (source instanceof SAXSource) {
            SAXSource saxSource = (SAXSource) source;
            XMLReader xmlReader = null;
            if (saxSource.getXMLReader() != null) {
                xmlReader = new XMLReader(saxSource.getXMLReader());
            }
            if (null == xmlReader) {
                return unmarshal(saxSource.getInputSource());
            } else {
                return unmarshal(saxSource.getInputSource(), xmlReader);
View Full Code Here

    }

    public Object unmarshal(Source source, Class clazz) {
        if (source instanceof SAXSource) {
            SAXSource saxSource = (SAXSource) source;
            XMLReader xmlReader = null;
            if (saxSource.getXMLReader() != null) {
                xmlReader = new XMLReader(saxSource.getXMLReader());
            }
            if (null == saxSource.getXMLReader()) {
                return unmarshal(saxSource.getInputSource(), clazz);
            } else {
                return unmarshal(saxSource.getInputSource(), clazz, xmlReader);
View Full Code Here

TOP

Related Classes of org.eclipse.persistence.internal.oxm.record.XMLReader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.