Java 类javax.xml.stream.XMLReporter 实例源码

项目:commons-scxml    文件:SCXMLReader.java   
/**
 * Report an ignored element via the {@link XMLReporter} if available and the class
 * {@link org.apache.commons.logging.Log}.
 *
 * @param reader The {@link XMLStreamReader} providing the SCXML document to parse.
 * @param configuration The {@link Configuration} to use while parsing.
 * @param parent The parent element local name in the SCXML namespace.
 * @param nsURI The namespace URI of the ignored element.
 * @param name The local name of the ignored element.
 *
 * @throws XMLStreamException An exception processing the underlying {@link XMLStreamReader}.
 * @throws ModelException The Commons SCXML object model is incomplete or inconsistent (includes
 *                        errors in the SCXML document that may not be identified by the schema).
 */
private static void reportIgnoredElement(final XMLStreamReader reader, final Configuration configuration,
                                         final String parent, final String nsURI, final String name)
        throws XMLStreamException, ModelException {

    StringBuilder sb = new StringBuilder();
    sb.append("Ignoring unknown or invalid element <").append(name)
            .append("> in namespace \"").append(nsURI)
            .append("\" as child of <").append(parent)
            .append("> at ").append(reader.getLocation());
    if (!configuration.isSilent() && logger.isWarnEnabled()) {
        logger.warn(sb.toString());
    }
    if (configuration.isStrict()) {
        throw new ModelException(sb.toString());
    }
    XMLReporter reporter = configuration.reporter;
    if (reporter != null) {
        reporter.report(sb.toString(), "COMMONS_SCXML", null, reader.getLocation());
    }
    skipToEndElement(reader);
}
项目:commons-scxml    文件:SCXMLReader.java   
/**
 * Report an ignored attribute via the {@link XMLReporter} if available and
 * {@link org.apache.commons.logging.Log}.
 *
 * @param reader The {@link XMLStreamReader} providing the SCXML document to parse.
 * @param configuration The {@link Configuration} to use while parsing.
 * @param element The element name.
 * @param attr The attribute which is ignored.
 * @param value The value of the attribute which is ignored.
 *
 * @throws XMLStreamException An exception processing the underlying {@link XMLStreamReader}.
 * @throws ModelException The Commons SCXML object model is incomplete or inconsistent (includes
 *                        errors in the SCXML document that may not be identified by the schema).
 */
private static void reportIgnoredAttribute(final XMLStreamReader reader, final Configuration configuration,
                                           final String element, final String attr, final String value)
        throws XMLStreamException, ModelException {

    StringBuilder sb = new StringBuilder();
    sb.append("Ignoring unknown or invalid <").append(element).append("> attribute ").append(attr)
            .append("=\"").append(value).append("\" at ").append(reader.getLocation());
    if (!configuration.isSilent() && logger.isWarnEnabled()) {
        logger.warn(sb.toString());
    }
    if (configuration.isStrict()) {
        throw new ModelException(sb.toString());
    }
    XMLReporter reporter = configuration.reporter;
    if (reporter != null) {
        reporter.report(sb.toString(), "COMMONS_SCXML", null, reader.getLocation());
    }
}
项目:commons-scxml    文件:SCXMLReader.java   
/**
 * Report a conflicting attribute via the {@link XMLReporter} if available and
 * {@link org.apache.commons.logging.Log}.
 *
 * @param reader The {@link XMLStreamReader} providing the SCXML document to parse.
 * @param configuration The {@link Configuration} to use while parsing.
 * @param element The element name.
 * @param attr The attribute with which a conflict is detected.
 * @param conflictingAttr The conflicting attribute
 *
 * @throws XMLStreamException An exception processing the underlying {@link XMLStreamReader}.
 * @throws ModelException The Commons SCXML object model is incomplete or inconsistent (includes
 *                        errors in the SCXML document that may not be identified by the schema).
 */
