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/10/04 23:50:35 UTC
cvs commit: jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/strategy DefaultObjectStringConverter.java
rdonkin 2004/10/04 14:50:35
Modified: betwixt/src/java/org/apache/commons/betwixt
BeanProperty.java IntrospectionConfiguration.java
XMLIntrospector.java
betwixt/src/java/org/apache/commons/betwixt/digester
AddDefaultsRule.java AttributeRule.java
betwixt/src/java/org/apache/commons/betwixt/strategy
DefaultObjectStringConverter.java
Log:
Documentation about property supression strategy and move to suppress class property using default suppression strategy.
Revision Changes Path
1.9 +0 -7 jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/BeanProperty.java
Index: BeanProperty.java
===================================================================
RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/BeanProperty.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- BeanProperty.java 14 Jul 2004 21:38:17 -0000 1.8
+++ BeanProperty.java 4 Oct 2004 21:50:35 -0000 1.9
@@ -169,13 +169,6 @@
// choose response from property type
- // XXX: ignore class property ??
- if ( Class.class.equals( getPropertyType() ) && "class".equals( getPropertyName() ) ) {
- log.trace( "Ignoring class property" );
- return null;
-
- }
-
//TODO this big conditional should be replaced with subclasses based
// on the type
1.5 +26 -1 jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/IntrospectionConfiguration.java
Index: IntrospectionConfiguration.java
===================================================================
RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/IntrospectionConfiguration.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- IntrospectionConfiguration.java 23 Sep 2004 21:46:00 -0000 1.4
+++ IntrospectionConfiguration.java 4 Oct 2004 21:50:35 -0000 1.5
@@ -23,6 +23,7 @@
import org.apache.commons.betwixt.strategy.NameMapper;
import org.apache.commons.betwixt.strategy.NamespacePrefixMapper;
import org.apache.commons.betwixt.strategy.PluralStemmer;
+import org.apache.commons.betwixt.strategy.PropertySuppressionStrategy;
import org.apache.commons.betwixt.strategy.SimpleTypeMapper;
import org.apache.commons.betwixt.strategy.StandardSimpleTypeMapper;
import org.apache.commons.betwixt.strategy.TypeBindingStrategy;
@@ -83,12 +84,19 @@
private SimpleTypeMapper simpleTypeMapper = new StandardSimpleTypeMapper();
/** Binding strategy for Java type */
private TypeBindingStrategy typeBindingStrategy = TypeBindingStrategy.DEFAULT;
+
+
/**
* Strategy used to determine whether the bind or introspection time type is to be used to
* determine the mapping.
*/
private MappingDerivationStrategy mappingDerivationStrategy = MappingDerivationStrategy.DEFAULT;
+ /**
+ * Strategy used to determine which properties should be ignored
+ */
+ private PropertySuppressionStrategy propertySuppressionStrategy = PropertySuppressionStrategy.DEFAULT;
+
/**
* Gets the <code>ClassNormalizer</code> strategy.
* This is used to determine the Class to be introspected
@@ -347,5 +355,22 @@
public void setMappingDerivationStrategy(
MappingDerivationStrategy mappingDerivationStrategy) {
this.mappingDerivationStrategy = mappingDerivationStrategy;
+ }
+
+ /**
+ * Gets the strategy which determines the properties to be ignored.
+ * @return the <code>PropertySuppressionStrategy</code> to be used for introspection, not null
+ */
+ public PropertySuppressionStrategy getPropertySuppressionStrategy() {
+ return propertySuppressionStrategy;
+ }
+
+ /**
+ * Sets the strategy which determines the properties to be ignored.
+ * @param propertySuppressionStrategy the <code>PropertySuppressionStrategy</code> to be used for introspection, not null
+ */
+ public void setPropertySuppressionStrategy(
+ PropertySuppressionStrategy propertySuppressionStrategy) {
+ this.propertySuppressionStrategy = propertySuppressionStrategy;
}
}
1.36 +12 -3 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.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- XMLIntrospector.java 23 Sep 2004 21:46:00 -0000 1.35
+++ XMLIntrospector.java 4 Oct 2004 21:50:35 -0000 1.36
@@ -1430,7 +1430,10 @@
PropertyDescriptor[] descriptors = beanInfo.getPropertyDescriptors();
if ( descriptors != null ) {
for (int i=0, size=descriptors.length; i<size; i++) {
- propertyDescriptors.add( descriptors[i] );
+ if (!getConfiguration().getPropertySuppressionStrategy()
+ .suppressProperty( descriptors[i].getPropertyType(), descriptors[i].getName())) {
+ propertyDescriptors.add( descriptors[i] );
+ }
}
}
@@ -1442,7 +1445,10 @@
descriptors = beanInfo.getPropertyDescriptors();
if ( descriptors != null ) {
for (int j=0, innerSize=descriptors.length; j<innerSize; j++) {
- propertyDescriptors.add( descriptors[j] );
+ if (!getConfiguration().getPropertySuppressionStrategy()
+ .suppressProperty( descriptors[j].getPropertyType(), descriptors[j].getName())) {
+ propertyDescriptors.add( descriptors[j] );
+ }
}
}
}
@@ -1477,7 +1483,10 @@
BeanInfo beanInfo = Introspector.getBeanInfo(superinterfaces[i]);
PropertyDescriptor[] descriptors = beanInfo.getPropertyDescriptors();
for (int j=0, descriptorLength=descriptors.length; j<descriptorLength ; j++) {
- propertyDescriptors.add(descriptors[j]);
+ if (!getConfiguration().getPropertySuppressionStrategy()
+ .suppressProperty( descriptors[j].getPropertyType(), descriptors[j].getName())) {
+ propertyDescriptors.add( descriptors[j] );
+ }
}
addAllSuperinterfaces(superinterfaces[i], propertyDescriptors);
1.14 +7 -4 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.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- AddDefaultsRule.java 4 Jul 2004 16:40:49 -0000 1.13
+++ AddDefaultsRule.java 4 Oct 2004 21:50:35 -0000 1.14
@@ -109,10 +109,13 @@
if ( processedProperties.contains( propertyName ) ) {
continue;
}
- Descriptor nodeDescriptor =
- getXMLIntrospector().createXMLDescriptor(new BeanProperty(descriptor));
- if ( nodeDescriptor != null ) {
- addDescriptor( nodeDescriptor );
+ if (!getXMLIntrospector().getConfiguration().getPropertySuppressionStrategy()
+ .suppressProperty(descriptor.getPropertyType(), descriptor.getName())) {
+ Descriptor nodeDescriptor =
+ getXMLIntrospector().createXMLDescriptor(new BeanProperty(descriptor));
+ if ( nodeDescriptor != null ) {
+ addDescriptor( nodeDescriptor );
+ }
}
}
}
1.11 +1 -7 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.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- AttributeRule.java 13 Jun 2004 21:32:45 -0000 1.10
+++ AttributeRule.java 4 Oct 2004 21:50:35 -0000 1.11
@@ -186,12 +186,6 @@
}
// choose response from property type
-
- // XXX: ignore class property ??
- if ( Class.class.equals( type ) && "class".equals( propertyDescriptor.getName() ) ) {
- log.trace( "Ignoring class property" );
- return;
- }
if ( getXMLIntrospector().isLoopType( type ) ) {
log.warn( "Using loop type for an attribute. Type = "
+ type.getName() + " attribute: " + attributeDescriptor.getQualifiedName() );
1.11 +5 -1 jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/strategy/DefaultObjectStringConverter.java
Index: DefaultObjectStringConverter.java
===================================================================
RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/strategy/DefaultObjectStringConverter.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- DefaultObjectStringConverter.java 4 Jul 2004 16:57:05 -0000 1.10
+++ DefaultObjectStringConverter.java 4 Oct 2004 21:50:35 -0000 1.11
@@ -42,7 +42,7 @@
public class DefaultObjectStringConverter extends ConvertUtilsObjectStringConverter {
/** Formats Dates to Strings and Strings to Dates */
- private static final SimpleDateFormat formatter
+ private final SimpleDateFormat formatter
= new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.UK);
/**
@@ -63,6 +63,10 @@
*/
public String objectToString(Object object, Class type, String flavour, Context context) {
if ( object != null ) {
+ if ( object instanceof Class) {
+ return ((Class) object).getName();
+ }
+
if ( object instanceof java.util.Date && isUtilDate( type ) ) {
return formatter.format( (java.util.Date) object );
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org