com.sun.org.apache.xerces.internal.xni.XMLString Java Examples

The following examples show how to use com.sun.org.apache.xerces.internal.xni.XMLString. 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: XIncludeHandler.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
@Override
public void processingInstruction(
    String target,
    XMLString data,
    Augmentations augs)
    throws XNIException {
    if (!fInDTD) {
        if (fDocumentHandler != null
            && getState() == STATE_NORMAL_PROCESSING) {
            // we need to change the depth like this so that modifyAugmentations() works
            fDepth++;
            augs = modifyAugmentations(augs);
            fDocumentHandler.processingInstruction(target, data, augs);
            fDepth--;
        }
    }
    else if (fDTDHandler != null) {
        fDTDHandler.processingInstruction(target, data, augs);
    }
}
 
Example #2
Source File: XIncludeHandler.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void processingInstruction(
    String target,
    XMLString data,
    Augmentations augs)
    throws XNIException {
    if (!fInDTD) {
        if (fDocumentHandler != null
            && getState() == STATE_NORMAL_PROCESSING) {
            // we need to change the depth like this so that modifyAugmentations() works
            fDepth++;
            augs = modifyAugmentations(augs);
            fDocumentHandler.processingInstruction(target, data, augs);
            fDepth--;
        }
    }
    else if (fDTDHandler != null) {
        fDTDHandler.processingInstruction(target, data, augs);
    }
}
 
Example #3
Source File: ValidatorHandlerImpl.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
public void characters(XMLString text, Augmentations augs)
        throws XNIException {
    if (fContentHandler != null) {
        // if the type is union it is possible that we receive
        // a character call with empty data
        if (text.length == 0) {
            return;
        }
        try {
            fContentHandler.characters(text.ch, text.offset, text.length);
        }
        catch (SAXException e) {
            throw new XNIException(e);
        }
    }
}
 
Example #4
Source File: XIncludeHandler.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void comment(XMLString text, Augmentations augs)
    throws XNIException {
    if (!fInDTD) {
        if (fDocumentHandler != null
            && getState() == STATE_NORMAL_PROCESSING) {
            fDepth++;
            augs = modifyAugmentations(augs);
            fDocumentHandler.comment(text, augs);
            fDepth--;
        }
    }
    else if (fDTDHandler != null) {
        fDTDHandler.comment(text, augs);
    }
}
 
Example #5
Source File: XMLScanner.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private void init() {
    // initialize scanner
    fEntityScanner = null;
    // initialize vars
    fEntityDepth = 0;
    fReportEntity = true;
    fResourceIdentifier.clear();

    if(!fAttributeCacheInitDone){
        for(int i = 0; i < initialCacheCount; i++){
            attributeValueCache.add(new XMLString());
            stringBufferCache.add(new XMLStringBuffer());
        }
        fAttributeCacheInitDone = true;
    }
    fStringBufferIndex = 0;
    fAttributeCacheUsedCount = 0;

}
 
Example #6
Source File: DTDGrammar.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * An internal entity declaration.
 *
 * @param name The name of the entity. Parameter entity names start with
 *             '%', whereas the name of a general entity is just the
 *             entity name.
 * @param text The value of the entity.
 * @param nonNormalizedText The non-normalized value of the entity. This
 *             value contains the same sequence of characters that was in
 *             the internal entity declaration, without any entity
 *             references expanded.
 * @param augs Additional information that may include infoset
 *                      augmentations.
 * @throws XNIException Thrown by handler to signal an error.
 */
public void internalEntityDecl(String name, XMLString text,
                               XMLString nonNormalizedText,
                               Augmentations augs) throws XNIException {

    int entityIndex = getEntityDeclIndex(name);
    if( entityIndex == -1){
        entityIndex = createEntityDecl();
        boolean isPE = name.startsWith("%");
        boolean inExternal = (fReadingExternalDTD || fPEDepth > 0);
        XMLEntityDecl  entityDecl = new XMLEntityDecl();
        entityDecl.setValues(name,null,null, null, null,
                             text.toString(), isPE, inExternal);

        setEntityDecl(entityIndex, entityDecl);
    }

}
 
Example #7
Source File: XML11DocumentScannerImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Normalize whitespace in an XMLString converting all whitespace
 * characters to space characters.
 */
protected void normalizeWhitespace(XMLString value) {
    int end = value.offset + value.length;
        for (int i = value.offset; i < end; ++i) {
       int c = value.ch[i];
       if (XMLChar.isSpace(c)) {
           value.ch[i] = ' ';
       }
   }
}
 
