You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mb...@apache.org on 2009/04/01 00:54:04 UTC

svn commit: r760708 - /commons/sandbox/flatfile/trunk/src/main/java/org/apache/commons/flatfile/morph/BaseEntityCollectionReflector.java

Author: mbenson
Date: Tue Mar 31 22:54:04 2009
New Revision: 760708

URL: http://svn.apache.org/viewvc?rev=760708&view=rev
Log:
address another TODO; changed mind but rename for better fit

Modified:
    commons/sandbox/flatfile/trunk/src/main/java/org/apache/commons/flatfile/morph/BaseEntityCollectionReflector.java

Modified: commons/sandbox/flatfile/trunk/src/main/java/org/apache/commons/flatfile/morph/BaseEntityCollectionReflector.java
URL: http://svn.apache.org/viewvc/commons/sandbox/flatfile/trunk/src/main/java/org/apache/commons/flatfile/morph/BaseEntityCollectionReflector.java?rev=760708&r1=760707&r2=760708&view=diff
==============================================================================
--- commons/sandbox/flatfile/trunk/src/main/java/org/apache/commons/flatfile/morph/BaseEntityCollectionReflector.java (original)
+++ commons/sandbox/flatfile/trunk/src/main/java/org/apache/commons/flatfile/morph/BaseEntityCollectionReflector.java Tue Mar 31 22:54:04 2009
@@ -35,11 +35,10 @@
  * @version $Revision$ $Date$
  */
 public abstract class BaseEntityCollectionReflector extends BaseContainerReflector {
-    //TODO make PropertyStrategy an enum; this would require factoring out the propertyName property
     /**
-     * Entity property strategy base class.
+     * Common property accessor logic.
      */
-    protected abstract class PropertyStrategy {
+    private abstract class PropertyAccessor {
         /**
          * Property name to find
          */
@@ -49,7 +48,7 @@
          * Create a new PropertyStrategy instance.
          * @param propertyName to find
          */
-        protected PropertyStrategy(String propertyName) {
+        protected PropertyAccessor(String propertyName) {
             this.propertyName = propertyName;
         }
 
@@ -141,14 +140,14 @@
     }
 
     /**
-     * Override the default strategy to treat an Entity as an ordinary javabean.
+     * Overrides the default strategy to treat an Entity as an ordinary javabean.
      */
-    private class OverrideStrategy extends PropertyStrategy {
+    private class OverridingPropertyAccessor extends PropertyAccessor {
         /**
-         * Create a new OverrideStrategy instance.
+         * Create a new OverridingPropertyAccessor instance.
          * @param propertyName String
          */
-        public OverrideStrategy(String propertyName) {
+        public OverridingPropertyAccessor(String propertyName) {
             super(propertyName.substring(TYPE_OVERRIDE.length()));
         }
 
@@ -175,14 +174,14 @@
     }
 
     /**
-     * Default {@link PropertyStrategy}
+     * Default {@link PropertyAccessor}
      */
-    private class DefaultStrategy extends PropertyStrategy {
+    private class DefaultPropertyAccessor extends PropertyAccessor {
         /**
-         * Create a new DefaultStrategy instance.
+         * Create a new DefaultPropertyAccessor instance.
          * @param propertyName String
          */
-        public DefaultStrategy(String propertyName) {
+        public DefaultPropertyAccessor(String propertyName) {
             super(propertyName);
         }
 
@@ -258,7 +257,7 @@
      * {@inheritDoc}
      */
     protected Class<?> getTypeImpl(Object bean, String propertyName) throws Exception {
-        return getPropertyStrategy(propertyName).getTypeFrom(bean);
+        return getPropertyAccessor(propertyName).getTypeFrom(bean);
     }
 
     /**
@@ -273,14 +272,14 @@
      * {@inheritDoc}
      */
     protected Object getImpl(Object bean, String propertyName) throws Exception {
-        return getPropertyStrategy(propertyName).getFrom(bean);
+        return getPropertyAccessor(propertyName).getFrom(bean);
     }
 
     /**
      * {@inheritDoc}
      */
     protected void setImpl(Object bean, String propertyName, Object value) throws Exception {
-        getPropertyStrategy(propertyName).setOn(bean, value);
+        getPropertyAccessor(propertyName).setOn(bean, value);
     }
 
     /**
@@ -358,14 +357,14 @@
      * {@inheritDoc}
      */
     protected boolean isReadableImpl(Object bean, String propertyName) throws Exception {
-        return getPropertyStrategy(propertyName).isReadableOn(bean);
+        return getPropertyAccessor(propertyName).isReadableOn(bean);
     }
 
     /**
      * {@inheritDoc}
      */
     protected boolean isWriteableImpl(Object bean, String propertyName) throws Exception {
-        return getPropertyStrategy(propertyName).isWriteableOn(bean);
+        return getPropertyAccessor(propertyName).isWriteableOn(bean);
     }
 
     /**
@@ -388,13 +387,14 @@
     }
 
     /**
-     * Get the strategy instance to handle this property.
+     * Get a PropertyAccessor instance to handle this property.
      * @param propertyName to handle
      * @return PropertyStrategy
      */
-    protected PropertyStrategy getPropertyStrategy(String propertyName) {
-        return propertyName.startsWith(TYPE_OVERRIDE) ? (PropertyStrategy) new OverrideStrategy(
-                propertyName) : new DefaultStrategy(propertyName);
+    private PropertyAccessor getPropertyAccessor(String propertyName) {
+        return propertyName.startsWith(TYPE_OVERRIDE) ? (PropertyAccessor) new OverridingPropertyAccessor(
+                propertyName)
+                : new DefaultPropertyAccessor(propertyName);
     }
 
     /**
@@ -403,7 +403,7 @@
      * @param e Entity
      * @return e's value as a String.
      */
-    protected String getString(Entity e) {
+    private String getString(Entity e) {
         String s = new String(e.getValue());
         return isTrimStrings() ? s.trim() : s;
     }