jdk.internal.org.xml.sax.SAXParseException Java Examples

The following examples show how to use jdk.internal.org.xml.sax.SAXParseException. 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: PropertiesDefaultHandler.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes)
    throws SAXException
{
    if (rootElem < 2) {
        rootElem++;
    }

    if (rootElm == null) {
        fatalError(new SAXParseException("An XML properties document must contain"
                + " the DOCTYPE declaration as defined by java.util.Properties.", null));
    }

    if (rootElem == 1 && !rootElm.equals(qName)) {
        fatalError(new SAXParseException("Document root element \"" + qName
                + "\", must match DOCTYPE root \"" + rootElm + "\"", null));
    }
    if (!ALLOWED_ELEMENTS.contains(qName)) {
        fatalError(new SAXParseException("Element type \"" + qName + "\" must be declared.", null));
    }
    if (qName.equals(ELEMENT_ENTRY)) {
        validEntry = true;
        key = attributes.getValue(ATTR_KEY);
        if (key == null) {
            fatalError(new SAXParseException("Attribute \"key\" is required and must be specified for element type \"entry\"", null));
        }
    } else if (qName.equals(ALLOWED_COMMENT)) {
        if (sawComment) {
            fatalError(new SAXParseException("Only one comment element may be allowed. "
                    + "The content of element type \"properties\" must match \"(comment?,entry*)\"", null));
        }
        sawComment = true;
    }
}
 
Example #2
Source File: PropertiesDefaultHandler.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes)
    throws SAXException
{
    if (rootElem < 2) {
        rootElem++;
    }

    if (rootElm == null) {
        fatalError(new SAXParseException("An XML properties document must contain"
                + " the DOCTYPE declaration as defined by java.util.Properties.", null));
    }

    if (rootElem == 1 && !rootElm.equals(qName)) {
        fatalError(new SAXParseException("Document root element \"" + qName
                + "\", must match DOCTYPE root \"" + rootElm + "\"", null));
    }
    if (!ALLOWED_ELEMENTS.contains(qName)) {
        fatalError(new SAXParseException("Element type \"" + qName + "\" must be declared.", null));
    }
    if (qName.equals(ELEMENT_ENTRY)) {
        validEntry = true;
        key = attributes.getValue(ATTR_KEY);
        if (key == null) {
            fatalError(new SAXParseException("Attribute \"key\" is required and must be specified for element type \"entry\"", null));
        }
    } else if (qName.equals(ALLOWED_COMMENT)) {
        if (sawComment) {
            fatalError(new SAXParseException("Only one comment element may be allowed. "
                    + "The content of element type \"properties\" must match \"(comment?,entry*)\"", null));
        }
        sawComment = true;
    }
}
 
Example #3
Source File: PropertiesDefaultHandler.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes)
    throws SAXException
{
    if (rootElem < 2) {
        rootElem++;
    }

    if (rootElm == null) {
        fatalError(new SAXParseException("An XML properties document must contain"
                + " the DOCTYPE declaration as defined by java.util.Properties.", null));
    }

    if (rootElem == 1 && !rootElm.equals(qName)) {
        fatalError(new SAXParseException("Document root element \"" + qName
                + "\", must match DOCTYPE root \"" + rootElm + "\"", null));
    }
    if (!ALLOWED_ELEMENTS.contains(qName)) {
        fatalError(new SAXParseException("Element type \"" + qName + "\" must be declared.", null));
    }
    if (qName.equals(ELEMENT_ENTRY)) {
        validEntry = true;
        key = attributes.getValue(ATTR_KEY);
        if (key == null) {
            fatalError(new SAXParseException("Attribute \"key\" is required and must be specified for element type \"entry\"", null));
        }
    } else if (qName.equals(ALLOWED_COMMENT)) {
        if (sawComment) {
            fatalError(new SAXParseException("Only one comment element may be allowed. "
                    + "The content of element type \"properties\" must match \"(comment?,entry*)\"", null));
        }
        sawComment = true;
    }
}
 
