mirceatoma    2002/10/15 16:25:09

  Modified:    xmlutil/src/java/org/apache/excalibur/xml/sax
                        DocumentHandlerAdapter.java
  Log:
  Formatted code.
  
  Revision  Changes    Path
  1.2       +44 -35    
jakarta-avalon-excalibur/xmlutil/src/java/org/apache/excalibur/xml/sax/DocumentHandlerAdapter.java
  
  Index: DocumentHandlerAdapter.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon-excalibur/xmlutil/src/java/org/apache/excalibur/xml/sax/DocumentHandlerAdapter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DocumentHandlerAdapter.java       15 Oct 2002 23:10:57 -0000      1.1
  +++ DocumentHandlerAdapter.java       15 Oct 2002 23:25:09 -0000      1.2
  @@ -20,74 +20,81 @@
   /**
    * This class is an utility class "wrapping" around a SAX version 2.0
    * {@link ContentHandler} and forwarding the events to it.
  - * <br>
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Mircea Toma</a>
    * @version CVS $Revision$ $Date$
    */
   
  -public class DocumentHandlerAdapter implements DocumentHandler {
  -    
  +public class DocumentHandlerAdapter implements DocumentHandler
  +{    
       private final static String XMLNS = "xmlns";
       private final static String XMLNS_PREFIX = "xmlns:";
       private final ContentHandler m_handler;
       private final NamespaceSupport m_support = new NamespaceSupport();
       
  -    public DocumentHandlerAdapter(ContentHandler handler) {
  +    public DocumentHandlerAdapter(ContentHandler handler)
  +    {
           m_handler = handler;
       }
       
  -    public void setDocumentLocator(Locator locator) {
  +    public void setDocumentLocator(Locator locator)
  +    {
           m_handler.setDocumentLocator(locator);
       }
       
  -    public void startDocument() throws SAXException {
  +    public void startDocument() throws SAXException
  +    {
           m_handler.startDocument();
       }
       
  -    public void endDocument() throws SAXException {
  +    public void endDocument() throws SAXException
  +    {
           m_handler.endDocument();
       }
  -        
  -    public void characters(char ch[], int start, int length) throws SAXException {
  +    
  +    public void characters(char ch[], int start, int length) throws SAXException
  +    {
           m_handler.characters(ch, start, length);
       }
       
  -    public void ignorableWhitespace(char ch[], int start, int length) throws 
SAXException {
  +    public void ignorableWhitespace(char ch[], int start, int length) throws 
SAXException
  +    {
           m_handler.ignorableWhitespace(ch, start, length);
       }
       
  -    public void processingInstruction(String target, String data) throws 
SAXException {
  +    public void processingInstruction(String target, String data) throws 
SAXException
  +    {
           m_handler.processingInstruction(target, data);
       }
  -        
  -    public void startElement(String name, AttributeList atts) throws SAXException {
  +    
  +    public void startElement(String name, AttributeList atts) throws SAXException
  +    {
           m_support.pushContext();
           
           for (int i = 0; i < atts.getLength(); i++)
           {
  -                final String attributeName = atts.getName(i);
  -                if (attributeName.startsWith(XMLNS_PREFIX))
  -                {
  -                        m_support.declarePrefix(attributeName.substring(6), 
atts.getValue(i));
  -                }
  -                else if (attributeName.equals(XMLNS))
  -                {
  -                        m_support.declarePrefix("", atts.getValue(i));
  -                }
  +            final String attributeName = atts.getName(i);
  +            if (attributeName.startsWith(XMLNS_PREFIX))
  +            {
  +                m_support.declarePrefix(attributeName.substring(6), 
atts.getValue(i));
  +            }
  +            else if (attributeName.equals(XMLNS))
  +            {
  +                m_support.declarePrefix("", atts.getValue(i));
  +            }
           }
  -
  +        
           final AttributesImpl attributes = new AttributesImpl();
           for (int i = 0; i < atts.getLength(); i++)
           {
  -                final String attributeName = atts.getName(i);
  -                if (!attributeName.startsWith(XMLNS_PREFIX) && 
!attributeName.equals(XMLNS))
  -                {
  -                    final String[] parts = m_support.processName(name, new 
String[3], true);
  -                    attributes.addAttribute(parts[0], parts[1], parts[2], 
atts.getType(i), atts.getValue(i));
  -                }
  +            final String attributeName = atts.getName(i);
  +            if (!attributeName.startsWith(XMLNS_PREFIX) && 
!attributeName.equals(XMLNS))
  +            {
  +                final String[] parts = m_support.processName(name, new String[3], 
true);
  +                attributes.addAttribute(parts[0], parts[1], parts[2], 
atts.getType(i), atts.getValue(i));
  +            }
           }
  -
  +        
           final Enumeration e = m_support.getDeclaredPrefixes();
           while(e.hasMoreElements())
           {
  @@ -99,16 +106,18 @@
           m_handler.startElement(parts[0], parts[1], parts[2], attributes);
       }
       
  -    public void endElement(String name) throws SAXException {
  +    public void endElement(String name) throws SAXException
  +    {
           final String[] parts = m_support.processName(name, new String[3], false);
           m_handler.endElement(parts[0], parts[1], parts[2]);
  -
  +        
           final Enumeration e = m_support.getDeclaredPrefixes();
  -        while(e.hasMoreElements()) {
  +        while(e.hasMoreElements())
  +        {
               final String prefix = (String)e.nextElement();
               m_handler.endPrefixMapping(prefix);
           }
           
           m_support.popContext();
  -    }    
  +    }
   }
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to