You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by rd...@apache.org on 2004/01/18 13:30:58 UTC
cvs commit: jakarta-commons/betwixt/xdocs tasks.xml
rdonkin 2004/01/18 04:30:58
Modified: betwixt/src/java/org/apache/commons/betwixt Tag:
REFACTORING-BRANCH_2004-01-13
ElementDescriptor.java XMLIntrospector.java
betwixt/src/java/org/apache/commons/betwixt/digester Tag:
REFACTORING-BRANCH_2004-01-13 TextRule.java
XMLIntrospectorHelper.java
betwixt/src/java/org/apache/commons/betwixt/io Tag:
REFACTORING-BRANCH_2004-01-13
AbstractBeanWriter.java
betwixt/xdocs Tag: REFACTORING-BRANCH_2004-01-13 tasks.xml
Added: betwixt/src/test/org/apache/commons/betwixt/introspection
Tag: REFACTORING-BRANCH_2004-01-13
TestDeclarativeIntrospection.java
Log:
New test case for introspection refactoring. src/test/org/apache/commons/betwixt/introspection/TestDeclarativeIntrospection.java
Revision Changes Path
No revision
No revision
1.14.2.3 +42 -5 jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/ElementDescriptor.java
Index: ElementDescriptor.java
===================================================================
RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/ElementDescriptor.java,v
retrieving revision 1.14.2.2
retrieving revision 1.14.2.3
diff -u -r1.14.2.2 -r1.14.2.3
--- ElementDescriptor.java 15 Jan 2004 23:34:22 -0000 1.14.2.2
+++ ElementDescriptor.java 18 Jan 2004 12:30:57 -0000 1.14.2.3
@@ -147,6 +147,7 @@
/**
* Base constructor.
* @param primitiveType if true, this element refers to a primitive type
+ * @deprecated PrimitiveType property has been removed
*/
public ElementDescriptor(boolean primitiveType) {
this.primitiveType = primitiveType;
@@ -201,6 +202,18 @@
return getContentDescriptors().length > 0;
}
+ /**
+ * Is this a simple element?
+ * A simple element is one without child elements or attributes.
+ * This corresponds to the simple type concept used in XML Schema.
+ * TODO: need to consider whether it's sufficient to calculate
+ * which are simple types (and so don't get IDs assigned etc)
+ * @return true if it is a <code>SimpleType</code> element
+ */
+ public boolean isSimple() {
+ return !(hasAttributes()) && !(hasChildren());
+ }
+
/**
* Sets whether <code>Collection</code> bean properties should wrap items in a parent element.
@@ -210,6 +223,8 @@
*
* @param wrapCollectionsInElement true if the elements for the items in the collection
* should be contained in a parent element
+ * @deprecated moved to a declarative style of descriptors where the alrogithmic should
+ * be done during introspection
*/
public void setWrapCollectionsInElement(boolean wrapCollectionsInElement) {
this.wrapCollectionsInElement = wrapCollectionsInElement;
@@ -223,6 +238,8 @@
*
* @return true if the elements for the items in the collection should be contained
* in a parent element
+ * @deprecated moved to a declarative style of descriptors where the alrogithmic should
+ * be done during introspection
*/
public boolean isWrapCollectionsInElement() {
return this.wrapCollectionsInElement;
@@ -468,6 +485,8 @@
/**
* Returns true if this element refers to a primitive type property
* @return whether this element refers to a primitive type (or property of a parent object)
+ * @deprecated moved to a declarative style of descriptors where the alrogithmic should
+ * be done during introspection
*/
public boolean isPrimitiveType() {
return primitiveType;
@@ -476,6 +495,8 @@
/**
* Sets whether this element refers to a primitive type (or property of a parent object)
* @param primitiveType true if this element refers to a primitive type
+ * @deprecated moved to a declarative style of descriptors where the alrogithmic should
+ * be done during introspection
*/
public void setPrimitiveType(boolean primitiveType) {
this.primitiveType = primitiveType;
@@ -581,7 +602,8 @@
}
/**
- *@todo is this implementation correct?
+ * TODO is this implementation correct?
+ * maybe this method is unnecessary
*/
public boolean isCollective() {
boolean result = false;
@@ -624,5 +646,20 @@
"ElementDescriptor[qname=" + getQualifiedName() + ",pname=" + getPropertyName()
+ ",class=" + getPropertyType() + ",singular=" + getSingularPropertyType()
+ ",updater=" + getUpdater() + ",wrap=" + isWrapCollectionsInElement() + "]";
+ }
+
+ /**
+ * Is this decriptor hollow?
+ * A hollow descriptor is one which gives only the class that the subgraph
+ * is mapped to rather than describing the entire subgraph.
+ * A new <code>XMLBeanInfo</code> should be introspected
+ * and that used to describe the subgraph.
+ * A hollow descriptor should not have any child descriptors.
+ * TODO: consider whether a subclass would be better
+ * @return true if this is hollow
+ */
+ public boolean isHollow() {
+ // TODO implementation
+ return false;
}
}
1.27.2.1 +8 -7 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.27
retrieving revision 1.27.2.1
diff -u -r1.27 -r1.27.2.1
--- XMLIntrospector.java 19 Oct 2003 14:53:52 -0000 1.27
+++ XMLIntrospector.java 18 Jan 2004 12:30:57 -0000 1.27.2.1
@@ -9,7 +9,7 @@
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -391,7 +391,6 @@
if ( bean.isPrimitiveType() ) {
log.trace("Bean is primitive");
elementDescriptor.setTextExpression( StringExpression.getInstance() );
- elementDescriptor.setPrimitiveType(true);
} else if ( bean.isLoopType() ) {
log.trace("Bean is loop");
@@ -666,7 +665,7 @@
if (log.isTraceEnabled()) {
log.trace( "Adding property as element: " + name );
}
- descriptor = new ElementDescriptor(true);
+ descriptor = new ElementDescriptor();
}
descriptor.setTextExpression( propertyExpression );
if ( propertyUpdater != null ) {
@@ -1029,6 +1028,8 @@
/**
* Is this class a primitive?
+ * TODO: this method will probably be removed when primitive types
+ * are subsumed into the simple type concept
* @param type the Class to test
* @return true for primitive types
*/
No revision
No revision
1.6.2.2 +9 -9 jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/digester/TextRule.java
Index: TextRule.java
===================================================================
RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/digester/TextRule.java,v
retrieving revision 1.6.2.1
retrieving revision 1.6.2.2
diff -u -r1.6.2.1 -r1.6.2.2
--- TextRule.java 13 Jan 2004 21:49:46 -0000 1.6.2.1
+++ TextRule.java 18 Jan 2004 12:30:57 -0000 1.6.2.2
@@ -9,7 +9,7 @@
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -105,7 +105,7 @@
* 2. If this tag has a value attribute together with either a property
* or type attribute.
*/
- public void begin(Attributes attributes) throws SAXException {
+ public void begin(String name, String namespace, Attributes attributes) throws SAXException {
TextDescriptor descriptor = new TextDescriptor();
@@ -135,9 +135,9 @@
);
if ( beanClass != null ) {
- String name = descriptor.getPropertyName();
+ String descriptorPropertyName = descriptor.getPropertyName();
PropertyDescriptor propertyDescriptor =
- getPropertyDescriptor( beanClass, name );
+ getPropertyDescriptor( beanClass, descriptorPropertyName );
if ( propertyDescriptor != null ) {
Method readMethod = propertyDescriptor.getReadMethod();
descriptor.setTextExpression( new MethodExpression( readMethod ) );
@@ -145,7 +145,7 @@
if (writeMethod != null) {
descriptor.setUpdater( new MethodUpdater(writeMethod));
}
- getProcessedPropertyNameSet().add( name );
+ getProcessedPropertyNameSet().add( descriptorPropertyName );
}
}
}
1.27.2.2 +11 -7 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.27.2.1
retrieving revision 1.27.2.2
diff -u -r1.27.2.1 -r1.27.2.2
--- XMLIntrospectorHelper.java 13 Jan 2004 21:49:46 -0000 1.27.2.1
+++ XMLIntrospectorHelper.java 18 Jan 2004 12:30:57 -0000 1.27.2.2
@@ -9,7 +9,7 @@
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -311,7 +311,7 @@
}
if ( isPrimitiveType( type ) ) {
elementDescriptor.setTextExpression( new MethodExpression( readMethod ) );
- elementDescriptor.setPrimitiveType(true);
+
} else if ( isLoopType( type ) ) {
log.trace("Loop type ??");
@@ -604,7 +604,11 @@
/**
* Is this a primitive type?
- *
+ *
+ * TODO: this method will probably be removed when primitive types
+ * are subsumed into the simple type concept.
+ * This needs moving into XMLIntrospector so that the list of simple
+ * type can be varied.
* @param type is this <code>Class<code> a primitive type?
* @return true for primitive types
*/
No revision
No revision
1.22.2.3 +7 -7 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.22.2.2
retrieving revision 1.22.2.3
diff -u -r1.22.2.2 -r1.22.2.3
--- AbstractBeanWriter.java 15 Jan 2004 23:34:22 -0000 1.22.2.2
+++ AbstractBeanWriter.java 18 Jan 2004 12:30:58 -0000 1.22.2.3
@@ -245,8 +245,8 @@
String ref = null;
String id = null;
- // only give id's to non-primatives
- if ( elementDescriptor.isPrimitiveType() ) {
+ // simple type should not have IDs
+ if ( elementDescriptor.isSimple() ) {
// write without an id
writeElement(
namespaceUri,
No revision
No revision
1.1.2.1 +159 -0 jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/introspection/Attic/TestDeclarativeIntrospection.java
No revision
No revision
1.25.2.1 +29 -0 jakarta-commons/betwixt/xdocs/tasks.xml
Index: tasks.xml
===================================================================
RCS file: /home/cvs/jakarta-commons/betwixt/xdocs/tasks.xml,v
retrieving revision 1.25
retrieving revision 1.25.2.1
diff -u -r1.25 -r1.25.2.1
--- tasks.xml 24 Nov 2003 09:23:13 -0000 1.25
+++ tasks.xml 18 Jan 2004 12:30:58 -0000 1.25.2.1
@@ -331,6 +331,16 @@
</li>
</ul>
</li>
+ <li><strong>Refactoring (more declarative descriptors)</strong>
+ <ul>
+ <li><strong>ElementDescriptor</strong>
+ <ul>
+ <li><code>WrapCollectionsInElement</code> property removed</li>
+ <li><code>PrimitiveType</code> property removed</li>
+ </ul>
+ </li>
+ </ul>
+ </li>
</ul>
</subsection>
</section>
@@ -385,6 +395,25 @@
<strong><code>ConvertUtils</code> conversion now ignored (by default) for java.util.Date</strong>
If you use a custom <code>ConvertUtils</code> java.util.Date converter then see
<a href='guide/binding.html#Converting Dates (And Other Objects)'>the guide</a>.
+ </li>
+ <li>
+ <strong>Introspection & ELementDescriptor</strong> changes in introspection and
+ ElementDescriptor to make them more declarative so that the logic required to
+ read and write beans can be reduced. An explicit flag has been added to indicate
+ which ElementDescriptors are hollow. The descriptors describing collective mappings
+ (one-to-many). wrapCollectionInElement has been removed with the wrapping element
+ descriptor becoming just a spacer (an xml element which is not mapped to a part of
+ the object graph). The updater now needs to be placed on the hollow collective
+ element rather than then parent spacer.
+ </li>
+ <li>
+ <strong>ID assignment</strong> IDs are now not assigned to any element
+ which are simple (do not have any children and no attributes) rather than just primitives.
+ The concept of primitives is being phased out in favour of the more general
+ concept of atomic mappings (object <-> string) and elements of simple type.
+ ID generation is likely to be refactored soon so that it's performed within
+ the structure of the attribute references rather than as part of the writing
+ algorithm.
</li>
</ul>
</subsection>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org