Example #4
Source File: PropertiesDefaultHandler.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes)
    throws SAXException
{
    if (rootElem < 2) {
        rootElem++;
    }

    if (rootElm == null) {
        fatalError(new SAXParseException("An XML properties document must contain"
                + " the DOCTYPE declaration as defined by java.util.Properties.", null));
    }

    if (rootElem == 1 && !rootElm.equals(qName)) {
        fatalError(new SAXParseException("Document root element \"" + qName
                + "\", must match DOCTYPE root \"" + rootElm + "\"", null));
    }
    if (!ALLOWED_ELEMENTS.contains(qName)) {
        fatalError(new SAXParseException("Element type \"" + qName + "\" must be declared.", null));
    }
    if (qName.equals(ELEMENT_ENTRY)) {
        validEntry = true;
        key = attributes.getValue(ATTR_KEY);
        if (key == null) {
            fatalError(new SAXParseException("Attribute \"key\" is required and must be specified for element type \"entry\"", null));
        }
    } else if (qName.equals(ALLOWED_COMMENT)) {
        if (sawComment) {
            fatalError(new SAXParseException("Only one comment element may be allowed. "
                    + "The content of element type \"properties\" must match \"(comment?,entry*)\"", null));
        }
        sawComment = true;
    }
}
 
Example #5
Source File: PropertiesDefaultHandler.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void endElement(String uri, String localName, String qName) throws SAXException {
    if (!ALLOWED_ELEMENTS.contains(qName)) {
        fatalError(new SAXParseException("Element: " + qName + " is invalid, must match  \"(comment?,entry*)\".", null));
    }

    if (validEntry) {
        properties.setProperty(key, buf.toString());
        buf.delete(0, buf.length());
        validEntry = false;
    }
}
 
Example #6
Source File: PropertiesDefaultHandler.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes)
    throws SAXException
{
    if (rootElem < 2) {
        rootElem++;
    }

    if (rootElm == null) {
        fatalError(new SAXParseException("An XML properties document must contain"
                + " the DOCTYPE declaration as defined by java.util.Properties.", null));
    }

    if (rootElem == 1 && !rootElm.equals(qName)) {
        fatalError(new SAXParseException("Document root element \"" + qName
                + "\", must match DOCTYPE root \"" + rootElm + "\"", null));
    }
    if (!ALLOWED_ELEMENTS.contains(qName)) {
        fatalError(new SAXParseException("Element type \"" + qName + "\" must be declared.", null));
    }
    if (qName.equals(ELEMENT_ENTRY)) {
        validEntry = true;
        key = attributes.getValue(ATTR_KEY);
        if (key == null) {
            fatalError(new SAXParseException("Attribute \"key\" is required and must be specified for element type \"entry\"", null));
        }
    } else if (qName.equals(ALLOWED_COMMENT)) {
        if (sawComment) {
            fatalError(new SAXParseException("Only one comment element may be allowed. "
                    + "The content of element type \"properties\" must match \"(comment?,entry*)\"", null));
        }
        sawComment = true;
    }
}
 
Example #7
Source File: PropertiesDefaultHandler.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes)
    throws SAXException
{
    if (rootElem < 2) {
        rootElem++;
    }

    if (rootElm == null) {
        fatalError(new SAXParseException("An XML properties document must contain"
                + " the DOCTYPE declaration as defined by java.util.Properties.", null));
    }

    if (rootElem == 1 && !rootElm.equals(qName)) {
        fatalError(new SAXParseException("Document root element \"" + qName
                + "\", must match DOCTYPE root \"" + rootElm + "\"", null));
    }
    if (!ALLOWED_ELEMENTS.contains(qName)) {
        fatalError(new SAXParseException("Element type \"" + qName + "\" must be declared.", null));
    }
    if (qName.equals(ELEMENT_ENTRY)) {
        validEntry = true;
        key = attributes.getValue(ATTR_KEY);
        if (key == null) {
            fatalError(new SAXParseException("Attribute \"key\" is required and must be specified for element type \"entry\"", null));
        }
    } else if (qName.equals(ALLOWED_COMMENT)) {
        if (sawComment) {
            fatalError(new SAXParseException("Only one comment element may be allowed. "
                    + "The content of element type \"properties\" must match \"(comment?,entry*)\"", null));
        }
        sawComment = true;
    }
}
 
