From edc59b90e90e4243f8510ec797dceca2c56725ce Mon Sep 17 00:00:00 2001
From: izabel <izabel>
Date: Fri, 16 May 2008 09:18:55 +0000
Subject: [PATCH] [SE-33] code refactoring: properties (small changes) property
 name => property code getIsFlag => isFlag PropertyType.userLabel =>
 PropertyType.label Remove @deprecated

SVN: 6089
---
 .../parser/AbstractParserObjectFactory.java   | 27 +++++----
 .../common/parser/DefaultPropertyMapper.java  | 18 +++---
 .../cisd/common/parser/IPropertyMapper.java   | 16 ++---
 .../cisd/common/parser/IPropertyModel.java    |  4 +-
 .../MandatoryPropertyMissingException.java    |  2 +-
 .../cisd/common/parser/MappedProperty.java    |  2 +-
 .../parser/UnmatchedPropertiesException.java  | 58 +++++++++----------
 .../AbstractParserObjectFactoryTest.java      |  2 +-
 8 files changed, 64 insertions(+), 65 deletions(-)

diff --git a/common/source/java/ch/systemsx/cisd/common/parser/AbstractParserObjectFactory.java b/common/source/java/ch/systemsx/cisd/common/parser/AbstractParserObjectFactory.java
index 2bc4d26d451..8838a680fe0 100644
--- a/common/source/java/ch/systemsx/cisd/common/parser/AbstractParserObjectFactory.java
+++ b/common/source/java/ch/systemsx/cisd/common/parser/AbstractParserObjectFactory.java
@@ -85,12 +85,12 @@ public abstract class AbstractParserObjectFactory<E> implements IParserObjectFac
         return converterPool.convert(value, type);
     }
 
-    /** For given property name returns corresponding <code>IPropertyModel</code>. */
-    private final IPropertyModel tryGetPropertyModel(final String name)
+    /** For given property code returns corresponding <code>IPropertyModel</code>. */
+    private final IPropertyModel tryGetPropertyModel(final String code)
     {
-        if (propertyMapper.containsPropertyName(name))
+        if (propertyMapper.containsPropertyCode(code))
         {
-            return propertyMapper.getPropertyModel(name);
+            return propertyMapper.getPropertyModel(code);
         }
         return null;
     }
@@ -107,31 +107,30 @@ public abstract class AbstractParserObjectFactory<E> implements IParserObjectFac
     private final void checkPropertyMapper(final Class<E> clazz, final IPropertyMapper propMapper)
             throws ParserException
     {
-        final Set<String> allPropertyNames = propMapper.getAllPropertyNames();
-        final Set<String> propertyNames = new LinkedHashSet<String>(allPropertyNames);
+        final Set<String> allPropertyCodes = propMapper.getAllPropertyCodes();
+        final Set<String> propertyCodes = new LinkedHashSet<String>(allPropertyCodes);
         final Set<String> missingProperties = new LinkedHashSet<String>();
         final Set<String> fieldNames = beanAnalyzer.getLabelToWriteMethods().keySet();
         for (final String fieldName : fieldNames)
         {
             final String fieldNameInLowerCase = fieldName.toLowerCase();
-            if (propertyNames.contains(fieldNameInLowerCase))
+            if (propertyCodes.contains(fieldNameInLowerCase))
             {
-                propertyNames.remove(fieldNameInLowerCase);
+                propertyCodes.remove(fieldNameInLowerCase);
             } else if (beanAnalyzer.isMandatory(fieldName))
             {
                 missingProperties.add(fieldName);
             }
         }
-        final Set<String> mandatoryPropertyNames =
-                beanAnalyzer.getMandatoryProperties();
+        final Set<String> mandatoryPropertyCodes = beanAnalyzer.getMandatoryProperties();
         if (missingProperties.size() > 0)
         {
-            throw new MandatoryPropertyMissingException(mandatoryPropertyNames, missingProperties);
+            throw new MandatoryPropertyMissingException(mandatoryPropertyCodes, missingProperties);
         }
-        if (propertyNames.size() > 0)
+        if (propertyCodes.size() > 0)
         {
-            throw new UnmatchedPropertiesException(clazz, allPropertyNames, mandatoryPropertyNames,
-                    beanAnalyzer.getOptionalProperties(), propertyNames);
+            throw new UnmatchedPropertiesException(clazz, allPropertyCodes, mandatoryPropertyCodes,
+                    beanAnalyzer.getOptionalProperties(), propertyCodes);
         }
     }
 
