rdonkin 2004/10/04 15:27:13 Modified: betwixt RELEASE-NOTES.txt project.xml betwixt/src/java/org/apache/commons/betwixt ElementDescriptor.java XMLIntrospector.java betwixt/src/java/org/apache/commons/betwixt/digester XMLIntrospectorHelper.java betwixt/src/java/org/apache/commons/betwixt/expression IteratorExpression.java betwixt/src/java/org/apache/commons/betwixt/io BeanRuleSet.java betwixt/src/java/org/apache/commons/betwixt/schema GlobalComplexType.java LocalComplexType.java Schema.java betwixt/src/test/org/apache/commons/betwixt CustomerBean.java TestBeanReader.java betwixt/src/test/org/apache/commons/betwixt/schema TestSchemaGeneration.java TestSchemaValidity.java betwixt/src/test/org/apache/commons/betwixt/strategy TuneBean.java betwixt/xdocs index.xml navigation.xml tasks.xml Log: Merged in release branch Revision Changes Path 1.4 +13 -8 jakarta-commons/betwixt/RELEASE-NOTES.txt Index: RELEASE-NOTES.txt =================================================================== RCS file: /home/cvs/jakarta-commons/betwixt/RELEASE-NOTES.txt,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- RELEASE-NOTES.txt 4 Jul 2004 15:31:17 -0000 1.3 +++ RELEASE-NOTES.txt 4 Oct 2004 22:27:12 -0000 1.4 @@ -1,16 +1,21 @@ $Id$ Commons Betwixt Package - Version 0.5 + Version 0.6 Release Notes INTRODUCTION: -Betwixt provides a flexible way to map beans into XML - and vice versa. This is the -first full Betwixt release. +Betwixt provides a flexible way to map beans into XML - and vice versa. -This release consolidates the codebase released in Alpha-1.0. It is stable and mature -but the design is limited. Newer, more sophisticated designs are being introduced -(in later releses) but they are unlikely to be binary compatible. This API exposed -in this release is therefore not sufficiently stable enough to warrent a 1.0 version -number. +Betwixt release 0.6 is the first release containing the refactored codebase +featuring an improved design. This is a service release for those who have been +using the code from the CVS branch and offers an easy, compatible upgrade path +for those using the 0.5 design. It is recommended that all users should upgrade +to this release since the 0.5 design is no longer actively supported and is +limited in terms of functionality. + +This release is binary compatible with the 0.5 codebase but the methods deprecated +in 0.5 are likely to be removed soon after 0.6 is released. + +For more details see the tasks document. \ No newline at end of file 1.41 +24 -13 jakarta-commons/betwixt/project.xml Index: project.xml =================================================================== RCS file: /home/cvs/jakarta-commons/betwixt/project.xml,v retrieving revision 1.40 retrieving revision 1.41 diff -u -r1.40 -r1.41 --- project.xml 13 Jul 2004 12:46:02 -0000 1.40 +++ project.xml 4 Oct 2004 22:27:12 -0000 1.41 @@ -18,7 +18,7 @@ <pomVersion>3</pomVersion> <name>Betwixt</name> <id>commons-betwixt</id> - <currentVersion>0.6-dev</currentVersion> + <currentVersion>0.6.1-dev</currentVersion> <inceptionYear>2002</inceptionYear> <shortDescription>Commons Betwixt</shortDescription> <description>Commons Betwixt: mapping beans to XML</description> @@ -71,7 +71,12 @@ <version> <id>0.6</id> <name>0.6</name> - <tag>HEAD</tag> + <tag>BETWIXT_0_6</tag> + </version> + <version> + <id>0.5</id> + <name>0.5</name> + <tag>BETWIXT_0_5</tag> </version> </versions> @@ -141,20 +146,18 @@ </dependency> <dependency> - <id>commons-beanutils</id> - <version>1.6.1</version> + <groupId>commons-beanutils</groupId> + <typeId>jar</typeId> + <artifactId>commons-beanutils-core</artifactId> + <version>1.7.0</version> <url>http://jakarta.apache.org/commons/beanutils.html</url> </dependency> - - <dependency> - <id>commons-collections</id> - <version>2.1</version> - <url>http://jakarta.apache.org/commons/collections.html</url> - </dependency> - + <dependency> - <id>commons-digester</id> - <version>1.5</version> + <groupId>commons-digester</groupId> + <typeId>jar</typeId> + <artifactId>commons-digester</artifactId> + <version>1.6</version> <url>http://jakarta.apache.org/commons/digester.html</url> </dependency> @@ -202,6 +205,14 @@ </resource> </resources> </unitTest> + <resources> + <resource> + <directory>${pom.build.sourceDirectory}</directory> + <includes> + <include>**/*.betwixt</include> + </includes> + </resource> + </resources> </build> 1.19 +5 -5 jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/ElementDescriptor.java Index: ElementDescriptor.java =================================================================== RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/ElementDescriptor.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- ElementDescriptor.java 23 Sep 2004 21:46:00 -0000 1.18 +++ ElementDescriptor.java 4 Oct 2004 22:27:12 -0000 1.19 @@ -114,7 +114,7 @@ /** * Base constructor. * @param primitiveType if true, this element refers to a primitive type - * @deprecated PrimitiveType property has been removed + * @deprecated 0.6 PrimitiveType property has been removed */ public ElementDescriptor(boolean primitiveType) { this.primitiveType = primitiveType; @@ -191,7 +191,7 @@ * * @param wrapCollectionsInElement true if the elements for the items in the collection * should be contained in a parent element - * @deprecated moved to a declarative style of descriptors where the alrogithmic should + * @deprecated 0.6 moved to a declarative style of descriptors where the alrogithmic should * be done during introspection */ public void setWrapCollectionsInElement(boolean wrapCollectionsInElement) { @@ -206,7 +206,7 @@ * * @return true if the elements for the items in the collection should be contained * in a parent element - * @deprecated moved to a declarative style of descriptors where the alrogithmic should + * @deprecated 0.6 moved to a declarative style of descriptors where the alrogithmic should * be done during introspection */ public boolean isWrapCollectionsInElement() { @@ -432,7 +432,7 @@ /** * Returns true if this element refers to a primitive type property * @return whether this element refers to a primitive type (or property of a parent object) - * @deprecated moved to a declarative style of descriptors where the alrogithmic should + * @deprecated 0.6 moved to a declarative style of descriptors where the alrogithmic should * be done during introspection */ public boolean isPrimitiveType() { @@ -442,7 +442,7 @@ /** * Sets whether this element refers to a primitive type (or property of a parent object) * @param primitiveType true if this element refers to a primitive type - * @deprecated moved to a declarative style of descriptors where the alrogithmic should + * @deprecated 0.6 moved to a declarative style of descriptors where the alrogithmic should * be done during introspection */ public void setPrimitiveType(boolean primitiveType) { 1.37 +17 -17 jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/XMLIntrospector.java Index: XMLIntrospector.java =================================================================== RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/XMLIntrospector.java,v retrieving revision 1.36 retrieving revision 1.37 diff -u -r1.36 -r1.37 --- XMLIntrospector.java 4 Oct 2004 21:50:35 -0000 1.36 +++ XMLIntrospector.java 4 Oct 2004 22:27:12 -0000 1.37 @@ -77,7 +77,7 @@ public class XMLIntrospector { /** * Log used for logging (Doh!) - * @deprecated use the [EMAIL PROTECTED] #getLog()} property instead + * @deprecated 0.6 use the [EMAIL PROTECTED] #getLog()} property instead */ protected Log log = LogFactory.getLog( XMLIntrospector.class ); @@ -192,7 +192,7 @@ * * @return the <code>ClassNormalizer</code> used to determine the Class to be introspected * for a given Object. - * @deprecated use getConfiguration().getClassNormalizer + * @deprecated 0.6 use getConfiguration().getClassNormalizer * @since 0.5 */ public ClassNormalizer getClassNormalizer() { @@ -206,7 +206,7 @@ * * @param classNormalizer the <code>ClassNormalizer</code> to be used to determine * the Class to be introspected for a given Object. - * @deprecated use getConfiguration().setClassNormalizer + * @deprecated 0.6 use getConfiguration().setClassNormalizer * @since 0.5 * */ @@ -238,7 +238,7 @@ /** * Should attributes (or elements) be used for primitive types. * @return true if primitive types will be mapped to attributes in the introspection - * @deprecated use getConfiguration().isAttributesForPrimitives + * @deprecated 0.6 use getConfiguration().isAttributesForPrimitives */ public boolean isAttributesForPrimitives() { return getConfiguration().isAttributesForPrimitives(); @@ -248,7 +248,7 @@ * Set whether attributes (or elements) should be used for primitive types. * @param attributesForPrimitives pass trus to map primitives to attributes, * pass false to map primitives to elements - * @deprecated use getConfiguration().setAttributesForPrimitives + * @deprecated 0.6 use getConfiguration().setAttributesForPrimitives */ public void setAttributesForPrimitives(boolean attributesForPrimitives) { getConfiguration().setAttributesForPrimitives(attributesForPrimitives); @@ -258,7 +258,7 @@ * Should collections be wrapped in an extra element? * * @return whether we should we wrap collections in an extra element? - * @deprecated use getConfiguration().isWrapCollectionsInElement + * @deprecated 0.6 use getConfiguration().isWrapCollectionsInElement */ public boolean isWrapCollectionsInElement() { return getConfiguration().isWrapCollectionsInElement(); @@ -269,7 +269,7 @@ * * @param wrapCollectionsInElement pass true if collections should be wrapped in a * parent element - * @deprecated use getConfiguration().setWrapCollectionsInElement + * @deprecated 0.6 use getConfiguration().setWrapCollectionsInElement */ public void setWrapCollectionsInElement(boolean wrapCollectionsInElement) { getConfiguration().setWrapCollectionsInElement(wrapCollectionsInElement); @@ -279,7 +279,7 @@ * Get singular and plural matching strategy. * * @return the strategy used to detect matching singular and plural properties - * @deprecated use getConfiguration().getPluralStemmer + * @deprecated 0.6 use getConfiguration().getPluralStemmer */ public PluralStemmer getPluralStemmer() { return getConfiguration().getPluralStemmer(); @@ -289,7 +289,7 @@ * Sets the strategy used to detect matching singular and plural properties * * @param pluralStemmer the PluralStemmer used to match singular and plural - * @deprecated use getConfiguration().setPluralStemmer + * @deprecated 0.6 use getConfiguration().setPluralStemmer */ public void setPluralStemmer(PluralStemmer pluralStemmer) { getConfiguration().setPluralStemmer(pluralStemmer); @@ -322,7 +322,7 @@ * * @return the strategy used to convert bean type names into element * names. If no element mapper is currently defined then a default one is created. - * @deprecated use getConfiguration().getElementNameMapper + * @deprecated 0.6 use getConfiguration().getElementNameMapper */ public NameMapper getElementNameMapper() { return getConfiguration().getElementNameMapper(); @@ -331,7 +331,7 @@ /** * Sets the strategy used to convert bean type names into element names * @param nameMapper the NameMapper to use for the conversion - * @deprecated use getConfiguration().setElementNameMapper + * @deprecated 0.6 use getConfiguration().setElementNameMapper */ public void setElementNameMapper(NameMapper nameMapper) { getConfiguration().setElementNameMapper( nameMapper ); @@ -343,7 +343,7 @@ * * @return the strategy used to convert bean type names into attribute * names. If no attributeNamemapper is known, it will default to the ElementNameMapper - * @deprecated getConfiguration().getAttributeNameMapper + * @deprecated 0.6 getConfiguration().getAttributeNameMapper */ public NameMapper getAttributeNameMapper() { return getConfiguration().getAttributeNameMapper(); @@ -353,7 +353,7 @@ /** * Sets the strategy used to convert bean type names into attribute names * @param nameMapper the NameMapper to use for the convertion - * @deprecated use getConfiguration().setAttributeNameMapper + * @deprecated 0.6 use getConfiguration().setAttributeNameMapper */ public void setAttributeNameMapper(NameMapper nameMapper) { getConfiguration().setAttributeNameMapper( nameMapper ); @@ -364,7 +364,7 @@ * By default it will be false. * * @return boolean if the beanInfoSearchPath should be used. - * @deprecated use getConfiguration().useBeanInfoSearchPath + * @deprecated 0.6 use getConfiguration().useBeanInfoSearchPath */ public boolean useBeanInfoSearchPath() { return getConfiguration().useBeanInfoSearchPath(); @@ -374,7 +374,7 @@ * Specifies if you want to use the beanInfoSearchPath * @see java.beans.Introspector for more details * @param useBeanInfoSearchPath - * @deprecated use getConfiguration().setUseBeanInfoSearchPath + * @deprecated 0.6 use getConfiguration().setUseBeanInfoSearchPath */ public void setUseBeanInfoSearchPath(boolean useBeanInfoSearchPath) { getConfiguration().setUseBeanInfoSearchPath( useBeanInfoSearchPath ); @@ -1014,7 +1014,7 @@ * to detect matching singular and plural properties. * * @return new defualt PluralStemmer implementation - * @deprecated this method has been moved into IntrospectionConfiguration. + * @deprecated 0.6 this method has been moved into IntrospectionConfiguration. * Those who need to vary this should subclass that class instead */ protected PluralStemmer createPluralStemmer() { @@ -1026,7 +1026,7 @@ * used to convert bean type names into element names. * * @return new default NameMapper implementation - * @deprecated this method has been moved into IntrospectionConfiguration. + * @deprecated 0.6 this method has been moved into IntrospectionConfiguration. * Those who need to vary this should subclass that class instead */ protected NameMapper createNameMapper() { 1.33 +8 -8 jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/digester/XMLIntrospectorHelper.java Index: XMLIntrospectorHelper.java =================================================================== RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/digester/XMLIntrospectorHelper.java,v retrieving revision 1.32 retrieving revision 1.33 diff -u -r1.32 -r1.33 --- XMLIntrospectorHelper.java 14 Jul 2004 21:38:17 -0000 1.32 +++ XMLIntrospectorHelper.java 4 Oct 2004 22:27:12 -0000 1.33 @@ -214,7 +214,7 @@ * * @param elementDescriptor configure this <code>ElementDescriptor</code> * @param propertyDescriptor configure from this <code>PropertyDescriptor</code> - * @deprecated unused + * @deprecated 0.6 unused */ public static void configureProperty( ElementDescriptor elementDescriptor, @@ -234,7 +234,7 @@ * @param beanClass the <code>Class</code> from which the update method should be found. * This may be null only when <code>updateMethodName</code> is also null. * @since 0.5 - * @deprecated moved into ElementRule + * @deprecated 0.6 moved into ElementRule */ public static void configureProperty( ElementDescriptor elementDescriptor, @@ -342,7 +342,7 @@ * * @param attributeDescriptor configure this <code>AttributeDescriptor</code> * @param propertyDescriptor configure from this <code>PropertyDescriptor</code> - * @deprecated moved into AttributeRule + * @deprecated 0.6 moved into AttributeRule */ public static void configureProperty( AttributeDescriptor attributeDescriptor, @@ -405,7 +405,7 @@ * @param introspector use this <code>XMLIntrospector</code> for introspection * @param rootDescriptor add defaults to this descriptor * @param beanClass the <code>Class</code> to which descriptor corresponds - * @deprecated use the method in XMLIntrospector instead + * @deprecated 0.6 use the method in XMLIntrospector instead */ public static void defaultAddMethods( XMLIntrospector introspector, @@ -573,7 +573,7 @@ * type can be varied. * @param type is this <code>Class<code> a primitive type? * @return true for primitive types - * @deprecated replaced by [EMAIL PROTECTED] org.apache.commons.betwixt.strategy.TypeBindingStrategy} + * @deprecated 0.6 replaced by [EMAIL PROTECTED] org.apache.commons.betwixt.strategy.TypeBindingStrategy} */ public static boolean isPrimitiveType(Class type) { if ( type == null ) { @@ -610,7 +610,7 @@ * searched for a match * @param propertyName the name of the 'adder' method to match * @return <code>ElementDescriptor</code> for the matching getter - * @deprecated moved into XMLIntrospector + * @deprecated 0.6 moved into XMLIntrospector */ protected static ElementDescriptor findGetCollectionDescriptor( XMLIntrospector introspector, @@ -647,7 +647,7 @@ * @param rootDescriptor the values of the maps are the children of this * <code>ElementDescriptor</code> index by their property names * @param map the map to which the elements will be added - * @deprecated moved into XMLIntrospector + * @deprecated 0.6 moved into XMLIntrospector */ protected static void makeElementDescriptorMap( ElementDescriptor rootDescriptor, Map map ) { ElementDescriptor[] children = rootDescriptor.getElementDescriptors(); @@ -670,7 +670,7 @@ * @param rootDescriptor traverse child graph for this <code>ElementDescriptor</code> * @param oldValue replace this <code>ElementDescriptor</code> * @param newValue replace with this <code>ElementDescriptor</code> - * @deprecated now unused + * @deprecated 0.6 now unused */ protected static void swapDescriptor( ElementDescriptor rootDescriptor, 1.9 +350 -3 jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/expression/IteratorExpression.java Index: IteratorExpression.java =================================================================== RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/expression/IteratorExpression.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- IteratorExpression.java 28 Feb 2004 13:38:32 -0000 1.8 +++ IteratorExpression.java 4 Oct 2004 22:27:12 -0000 1.9 @@ -16,14 +16,14 @@ package org.apache.commons.betwixt.expression; +import java.lang.reflect.Array; import java.util.Collection; import java.util.Collections; import java.util.Enumeration; import java.util.Iterator; import java.util.Map; +import java.util.NoSuchElementException; -import org.apache.commons.collections.iterators.ArrayIterator; -import org.apache.commons.collections.iterators.EnumerationIterator; /** <p><code>IteratorExpression</code> returns an iterator over the current context.</p> * @@ -100,4 +100,351 @@ public String toString() { return "IteratorExpression [expression=" + expression + "]"; } + + + /** + * <code>ArrayIterator</code> originated in commons-collections. Added + * as a private inner class to break dependency. + * + * @author James Strachan + * @author Mauricio S. Moura + * @author Michael A. Smith + * @author Neil O'Toole + * @author Stephen Colebourne + */ + private static final class ArrayIterator implements Iterator { + + /** The array to iterate over */ + protected Object array; + + /** The start index to loop from */ + protected int startIndex = 0; + + /** The end index to loop to */ + protected int endIndex = 0; + + /** The current iterator index */ + protected int index = 0; + + // Constructors + // ---------------------------------------------------------------------- + /** + * Constructor for use with <code>setArray</code>. + * <p> + * Using this constructor, the iterator is equivalent to an empty + * iterator until [EMAIL PROTECTED] #setArray(Object)}is called to establish the + * array to iterate over. + */ + public ArrayIterator() { + super(); + } + + /** + * Constructs an ArrayIterator that will iterate over the values in the + * specified array. + * + * @param array + * the array to iterate over. + * @throws IllegalArgumentException + * if <code>array</code> is not an array. + * @throws NullPointerException + * if <code>array</code> is <code>null</code> + */ + public ArrayIterator(final Object array) { + super(); + setArray(array); + } + + /** + * Constructs an ArrayIterator that will iterate over the values in the + * specified array from a specific start index. + * + * @param array + * the array to iterate over. + * @param startIndex + * the index to start iterating at. + * @throws IllegalArgumentException + * if <code>array</code> is not an array. + * @throws NullPointerException + * if <code>array</code> is <code>null</code> + * @throws IndexOutOfBoundsException + * if the index is invalid + */ + public ArrayIterator(final Object array, final int startIndex) { + super(); + setArray(array); + checkBound(startIndex, "start"); + this.startIndex = startIndex; + this.index = startIndex; + } + + /** + * Construct an ArrayIterator that will iterate over a range of values + * in the specified array. + * + * @param array + * the array to iterate over. + * @param startIndex + * the index to start iterating at. + * @param endIndex + * the index to finish iterating at. + * @throws IllegalArgumentException + * if <code>array</code> is not an array. + * @throws NullPointerException + * if <code>array</code> is <code>null</code> + * @throws IndexOutOfBoundsException + * if either index is invalid + */ + public ArrayIterator(final Object array, final int startIndex, + final int endIndex) { + super(); + setArray(array); + checkBound(startIndex, "start"); + checkBound(endIndex, "end"); + if (endIndex < startIndex) { + throw new IllegalArgumentException( + "End index must not be less than start index."); + } + this.startIndex = startIndex; + this.endIndex = endIndex; + this.index = startIndex; + } + + /** + * Checks whether the index is valid or not. + * + * @param bound + * the index to check + * @param type + * the index type (for error messages) + * @throws IndexOutOfBoundsException + * if the index is invalid + */ + protected void checkBound(final int bound, final String type) { + if (bound > this.endIndex) { + throw new ArrayIndexOutOfBoundsException( + "Attempt to make an ArrayIterator that " + type + + "s beyond the end of the array. "); + } + if (bound < 0) { + throw new ArrayIndexOutOfBoundsException( + "Attempt to make an ArrayIterator that " + type + + "s before the start of the array. "); + } + } + + // Iterator interface + //----------------------------------------------------------------------- + /** + * Returns true if there are more elements to return from the array. + * + * @return true if there is a next element to return + */ + public boolean hasNext() { + return (index < endIndex); + } + + /** + * Returns the next element in the array. + * + * @return the next element in the array + * @throws NoSuchElementException + * if all the elements in the array have already been + * returned + */ + public Object next() { + if (hasNext() == false) { + throw new NoSuchElementException(); + } + return Array.get(array, index++); + } + + /** + * Throws [EMAIL PROTECTED] UnsupportedOperationException}. + * + * @throws UnsupportedOperationException + * always + */ + public void remove() { + throw new UnsupportedOperationException( + "remove() method is not supported"); + } + + // Properties + //----------------------------------------------------------------------- + /** + * Gets the array that this iterator is iterating over. + * + * @return the array this iterator iterates over, or <code>null</code> + * if the no-arg constructor was used and + * [EMAIL PROTECTED] #setArray(Object)}has never been called with a valid + * array. + */ + public Object getArray() { + return array; + } + + /** + * Sets the array that the ArrayIterator should iterate over. + * <p> + * If an array has previously been set (using the single-arg constructor + * or this method) then that array is discarded in favour of this one. + * Iteration is restarted at the start of the new array. Although this + * can be used to reset iteration, the [EMAIL PROTECTED] #reset()}method is a more + * effective choice. + * + * @param array + * the array that the iterator should iterate over. + * @throws IllegalArgumentException + * if <code>array</code> is not an array. + * @throws NullPointerException + * if <code>array</code> is <code>null</code> + */ + public void setArray(final Object array) { + // Array.getLength throws IllegalArgumentException if the object is + // not + // an array or NullPointerException if the object is null. This call + // is made before saving the array and resetting the index so that + // the + // array iterator remains in a consistent state if the argument is + // not + // an array or is null. + this.endIndex = Array.getLength(array); + this.startIndex = 0; + this.array = array; + this.index = 0; + } + + /** + * Resets the iterator back to the start index. + */ + public void reset() { + this.index = this.startIndex; + } + + } + + + /** + * Adapter to make [EMAIL PROTECTED] Enumeration Enumeration}instances appear to be + * [EMAIL PROTECTED] Iterator Iterator}instances. Originated in commons-collections. + * Added as a private inner class to break dependency. + * + * @author <a href="mailto:[EMAIL PROTECTED]">James Strachan </a> + * @author <a href="mailto:[EMAIL PROTECTED]">Daniel Rall </a> + */ + private static final class EnumerationIterator implements Iterator { + + /** The collection to remove elements from */ + private Collection collection; + + /** The enumeration being converted */ + private Enumeration enumeration; + + /** The last object retrieved */ + private Object last; + + // Constructors + //----------------------------------------------------------------------- + /** + * Constructs a new <code>EnumerationIterator</code> that will not + * function until [EMAIL PROTECTED] #setEnumeration(Enumeration)} is called. + */ + public EnumerationIterator() { + this(null, null); + } + + /** + * Constructs a new <code>EnumerationIterator</code> that provides + * an iterator view of the given enumeration. + * + * @param enumeration the enumeration to use + */ + public EnumerationIterator(final Enumeration enumeration) { + this(enumeration, null); + } + + /** + * Constructs a new <code>EnumerationIterator</code> that will remove + * elements from the specified collection. + * + * @param enumeration the enumeration to use + * @param collection the collection to remove elements form + */ + public EnumerationIterator(final Enumeration enumeration, + final Collection collection) { + super(); + this.enumeration = enumeration; + this.collection = collection; + this.last = null; + } + + // Iterator interface + //----------------------------------------------------------------------- + /** + * Returns true if the underlying enumeration has more elements. + * + * @return true if the underlying enumeration has more elements + * @throws NullPointerException if the underlying enumeration is null + */ + public boolean hasNext() { + return enumeration.hasMoreElements(); + } + + /** + * Returns the next object from the enumeration. + * + * @return the next object from the enumeration + * @throws NullPointerException if the enumeration is null + */ + public Object next() { + last = enumeration.nextElement(); + return last; + } + + /** + * Removes the last retrieved element if a collection is attached. + * <p> + * Functions if an associated <code>Collection</code> is known. + * If so, the first occurrence of the last returned object from this + * iterator will be removed from the collection. + * + * @exception IllegalStateException <code>next()</code> not called. + * @exception UnsupportedOperationException if no associated collection + */ + public void remove() { + if (collection != null) { + if (last != null) { + collection.remove(last); + } else { + throw new IllegalStateException( + "next() must have been called for remove() to function"); + } + } else { + throw new UnsupportedOperationException( + "No Collection associated with this Iterator"); + } + } + + // Properties + //----------------------------------------------------------------------- + /** + * Returns the underlying enumeration. + * + * @return the underlying enumeration + */ + public Enumeration getEnumeration() { + return enumeration; + } + + /** + * Sets the underlying enumeration. + * + * @param enumeration the new underlying enumeration + */ + public void setEnumeration(final Enumeration enumeration) { + this.enumeration = enumeration; + } + } + } 1.21 +2 -2 jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/io/BeanRuleSet.java Index: BeanRuleSet.java =================================================================== RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/io/BeanRuleSet.java,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- BeanRuleSet.java 4 Jul 2004 16:58:17 -0000 1.20 +++ BeanRuleSet.java 4 Oct 2004 22:27:12 -0000 1.21 @@ -98,7 +98,7 @@ * @param baseBeanClass the <code>Class</code> whose mapping rules will be created * @param context the root Context that bean carrying Contexts should be obtained from, * not null - * @deprecated use the constructor which takes a ReadContext instead + * @deprecated 0.6 use the constructor which takes a ReadContext instead */ public BeanRuleSet( XMLIntrospector introspector, 1.3 +19 -4 jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/schema/GlobalComplexType.java Index: GlobalComplexType.java =================================================================== RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/schema/GlobalComplexType.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- GlobalComplexType.java 16 Jun 2004 11:21:26 -0000 1.2 +++ GlobalComplexType.java 4 Oct 2004 22:27:12 -0000 1.3 @@ -18,9 +18,9 @@ import java.beans.IntrospectionException; import java.util.Iterator; +import java.util.Collection; import org.apache.commons.betwixt.ElementDescriptor; -import org.apache.commons.collections.CollectionUtils; /** * Models a <code>complexType</code> from an XML schema. @@ -68,8 +68,8 @@ if (obj instanceof GlobalComplexType) { GlobalComplexType complexType = (GlobalComplexType) obj; result = isEqual(name, complexType.name) && - CollectionUtils.isEqualCollection(attributes, complexType.attributes) && - CollectionUtils.isEqualCollection(elements, complexType.elements); + equalContents(attributes, complexType.attributes) && + equalContents(elements, complexType.elements); } return result; @@ -77,6 +77,21 @@ public int hashCode() { return 0; + } + + private boolean equalContents(Collection one, Collection two) + { + // doesn't check cardinality but should be ok + if (one.size() != two.size()) { + return false; + } + for (Iterator it=one.iterator();it.hasNext();) { + Object object = it.next(); + if (!two.contains(object)) { + return false; + } + } + return true; } /** 1.3 +20 -4 jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/schema/LocalComplexType.java Index: LocalComplexType.java =================================================================== RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/schema/LocalComplexType.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- LocalComplexType.java 16 Jun 2004 11:21:26 -0000 1.2 +++ LocalComplexType.java 4 Oct 2004 22:27:12 -0000 1.3 @@ -18,9 +18,9 @@ import java.beans.IntrospectionException; import java.util.Iterator; +import java.util.Collection; import org.apache.commons.betwixt.ElementDescriptor; -import org.apache.commons.collections.CollectionUtils; /** * @author <a href='http://jakarta.apache.org/'>Jakarta Commons Team</a> @@ -40,12 +40,28 @@ if (obj instanceof GlobalComplexType) { GlobalComplexType complexType = (GlobalComplexType) obj; result = - CollectionUtils.isEqualCollection(attributes, complexType.attributes) && - CollectionUtils.isEqualCollection(elements, complexType.elements); + equalContents(attributes, complexType.attributes) && + equalContents(elements, complexType.elements); } return result; } + + + private boolean equalContents(Collection one, Collection two) + { + // doesn't check cardinality but should be ok + if (one.size() != two.size()) { + return false; + } + for (Iterator it=one.iterator();it.hasNext();) { + Object object = it.next(); + if (!two.contains(object)) { + return false; + } + } + return true; + } public int hashCode() { return 0; 1.3 +20 -5 jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/schema/Schema.java Index: Schema.java =================================================================== RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/schema/Schema.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- Schema.java 16 Jun 2004 11:21:26 -0000 1.2 +++ Schema.java 4 Oct 2004 22:27:12 -0000 1.3 @@ -20,11 +20,11 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import java.util.Collection; import org.apache.commons.betwixt.ElementDescriptor; import org.apache.commons.betwixt.XMLBeanInfo; import org.apache.commons.betwixt.XMLIntrospector; -import org.apache.commons.collections.CollectionUtils; /** * Model for top level element in an XML Schema @@ -130,11 +130,26 @@ if (obj instanceof Schema) { Schema schema = (Schema) obj; result = - CollectionUtils.isEqualCollection(elements, schema.elements) && - CollectionUtils.isEqualCollection(complexTypes, schema.complexTypes) && - CollectionUtils.isEqualCollection(simpleTypes, schema.simpleTypes); + equalContents(elements, schema.elements) && + equalContents(complexTypes, schema.complexTypes) && + equalContents(simpleTypes, schema.simpleTypes); } return result; + } + + private boolean equalContents(Collection one, Collection two) + { + // doesn't check cardinality but should be ok + if (one.size() != two.size()) { + return false; + } + for (Iterator it=one.iterator();it.hasNext();) { + Object object = it.next(); + if (!two.contains(object)) { + return false; + } + } + return true; } public int hashCode() { 1.13 +79 -1 jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/CustomerBean.java Index: CustomerBean.java =================================================================== RCS file: /home/cvs/jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/CustomerBean.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- CustomerBean.java 28 Feb 2004 13:38:34 -0000 1.12 +++ CustomerBean.java 4 Oct 2004 22:27:12 -0000 1.13 @@ -27,7 +27,6 @@ import java.util.List; import java.util.Map; -import org.apache.commons.collections.iterators.IteratorEnumeration; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -273,5 +272,84 @@ public void setBigInteger(BigInteger bigInteger) { this.bigInteger = bigInteger; } + + /** + * Adapter to make an [EMAIL PROTECTED] Iterator Iterator} instance appear to be + * an [EMAIL PROTECTED] Enumeration Enumeration} instance. + * Originate in commons collections + * + * @author <a href="mailto:[EMAIL PROTECTED]">James Strachan</a> + */ + private static final class IteratorEnumeration implements Enumeration { + + /** The iterator being decorated. */ + private Iterator iterator; + + /** + * Constructs a new <code>IteratorEnumeration</code> that will not + * function until [EMAIL PROTECTED] #setIterator(Iterator) setIterator} is + * invoked. + */ + public IteratorEnumeration() { + super(); + } + + /** + * Constructs a new <code>IteratorEnumeration</code> that will use + * the given iterator. + * + * @param iterator the iterator to use + */ + public IteratorEnumeration( Iterator iterator ) { + super(); + this.iterator = iterator; + } + + // Iterator interface + //------------------------------------------------------------------------- + + /** + * Returns true if the underlying iterator has more elements. + * + * @return true if the underlying iterator has more elements + */ + public boolean hasMoreElements() { + return iterator.hasNext(); + } + + /** + * Returns the next element from the underlying iterator. + * + * @return the next element from the underlying iterator. + * @throws java.util.NoSuchElementException if the underlying iterator has no + * more elements + */ + public Object nextElement() { + return iterator.next(); + } + + // Properties + //------------------------------------------------------------------------- + + /** + * Returns the underlying iterator. + * + * @return the underlying iterator + */ + public Iterator getIterator() { + return iterator; + } + + /** + * Sets the underlying iterator. + * + * @param iterator the new underlying iterator + */ + public void setIterator( Iterator iterator ) { + this.iterator = iterator; + } + + } + } 1.24 +4 -2 jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/TestBeanReader.java Index: TestBeanReader.java =================================================================== RCS file: /home/cvs/jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/TestBeanReader.java,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- TestBeanReader.java 13 Jun 2004 21:32:46 -0000 1.23 +++ TestBeanReader.java 4 Oct 2004 22:27:12 -0000 1.24 @@ -31,6 +31,7 @@ import java.util.ArrayList; import java.util.Calendar; import java.util.List; +import java.util.Iterator; import junit.framework.Test; import junit.framework.TestSuite; @@ -43,7 +44,6 @@ import org.apache.commons.betwixt.io.BeanWriter; import org.apache.commons.betwixt.strategy.ConvertUtilsObjectStringConverter; import org.apache.commons.betwixt.strategy.HyphenatedNameMapper; -import org.apache.commons.collections.CollectionUtils; import org.apache.commons.digester.ExtendedBaseRules; import org.apache.commons.digester.Rule; import org.xml.sax.Attributes; @@ -706,7 +706,9 @@ assertEquals("Number of children", 6, bean.getSize()); ArrayList list = new ArrayList(); - CollectionUtils.addAll(list, bean.getChildren()); + for (Iterator it=bean.getChildren();it.hasNext();) { + list.add(it.next()); + } DoubleLinkedChildBean childZero = (DoubleLinkedChildBean) list.get(0); DoubleLinkedChildBean childOne = (DoubleLinkedChildBean) list.get(1); 1.3 +6 -11 jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/schema/TestSchemaGeneration.java Index: TestSchemaGeneration.java =================================================================== RCS file: /home/cvs/jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/schema/TestSchemaGeneration.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- TestSchemaGeneration.java 13 Jun 2004 21:32:48 -0000 1.2 +++ TestSchemaGeneration.java 4 Oct 2004 22:27:13 -0000 1.3 @@ -34,12 +34,7 @@ super(name); } - public void testDummy() { - // the tests here require digester CVS HEAD to function correctly - // they should be readded as soon as the digester release has been created - } - - public void _testSimplestBeanWithAttributes() throws Exception { + public void testSimplestBeanWithAttributes() throws Exception { SchemaTranscriber transcriber = new SchemaTranscriber(); transcriber.getXMLIntrospector().getConfiguration().setAttributesForPrimitives(true); Schema schema = transcriber.generate(SimplestBean.class); @@ -65,7 +60,7 @@ } - public void _testSimplestBeanWithElement() throws Exception { + public void testSimplestBeanWithElement() throws Exception { SchemaTranscriber transcriber = new SchemaTranscriber(); transcriber.getXMLIntrospector().getConfiguration().setAttributesForPrimitives(true); Schema schema = transcriber.generate(SimplestElementBean.class); @@ -91,7 +86,7 @@ xmlAssertIsomorphicContent(parseString(expected), parseString(xsd)); } - public void _testSimpleBean() throws Exception { + public void testSimpleBean() throws Exception { SchemaTranscriber transcriber = new SchemaTranscriber(); Schema schema = transcriber.generate(SimpleBean.class); @@ -120,7 +115,7 @@ } - public void _testOrderLineBean() throws Exception { + public void testOrderLineBean() throws Exception { SchemaTranscriber transcriber = new SchemaTranscriber(); transcriber.getXMLIntrospector().getConfiguration().setAttributesForPrimitives(true); transcriber.getXMLIntrospector().getConfiguration().setAttributeNameMapper(new HyphenatedNameMapper()); @@ -155,7 +150,7 @@ xmlAssertIsomorphicContent(parseString(expected), parseString(xsd), true); } - public void _testOrder() throws Exception { + public void testOrder() throws Exception { SchemaTranscriber transcriber = new SchemaTranscriber(); transcriber.getXMLIntrospector().getConfiguration().setElementNameMapper(new HyphenatedNameMapper()); transcriber.getXMLIntrospector().getConfiguration().setAttributeNameMapper(new HyphenatedNameMapper()); 1.3 +8 -13 jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/schema/TestSchemaValidity.java Index: TestSchemaValidity.java =================================================================== RCS file: /home/cvs/jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/schema/TestSchemaValidity.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- TestSchemaValidity.java 13 Jun 2004 21:32:48 -0000 1.2 +++ TestSchemaValidity.java 4 Oct 2004 22:27:13 -0000 1.3 @@ -40,11 +40,6 @@ super(name); } - public void testDummy() { - // the tests here require digester CVS HEAD to function correctly - // they should be readded as soon as the digester release has been created - } - private String generateSchema(Class clazz) throws Exception { SchemaTranscriber transcriber = new SchemaTranscriber(); transcriber.getXMLIntrospector().getConfiguration().setAttributesForPrimitives(true); @@ -61,7 +56,7 @@ return xsd; } - public void _testSimplestBeanWithAttributes() throws Exception { + public void testSimplestBeanWithAttributes() throws Exception { String xsd = generateSchema(SimplestBean.class); StringWriter out = new StringWriter(); @@ -79,7 +74,7 @@ } - public void _testSimplestBeanWithElements() throws Exception { + public void testSimplestBeanWithElements() throws Exception { String xsd = generateSchema(SimplestElementBean.class); StringWriter out = new StringWriter(); @@ -97,7 +92,7 @@ } - public void _testSimpleBean() throws Exception { + public void testSimpleBean() throws Exception { String xsd = generateSchema(SimpleBean.class); StringWriter out = new StringWriter(); @@ -131,7 +126,7 @@ return xsd; } - public void _testOrderLine() throws Exception { + public void testOrderLine() throws Exception { String xsd = generateOrderLineSchema(); StringWriter out = new StringWriter(); @@ -168,7 +163,7 @@ return xsd; } - public void _testOrder() throws Exception { + public void testOrder() throws Exception { String xsd = generateOrderSchema(); StringWriter out = new StringWriter(); out.write("<?xml version='1.0'?>"); @@ -188,7 +183,7 @@ writer.write(bean); String xml = out.getBuffer().toString(); - + xmlAssertIsValid(new InputSource(new StringReader(xml)), new InputSource(new StringReader(xsd))); } @@ -209,7 +204,7 @@ return xsd; } - public void _testRSS() throws Exception { + public void testRSS() throws Exception { String xsd = generateRSSSchema(); StringWriter out = new StringWriter(); out.write("<?xml version='1.0'?>"); 1.3 +12 -3 jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/strategy/TuneBean.java Index: TuneBean.java =================================================================== RCS file: /home/cvs/jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/strategy/TuneBean.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- TuneBean.java 13 Jun 2004 21:32:49 -0000 1.2 +++ TuneBean.java 4 Oct 2004 22:27:13 -0000 1.3 @@ -21,7 +21,6 @@ import java.util.Collection; import java.util.Iterator; -import org.apache.commons.collections.CollectionUtils; /** * @author <a href='http://jakarta.apache.org/'>Jakarta Commons Team</a> @@ -74,6 +73,16 @@ } public boolean sameComposers(Collection otherComposers) { - return CollectionUtils.isEqualCollection(otherComposers, composers); + // doesn't check cardinality but should be ok + if (otherComposers.size() != composers.size()) { + return false; + } + for (Iterator it=composers.iterator();it.hasNext();) { + Object object = it.next(); + if (!otherComposers.contains(object)) { + return false; + } + } + return true; } } 1.10 +21 -0 jakarta-commons/betwixt/xdocs/index.xml Index: index.xml =================================================================== RCS file: /home/cvs/jakarta-commons/betwixt/xdocs/index.xml,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- index.xml 3 Jul 2004 11:18:02 -0000 1.9 +++ index.xml 4 Oct 2004 22:27:13 -0000 1.10 @@ -41,6 +41,27 @@ </section> <section name="Releases"> + <subsection name='Betwixt 0.6'> + <p> +Betwixt release 0.6 is the first release containing the refactored codebase +featuring an improved design. This is a service release for those who have been +using the code from the CVS branch and offers an easy, compatible upgrade path +for those using the 0.5 design. It is recommended that all users should upgrade +to this release since the 0.5 design is no longer actively supported and is +limited in terms of functionality. + </p> + <p> +This release is binary compatible with the 0.5 codebase but the methods deprecated +in 0.5 are likely to be removed soon after 0.6 is released. + </p> + <p> +Betwixt 0.6 is available in +<a href='http://jakarta.apache.org/site/binindex.cgi#commons-betwixt'>binary</a> +and +<a href='http://jakarta.apache.org/site/sourceindex.cgi#commons-betwixt'>source</a> +distributions. + </p> + </subsection> <subsection name="Betwixt 0.5"> <p> Betwixt release 0.5 is intended to consolidate the codebase released as 1.0 Alpha 1. 1.17 +1 -0 jakarta-commons/betwixt/xdocs/navigation.xml Index: navigation.xml =================================================================== RCS file: /home/cvs/jakarta-commons/betwixt/xdocs/navigation.xml,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- navigation.xml 23 Sep 2004 21:46:01 -0000 1.16 +++ navigation.xml 4 Oct 2004 22:27:13 -0000 1.17 @@ -53,6 +53,7 @@ <item name="Tutorial" href="/guide/tutorial.html"/> </menu> <menu name='Release Documentation'> + <item name='0.6' href='http://jakarta.apache.org/commons/betwixt/betwixt-0.6'/> <item name='0.5' href='http://jakarta.apache.org/commons/betwixt/betwixt-0.5'/> </menu> 1.38 +2 -2 jakarta-commons/betwixt/xdocs/tasks.xml Index: tasks.xml =================================================================== RCS file: /home/cvs/jakarta-commons/betwixt/xdocs/tasks.xml,v retrieving revision 1.37 retrieving revision 1.38 diff -u -r1.37 -r1.38 --- tasks.xml 4 Oct 2004 21:49:20 -0000 1.37 +++ tasks.xml 4 Oct 2004 22:27:13 -0000 1.38 @@ -330,7 +330,7 @@ </subsection> </section> <section name='Deprecated'> - <subsection name='Since 0.5'> + <subsection name='0.6'> <ul> <li><strong>Refactoring (more declarative descriptors)</strong> <ul> @@ -432,7 +432,7 @@ </subsection> </section> <section name='Backwards Incompatible Changes'> - <subsection name='Since 0.5'> + <subsection name='0.6'> <ul> </ul> </subsection>
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]