Example #8
Source File: PropertiesDefaultHandler.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void endElement(String uri, String localName, String qName) throws SAXException {
    if (!ALLOWED_ELEMENTS.contains(qName)) {
        fatalError(new SAXParseException("Element: " + qName + " is invalid, must match  \"(comment?,entry*)\".", null));
    }

    if (validEntry) {
        properties.setProperty(key, buf.toString());
        buf.delete(0, buf.length());
        validEntry = false;
    }
}
 
Example #9
Source File: PropertiesDefaultHandler.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes)
    throws SAXException
{
    if (rootElem < 2) {
        rootElem++;
    }

    if (rootElm == null) {
        fatalError(new SAXParseException("An XML properties document must contain"
                + " the DOCTYPE declaration as defined by java.util.Properties.", null));
    }

    if (rootElem == 1 && !rootElm.equals(qName)) {
        fatalError(new SAXParseException("Document root element \"" + qName
                + "\", must match DOCTYPE root \"" + rootElm + "\"", null));
    }
    if (!ALLOWED_ELEMENTS.contains(qName)) {
        fatalError(new SAXParseException("Element type \"" + qName + "\" must be declared.", null));
    }
    if (qName.equals(ELEMENT_ENTRY)) {
        validEntry = true;
        key = attributes.getValue(ATTR_KEY);
        if (key == null) {
            fatalError(new SAXParseException("Attribute \"key\" is required and must be specified for element type \"entry\"", null));
        }
    } else if (qName.equals(ALLOWED_COMMENT)) {
        if (sawComment) {
            fatalError(new SAXParseException("Only one comment element may be allowed. "
                    + "The content of element type \"properties\" must match \"(comment?,entry*)\"", null));
        }
        sawComment = true;
    }
}
 
Example #10
Source File: PropertiesDefaultHandler.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void endElement(String uri, String localName, String qName) throws SAXException {
    if (!ALLOWED_ELEMENTS.contains(qName)) {
        fatalError(new SAXParseException("Element: " + qName + " is invalid, must match  \"(comment?,entry*)\".", null));
    }

    if (validEntry) {
        properties.setProperty(key, buf.toString());
        buf.delete(0, buf.length());
        validEntry = false;
    }
}
 
Example #11
Source File: PropertiesDefaultHandler.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes)
    throws SAXException
{
    if (rootElem < 2) {
        rootElem++;
    }

    if (rootElm == null) {
        fatalError(new SAXParseException("An XML properties document must contain"
                + " the DOCTYPE declaration as defined by java.util.Properties.", null));
    }

    if (rootElem == 1 && !rootElm.equals(qName)) {
        fatalError(new SAXParseException("Document root element \"" + qName
                + "\", must match DOCTYPE root \"" + rootElm + "\"", null));
    }
    if (!ALLOWED_ELEMENTS.contains(qName)) {
        fatalError(new SAXParseException("Element type \"" + qName + "\" must be declared.", null));
    }
    if (qName.equals(ELEMENT_ENTRY)) {
        validEntry = true;
        key = attributes.getValue(ATTR_KEY);
        if (key == null) {
            fatalError(new SAXParseException("Attribute \"key\" is required and must be specified for element type \"entry\"", null));
        }
    } else if (qName.equals(ALLOWED_COMMENT)) {
        if (sawComment) {
            fatalError(new SAXParseException("Only one comment element may be allowed. "
                    + "The content of element type \"properties\" must match \"(comment?,entry*)\"", null));
        }
        sawComment = true;
    }
}
 
Example #12
Source File: PropertiesDefaultHandler.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void endElement(String uri, String localName, String qName) throws SAXException {
    if (!ALLOWED_ELEMENTS.contains(qName)) {
        fatalError(new SAXParseException("Element: " + qName + " is invalid, must match  \"(comment?,entry*)\".", null));
    }

    if (validEntry) {
        properties.setProperty(key, buf.toString());
        buf.delete(0, buf.length());
        validEntry = false;
    }
}
 