diff --git a/common/source/java/ch/systemsx/cisd/common/parser/DefaultPropertyMapper.java b/common/source/java/ch/systemsx/cisd/common/parser/DefaultPropertyMapper.java
index 9b52cbaa45e..48388ea3ebd 100644
--- a/common/source/java/ch/systemsx/cisd/common/parser/DefaultPropertyMapper.java
+++ b/common/source/java/ch/systemsx/cisd/common/parser/DefaultPropertyMapper.java
@@ -48,7 +48,7 @@ public class DefaultPropertyMapper implements IPropertyMapper
 
                         public final String getKey(final IPropertyModel e)
                         {
-                            return e.getName().toLowerCase();
+                            return e.getCode().toLowerCase();
                         }
                     });
         tokensToMap(properties);
@@ -74,24 +74,24 @@ public class DefaultPropertyMapper implements IPropertyMapper
     // IPropertyMapper
     //
 
-    public final boolean containsPropertyName(final String propertyName)
+    public final boolean containsPropertyCode(final String propertyCode)
     {
-        return propertyModels.tryGet(propertyName.toLowerCase()) != null;
+        return propertyModels.tryGet(propertyCode.toLowerCase()) != null;
     }
 
-    public final Set<String> getAllPropertyNames()
+    public final Set<String> getAllPropertyCodes()
     {
         return new TreeSet<String>(propertyModels.keySet());
     }
 
-    public final IPropertyModel getPropertyModel(final String propertyName)
+    public final IPropertyModel getPropertyModel(final String propertyCode)
             throws IllegalArgumentException
     {
-        if (containsPropertyName(propertyName) == false)
+        if (containsPropertyCode(propertyCode) == false)
         {
-            throw new IllegalArgumentException(String.format(
-                    "Given property name '%s' does not exist.", propertyName));
+            throw new IllegalArgumentException(String.format("Given property '%s' does not exist.",
+                    propertyCode));
         }
-        return propertyModels.tryGet(propertyName.toLowerCase());
+        return propertyModels.tryGet(propertyCode.toLowerCase());
     }
 }
diff --git a/common/source/java/ch/systemsx/cisd/common/parser/IPropertyMapper.java b/common/source/java/ch/systemsx/cisd/common/parser/IPropertyMapper.java
index aa17d274f36..90268109ebc 100644
--- a/common/source/java/ch/systemsx/cisd/common/parser/IPropertyMapper.java
+++ b/common/source/java/ch/systemsx/cisd/common/parser/IPropertyMapper.java
@@ -20,7 +20,7 @@ import java.util.Set;
 
 /**
  * The job of <code>PropertyMapper</code> is to return mapping informations regarding a given
- * property name.
+ * property code.
  * 
  * @author Christian Ribeaud
  */
@@ -28,23 +28,23 @@ public interface IPropertyMapper
 {
 
     /**
-     * Returns an <code>IPropertyModel</code> for a given property name.
+     * Returns an <code>IPropertyModel</code> for a given property code.
      * 
-     * @throws IllegalArgumentException if given <var>propertyName</var> does not exist.
+     * @throws IllegalArgumentException if given <var>propertyCode</var> does not exist.
      */
-    public IPropertyModel getPropertyModel(final String propertyName)
+    public IPropertyModel getPropertyModel(final String propertyCode)
             throws IllegalArgumentException;
 
     /**
-     * Returns a set of all property names.
+     * Returns a set of all property codes.
      * <p>
      * Note that changes applied to returned <code>Set</code> are not reflected in the backed
      * collection.
      * </p>
      */
-    public Set<String> getAllPropertyNames();
+    public Set<String> getAllPropertyCodes();
 
-    /** Whether there is a property with given <var>propertyName</var>. */
-    public boolean containsPropertyName(final String propertyName);
+    /** Whether there is a property with given <var>propertyCode</var>. */
+    public boolean containsPropertyCode(final String propertyCode);
 
 }
