[jdom-interest] JDOM Beta10 released

Bradley S. Huffman hip at cs.okstate.edu
Tue Feb 17 10:38:06 PST 2004


Jason Hunter writes:

> > i.e. applying the patch I sent earlier today essentially reverts the API to
> > b9 state, but keeps all the "wins: from having "Content".
> > 
> > Rolf
> 
> I did not see the patch come through.

It made it into the archives, or below is the text.

Brad

Index: Content.java
===================================================================
retrieving revision 1.3
diff -r1.3 Content.java
79c79
<     protected Parent parent = null;
---
>     protected Container parent = null;
91c91
<             parent.removeContent(this);
---
>             parent.getContent().remove(this);
103c103
<     public Parent getParent() {
---
>     public Container getParent() {
114c114
<     protected Content setParent(Parent parent) {
---
>     protected Content setParent(Container parent) {
127c127,129
<         return parent.getDocument();
---
>         if (parent instanceof Document) return (Document)parent;
>         if (parent instanceof Element) return ((Element)parent).getDocument();
>         return null;
134c136
<      * @return xpath string value of this child.
---
>      * @return xpath string value of this content.
139c141
<      * Returns a deep, unattached copy of this child and its descendants
---
>      * Returns a shallow, but unattached copy of this content 
169c171
< 
---
>     
Index: ContentList.java
===================================================================
retrieving revision 1.36
diff -r1.36 ContentList.java
106c106
<     private Parent parent;
---
>     private Container parent;
109c109
<     ContentList(Parent parent) {
---
>     ContentList(Container parent) {
149c149
<             Parent p = child.getParent();
---
>             Container p = child.getParent();
Index: DescendantIterator.java
===================================================================
retrieving revision 1.4
diff -r1.4 DescendantIterator.java
62c62
< import org.jdom.Parent;
---
> import org.jdom.Container;
84c84
<     DescendantIterator(Parent parent) {
---
>     DescendantIterator(Container parent) {
Index: Document.java
===================================================================
retrieving revision 1.80
diff -r1.80 Document.java
72c72
< public class Document implements Parent {
---
> public class Document implements Container {
317c317
<     public Parent addContent(Content child) {
---
>     public Document addContent(Content child) {
322c322
<     public Parent addContent(Collection c) {
---
>     public Document addContent(Collection c) {
327c327
<     public Parent addContent(int index, Content child) {
---
>     public Document addContent(int index, Content child) {
332c332
<     public Parent addContent(int index, Collection c) {
---
>     public Document addContent(int index, Collection c) {
456c456
<     public Parent setContent(Collection newContent) {
---
>     public Document setContent(Collection newContent) {
500c500
<     public Parent setContent(int index, Content child) {
---
>     public Document setContent(int index, Content child) {
520c520
<     public Parent setContent(int index, Collection collection) {
---
>     public Document setContent(int index, Collection collection) {
534c534
<     public Parent setContent(Content child) {
---
>     public Document setContent(Content child) {
661c661
<     public Parent getParent() {
---
>     public Container getParent() {
737a738
> 
Index: Element.java
===================================================================
retrieving revision 1.145
diff -r1.145 Element.java
81c81
< public class Element extends Content implements Parent {
---
> public class Element extends Content implements Container {
738c738
<     public Parent setContent(Collection newContent) {
---
>     public Element setContent(Collection newContent) {
757c757
<     public Parent setContent(int index, Content child) {
---
>     public Element setContent(int index, Content child) {
777c777
<     public Parent setContent(int index, Collection collection) {
---
>     public Element setContent(int index, Collection collection) {
793c793
<     public Parent addContent(String str) {
---
>     public Element addContent(String str) {
805c805
<     public Parent addContent(Content child) {
---
>     public Element addContent(Content child) {
810c810
<     public Parent addContent(Collection collection) {
---
>     public Element addContent(Collection collection) {
815c815
<     public Parent addContent(int index, Content child) {
---
>     public Element addContent(int index, Content child) {
820c820
<     public Parent addContent(int index, Collection c) {
---
>     public Element addContent(int index, Collection c) {
852c852
<     public Parent setContent(Content child) {
---
>     public Element setContent(Content child) {
Index: Parent.java
===================================================================
diff -N Parent.java
1,382d0
< /*--
< 
<  $Id: Parent.java,v 1.9 2004/02/06 09:28:30 jhunter Exp $
< 
<  Copyright (C) 2000-2004 Jason Hunter & Brett McLaughlin.
<  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 <request_AT_jdom_DOT_org>.
< 
<  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 <request_AT_jdom_DOT_org>.
< 
<  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 Jason Hunter <jhunter_AT_jdom_DOT_org> and
<  Brett McLaughlin <brett_AT_jdom_DOT_org>.  For more information
<  on the JDOM Project, please see <http://www.jdom.org/>.
< 
<  */
< 
< package org.jdom;
< 
< import java.io.Serializable;
< import java.util.*;
< import org.jdom.filter.Filter;
< 
< /**
<  * Superclass for JDOM objects which are allowed to contain
<  * {@link Content} content.
<  *
<  * @see org.jdom.Content
<  * @see org.jdom.Document
<  * @see org.jdom.Element
<  *
<  * @author Bradley S. Huffman
<  * @author Jason Hunter
<  * @version $Revision: 1.9 $, $Date: 2004/02/06 09:28:30 $
<  */
< public interface Parent extends Cloneable, Serializable {
< 
<     /**
<      * Returns the number of children in this parent's content list.
<      * Children may be any {@link Content} type.
<      *
<      * @return number of children
<      */
<     int getContentSize();
< 
<     /**
<      * Returns the index of the supplied child in the content list,
<      * or -1 if not a child of this parent.
<      *
<      * @param child  child to search for
<      * @return       index of child, or -1 if not found
<      */
<     int indexOf(Content child);
< 
< //    /**
< //     * Starting at the given index (inclusive), returns the index of
< //     * the first child matching the supplied filter, or -1
< //     * if none is found.
< //     *
< //     * @return index of child, or -1 if none found
< //     */
< //    int indexOf(int index, Filter filter);
< 
<     /**
<      * Appends the child to the end of the content list.
<      *
<      * @param child   child to append to end of content list
<      * @return        the parent on which the method was called
<      */
<     Parent addContent(Content child);
< 
<     /**
<      * Appends all children in the given collection to the end of
<      * the content list.  In event of an exception during add the
<      * original content will be unchanged and the objects in the supplied
<      * collection will be unaltered.
<      *
<      * @param collection collection to append
<      * @return           the parent on which the method was called
<      */
<     Parent addContent(Collection collection);
< 
<     /**
<      * Inserts the child into the content list at the given index.
<      *
<      * @param child      child to insert
<      * @return           the parent on which the method was called
<      * @throws IndexOutOfBoundsException if index is negative or beyond
<      *         the current number of children
<      */
<     Parent addContent(int index, Content child);
< 
<     /**
<      * Inserts the content in a collection into the content list
<      * at the given index.  In event of an exception the original content
<      * will be unchanged and the objects in the supplied collection will be
<      * unaltered.
<      *
<      * @param collection  collection to insert
<      * @return            the parent on which the method was called
<      * @throws IndexOutOfBoundsException if index is negative or beyond
<      *         the current number of children
<      */
<     Parent addContent(int index, Collection collection);
< 
<     /**
<      * Returns a list containing detached clones of this parent's content list.
<      *
<      * @return list of cloned child content
<      */
<     List cloneContent();
< 
<     /**
<      * Returns the child at the given index.
<      *
<      * @param index location of desired child
<      * @return child at the given index
<      * @throws IndexOutOfBoundsException if index is negative or beyond
<      *         the current number of children
<      * @throws IllegalStateException if parent is a Document
<      *         and the root element is not set
<      */
<     Content getContent(int index);
< 
<     /**
<      * Returns the full content of this parent as a {@link java.util.List}
<      * which contains objects of type {@link Content}. The returned list is
<      * <b>"live"</b> and in document order. Any modifications
<      * to it affect the element's actual contents. Modifications are checked
<      * for conformance to XML 1.0 rules.
<      * <p>
<      * Sequential traversal through the List is best done with an Iterator
<      * since the underlying implement of {@link java.util.List#size} may
<      * require walking the entire list and indexed lookups may require
<      * starting at the beginning each time.
<      *
<      * @return a list of the content of the parent
<      * @throws IllegalStateException if parent is a Document
<      *         and the root element is not set
<      */
<     List getContent();
< 
<     /**
<      * Returns as a {@link java.util.List} the content of
<      * this parent that matches the supplied filter. The returned list is
<      * <b>"live"</b> and in document order. Any modifications to it affect
<      * the element's actual contents. Modifications are checked for
<      * conformance to XML 1.0 rules.
<      * <p>
<      * Sequential traversal through the List is best done with an Iterator
<      * since the underlying implement of {@link java.util.List#size} may
<      * require walking the entire list and indexed lookups may require
<      * starting at the beginning each time.
<      *
<      * @param  filter filter to apply
<      * @return a list of the content of the parent matching the filter
<      * @throws IllegalStateException if parent is a Document
<      *         and the root element is not set
<      */
<     List getContent(Filter filter);
< 
<     /**
<      * Removes all content from this parent and returns the detached
<      * children.
<      *
<      * @return list of the old content detached from this parent
<      */
<     List removeContent();
< 
<     /**
<      * Removes from this parent all child content matching the given filter
<      * and returns a list of the detached children.
<      *
<      * @param  filter filter to apply
<      * @return list of the detached children matching the filter
<      */
<     List removeContent(Filter filter);
< 
<     /**
<      * Removes a single child node from the content list.
<      *
<      * @param  child  child to remove
<      * @return whether the removal occurred
<      */
<     boolean removeContent(Content child);
< 
<     /**
<      * Removes and returns the child at the given
<      * index, or returns null if there's no such child.
<      *
<      * @param index index of child to remove
<      * @return detached child at given index or null if no
<      * @throws IndexOutOfBoundsException if index is negative or beyond
<      *             the current number of children
<      */
<     Content removeContent(int index);
< 
<     /**
<      * Set this parent's content to the supplied child.
<      * <p>
<      * If the supplied child is legal content for this parent and before
<      * it is added, all content in the current content list will
<      * be cleared and all current children will have their parentage set to
<      * null.
<      * <p>
<      * This has the effect that any active list (previously obtained with
<      * a call to one of the {@link #getContent} methods will also change
<      * to reflect the new content.  In addition, all content in the supplied
<      * collection will have their parentage set to this parent.  If the user
<      * wants to continue working with a <b>"live"</b> list of this parent's
<      * child, then a call to setContent should be followed by a call to one
<      * of the {@link #getContent} methods to obtain a <b>"live"</b>
<      * version of the children.
<      * <p>
<      * Passing a null child clears the existing content.
<      * <p>
<      * In event of an exception the original content will be unchanged and
<      * the supplied child will be unaltered.
<      *
<      * @param child new content to replace existing content
<      * @return           the parent on which the method was called
<      * @throws IllegalAddException if the supplied child is already attached
<      *                             or not legal content for this parent
<      */
<     Parent setContent(Content child);
< 
<     /**
<      * Sets this parent's content to the supplied content list.  The supplied
<      * collection must contain only objects of type {@link Content}.
<      * <p>
<      * If the supplied content is legal content for this parent and before
<      * it is added, all content in the current content list will
<      * be cleared and all current children will have their parentage set to
<      * null.
<      * <p>
<      * This has the effect that any active list (previously obtained with
<      * a call to one of the {@link #getContent} methods will also change
<      * to reflect the new content.  In addition, all content in the supplied
<      * collection will have their parentage set to this parent.  If the user
<      * wants to continue working with a <b>"live"</b> list of this parent's
<      * child, then a call to setContent should be followed by a call to one
<      * of the {@link #getContent} methods to obtain a <b>"live"</b>
<      * version of the children.
<      * <p>
<      * Passing a null or empty Collection clears the existing content.
<      * <p>
<      * In event of an exception the original content will be unchanged and
<      * the content in the supplied collection will be unaltered.
<      *
<      * @param collection new collection of content to replace existing content
<      * @return           the parent on which the method was called
<      * @throws IllegalAddException if any object in the supplied content is
<      *            already attached or not legal content for this parent
<      */
<     Parent setContent(Collection collection);
< 
<     /**
<      * Replaces the current child the given index with the supplied child.
<      * <p>
<      * In event of an exception the original content will be unchanged and
<      * the supplied child will be unaltered.
<      *
<      * @param index index of child to replace
<      * @param child new content to replace the existing content
<      * @return           the parent on which the method was called
<      * @throws IllegalAddException if the supplied child is already attached
<      *                             or not legal content for this parent
<      * @throws IndexOutOfBoundsException if index is negative or beyond
<      *         the current number of children
<      */
<     Parent setContent(int index, Content child);
< 
<     /**
<      * Replaces the child at the given index whith the supplied
<      * collection.
<      * <p>
<      * In event of an exception the original content will be unchanged and
<      * the content in the supplied collection will be unaltered.
<      *
<      * @param index index of child to replace
<      * @param collection collection of content to add
<      * @return           the parent on which the method was called
<      * @throws IllegalAddException if any object in the supplied content is
<      *            already attached or not legal content for this parent
<      * @throws IndexOutOfBoundsException if index is negative or beyond
<      *         the current number of children
<      */
<     Parent setContent(int index, Collection collection);
< 
<     /**
<      * Obtain a deep, unattached copy of this parent and it's children.
<      *
<      * @return a deep copy of this parent and it's children.
<      */
<     Object clone();
< 
<     /**
<      * Returns an {@link java.util.Iterator} that walks over all descendants
<      * in document order.
<      *
<      * @return an iterator to walk descendants
<      */
<     Iterator getDescendants();
< 
<     /**
<      * Returns an {@link java.util.Iterator} that walks over all descendants
<      * in document order applying the Filter to return only elements that
<      * match the filter rule.  With filters you can match only Elements,
<      * only Comments, Elements or Comments, only Elements with a given name
<      * and/or prefix, and so on.
<      *
<      * @return an iterator to walk descendants that match a filter
<      */
<     Iterator getDescendants(Filter filter);
< 
<     /**
<      * Return this parent's parent, or null if this parent is currently
<      * not attached to another parent. This is the same method as in Content but
<      * also added to Parent to allow more easy up-the-tree walking.
<      *
<      * @return this parent's parent or null if none
<      */
<     Parent getParent();
< 
<     /**
<      * Return this parent's owning document or null if the branch containing
<      * this parent is currently not attached to a document.
<      *
<      * @return this child's owning document or null if none
<      */
<     Document getDocument();
< 
<     /**
<      * Checks if this parent can contain the given child at the specified
<      * position, throwing a descriptive IllegalAddException if not and
<      * simply returning if it's allowed.
<      *
<      * @param child   the potential child to be added to this parent
<      * @param index   the location for the potential child
<      * @throws IllegalAddException  if the child add isn't allowed
<      */
<     void canContain(Content child, int index) throws IllegalAddException;
< }
Index: input/SAXHandler.java
===================================================================
retrieving revision 1.64
diff -r1.64 SAXHandler.java
675c675
<             Parent p = currentElement.getParent();
---
>             Container p = currentElement.getParent();
Index: xpath/JaxenXPath.java
===================================================================
retrieving revision 1.16
diff -r1.16 JaxenXPath.java
340c340
<                   Parent p = ((Content) ctx).getParent();
---
>                   Container p = ((Content) ctx).getParent();
Index: src/java/org/jdom/Container.java
===================================================================
RCS file: src/java/org/jdom/Container.java
diff -N src/java/org/jdom/Container.java
0a1,92
> /*--
> 
>  $Id: Parent.java,v 1.9 2004/02/06 09:28:30 jhunter Exp $
> 
>  Copyright (C) 2000-2004 Jason Hunter & Brett McLaughlin.
>  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 <request_AT_jdom_DOT_org>.
> 
>  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 <request_AT_jdom_DOT_org>.
> 
>  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 Jason Hunter <jhunter_AT_jdom_DOT_org> and
>  Brett McLaughlin <brett_AT_jdom_DOT_org>.  For more information
>  on the JDOM Project, please see <http://www.jdom.org/>.
> 
>  */
> 
> package org.jdom;
> 
> import java.io.Serializable;
> import java.util.List;
> 
> /**
>  * Superclass for JDOM objects which are allowed to contain
>  * {@link Content} content.
>  *
>  * @see org.jdom.Content
>  * @see org.jdom.Document
>  * @see org.jdom.Element
>  *
>  * @author Bradley S. Huffman
>  * @author Jason Hunter
>  * @version $Revision: 1.9 $, $Date: 2004/02/06 09:28:30 $
>  */
> public interface Container extends Cloneable, Serializable {
> 
>     /**
>      * Checks if this parent can contain the given child at the specified
>      * position, throwing a descriptive IllegalAddException if not and
>      * simply returning if it's allowed.
>      *
>      * @param child   the potential child to be added to this parent
>      * @param index   the location for the potential child
>      * @throws IllegalAddException  if the child add isn't allowed
>      */
>     void canContain(Content child, int index) throws IllegalAddException;
>     
>     /**
>      * get the underlying ContentList of this Container;
>      * @return
>      */
>     List getContent();
> }



More information about the jdom-interest mailing list