Example #8
Source File: XMLDocumentFragmentScannerImpl.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public XMLString getCharacterData(){
    if(fUsebuffer){
        return fContentBuffer ;
    }else{
        return fTempString;
    }

}
 
Example #9
Source File: XMLDocumentFragmentScannerImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/** this function gets an XMLString (which is used to store the attribute value) from the special pool
 *  maintained for attributes.
 *  fAttributeCacheUsedCount tracks the number of attributes that has been consumed from the pool.
 *  if all the attributes has been consumed, it adds a new XMLString inthe pool and returns the same
 *  XMLString.
 *
 * @return XMLString XMLString used to store an attribute value.
 */

protected XMLString getString(){
    if(fAttributeCacheUsedCount < initialCacheCount || fAttributeCacheUsedCount < attributeValueCache.size()){
        return attributeValueCache.get(fAttributeCacheUsedCount++);
    } else{
        XMLString str = new XMLString();
        fAttributeCacheUsedCount++;
        attributeValueCache.add(str);
        return str;
    }
}
 
Example #10
Source File: DOMResultAugmentor.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
public void characters(XMLString text, Augmentations augs)
        throws XNIException {
    if (!fIgnoreChars) {
        final Element currentElement = (Element) fDOMValidatorHelper.getCurrentElement();
        currentElement.appendChild(fDocument.createTextNode(text.toString()));
    }
}
 
Example #11
Source File: SAX2XNI.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void characters( char[] buf, int offset, int len ) throws SAXException {
    try {
        fCore.characters(new XMLString(buf,offset,len),null);
    } catch( WrappedSAXException e ) {
        throw e.exception;
    }
}
 
Example #12
Source File: XML11DocumentScannerImpl.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Checks whether this string would be unchanged by normalization.
 *
 * @return -1 if the value would be unchanged by normalization,
 * otherwise the index of the first whitespace character which
 * would be transformed.
 */
protected int isUnchangedByNormalization(XMLString value) {
    int end = value.offset + value.length;
    for (int i = value.offset; i < end; ++i) {
        int c = value.ch[i];
        if (XMLChar.isSpace(c)) {
            return i - value.offset;
        }
    }
    return -1;
}
 
Example #13
Source File: UnparsedEntityHandler.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void internalEntityDecl(String name, XMLString text,
        XMLString nonNormalizedText, Augmentations augmentations)
        throws XNIException {
    if (fDTDHandler != null) {
        fDTDHandler.internalEntityDecl(name, text,
                nonNormalizedText, augmentations);
    }
}
 
Example #14
Source File: SchemaDOM.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
void comment(XMLString text) {
    fAnnotationBuffer.append("<!--");
    if (text.length > 0) {
        fAnnotationBuffer.append(text.ch, text.offset, text.length);
    }
    fAnnotationBuffer.append("-->");
}
 
Example #15
Source File: DTDGrammarUtil.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public boolean isIgnorableWhiteSpace(XMLString text) {
    if (isInElementContent()) {
        for (int i = text.offset; i < text.offset + text.length; i++) {
            if (!XMLChar.isSpace(text.ch[i])) {
                return false;
            }
        }
        return true;
    }
    return false;
}
 
Example #16
Source File: XMLDocumentFragmentScannerImpl.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/** this function gets an XMLString (which is used to store the attribute value) from the special pool
 *  maintained for attributes.
 *  fAttributeCacheUsedCount tracks the number of attributes that has been consumed from the pool.
 *  if all the attributes has been consumed, it adds a new XMLString inthe pool and returns the same
 *  XMLString.
 *
 * @return XMLString XMLString used to store an attribute value.
 */

protected XMLString getString(){
    if(fAttributeCacheUsedCount < initialCacheCount || fAttributeCacheUsedCount < attributeValueCache.size()){
        return attributeValueCache.get(fAttributeCacheUsedCount++);
    } else{
        XMLString str = new XMLString();
        fAttributeCacheUsedCount++;
        attributeValueCache.add(str);
        return str;
    }
}
 
Example #17
Source File: ValidatorHandlerImpl.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
public void processingInstruction(String target, XMLString data,
        Augmentations augs) throws XNIException {
    if (fContentHandler != null) {
        try {
            fContentHandler.processingInstruction(target, data.toString());
        }
        catch (SAXException e) {
            throw new XNIException(e);
        }
    }
}
 
