commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject cvs commit: jakarta-commons/betwixt/xdocs tasks.xml
Date Mon, 17 Feb 2003 19:41:57 GMT
rdonkin     2003/02/17 11:41:57

  Modified:    betwixt/src/java/org/apache/commons/betwixt/io
                        AbstractBeanWriter.java SAXBeanWriter.java
               betwixt/src/java/org/apache/commons/betwixt/strategy
                        HyphenatedNameMapper.java
               betwixt/src/test/org/apache/commons/betwixt/io
                        TestSAXBeanWriter.java
               betwixt/xdocs tasks.xml
  Log:
  Refactored AbstractBeanWriter so that local names and uris are available for SAXBeanWriter.
Hopefully, the changes should make it easier to move towards using a SAX based engine in the
future. .Problem spotted and initial patch contributed by Jakob Praher.
  
  Revision  Changes    Path
  1.12      +275 -29   jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/io/AbstractBeanWriter.java
  
  Index: AbstractBeanWriter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/io/AbstractBeanWriter.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- AbstractBeanWriter.java	13 Feb 2003 18:41:48 -0000	1.11
  +++ AbstractBeanWriter.java	17 Feb 2003 19:41:56 -0000	1.12
  @@ -190,7 +190,36 @@
                           IOException, 
                           SAXException,
                           IntrospectionException {
  -                    
  +        writeBean( "", qualifiedName, qualifiedName, bean);
  +    }
  +    
  +    /** 
  +     * <p>Writes the given bean to the current stream 
  +     * using the given <code>qualifiedName</code>.</p>
  +     *
  +     * <p>This method will throw a <code>CyclicReferenceException</code>
when a cycle
  +     * is encountered in the graph <strong>only</strong> if the <code>WriteIDs</code>
  +     * property is false.</p>
  +     *
  +     * @param namespaceUri the namespace uri
  +     * @param localName the local name
  +     * @param qualifiedName the string naming root element
  +     * @param bean the <code>Object</code> to write out as xml
  +     * 
  +     * @throws CyclicReferenceException when a cyclic reference is encountered 
  +     * @throws IOException if an IO problem occurs during writing
  +     * @throws SAXException if an SAX problem occurs during writing 
  +     * @throws IntrospectionException if a java beans introspection problem occurs
  +     */
  +    private void writeBean (
  +                String namespaceUri,
  +                String localName,
  +                String qualifiedName, 
  +                Object bean) 
  +                    throws 
  +                        IOException, 
  +                        SAXException,
  +                        IntrospectionException {                    
           
           if ( log.isTraceEnabled() ) {
               log.trace( "Writing bean graph (qualified name '" + qualifiedName + "'" );
  @@ -205,6 +234,12 @@
                   if ( qualifiedName == null ) {
                       qualifiedName = elementDescriptor.getQualifiedName();
                   }
  +                if ( namespaceUri == null ) {
  +                    namespaceUri = elementDescriptor.getURI();
  +                }
  +                if ( localName == null ) {
  +                    localName = elementDescriptor.getLocalName();
  +                }
   
                   String ref = null;
                   String id = null;
  @@ -212,10 +247,13 @@
                   // only give id's to non-primatives
                   if ( elementDescriptor.isPrimitiveType() ) {
                       // write without an id
  -                    write( 
  +                    writeElement( 
  +                        namespaceUri,
  +                        localName,
                           qualifiedName, 
                           elementDescriptor, 
                           context );
  +                        
                   } else {
                       pushBean ( context.getBean() );
                       if ( writeIDs ) {
  @@ -231,7 +269,9 @@
                               
                               if ( writeIDs ) {
                                   // write element with id
  -                                write( 
  +                                writeElement(
  +                                    namespaceUri,
  +                                    localName,
                                       qualifiedName, 
                                       elementDescriptor, 
                                       context , 
  @@ -240,7 +280,9 @@
                                       
                               } else {    
                                   // write element without ID
  -                                write( 
  +                                writeElement( 
  +                                    namespaceUri,
  +                                    localName,
                                       qualifiedName, 
                                       elementDescriptor, 
                                       context );
  @@ -263,7 +305,9 @@
                               idMap.put( bean, id);
                               
                               // the ID attribute should be written automatically
  -                            write( 
  +                            writeElement( 
  +                                namespaceUri,
  +                                localName,
                                   qualifiedName, 
                                   elementDescriptor, 
                                   context );
  @@ -273,6 +317,8 @@
                           if ( !ignoreElement( elementDescriptor, context )) {
                               // we've already written this bean so write an IDREF
                               writeIDREFElement( 
  +                                            namespaceUri,
  +                                            localName,
                                               qualifiedName,  
                                               beanInfo.getIDREFAttributeName(), 
                                               ref);
  @@ -426,9 +472,25 @@
        * @throws IOException if an IO problem occurs during writing
        * @throws SAXException if an SAX problem occurs during writing 
        */
  -    protected abstract void expressElementStart(String qualifiedName) 
  -                                        throws IOException, SAXException;
  -       
  +    protected void expressElementStart(String qualifiedName) 
  +                                        throws IOException, SAXException {
  +        // do nothing
  +    }
  +                                        
  +    /** 
  +     * Express an element tag start using given qualified name.
  +     *
  +     * @param uri the namespace uri 
  +     * @param localName the local name for this element
  +     * @param qualifiedName the qualified name of the element to be expressed
  +     * @throws IOException if an IO problem occurs during writing
  +     * @throws SAXException if an SAX problem occurs during writing 
  +     */
  +    protected void expressElementStart(String uri, String localName, String qualifiedName)

  +                                        throws IOException, SAXException {
  +        expressElementStart( qualifiedName );
  +    }
  +    
        /**
        * Express a closing tag.
        *
  @@ -445,8 +507,31 @@
        * @throws IOException if an IO problem occurs during writing
        * @throws SAXException if an SAX problem occurs during writing 
        */
  -    protected abstract void expressElementEnd(String qualifiedName) 
  -                                              throws IOException, SAXException;
  +    protected void expressElementEnd(String qualifiedName) 
  +                                              throws IOException, SAXException {
  +        // do nothing
  +    }
  +    
  +    /** 
  +     * Express an element end tag (with given name) 
  +     *
  +     * @param uri the namespace uri of the element close tag
  +     * @param localName the local name of the element close tag
  +     * @param qualifiedName the qualified name for the element to be closed
  +     *
  +     * @throws IOException if an IO problem occurs during writing
  +     * @throws SAXException if an SAX problem occurs during writing 
  +     */
  +    protected void expressElementEnd(
  +                                                String uri,
  +                                                String localName,
  +                                                String qualifiedName) 
  +                                                    throws 
  +                                                        IOException, 
  +                                                        SAXException {
  +        expressElementEnd(qualifiedName);
  +    }
  +                                              
       
       /** 
        * Express an empty element end.
  @@ -474,12 +559,35 @@
        * @throws IOException if an IO problem occurs during writing
        * @throws SAXException if an SAX problem occurs during writing 
        */
  -    protected abstract void expressAttribute(
  +    protected void expressAttribute(
  +                                String qualifiedName, 
  +                                String value) 
  +                                    throws
  +                                        IOException, 
  +                                        SAXException {
  +        // Do nothing
  +    }
  +
  +    /** 
  +     * Express an attribute 
  +     *
  +     * @param namesapceUri the namespace uri
  +     * @param localName the local name
  +     * @param qualifiedName the qualified name of the attribute
  +     * @param value the attribute value
  +     * @throws IOException if an IO problem occurs during writing
  +     * @throws SAXException if an SAX problem occurs during writing 
  +     */
  +    protected void expressAttribute(
  +                                String namespaceUri,
  +                                String localName,
                                   String qualifiedName, 
                                   String value) 
                                       throws
                                           IOException, 
  -                                        SAXException;
  +                                        SAXException {
  +        expressAttribute(qualifiedName, value);
  +    }
   
   
       // Implementation methods
  @@ -495,6 +603,7 @@
        * @throws IOException if an IO problem occurs during writing
        * @throws SAXException if an SAX problem occurs during writing 
        * @throws IntrospectionException if a java beans introspection problem occurs
  +     * @deprecated refactoring means method no longer needed
        */
       protected void write( 
                               String qualifiedName, 
  @@ -504,6 +613,31 @@
                                       IOException, 
                                       SAXException,
                                       IntrospectionException {
  +        writeElement( "", qualifiedName, qualifiedName, elementDescriptor, context );
  +    }
  +    
  +    /** 
  +     * Writes the given element 
  +     *
  +     * @param namespaceUri the namespace uri
  +     * @param localName the local name
  +     * @param qualifiedName qualified name to use for the element
  +     * @param elementDescriptor the <code>ElementDescriptor</code> describing
the element
  +     * @param context the <code>Context</code> to use to evaluate the bean
expressions
  +     * @throws IOException if an IO problem occurs during writing
  +     * @throws SAXException if an SAX problem occurs during writing 
  +     * @throws IntrospectionException if a java beans introspection problem occurs
  +     */
  +    private void writeElement(
  +                            String namespaceUri,
  +                            String localName,
  +                            String qualifiedName, 
  +                            ElementDescriptor elementDescriptor, 
  +                            Context context ) 
  +                                throws 
  +                                    IOException, 
  +                                    SAXException,
  +                                    IntrospectionException {
           if( log.isTraceEnabled() ) {
               log.trace( "Writing: " + qualifiedName + " element: " + elementDescriptor );
           }
  @@ -514,10 +648,10 @@
               }
           
               if (elementDescriptor.isWrapCollectionsInElement()) {
  -                expressElementStart( qualifiedName );
  +                expressElementStart( namespaceUri, localName, qualifiedName );
               }
               
  -            writeRestOfElement( qualifiedName, elementDescriptor, context);
  +            writeRestOfElement( namespaceUri, localName, qualifiedName, elementDescriptor,
context);
           }
       }
       
  @@ -534,6 +668,7 @@
        * @throws IOException if an IO problem occurs during writing
        * @throws SAXException if an SAX problem occurs during writing 
        * @throws IntrospectionException if a java beans introspection problem occurs
  +     * @deprecated refactoring means method no longer needed
        */
       protected void write( 
                               String qualifiedName, 
  @@ -545,14 +680,56 @@
                                       IOException, 
                                       SAXException,
                                       IntrospectionException {
  +        writeElement( 
  +                    "", 
  +                    qualifiedName, 
  +                    qualifiedName, 
  +                    elementDescriptor, 
  +                    context, 
  +                    idAttribute, 
  +                    idValue );
  +    }
  +    
  +    /** 
  +     * Writes the given element adding an ID attribute 
  +     *
  +     * @param namespaceUri the namespace uri
  +     * @param localName the local name
  +     * @param qualifiedName the qualified name
  +     * @param elementDescriptor the ElementDescriptor describing this element
  +     * @param context the context being evaliated against
  +     * @param idAttribute the qualified name of the <code>ID</code> attribute

  +     * @param idValue the value for the <code>ID</code> attribute 
  +     * @throws IOException if an IO problem occurs during writing
  +     * @throws SAXException if an SAX problem occurs during writing 
  +     * @throws IntrospectionException if a java beans introspection problem occurs
  +     */
  +    private void writeElement( 
  +                            String namespaceUri,
  +                            String localName,
  +                            String qualifiedName, 
  +                            ElementDescriptor elementDescriptor, 
  +                            Context context,
  +                            String idAttribute,
  +                            String idValue ) 
  +                                throws 
  +                                    IOException, 
  +                                    SAXException,
  +                                    IntrospectionException {
                      
           if ( !ignoreElement( elementDescriptor, context ) ) {
           
  -            expressElementStart( qualifiedName );
  +            expressElementStart( namespaceUri, localName, qualifiedName );
                
  -            expressAttribute( idAttribute, idValue );        
  +            // XXX For the moment, assign ID attribute to default namespace
  +            expressAttribute( "", idAttribute, idAttribute, idValue );        
           
  -            writeRestOfElement( qualifiedName, elementDescriptor, context );
  +            writeRestOfElement( 
  +                                namespaceUri, 
  +                                localName, 
  +                                qualifiedName, 
  +                                elementDescriptor, 
  +                                context );
   
           } else if ( log.isTraceEnabled() ) {
               log.trace( "Element " + qualifiedName + " is empty." );
  @@ -568,6 +745,7 @@
        * @throws IOException if an IO problem occurs during writing
        * @throws SAXException if an SAX problem occurs during writing 
        * @throws IntrospectionException if a java beans introspection problem occurs
  +     * @deprecated refactored away
        */
       protected void writeRestOfElement( 
                               String qualifiedName, 
  @@ -577,6 +755,31 @@
                                       IOException, 
                                       SAXException,
                                       IntrospectionException {
  +        writeRestOfElement( "", qualifiedName, qualifiedName, elementDescriptor, context
);
  +    }
  +
  +    /**
  +     * Write attributes, child elements and element end 
  +     * 
  +     * @param uri the element namespace uri 
  +     * @param localName the local name of the element
  +     * @param qualifiedName the qualified name of the element
  +     * @param elementDescriptor the descriptor for this element
  +     * @param context evaluate against this context
  +     * @throws IOException if an IO problem occurs during writing
  +     * @throws SAXException if an SAX problem occurs during writing 
  +     * @throws IntrospectionException if a java beans introspection problem occurs
  +     */
  +    private void writeRestOfElement( 
  +                            String uri,
  +                            String localName,
  +                            String qualifiedName, 
  +                            ElementDescriptor elementDescriptor, 
  +                            Context context ) 
  +                                throws 
  +                                    IOException, 
  +                                    SAXException,
  +                                    IntrospectionException {
   
           if ( elementDescriptor.isWrapCollectionsInElement() ) {
               writeAttributes( elementDescriptor, context );
  @@ -584,7 +787,7 @@
   
           if ( writeContent( elementDescriptor, context ) ) {
               if ( elementDescriptor.isWrapCollectionsInElement() ) {
  -                expressElementEnd( qualifiedName );
  +                expressElementEnd( uri, localName, qualifiedName );
               }
           } else {
               if ( elementDescriptor.isWrapCollectionsInElement() ) {
  @@ -603,6 +806,7 @@
        * @throws IOException if an IO problem occurs during writing
        * @throws SAXException if an SAX problem occurs during writing 
        * @throws IntrospectionException if a java beans introspection problem occurs
  +     * @deprecated refactored away
        */
       protected void writeIDREFElement( 
                                       String qualifiedName, 
  @@ -612,11 +816,42 @@
                                               IOException, 
                                               SAXException,
                                               IntrospectionException {
  +        writeIDREFElement( 
  +                            "", 
  +                            qualifiedName, 
  +                            qualifiedName, 
  +                            idrefAttributeName, 
  +                            idrefAttributeValue );
  +    }
  +
  +    /**
  +     * Writes an element with a <code>IDREF</code> attribute 
  +     *
  +     * @param uri the namespace uri
  +     * @param localName the local name
  +     * @param qualifiedName of the element with <code>IDREF</code> attribute

  +     * @param idrefAttributeName the qualified name of the <code>IDREF</code>
attribute 
  +     * @param idrefAttributeValue the value for the <code>IDREF</code> attribute

  +     * @throws IOException if an IO problem occurs during writing
  +     * @throws SAXException if an SAX problem occurs during writing 
  +     * @throws IntrospectionException if a java beans introspection problem occurs
  +     */
  +    private void writeIDREFElement( 
  +                                    String uri,
  +                                    String localName,
  +                                    String qualifiedName, 
  +                                    String idrefAttributeName,
  +                                    String idrefAttributeValue ) 
  +                                        throws 
  +                                            IOException, 
  +                                            SAXException,
  +                                            IntrospectionException {
   
           // write IDREF element
  -        expressElementStart( qualifiedName );
  +        expressElementStart( uri, localName, qualifiedName );
           
  -        expressAttribute( idrefAttributeName, idrefAttributeValue );
  +        // XXX for the moment, assgin IDREF to default namespace
  +        expressAttribute( "", idrefAttributeName, idrefAttributeName, idrefAttributeValue
);
                               
           expressElementEnd();
       }
  @@ -650,6 +885,8 @@
                       Object childBean = childExpression.evaluate( context );
                       if ( childBean != null ) {
                           String qualifiedName = childDescriptor.getQualifiedName();
  +                        String namespaceUri = childDescriptor.getURI();
  +                        String localName = childDescriptor.getLocalName();
                           // XXXX: should we handle nulls better
                           if ( childBean instanceof Iterator ) {
                               for ( Iterator iter = (Iterator) childBean; iter.hasNext();
) {
  @@ -664,7 +901,7 @@
                                       }
                                   }
                                   ++indentLevel;
  -                                write( qualifiedName, object );
  +                                writeBean( namespaceUri, localName, qualifiedName, object
);
                                   --indentLevel;
                               }
                           } else {
  @@ -673,7 +910,7 @@
                                   expressTagClose();
                               }
                               ++indentLevel;
  -                            write( qualifiedName, childBean );
  +                            writeBean( namespaceUri, localName, qualifiedName, childBean
);
                               --indentLevel;
                           }
                       }                    
  @@ -686,7 +923,12 @@
                           ++indentLevel;
                       }
   
  -                     write( childDescriptor.getQualifiedName(), childDescriptor, childContext
);
  +                     writeElement( 
  +                                childDescriptor.getURI(), 
  +                                childDescriptor.getLocalName(), 
  +                                childDescriptor.getQualifiedName(), 
  +                                childDescriptor, 
  +                                childContext );
   
                       if (childDescriptor.isWrapCollectionsInElement()) {
                           --indentLevel;
  @@ -763,7 +1005,11 @@
               if ( value != null ) {
                   String text = value.toString();
                   if ( text != null && text.length() > 0 ) {
  -                    expressAttribute(attributeDescriptor.getQualifiedName(), text);
  +                    expressAttribute(
  +                                    attributeDescriptor.getURI(),
  +                                    attributeDescriptor.getLocalName(),
  +                                    attributeDescriptor.getQualifiedName(), 
  +                                    text);
                   }
               }                
           }
  
  
  
  1.8       +125 -18   jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/io/SAXBeanWriter.java
  
  Index: SAXBeanWriter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/io/SAXBeanWriter.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- SAXBeanWriter.java	13 Feb 2003 19:24:21 -0000	1.7
  +++ SAXBeanWriter.java	17 Feb 2003 19:41:56 -0000	1.8
  @@ -151,8 +151,22 @@
        *
        * @param qualifiedName the fully qualified element name
        * @throws SAXException if the <code>ContentHandler</code> has a problem
  +     * @deprecated use {@link #expressElementStart(String, String, String)}
        */
       protected void expressElementStart(String qualifiedName) throws SAXException  {
  +        expressElementStart("", qualifiedName, qualifiedName);
  +    }
  +    
  +    /** 
  +     * Express an element tag start using given qualified name.
  +     *
  +     * @param uri the namespace uri 
  +     * @param localName the local name for this element
  +     * @param qualifiedName the qualified name of the element to be expressed
  +     * @throws SAXException if an SAX problem occurs during writing 
  +     */
  +    protected void expressElementStart(String uri, String localName, String qualifiedName)

  +                                        throws SAXException {
           if (elementStack == null) {
               elementStack = new Stack();
           }
  @@ -160,7 +174,7 @@
               sendElementStart();
           }
           attributes = new AttributesImpl();
  -        elementStack.push(qualifiedName);
  +        elementStack.push(new ElementName(uri, localName, qualifiedName));
           elementWaiting = true;
       }
       
  @@ -175,15 +189,29 @@
        *
        * @param qualifiedName the fully qualified name of the element
        * @throws SAXException if the <code>ContentHandler</code> has a problem
  +     * @deprecated use {@link #expressElementEnd(String, String, String)}
        */
       protected void expressElementEnd(String qualifiedName) throws SAXException  {
  +        expressElementEnd("", qualifiedName, qualifiedName);
  +    }    
  +    
  +    /** 
  +     * Express an element tag start using given qualified name.
  +     *
  +     * @param uri the namespace uri 
  +     * @param localName the local name for this element
  +     * @param qualifiedName the qualified name of the element to be expressed
  +     * @throws SAXException if an SAX problem occurs during writing 
  +     */
  +    protected void expressElementEnd(String uri, String localName, String qualifiedName)

  +                                        throws SAXException {
           if (elementWaiting) {
               elementWaiting = false;
               sendElementStart();
           }
  -        // can't handle namespaces yet
  -        contentHandler.endElement("","",qualifiedName);
  -    }    
  +        
  +        contentHandler.endElement(uri, localName, qualifiedName);
  +    }
       
       /** 
        * Express an empty element end 
  @@ -191,8 +219,11 @@
        */
       protected void expressElementEnd() throws SAXException  {
           // last element name must be correct since there haven't been any tag in between
  -        String lastElement = (String) elementStack.peek();
  -        contentHandler.endElement("","",lastElement);
  +        ElementName lastElement = (ElementName) elementStack.peek();
  +        contentHandler.endElement(
  +                                lastElement.getUri(), 
  +                                lastElement.getLocalName() ,
  +                                lastElement.getQName());
       }
   
       /** 
  @@ -216,16 +247,30 @@
        * Express an attribute 
        * @param qualifiedName the fully qualified attribute name
        * @param value the attribute value
  -     * @throws SAXException if the <code>ContentHandler</code> has a problem
  +     * @deprecated use {@link #expressAttribute(String, String, String, String)}
  +     */
  +    protected void expressAttribute(
  +                                String qualifiedName, 
  +                                String value) {
  +        expressAttribute("", qualifiedName, qualifiedName, value);
  +    }
  +    
  +    /** 
  +     * Express an attribute 
  +     *
  +     * @param namespaceUri the namespace for the attribute
  +     * @param localName the local name for the attribute
  +     * @param qualifiedName the qualified name of the attribute
  +     * @param value the attribute value
        */
       protected void expressAttribute(
  +                                String namespaceUri,
  +                                String localName,
                                   String qualifiedName, 
  -                                String value) 
  -                                    throws
  -                                        SAXException  {
  +                                String value) {
           // FIX ME
           // SHOULD PROBABLY SUPPORT ID IDREF HERE
  -        attributes.addAttribute("", "", qualifiedName, "CDATA", value);
  +        attributes.addAttribute(namespaceUri, localName, qualifiedName, "CDATA", value);
       }
   
   
  @@ -237,8 +282,15 @@
        * @throws SAXException if the <code>ContentHandler</code> has a problem
        */
       private void sendElementStart() throws SAXException {
  -        String lastElement = (String)elementStack.peek();
  -        contentHandler.startElement("","",lastElement,attributes);
  +        ElementName lastElement = (ElementName) elementStack.peek();
  +        if (log.isTraceEnabled()) {
  +            log.trace(lastElement);
  +        }
  +        contentHandler.startElement(
  +                                lastElement.getUri(), 
  +                                lastElement.getLocalName(), 
  +                                lastElement.getQName(), 
  +                                attributes);
       }
       /**
        * This will announce the start of the document
  @@ -262,6 +314,61 @@
           if ( callDocumentEvents ) {
               contentHandler.endDocument();
           }
  +    }
  +
  +    /** Used to store element names stored on the stack */
  +    private class ElementName {
  +        /** Namespace uri */
  +        private String uri;
  +        /** Local name */
  +        private String localName;
  +        /** Qualified name */
  +        private String qName;
  +        
  +        /** 
  +         * Gets namespace uri 
  +         * @return the namespace uri
  +         */
  +        String getUri() {
  +            return uri;
  +        }
  + 
  +        /** 
  +         * Gets local name 
  +         * @return the local name
  +         */
  +        String getLocalName() {
  +            return localName;
  +        }
  +        
  +        /** 
  +         * Gets qualified name 
  +         * @return the qualified name
  +         */
  +        String getQName() {
  +            return qName;
  +        }
  +                      
  +        /** 
  +         * Base constructor 
  +         * @param uri the namespace uri
  +         * @param localName the local name of this element
  +         * @param qName the qualified name of this element
  +         */
  +        ElementName(String uri, String localName, String qName) {
  +            this.uri = uri;
  +            this.localName = localName;
  +            this.qName = qName;
  +        }
  +        
  +        /**
  +         * Return something useful for logging
  +         *
  +         * @return something useful for logging
  +         */
  +        public String toString() {
  +            return "[ElementName uri=" + uri + " ,lName=" + localName + " ,qName=" + qName
+ "]";
  +        }	
       }
   
   }
  
  
  
  1.7       +1 -1      jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/strategy/HyphenatedNameMapper.java
  
  Index: HyphenatedNameMapper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/strategy/HyphenatedNameMapper.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- HyphenatedNameMapper.java	6 Jan 2003 22:50:45 -0000	1.6
  +++ HyphenatedNameMapper.java	17 Feb 2003 19:41:56 -0000	1.7
  @@ -204,7 +204,7 @@
        * upper or lower case conversions are being used
        *
        * @param ch the character to be converted
  -     * @return converted to upper case if {@link isUpperCase} otherwise to lower case 
  +     * @return converted to upper case if {@link #isUpperCase} otherwise to lower case

        */
       protected char convertChar(char ch) {
           if ( upperCase ) {
  
  
  
  1.4       +46 -5     jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/io/TestSAXBeanWriter.java
  
  Index: TestSAXBeanWriter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/io/TestSAXBeanWriter.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TestSAXBeanWriter.java	13 Feb 2003 19:24:21 -0000	1.3
  +++ TestSAXBeanWriter.java	17 Feb 2003 19:41:57 -0000	1.4
  @@ -72,11 +72,13 @@
   import junit.textui.TestRunner;
   
   import org.apache.commons.betwixt.PersonBean;
  +import org.apache.commons.logging.impl.SimpleLog;
   import org.w3c.dom.Document;
   import org.w3c.dom.Element;
   import org.w3c.dom.Node;
   import org.w3c.dom.NodeList;
   import org.xml.sax.InputSource;
  +import org.xml.sax.Attributes;
   import org.xml.sax.helpers.DefaultHandler;
   
   /** 
  @@ -100,9 +102,14 @@
           // writer bean into string
           StringWriter out = new StringWriter();
           
  +        SimpleLog log = new SimpleLog("[TestWrite:SAXBeanWriter]");
  +        log.setLevel(SimpleLog.LOG_LEVEL_TRACE);
  +        
           SAXBeanWriter writer = new SAXBeanWriter(new SAXContentHandler(out));
  +        writer.setLog(log);
           writer.write(bean);
           String beanString = out.getBuffer().toString();
  +        System.out.println(beanString);
           // test the result
           DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
           DocumentBuilder builder = factory.newDocumentBuilder();
  @@ -177,6 +184,40 @@
           assertEquals("Start called", handler.startCalled , false); 
           assertEquals("End called", handler.endCalled , false);     
       }
  +    
  +    /** This tests whether local names and qNames match */
  +    public void testLocalNames() throws Exception {
  +    
  +        class TestNames extends DefaultHandler {
  +            boolean namesMatch = true;
  +            
  +            public void startElement(String uri, String localName, String qName, Attributes
attributes) {
  +                if (!localName.equals(qName)) {
  +                    namesMatch = false;
  +                }
  +                
  +                for (int i=0, size=attributes.getLength(); i<size; i++) {
  +                    if (!attributes.getLocalName(i).equals(attributes.getQName(i))) {
  +                        namesMatch = false;
  +                    }
  +                }
  +            }
  +            
  +            public void endElement(String uri, String localName, String qName) {
  +                if (!localName.equals(qName)) {
  +                    namesMatch = false;
  +                }
  +            }
  +        }
  +        
  +        PersonBean bean = new PersonBean(24, "vikki");
  +        TestNames testHandler = new TestNames();
  +        SAXBeanWriter writer = new SAXBeanWriter(testHandler);
  +        writer.write(bean);
  +        
  +        assertEquals("Local names match QNames", testHandler.namesMatch, true);
  +    }
  +    
           
       public static Test suite() {
           return new TestSuite(TestSAXBeanWriter.class);
  
  
  
  1.8       +42 -1     jakarta-commons/betwixt/xdocs/tasks.xml
  
  Index: tasks.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/betwixt/xdocs/tasks.xml,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- tasks.xml	13 Feb 2003 18:41:49 -0000	1.7
  +++ tasks.xml	17 Feb 2003 19:41:57 -0000	1.8
  @@ -211,12 +211,53 @@
               <li> 
                   <code>Expression.update</code> has been replaced by Updater
               </li>
  +            <li> 
  +                <code>AbstractBeanWriter.write(String, ElementDescriptor, Context)</code>
refactored away
  +            </li>
  +            <li> 
  +                <code>AbstractBeanWriter.write(String, ElementDescriptor, Context,
String, String)</code> refactored away
  +            </li>
  +            <li> 
  +                <code>AbstractBeanWriter.writeIDREFElement( String, String, String)</code>
refactored away
  +            </li>       
  +            <li> 
  +                <code>AbstractBeanWriter.writeRestOfElement</code> refactored
away
  +            </li>    
  +            <li> 
  +                <code>SAXBeanWriter.expressElementEnd(String qualifiedName)</code>
deprecated 
  +            </li>   
  +            <li> 
  +                <code>SAXBeanWriter.expressAttribute(String qualifiedName)</code>
deprecated 
  +            </li>  
  +            <li> 
  +                <code>SAXBeanWriter.expressElementStart(String qualifiedName)</code>
deprecated 
  +            </li>  
           </ul>
       </subsection>
   </section>
  -<section name='Symantic Changes'>
  +<section name='Backwards Incompatible Changes'>
       <subsection name='Since 1.0-Alpha 1 Release'>
           <ul>
  +        </ul>
  +    </subsection>
  +</section>
  +<section name='Symantic Changes'>
  +    <subsection name='Since 1.0-Alpha 1 Release'>
  +        <ul>	
  +            <li>
  +                <strong>SAXBeanWriter now sets localName</strong>
  +                SAXBeanWriter now sets localName as well as qName for each SAX call. The
local name
  +                is derived from the qualified name. Users whose names contain colons but
which do not 
  +                comply with the namespace dialect will need to set the NamespaceDialect
property to 
  +                false.
  +            </li>
  +            <li>
  +                <strong>AbstractBeanWriter has been refactored</strong>
  +                AbstractBeanWriter has been extensively refactored.
  +                The public interface has been preserved but the protected API has been
extensively modified.
  +                In order to preserve backwards compatibility, methods have been deprecated
but are no
  +                longer called and so code that overrides then will break.
  +            </li>
           </ul>
       </subsection>
   </section>
  
  
  

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


Mime
View raw message