private static void reportConflictingAttribute(final XMLStreamReader reader, final Configuration configuration,
                                         final String element, final String attr, final String conflictingAttr)
        throws XMLStreamException, ModelException {

    StringBuilder sb = new StringBuilder();
    sb.append("Ignoring <").append(element).append("> attribute \"").append(conflictingAttr)
            .append("\" which conflicts with already defined attribute \"").append(attr)
            .append("\" at ").append(reader.getLocation());
    if (!configuration.isSilent() && logger.isWarnEnabled()) {
        logger.warn(sb.toString());
    }
    if (configuration.isStrict()) {
        throw new ModelException(sb.toString());
    }
    XMLReporter reporter = configuration.reporter;
    if (reporter != null) {
        reporter.report(sb.toString(), "COMMONS_SCXML", null, reader.getLocation());
    }
}
项目:woodstox    文件:StreamScanner.java   
protected void _reportProblem(XMLReporter rep, XMLValidationProblem prob)
    throws XMLStreamException
{
    if (rep != null) {
        Location loc = prob.getLocation();
        if (loc == null) {
            loc = getLastCharLocation();
            prob.setLocation(loc);
        }
        // Backwards-compatibility fix: add non-null type, if missing:
        if (prob.getType() == null) {
            prob.setType(ErrorConsts.WT_VALIDATION);
        }
        // [WSTX-154]: was catching and dropping thrown exception: shouldn't.
        // [WTSX-157]: need to support XMLReporter2
        if (rep instanceof XMLReporter2) {
            ((XMLReporter2) rep).report(prob);
        } else {
            rep.report(prob.getMessage(), prob.getType(), prob, loc);
        }
    }
}
项目:woodstox    文件:BaseStreamWriter.java   
protected void doReportProblem(XMLReporter rep, XMLValidationProblem prob)
    throws XMLStreamException
{
    if (rep != null) {
        Location loc = prob.getLocation();
        if (loc == null) {
            loc = getLocation();
            prob.setLocation(loc);
        }
        // Backwards-compatibility fix: add non-null type, if missing:
        if (prob.getType() == null) {
            prob.setType(ErrorConsts.WT_VALIDATION);
        }
        // [WSTX-154]: was catching and dropping thrown exception: shouldn't.
        rep.report(prob.getMessage(), prob.getType(), prob, loc);
    }
}
项目:scaleDOM    文件:StaxXmlParser.java   
@Override
public void setErrorHandler(final ErrorHandler eh) {
    checkNotNull(eh, "Argument eh must not be null.");

    inputFactory.setXMLReporter(new XMLReporter() {
        @Override
        public void report(final String message, final String errorType, final Object relatedInformation,
                final Location location) throws XMLStreamException {
            try {
                eh.error(new SAXParseException(message, location.getPublicId(), location.getSystemId(), location
                        .getLineNumber(), location.getColumnNumber()));
            } catch (final SAXException ex) {
                throw new XMLStreamException(ex);
            }
        }
    });
}
项目:javify    文件:XMLInputFactoryImpl.java   
public void setProperty(String name, Object value)
  throws IllegalArgumentException
{
  if (name.equals(IS_NAMESPACE_AWARE))
    namespaceAware = ((Boolean) value).booleanValue();
  else if (name.equals(IS_VALIDATING))
    validating = ((Boolean) value).booleanValue();
  else if (name.equals(IS_COALESCING))
    coalescing = ((Boolean) value).booleanValue();
  else if (name.equals(IS_REPLACING_ENTITY_REFERENCES))
    replacingEntityReferences = ((Boolean) value).booleanValue();
  else if (name.equals(IS_SUPPORTING_EXTERNAL_ENTITIES))
    externalEntities = ((Boolean) value).booleanValue();
  else if (name.equals(SUPPORT_DTD))
    supportDTD = ((Boolean) value).booleanValue();
  else if (name.equals(REPORTER))
    reporter = (XMLReporter) value;
  else if (name.equals(RESOLVER))
    resolver = (XMLResolver) value;
  else if (name.equals(ALLOCATOR))
    allocator = (XMLEventAllocator) value;
  else if (name.equals("gnu.xml.stream.stringInterning"))
    stringInterning = ((Boolean) value).booleanValue();
  else if (name.equals("gnu.xml.stream.baseAware"))
    baseAware = ((Boolean) value).booleanValue();
  else if (name.equals("gnu.xml.stream.xIncludeAware"))
    xIncludeAware = ((Boolean) value).booleanValue();
  else
    throw new IllegalArgumentException(name);
}
项目:jvm-stm    文件:XMLInputFactoryImpl.java   
public void setProperty(String name, Object value)
  throws IllegalArgumentException
{
  if (name.equals(IS_NAMESPACE_AWARE))
    namespaceAware = ((Boolean) value).booleanValue();
  else if (name.equals(IS_VALIDATING))
    validating = ((Boolean) value).booleanValue();
  else if (name.equals(IS_COALESCING))
    coalescing = ((Boolean) value).booleanValue();
  else if (name.equals(IS_REPLACING_ENTITY_REFERENCES))
    replacingEntityReferences = ((Boolean) value).booleanValue();
  else if (name.equals(IS_SUPPORTING_EXTERNAL_ENTITIES))
    externalEntities = ((Boolean) value).booleanValue();
  else if (name.equals(SUPPORT_DTD))
    supportDTD = ((Boolean) value).booleanValue();
  else if (name.equals(REPORTER))
    reporter = (XMLReporter) value;
  else if (name.equals(RESOLVER))
    resolver = (XMLResolver) value;
  else if (name.equals(ALLOCATOR))
    allocator = (XMLEventAllocator) value;
  else if (name.equals("gnu.xml.stream.stringInterning"))
    stringInterning = ((Boolean) value).booleanValue();
  else if (name.equals("gnu.xml.stream.baseAware"))
    baseAware = ((Boolean) value).booleanValue();
  else if (name.equals("gnu.xml.stream.xIncludeAware"))
    xIncludeAware = ((Boolean) value).booleanValue();
  else
    throw new IllegalArgumentException(name);
}
项目:woodstox    文件:StreamScanner.java   
public void reportProblem(String probType, String format, Object arg, Object arg2)
    throws XMLStreamException
{
    XMLReporter rep = mConfig.getXMLReporter();
    if (rep != null) {
        _reportProblem(rep, probType,
                        MessageFormat.format(format, new Object[] { arg, arg2 }), null);
    }
}
项目:woodstox    文件:StreamScanner.java   
@Override
public void reportProblem(Location loc, String probType,
                          String format, Object arg, Object arg2)
    throws XMLStreamException
{
    XMLReporter rep = mConfig.getXMLReporter();
    if (rep != null) {
        String msg = (arg != null || arg2 != null) ?
            MessageFormat.format(format, new Object[] { arg, arg2 }) : format;
        _reportProblem(rep, probType, msg, loc);
    }
}
项目:woodstox    文件:StreamScanner.java   
protected void _reportProblem(XMLReporter rep, String probType, String msg, Location loc)
    throws XMLStreamException
{
    if (loc == null) {
        loc = getLastCharLocation();
    }
    _reportProblem(rep, new XMLValidationProblem(loc, msg, XMLValidationProblem.SEVERITY_ERROR, probType));
}
项目:woodstox    文件:StreamScanner.java   
/**
 *<p>
 * Note: this is the base implementation used for implementing
 * <code>ValidationContext</code>
 */
