sanders     01/12/10 22:43:55

  Modified:    betwixt/src/java/org/apache/commons/betwixt
                        AttributeDescriptor.java ElementDescriptor.java
                        NodeDescriptor.java XMLBeanInfo.java
                        XMLIntrospector.java
               betwixt/src/java/org/apache/commons/betwixt/io
                        BeanWriter.java
  Log:
  Documentation patch submitted by robert burrell donkin <[EMAIL PROTECTED]>
  
  Revision  Changes    Path
  1.2       +5 -2      
jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/AttributeDescriptor.java
  
  Index: AttributeDescriptor.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/AttributeDescriptor.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AttributeDescriptor.java  2001/08/22 12:25:02     1.1
  +++ AttributeDescriptor.java  2001/12/11 06:43:47     1.2
  @@ -5,7 +5,7 @@
    * version 1.1, a copy of which has been included with this distribution in
    * the LICENSE file.
    * 
  - * $Id: AttributeDescriptor.java,v 1.1 2001/08/22 12:25:02 jstrachan Exp $
  + * $Id: AttributeDescriptor.java,v 1.2 2001/12/11 06:43:47 sanders Exp $
    */
   package org.apache.commons.betwixt;
   
  @@ -13,17 +13,20 @@
     * to be created for a bean instance.</p>
     *
     * @author <a href="mailto:[EMAIL PROTECTED]";>James Strachan</a>
  -  * @version $Revision: 1.1 $
  +  * @version $Revision: 1.2 $
     */
   public class AttributeDescriptor extends NodeDescriptor {
   
  +    /** Base constructor */
       public AttributeDescriptor() {
       }
   
  +    /** Creates a AttributeDescriptor with no namespace URI or prefix */
       public AttributeDescriptor(String localName) {
           super( localName );
       }
   
  +    /** Creates a AttributeDescriptor with namespace URI and qualified name */
       public AttributeDescriptor(String localName,String qualifiedName,String uri) {
           super(localName, qualifiedName, uri);
       }
  
  
  
  1.4       +13 -4     
jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/ElementDescriptor.java
  
  Index: ElementDescriptor.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/ElementDescriptor.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ElementDescriptor.java    2001/08/23 14:25:57     1.3
  +++ ElementDescriptor.java    2001/12/11 06:43:47     1.4
  @@ -5,7 +5,7 @@
    * version 1.1, a copy of which has been included with this distribution in
    * the LICENSE file.
    * 
  - * $Id: ElementDescriptor.java,v 1.3 2001/08/23 14:25:57 jstrachan Exp $
  + * $Id: ElementDescriptor.java,v 1.4 2001/12/11 06:43:47 sanders Exp $
    */
   package org.apache.commons.betwixt;
   
  @@ -14,26 +14,33 @@
   /** <p><code>ElementDescriptor</code> describes the XML elements
     * to be created for a bean instance.</p>
     *
  +  * <p> It contains <code>AttributeDescriptor</code>'s for all it's attributes
  +  * and <code>ElementDescriptor</code>'s for it's child elements.
  +  *
     * @author <a href="mailto:[EMAIL PROTECTED]";>James Strachan</a>
  -  * @version $Revision: 1.3 $
  +  * @version $Revision: 1.4 $
     */
   public class ElementDescriptor extends NodeDescriptor {
   
  +    /** Descriptors for element attributes */
       private AttributeDescriptor[] attributeDescriptors;
  +    /** Descriptors for child elements */
       private ElementDescriptor[] elementDescriptors;
       
       /** the expression used to evaluate the new context of this node 
        * or null if the same context is to be used */
       private Expression contextExpression;
     
  -    
  +    /** Base constructor */
       public ElementDescriptor() {
       }
   
  +    /** Creates a <code>ElementDescriptor</code> with no namespace URI or prefix */
       public ElementDescriptor(String localName) {
           super( localName );
       }
   
  +    /** Creates a <code>ElementDescriptor</code> with namespace URI and qualified 
name */
       public ElementDescriptor(String localName, String qualifiedName, String uri) {
           super(localName, qualifiedName, uri);
       }
  @@ -53,6 +60,7 @@
           return attributeDescriptors;
       }
       
  +    /** Set <code>AttributesDescriptors</code> for this element */
       public void setAttributeDescriptors(AttributeDescriptor[] attributeDescriptors) 
{
           this.attributeDescriptors = attributeDescriptors;
       }
  @@ -61,7 +69,8 @@
       public ElementDescriptor[] getElementDescriptors() {
           return elementDescriptors;
       }
  -    
  +
  +    /** Set descriptors for child element of this element */
       public void setElementDescriptors(ElementDescriptor[] elementDescriptors) {
           this.elementDescriptors = elementDescriptors;
       }
  
  
  
  1.3       +19 -8     
jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/NodeDescriptor.java
  
  Index: NodeDescriptor.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/NodeDescriptor.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- NodeDescriptor.java       2001/08/22 18:30:48     1.2
  +++ NodeDescriptor.java       2001/12/11 06:43:47     1.3
  @@ -5,17 +5,19 @@
    * version 1.1, a copy of which has been included with this distribution in
    * the LICENSE file.
    * 
  - * $Id: NodeDescriptor.java,v 1.2 2001/08/22 18:30:48 jstrachan Exp $
  + * $Id: NodeDescriptor.java,v 1.3 2001/12/11 06:43:47 sanders Exp $
    */
   package org.apache.commons.betwixt;
   
   import org.apache.commons.betwixt.expression.Expression;
   
  -/** <p><code>ElementDescriptor</code> describes the XML elements
  -  * to be created for a bean instance.</p>
  +/** <p> Common superclass for <code>ElementDescriptor</code> and 
<code>AttributeDescriptor</code>.</p>
     *
  +  * <p> Nodes can have just a local name
  +  * or they can have a local name, qualified name and a namespace uri.</p>
  +  *
     * @author <a href="mailto:[EMAIL PROTECTED]";>James Strachan</a>
  -  * @version $Revision: 1.2 $
  +  * @version $Revision: 1.3 $
     */
   public class NodeDescriptor {
   
  @@ -26,8 +28,8 @@
       private String uri;
       /** the expression used to evaluate the text value of this node */
       private Expression textExpression;
  -    
       
  +    /** Base constructor */
       public NodeDescriptor() {
       }
   
  @@ -37,23 +39,27 @@
           this.qualifiedName = localName;
       }
   
  +
  +    /** Creates a NodeDescriptor with namespace URI and qualified name */
       public NodeDescriptor(String localName, String qualifiedName, String uri) {
           this.localName = localName;
           this.qualifiedName = qualifiedName;
           this.uri = uri;
       }
   
  -    /** Returns the local name of the element, excluding any namespace prefix 
  +    /** Returns the local name, excluding any namespace prefix 
         */
       public String getLocalName() {
           return localName;
       }
   
  +    /** Sets the local name 
  +      */
       public void setLocalName(String localName) {
           this.localName = localName;
       }    
       
  -    /** Returns the qualified name of the element, including any namespace prefix 
  +    /** Returns the qualified name, including any namespace prefix 
         */
       public String getQualifiedName() {
           if ( qualifiedName == null ) {
  @@ -61,7 +67,9 @@
           }
           return qualifiedName;
       }
  -
  +    
  +    /** Sets the qualified name
  +      */
       public void setQualifiedName(String qualifiedName) {
           this.qualifiedName = qualifiedName;
       }    
  @@ -71,6 +79,9 @@
           return ( uri != null ) ? uri : "";
       }
       
  +
  +    /** Sets the namespace URI that this node belongs to.
  +     */
       public void setURI(String uri) {
           this.uri = uri;
       }
  
  
  
  1.2       +5 -3      
jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/XMLBeanInfo.java
  
  Index: XMLBeanInfo.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/XMLBeanInfo.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XMLBeanInfo.java  2001/08/22 12:25:02     1.1
  +++ XMLBeanInfo.java  2001/12/11 06:43:47     1.2
  @@ -5,7 +5,7 @@
    * version 1.1, a copy of which has been included with this distribution in
    * the LICENSE file.
    * 
  - * $Id: XMLBeanInfo.java,v 1.1 2001/08/22 12:25:02 jstrachan Exp $
  + * $Id: XMLBeanInfo.java,v 1.2 2001/12/11 06:43:47 sanders Exp $
    */
   package org.apache.commons.betwixt;
   
  @@ -16,20 +16,22 @@
     * or XSLT for example.</p>
     *
     * @author <a href="mailto:[EMAIL PROTECTED]";>James Strachan</a>
  -  * @version $Revision: 1.1 $
  +  * @version $Revision: 1.2 $
     */
   public class XMLBeanInfo {
   
       private ElementDescriptor elementDescriptor;
       
  -    
  +    /** Base constructor */
       public XMLBeanInfo() {
       }
   
  +    /** Get descriptor for bean represention */
       public ElementDescriptor getElementDescriptor() {
           return elementDescriptor;
       }
   
  +    /** Set descriptor for bean represention */
       public void setElementDescriptor(ElementDescriptor elementDescriptor) {
           this.elementDescriptor = elementDescriptor;
       }    
  
  
  
  1.9       +24 -4     
jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/XMLIntrospector.java
  
  Index: XMLIntrospector.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/XMLIntrospector.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- XMLIntrospector.java      2001/11/19 10:10:51     1.8
  +++ XMLIntrospector.java      2001/12/11 06:43:47     1.9
  @@ -5,7 +5,7 @@
    * version 1.1, a copy of which has been included with this distribution in
    * the LICENSE file.
    * 
  - * $Id: XMLIntrospector.java,v 1.8 2001/11/19 10:10:51 jstrachan Exp $
  + * $Id: XMLIntrospector.java,v 1.9 2001/12/11 06:43:47 sanders Exp $
    */
   package org.apache.commons.betwixt;
   
  @@ -35,25 +35,38 @@
   /** <p><code>XMLIntrospector</code> an introspector of beans to create a 
XMLBeanInfo instance.</p>
     *
     * @author <a href="mailto:[EMAIL PROTECTED]";>James Strachan</a>
  -  * @version $Revision: 1.8 $
  +  * @version $Revision: 1.9 $
     */
   public class XMLIntrospector {
   
       /** should attributes or elements be used for primitive types */
       private boolean attributesForPrimitives = true;
  -
  +    
  +    /** Base constructor */
       public XMLIntrospector() {
       }
       
  +    /** Create a standard <code>XMLBeanInfo</code> by introspection
  +        The actual introspection depends only on the <code>BeanInfo</code>
  +        associated with the bean.
  +        */
       public XMLBeanInfo introspect(Object bean) throws IntrospectionException {
           return introspect( bean.getClass() );
       }
       
  +    /** Create a standard <code>XMLBeanInfo</code> by introspection.
  +        The actual introspection depends only on the <code>BeanInfo</code>
  +        associated with the bean.        
  +      */
       public XMLBeanInfo introspect(Class aClass) throws IntrospectionException {
           BeanInfo info = Introspector.getBeanInfo( aClass );
           return introspect( info );
       }
       
  +    /** Create a standard <code>XMLBeanInfo</code> by introspection. 
  +        The actual introspection depends only on the <code>BeanInfo</code>
  +        associated with the bean.
  +        */
       public XMLBeanInfo introspect(BeanInfo beanInfo) throws IntrospectionException 
{
           XMLBeanInfo answer = createXMLBeanInfo( beanInfo );
   
  @@ -115,12 +128,13 @@
           return answer;
       }
       
  -    /** Should attributes be used for primitive types or elements.
  +    /** Should attributes (or elements) be used for primitive types.
        */
       public boolean isAttributesForPrimitives() {
           return attributesForPrimitives;
       }
   
  +    /** Set whether attributes (or elements) should be used for primitive types. */
       public void setAttributesForPrimitives(boolean attributesForPrimitives) {
           this.attributesForPrimitives = attributesForPrimitives;
       }
  @@ -128,6 +142,7 @@
       
       // Implementation methods
       //-------------------------------------------------------------------------    
  +    /** Loop through properties and process each one */
       protected void addProperties(BeanInfo beanInfo, List elements, List attributes) 
throws IntrospectionException {
           PropertyDescriptor[] descriptors = beanInfo.getPropertyDescriptors();
           if ( descriptors != null ) {
  @@ -137,6 +152,11 @@
           }
       }
       
  +    /** 
  +     * Process a property. 
  +     * Go through and work out whether it's a loop property, a primitive or a 
standard.
  +     * The class property is ignored.
  +     */
       protected void addProperty(BeanInfo beanInfo, PropertyDescriptor 
propertyDescriptor, List elements, List attributes) throws IntrospectionException {
           Class type = propertyDescriptor.getPropertyType();
           NodeDescriptor nodeDescriptor = null;
  
  
  
  1.7       +49 -5     
jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/io/BeanWriter.java
  
  Index: BeanWriter.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/io/BeanWriter.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- BeanWriter.java   2001/08/23 15:03:07     1.6
  +++ BeanWriter.java   2001/12/11 06:43:55     1.7
  @@ -5,7 +5,7 @@
    * version 1.1, a copy of which has been included with this distribution in
    * the LICENSE file.
    * 
  - * $Id: BeanWriter.java,v 1.6 2001/08/23 15:03:07 jstrachan Exp $
  + * $Id: BeanWriter.java,v 1.7 2001/12/11 06:43:55 sanders Exp $
    */
   package org.apache.commons.betwixt.io;
   
  @@ -24,10 +24,25 @@
   import org.apache.commons.betwixt.expression.Context;
   import org.apache.commons.betwixt.expression.Expression;
   
  -/** <p><code>BeanWriter</code> outputs a bean as XML.</p>
  +/** <p><code>BeanWriter</code> output beans as XML.</p>
  +  * The output for each bean is an xml fragment
  +  * (rather than a well-formed xml-document).
  +  * This allows bean representations to be appended to a document 
  +  * by writing each in turn to the stream.
  +  * So to create a well formed xml document, 
  +  * you'll need to write the prolog to the stream first.
  +  * If you append more than one bean to the stream, 
  +  * then you'll need to add a wrapping root element as well.
     *
  +  * <p> The line ending to be used is set by {@link #setEndOfLine}. 
  +  * 
  +  * <p> The output can be formatted (with whitespace) for easy reading 
  +  * by calling {@link #enablePrettyPrint}. 
  +  * The output will be indented. 
  +  * The indent string used is set by {@link #setIndent}.
  +  *
     * @author <a href="mailto:[EMAIL PROTECTED]";>James Strachan</a>
  -  * @version $Revision: 1.6 $
  +  * @version $Revision: 1.7 $
     */
   public class BeanWriter {
   
  @@ -44,20 +59,39 @@
       /** should we flush after writing bean */
       private boolean autoFlush;
       
  +    /**
  +     * <p> Constructor uses <code>System.out</code> for output.</p>
  +     */
       public BeanWriter() {
           this( System.out );
       }
  -
  +    
  +    /**
  +     * <p> Constuctor uses given <code>OutputStream</code> for output.</p>
  +     *
  +     * @param out write out representations to this stream
  +     */
       public BeanWriter(OutputStream out) {
           this.writer = new BufferedWriter( new OutputStreamWriter( out ) );
           this.autoFlush = true;
       }
   
  +    /**
  +     * <p> Constructor sets writer used for output.</p>
  +     *
  +     * @param writer write out representations to this writer
  +     */
       public BeanWriter(Writer writer) {
           this.writer = writer;
       }
   
  -    /** Writes the given bean to the current stream using the XML introspector */
  +    /** 
  +     * <p> Writes the given bean to the current stream using the XML 
introspector.</p>
  +     * 
  +     * <p> This writes an xml fragment representing the bean to the current 
stream.</p>
  +     *
  +     * @param bean write out representation of this bean
  +     */
       public void write(Object bean) throws IOException, IntrospectionException  {
           XMLBeanInfo beanInfo = introspector.introspect( bean );
           if ( beanInfo != null ) {
  @@ -73,6 +107,9 @@
           }
       }
       
  +    /**
  +     * <p> Switch on formatted output.
  +     */
       public void enablePrettyPrint() {
           endOfLine = "\n";
           indent = "  ";
  @@ -102,6 +139,7 @@
       // Implementation methods
       //-------------------------------------------------------------------------    
       
  +    /** Writes the given bean to the current stream using the given 
<code>qualifiedName</code> */
       public void write(String qualifiedName, Object bean) throws IOException, 
IntrospectionException  {
           XMLBeanInfo beanInfo = introspector.introspect( bean );
           if ( beanInfo != null ) {
  @@ -115,6 +153,7 @@
               }
           }
       }
  +    
       /** Writes the given element */
       protected void write( String qualifiedName, ElementDescriptor 
elementDescriptor, Context context ) throws IOException, IntrospectionException {
           writePrintln();
  @@ -217,12 +256,17 @@
           }
       }
       
  +    /** Writes out an empty line.
  +     * Uses current <code>endOfLine</code>.
  +     */
       protected void writePrintln() throws IOException {
           if ( endOfLine != null ) {
               writer.write( endOfLine );
           }
       }
       
  +    /** Writes out <code>indent</code>'s to the current <code>indentLevel</code>
  +     */
       protected void writeIndent() throws IOException {
           if ( indent != null ) {
               for ( int i = 0; i < indentLevel; i++ ) {
  
  
  

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

Reply via email to