Example #13
Source File: PropertiesDefaultHandler.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void endElement(String uri, String localName, String qName) throws SAXException {
    if (!ALLOWED_ELEMENTS.contains(qName)) {
        fatalError(new SAXParseException("Element: " + qName + " is invalid, must match  \"(comment?,entry*)\".", null));
    }

    if (validEntry) {
        properties.setProperty(key, buf.toString());
        buf.delete(0, buf.length());
        validEntry = false;
    }
}
 
Example #14
Source File: PropertiesDefaultHandler.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void endElement(String uri, String localName, String qName) throws SAXException {
    if (!ALLOWED_ELEMENTS.contains(qName)) {
        fatalError(new SAXParseException("Element: " + qName + " is invalid, must match  \"(comment?,entry*)\".", null));
    }

    if (validEntry) {
        properties.setProperty(key, buf.toString());
        buf.delete(0, buf.length());
        validEntry = false;
    }
}
 
Example #15
Source File: PropertiesDefaultHandler.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes)
    throws SAXException
{
    if (sawRoot) {
        if (!ALLOWED_ELEMENTS.contains(qName)) {
            fatalError(new SAXParseException("Element type \"" + qName + "\" must be declared.", null));
        }
    } else {
        // check whether the root has been declared in the DTD
        if (rootElm == null) {
            fatalError(new SAXParseException("An XML properties document must contain"
                + " the DOCTYPE declaration as defined by java.util.Properties.", null));
        }

        // check whether the element name matches the declaration
        if (!rootElm.equals(qName)) {
            fatalError(new SAXParseException("Document root element \"" + qName
                + "\", must match DOCTYPE root \"" + rootElm + "\"", null));
        }

        // this is a valid root element
        sawRoot = true;
    }

    if (qName.equals(ELEMENT_ENTRY)) {
        validEntry = true;
        key = attributes.getValue(ATTR_KEY);
        if (key == null) {
            fatalError(new SAXParseException("Attribute \"key\" is required and " +
                "must be specified for element type \"entry\"", null));
        }
    } else if (qName.equals(ALLOWED_COMMENT)) {
        if (sawComment) {
            fatalError(new SAXParseException("Only one comment element may be allowed. "
                + "The content of element type \"properties\" must match \"(comment?,entry*)\"", null));
        }
        sawComment = true;
    }
}
 
Example #16
Source File: PropertiesDefaultHandler.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
@Override
public void endElement(String uri, String localName, String qName) throws SAXException {
    if (!ALLOWED_ELEMENTS.contains(qName) && !ELEMENT_ROOT.equals(qName)) {
        fatalError(new SAXParseException("Element: " + qName +
            " is invalid, must match  \"(comment?,entry*)\".", null));
    }

    if (validEntry) {
        properties.setProperty(key, buf.toString());
        buf.delete(0, buf.length());
        validEntry = false;
    }
}
 
Example #17
Source File: PropertiesDefaultHandler.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
@Override
public void startInternalSub () throws SAXException
{
    fatalError(new SAXParseException("Internal DTD subset is not allowed. " +
        "The Properties XML document must have the following DOCTYPE declaration: \n" +
        PROPS_DTD_DECL, null));
}
 
Example #18
Source File: PropertiesDefaultHandler.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void endElement(String uri, String localName, String qName) throws SAXException {
    if (!ALLOWED_ELEMENTS.contains(qName)) {
        fatalError(new SAXParseException("Element: " + qName + " is invalid, must match  \"(comment?,entry*)\".", null));
    }

    if (validEntry) {
        properties.setProperty(key, buf.toString());
        buf.delete(0, buf.length());
        validEntry = false;
    }
}
 