@Override
public void reportValidationProblem(XMLValidationProblem prob)
    throws XMLStreamException
{
    // !!! TBI: Fail-fast vs. deferred modes?
    /* For now let's implement basic functionality: warnings get
     * reported via XMLReporter, errors and fatal errors result in
     * immediate exceptions.
     */
    /* 27-May-2008, TSa: [WSTX-153] Above is incorrect: as per Stax
     *   javadocs for XMLReporter, both warnings and non-fatal errors
     *   (which includes all validation errors) should be reported via
     *   XMLReporter interface, and only fatals should cause an
     *   immediate stream exception (by-passing reporter)
     */
    if (prob.getSeverity() > XMLValidationProblem.SEVERITY_ERROR) {
        throw WstxValidationException.create(prob);
    }
    XMLReporter rep = mConfig.getXMLReporter();
    if (rep != null) {
        _reportProblem(rep, prob);
    } else {
        /* If no reporter, regular non-fatal errors are to be reported
         * as exceptions as well, for backwards compatibility
         */
        if (prob.getSeverity() >= XMLValidationProblem.SEVERITY_ERROR) {
            throw WstxValidationException.create(prob);
        }
    }
}
项目:woodstox    文件:FullDTDReader.java   
private void _reportWarning(XMLReporter rep, String probType, String msg,
                           Location loc)
    throws XMLStreamException
{
    if (rep != null) {
        /* Note: since the problem occurs at DTD (schema) parsing,
         * not during validation, can not set reporter.
         */
        XMLValidationProblem prob = new XMLValidationProblem
            (loc, msg, XMLValidationProblem.SEVERITY_WARNING, probType);
        rep.report(msg, probType, prob, loc);
    }
}
项目:woodstox    文件:BaseStreamWriter.java   
@Override
public void reportProblem(XMLValidationProblem prob)
    throws XMLStreamException
{
    // Custom handler set? If so, it'll take care of it:
    if (mVldProbHandler != null) {
        mVldProbHandler.reportProblem(prob);
        return;
    }

    /* For now let's implement basic functionality: warnings get
     * reported via XMLReporter, errors and fatal errors result in
     * immediate exceptions.
     */
    /* 27-May-2008, TSa: [WSTX-153] Above is incorrect: as per Stax
     *   javadocs for XMLReporter, both warnings and non-fatal errors
     *   (which includes all validation errors) should be reported via
     *   XMLReporter interface, and only fatals should cause an
     *   immediate stream exception (by-passing reporter)
     */
    if (prob.getSeverity() > XMLValidationProblem.SEVERITY_ERROR) {
        throw WstxValidationException.create(prob);
    }
    XMLReporter rep = mConfig.getProblemReporter();
    if (rep != null) {
        doReportProblem(rep, prob);
    } else {
        /* If no reporter, regular non-fatal errors are to be reported
         * as exceptions as well, for backwards compatibility
         */
        if (prob.getSeverity() >= XMLValidationProblem.SEVERITY_ERROR) {
            throw WstxValidationException.create(prob);
        }
    }
}
项目:woodstox    文件:BaseStreamWriter.java   
protected void doReportProblem(XMLReporter rep, String probType, String msg, Location loc)
    throws XMLStreamException
{
    if (loc == null) {
        loc = getLocation();
    }
    doReportProblem(rep, new XMLValidationProblem(loc, msg, XMLValidationProblem.SEVERITY_ERROR, probType));
}
项目:woodstox    文件:ReaderBootstrapper.java   
protected void verifyXmlEncoding(ReaderConfig cfg)
    throws XMLStreamException
{
    String inputEnc = mInputEncoding;

    // Close enough?
    if (StringUtil.equalEncodings(inputEnc, mFoundEncoding)) {
        return;
    }

    /* Ok, maybe the difference is just with endianness indicator?
     * (UTF-16BE vs. UTF-16)?
     */
    // !!! TBI

    XMLReporter rep = cfg.getXMLReporter();
    if (rep != null) {
        Location loc = getLocation();
        String msg = MessageFormat.format(ErrorConsts.W_MIXED_ENCODINGS,
                                          new Object[] { mFoundEncoding,
                                                         inputEnc });
        String type = ErrorConsts.WT_XML_DECL;
        /* 30-May-2008, tatus: Should wrap all the info as XMValidationProblem
         *    since that's Woodstox' contract wrt. relatedInformation field.
         */
        XMLValidationProblem prob = new XMLValidationProblem(loc, msg, XMLValidationProblem.SEVERITY_WARNING, type);
        rep.report(msg, type, prob, loc);
    }
}
项目:JamVM-PH    文件:XMLInputFactoryImpl.java   
public void setProperty(String name, Object value)
  throws IllegalArgumentException
{
  if (name.equals(IS_NAMESPACE_AWARE))
    namespaceAware = ((Boolean) value).booleanValue();
  else if (name.equals(IS_VALIDATING))
    validating = ((Boolean) value).booleanValue();
  else if (name.equals(IS_COALESCING))
    coalescing = ((Boolean) value).booleanValue();
  else if (name.equals(IS_REPLACING_ENTITY_REFERENCES))
    replacingEntityReferences = ((Boolean) value).booleanValue();
  else if (name.equals(IS_SUPPORTING_EXTERNAL_ENTITIES))
    externalEntities = ((Boolean) value).booleanValue();
  else if (name.equals(SUPPORT_DTD))
    supportDTD = ((Boolean) value).booleanValue();
  else if (name.equals(REPORTER))
    reporter = (XMLReporter) value;
  else if (name.equals(RESOLVER))
    resolver = (XMLResolver) value;
  else if (name.equals(ALLOCATOR))
    allocator = (XMLEventAllocator) value;
  else if (name.equals("gnu.xml.stream.stringInterning"))
    stringInterning = ((Boolean) value).booleanValue();
  else if (name.equals("gnu.xml.stream.baseAware"))
    baseAware = ((Boolean) value).booleanValue();
  else if (name.equals("gnu.xml.stream.xIncludeAware"))
    xIncludeAware = ((Boolean) value).booleanValue();
  else
    throw new IllegalArgumentException(name);
}
项目:classpath    文件:XMLInputFactoryImpl.java   
public void setProperty(String name, Object value)
  throws IllegalArgumentException
{
  if (name.equals(IS_NAMESPACE_AWARE))
    namespaceAware = ((Boolean) value).booleanValue();
  else if (name.equals(IS_VALIDATING))
    validating = ((Boolean) value).booleanValue();
  else if (name.equals(IS_COALESCING))
    coalescing = ((Boolean) value).booleanValue();
  else if (name.equals(IS_REPLACING_ENTITY_REFERENCES))
    replacingEntityReferences = ((Boolean) value).booleanValue();
  else if (name.equals(IS_SUPPORTING_EXTERNAL_ENTITIES))
    externalEntities = ((Boolean) value).booleanValue();
  else if (name.equals(SUPPORT_DTD))
    supportDTD = ((Boolean) value).booleanValue();
  else if (name.equals(REPORTER))
    reporter = (XMLReporter) value;
  else if (name.equals(RESOLVER))
    resolver = (XMLResolver) value;
  else if (name.equals(ALLOCATOR))
    allocator = (XMLEventAllocator) value;
  else if (name.equals("gnu.xml.stream.stringInterning"))
    stringInterning = ((Boolean) value).booleanValue();
  else if (name.equals("gnu.xml.stream.baseAware"))
    baseAware = ((Boolean) value).booleanValue();
  else if (name.equals("gnu.xml.stream.xIncludeAware"))
    xIncludeAware = ((Boolean) value).booleanValue();
  else
    throw new IllegalArgumentException(name);
}
项目:OpenJSharp    文件:SAX2StAXBaseWriter.java   
public SAX2StAXBaseWriter(XMLReporter reporter) {
        this.reporter = reporter;
}
项目:OpenJSharp    文件:SAX2StAXBaseWriter.java   
public void setXMLReporter(XMLReporter reporter) {
        this.reporter = reporter;
}
项目:OpenJSharp    文件:StaxErrorReporter.java   
/**
 *One must call reset before using any of the function.
 */
