You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by robert burrell donkin <ro...@mac.com> on 2001/12/08 11:30:56 UTC

[BETWIXT] Documentation patchs

hi james

here's some documentation patchs.

- robert


Re: [BETWIXT] some changes

Posted by robert burrell donkin <ro...@mac.com>.
On Thursday, December 13, 2001, at 12:32 PM, James Strachan wrote:

> Hi Robert

hi james

<snip>

> I'm still fighting off my inbox and demanding day job but will hopefully 
> get
> more free time to dive in and help you soon.

i now have karma for the sandbox. i'll try to keep posting up regular 
progress reports so that you can get the most from any time you find.

>> 2. add a very simple logging method (probably just a log(String) method 
>> in
>> the introspector with a debug property printing to standard out). this 
>> can
>> be replaced by a more comprehensive system later.
>
> Agreed. It'd probably be worth using the commons-logging package; it looks
> pretty good and simple and would work with log4j or JDK1.4.

i've had a look at the commons-logging package and i'll probably look at 
adding logging to XMLIntrospector and BeanWriter next to help me with the 
cyclic reference fix. once i've fixed that problem i'll probably come back 
to the stuff i've <snip>ped out from your last mail.

- robert


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [BETWIXT] some changes

Posted by robert burrell donkin <ro...@mac.com>.
On Thursday, December 13, 2001, at 12:32 PM, James Strachan wrote:

> Hi Robert

hi james

<snip>

all that stuff i've snipped sounds cool. i'll probably come back with some 
more questions on it later on.


>> what do you think?
>
> Sounds great!
>
> I've witnessed the excellent work you've done on digester, want to be a
> committer on betwixt then you can just commit your changes rather than
> making patches?

i don't mind making patches but if you're happy to let me loose on your 
code, then sandbox karma for rdonkin@apache.org should suffice.

- robert


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [BETWIXT] some changes

Posted by robert burrell donkin <ro...@mac.com>.
On Thursday, December 13, 2001, at 12:32 PM, James Strachan wrote:

> Hi Robert

hi james

> ----- Original Message -----
> From: "robert burrell donkin" <ro...@mac.com>

<snip>

>> 2. add a very simple logging method (probably just a log(String) method 
>> in
>> the introspector with a debug property printing to standard out). this 
>> can
>> be replaced by a more comprehensive system later.
>
> Agreed. It'd probably be worth using the commons-logging package; it looks
> pretty good and simple and would work with log4j or JDK1.4.

commons-logging looks pretty good. it's got some annoying bugs but i don't 
think that it'll take much to fix them.

i've added support for logging to commons-logging to BeanWriter and 
XMLIntrospector. the logs are named according to their fully packaged 
class name (eg org.apache.commons.betwixt.BeanWriter).  i haven't added 
lots of calls to logging - this just puts the infrastructure in place.

i'll look at that cyclic reference bug fix next.

- robert


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [BETWIXT] some changes

Posted by James Strachan <ja...@yahoo.co.uk>.
Hi Robert

----- Original Message -----
From: "robert burrell donkin" <ro...@mac.com>
> i'd like to start adding some enhancements to betwixt. my starting to do
> list is:
>
> 1. add property getter and setter for the XMLIntrospector used by
> BeanWriter. (allowing the introspection behaviour to be altered)

Sounds good.

I've been meaning to put an extension mechanism into XMLIntrospector that
works like the extension mechanism in java.beans.Instropector. e.g. given a
FooBean class it would look on the classpath for a FooBeanXMLBeanInfo class
using the same Java beans mechanism.

That and maybe having an XML document to describe custom bean mappings. I've
found developers often want to express their beans in different XML
formats - e.g. use elements for everything, or use attributes for primitive
types, or only for 'short' fields. Then when collections, arrays and Maps
get used often all kinds of different mappings are often desired. So maybe
some XML-based document to describe a more customized 'beaninfo' might be
good.

I'm still fighting off my inbox and demanding day job but will hopefully get
more free time to dive in and help you soon.


> 2. add a very simple logging method (probably just a log(String) method in
> the introspector with a debug property printing to standard out). this can
> be replaced by a more comprehensive system later.

Agreed. It'd probably be worth using the commons-logging package; it looks
pretty good and simple and would work with log4j or JDK1.4.


> 3. solve the problem of infinite loops. (BeanWriter loops when you have
> cyclic references). you should be able to spot these by using a stack. at
> the very least, an exception can be thrown when a cycle is spotted rather
> than looping forever.
>
> what do you think?

Sounds great!

I've witnessed the excellent work you've done on digester, want to be a
committer on betwixt then you can just commit your changes rather than
making patches?

James

>
> - robert
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


[BETWIXT] some changes

Posted by robert burrell donkin <ro...@mac.com>.
hi james

i'd like to start adding some enhancements to betwixt. my starting to do 
list is:

