labs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simo...@apache.org
Subject svn commit: r834841 - in /labs/magma/trunk: foundation-beans/src/main/java/org/apache/magma/conversion/AddConversionInHandler.aj foundation-i18n/src/main/java/org/apache/magma/i18n/AddFormattingInHandler.aj
Date Wed, 11 Nov 2009 11:17:15 GMT
Author: simoneg
Date: Wed Nov 11 11:17:13 2009
New Revision: 834841

URL: http://svn.apache.org/viewvc?rev=834841&view=rev
Log:
LABS-495: optimizing also string based handling

Modified:
    labs/magma/trunk/foundation-beans/src/main/java/org/apache/magma/conversion/AddConversionInHandler.aj
    labs/magma/trunk/foundation-i18n/src/main/java/org/apache/magma/i18n/AddFormattingInHandler.aj

Modified: labs/magma/trunk/foundation-beans/src/main/java/org/apache/magma/conversion/AddConversionInHandler.aj
URL: http://svn.apache.org/viewvc/labs/magma/trunk/foundation-beans/src/main/java/org/apache/magma/conversion/AddConversionInHandler.aj?rev=834841&r1=834840&r2=834841&view=diff
==============================================================================
--- labs/magma/trunk/foundation-beans/src/main/java/org/apache/magma/conversion/AddConversionInHandler.aj
(original)
+++ labs/magma/trunk/foundation-beans/src/main/java/org/apache/magma/conversion/AddConversionInHandler.aj
Wed Nov 11 11:17:13 2009
@@ -115,6 +115,7 @@
 		this.stringValues.clear();
 		this.explicitlySet.clear();
 		this.nonConverted.clear();
+		/*
 		Set<String> names = this.data.getPropertyNames();
 		for (String name : names) {
 			PropertyInfo property = this.data.getProperty(name);
@@ -122,7 +123,8 @@
 				Object val = this.values.get(name);
 				loadConverted(property, val);
 			}
-		}		
+		}	
+		*/	
 	}
 	
 	/**

Modified: labs/magma/trunk/foundation-i18n/src/main/java/org/apache/magma/i18n/AddFormattingInHandler.aj
URL: http://svn.apache.org/viewvc/labs/magma/trunk/foundation-i18n/src/main/java/org/apache/magma/i18n/AddFormattingInHandler.aj?rev=834841&r1=834840&r2=834841&view=diff
==============================================================================
--- labs/magma/trunk/foundation-i18n/src/main/java/org/apache/magma/i18n/AddFormattingInHandler.aj
(original)
+++ labs/magma/trunk/foundation-i18n/src/main/java/org/apache/magma/i18n/AddFormattingInHandler.aj
Wed Nov 11 11:17:13 2009
@@ -25,6 +25,7 @@
 import org.apache.magma.beans.BeanHandler;
 import org.apache.magma.beans.PropertyInfo;
 import org.apache.magma.conversion.ConversionException;
+import org.apache.magma.conversion.Converter;
 
 /**
  * Adds a layer to the {@link BeanHandler} to support formatted values retrieval and parsing.
@@ -71,10 +72,15 @@
 	public String BeanHandler.getFormattedStringValue(String field) {
 		PropertyInfo property = data.getProperty(field);
 		if (property == null) throw new MagmaException("Cannot find a proprty named {0} in class
{1}", field, bean.getClass().getName());
-		if (property.getFormatter() == null) {
+		Formatter form = property.getFormatter();
+		if (form == null) {
 			return this.getStringValue(field);
 		}		
 		if (!property.isReadable()) throw new MagmaException("Property {0} is not readable in class
{1}", field, bean.getClass().getName());
+		if (!formattedValues.containsKey(field)) {
+			Object val = getValue(field);
+			loadFormatted(property, val);
+		}
 		return formattedValues.get(field);
 	}
 	
@@ -83,21 +89,7 @@
 	 */
 	public void BeanHandler.rollbackFormattedStringValues() {
 		this.formattedValues.clear();
-		Set<String> names = this.data.getPropertyNames();
-		for (String name : names) {
-			PropertyInfo property = this.data.getProperty(name);
-			Object val = this.values.get(name);
-			if (val != null) {
-				Formatter form = property.getFormatter();
-				if (form != null) {
-					this.formattedValues.put(name, form.to(val));
-				} else {
-					this.formattedValues.put(name, this.getStringValue(name));
-				}
-			} else {
-				this.formattedValues.put(name, "");
-			}
-		}		
+		this.formattedExplicitlySet.clear();
 	}
 	
 	/**
@@ -128,4 +120,19 @@
 		if (exc != null) throw exc;
 	}
 	
+	private void BeanHandler.loadFormatted(PropertyInfo property, Object val) {
+		String name = property.getName();
+		if (val != null) {
+			Formatter form = property.getFormatter();
+			if (form != null) {
+				this.formattedValues.put(name, form.to(val));
+			} else {
+				this.formattedValues.put(name, this.getStringValue(name));
+			}
+		} else {
+			this.formattedValues.put(name, "");
+		}
+	}
+	
+	
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org


Mime
View raw message