/** * Returns the object for this element. * * @return the object. */ public Object getObject() { return getResult(); } }
protected void startParsing( final Attributes attrs ) throws SAXException { super.startParsing( attrs ); final int length = attrs.getLength(); for ( int i = 0; i < length; i++ ) { attributes.setAttribute( attrs.getURI( i ), attrs.getLocalName( i ), attrs.getValue( i ) ); } }
protected XmlReadHandler getHandlerForChild( final String uri, final String tagName, final Attributes atts ) throws SAXException { if ( isSameNamespace( uri ) == false ) { return null; } if ( "alias".equals( tagName ) ) { final StringReadHandler rh = new StringReadHandler(); aliasReadHandlers.add( rh ); return rh; } return null; }
protected void doneParsing() throws SAXException { super.doneParsing(); try { final NamespaceCollection namespaceCollection = StyleSheetParserUtil.getInstance().getNamespaceCollection(); final SelectorList selectorList = StyleSheetParserUtil.getInstance().parseSelector( namespaceCollection, getResult() ); for ( int i = 0; i < selectorList.getLength(); i += 1 ) { selector.add( (CSSSelector) selectorList.item( i ) ); } } catch ( CSSParseException e ) { throw new ParseException( "Failed to parse selector", e, getLocator() ); } }
/** * Done parsing. * * @throws SAXException * if there is a parsing error. */ protected void doneParsing() throws SAXException { super.doneParsing(); if ( nullValue ) { value = null; return; } try { value = ConverterRegistry.toPropertyValue( getResult(), type ); } catch ( BeanException e ) { try { value = ConverterRegistry.toPropertyValue( getResult().trim(), type ); } catch ( BeanException ex ) { throw new ParseException( "Unable to convert value '" + getResult() + "' into a object of type '" + type + "'.", ex, getLocator() ); } } }
public String getQuery() { if ( query == null ) { return null; } return query.getResult(); } }
protected void startParsing( final Attributes attrs ) throws SAXException { super.startParsing( attrs ); name = attrs.getValue( getUri(), "name" ); if ( name == null ) { throw new SAXException( "Required attribute 'name' is missing." ); } namespace = attrs.getValue( getUri(), "namespace" ); if ( namespace == null ) { throw new SAXException( "Required attribute 'namespace' is missing." ); } }
/** * Returns the handler for a child element. * * @param tagName * the tag name. * @param atts * the attributes. * @return the handler or null, if the tagname is invalid. * @throws org.xml.sax.SAXException * if there is a parsing error. */ protected XmlReadHandler getHandlerForChild( final String uri, final String tagName, final Attributes atts ) throws SAXException { if ( getUri().equals( uri ) == false ) { return null; } if ( "field".equals( tagName ) ) { final StringReadHandler readHandler = new StringReadHandler(); fieldHandlers.add( readHandler ); return readHandler; } return null; }
/** * Done parsing. * * @throws org.xml.sax.SAXException * if there is a parsing error. */ protected void doneParsing() throws SAXException { final int size = fieldHandlers.size(); fields = new String[size]; for ( int i = 0; i < size; i++ ) { final StringReadHandler readHandler = fieldHandlers.get( i ); fields[i] = readHandler.getResult(); } }
/** * Starts parsing. * * @param attrs the attributes. * @throws SAXException if there is a parsing error. */ protected void startParsing( final Attributes attrs ) throws SAXException { super.startParsing( attrs ); name = attrs.getValue( getUri(), nameAttribute ); if ( nameMandatory && name == null ) { throw new ParseException( "Required attribute '" + nameAttribute + "' missing", getLocator() ); } }
protected XmlReadHandler getHandlerForChild( final String uri, final String tagName, final Attributes atts ) throws SAXException { if ( isSameNamespace( uri ) == false ) { return null; } if ( "static-query".equals( tagName ) ) { query = new StringReadHandler(); return query; } if ( "script".equals( tagName ) ) { script = new PropertyReadHandler( "language", false ); return script; } return null; }
/** * Done parsing. * * @throws SAXException * if there is a parsing error. */ protected void doneParsing() throws SAXException { final Iterator it = fieldHandlers.entrySet().iterator(); while ( it.hasNext() ) { final Map.Entry entry = (Map.Entry) it.next(); final String key = (String) entry.getKey(); final StringReadHandler readHandler = (StringReadHandler) entry.getValue(); configuration.setConfigProperty( key, readHandler.getResult() ); } }
/** * Starts parsing. * * @param attrs * the attributes. * @throws SAXException * if there is a parsing error. */ protected void startParsing( final Attributes attrs ) throws SAXException { super.startParsing( attrs ); if ( "true".equals( attrs.getValue( getUri(), "null" ) ) ) { nullValue = true; } // redefine the declared type. Do not care whether the type will be compatible with the global one, // this is the user's problem. final String type = attrs.getValue( getUri(), "type" ); if ( type != null ) { try { final ClassLoader loader = ObjectUtilities.getClassLoader( AbstractXmlReadHandler.class ); this.type = Class.forName( CompatibilityMapperUtil.mapClassName( type ), false, loader ); } catch ( ClassNotFoundException e ) { throw new ParseException( "Required attribute 'type' is not valid.", getLocator() ); } } }
/** * Returns the handler for a child element. * * @param tagName * the tag name. * @param atts * the attributes. * @return the handler or null, if the tagname is invalid. * @throws SAXException * if there is a parsing error. */ protected XmlReadHandler getHandlerForChild( final String uri, final String tagName, final Attributes atts ) throws SAXException { if ( isSameNamespace( uri ) == false ) { return null; } if ( "driver".equals( tagName ) ) { driverReadHandler = new StringReadHandler(); return driverReadHandler; } if ( "url".equals( tagName ) ) { urlReadHandler = new StringReadHandler(); return urlReadHandler; } if ( "properties".equals( tagName ) ) { propertiesReadHandler = new PasswordPropertiesReadHandler(); return propertiesReadHandler; } return null; }
protected void doneParsing() throws SAXException { for ( int i = 0; i < aliasReadHandlers.size(); i++ ) { final StringReadHandler readHandler = aliasReadHandlers.get( i ); getBuilder().alias( readHandler.getResult() ); } }
/** * Returns the handler for a child element. * * @param tagName * the tag name. * @param atts * the attributes. * @return the handler or null, if the tagname is invalid. * @throws SAXException * if there is a parsing error. */ protected XmlReadHandler getHandlerForChild( final String uri, final String tagName, final Attributes atts ) throws SAXException { if ( isSameNamespace( uri ) == false ) { return null; } if ( "path".equals( tagName ) ) { pathReadHandler = new StringReadHandler(); return pathReadHandler; } if ( "username".equals( tagName ) ) { usernameReadHandler = new StringReadHandler(); return usernameReadHandler; } if ( "password".equals( tagName ) ) { passwordReadHandler = new PasswordReadHandler(); return passwordReadHandler; } return null; }
/** * Done parsing. * * @throws SAXException * if there is a parsing error. */ protected void doneParsing() throws SAXException { final JndiConnectionProvider provider = new JndiConnectionProvider(); if ( pathReadHandler != null ) { provider.setConnectionPath( pathReadHandler.getResult() ); } if ( usernameReadHandler != null ) { provider.setUsername( usernameReadHandler.getResult() ); } if ( passwordReadHandler != null ) { provider.setPassword( passwordReadHandler.getResult() ); } this.connectionProvider = provider; }
/** * Returns the handler for a child element. * * @param uri * the namespace. * @param tagName * the tag name. * @param attrs * the attributes. * @return the handler or null, if the tagname is invalid. * @throws SAXException * if there is a parsing error. */ protected XmlReadHandler getHandlerForChild( final String uri, final String tagName, final Attributes attrs ) throws SAXException { if ( isSameNamespace( uri ) == false ) { return null; } if ( "property".equals( tagName ) ) { final String name = attrs.getValue( getUri(), "name" ); if ( name == null ) { throw new SAXException( "Required attribute 'name' is missing." ); } final StringReadHandler readHandler = new StringReadHandler(); fieldHandlers.put( name, readHandler ); return readHandler; } return null; }
/** * Done parsing. * * @throws SAXException * if there is a parsing error. */ protected void doneParsing() throws SAXException { final DriverConnectionProvider provider = new DriverConnectionProvider(); if ( driverReadHandler != null ) { provider.setDriver( driverReadHandler.getResult() ); } if ( urlReadHandler != null ) { provider.setUrl( urlReadHandler.getResult() ); } if ( propertiesReadHandler != null ) { final Properties p = (Properties) propertiesReadHandler.getObject(); final Iterator it = p.entrySet().iterator(); while ( it.hasNext() ) { final Map.Entry entry = (Map.Entry) it.next(); provider.setProperty( (String) entry.getKey(), (String) entry.getValue() ); } } driverConnectionProvider = provider; }
fieldReadHandler = new StringReadHandler();