Example usage for javax.xml.parsers SAXParser getClass

List of usage examples for javax.xml.parsers SAXParser getClass

Introduction

In this page you can find the example usage for javax.xml.parsers SAXParser getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:jcurl.core.io.SetupSaxDeSer.java

private static synchronized SAXParser newParser() throws SAXException {
    if (spf == null) {
        spf = SAXParserFactory.newInstance();
        // http://www.cafeconleche.org/slides/xmlone/london2002/namespaces/36.html
        // http://xml.apache.org/xerces-j/features.html
        // spf.setFeature("http://xml.org/sax/features/namespaces", true);
        // spf.setFeature("http://xml.org/sax/features/namespace-prefixes",
        // true);
        spf.setNamespaceAware(true);/*  w w  w. jav a 2 s  .c  o m*/
        spf.setValidating(false);
    }
    try {
        final SAXParser sp = spf.newSAXParser();
        if (log.isDebugEnabled())
            log.debug(sp.getClass().getName());
        return sp;
    } catch (ParserConfigurationException e) {
        throw new RuntimeException(e);
    }
}

From source file:net.sf.jasperreports.engine.xml.BaseSaxParserFactory.java

protected void enableSchemaCaching(SAXParser parser) {
    String parserType = parser.getClass().getName();
    if (parserType.startsWith(PACKAGE_PREFIX_XERCES)) {
        setGrammarPoolProperty(parser, POOL_CLASS_XERCES);
    } else if (parserType.startsWith(PACKAGE_PREFIX_SUN_XERCES)) {
        setGrammarPoolProperty(parser, POOL_CLASS_SUN_XERCES);
    } else {//from   ww w  . ja  v  a  2 s. co  m
        if (log.isDebugEnabled()) {
            log.debug("Schema caching only works with Xerces parsers");
        }
    }
}

From source file:org.apache.axis.client.HappyClient.java

/**
 * what parser are we using.//from  w w  w  .  ja  v  a 2 s. c  om
 * @return the classname of the parser
 */
private String getParserName() {
    SAXParser saxParser = getSAXParser();
    if (saxParser == null) {
        return Messages.getMessage("happyClientNoParser");
    }

    // check to what is in the classname
    String saxParserName = saxParser.getClass().getName();
    return saxParserName;
}

From source file:org.apache.axis.client.HappyClient.java

/**
 * get the location of the parser//from  w  w  w  .j  a va2 s  .  co  m
 * @return path or null for trouble in tracking it down
 */

private String getParserLocation() {
    SAXParser saxParser = getSAXParser();
    if (saxParser == null) {
        return null;
    }
    String location = getLocation(saxParser.getClass());
    return location;
}

From source file:org.apache.jsp.happyaxis_jsp.java

/**
 * what parser are we using./* www.  j a v  a2 s.c o  m*/
 * @return the classname of the parser
 */
private String getParserName() {
    SAXParser saxParser = getSAXParser();
    if (saxParser == null) {
        return getMessage("couldNotCreateParser");
    }

    // check to what is in the classname
    String saxParserName = saxParser.getClass().getName();
    return saxParserName;
}

From source file:org.apache.jsp.happyaxis_jsp.java

/**
 * get the location of the parser//from   w ww .  j ava2s  .c o m
 * @return path or null for trouble in tracking it down
 */

private String getParserLocation(JspWriter out) {
    SAXParser saxParser = getSAXParser();
    if (saxParser == null) {
        return null;
    }
    String location = getLocation(out, saxParser.getClass());
    return location;
}

From source file:org.apache.tomcat.util.digester.GenericParser.java

/**
 * Create a <code>SAXParser</code> configured to support XML Scheman and DTD
 * @param properties parser specific properties/features
 * @return an XML Schema/DTD enabled <code>SAXParser</code>
 *///w  w w  . j  a  v  a2 s  . c  o  m
public static SAXParser newSAXParser(Properties properties)
        throws ParserConfigurationException, SAXException, SAXNotRecognizedException {

    SAXParserFactory factory = (SAXParserFactory) properties.get("SAXParserFactory");
    SAXParser parser = factory.newSAXParser();
    String schemaLocation = (String) properties.get("schemaLocation");
    String schemaLanguage = (String) properties.get("schemaLanguage");

    try {
        if (schemaLocation != null) {
            parser.setProperty(JAXP_SCHEMA_LANGUAGE, schemaLanguage);
            parser.setProperty(JAXP_SCHEMA_SOURCE, schemaLocation);
        }
    } catch (SAXNotRecognizedException e) {
        log.info(parser.getClass().getName() + ": " + e.getMessage() + " not supported.");
    }
    return parser;
}

From source file:org.apache.tomcat.util.digester.XercesParser.java

/**
 * Configure schema validation as recommended by the JAXP 1.2 spec.
 * The <code>properties</code> object may contains information about
 * the schema local and language. // ww w  .  ja va 2 s.com
 * @param properties parser optional info
 */
private static void configureOldXerces(SAXParser parser, Properties properties)
        throws ParserConfigurationException, SAXNotSupportedException {

    String schemaLocation = (String) properties.get("schemaLocation");
    String schemaLanguage = (String) properties.get("schemaLanguage");

    try {
        if (schemaLocation != null) {
            parser.setProperty(JAXP_SCHEMA_LANGUAGE, schemaLanguage);
            parser.setProperty(JAXP_SCHEMA_SOURCE, schemaLocation);
        }
    } catch (SAXNotRecognizedException e) {
        log.info(parser.getClass().getName() + ": " + e.getMessage() + " not supported.");
    }

}

From source file:org.attoparser.benchmark.AttoParserVSStandardSAXBenchmark.java

private static String getSAXParserClassName() throws Exception {
    final SAXParserFactory parserFactory = SAXParserFactory.newInstance();
    final SAXParser parser = parserFactory.newSAXParser();
    return parser.getClass().getName();
}

From source file:org.jcurl.core.io.SetupSaxDeSer.java

private static synchronized SAXParser newParser() throws SAXException {
    if (spf == null) {
        spf = SAXParserFactory.newInstance();
        // http://www.cafeconleche.org/slides/xmlone/london2002/namespaces/36.html
        // http://xml.apache.org/xerces-j/features.html
        // spf.setFeature("http://xml.org/sax/features/namespaces", true);
        // spf.setFeature("http://xml.org/sax/features/namespace-prefixes",
        // true);
        spf.setNamespaceAware(true);/*from  ww w  . ja v  a 2  s. c  o m*/
        spf.setValidating(false);
    }
    try {
        final SAXParser sp = spf.newSAXParser();
        if (log.isDebugEnabled())
            log.debug(sp.getClass().getName());
        return sp;
    } catch (final ParserConfigurationException e) {
        throw new RuntimeException(e);
    }
}