@Override public String getStringProperty(final String propertyName) { return _properties.getString(propertyName); }
@Override public NodeType getPrimitiveNodeType() { if (_primitiveNodeType != null) { return _primitiveNodeType; } String prop = _properties.getString(XMLProperties.PRIMITIVE_NODE_TYPE, null); if (prop == null) { return null; } _primitiveNodeType = NodeType.getNodeType(prop); return _primitiveNodeType; }
@Override public XMLNaming getXMLNaming() { if (_xmlNaming != null) { return _xmlNaming; } String prop = _properties.getString(XMLProperties.XML_NAMING, null); setXMLNaming(prop); return _xmlNaming; }
@Override public RegExpEvaluator getRegExpEvaluator() { if (_regExpEvaluator != null) { return _regExpEvaluator; } String className = _properties.getString(XMLProperties.REG_EXP_CLASS_NAME, ""); if (className.length() == 0) { _regExpEvaluator = null; } else { try { Class<?> regExpEvalClass = Class.forName(className); _regExpEvaluator = (RegExpEvaluator) regExpEvalClass.newInstance(); } catch (ClassNotFoundException e) { throw new RuntimeException(Messages.format("conf.failedInstantiateRegExp", className, e)); } catch (InstantiationException e) { throw new RuntimeException(Messages.format("conf.failedInstantiateRegExp", className, e)); } catch (IllegalAccessException e) { throw new RuntimeException(Messages.format("conf.failedInstantiateRegExp", className, e)); } } return _regExpEvaluator; }
@Override public XMLReader getXMLReader(final String features) { XMLReader reader = null; Boolean validation = _properties.getBoolean(XMLProperties.PARSER_VALIDATION); Boolean namespaces = _properties.getBoolean(XMLProperties.NAMESPACES); String readerClassName = _properties.getString(XMLProperties.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( _properties.getString(XMLProperties.PARSER_FEATURES, features), _properties.getString(XMLProperties.PARSER_FEATURES_DISABLED, ""), validation.booleanValue(), namespaces.booleanValue(), reader); return reader; }
Boolean validation = properties.getBoolean(XMLProperties.PARSER_VALIDATION); Boolean namespaces = properties.getBoolean(XMLProperties.NAMESPACES); String parserClassName = properties.getString(XMLProperties.PARSER); if ((parserClassName == null) || (parserClassName.length() == 0)) { SAXParser saxParser = XMLReader xmlReader = (XMLReader) parser; XMLParserUtils.setFeaturesOnXmlReader( properties.getString(XMLProperties.PARSER_FEATURES, features), properties.getString(XMLProperties.PARSER_FEATURES_DISABLED, ""), validation.booleanValue(), namespaces.booleanValue(), xmlReader);
processNamespacePackageMappings(rtconf.getString(Property.NAMESPACE_PACKAGES_OLD, "")); processNamespacePackageMappings(rtconf.getString(Property.NAMESPACE_PACKAGES, "")); processNamespacePackageMappings(_defaultProps.getProperty(Property.NAMESPACE_PACKAGES_OLD, "")); processNamespacePackageMappings(_defaultProps.getProperty(Property.NAMESPACE_PACKAGES, ""));
/** * @see org.castor.xml.InternalContext#getSerializer() */ public static Serializer getSerializer(final AbstractProperties properties) { Serializer serializer = getSerializerFactory(properties.getString(XMLProperties.SERIALIZER_FACTORY)) .getSerializer(); serializer.setOutputFormat(getOutputFormat(properties)); return serializer; }
/** * @see org.castor.xml.InternalContext#getOutputFormat() */ public static OutputFormat getOutputFormat(final AbstractProperties properties) { boolean indent = properties.getBoolean(XMLProperties.USE_INDENTATION, false); String version = properties.getString(XMLProperties.XML_VERSION, "1.0"); OutputFormat format = getSerializerFactory(properties.getString(XMLProperties.SERIALIZER_FACTORY)) .getOutputFormat(); format.setMethod(OutputFormat.XML); format.setVersion(version); format.setIndenting(indent); // There is a bad interaction between the indentation and the // setPreserveSpace option. The indentated output is strangely indented. if (!indent) { format.setPreserveSpace(true); } return format; } // -- getOutputFormat