Example #18
Source File: UnparsedEntityHandler.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
public void attributeDecl(String elementName, String attributeName,
        String type, String[] enumeration, String defaultType,
        XMLString defaultValue, XMLString nonNormalizedDefaultValue,
        Augmentations augmentations) throws XNIException {
    if (fDTDHandler != null) {
        fDTDHandler.attributeDecl(elementName, attributeName,
                type, enumeration, defaultType,
                defaultValue, nonNormalizedDefaultValue,
                augmentations);
    }
}
 
Example #19
Source File: XMLDocumentFragmentScannerImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public XMLString getCharacterData(){
    if(fUsebuffer){
        return fContentBuffer ;
    }else{
        return fTempString;
    }

}
 
Example #20
Source File: XMLDTDProcessor.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * An internal entity declaration.
 *
 * @param name The name of the entity. Parameter entity names start with
 *             '%', whereas the name of a general entity is just the
 *             entity name.
 * @param text The value of the entity.
 * @param nonNormalizedText The non-normalized value of the entity. This
 *             value contains the same sequence of characters that was in
 *             the internal entity declaration, without any entity
 *             references expanded.
 * @param augs Additional information that may include infoset
 *                      augmentations.
 *
 * @throws XNIException Thrown by handler to signal an error.
 */
public void internalEntityDecl(String name, XMLString text,
                               XMLString nonNormalizedText,
                               Augmentations augs) throws XNIException {

    DTDGrammar grammar = (fDTDGrammar != null? fDTDGrammar: fGrammarBucket.getActiveGrammar());
    int index = grammar.getEntityDeclIndex(name) ;

    //If the same entity is declared more than once, the first declaration
    //encountered is binding, SAX requires only effective(first) declaration
    //to be reported to the application

    //REVISIT: Does it make sense to pass duplicate Entity information across
    //the pipeline -- nb?

    //its a new entity and hasn't been declared.
    if(index == -1){
        //store internal entity declaration in grammar
        if(fDTDGrammar != null)
            fDTDGrammar.internalEntityDecl(name, text, nonNormalizedText, augs);
        // call handlers
        if (fDTDHandler != null) {
            fDTDHandler.internalEntityDecl(name, text, nonNormalizedText, augs);
        }
    }

}
 
Example #21
Source File: XMLDTDProcessor.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * An internal entity declaration.
 *
 * @param name The name of the entity. Parameter entity names start with
 *             '%', whereas the name of a general entity is just the
 *             entity name.
 * @param text The value of the entity.
 * @param nonNormalizedText The non-normalized value of the entity. This
 *             value contains the same sequence of characters that was in
 *             the internal entity declaration, without any entity
 *             references expanded.
 * @param augs Additional information that may include infoset
 *                      augmentations.
 *
 * @throws XNIException Thrown by handler to signal an error.
 */
public void internalEntityDecl(String name, XMLString text,
                               XMLString nonNormalizedText,
                               Augmentations augs) throws XNIException {

    DTDGrammar grammar = (fDTDGrammar != null? fDTDGrammar: fGrammarBucket.getActiveGrammar());
    int index = grammar.getEntityDeclIndex(name) ;

    //If the same entity is declared more than once, the first declaration
    //encountered is binding, SAX requires only effective(first) declaration
    //to be reported to the application

    //REVISIT: Does it make sense to pass duplicate Entity information across
    //the pipeline -- nb?

    //its a new entity and hasn't been declared.
    if(index == -1){
        //store internal entity declaration in grammar
        if(fDTDGrammar != null)
            fDTDGrammar.internalEntityDecl(name, text, nonNormalizedText, augs);
        // call handlers
        if (fDTDHandler != null) {
            fDTDHandler.internalEntityDecl(name, text, nonNormalizedText, augs);
        }
    }

}
 
Example #22
Source File: XMLDocumentFragmentScannerImpl.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/** this function gets an XMLString (which is used to store the attribute value) from the special pool
 *  maintained for attributes.
 *  fAttributeCacheUsedCount tracks the number of attributes that has been consumed from the pool.
 *  if all the attributes has been consumed, it adds a new XMLString inthe pool and returns the same
 *  XMLString.
 *
 * @return XMLString XMLString used to store an attribute value.
 */

protected XMLString getString(){
    if(fAttributeCacheUsedCount < initialCacheCount ||
            fAttributeCacheUsedCount < attributeValueCache.size()){
        return attributeValueCache.get(fAttributeCacheUsedCount++);
    } else{
        XMLString str = new XMLString();
        fAttributeCacheUsedCount++;
        attributeValueCache.add(str);
        return str;
    }
}
 