public void reset(PropertyManager propertyManager){
    fXMLReporter = (XMLReporter)propertyManager.getProperty(XMLInputFactory.REPORTER);
}
项目:openjdk-jdk10    文件:SAX2StAXBaseWriter.java   
public SAX2StAXBaseWriter(XMLReporter reporter) {
        this.reporter = reporter;
}
项目:openjdk-jdk10    文件:SAX2StAXBaseWriter.java   
public void setXMLReporter(XMLReporter reporter) {
        this.reporter = reporter;
}
项目:openjdk-jdk10    文件:StaxErrorReporter.java   
/**
 *One must call reset before using any of the function.
 */
public void reset(PropertyManager propertyManager){
    fXMLReporter = (XMLReporter)propertyManager.getProperty(XMLInputFactory.REPORTER);
}
项目:openjdk-jdk10    文件:MyInputFactory.java   
@Override
public XMLReporter getXMLReporter() {
    throw new UnsupportedOperationException("Not supported yet.");
}
项目:openjdk-jdk10    文件:MyInputFactory.java   
@Override
public void setXMLReporter(XMLReporter reporter) {
    throw new UnsupportedOperationException("Not supported yet.");
}
项目:openjdk-jdk10    文件:XMLInputFactoryWrapper.java   
@Override
public XMLReporter getXMLReporter() {
    return defaultImpl.getXMLReporter();
}
项目:openjdk-jdk10    文件:XMLInputFactoryWrapper.java   
@Override
public void setXMLReporter(XMLReporter reporter) {
    defaultImpl.setXMLReporter(reporter);
}
项目:openjdk-jdk10    文件:XMLInputFactoryImpl.java   
@Override
public XMLReporter getXMLReporter() {
    return null;
}
项目:openjdk9    文件:SAX2StAXBaseWriter.java   
public SAX2StAXBaseWriter(XMLReporter reporter) {
        this.reporter = reporter;
}
项目:openjdk9    文件:SAX2StAXBaseWriter.java   
public void setXMLReporter(XMLReporter reporter) {
        this.reporter = reporter;
}
项目:openjdk9    文件:StaxErrorReporter.java   
/**
 *One must call reset before using any of the function.
 */