Example #19
Source File: PropertiesDefaultHandler.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes)
    throws SAXException
{
    if (rootElem < 2) {
        rootElem++;
    }

    if (rootElm == null) {
        fatalError(new SAXParseException("An XML properties document must contain"
                + " the DOCTYPE declaration as defined by java.util.Properties.", null));
    }

    if (rootElem == 1 && !rootElm.equals(qName)) {
        fatalError(new SAXParseException("Document root element \"" + qName
                + "\", must match DOCTYPE root \"" + rootElm + "\"", null));
    }
    if (!ALLOWED_ELEMENTS.contains(qName)) {
        fatalError(new SAXParseException("Element type \"" + qName + "\" must be declared.", null));
    }
    if (qName.equals(ELEMENT_ENTRY)) {
        validEntry = true;
        key = attributes.getValue(ATTR_KEY);
        if (key == null) {
            fatalError(new SAXParseException("Attribute \"key\" is required and must be specified for element type \"entry\"", null));
        }
    } else if (qName.equals(ALLOWED_COMMENT)) {
        if (sawComment) {
            fatalError(new SAXParseException("Only one comment element may be allowed. "
                    + "The content of element type \"properties\" must match \"(comment?,entry*)\"", null));
        }
        sawComment = true;
    }
}
 
Example #20
Source File: PropertiesDefaultHandler.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes)
    throws SAXException
{
    if (rootElem < 2) {
        rootElem++;
    }

    if (rootElm == null) {
        fatalError(new SAXParseException("An XML properties document must contain"
                + " the DOCTYPE declaration as defined by java.util.Properties.", null));
    }

    if (rootElem == 1 && !rootElm.equals(qName)) {
        fatalError(new SAXParseException("Document root element \"" + qName
                + "\", must match DOCTYPE root \"" + rootElm + "\"", null));
    }
    if (!ALLOWED_ELEMENTS.contains(qName)) {
        fatalError(new SAXParseException("Element type \"" + qName + "\" must be declared.", null));
    }
    if (qName.equals(ELEMENT_ENTRY)) {
        validEntry = true;
        key = attributes.getValue(ATTR_KEY);
        if (key == null) {
            fatalError(new SAXParseException("Attribute \"key\" is required and must be specified for element type \"entry\"", null));
        }
    } else if (qName.equals(ALLOWED_COMMENT)) {
        if (sawComment) {
            fatalError(new SAXParseException("Only one comment element may be allowed. "
                    + "The content of element type \"properties\" must match \"(comment?,entry*)\"", null));
        }
        sawComment = true;
    }
}
 
Example #21
Source File: PropertiesDefaultHandler.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void fatalError(SAXParseException x) throws SAXException {
    throw x;
}
 
Example #22
Source File: PropertiesDefaultHandler.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void fatalError(SAXParseException x) throws SAXException {
    throw x;
}
 
Example #23
Source File: ParserSAX.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Notifies the handler about fatal parsing error.
 *
 * @param msg The problem description message.
 */
protected void panic(String msg) throws SAXException {
    SAXParseException spe = new SAXParseException(msg, this);
    mHandErr.fatalError(spe);
    throw spe;  // [#1.2] fatal error definition
}
 
Example #24
Source File: PropertiesDefaultHandler.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void warning(SAXParseException x) throws SAXException {
    throw x;
}
 
Example #25
Source File: ParserSAX.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Notifies the handler about fatal parsing error.
 *
 * @param msg The problem description message.
 */
protected void panic(String msg) throws SAXException {
    SAXParseException spe = new SAXParseException(msg, this);
    mHandErr.fatalError(spe);
    throw spe;  // [#1.2] fatal error definition
}
 
Example #26
Source File: PropertiesDefaultHandler.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void warning(SAXParseException x) throws SAXException {
    throw x;
}
 
Example #27
Source File: PropertiesDefaultHandler.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void warning(SAXParseException x) throws SAXException {
    throw x;
}
 
Example #28
Source File: ParserSAX.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Notifies the handler about fatal parsing error.
 *
 * @param msg The problem description message.
 */
protected void panic(String msg) throws SAXException {
    SAXParseException spe = new SAXParseException(msg, this);
    mHandErr.fatalError(spe);
    throw spe;  // [#1.2] fatal error definition
}
 
Example #29
Source File: PropertiesDefaultHandler.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void error(SAXParseException x) throws SAXException {
    throw x;
}
 
Example #30
Source File: PropertiesDefaultHandler.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void warning(SAXParseException x) throws SAXException {
    throw x;
}