commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <james_strac...@yahoo.co.uk>
Subject Re: [BETWIXT] Documentation patchs
Date Tue, 11 Dec 2001 08:23:01 GMT
From: "Scott Sanders" <sanders@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:
<mailto:commons-dev-unsubscribe@jakarta.apache.org>
> > For additional commands, e-mail:
<mailto:commons-dev-help@jakarta.apache.org>
>
> --
> Scott Sanders - sanders@apache.org
>
> --
> To unsubscribe, e-mail:
<mailto:commons-dev-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
<mailto:commons-dev-help@jakarta.apache.org>


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


--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message