예제 #1
0
  /** @see org.castor.xml.InternalContext#getXMLReader(java.lang.String) */
  public XMLReader getXMLReader(final String features) {
    XMLReader reader = null;
    Boolean validation = _configuration.getBoolean(XMLConfiguration.PARSER_VALIDATION);
    Boolean namespaces = _configuration.getBoolean(XMLConfiguration.NAMESPACES);

    String readerClassName = _configuration.getString(XMLConfiguration.PARSER);

    if (readerClassName == null || readerClassName.length() == 0) {
      SAXParser saxParser =
          XMLParserUtils.getSAXParser(validation.booleanValue(), namespaces.booleanValue());
      if (saxParser != null) {
        try {
          reader = saxParser.getXMLReader();
        } catch (SAXException e) {
          LOG.error(Messages.format("conf.configurationError", e));
        }
      }
    }

    if (reader == null) {
      if ((readerClassName == null)
          || (readerClassName.length() == 0)
          || (readerClassName.equalsIgnoreCase("xerces"))) {
        readerClassName = "org.apache.xerces.parsers.SAXParser";
      }

      reader = XMLParserUtils.instantiateXMLReader(readerClassName);
    }

    XMLParserUtils.setFeaturesOnXmlReader(
        _configuration.getString(XMLConfiguration.PARSER_FEATURES, features),
        _configuration.getString(XMLConfiguration.PARSER_FEATURES_DISABLED, ""),
        validation.booleanValue(),
        namespaces.booleanValue(),
        reader);

    return reader;
  } // -- getXMLReader
예제 #2
0
 /**
  * Returns the currently configured XMLSerializerFactory instance.
  *
  * @param serializerFactoryName the class name of the serializer factory
  * @return XMLSerializerFactory to use by Castor
  */
 protected XMLSerializerFactory getSerializerFactory(final String serializerFactoryName) {
   return XMLParserUtils.getSerializerFactory(serializerFactoryName);
 }
예제 #3
0
 /** @see org.castor.xml.InternalContext#getOutputFormat() */
 public OutputFormat getOutputFormat() {
   return XMLParserUtils.getOutputFormat(_configuration);
 }
예제 #4
0
 /** @see org.castor.xml.InternalContext#getSerializer() */
 public Serializer getSerializer() {
   return XMLParserUtils.getSerializer(_configuration);
 }
예제 #5
0
 /** @see org.castor.xml.InternalContext#getParser(java.lang.String) */
 public Parser getParser(final String features) {
   return XMLParserUtils.getParser(_configuration, features);
 }
예제 #6
0
 /**
  * {@inheritDoc}
  *
  * @see org.castor.xml.InternalContext#getSerializer()
  */
 public Serializer getSerializer() {
   return XMLParserUtils.getSerializer(_properties);
 }
예제 #7
0
 /**
  * {@inheritDoc}
  *
  * @see org.castor.xml.InternalContext#getParser(java.lang.String)
  */
 public Parser getParser(final String features) {
   return XMLParserUtils.getParser(_properties, features);
 }