Search in sources :

Example 1 with StrBuffer

use of org.eclipse.persistence.internal.oxm.StrBuffer in project eclipselink by eclipse-ee4j.

the class UnmarshalRecordImpl method characters.

@Override
public void characters(char[] ch, int start, int length) throws SAXException {
    if (currentObject == null) {
        return;
    }
    try {
        int strBufferInitialLength = -1;
        if (null != selfRecords) {
            strBufferInitialLength = getStringBuffer().length();
            for (int x = 0, selfRecordsSize = selfRecords.size(); x < selfRecordsSize; x++) {
                UnmarshalRecord selfRecord = selfRecords.get(x);
                if (selfRecord != null) {
                    selfRecord.characters(ch, start, length);
                } else {
                    getFragmentBuilder().characters(ch, start, length);
                }
            }
        }
        if (-1 != unmappedLevel && unmappedLevel <= levelIndex) {
            return;
        }
        XPathNode textNode = xPathNode.getTextNode();
        if (null == textNode) {
            textNode = xPathNode.getAnyNode();
            if (textNode != null) {
                xpathNodeIsMixedContent = true;
                this.xPathFragment.setLocalName(null);
                this.xPathFragment.setNamespaceURI(null);
                if (0 == length) {
                    return;
                }
            }
        }
        if (null != textNode) {
            if (textNode.getUnmarshalNodeValue().isMixedContentNodeValue()) {
                String tmpString = new String(ch, start, length);
                if (!textNode.isWhitespaceAware() && tmpString.trim().length() == 0) {
                    return;
                }
            }
            xPathNode = textNode;
            unmarshalContext.characters(this);
        }
        NodeValue unmarshalNodeValue = xPathNode.getUnmarshalNodeValue();
        if (null != unmarshalNodeValue && !unmarshalNodeValue.isWrapperNodeValue()) {
            if (strBufferInitialLength == -1) {
                getStringBuffer().append(ch, start, length);
            } else {
                StrBuffer strBuffer = getStringBuffer();
                if (strBufferInitialLength == strBuffer.length()) {
                    strBuffer.append(ch, start, length);
                }
            }
        }
    } catch (EclipseLinkException e) {
        if (null == xmlReader.getErrorHandler()) {
            throw e;
        } else {
            SAXParseException saxParseException = new SAXParseException(null, getDocumentLocator(), e);
            xmlReader.getErrorHandler().error(saxParseException);
        }
    }
}
Also used : MappingNodeValue(org.eclipse.persistence.internal.oxm.MappingNodeValue) NodeValue(org.eclipse.persistence.internal.oxm.NodeValue) EclipseLinkException(org.eclipse.persistence.exceptions.EclipseLinkException) SAXParseException(org.xml.sax.SAXParseException) XPathNode(org.eclipse.persistence.internal.oxm.XPathNode) StrBuffer(org.eclipse.persistence.internal.oxm.StrBuffer)

Aggregations

EclipseLinkException (org.eclipse.persistence.exceptions.EclipseLinkException)1 MappingNodeValue (org.eclipse.persistence.internal.oxm.MappingNodeValue)1 NodeValue (org.eclipse.persistence.internal.oxm.NodeValue)1 StrBuffer (org.eclipse.persistence.internal.oxm.StrBuffer)1 XPathNode (org.eclipse.persistence.internal.oxm.XPathNode)1 SAXParseException (org.xml.sax.SAXParseException)1