public void reset(PropertyManager propertyManager){
    fXMLReporter = (XMLReporter)propertyManager.getProperty(XMLInputFactory.REPORTER);
}
项目:openjdk9    文件:MyInputFactory.java   
@Override
public XMLReporter getXMLReporter() {
    throw new UnsupportedOperationException("Not supported yet.");
}
项目:openjdk9    文件:MyInputFactory.java   
@Override
public void setXMLReporter(XMLReporter reporter) {
    throw new UnsupportedOperationException("Not supported yet.");
}
项目:openjdk9    文件:XMLInputFactoryImpl.java   
@Override
public XMLReporter getXMLReporter() {
    return null;
}
项目:lookaside_java-1.8.0-openjdk    文件:SAX2StAXBaseWriter.java   
public SAX2StAXBaseWriter(XMLReporter reporter) {
        this.reporter = reporter;
}
项目:lookaside_java-1.8.0-openjdk    文件:SAX2StAXBaseWriter.java   
public void setXMLReporter(XMLReporter reporter) {
        this.reporter = reporter;
}
项目:lookaside_java-1.8.0-openjdk    文件:StaxErrorReporter.java   
/**
 *One must call reset before using any of the function.
 */
public void reset(PropertyManager propertyManager){
    fXMLReporter = (XMLReporter)propertyManager.getProperty(XMLInputFactory.REPORTER);
}
项目:javify    文件:XMLInputFactoryImpl.java   
public XMLReporter getXMLReporter()
{
  return reporter;
}
项目:javify    文件:XMLInputFactoryImpl.java   
public void setXMLReporter(XMLReporter reporter)
{
  this.reporter = reporter;
}