1. add property getter and setter for the XMLIntrospector used by 
BeanWriter. (allowing the introspection behaviour to be altered)
2. add a very simple logging method (probably just a log(String) method in 
the introspector with a debug property printing to standard out). this can 
be replaced by a more comprehensive system later.
3. solve the problem of infinite loops. (BeanWriter loops when you have 
cyclic references). you should be able to spot these by using a stack. at 
the very least, an exception can be thrown when a cycle is spotted rather 
than looping forever.

what do you think?

- robert


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [BETWIXT] Documentation patchs

Posted by James Strachan <ja...@yahoo.co.uk>.
From: "Scott Sanders" <sa...@apache.org>
> Committed.

Thanks Scott!

Sorry, I've been a bit heavily loaded lately.

James

>
> Thanks,
> Scott
>
> On Sat, Dec 08, 2001 at 10:30:56AM +0000, robert burrell donkin wrote:
> > hi james
> >
> > here's some documentation patchs.
> >
> > - robert
> >
>
> > Index:
betwixt/src/java/org/apache/commons/betwixt/ElementDescriptor.java
> > ===================================================================
> > RCS file:
/home/cvs/jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwix
t/ElementDescriptor.java,v
> > retrieving revision 1.3
> > diff -u -r1.3 ElementDescriptor.java
> > --- betwixt/src/java/org/apache/commons/betwixt/ElementDescriptor.java
2001/08/23 14:25:57 1.3
> > +++ betwixt/src/java/org/apache/commons/betwixt/ElementDescriptor.java
2001/12/08 09:53:39
> > @@ -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:jstrachan@apache.org">James Strachan</a>
> >    * @version $Revision: 1.3 $
> >    */
> >  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;
> >      }
>
> > Index:
betwixt/src/java/org/apache/commons/betwixt/AttributeDescriptor.java
> > ===================================================================
> > RCS file:
/home/cvs/jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwix
t/AttributeDescriptor.java,v
> > retrieving revision 1.1
> > diff -u -r1.1 AttributeDescriptor.java
> > --- betwixt/src/java/org/apache/commons/betwixt/AttributeDescriptor.java
2001/08/22 12:25:02 1.1
> > +++ betwixt/src/java/org/apache/commons/betwixt/AttributeDescriptor.java
2001/12/08 09:53:13
> > @@ -17,13 +17,16 @@
> >    */
> >  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);
> >      }
>
> > Index: betwixt/src/java/org/apache/commons/betwixt/io/BeanWriter.java
> > ===================================================================
> > RCS file:
/home/cvs/jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwix
t/io/BeanWriter.java,v
> > retrieving revision 1.6
> > diff -u -r1.6 BeanWriter.java
> > --- betwixt/src/java/org/apache/commons/betwixt/io/BeanWriter.java
2001/08/23 15:03:07 1.6
> > +++ betwixt/src/java/org/apache/commons/betwixt/io/BeanWriter.java
2001/12/08 09:55:21
> > @@ -24,8 +24,23 @@
> >  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:jstrachan@apache.org">James Strachan</a>
> >    * @version $Revision: 1.6 $
> >    */
> > @@ -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++ ) {
>
> > Index: betwixt/src/java/org/apache/commons/betwixt/NodeDescriptor.java
> > ===================================================================
> > RCS file:
/home/cvs/jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwix
t/NodeDescriptor.java,v
> > retrieving revision 1.2
> > diff -u -r1.2 NodeDescriptor.java
> > --- betwixt/src/java/org/apache/commons/betwixt/NodeDescriptor.java
2001/08/22 18:30:48 1.2
> > +++ betwixt/src/java/org/apache/commons/betwixt/NodeDescriptor.java
2001/12/08 09:54:08
> > @@ -11,9 +11,11 @@
> >
> >  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:jstrachan@apache.org">James Strachan</a>
> >    * @version $Revision: 1.2 $
> >    */
> > @@ -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;
> >      }
>
> > Index: betwixt/src/java/org/apache/commons/betwixt/XMLBeanInfo.java
> > ===================================================================
> > RCS file:
/home/cvs/jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwix
t/XMLBeanInfo.java,v
> > retrieving revision 1.1
> > diff -u -r1.1 XMLBeanInfo.java
> > --- betwixt/src/java/org/apache/commons/betwixt/XMLBeanInfo.java
2001/08/22 12:25:02 1.1
> > +++ betwixt/src/java/org/apache/commons/betwixt/XMLBeanInfo.java
2001/12/08 09:54:29
> > @@ -22,14 +22,16 @@
> >
> >      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;
> >      }
>
> > Index: betwixt/src/java/org/apache/commons/betwixt/XMLIntrospector.java
> > ===================================================================
> > RCS file:
/home/cvs/jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwix
t/XMLIntrospector.java,v
> > retrieving revision 1.8
> > diff -u -r1.8 XMLIntrospector.java
> > --- betwixt/src/java/org/apache/commons/betwixt/XMLIntrospector.java
2001/11/19 10:10:51 1.8
> > +++ betwixt/src/java/org/apache/commons/betwixt/XMLIntrospector.java
2001/12/08 09:54:57
> > @@ -41,19 +41,32 @@
> >
> >      /** 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;
> >
>
> > --
> > To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> > For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
> --
> Scott Sanders - sanders@apache.org
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [BETWIXT] Documentation patchs

Posted by Scott Sanders <sa...@apache.org>.
Committed. 

Thanks,
Scott

On Sat, Dec 08, 2001 at 10:30:56AM +0000, robert burrell donkin wrote:
> hi james
> 
> here's some documentation patchs.
> 
> - robert
> 

> Index: betwixt/src/java/org/apache/commons/betwixt/ElementDescriptor.java
> ===================================================================
> RCS file: /home/cvs/jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/ElementDescriptor.java,v
> retrieving revision 1.3
> diff -u -r1.3 ElementDescriptor.java
> --- betwixt/src/java/org/apache/commons/betwixt/ElementDescriptor.java	2001/08/23 14:25:57	1.3
> +++ betwixt/src/java/org/apache/commons/betwixt/ElementDescriptor.java	2001/12/08 09:53:39
> @@ -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:jstrachan@apache.org">James Strachan</a>
>    * @version $Revision: 1.3 $
>    */
>  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;
>      }

