/** * Build a configuration object using an XML InputSource object * @param input an <code>InputSource</code> value * @return a <code>Configuration</code> object * @throws SAXException if a parsing error occurs * @throws IOException if an I/O error occurs * @throws ConfigurationException if an error occurs */ public Configuration build( final InputSource input ) throws SAXException, IOException, ConfigurationException { synchronized( this ) { m_handler.clear(); m_parser.parse( input ); return m_handler.getConfiguration(); } }
/** Replace {vars} in element bodies. */ public void characters( final char[] ch, int start, int len ) throws SAXException { StringBuffer buf = new StringBuffer(); if (start!=0) buf.append(ch, 0, start-1); String newVal = interp(new String(ch,start, len)); buf.append(newVal); buf.append(ch, start+len, ch.length-(start+len)); super.characters(buf.toString().toCharArray(), start, newVal.length()); }
/** * Handling hook for ending the document parsing. * * @throws SAXException if an error occurs */ public void endDocument() throws SAXException { super.endDocument(); m_namespaceSupport.reset(); }
/** * */ private Configuration readRefreshJobConfiguration() { Source source = null; SAXConfigurationHandler b = new SAXConfigurationHandler(); try { if (this.configFile.exists()) { source = this.resolver.resolveURI(this.configFile.toURL().toString()); SourceUtil.toSAX(this.manager, source, source.getMimeType(), b); } } catch (Exception ignore) { getLogger().warn("Unable to read configuration from " + this.configFile); } finally { if (source != null) { this.resolver.release(source); } } return b.getConfiguration(); }
/** * Get a SAXConfigurationHandler for your configuration reading. * @return a <code>SAXConfigurationHandler</code> */ protected SAXConfigurationHandler getHandler() { try { if( m_parser.getFeature( "http://xml.org/sax/features/namespaces" ) ) { return new NamespacedSAXConfigurationHandler(); } } catch( Exception e ) { // ignore error and fall through to the non-namespaced version } return new SAXConfigurationHandler(); }
createConfiguration( rawName, getLocationString() );
/** * Handling hook for starting the document parsing. * * @throws SAXException if an error occurs */ public void startDocument() throws SAXException { m_namespaceSupport.reset(); super.startDocument(); }
/** Replace {vars} in attributes. */ public void startElement(String uri, String localName, String qName, Attributes attr) throws SAXException { AttributesImpl newAttr = new AttributesImpl(attr); for (int i=0; i<attr.getLength(); i++) { newAttr.setValue(i, interp(attr.getValue(i))); } super.startElement(uri, localName, qName, newAttr); }
SAXConfigurationHandler builder = new SAXConfigurationHandler(); SourceUtil.parse(this.manager, resource, builder); conf.configuration = builder.getConfiguration();
SAXConfigurationHandler builder = new SAXConfigurationHandler(); SourceUtil.toSAX(source, builder); conf.configuration = builder.getConfiguration();
/** * Build a configuration object from a file using a File object. * @param file a <code>File</code> object * @return a <code>Configuration</code> object * @throws SAXException if a parsing error occurs * @throws IOException if an I/O error occurs * @throws ConfigurationException if an error occurs */ public Configuration buildFromFile( final File file ) throws SAXException, IOException, ConfigurationException { synchronized( this ) { m_handler.clear(); m_parser.parse( file.toURL().toString() ); return m_handler.getConfiguration(); } }
Source src = resolver.resolveURI(url); try { SAXConfigurationHandler handler = new SAXConfigurationHandler(); SourceUtil.toSAX(this.manager, src, null, handler); config = handler.getConfiguration(); } finally { resolver.release(src);