Example #23
Source File: UnparsedEntityHandler.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
public void internalEntityDecl(String name, XMLString text,
        XMLString nonNormalizedText, Augmentations augmentations)
        throws XNIException {
    if (fDTDHandler != null) {
        fDTDHandler.internalEntityDecl(name, text,
                nonNormalizedText, augmentations);
    }
}
 
Example #24
Source File: SchemaDOM.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
void characters(XMLString text) {

        // escape characters if necessary
        if (!inCDATA) {
            final StringBuffer annotationBuffer = fAnnotationBuffer;
            for (int i = text.offset; i < text.offset+text.length; ++i) {
                char ch = text.ch[i];
                if (ch == '&') {
                    annotationBuffer.append("&amp;");
                }
                else if (ch == '<') {
                    annotationBuffer.append("&lt;");
                }
                // character sequence "]]>" cannot appear in content,
                // therefore we should escape '>'.
                else if (ch == '>') {
                    annotationBuffer.append("&gt;");
                }
                // If CR is part of the document's content, it
                // must not be printed as a literal otherwise
                // it would be normalized to LF when the document
                // is reparsed.
                else if (ch == '\r') {
                    annotationBuffer.append("&#xD;");
                }
                else {
                    annotationBuffer.append(ch);
                }
            }
        }
        else {
            fAnnotationBuffer.append(text.ch, text.offset, text.length);
        }
    }
 
Example #25
Source File: SAX2XNI.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
public void ignorableWhitespace( char[] buf, int offset, int len ) throws SAXException {
    try {
        fCore.ignorableWhitespace(new XMLString(buf,offset,len),null);
    } catch( WrappedSAXException e ) {
        throw e.exception;
    }
}
 
Example #26
Source File: SAX2XNI.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
private XMLString createXMLString(String str) {
    // with my patch
    // return new XMLString(str);

    // for now
    return new XMLString(str.toCharArray(), 0, str.length());
}
 
Example #27
Source File: JAXPValidatorComponent.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void ignorableWhitespace(char[] ch, int start, int len) throws SAXException {
    try {
        handler().ignorableWhitespace(new XMLString(ch,start,len),aug());
    } catch( XNIException e ) {
        throw toSAXException(e);
    }
}
 
Example #28
Source File: SAX2XNI.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
private XMLString createXMLString(String str) {
    // with my patch
    // return new XMLString(str);

    // for now
    return new XMLString(str.toCharArray(), 0, str.length());
}
 
Example #29
Source File: XMLDTDScannerImpl.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * Scans a processing data. This is needed to handle the situation
 * where a document starts with a processing instruction whose
 * target name <em>starts with</em> "xml". (e.g. xmlfoo)
 *
 * @param target The PI target
 * @param data The string to fill in with the data
 */
protected final void scanPIData(String target, XMLString data)
throws IOException, XNIException {
    //Venu REVISIT
    //      super.scanPIData(target, data);
    fMarkUpDepth--;

    // call handler
    if (fDTDHandler != null) {
        fDTDHandler.processingInstruction(target, data, null);
    }

}
 
Example #30
Source File: AbstractSAXParser.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * A processing instruction. Processing instructions consist of a
 * target name and, optionally, text data. The data is only meaningful
 * to the application.
 * <p>
 * Typically, a processing instruction's data will contain a series
 * of pseudo-attributes. These pseudo-attributes follow the form of
 * element attributes but are <strong>not</strong> parsed or presented
 * to the application as anything other than text. The application is
 * responsible for parsing the data.
 *
 * @param target The target.
 * @param data   The data or null if none specified.
 * @param augs     Additional information that may include infoset augmentations
 *
 * @throws XNIException Thrown by handler to signal an error.
 */
public void processingInstruction(String target, XMLString data, Augmentations augs)
    throws XNIException {

    //
    // REVISIT - I keep running into SAX apps that expect
    //   null data to be an empty string, which is contrary
    //   to the comment for this method in the SAX API.
    //

    try {
        // SAX1
        if (fDocumentHandler != null) {
            fDocumentHandler.processingInstruction(target,
                                                   data.toString());
        }

        // SAX2
        if (fContentHandler != null) {
            fContentHandler.processingInstruction(target, data.toString());
        }
    }
    catch (SAXException e) {
        throw new XNIException(e);
    }

}