> Index: betwixt/src/java/org/apache/commons/betwixt/AttributeDescriptor.java
> ===================================================================
> RCS file: /home/cvs/jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/AttributeDescriptor.java,v
> retrieving revision 1.1
> diff -u -r1.1 AttributeDescriptor.java
> --- betwixt/src/java/org/apache/commons/betwixt/AttributeDescriptor.java	2001/08/22 12:25:02	1.1
> +++ betwixt/src/java/org/apache/commons/betwixt/AttributeDescriptor.java	2001/12/08 09:53:13
> @@ -17,13 +17,16 @@
>    */
>  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);
>      }

> Index: betwixt/src/java/org/apache/commons/betwixt/io/BeanWriter.java
> ===================================================================
> RCS file: /home/cvs/jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/io/BeanWriter.java,v
> retrieving revision 1.6
> diff -u -r1.6 BeanWriter.java
> --- betwixt/src/java/org/apache/commons/betwixt/io/BeanWriter.java	2001/08/23 15:03:07	1.6
> +++ betwixt/src/java/org/apache/commons/betwixt/io/BeanWriter.java	2001/12/08 09:55:21
> @@ -24,8 +24,23 @@
>  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:jstrachan@apache.org">James Strachan</a>
>    * @version $Revision: 1.6 $
>    */
> @@ -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++ ) {

> Index: betwixt/src/java/org/apache/commons/betwixt/NodeDescriptor.java
> ===================================================================
> RCS file: /home/cvs/jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/NodeDescriptor.java,v
> retrieving revision 1.2
> diff -u -r1.2 NodeDescriptor.java
> --- betwixt/src/java/org/apache/commons/betwixt/NodeDescriptor.java	2001/08/22 18:30:48	1.2
> +++ betwixt/src/java/org/apache/commons/betwixt/NodeDescriptor.java	2001/12/08 09:54:08
> @@ -11,9 +11,11 @@
>  
>  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:jstrachan@apache.org">James Strachan</a>
>    * @version $Revision: 1.2 $
>    */
> @@ -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;
>      }

> Index: betwixt/src/java/org/apache/commons/betwixt/XMLBeanInfo.java
> ===================================================================
> RCS file: /home/cvs/jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/XMLBeanInfo.java,v
> retrieving revision 1.1
> diff -u -r1.1 XMLBeanInfo.java
> --- betwixt/src/java/org/apache/commons/betwixt/XMLBeanInfo.java	2001/08/22 12:25:02	1.1
> +++ betwixt/src/java/org/apache/commons/betwixt/XMLBeanInfo.java	2001/12/08 09:54:29
> @@ -22,14 +22,16 @@
>  
>      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;
>      }    

> Index: betwixt/src/java/org/apache/commons/betwixt/XMLIntrospector.java
> ===================================================================
> RCS file: /home/cvs/jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/XMLIntrospector.java,v
> retrieving revision 1.8
> diff -u -r1.8 XMLIntrospector.java
> --- betwixt/src/java/org/apache/commons/betwixt/XMLIntrospector.java	2001/11/19 10:10:51	1.8
> +++ betwixt/src/java/org/apache/commons/betwixt/XMLIntrospector.java	2001/12/08 09:54:57
> @@ -41,19 +41,32 @@
>  
>      /** 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;
> 

> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

-- 
Scott Sanders - sanders@apache.org

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>