masonjm     2004/07/16 15:46:30

  Modified:    webdavclient build.xml
               webdavclient/clientlib/src/java/org/apache/webdav/lib
                        BaseProperty.java
               webdavclient/clientlib/src/java/org/apache/util
                        DOMUtils.java
  Added:       webdavclient/lib jdom.license jdom-20040226-.jar
  Log:
  - DOMUtils.getTextValue() now gets text recursively, not just from immediate 
children.
  - BaseProperty.getPropertyAsString() now returns useful information for properties 
with XML content.
  
  Revision  Changes    Path
  1.16      +3 -0      jakarta-slide/webdavclient/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/webdavclient/build.xml,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- build.xml 15 Jul 2004 11:53:24 -0000      1.15
  +++ build.xml 16 Jul 2004 22:46:30 -0000      1.16
  @@ -54,11 +54,13 @@
       <property name="ant.jar" value="lib/ant.jar"/>
       <property name="commons-transaction.jar" 
value="lib/commons-transaction-0.1pre.jar"/>
       <property name="j2ee-spec.jar" value="lib/geronimo-spec-j2ee-1.0-M1.jar"/>
  +    <property name="jdom.jar" value="lib/jdom-20040226-.jar"/>
       <!-- =================================================================== -->
       <!-- Classpaths                                                          -->
       <!-- =================================================================== -->
       <path id="clientlib.classpath">
           <pathelement location="${commons-httpclient.jar}"/>
  +        <pathelement location="${jdom.jar}"/>
       </path>
       <path id="cmd.classpath">
           <pathelement location="${antlr.jar}"/>
  @@ -264,6 +266,7 @@
           <copy todir="${clientlib.dist}/lib">
               <fileset dir="lib">
                   <include name="commons-*.jar"/>
  +                <include name="jdom*.*"/>
               </fileset>
           </copy>
           <jar jarfile="${clientlib.dist}/lib/${clientlib.final.name}.jar"
  
  
  
  1.1                  jakarta-slide/webdavclient/lib/jdom.license
  
  Index: jdom.license
  ===================================================================
  /*-- 

  

   $Id: jdom.license,v 1.1 2002/06/13 16:41:15 pnever Exp $

  

   Copyright (C) 2000-2002 Brett McLaughlin & Jason Hunter.

   All rights reserved.

   

   Redistribution and use in source and binary forms, with or without

   modification, are permitted provided that the following conditions

   are met:

   

   1. Redistributions of source code must retain the above copyright

      notice, this list of conditions, and the following disclaimer.

   

   2. Redistributions in binary form must reproduce the above copyright

      notice, this list of conditions, and the disclaimer that follows 

      these conditions in the documentation and/or other materials 

      provided with the distribution.

  

   3. The name "JDOM" must not be used to endorse or promote products

      derived from this software without prior written permission.  For

      written permission, please contact [EMAIL PROTECTED]

   

   4. Products derived from this software may not be called "JDOM", nor

      may "JDOM" appear in their name, without prior written permission

      from the JDOM Project Management ([EMAIL PROTECTED]).

   

   In addition, we request (but do not require) that you include in the 

   end-user documentation provided with the redistribution and/or in the 

   software itself an acknowledgement equivalent to the following:

       "This product includes software developed by the

        JDOM Project (http://www.jdom.org/)."

   Alternatively, the acknowledgment may be graphical using the logos 

   available at http://www.jdom.org/images/logos.

  

   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED

   WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES

   OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE

   DISCLAIMED.  IN NO EVENT SHALL THE JDOM AUTHORS OR THE PROJECT

   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,

   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT

   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF

   USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND

   ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,

   OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT

   OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF

   SUCH DAMAGE.

  

   This software consists of voluntary contributions made by many 

   individuals on behalf of the JDOM Project and was originally 

   created by Brett McLaughlin <[EMAIL PROTECTED]> and 

   Jason Hunter <[EMAIL PROTECTED]>.  For more information on the 

   JDOM Project, please see <http://www.jdom.org/>.

   

   */

  

  
  
  
  1.1                  jakarta-slide/webdavclient/lib/jdom-20040226-.jar
  
        <<Binary file>>
  
  
  1.3       +23 -7     
jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/BaseProperty.java
  
  Index: BaseProperty.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/BaseProperty.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BaseProperty.java 11 Feb 2004 11:30:51 -0000      1.2
  +++ BaseProperty.java 16 Jul 2004 22:46:30 -0000      1.3
  @@ -24,8 +24,13 @@
   package org.apache.webdav.lib;
   
   import java.io.StringWriter;
  +import java.util.List;
  +
   import org.apache.util.DOMUtils;
   import org.apache.util.PropertyWriter;
  +import org.jdom.input.DOMBuilder;
  +import org.jdom.output.Format;
  +import org.jdom.output.XMLOutputter;
   import org.w3c.dom.Element;
   
   /**
  @@ -112,14 +117,25 @@
   
   
       /**
  -     * This method returns the namespace of the property.  Thus, for example,
  +     * This method returns the value of the property.  Thus, for example,
        * calling this method on a property such as
        * <code>&lt;D:getlastmodified&gt;Tue, 05 Dec 2000
        * 05:25:02&lt;/D:getlastmodified&gt;</code> returns
  -     * <code>Tue, 05 Dec 2000 05:25:02</code>.
  +     * <code>Tue, 05 Dec 2000 05:25:02</code>.<br/>
  +     * Note: Mixed content (text and xml together) will not be returned
  +     * accurately.
        */
       public String getPropertyAsString() {
  -        return DOMUtils.getTextValue(element);
  +     StringBuffer text = new StringBuffer();
  +        DOMBuilder builder = new DOMBuilder();
  +        XMLOutputter outputter = new XMLOutputter( Format.getPrettyFormat() );
  +        org.jdom.Element e = builder.build( element );
  +        List children = e.getChildren();
  +        if ( children.size() > 0 ) {
  +             text.append( outputter.outputString( children ) );
  +        }
  +        text.append( e.getTextTrim() );
  +        return text.toString();
       }
   
   
  
  
  
  1.4       +8 -9      
jakarta-slide/webdavclient/clientlib/src/java/org/apache/util/DOMUtils.java
  
  Index: DOMUtils.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/webdavclient/clientlib/src/java/org/apache/util/DOMUtils.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DOMUtils.java     24 May 2004 09:16:41 -0000      1.3
  +++ DOMUtils.java     16 Jul 2004 22:46:30 -0000      1.4
  @@ -135,8 +135,7 @@
   
   
       /**
  -     *  Scan all immediate children of a node, and append all
  -     *  text nodes into a string.  Consider the following example
  +     *  Recursively scans all child elements, appending any text nodes.
        *
        *  <PRE>
        *  &lt;customer&gt;Joe Schmoe&lt;/customer&gt;
  @@ -152,10 +151,10 @@
           String text = "";
           NodeList textList = node.getChildNodes();
           for (int i = 0; i < textList.getLength(); i++) {
  -            try {
  +            if (textList.item(i).getNodeType() == Node.TEXT_NODE) {
                   text += ((Text) textList.item(i)).getData();
  -            } catch (ClassCastException e) {
  -                // we don't care about non-Text nodes
  +            } else {
  +                text += getTextValue(textList.item(i));
               }
           }
           return text;
  
  
  

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

Reply via email to