rdonkin 2003/01/06 14:50:45 Modified: betwixt checkstyle.properties betwixt/src/java/org/apache/commons/betwixt ElementDescriptor.java XMLIntrospector.java betwixt/src/java/org/apache/commons/betwixt/digester AddDefaultsRule.java AttributeRule.java ElementRule.java InfoRule.java XMLIntrospectorHelper.java betwixt/src/java/org/apache/commons/betwixt/expression IteratorExpression.java MethodExpression.java MethodUpdater.java betwixt/src/java/org/apache/commons/betwixt/io AbstractBeanWriter.java BeanCreateRule.java BeanWriter.java CyclicReferenceException.java betwixt/src/java/org/apache/commons/betwixt/io/id AbstractIDGenerator.java RandomIDGenerator.java SequentialIDGenerator.java betwixt/src/java/org/apache/commons/betwixt/registry DefaultXMLBeanInfoRegistry.java NoCacheRegistry.java XMLBeanInfoRegistry.java betwixt/src/java/org/apache/commons/betwixt/strategy CapitalizeNameMapper.java DecapitalizeNameMapper.java DefaultNameMapper.java DefaultPluralStemmer.java HyphenatedNameMapper.java NameMapper.java PluralStemmer.java Log: Enhanced java doc comments and corrected style issues (thanks checkstyle!) Revision Changes Path 1.3 +2 -1 jakarta-commons/betwixt/checkstyle.properties Index: checkstyle.properties =================================================================== RCS file: /home/cvs/jakarta-commons/betwixt/checkstyle.properties,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- checkstyle.properties 6 Jan 2003 21:23:00 -0000 1.2 +++ checkstyle.properties 6 Jan 2003 22:50:43 -0000 1.3 @@ -5,5 +5,6 @@ checkstyle.ignore.public.in.interface = true ## allow singletons to be named any-which-way-but-loose checkstyle.pattern.const = ^[a-zA-Z0-9_]*$ - +## don't complain about CyclicReferenceException's +checkstyle.javadoc.checkUnusedThrows = true 1.5 +4 -8 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.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- ElementDescriptor.java 11 Dec 2002 22:12:10 -0000 1.4 +++ ElementDescriptor.java 6 Jan 2003 22:50:44 -0000 1.5 @@ -178,8 +178,7 @@ if ( attributeDescriptors == null ) { if ( attributeList == null ) { attributeDescriptors = new AttributeDescriptor[0]; - } - else { + } else { attributeDescriptors = new AttributeDescriptor[ attributeList.size() ]; attributeList.toArray( attributeDescriptors ); @@ -209,8 +208,7 @@ if ( elementDescriptors == null ) { if ( elementList == null ) { elementDescriptors = new ElementDescriptor[0]; - } - else { + } else { elementDescriptors = new ElementDescriptor[ elementList.size() ]; elementList.toArray( elementDescriptors ); @@ -265,8 +263,7 @@ } // force lazy recreation later attributeDescriptors = null; - } - else { + } else { attributeList = new ArrayList(); } } @@ -284,8 +281,7 @@ } // force lazy recreation later elementDescriptors = null; - } - else { + } else { elementList = new ArrayList(); } } 1.18 +5 -10 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.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- XMLIntrospector.java 5 Jan 2003 17:18:32 -0000 1.17 +++ XMLIntrospector.java 6 Jan 2003 22:50:44 -0000 1.18 @@ -224,8 +224,7 @@ public XMLBeanInfo introspect(Class aClass) throws IntrospectionException { // we first reset the beaninfo searchpath. String[] searchPath = null; - if (!useBeanInfoSearchPath) - { + if (!useBeanInfoSearchPath) { searchPath = Introspector.getBeanInfoSearchPath(); Introspector.setBeanInfoSearchPath(new String[] { }); } @@ -254,8 +253,7 @@ if (log.isTraceEnabled()) { log.trace(xmlInfo); } - if (!useBeanInfoSearchPath) - { + if (!useBeanInfoSearchPath) { // we restore the beaninfo searchpath. Introspector.setBeanInfoSearchPath(searchPath); } @@ -286,8 +284,7 @@ if ( isPrimitiveType( beanClass ) ) { elementDescriptor.setTextExpression( StringExpression.getInstance() ); elementDescriptor.setPrimitiveType(true); - } - else if ( isLoopType( beanClass ) ) { + } else if ( isLoopType( beanClass ) ) { ElementDescriptor loopDescriptor = new ElementDescriptor(); loopDescriptor.setContextExpression( new IteratorExpression( EmptyExpression.getInstance() ) @@ -302,8 +299,7 @@ new IteratorExpression( EmptyExpression.getInstance() ) ); */ - } - else { + } else { List elements = new ArrayList(); List attributes = new ArrayList(); @@ -504,8 +500,7 @@ } digester.setBeanClass( aClass ); return (XMLBeanInfo) digester.parse( urlText ); - } - catch (Exception e) { + } catch (Exception e) { log.warn( "Caught exception trying to parse: " + name, e ); } } 1.5 +8 -14 jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/digester/AddDefaultsRule.java Index: AddDefaultsRule.java =================================================================== RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/digester/AddDefaultsRule.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- AddDefaultsRule.java 5 Jan 2003 17:18:32 -0000 1.4 +++ AddDefaultsRule.java 6 Jan 2003 22:50:44 -0000 1.5 @@ -122,8 +122,7 @@ } } } - } - catch (Exception e) { + } catch (Exception e) { log.info( "Caught introspection exception", e ); } } @@ -151,26 +150,21 @@ ElementDescriptor root = beanInfo.getElementDescriptor() ; if ( root == null ) { beanInfo.setElementDescriptor( elementDescriptor ); - } - else { + } else { root.addElementDescriptor( elementDescriptor ); } - } - else { + } else { throw new SAXException( "the <addDefaults> element should be within an <element> tag" ); } - } - else if ( top instanceof ElementDescriptor ) { + } else if ( top instanceof ElementDescriptor ) { ElementDescriptor parent = (ElementDescriptor) top; if ( nodeDescriptor instanceof ElementDescriptor ) { parent.addElementDescriptor( (ElementDescriptor) nodeDescriptor ); - } - else { + } else { parent.addAttributeDescriptor( (AttributeDescriptor) nodeDescriptor ); } - } - else { + } else { throw new SAXException( "Invalid use of <addDefaults>. It should be nested inside <element> element" ); } @@ -181,8 +175,8 @@ if ( top instanceof XMLBeanInfo ) { XMLBeanInfo beanInfo = (XMLBeanInfo) top; return beanInfo.getElementDescriptor(); - } - else if ( top instanceof ElementDescriptor ) { + + } else if ( top instanceof ElementDescriptor ) { ElementDescriptor parent = (ElementDescriptor) top; // XXX: could maybe walk up the parent hierarchy? return parent; 1.4 +4 -8 jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/digester/AttributeRule.java Index: AttributeRule.java =================================================================== RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/digester/AttributeRule.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- AttributeRule.java 5 Jan 2003 17:18:32 -0000 1.3 +++ AttributeRule.java 6 Jan 2003 22:50:44 -0000 1.4 @@ -111,8 +111,7 @@ if ( propertyName != null && propertyName.length() > 0 ) { configureDescriptor(descriptor); - } - else { + } else { String value = attributes.getValue( "value" ); if ( value != null ) { descriptor.setTextExpression( new ConstantExpression( value ) ); @@ -123,8 +122,7 @@ if ( top instanceof ElementDescriptor ) { ElementDescriptor parent = (ElementDescriptor) top; parent.addAttributeDescriptor( descriptor ); - } - else { + } else { throw new SAXException( "Invalid use of <attribute>. It should " + "be nested inside an <element> element" ); } @@ -148,8 +146,7 @@ if ( name != null ) { try { return classLoader.loadClass(name); - } - catch (Exception e) { // SWALLOW + } catch (Exception e) { // SWALLOW } } return null; @@ -174,8 +171,7 @@ } } } - } - catch (Exception e) { + } catch (Exception e) { log.warn( "Caught introspection exception", e ); } } 1.5 +8 -10 jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/digester/ElementRule.java Index: ElementRule.java =================================================================== RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/digester/ElementRule.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- ElementRule.java 5 Jan 2003 17:18:32 -0000 1.4 +++ ElementRule.java 6 Jan 2003 22:50:44 -0000 1.5 @@ -127,8 +127,8 @@ if ( propertyName != null && propertyName.length() > 0 ) { configureDescriptor(descriptor); - } - else { + + } else { String value = attributes.getValue( "value" ); if ( value != null ) { descriptor.setTextExpression( new ConstantExpression( value ) ); @@ -140,12 +140,12 @@ XMLBeanInfo beanInfo = (XMLBeanInfo) top; beanInfo.setElementDescriptor( descriptor ); beanClass = beanInfo.getBeanClass(); - } - else if ( top instanceof ElementDescriptor ) { + + } else if ( top instanceof ElementDescriptor ) { ElementDescriptor parent = (ElementDescriptor) top; parent.addElementDescriptor( descriptor ); - } - else { + + } else { throw new SAXException( "Invalid use of <element>. It should " + "be nested inside <info> or other <element> nodes" ); } @@ -177,8 +177,7 @@ } return answer; } - } - catch (Exception e) { + } catch (Exception e) { log.warn("Cannot load specified type", e); } } @@ -238,8 +237,7 @@ } log.trace("No match found."); return null; - } - catch (Exception e) { + } catch (Exception e) { log.warn( "Caught introspection exception", e ); } } 1.4 +4 -5 jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/digester/InfoRule.java Index: InfoRule.java =================================================================== RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/digester/InfoRule.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- InfoRule.java 5 Jan 2003 17:18:32 -0000 1.3 +++ InfoRule.java 6 Jan 2003 22:50:44 -0000 1.4 @@ -99,12 +99,11 @@ if ( value != null ) { if ( value.equalsIgnoreCase( "element" ) ) { getXMLInfoDigester().setAttributesForPrimitives( false ); - } - else - if ( value.equalsIgnoreCase( "attribute" ) ) { + + } else if ( value.equalsIgnoreCase( "attribute" ) ) { getXMLInfoDigester().setAttributesForPrimitives( true ); - } - else { + + } else { // XXX Should this be a checked exception? throw new Exception( "Invalid value inside element <info> for attribute 'primitiveTypes'." 1.14 +13 -19 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.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- XMLIntrospectorHelper.java 5 Jan 2003 17:18:32 -0000 1.13 +++ XMLIntrospectorHelper.java 6 Jan 2003 22:50:44 -0000 1.14 @@ -160,8 +160,7 @@ log.trace( "Adding property as attribute: " + name ); } nodeDescriptor = new AttributeDescriptor(); - } - else { + } else { if (log.isTraceEnabled()) { log.trace( "Adding property as element: " + name ); } @@ -172,8 +171,7 @@ if ( writeMethod != null ) { nodeDescriptor.setUpdater( new MethodUpdater( writeMethod ) ); } - } - else if ( isLoopType( type ) ) { + } else if ( isLoopType( type ) ) { if (log.isTraceEnabled()) { log.trace("Loop type: " + name); } @@ -193,8 +191,7 @@ elementDescriptor.setElementDescriptors( new ElementDescriptor[] { loopDescriptor } ); nodeDescriptor = elementDescriptor; - } - else { + } else { if (log.isTraceEnabled()) { log.trace( "Standard property: " + name); } @@ -211,8 +208,7 @@ // we want to use the attributemapper only when it is an attribute.. nodeDescriptor.setLocalName( introspector.getAttributeNameMapper().mapTypeToElementName( name ) ); - } - else { + } else { nodeDescriptor.setLocalName( introspector.getElementNameMapper().mapTypeToElementName( name ) ); } @@ -260,8 +256,7 @@ if ( isPrimitiveType( type ) ) { elementDescriptor.setTextExpression( new MethodExpression( readMethod ) ); elementDescriptor.setPrimitiveType(true); - } - else if ( isLoopType( type ) ) { + } else if ( isLoopType( type ) ) { log.trace("Loop type ??"); // don't wrap this in an extra element as its specified in the @@ -271,8 +266,7 @@ ); writeMethod = null; - } - else { + } else { log.trace( "Standard property" ); elementDescriptor.setContextExpression( new MethodExpression( readMethod ) ); } @@ -397,8 +391,7 @@ .mapTypeToElementName( propertyName ) ); } } - } - else { + } else { if ( log.isDebugEnabled() ) { log.debug( "Could not find an ElementDescriptor with property name: " @@ -426,11 +419,11 @@ public static boolean isPrimitiveType(Class type) { if ( type == null ) { return false; - } - else if ( type.isPrimitive() ) { + + } else if ( type.isPrimitive() ) { return true; - } - else if ( type.equals( Object.class ) ) { + + } else if ( type.equals( Object.class ) ) { return false; } return type.getName().startsWith( "java.lang." ) @@ -475,7 +468,8 @@ if ( log.isTraceEnabled() ) { log.trace( - "findPluralDescriptor( " + propertyName + " ):ElementDescriptor=" + elementDescriptor ); + "findPluralDescriptor( " + propertyName + + " ):ElementDescriptor=" + elementDescriptor ); } return elementDescriptor; 1.4 +8 -8 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.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- IteratorExpression.java 30 Dec 2002 17:33:48 -0000 1.3 +++ IteratorExpression.java 6 Jan 2003 22:50:44 -0000 1.4 @@ -97,22 +97,22 @@ if ( value instanceof Iterator ) { // if the value is an iterator, we're done return (Iterator) value; - } - else if ( value instanceof Collection ) { + + } else if ( value instanceof Collection ) { // if it's a collection, return an iterator for that collection Collection collection = (Collection) value; return collection.iterator(); - } - else if ( value instanceof Map ) { + + } else if ( value instanceof Map ) { // if it's a map, return an iterator for the map entries Map map = (Map) value; return map.entrySet().iterator(); - } - else if ( value instanceof Enumeration ) { + + } else if ( value instanceof Enumeration ) { // if it's an enumeration, wrap it in an EnumerationIterator return new EnumerationIterator( (Enumeration) value ); - } - else if ( value != null ) { + + } else if ( value != null ) { // if we have an array return an ArrayIterator Class type = value.getClass(); if ( type.isArray() ) { 1.3 +5 -6 jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/expression/MethodExpression.java Index: MethodExpression.java =================================================================== RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/expression/MethodExpression.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- MethodExpression.java 1 Jul 2002 18:56:26 -0000 1.2 +++ MethodExpression.java 6 Jan 2003 22:50:44 -0000 1.3 @@ -72,6 +72,7 @@ /** null arguments */ protected static Object[] NULL_ARGUMENTS; + /** null classes */ protected static Class[] NULL_CLASSES; /** The method to call on the bean */ @@ -93,8 +94,8 @@ Object[] arguments = getArguments(); try { return method.invoke( bean, arguments ); - } - catch (IllegalAccessException e) { + + } catch (IllegalAccessException e) { // lets try use another method with the same name try { Class type = bean.getClass(); @@ -102,12 +103,10 @@ if ( alternate != null ) { return alternate.invoke( bean, arguments ); } - } - catch (Exception e2) { + } catch (Exception e2) { handleException(context, e2); } - } - catch (Exception e) { + } catch (Exception e) { handleException(context, e); } } 1.6 +2 -2 jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/expression/MethodUpdater.java Index: MethodUpdater.java =================================================================== RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/expression/MethodUpdater.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- MethodUpdater.java 30 Dec 2002 18:18:37 -0000 1.5 +++ MethodUpdater.java 6 Jan 2003 22:50:44 -0000 1.6 @@ -129,8 +129,8 @@ ); } method.invoke( bean, arguments ); - } - catch (Exception e) { + + } catch (Exception e) { String valueTypeName = (newValue != null) ? newValue.getClass().getName() : "null"; log.warn( "Cannot evaluate method: " + method.getName() + " on bean: " + bean 1.10 +232 -79 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.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- AbstractBeanWriter.java 5 Jan 2003 17:18:32 -0000 1.9 +++ AbstractBeanWriter.java 6 Jan 2003 22:50:44 -0000 1.10 @@ -87,28 +87,53 @@ // but this is a poor strategy /** + * <p>Abstract superclass for bean writers. + * This class encapsulates the processing logic. + * Subclasses provide implementations for the actual expression of the xml.</p> + * * @author <a href="mailto:[EMAIL PROTECTED]">Robert Burrell Donkin</a> * @version $Revision$ */ -abstract public class AbstractBeanWriter { +public abstract class AbstractBeanWriter { /** Introspector used */ - protected XMLIntrospector introspector = new XMLIntrospector(); + private XMLIntrospector introspector = new XMLIntrospector(); /** Log used for logging (Doh!) */ private Log log = LogFactory.getLog( AbstractBeanWriter.class ); /** Map containing ID attribute values for beans */ - protected HashMap idMap = new HashMap(); + private HashMap idMap = new HashMap(); /** Stack containing beans - used to detect cycles */ private ArrayStack beanStack = new ArrayStack(); /** Used to generate ID attribute values*/ - protected IDGenerator idGenerator = new SequentialIDGenerator(); + private IDGenerator idGenerator = new SequentialIDGenerator(); /** Should generated <code>ID</code> attribute values be added to the elements? */ - protected boolean writeIDs = true; + private boolean writeIDs = true; /** indentation level */ - protected int indentLevel; - + private int indentLevel; + + /** + * Marks the start of the bean writing. + * By default doesn't do anything, but can be used + * to do extra start processing + * @throws IOException if an IO problem occurs during writing + * @throws SAXException if an SAX problem occurs during writing + */ + public void start() throws IOException, SAXException { + } + + /** + * Marks the start of the bean writing. + * By default doesn't do anything, but can be used + * to do extra end processing + * @throws IOException if an IO problem occurs during writing + * @throws SAXException if an SAX problem occurs during writing + */ + + public void end() throws IOException, SAXException { + } + /** * <p> Writes the given bean to the current stream using the XML introspector.</p> * @@ -119,10 +144,16 @@ * property is false.</p> * * @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 * * @param bean write out representation of this bean */ - public void write(Object bean) throws IOException, SAXException, IntrospectionException { + public void write(Object bean) throws + IOException, + SAXException, + IntrospectionException { if (log.isDebugEnabled()) { log.debug( "Writing bean graph..." ); log.debug( bean ); @@ -135,29 +166,6 @@ } } - /** - * Marks the start of the bean writing. - * By default doesn't do anything, but can be used - * to do extra start processing - * @throws IOException - * @throws SAXException - */ - public void start() throws IOException, SAXException { - } - - /** - * Marks the start of the bean writing. - * By default doesn't do anything, but can be used - * to do extra end processing - * @throws IOExcpetion - * @throws SAXException - */ - - public void end() throws IOException, SAXException { - } - - - /** * <p>Writes the given bean to the current stream * using the given <code>qualifiedName</code>.</p> @@ -166,7 +174,13 @@ * is encountered in the graph <strong>only</strong> if the <code>WriteIDs</code> * property is false.</p> * + * @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 */ public void write( String qualifiedName, @@ -201,8 +215,7 @@ qualifiedName, elementDescriptor, context ); - } - else { + } else { pushBean ( context.getBean() ); if ( writeIDs ) { ref = (String) idMap.get( context.getBean() ); @@ -254,8 +267,7 @@ elementDescriptor, context ); } - } - else { + } else { // we've already written this bean so write an IDREF writeIDREFElement( @@ -282,6 +294,16 @@ } /** + * Get the indentation for the current element. + * Used for pretty priting. + * + * @return the amount that the current element is indented + */ + protected int getIndentLevel() { + return indentLevel; + } + + /** * Set <code>IDGenerator</code> implementation * used to generate <code>ID</code> attribute values. * This property can be used to customize the algorithm used for generation. @@ -292,7 +314,14 @@ this.idGenerator = idGenerator; } - /** Get whether generated <code>ID</code> attribute values should be added to the elements */ + /** + * <p>Should generated <code>ID</code> attribute values be added to the elements?</p> + * + * <p>If IDs are not being written then if a cycle is encountered in the bean graph, + * then a {@link CyclicReferenceException} will be thrown by the write method.</p> + * + * @return true if <code>ID</code> and <code>IDREF</code> attributes are to be written + */ public boolean getWriteIDs() { return writeIDs; } @@ -301,18 +330,22 @@ * Set whether generated <code>ID</code> attribute values should be added to the elements * If this property is set to false, then <code>CyclicReferenceException</code> * will be thrown whenever a cyclic occurs in the bean graph. + * + * @param writeIDs true if <code>ID</code>'s and <code>IDREF</code>'s should be written */ public void setWriteIDs(boolean writeIDs) { this.writeIDs = writeIDs; } /** - * <p> Get the introspector used. </p> + * <p>Gets the introspector used.</p> * - * <p> The {@link XMLBeanInfo} used to map each bean is + * <p>The {@link XMLBeanInfo} used to map each bean is * created by the <code>XMLIntrospector</code>. * One way in which the mapping can be customized is * by altering the <code>XMLIntrospector</code>. </p> + * + * @return the <code>XMLIntrospector</code> used for introspection */ public XMLIntrospector getXMLIntrospector() { return introspector; @@ -320,9 +353,9 @@ /** - * <p> Set the introspector to be used. </p> + * <p>Sets the introspector to be used.</p> * - * <p> The {@link XMLBeanInfo} used to map each bean is + * <p>The {@link XMLBeanInfo} used to map each bean is * created by the <code>XMLIntrospector</code>. * One way in which the mapping can be customized is by * altering the <code>XMLIntrospector</code>. </p> @@ -334,7 +367,9 @@ } /** - * <p> Get the current logging implementation. </p> + * <p>Gets the current logging implementation.</p> + * + * @return the <code>Log</code> implementation which this class logs to */ public final Log getAbstractBeanWriterLog() { return log; @@ -353,23 +388,62 @@ // Expression methods //------------------------------------------------------------------------- - /** Express an element tag start using given qualified name */ - abstract protected void expressElementStart(String qualifiedName) + /** + * Express an element tag start using given qualified name. + * + * @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 abstract void expressElementStart(String qualifiedName) throws IOException, SAXException; - - abstract protected void expressTagClose() throws IOException, SAXException; + + /** + * Express a closing tag. + * + * @throws IOException if an IO problem occurs during writing + * @throws SAXException if an SAX problem occurs during writing + */ + protected abstract void expressTagClose() throws IOException, SAXException; - /** Express an element end tag using given qualifiedName */ - abstract protected void expressElementEnd(String qualifiedName) throws IOException, SAXException; + /** + * Express an element end tag (with given name) + * + * @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 abstract void expressElementEnd(String qualifiedName) + throws IOException, SAXException; - /** Express an empty element end */ - abstract protected void expressElementEnd() throws IOException, SAXException; + /** + * Express an empty element end. + * + * @throws IOException if an IO problem occurs during writing + * @throws SAXException if an SAX problem occurs during writing + */ + protected abstract void expressElementEnd() throws IOException, SAXException; - /** Express body text */ - abstract protected void expressBodyText(String text) throws IOException, SAXException; + /** + * Express body text + * + * @param text the string to write out as the body of the current element + * + * @throws IOException if an IO problem occurs during writing + * @throws SAXException if an SAX problem occurs during writing + */ + protected abstract void expressBodyText(String text) throws IOException, SAXException; - /** Express an attribute */ - abstract protected void expressAttribute( + /** + * Express an attribute + * + * @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 abstract void expressAttribute( String qualifiedName, String value) throws @@ -381,7 +455,16 @@ //------------------------------------------------------------------------- - /** Writes the given element */ + /** + * Writes the given element + * + * @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 + */ protected void write( String qualifiedName, ElementDescriptor elementDescriptor, @@ -400,7 +483,18 @@ - /** Writes the given element adding an ID attribute */ + /** + * Writes the given element adding an ID attribute + * + * @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 + * @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 + */ protected void write( String qualifiedName, ElementDescriptor elementDescriptor, @@ -419,7 +513,16 @@ writeRestOfElement( qualifiedName, elementDescriptor, context ); } - /** Write attributes, child elements and element end */ + /** + * Write attributes, child elements and element end + * + * @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 + */ protected void writeRestOfElement( String qualifiedName, ElementDescriptor elementDescriptor, @@ -429,25 +532,32 @@ SAXException, IntrospectionException { - if (elementDescriptor.isWrapCollectionsInElement()) { + if ( elementDescriptor.isWrapCollectionsInElement() ) { writeAttributes( elementDescriptor, context ); } if ( writeContent( elementDescriptor, context ) ) { - if (elementDescriptor.isWrapCollectionsInElement()) { + if ( elementDescriptor.isWrapCollectionsInElement() ) { expressElementEnd( qualifiedName ); } - } - else { - if (elementDescriptor.isWrapCollectionsInElement()) { + } else { + if ( elementDescriptor.isWrapCollectionsInElement() ) { expressElementEnd(); } } } - - + /** + * Writes an element with a <code>IDREF</code> attribute + * + * @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 + */ protected void writeIDREFElement( String qualifiedName, String idrefAttributeName, @@ -465,9 +575,15 @@ expressElementEnd(); } - /** Writes the element content. + /** + * Writes the element content. * + * @param elementDescriptor the <code>ElementDescriptor</code> to write as xml + * @param context the <code>Context</code> to use to evaluate the bean expressions * @return true if some content was written + * @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 */ protected boolean writeContent( ElementDescriptor elementDescriptor, @@ -505,8 +621,7 @@ write( qualifiedName, object ); --indentLevel; } - } - else { + } else { if ( ! writtenContent ) { writtenContent = true; expressTagClose(); @@ -516,8 +631,7 @@ --indentLevel; } } - } - else { + } else { if ( ! writtenContent ) { writtenContent = true; expressTagClose(); @@ -537,8 +651,7 @@ writePrintln(); writeIndent(); } - } - else { + } else { // evaluate the body text Expression expression = elementDescriptor.getTextExpression(); if ( expression != null ) { @@ -558,14 +671,22 @@ return writtenContent; } - /** Writes the attribute declarations */ + /** + * Writes the attribute declarations + * + * @param elementDescriptor the <code>ElementDescriptor</code> to be written out as xml + * @param context the <code>Context</code> to use to evaluation bean expressions + * @throws IOException if an IO problem occurs during writing + * @throws SAXException if an SAX problem occurs during writing + */ protected void writeAttributes( ElementDescriptor elementDescriptor, Context context ) throws IOException, SAXException { - if (!elementDescriptor.isWrapCollectionsInElement()) + if (!elementDescriptor.isWrapCollectionsInElement()) { return; + } AttributeDescriptor[] attributeDescriptors = elementDescriptor.getAttributeDescriptors(); if ( attributeDescriptors != null ) { @@ -577,7 +698,14 @@ } - /** Writes an attribute declaration */ + /** + * Writes an attribute declaration + * + * @param attributeDescriptor the <code>AttributeDescriptor</code> to be written as xml + * @param context the <code>Context</code> to use to evaluation bean expressions + * @throws IOException if an IO problem occurs during writing + * @throws SAXException if an SAX problem occurs during writing + */ protected void writeAttribute( AttributeDescriptor attributeDescriptor, Context context ) @@ -595,10 +723,30 @@ } } + /** + * Writes a empty line. + * This implementation does nothing but can be overridden by subclasses. + * + * @throws IOException if the line cannot be written + */ protected void writePrintln() throws IOException {} + + /** + * Writes an indentation. + * This implementation does nothing but can be overridden by subclasses. + * + * @throws IOException if the indent cannot be written + */ protected void writeIndent() throws IOException {} - protected void pushBean( Object bean ) throws CyclicReferenceException { + /** + * Pushes the bean onto the ancestry stack. + * If IDs are not being written, then check for cyclic references. + * + * @param bean push this bean onto the ancester stack + * @throws CyclicReferenceException if there is an identical bean already on the stack + */ + protected void pushBean( Object bean ) { // check that we don't have a cyclic reference when we're not writing IDs if ( !writeIDs ) { Iterator it = beanStack.iterator(); @@ -625,6 +773,11 @@ beanStack.push( bean ); } + /** + * Pops the top bean off from the ancestry stack + * + * @return the last object pushed onto the ancester stack + */ protected Object popBean() { Object bean = beanStack.pop(); if (log.isTraceEnabled()) { 1.16 +13 -14 jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/io/BeanCreateRule.java Index: BeanCreateRule.java =================================================================== RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/io/BeanCreateRule.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- BeanCreateRule.java 5 Jan 2003 17:18:32 -0000 1.15 +++ BeanCreateRule.java 6 Jan 2003 22:50:44 -0000 1.16 @@ -117,8 +117,7 @@ public BeanCreateRule( ElementDescriptor descriptor, Class beanClass, - String pathPrefix ) - { + String pathPrefix ) { this( descriptor, beanClass, pathPrefix, true ); } @@ -371,8 +370,8 @@ log.trace( "Creating instance of " + beanClass ); } return beanClass.newInstance(); - } - catch (Exception e) { + + } catch (Exception e) { log.warn( "Could not create instance of type: " + beanClass.getName() ); return null; } @@ -451,8 +450,8 @@ } if ( childDescriptor.isPrimitiveType() ) { addPrimitiveTypeRule(path, childDescriptor); - } - else { + + } else { // add the first child to the path ElementDescriptor[] grandChildren = childDescriptor.getElementDescriptors(); if ( grandChildren != null && grandChildren.length > 0 ) { @@ -461,8 +460,8 @@ if ( grandChildQName != null && grandChildQName.length() > 0 ) { if (childDescriptor.isWrapCollectionsInElement()) { path += '/' + grandChildQName; - } - else{ + + } else { path = prefix + grandChildQName; } } @@ -472,8 +471,8 @@ Class beanClass = childDescriptor.getSingularPropertyType(); if ( XMLIntrospectorHelper.isPrimitiveType( beanClass ) ) { addPrimitiveTypeRule(path, childDescriptor); - } - else { + + } else { Rule rule = new BeanCreateRule( childDescriptor, context, @@ -515,8 +514,8 @@ try { XMLBeanInfo xmlInfo = introspector.introspect( beanClass ); return xmlInfo.getElementDescriptor(); - } - catch (Exception e) { + + } catch (Exception e) { log.warn( "Could not introspect class: " + beanClass, e ); } } @@ -547,8 +546,8 @@ log.debug( "Adding digester rule for path: " + path + " rule: " + rule ); } digester.addRule( path, rule ); - } - else { + + } else { if ( log.isDebugEnabled() ) { log.debug( "Ignoring duplicate digester rule for path: " + path + " rule: " + rule ); 1.12 +6 -6 jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/io/BeanWriter.java Index: BeanWriter.java =================================================================== RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/io/BeanWriter.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- BeanWriter.java 30 Dec 2002 18:18:36 -0000 1.11 +++ BeanWriter.java 6 Jan 2003 22:50:44 -0000 1.12 @@ -122,15 +122,15 @@ public class BeanWriter extends AbstractBeanWriter { /** Escaped <code><</code> entity */ - private final static String LESS_THAN_ENTITY = "<"; + private static final String LESS_THAN_ENTITY = "<"; /** Escaped <code>></code> entity */ - private final static String GREATER_THAN_ENTITY = ">"; + private static final String GREATER_THAN_ENTITY = ">"; /** Escaped <code>&</code> entity */ - private final static String AMPERSAND_ENTITY = "&"; + private static final String AMPERSAND_ENTITY = "&"; /** Escaped <code>'</code> entity */ - private final static String APOSTROPHE_ENTITY = "'"; + private static final String APOSTROPHE_ENTITY = "'"; /** Escaped <code>"</code> entity */ - private final static String QUOTE_ENTITY = """; + private static final String QUOTE_ENTITY = """; /** Where the output goes */ private Writer writer; @@ -359,7 +359,7 @@ */ protected void writeIndent() throws IOException { if ( indent != null ) { - for ( int i = 0; i < indentLevel; i++ ) { + for ( int i = 0; i < getIndentLevel(); i++ ) { writer.write( getIndent() ); } } 1.3 +5 -2 jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/io/CyclicReferenceException.java Index: CyclicReferenceException.java =================================================================== RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/io/CyclicReferenceException.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- CyclicReferenceException.java 12 Jun 2002 21:40:06 -0000 1.2 +++ CyclicReferenceException.java 6 Jan 2003 22:50:44 -0000 1.3 @@ -90,8 +90,11 @@ super(DEFAULT_MESSAGE); } - /** Construct exception with given message - */ + /** + * Construct exception with message + * + * @param message the detailed message string + */ public CyclicReferenceException(String message) { super(message); } 1.4 +9 -1 jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/io/id/AbstractIDGenerator.java Index: AbstractIDGenerator.java =================================================================== RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/io/id/AbstractIDGenerator.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- AbstractIDGenerator.java 14 Aug 2002 18:50:21 -0000 1.3 +++ AbstractIDGenerator.java 6 Jan 2003 22:50:44 -0000 1.4 @@ -79,7 +79,11 @@ /** Last <code>ID</code> returned */ private String lastId = "0"; - /** Get last <code>ID</code> returned. */ + /** + * Gets last <code>ID</code> returned. + * + * @return the last id created by the generated + */ public final String getLastId() { return lastId; } @@ -89,6 +93,8 @@ * * <p>This method obtains the next <code>ID</code> from subclass * and then uses this to set the <code>LastId</code> property.</p> + * + * @return the next id generated */ public final String nextId() { lastId = nextIdImpl(); @@ -100,6 +106,8 @@ * This implementation needs only provide the next <code>ID</code> * value (according to it's algorithm). * Setting the <code>LastId</code> property can be left to this class. + * + * @return the next id generated */ protected abstract String nextIdImpl(); } 1.4 +13 -3 jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/io/id/RandomIDGenerator.java Index: RandomIDGenerator.java =================================================================== RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/io/id/RandomIDGenerator.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- RandomIDGenerator.java 14 Aug 2002 18:50:21 -0000 1.3 +++ RandomIDGenerator.java 6 Jan 2003 22:50:44 -0000 1.4 @@ -103,11 +103,13 @@ } /** - * <p>Provide a random <code>ID</code><p> + * <p>Generates a random <code>ID</code><p> * * <p>If the <code>PositiveIds</code> property is true, * then this method will recursively call itself if the random * <code>ID</code> is less than zero.</p> + * + * @return a random integer (converted to a string) */ public String nextIdImpl() { int next = random.nextInt(); @@ -118,12 +120,20 @@ return Integer.toString(next); } - /** Get whether only positive <code>ID</code>'s should be generated */ + /** + * Gets whether only positive <code>ID</code>'s should be generated + * + * @return whether only positive IDs should be generated + */ public boolean getPositiveIds() { return onlyPositiveIds; } - /** Set whether only positive <code>ID</code>'s should be generated */ + /** + * Sets whether only positive <code>ID</code>'s should be generated + * + * @param onlyPositiveIds pass true if only positive IDs should be generated + */ public void setPositiveIds(boolean onlyPositiveIds) { this.onlyPositiveIds = onlyPositiveIds; } 1.4 +5 -1 jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/io/id/SequentialIDGenerator.java Index: SequentialIDGenerator.java =================================================================== RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/io/id/SequentialIDGenerator.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- SequentialIDGenerator.java 14 Aug 2002 18:50:21 -0000 1.3 +++ SequentialIDGenerator.java 6 Jan 2003 22:50:44 -0000 1.4 @@ -101,13 +101,17 @@ /** * Increment counter and then return value. + * + * @return one more than the current counter (converted to a string) */ public String nextIdImpl() { return Integer.toString(++counter); } /** - * Get the current counter value + * Gets the current counter value + * + * @return the last ID in the sequence */ public int getCount() { return counter; 1.3 +9 -2 jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/registry/DefaultXMLBeanInfoRegistry.java Index: DefaultXMLBeanInfoRegistry.java =================================================================== RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/registry/DefaultXMLBeanInfoRegistry.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- DefaultXMLBeanInfoRegistry.java 30 Dec 2002 18:18:37 -0000 1.2 +++ DefaultXMLBeanInfoRegistry.java 6 Jan 2003 22:50:44 -0000 1.3 @@ -73,7 +73,11 @@ private Map xmlBeanInfos = new HashMap(); /** - * Get from cache. + * Get <code>XMLBeanInfo</code> from cache. + * + * @param forThisClass the class for which to find a <code>XMLBeanInfo</code> + * @return cached <code>XMLBeanInfo</code> associated with given class + * or <code>null</code> if no <code>XMLBeanInfo</code> has been associated */ public XMLBeanInfo get(Class forThisClass) { return (XMLBeanInfo) xmlBeanInfos.get(forThisClass); @@ -81,6 +85,9 @@ /** * Put into cache + * + * @param forThisClass the class to cache the <code>XMLBeanInfo</code> for + * @param beanInfo the <code>XMLBeanInfo</code> to cache */ public void put(Class forThisClass, XMLBeanInfo beanInfo) { xmlBeanInfos.put(forThisClass, beanInfo); 1.3 +12 -5 jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/registry/NoCacheRegistry.java Index: NoCacheRegistry.java =================================================================== RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/registry/NoCacheRegistry.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- NoCacheRegistry.java 15 Dec 2002 17:42:06 -0000 1.2 +++ NoCacheRegistry.java 6 Jan 2003 22:50:44 -0000 1.3 @@ -68,21 +68,28 @@ /** Always return null. * - * return <code>null</code> + * @param forThisClass this parameter is ignored + * @return <code>null</code> */ public XMLBeanInfo get(Class forThisClass) { return null; } - /** Do nothing */ + /** + * Do nothing (this implementation does not cache) + * + * @param forThisClass the class is ignored + * @param beanInfo the <code>XMLBeanInfo</code> is ignored + */ public void put(Class forThisClass, XMLBeanInfo beanInfo) {} /** + * Nothing cached so nothing to flush + * * @see org.apache.commons.betwixt.registry.XMLBeanInfoRegistry#flush() * */ - public void flush() - { + public void flush() { } } 1.3 +6 -2 jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/registry/XMLBeanInfoRegistry.java Index: XMLBeanInfoRegistry.java =================================================================== RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/registry/XMLBeanInfoRegistry.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- XMLBeanInfoRegistry.java 15 Dec 2002 17:42:06 -0000 1.2 +++ XMLBeanInfoRegistry.java 6 Jan 2003 22:50:44 -0000 1.3 @@ -87,12 +87,16 @@ * * @param forThisClass get <code>XMLBeanInfo</code> for this class * - * @return <code>null</code> if fresh introspection should be used to find the <code>XMLBeanInfo</code> + * @return <code>null</code> if fresh introspection should be used + * to find the <code>XMLBeanInfo</code> */ public XMLBeanInfo get(Class forThisClass); /** * Associate a class with it's <code>XMLBeanInfo</code>. + * + * @param forThisClass the class to associate with the given bean info + * @param beanInfo the <code>XMLBeanInfo</code> to use for the given class */ public void put(Class forThisClass, XMLBeanInfo beanInfo); 1.4 +8 -9 jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/strategy/CapitalizeNameMapper.java Index: CapitalizeNameMapper.java =================================================================== RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/strategy/CapitalizeNameMapper.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- CapitalizeNameMapper.java 5 Jan 2003 09:52:22 -0000 1.3 +++ CapitalizeNameMapper.java 6 Jan 2003 22:50:45 -0000 1.4 @@ -69,16 +69,15 @@ * @author <a href="mailto:[EMAIL PROTECTED]">Martin van den Bemt</a> * @version $Id$ */ -public class CapitalizeNameMapper implements NameMapper -{ +public class CapitalizeNameMapper implements NameMapper { /** * Capitalize first letter of type name. * + * @param typeName the string to convert * @return <code>typeName</code> after first letter has been converted to upper case */ - public String mapTypeToElementName(String typeName) - { + public String mapTypeToElementName(String typeName) { if (typeName == null || typeName.length() ==0) { return typeName; } 1.3 +1 -0 jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/strategy/DecapitalizeNameMapper.java Index: DecapitalizeNameMapper.java =================================================================== RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/strategy/DecapitalizeNameMapper.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- DecapitalizeNameMapper.java 5 Jan 2003 09:52:22 -0000 1.2 +++ DecapitalizeNameMapper.java 6 Jan 2003 22:50:45 -0000 1.3 @@ -85,6 +85,7 @@ * Decapitalize first letter unless both are upper case. * (As per standard java beans behaviour.) * + * @param typeName the string to convert * @return decapitalized name as per <code>java.beans.Introspector</code> */ public String mapTypeToElementName(String typeName) { 1.3 +2 -1 jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/strategy/DefaultNameMapper.java Index: DefaultNameMapper.java =================================================================== RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/strategy/DefaultNameMapper.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- DefaultNameMapper.java 5 Jan 2003 09:52:22 -0000 1.2 +++ DefaultNameMapper.java 6 Jan 2003 22:50:45 -0000 1.3 @@ -74,7 +74,8 @@ /** * This implementation returns the parameter passed in without modification. - * + * + * @param typeName the string to convert * @return the typeName parameter without modification */ public String mapTypeToElementName(String typeName) { 1.7 +8 -6 jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/strategy/DefaultPluralStemmer.java Index: DefaultPluralStemmer.java =================================================================== RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/strategy/DefaultPluralStemmer.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- DefaultPluralStemmer.java 5 Jan 2003 10:23:07 -0000 1.6 +++ DefaultPluralStemmer.java 6 Jan 2003 22:50:45 -0000 1.7 @@ -94,10 +94,13 @@ * <p>If no matches are found then - if one exists - a property starting with the * singular name will be returned.</p> * - * @return the plural descriptor for the given singular property name - * @return if more than one descriptor matches, then the best match is returned + * @param propertyName the property name string to match + * @param map the <code>Map</code> containing the <code>ElementDescriptor</code>'s + * to be searched + * @return The plural descriptor for the given singular property name. + * If more than one descriptor matches, then the best match is returned. */ - public ElementDescriptor findPluralDescriptor( String propertyName, Map map) { + public ElementDescriptor findPluralDescriptor( String propertyName, Map map ) { int foundKeyCount = 0; String keyFound = null; ElementDescriptor answer = (ElementDescriptor) map.get( propertyName + "s" ); @@ -126,9 +129,8 @@ } foundKeyCount++; keyFound = key; - } - else - { + + } else { // check if we have a better match,, if (keyFound.length() > key.length()) { answer = (ElementDescriptor) map.get(key); 1.6 +13 -7 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.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- HyphenatedNameMapper.java 5 Jan 2003 17:18:32 -0000 1.5 +++ HyphenatedNameMapper.java 6 Jan 2003 22:50:45 -0000 1.6 @@ -124,6 +124,7 @@ * <p>Then the {@link #getSeparator} property value is inserted so that it separates * each word.</p> * + * @param typeName the name string to convert * @return the bean name converted to either upper or lower case with words separated * by the separator. */ @@ -142,12 +143,10 @@ if (Character.isUpperCase(typeName.charAt(i))) { sb.append(separator); sb.append(convertChar(typeName.charAt(i))); - } - else { + } else { if ( upperCase ) { sb.append(convertChar(typeName.charAt(i))); - } - else { + } else { sb.append(typeName.charAt(i)); } } @@ -169,6 +168,8 @@ /** * Sets the separator used to seperate words, which defaults to '-' + * + * @param separator the string inserted to separate words */ public void setSeparator(String separator) { this.separator = separator; @@ -187,7 +188,9 @@ /** * Sets whether upper or lower case conversions should be performed, - * which defaults to false for lower case + * which defaults to false for lower case. + * + * @param upperCase whether the name is to be converted to upper case */ public void setUpperCase(boolean upperCase) { this.upperCase = upperCase; @@ -199,12 +202,15 @@ /** * Performs type conversion on the given character based on whether * 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 */ protected char convertChar(char ch) { if ( upperCase ) { return Character.toUpperCase(ch); - } - else { + + } else { return Character.toLowerCase(ch); } } 1.3 +2 -1 jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/strategy/NameMapper.java Index: NameMapper.java =================================================================== RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/strategy/NameMapper.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- NameMapper.java 5 Jan 2003 09:52:22 -0000 1.2 +++ NameMapper.java 6 Jan 2003 22:50:45 -0000 1.3 @@ -72,7 +72,8 @@ /** * Convert the given bean or property name to name for use in xml * (as an element or an attribute nqame). - * + * + * @param typeName the string to convert * @return the element name for the given bean type name */ String mapTypeToElementName(String typeName); 1.4 +1 -1 jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/strategy/PluralStemmer.java Index: PluralStemmer.java =================================================================== RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/strategy/PluralStemmer.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- PluralStemmer.java 5 Jan 2003 10:23:07 -0000 1.3 +++ PluralStemmer.java 6 Jan 2003 22:50:45 -0000 1.4 @@ -82,7 +82,7 @@ * Find the plural descriptor for a singular property. * * @return the plural descriptor for the given singular property name - * @return <code>null</code> is no matching descriptor can be found + * or <code>null</code> is no matching descriptor can be found * @param propertyName is the singular property name, from the adder method * @param map is a map with the keys are the property names of the available * descriptors and the values are the descriptors. This may not be null.
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>