\ No newline at end of file
diff --git a/common/source/java/ch/systemsx/cisd/common/parser/IPropertyModel.java b/common/source/java/ch/systemsx/cisd/common/parser/IPropertyModel.java
index 7727a11ac58..01478e9176c 100644
--- a/common/source/java/ch/systemsx/cisd/common/parser/IPropertyModel.java
+++ b/common/source/java/ch/systemsx/cisd/common/parser/IPropertyModel.java
@@ -30,8 +30,8 @@ public interface IPropertyModel
     /** Returns the column number where the information regarding this property could be found. */
     public int getColumn();
 
-    /** Returns the property name as it has been found in the parsed file. */
-    public String getName();
+    /** Returns the property code as it has been found in the parsed file. */
+    public String getCode();
 
     /**
      * Returns the format of this property.
diff --git a/common/source/java/ch/systemsx/cisd/common/parser/MandatoryPropertyMissingException.java b/common/source/java/ch/systemsx/cisd/common/parser/MandatoryPropertyMissingException.java
index 39aca01ffe6..bde40cd002a 100644
--- a/common/source/java/ch/systemsx/cisd/common/parser/MandatoryPropertyMissingException.java
+++ b/common/source/java/ch/systemsx/cisd/common/parser/MandatoryPropertyMissingException.java
@@ -31,7 +31,7 @@ public final class MandatoryPropertyMissingException extends ParserException
 {
     private static final long serialVersionUID = 1L;
 
-    /** The mandatory property names that could not be found in the parsed file. */
+    /** The mandatory property codes that could not be found in the parsed file. */
     private final Set<String> missingMandatoryProperties;
 
     /** The fields that are mandatory. */
diff --git a/common/source/java/ch/systemsx/cisd/common/parser/MappedProperty.java b/common/source/java/ch/systemsx/cisd/common/parser/MappedProperty.java
index e1f679dfb31..49468bcfec8 100644
--- a/common/source/java/ch/systemsx/cisd/common/parser/MappedProperty.java
+++ b/common/source/java/ch/systemsx/cisd/common/parser/MappedProperty.java
@@ -60,7 +60,7 @@ final class MappedProperty implements IPropertyModel
         return column;
     }
 
-    public final String getName()
+    public final String getCode()
     {
         return name;
     }
diff --git a/common/source/java/ch/systemsx/cisd/common/parser/UnmatchedPropertiesException.java b/common/source/java/ch/systemsx/cisd/common/parser/UnmatchedPropertiesException.java
index 97f371f10ad..2f2ac5e91bd 100644
--- a/common/source/java/ch/systemsx/cisd/common/parser/UnmatchedPropertiesException.java
+++ b/common/source/java/ch/systemsx/cisd/common/parser/UnmatchedPropertiesException.java
@@ -34,43 +34,43 @@ public final class UnmatchedPropertiesException extends ParserException
     /** The bean this is set during the parsing process. */
     private final Class<?> beanClass;
 
-    /** The property names found in the parsed file. */
-    private final Set<String> allPropertyNames;
+    /** The property codes found in the parsed file. */
+    private final Set<String> allPropertyCodes;
 
-    /** The mandatory property names found in the bean. */
-    private final Set<String> mandatoryNames;
+    /** The mandatory property codes found in the bean. */
+    private final Set<String> mandatoryCodes;
 
-    /** The optional property names found in the bean. */
-    private final Set<String> optionalNames;
+    /** The optional property codes found in the bean. */
+    private final Set<String> optionalCodes;
 
     /**
-     * The property names of {@link #allPropertyNames} that can neither be found in
-     * {@link #mandatoryNames} nor in {@link #optionalNames}.
+     * The property codes of {@link #allPropertyCodes} that can neither be found in
+     * {@link #mandatoryCodes} nor in {@link #optionalCodes}.
      */
