avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-avalon/src/java/org/apache/avalon/configuration SAXConfigurationHandler.java
Date Thu, 15 Mar 2001 04:41:52 GMT
donaldp     01/03/14 20:41:52

  Modified:    src/java/org/apache/avalon/configuration
                        SAXConfigurationHandler.java
  Log:
  Made interface more useful if constructing configurations by hand.
  
  Revision  Changes    Path
  1.2       +21 -12    jakarta-avalon/src/java/org/apache/avalon/configuration/SAXConfigurationHandler.java
  
  Index: SAXConfigurationHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon/src/java/org/apache/avalon/configuration/SAXConfigurationHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SAXConfigurationHandler.java	2001/02/24 04:00:14	1.1
  +++ SAXConfigurationHandler.java	2001/03/15 04:41:52	1.2
  @@ -29,6 +29,7 @@
       protected final ArrayList              m_elements        = new ArrayList();
       protected Configuration                m_configuration;
       protected Locator                      m_locator;
  +    protected String                       m_value;
   
       public Configuration getConfiguration()
       {
  @@ -52,24 +53,32 @@
           final String value = (new String( ch, start, end )).trim();
   
           if( value.equals( "" ) ) return;
  -        
  -        final DefaultConfiguration configuration = 
  -            (DefaultConfiguration)m_elements.get( m_elements.size() - 1 );
  -
  -        if( 0 != configuration.getChildCount() )
  -        {
  -            throw new SAXException( "Not allowed to define mixed content in the " +
  -                                    "element " + configuration.getName() + " at " +
  -                                    configuration.getLocation() );
  -        }
   
  -        configuration.appendValueData( value );
  +        if( null == m_value ) m_value = value;
  +        else m_value += value;
       }
   
       public void endElement( final String namespaceURI, 
                               final String localName,
                               final String rawName ) 
  +        throws SAXException 
       {
  +        if( null != m_value ) 
  +        {        
  +            final DefaultConfiguration configuration =
  +                (DefaultConfiguration)m_elements.get( m_elements.size() - 1 );
  +            
  +            if( 0 != configuration.getChildCount() )
  +            {
  +                throw new SAXException( "Not allowed to define mixed content in the " +
  +                                        "element " + configuration.getName() + " at " +
  +                                        configuration.getLocation() );
  +            }
  +
  +            configuration.setValue( m_value );
  +            m_value = null;
  +        }
  +
           final int location = m_elements.size() - 1;
           final Object object = m_elements.remove( location );
           
  @@ -118,7 +127,7 @@
           {
               final String name = attributes.getQName( i );
               final String value = attributes.getValue( i );
  -            configuration.addAttribute( name, value );
  +            configuration.setAttribute( name, value );
           }
       }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: avalon-dev-help@jakarta.apache.org


Mime
View raw message