-    private final Set<String> propertyNames;
+    private final Set<String> propertyCodes;
 
     public UnmatchedPropertiesException(final Class<?> beanClass,
-            final Set<String> allPropertyNames, final Set<String> mandatoryNames,
-            final Set<String> optionalNames, final Set<String> propertyNames)
+            final Set<String> allPropertyCodes, final Set<String> mandatoryCodes,
+            final Set<String> optionalCodes, final Set<String> propertyCodes)
     {
-        super(createMessage(propertyNames, mandatoryNames, optionalNames));
-        assert allPropertyNames != null : "All property names can not be null.";
-        assert mandatoryNames != null : "Mandatory names can not be null.";
-        assert optionalNames != null : "Optional names can not be null.";
+        super(createMessage(propertyCodes, mandatoryCodes, optionalCodes));
+        assert allPropertyCodes != null : "All property codes can not be null.";
+        assert mandatoryCodes != null : "Mandatory codes can not be null.";
+        assert optionalCodes != null : "Optional codes can not be null.";
         this.beanClass = beanClass;
-        this.allPropertyNames = allPropertyNames;
-        this.mandatoryNames = mandatoryNames;
-        this.optionalNames = optionalNames;
-        this.propertyNames = propertyNames;
+        this.allPropertyCodes = allPropertyCodes;
+        this.mandatoryCodes = mandatoryCodes;
+        this.optionalCodes = optionalCodes;
+        this.propertyCodes = propertyCodes;
     }
 
-    private final static String createMessage(Set<String> propertyNames,
+    private final static String createMessage(Set<String> propertyCodes,
             Set<String> mandatoryNames, Set<String> optionalNames)
     {
-        assert propertyNames != null : "Property names can not be null.";
-        assert propertyNames.size() > 0 : "There is no reason to throw this exception.";
+        assert propertyCodes != null : "Property codes can not be null.";
+        assert propertyCodes.size() > 0 : "There is no reason to throw this exception.";
         final StringBuilder builder = new StringBuilder();
-        builder.append("Columns ").append(toString(propertyNames)).append(
+        builder.append("Columns ").append(toString(propertyCodes)).append(
                 " specified in the header are not expected (");
         final boolean hasMandatory = mandatoryNames.size() > 0;
         if (hasMandatory)
@@ -102,24 +102,24 @@ public final class UnmatchedPropertiesException extends ParserException
         return beanClass;
     }
 
-    public final Set<String> getAllPropertyNames()
+    public final Set<String> getAllPropertyCodes()
     {
-        return Collections.unmodifiableSet(allPropertyNames);
+        return Collections.unmodifiableSet(allPropertyCodes);
     }
 
-    public final Set<String> getPropertyNames()
+    public final Set<String> getPropertyCodes()
     {
-        return Collections.unmodifiableSet(propertyNames);
+        return Collections.unmodifiableSet(propertyCodes);
     }
 
     public final Set<String> getMandatoryNames()
     {
-        return Collections.unmodifiableSet(mandatoryNames);
+        return Collections.unmodifiableSet(mandatoryCodes);
     }
 
     public final Set<String> getOptionalNames()
     {
-        return Collections.unmodifiableSet(optionalNames);
+        return Collections.unmodifiableSet(optionalCodes);
     }
 
 }
diff --git a/common/sourceTest/java/ch/systemsx/cisd/common/parser/AbstractParserObjectFactoryTest.java b/common/sourceTest/java/ch/systemsx/cisd/common/parser/AbstractParserObjectFactoryTest.java
index cc9f6abe7b1..2b438543163 100644
--- a/common/sourceTest/java/ch/systemsx/cisd/common/parser/AbstractParserObjectFactoryTest.java
+++ b/common/sourceTest/java/ch/systemsx/cisd/common/parser/AbstractParserObjectFactoryTest.java
@@ -101,7 +101,7 @@ public final class AbstractParserObjectFactoryTest
             final String[] lineTokens = new String[]
                 { "1. experiment" };
             beanFactory.createObject(lineTokens);
-            fail("Field/Property name 'name' is mandatory.");
+            fail("Field/Property code 'name' is mandatory.");
         } catch (final MandatoryPropertyMissingException ex)
         {
             AssertJUnit.assertTrue(ex.getMessage().indexOf("name") > 1);
-- 
GitLab