You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2010/01/07 18:20:29 UTC

svn commit: r896930 - in /myfaces/tobago/trunk: core/src/main/java/org/apache/myfaces/tobago/component/ core/src/main/java/org/apache/myfaces/tobago/context/ core/src/main/java/org/apache/myfaces/tobago/internal/context/ core/src/main/java/org/apache/m...

Author: lofwyr
Date: Thu Jan  7 17:13:58 2010
New Revision: 896930

URL: http://svn.apache.org/viewvc?rev=896930&view=rev
Log:
TOBAGO-606: Optimize usage and object-creation/caching of Measure objects.

Modified:
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIGridLayout.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIMessages.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ResourceManagerImpl.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/internal/context/ThemeConfigCacheKey.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/FactorList.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/IntervalList.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/Measure.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/PixelMeasure.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/grid/Grid.java
    myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/layout/IntervalListUnitTest.java
    myfaces/tobago/trunk/example/test/src/main/java/org/apache/myfaces/tobago/example/test/MeasureBean.java
    myfaces/tobago/trunk/extension/math/src/main/java/org/apache/myfaces/tobago/component/AbstractUIEquationGridLayout.java
    myfaces/tobago/trunk/extension/math/src/main/java/org/apache/myfaces/tobago/component/UIEquationGridLayout.java
    myfaces/tobago/trunk/extension/math/src/main/java/org/apache/myfaces/tobago/layout/math/SystemOfEquations.java
    myfaces/tobago/trunk/extension/math/src/test/java/org/apache/myfaces/tobago/component/GridLayoutManagerUnitTest.java
    myfaces/tobago/trunk/extension/math/src/test/java/org/apache/myfaces/tobago/layout/math/CombinationEquationUnitTest.java
    myfaces/tobago/trunk/extension/math/src/test/java/org/apache/myfaces/tobago/layout/math/EquationManagerUnitTest.java
    myfaces/tobago/trunk/extension/math/src/test/java/org/apache/myfaces/tobago/layout/math/PartitionEquationUnitTest.java
    myfaces/tobago/trunk/extension/math/src/test/java/org/apache/myfaces/tobago/layout/math/SystemOfEquationsUnitTest.java
    myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/sandbox/standard/tag/NumberSliderRenderer.java
    myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/BoxRenderer.java
    myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MessagesRenderer.java
    myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java
    myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/util/RenderUtil.java
    myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component1.1.stg
    myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component1.2.stg

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIGridLayout.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIGridLayout.java?rev=896930&r1=896929&r2=896930&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIGridLayout.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIGridLayout.java Thu Jan  7 17:13:58 2010
@@ -33,7 +33,6 @@
 import org.apache.myfaces.tobago.layout.Measure;
 import org.apache.myfaces.tobago.layout.Orientation;
 import org.apache.myfaces.tobago.layout.PixelLayoutToken;
-import org.apache.myfaces.tobago.layout.PixelMeasure;
 import org.apache.myfaces.tobago.layout.RelativeLayoutToken;
 import org.apache.myfaces.tobago.layout.grid.Cell;
 import org.apache.myfaces.tobago.layout.grid.Grid;
@@ -101,7 +100,7 @@
 
       if (token instanceof PixelLayoutToken) {
         int pixel = ((PixelLayoutToken) token).getPixel();
-        grid.getSizes(orientation)[i] = new PixelMeasure(pixel); // XXX refactor
+        grid.getSizes(orientation)[i] = Measure.valueOf(pixel); // XXX refactor
       }
 
       IntervalList intervals = new IntervalList();
@@ -126,7 +125,7 @@
       }
       if (intervals.size() >= 1) {
         Measure auto = intervals.computeAuto();
-        grid.getSizes(orientation)[i] = (PixelMeasure) auto;
+        grid.getSizes(orientation)[i] = auto;
       }
 // todo: what when we cannot find a good value for "auto"?
       i++;
@@ -134,7 +133,7 @@
 
     // set the size if all sizes are set
     Measure size = Measure.ZERO;
-    PixelMeasure[] sizes = grid.getSizes(orientation);
+    Measure[] sizes = grid.getSizes(orientation);
     for (int j = 0; j < sizes.length; j++) {
       if (sizes[j] == null) {
         size = null; // set to invalid
@@ -166,11 +165,10 @@
       LayoutContainer container = getLayoutContainer();
       Measure available = LayoutUtils.getCurrentSize(orientation, container);
       if (available != null) {
-        for (PixelMeasure value : grid.getSizes(orientation)) {
+        for (Measure value : grid.getSizes(orientation)) {
           available = available.subtractNotNegative(value);
         }
-        PixelMeasure spacing = new PixelMeasure(
-            getSpacing(orientation).getPixel() * (grid.getSizes(orientation).length - 1));
+        Measure spacing = getSpacing(orientation).multiply(grid.getSizes(orientation).length - 1);
         available = available.subtractNotNegative(spacing);
 
         available = available.subtractNotNegative(LayoutUtils.getBeginOffset(orientation, container));
@@ -183,7 +181,7 @@
         int j = 0;
         for (LayoutToken token : grid.getTokens(orientation)) {
           if (token instanceof RelativeLayoutToken) {
-            grid.getSizes(orientation)[i] = (PixelMeasure) partition.get(j);
+            grid.getSizes(orientation)[i] = partition.get(j);
             j++;
           }
           i++;
@@ -203,7 +201,7 @@
           component.setDisplay(Display.BLOCK); // TODO: use CSS via classes and style.css
 
           Integer span = ((OriginCell) cell).getSpan(orientation);
-          PixelMeasure[] pixelMeasures = grid.getSizes(orientation);
+          Measure[] pixelMeasures = grid.getSizes(orientation);
 
           // compute the size of the cell
           Measure size = pixelMeasures[i];
@@ -237,7 +235,7 @@
 
           component.setDisplay(Display.BLOCK); // TODO: use CSS via classes and style.css
 
-          PixelMeasure[] pixelMeasures = grid.getSizes(orientation);
+          Measure[] pixelMeasures = grid.getSizes(orientation);
 
           // compute the position of the cell
           Measure position = LayoutUtils.getBeginOffset(orientation, getLayoutContainer());

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIMessages.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIMessages.java?rev=896930&r1=896929&r2=896930&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIMessages.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIMessages.java Thu Jan  7 17:13:58 2010
@@ -19,7 +19,7 @@
 
 import org.apache.commons.collections.iterators.SingletonIterator;
 import org.apache.myfaces.tobago.layout.LayoutComponent;
-import org.apache.myfaces.tobago.layout.PixelMeasure;
+import org.apache.myfaces.tobago.layout.Measure;
 
 import javax.faces.application.FacesMessage;
 import javax.faces.context.FacesContext;
@@ -79,7 +79,7 @@
     // todo: performance
     int count = createMessageList(facesContext).size();
     // todo: is this okay? to set local values?
-    setPreferredHeight(new PixelMeasure(20 * count));
+    setPreferredHeight(Measure.valueOf(20 * count));
   }
 
   public static class Item {

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ResourceManagerImpl.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ResourceManagerImpl.java?rev=896930&r1=896929&r2=896930&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ResourceManagerImpl.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ResourceManagerImpl.java Thu Jan  7 17:13:58 2010
@@ -226,13 +226,13 @@
       List properties = getPaths(clientKey, "", PROPERTY, "tobago-theme-config", "",
           false, true, false, rendererType + "." + name, true, true);
       if (properties != null) {
-        Measure measure = Measure.parse(properties.get(0));
+        Measure measure = Measure.valueOf(properties.get(0));
 
         for (String m : markup) {
           List mProperties = getPaths(clientKey, "", PROPERTY, "tobago-theme-config", "",
               false, true, false, rendererType + "[" + m + "]" + "." + name, true, true);
           if (mProperties != null) {
-            measure.add(Measure.parse(mProperties.get(0)));
+            measure.add(Measure.valueOf(mProperties.get(0)));
           }
         }
 

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/internal/context/ThemeConfigCacheKey.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/internal/context/ThemeConfigCacheKey.java?rev=896930&r1=896929&r2=896930&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/internal/context/ThemeConfigCacheKey.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/internal/context/ThemeConfigCacheKey.java Thu Jan  7 17:13:58 2010
@@ -33,7 +33,7 @@
       ClientPropertiesKey clientPropertiesKey, String rendererType, String[] markup, String name) {
     this.clientPropertiesKey = clientPropertiesKey;
     this.rendererType = rendererType;
-    this.markup = (String[]) ArrayUtils.clone(markup);
+    this.markup = (String[]) ArrayUtils.clone(markup); // todo: copy ref and don't clone when markup is unmodifiable
     this.name = name;
     hashCode = calcHashCode();
   }

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/FactorList.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/FactorList.java?rev=896930&r1=896929&r2=896930&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/FactorList.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/FactorList.java Thu Jan  7 17:13:58 2010
@@ -46,7 +46,7 @@
     MathUtils.adjustRemainders(doubles, 0.0);
 
     for (double value : doubles) {
-      result.add(new PixelMeasure((int) value));
+      result.add(Measure.valueOf((int) value));
     }
 
     return result;

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/IntervalList.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/IntervalList.java?rev=896930&r1=896929&r2=896930&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/IntervalList.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/IntervalList.java Thu Jan  7 17:13:58 2010
@@ -33,17 +33,17 @@
     List<Measure> minimumList = collectMinimum();
     List<Measure> maximumList = collectMaximum();
     if (!currentList.isEmpty()) {
-      auto = max(max(minimumList), max(currentList));
+      auto = Measure.max(Measure.max(minimumList), Measure.max(currentList));
     } else {
-      Measure maximumOfMinimumList = max(minimumList);
-      Measure minimumOfMaximumList = min(maximumList);
-      if (maximumOfMinimumList.getPixel() > minimumOfMaximumList.getPixel()) {
+      Measure maximumOfMinimumList = Measure.max(minimumList);
+      Measure minimumOfMaximumList = Measure.min(maximumList);
+      if (maximumOfMinimumList.greaterThan(minimumOfMaximumList)) {
         LOG.warn("!");
         auto = maximumOfMinimumList;
       } else {
         List<Measure> preferredInInterval = findPreferredInInterval(maximumOfMinimumList, minimumOfMaximumList);
         if (!preferredInInterval.isEmpty()) {
-          auto = max(preferredInInterval);
+          auto = Measure.max(preferredInInterval);
         } else {
           auto = maximumOfMinimumList;
         }
@@ -83,39 +83,11 @@
     return result;
   }
 
-  private Measure max(List<Measure> list) {
-    Measure max = Measure.ZERO;
-    for (Measure measure : list) {
-      if (measure.getPixel() > max.getPixel()) {
-        max = measure;
-      }
-    }
-    return max;
-  }
-
-  private Measure min(List<Measure> list) {
-    Measure min = new PixelMeasure(Integer.MAX_VALUE);
-    for (Measure measure : list) {
-      if (measure.getPixel() < min.getPixel()) {
-        min = measure;
-      }
-    }
-    return min;
-  }
-
-  private Measure max(Measure m1, Measure m2) {
-    if (m1.getPixel() > m2.getPixel()) {
-      return m1;
-    } else {
-      return m2;
-    }
-  }
-
   private List<Measure> findPreferredInInterval(Measure min, Measure max) {
     List<Measure> result = new ArrayList<Measure>();
     for (Interval interval : this) {
       Measure preferred = interval.getPreferred();
-      if (preferred != null && preferred.getPixel() >= min.getPixel() && preferred.getPixel() <= max.getPixel()) {
+      if (preferred != null && preferred.greaterOrEqualThan(min) && preferred.lessOrEqualThan(max)) {
         result.add(preferred);
       }
     }

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/Measure.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/Measure.java?rev=896930&r1=896929&r2=896930&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/Measure.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/Measure.java Thu Jan  7 17:13:58 2010
@@ -22,6 +22,7 @@
 import org.apache.commons.logging.LogFactory;
 
 import java.io.Serializable;
+import java.util.List;
 
 public abstract class Measure implements Serializable {
 
@@ -29,32 +30,73 @@
 
   private static final Log LOG = LogFactory.getLog(Measure.class);
 
-  public static final Measure ZERO = new PixelMeasure(0);
+  public static final Measure ZERO = valueOf(0);
+  public static final Measure MAX = valueOf(Integer.MAX_VALUE);
 
   // todo: refactor and consolidate with LayoutToken
-
-  public static Measure parse(Object object) {
-    if (object == null) {
+  
+  public static Measure valueOf(Measure value) {
+    if (value == null) {
       return ZERO;
     }
-    if (object instanceof Measure) {
-      return (Measure) object;
+    return value;
+  }
+
+  public static Measure valueOf(int value) {
+    return PixelMeasure.pixelValueOf(value);
+  }
+
+  public static Measure valueOf(Integer value) {
+    if (value == null) {
+      return ZERO;
     }
-    if (object instanceof Number) {
-      return new PixelMeasure(((Number) object).intValue());
+    return valueOf(value.intValue());
+  }
+
+  public static Measure valueOf(Number value) {
+    if (value == null) {
+      return ZERO;
     }
-    String value = object instanceof String ? (String) object : object.toString();
-    
+    return valueOf(value.intValue());
+  }
+
+  public static Measure valueOf(String value) {
     if (StringUtils.isEmpty(value)) {
       return ZERO;
     }
-    if (value.toLowerCase().matches("\\d+px")) {// XXX no regexp here: user LayoutTokens.parse !!!
-      return new PixelMeasure(Integer.parseInt(value.substring(0, value.length() - 2)));
+    try {
+      if (value.endsWith("px")) {
+        return Measure.valueOf(Integer.parseInt(value.substring(0, value.length() - 2)));
+      }
+      return Measure.valueOf(Integer.parseInt(value));
+
+    } catch (NumberFormatException e) {
+      throw new IllegalArgumentException("Can't parse to any measure: '" + value + "'", e);
+    }
+  }
+
+  public static Measure valueOf(Object object) {
+    if (object instanceof Measure) {
+      return valueOf((Measure) object);
+    }
+    if (object instanceof Number) {
+      return valueOf((Number) object);
     }
-    if (value.matches("\\d+")) {// XXX no regexp here: user LayoutTokens.parse !!!
-      return new PixelMeasure(Integer.parseInt(value));
+    if (object instanceof String) {
+      return valueOf((String) object);
     }
-    throw new IllegalArgumentException("Can't parse to any measure: '" + value + "'");
+    if (object == null) {
+      return ZERO;
+    }
+    return valueOf(object.toString());
+  }
+
+  /**
+   * @deprecated since 1.5.0, please use valueOf()
+   */
+  @Deprecated
+  public static Measure parse(String value) {
+    return valueOf(value);
   }
 
   public abstract Measure add(Measure m);
@@ -74,17 +116,60 @@
   public abstract Measure subtractNotNegative(Measure m);
 
   public abstract Measure subtract(Measure m);
-  
+
   public abstract Measure subtract(int m);
 
   public boolean greaterThan(Measure measure) {
     return measure != null && getPixel() > measure.getPixel();
   }
 
+  public boolean greaterOrEqualThan(Measure measure) {
+    return measure != null && getPixel() >= measure.getPixel();
+  }
+
   public boolean lessThan(Measure measure) {
     return measure != null && getPixel() < measure.getPixel();
   }
 
+  public boolean lessOrEqualThan(Measure measure) {
+    return measure != null && getPixel() <= measure.getPixel();
+  }
+
   public abstract int getPixel();
 
+  public static Measure max(List<Measure> list) {
+    Measure max = ZERO;
+    for (Measure measure : list) {
+      if (measure.greaterThan(max)) {
+        max = measure;
+      }
+    }
+    return max;
+  }
+
+  public static Measure min(List<Measure> list) {
+    Measure min = MAX;
+    for (Measure measure : list) {
+      if (measure.lessThan(min)) {
+        min = measure;
+      }
+    }
+    return min;
+  }
+
+  public static Measure max(Measure m1, Measure m2) {
+    if (m1.greaterThan(m2)) {
+      return m1;
+    } else {
+      return m2;
+    }
+  }
+
+  public static Measure min(Measure m1, Measure m2) {
+    if (m1.lessThan(m2)) {
+      return m1;
+    } else {
+      return m2;
+    }
+  }
 }

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/PixelMeasure.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/PixelMeasure.java?rev=896930&r1=896929&r2=896930&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/PixelMeasure.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/PixelMeasure.java Thu Jan  7 17:13:58 2010
@@ -27,49 +27,62 @@
 
   private static final Log LOG = LogFactory.getLog(PixelMeasure.class);
 
+  static final Measure[] PIXEL_CACHE;
+  static final int PIXEL_CACHE_MAX = 4000;
+  
+  static {
+    PIXEL_CACHE = new Measure[PIXEL_CACHE_MAX + 1];
+    for (int i = 0; i < PIXEL_CACHE.length; i++) {
+      PIXEL_CACHE[i] = new PixelMeasure(i);
+    }
+  }
+  
   private final int pixel;
 
-  public PixelMeasure(int pixel) {
+  private PixelMeasure(int pixel) {
     this.pixel = pixel;
   }
 
-  public PixelMeasure(Measure measure) {
-    this.pixel = measure.getPixel();
+  static Measure pixelValueOf(int value) {
+    if (value <= PixelMeasure.PIXEL_CACHE_MAX) {
+      return PixelMeasure.PIXEL_CACHE[value];
+    }
+    return new PixelMeasure(value);
   }
-
+  
   public Measure add(Measure m) {
-    return new PixelMeasure(pixel + m.getPixel());
+    return pixelValueOf(pixel + m.getPixel());
   }
 
   public Measure add(int m) {
-    return new PixelMeasure(pixel + m);
+    return pixelValueOf(pixel + m);
   }
 
   public Measure multiply(int times) {
-    return new PixelMeasure(pixel * times);
+    return pixelValueOf(pixel * times);
   }
 
   public Measure subtractNotNegative(Measure m) {
     if (m == null) {
-      return new PixelMeasure(this);
+      return this;
     } else if (m.getPixel() > pixel) {
       LOG.warn("Not enough space! value=" + pixel);
       return ZERO;
     } else {
-      return new PixelMeasure(pixel - m.getPixel());
+      return pixelValueOf(pixel - m.getPixel());
     }
   }
 
   public Measure subtract(Measure m) {
     if (m == null) {
-      return new PixelMeasure(this);
+      return this;
     } else {
-      return new PixelMeasure(pixel - m.getPixel());
+      return pixelValueOf(pixel - m.getPixel());
     }
   }
 
   public Measure subtract(int m) {
-      return new PixelMeasure(pixel - m);
+      return pixelValueOf(pixel - m);
   }
 
   public int getPixel() {

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/grid/Grid.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/grid/Grid.java?rev=896930&r1=896929&r2=896930&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/grid/Grid.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/grid/Grid.java Thu Jan  7 17:13:58 2010
@@ -21,8 +21,8 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.myfaces.tobago.layout.AutoLayoutToken;
 import org.apache.myfaces.tobago.layout.LayoutTokens;
+import org.apache.myfaces.tobago.layout.Measure;
 import org.apache.myfaces.tobago.layout.Orientation;
-import org.apache.myfaces.tobago.layout.PixelMeasure;
 
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -39,8 +39,8 @@
   private List<Cell> cells;
   private LayoutTokens columns;
   private LayoutTokens rows;
-  private PixelMeasure[] widths;
-  private PixelMeasure[] heights;
+  private Measure[] widths;
+  private Measure[] heights;
 
   private List<Integer> errorIndexes;
 
@@ -61,8 +61,8 @@
       this.cells.add(null);
     }
 
-    widths = new PixelMeasure[columns.getSize()];
-    heights = new PixelMeasure[rows.getSize()];
+    widths = new Measure[columns.getSize()];
+    heights = new Measure[rows.getSize()];
   }
 
   public void add(OriginCell cell, int columnSpan, int rowSpan) {
@@ -163,8 +163,8 @@
       rows.addToken(AutoLayoutToken.INSTANCE);
     }
 
-    PixelMeasure[] oldHeights = heights;
-    heights = new PixelMeasure[heights.length + newRows];
+    Measure[] oldHeights = heights;
+    heights = new Measure[heights.length + newRows];
     System.arraycopy(oldHeights, 0, heights, 0, oldHeights.length);
   }
 
@@ -471,15 +471,15 @@
     this.verticalIndices = verticalIndices;
   }
 
-  public PixelMeasure[] getSizes(Orientation orientation) {
+  public Measure[] getSizes(Orientation orientation) {
     return orientation == Orientation.HORIZONTAL ? getWidths() : getHeights();
   }
 
-  public PixelMeasure[] getWidths() {
+  public Measure[] getWidths() {
     return widths;
   }
 
-  public PixelMeasure[] getHeights() {
+  public Measure[] getHeights() {
     return heights;
   }
 }

Modified: myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/layout/IntervalListUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/layout/IntervalListUnitTest.java?rev=896930&r1=896929&r2=896930&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/layout/IntervalListUnitTest.java (original)
+++ myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/layout/IntervalListUnitTest.java Thu Jan  7 17:13:58 2010
@@ -189,6 +189,6 @@
   }
 
   private Measure px(int pixel) {
-    return new PixelMeasure(pixel);
+    return Measure.valueOf(pixel);
   }
 }

Modified: myfaces/tobago/trunk/example/test/src/main/java/org/apache/myfaces/tobago/example/test/MeasureBean.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/test/src/main/java/org/apache/myfaces/tobago/example/test/MeasureBean.java?rev=896930&r1=896929&r2=896930&view=diff
==============================================================================
--- myfaces/tobago/trunk/example/test/src/main/java/org/apache/myfaces/tobago/example/test/MeasureBean.java (original)
+++ myfaces/tobago/trunk/example/test/src/main/java/org/apache/myfaces/tobago/example/test/MeasureBean.java Thu Jan  7 17:13:58 2010
@@ -18,7 +18,6 @@
  */
 
 import org.apache.myfaces.tobago.layout.Measure;
-import org.apache.myfaces.tobago.layout.PixelMeasure;
 
 public class MeasureBean {
 
@@ -39,11 +38,11 @@
   }
 
   public Measure getMeasureWidth() {
-    return new PixelMeasure(300);
+    return Measure.valueOf(300);
   }
 
   public Measure getMeasureHeight() {
-    return new PixelMeasure(95);
+    return Measure.valueOf(95);
   }
 
   public String getStringWidth() {

Modified: myfaces/tobago/trunk/extension/math/src/main/java/org/apache/myfaces/tobago/component/AbstractUIEquationGridLayout.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/extension/math/src/main/java/org/apache/myfaces/tobago/component/AbstractUIEquationGridLayout.java?rev=896930&r1=896929&r2=896930&view=diff
==============================================================================
--- myfaces/tobago/trunk/extension/math/src/main/java/org/apache/myfaces/tobago/component/AbstractUIEquationGridLayout.java (original)
+++ myfaces/tobago/trunk/extension/math/src/main/java/org/apache/myfaces/tobago/component/AbstractUIEquationGridLayout.java Thu Jan  7 17:13:58 2010
@@ -30,7 +30,6 @@
 import org.apache.myfaces.tobago.layout.Measure;
 import org.apache.myfaces.tobago.layout.Orientation;
 import org.apache.myfaces.tobago.layout.PixelLayoutToken;
-import org.apache.myfaces.tobago.layout.PixelMeasure;
 import org.apache.myfaces.tobago.layout.RelativeLayoutToken;
 import org.apache.myfaces.tobago.layout.grid.Cell;
 import org.apache.myfaces.tobago.layout.grid.Grid;
@@ -214,7 +213,7 @@
     for (int i = 0; i < columnTokens.getSize(); i++) {
       LayoutToken layoutToken = columnTokens.get(i);
       if (layoutToken instanceof PixelLayoutToken) {
-        Measure pixel = new PixelMeasure(((PixelLayoutToken) layoutToken).getPixel());
+        Measure pixel = Measure.valueOf(((PixelLayoutToken) layoutToken).getPixel());
         layoutContext.getHorizontal().setFixedLength(i + horizontalIndexOffset, pixel, this);
       }
     }
@@ -224,7 +223,7 @@
       LayoutToken layoutToken = rowTokens.get(i);
       if (layoutToken instanceof PixelLayoutToken) {
         // XXX PixelLayoutToken might be removed/changed
-        Measure pixel = new PixelMeasure(((PixelLayoutToken) layoutToken).getPixel());
+        Measure pixel = Measure.valueOf(((PixelLayoutToken) layoutToken).getPixel());
         layoutContext.getVertical().setFixedLength(i + verticalIndexOffset, pixel, this);
       }
     }

Modified: myfaces/tobago/trunk/extension/math/src/main/java/org/apache/myfaces/tobago/component/UIEquationGridLayout.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/extension/math/src/main/java/org/apache/myfaces/tobago/component/UIEquationGridLayout.java?rev=896930&r1=896929&r2=896930&view=diff
==============================================================================
--- myfaces/tobago/trunk/extension/math/src/main/java/org/apache/myfaces/tobago/component/UIEquationGridLayout.java (original)
+++ myfaces/tobago/trunk/extension/math/src/main/java/org/apache/myfaces/tobago/component/UIEquationGridLayout.java Thu Jan  7 17:13:58 2010
@@ -68,7 +68,7 @@
           Measure cellspacing = (Measure) object;
           return cellspacing;
         } else if (object instanceof Number) {
-          return new org.apache.myfaces.tobago.layout.PixelMeasure(((Number)object).intValue());
+          return Measure.valueOf(((Number)object).intValue());
         } else if (object instanceof String) {
           return Measure.parse((String)object);
         } else if (object != null) {
@@ -97,7 +97,7 @@
           Measure columnSpacing = (Measure) object;
           return columnSpacing;
         } else if (object instanceof Number) {
-          return new org.apache.myfaces.tobago.layout.PixelMeasure(((Number)object).intValue());
+          return Measure.valueOf(((Number)object).intValue());
         } else if (object instanceof String) {
           return Measure.parse((String)object);
         } else if (object != null) {
@@ -128,7 +128,7 @@
           Measure rowSpacing = (Measure) object;
           return rowSpacing;
         } else if (object instanceof Number) {
-          return new org.apache.myfaces.tobago.layout.PixelMeasure(((Number)object).intValue());
+          return Measure.valueOf(((Number)object).intValue());
         } else if (object instanceof String) {
           return Measure.parse((String)object);
         } else if (object != null) {

Modified: myfaces/tobago/trunk/extension/math/src/main/java/org/apache/myfaces/tobago/layout/math/SystemOfEquations.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/extension/math/src/main/java/org/apache/myfaces/tobago/layout/math/SystemOfEquations.java?rev=896930&r1=896929&r2=896930&view=diff
==============================================================================
--- myfaces/tobago/trunk/extension/math/src/main/java/org/apache/myfaces/tobago/layout/math/SystemOfEquations.java (original)
+++ myfaces/tobago/trunk/extension/math/src/main/java/org/apache/myfaces/tobago/layout/math/SystemOfEquations.java Thu Jan  7 17:13:58 2010
@@ -21,7 +21,6 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.myfaces.tobago.internal.layout.MathUtils;
 import org.apache.myfaces.tobago.layout.Measure;
-import org.apache.myfaces.tobago.layout.PixelMeasure;
 
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -246,7 +245,7 @@
     Measure[] result = new Measure[numberOfVariables];
     for (int i = 0; i < numberOfVariables; i++) {
       assert MathUtils.isInteger(data[i][numberOfVariables]);
-      result[i] = new PixelMeasure((int) Math.round(data[i][numberOfVariables]));
+      result[i] = Measure.valueOf((int) Math.round(data[i][numberOfVariables]));
     }
     return result;
   }

Modified: myfaces/tobago/trunk/extension/math/src/test/java/org/apache/myfaces/tobago/component/GridLayoutManagerUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/extension/math/src/test/java/org/apache/myfaces/tobago/component/GridLayoutManagerUnitTest.java?rev=896930&r1=896929&r2=896930&view=diff
==============================================================================
--- myfaces/tobago/trunk/extension/math/src/test/java/org/apache/myfaces/tobago/component/GridLayoutManagerUnitTest.java (original)
+++ myfaces/tobago/trunk/extension/math/src/test/java/org/apache/myfaces/tobago/component/GridLayoutManagerUnitTest.java Thu Jan  7 17:13:58 2010
@@ -23,7 +23,6 @@
 import org.apache.myfaces.tobago.layout.Measure;
 import org.apache.myfaces.tobago.layout.MockComponent;
 import org.apache.myfaces.tobago.layout.MockContainer;
-import org.apache.myfaces.tobago.layout.PixelMeasure;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -59,8 +58,8 @@
     manager.setParent(container);
     container.setLayoutManager(manager);
 
-    container.setWidth(new PixelMeasure(300));
-    container.setHeight(new PixelMeasure(20));
+    container.setWidth(px(300));
+    container.setHeight(px(20));
     container.setLeftOffset(Measure.ZERO);
     container.setTopOffset(Measure.ZERO);
     container.setRightOffset(Measure.ZERO);
@@ -71,13 +70,13 @@
     Measure[] result = layoutContext.getHorizontal().getResult();
     LOG.info("result: " + Arrays.toString(result));
     Assert.assertArrayEquals(new Measure[]{
-        new PixelMeasure(300), new PixelMeasure(100), new PixelMeasure(200), Measure.ZERO,
-        new PixelMeasure(100), new PixelMeasure(200)}, result);
+        px(300), px(100), px(200), Measure.ZERO,
+        px(100), px(200)}, result);
 
     result = layoutContext.getVertical().getResult();
     LOG.info("result: " + Arrays.toString(result));
     Assert.assertArrayEquals(new Measure[]{
-        new PixelMeasure(20), new PixelMeasure(20), Measure.ZERO, new PixelMeasure(20), new PixelMeasure(20)},
+        px(20), px(20), Measure.ZERO, px(20), px(20)},
         result);
 
     Assert.assertEquals("width of container", 300, container.getWidth().getPixel());
@@ -116,21 +115,21 @@
     manager.setParent(container);
     container.setLayoutManager(manager);
 
-    container.setWidth(new PixelMeasure(300));
-    container.setHeight(new PixelMeasure(20));
+    container.setWidth(px(300));
+    container.setHeight(px(20));
     EquationLayoutContext layoutContext = new EquationLayoutContext(container);
     layoutContext.layout();
 
     Measure[] result = layoutContext.getHorizontal().getResult();
     LOG.info("result: " + Arrays.toString(result));
     Assert.assertArrayEquals(new Measure[]{
-        new PixelMeasure(300), new PixelMeasure(100), new PixelMeasure(100), new PixelMeasure(100), Measure.ZERO,
-        new PixelMeasure(100), new PixelMeasure(200)}, result);
+        px(300), px(100), px(100), px(100), Measure.ZERO,
+        px(100), px(200)}, result);
 
     result = layoutContext.getVertical().getResult();
     LOG.info("result: " + Arrays.toString(result));
     Assert.assertArrayEquals(new Measure[]{
-        new PixelMeasure(20), new PixelMeasure(20), Measure.ZERO, new PixelMeasure(20), new PixelMeasure(20)},
+        px(20), px(20), Measure.ZERO, px(20), px(20)},
         result);
 
     Assert.assertEquals("width of container", 300, container.getWidth().getPixel());
@@ -193,8 +192,8 @@
     subContainer.setRightOffset(Measure.ZERO);
     subContainer.setBottomOffset(Measure.ZERO);
 
-    container.setWidth(new PixelMeasure(800));
-    container.setHeight(new PixelMeasure(800));
+    container.setWidth(px(800));
+    container.setHeight(px(800));
     container.setLeftOffset(Measure.ZERO);
     container.setTopOffset(Measure.ZERO);
     container.setRightOffset(Measure.ZERO);
@@ -205,22 +204,22 @@
     Measure[] result = layoutContext.getHorizontal().getResult();
     LOG.info("result: " + Arrays.toString(result));
     Assert.assertArrayEquals(new Measure[]{
-        new PixelMeasure(800), new PixelMeasure(100), new PixelMeasure(200), new PixelMeasure(500), Measure.ZERO,
-        new PixelMeasure(100), new PixelMeasure(700), new PixelMeasure(100), new PixelMeasure(200),
-        new PixelMeasure(500), new PixelMeasure(350), new PixelMeasure(150), Measure.ZERO, new PixelMeasure(350),
-        new PixelMeasure(150), new PixelMeasure(350), new PixelMeasure(150)
+        px(800), px(100), px(200), px(500), Measure.ZERO,
+        px(100), px(700), px(100), px(200),
+        px(500), px(350), px(150), Measure.ZERO, px(350),
+        px(150), px(350), px(150)
     }, result);
 
 
     result = layoutContext.getVertical().getResult();
     LOG.info("result: " + Arrays.toString(result));
     Assert.assertArrayEquals(new Measure[]{
-        new PixelMeasure(800), new PixelMeasure(200), new PixelMeasure(600), Measure.ZERO,
-        new PixelMeasure(200), new PixelMeasure(200),
-        new PixelMeasure(600), new PixelMeasure(600), new PixelMeasure(600),
-        new PixelMeasure(300), new PixelMeasure(300), Measure.ZERO,
-        new PixelMeasure(300), new PixelMeasure(300),
-        new PixelMeasure(300), new PixelMeasure(300)
+        px(800), px(200), px(600), Measure.ZERO,
+        px(200), px(200),
+        px(600), px(600), px(600),
+        px(300), px(300), Measure.ZERO,
+        px(300), px(300),
+        px(300), px(300)
     }, result);
 
     Assert.assertEquals("width of container", 800, container.getWidth().getPixel());
@@ -274,8 +273,8 @@
     manager3.setParent(span2);
     span2.setLayoutManager(manager3);
 
-    container.setWidth(new PixelMeasure(900));
-    container.setHeight(new PixelMeasure(200));
+    container.setWidth(px(900));
+    container.setHeight(px(200));
     container.setLeftOffset(Measure.ZERO);
     container.setTopOffset(Measure.ZERO);
     container.setRightOffset(Measure.ZERO);
@@ -288,18 +287,18 @@
     Measure[] result = layoutContext.getHorizontal().getResult();
     LOG.info("result: " + Arrays.toString(result));
     Assert.assertArrayEquals(new Measure[]{
-        new PixelMeasure(900), new PixelMeasure(300), new PixelMeasure(300), new PixelMeasure(300), Measure.ZERO,
-        new PixelMeasure(300), new PixelMeasure(600), new PixelMeasure(200), new PixelMeasure(200),
-        new PixelMeasure(200), Measure.ZERO, new PixelMeasure(600), new PixelMeasure(200), new PixelMeasure(200),
-        new PixelMeasure(200), Measure.ZERO, new PixelMeasure(300)
+        px(900), px(300), px(300), px(300), Measure.ZERO,
+        px(300), px(600), px(200), px(200),
+        px(200), Measure.ZERO, px(600), px(200), px(200),
+        px(200), Measure.ZERO, px(300)
     }, result);
 
     result = layoutContext.getVertical().getResult();
     LOG.info("result: " + Arrays.toString(result));
     Assert.assertArrayEquals(new Measure[]{
-        new PixelMeasure(200), new PixelMeasure(100), new PixelMeasure(100), Measure.ZERO,
-        new PixelMeasure(100), new PixelMeasure(100), new PixelMeasure(100), Measure.ZERO,
-        new PixelMeasure(100), new PixelMeasure(100), Measure.ZERO, new PixelMeasure(100)},
+        px(200), px(100), px(100), Measure.ZERO,
+        px(100), px(100), px(100), Measure.ZERO,
+        px(100), px(100), Measure.ZERO, px(100)},
         result);
 
     Assert.assertEquals("width of container", 900, container.getWidth().getPixel());
@@ -342,8 +341,8 @@
     manager.setParent(container);
     container.setLayoutManager(manager);
 
-    container.setWidth(new PixelMeasure(800));
-    container.setHeight(new PixelMeasure(800));
+    container.setWidth(px(800));
+    container.setHeight(px(800));
     container.setLeftOffset(Measure.ZERO);
     container.setTopOffset(Measure.ZERO);
     container.setRightOffset(Measure.ZERO);
@@ -354,15 +353,15 @@
     Measure[] result = layoutContext.getHorizontal().getResult();
     LOG.info("result: " + Arrays.toString(result));
     Assert.assertArrayEquals(new Measure[]{
-        new PixelMeasure(800), new PixelMeasure(400), new PixelMeasure(400), Measure.ZERO,
-        new PixelMeasure(400), new PixelMeasure(400), new PixelMeasure(400)}, result);
+        px(800), px(400), px(400), Measure.ZERO,
+        px(400), px(400), px(400)}, result);
 
 
     result = layoutContext.getVertical().getResult();
     LOG.info("result: " + Arrays.toString(result));
     Assert.assertArrayEquals(new Measure[]{
-        new PixelMeasure(800), new PixelMeasure(400), new PixelMeasure(400), Measure.ZERO,
-        new PixelMeasure(800), new PixelMeasure(400), new PixelMeasure(400)}, result);
+        px(800), px(400), px(400), Measure.ZERO,
+        px(800), px(400), px(400)}, result);
 
     Assert.assertEquals("width of container", 800, container.getWidth().getPixel());
     Assert.assertEquals("height of container", 800, container.getHeight().getPixel());
@@ -370,4 +369,8 @@
     Assert.assertEquals("height of span", 800, span.getHeight().getPixel());
   }
 
+  private Measure px(int pixel) {
+    return Measure.valueOf(pixel);
+  }
+  
 }

Modified: myfaces/tobago/trunk/extension/math/src/test/java/org/apache/myfaces/tobago/layout/math/CombinationEquationUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/extension/math/src/test/java/org/apache/myfaces/tobago/layout/math/CombinationEquationUnitTest.java?rev=896930&r1=896929&r2=896930&view=diff
==============================================================================
--- myfaces/tobago/trunk/extension/math/src/test/java/org/apache/myfaces/tobago/layout/math/CombinationEquationUnitTest.java (original)
+++ myfaces/tobago/trunk/extension/math/src/test/java/org/apache/myfaces/tobago/layout/math/CombinationEquationUnitTest.java Thu Jan  7 17:13:58 2010
@@ -19,7 +19,6 @@
 
 import org.apache.myfaces.tobago.internal.layout.MathUtils;
 import org.apache.myfaces.tobago.layout.Measure;
-import org.apache.myfaces.tobago.layout.PixelMeasure;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -36,11 +35,11 @@
         new CombinationEquation(4, 0, 3, Measure.ZERO, null, "test").toString());
 
     Assert.assertEquals("CombinationEquation:  x_0 = x_4 (test)",
-        new CombinationEquation(4, 0, 1, new PixelMeasure(5), null, "test").toString());
+        new CombinationEquation(4, 0, 1, px(5), null, "test").toString());
     Assert.assertEquals("CombinationEquation:  x_0 + x_1 + 5px = x_4 (test)",
-        new CombinationEquation(4, 0, 2, new PixelMeasure(5), null, "test").toString());
+        new CombinationEquation(4, 0, 2, px(5), null, "test").toString());
     Assert.assertEquals("CombinationEquation:  x_0 + ... + x_2 + 2 * 5px = x_4 (test)",
-        new CombinationEquation(4, 0, 3, new PixelMeasure(5), null, "test").toString());
+        new CombinationEquation(4, 0, 3, px(5), null, "test").toString());
   }
 
   @Test
@@ -55,12 +54,16 @@
     row = new CombinationEquation(4, 0, 3, Measure.ZERO, null, "test").fillRow(length);
     Assert.assertArrayEquals(new double[] {-1, -1, -1, 0, 1, 0, 0, 0}, row, MathUtils.EPSILON);
 
-    row = new CombinationEquation(4, 0, 1, new PixelMeasure(5), null, "test").fillRow(length);
+    row = new CombinationEquation(4, 0, 1, px(5), null, "test").fillRow(length);
     Assert.assertArrayEquals(new double[] {-1, 0, 0, 0, 1, 0, 0, 0}, row, MathUtils.EPSILON);
-    row = new CombinationEquation(4, 0, 2, new PixelMeasure(5), null, "test").fillRow(length);
+    row = new CombinationEquation(4, 0, 2, px(5), null, "test").fillRow(length);
     Assert.assertArrayEquals(new double[] {-1, -1, 0, 0, 1, 0, 0, 5}, row, MathUtils.EPSILON);
-    row = new CombinationEquation(4, 0, 3, new PixelMeasure(5), null, "test").fillRow(length);
+    row = new CombinationEquation(4, 0, 3, px(5), null, "test").fillRow(length);
     Assert.assertArrayEquals(new double[] {-1, -1, -1, 0, 1, 0, 0, 10}, row, MathUtils.EPSILON);
   }
 
+  private Measure px(int pixel) {
+    return Measure.valueOf(pixel);
+  }
+  
 }

Modified: myfaces/tobago/trunk/extension/math/src/test/java/org/apache/myfaces/tobago/layout/math/EquationManagerUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/extension/math/src/test/java/org/apache/myfaces/tobago/layout/math/EquationManagerUnitTest.java?rev=896930&r1=896929&r2=896930&view=diff
==============================================================================
--- myfaces/tobago/trunk/extension/math/src/test/java/org/apache/myfaces/tobago/layout/math/EquationManagerUnitTest.java (original)
+++ myfaces/tobago/trunk/extension/math/src/test/java/org/apache/myfaces/tobago/layout/math/EquationManagerUnitTest.java Thu Jan  7 17:13:58 2010
@@ -21,7 +21,6 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.myfaces.tobago.layout.LayoutTokens;
 import org.apache.myfaces.tobago.layout.Measure;
-import org.apache.myfaces.tobago.layout.PixelMeasure;
 import org.apache.myfaces.tobago.layout.RelativeLayoutToken;
 import org.junit.Assert;
 import org.junit.Test;
@@ -257,52 +256,52 @@
 
     index = equationManager.addComponentRoot();
     Assert.assertEquals(0, index);
-    equationManager.setFixedLength(index, new PixelMeasure(630), "test");        // the first (current) index has a fix size of 600
-    indices = equationManager.partition(index, 4, px0(), px0(), px0(), LayoutTokens.parse("*"), "test"); // this index is divided into 4 parts
+    equationManager.setFixedLength(index, px(630), "test");        // the first (current) index has a fix size of 600
+    indices = equationManager.partition(index, 4, px(0), px(0), px(0), LayoutTokens.parse("*"), "test"); // this index is divided into 4 parts
     Assert.assertArrayEquals(new int[]{1, 2, 3, 4, 5}, indices);
     equationManager.proportionate(indices[2], indices[3], 1, 2, "test");     // the value on index 2 has factor 1,
     //                                                the value on position 3 has factor 2
     {
-      equationManager.setFixedLength(indices[0], new PixelMeasure(100), "test");        // the first one has a fix size of 100
-      index = equationManager.combine(indices[0], 1, px0(), new RelativeLayoutToken(1), "test");
+      equationManager.setFixedLength(indices[0], px(100), "test");        // the first one has a fix size of 100
+      index = equationManager.combine(indices[0], 1, px(0), new RelativeLayoutToken(1), "test");
       Assert.assertEquals(6, index);
     }
     {
-      equationManager.setFixedLength(indices[1], new PixelMeasure(200), "test");        // the second one has a fix size of 200
-      index = equationManager.combine(indices[1], 1, px0(), new RelativeLayoutToken(1), "test");
+      equationManager.setFixedLength(indices[1], px(200), "test");        // the second one has a fix size of 200
+      index = equationManager.combine(indices[1], 1, px(0), new RelativeLayoutToken(1), "test");
       Assert.assertEquals(7, index);
 
-      index = equationManager.combine(indices[1], 1, px0(), new RelativeLayoutToken(1), "test");
+      index = equationManager.combine(indices[1], 1, px(0), new RelativeLayoutToken(1), "test");
       Assert.assertEquals(8, index);
-      int[] i7 = equationManager.partition(8, 2, px0(), px0(), px0(), LayoutTokens.parse("*"), "test");
+      int[] i7 = equationManager.partition(8, 2, px(0), px(0), px(0), LayoutTokens.parse("*"), "test");
       Assert.assertArrayEquals(new int[]{9, 10,11}, i7);
       equationManager.proportionate(i7[0], i7[1], 1, 2, "test");
 
-      index = equationManager.combine(indices[1], 1, px0(), new RelativeLayoutToken(1), "test");
+      index = equationManager.combine(indices[1], 1, px(0), new RelativeLayoutToken(1), "test");
       Assert.assertEquals(12, index);
-      int[] i10 = equationManager.partition(12, 2, px0(), px0(), px0(), LayoutTokens.parse("*"), "test");
+      int[] i10 = equationManager.partition(12, 2, px(0), px(0), px(0), LayoutTokens.parse("*"), "test");
       Assert.assertArrayEquals(new int[]{13, 14, 15}, i10);
       equationManager.proportionate(i10[0], i10[1], 4, 1, "test");
     }
     {
-      index = equationManager.combine(indices[2], 1, px0(), new RelativeLayoutToken(1), "test");
+      index = equationManager.combine(indices[2], 1, px(0), new RelativeLayoutToken(1), "test");
       Assert.assertEquals(16, index);
     }
     {
-      index = equationManager.combine(indices[3], 1, px0(), new RelativeLayoutToken(1), "test");
+      index = equationManager.combine(indices[3], 1, px(0), new RelativeLayoutToken(1), "test");
       Assert.assertEquals(17, index);
-      int[] i14 = equationManager.partition(17, 2, px0(), px0(), px0(), LayoutTokens.parse("*"), "test");
+      int[] i14 = equationManager.partition(17, 2, px(0), px(0), px(0), LayoutTokens.parse("*"), "test");
       Assert.assertArrayEquals(new int[]{18, 19, 20}, i14);
-      equationManager.setFixedLength(i14[0], new PixelMeasure(130), "test");        // the second one has a fix size of 200
+      equationManager.setFixedLength(i14[0], px(130), "test");        // the second one has a fix size of 200
     }
     {
-      int iSpan2 = equationManager.combine(indices[2], 2, px0(), new RelativeLayoutToken(1), "test");
+      int iSpan2 = equationManager.combine(indices[2], 2, px(0), new RelativeLayoutToken(1), "test");
       Assert.assertEquals(21, iSpan2);
     }
     {
-      int iSpan4 = equationManager.combine(indices[0], 4, px0(), new RelativeLayoutToken(1), "test");
+      int iSpan4 = equationManager.combine(indices[0], 4, px(0), new RelativeLayoutToken(1), "test");
       Assert.assertEquals(22, iSpan4);
-      int[] i18 = equationManager.partition(22, 6, px0(), px0(), px0(), LayoutTokens.parse("*"), "test");
+      int[] i18 = equationManager.partition(22, 6, px(0), px(0), px(0), LayoutTokens.parse("*"), "test");
       Assert.assertArrayEquals(new int[]{23, 24, 25, 26, 27, 28, 29}, i18);
       equationManager.proportionate(i18[0], i18[1], 1, 2, "test");
       equationManager.proportionate(i18[0], i18[2], 1, 3, "test");
@@ -311,11 +310,11 @@
       equationManager.proportionate(i18[0], i18[5], 1, 6, "test");
     }
     {
-      int i19_1 = equationManager.combine(23, 6, px0(), new RelativeLayoutToken(1), "test");
+      int i19_1 = equationManager.combine(23, 6, px(0), new RelativeLayoutToken(1), "test");
       Assert.assertEquals(30, i19_1);
-      int i19_2 = equationManager.combine(23, 3, px0(), new RelativeLayoutToken(1), "test");
+      int i19_2 = equationManager.combine(23, 3, px(0), new RelativeLayoutToken(1), "test");
       Assert.assertEquals(31, i19_2);
-      int i22 = equationManager.combine(26, 3, px0(), new RelativeLayoutToken(1), "test");
+      int i22 = equationManager.combine(26, 3, px(0), new RelativeLayoutToken(1), "test");
       Assert.assertEquals(32, i22);
     }
 
@@ -327,44 +326,44 @@
     Measure[] result = equationManager.getResult();
     LOG.info("result: " + Arrays.toString(result));
     Assert.assertArrayEquals(new Measure[]{
-        new PixelMeasure(630),        // x_0
-        new PixelMeasure(100),        // x_1
-        new PixelMeasure(200),        // x_2
-        new PixelMeasure(110),        // x_3
-        new PixelMeasure(220),        // x_4
-        new PixelMeasure(0),          // x_5
-        new PixelMeasure(100),        // x_6
-        new PixelMeasure(200),        // x_7
-        new PixelMeasure(200),        // x_8
-        new PixelMeasure(67),         // x_9
-        new PixelMeasure(133),        // x_10
-        new PixelMeasure(0),          // x_11
-        new PixelMeasure(200),        // x_12
-        new PixelMeasure(160),        // x_13
-        new PixelMeasure(40),         // x_14
-        new PixelMeasure(0),          // x_15
-        new PixelMeasure(110),        // x_16
-        new PixelMeasure(220),        // x_17
-        new PixelMeasure(130),        // x_18
-        new PixelMeasure(90),         // x_19
-        new PixelMeasure(0),          // x_20
-        new PixelMeasure(330),        // x_21
-        new PixelMeasure(630),        // x_22
-        new PixelMeasure(30),         // x_23
-        new PixelMeasure(60),         // x_24
-        new PixelMeasure(90),         // x_25
-        new PixelMeasure(120),        // x_26
-        new PixelMeasure(150),        // x_27
-        new PixelMeasure(180),        // x_28
-        new PixelMeasure(0),          // x_29
-        new PixelMeasure(630),        // x_30
-        new PixelMeasure(180),        // x_31
-        new PixelMeasure(450),        // x_32
+        px(630),        // x_0
+        px(100),        // x_1
+        px(200),        // x_2
+        px(110),        // x_3
+        px(220),        // x_4
+        px(0),          // x_5
+        px(100),        // x_6
+        px(200),        // x_7
+        px(200),        // x_8
+        px(67),         // x_9
+        px(133),        // x_10
+        px(0),          // x_11
+        px(200),        // x_12
+        px(160),        // x_13
+        px(40),         // x_14
+        px(0),          // x_15
+        px(110),        // x_16
+        px(220),        // x_17
+        px(130),        // x_18
+        px(90),         // x_19
+        px(0),          // x_20
+        px(330),        // x_21
+        px(630),        // x_22
+        px(30),         // x_23
+        px(60),         // x_24
+        px(90),         // x_25
+        px(120),        // x_26
+        px(150),        // x_27
+        px(180),        // x_28
+        px(0),          // x_29
+        px(630),        // x_30
+        px(180),        // x_31
+        px(450),        // x_32
     }, result);
   }
 
-  private static Measure px0() {
-    return Measure.ZERO;
+  private static Measure px(int pixel) {
+    return Measure.valueOf(pixel);
   }
-
+  
 }

Modified: myfaces/tobago/trunk/extension/math/src/test/java/org/apache/myfaces/tobago/layout/math/PartitionEquationUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/extension/math/src/test/java/org/apache/myfaces/tobago/layout/math/PartitionEquationUnitTest.java?rev=896930&r1=896929&r2=896930&view=diff
==============================================================================
--- myfaces/tobago/trunk/extension/math/src/test/java/org/apache/myfaces/tobago/layout/math/PartitionEquationUnitTest.java (original)
+++ myfaces/tobago/trunk/extension/math/src/test/java/org/apache/myfaces/tobago/layout/math/PartitionEquationUnitTest.java Thu Jan  7 17:13:58 2010
@@ -19,7 +19,6 @@
 
 import org.apache.myfaces.tobago.internal.layout.MathUtils;
 import org.apache.myfaces.tobago.layout.Measure;
-import org.apache.myfaces.tobago.layout.PixelMeasure;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -64,7 +63,7 @@
   }
   
   private Measure px(int pixel) {
-    return new PixelMeasure(pixel);
+    return Measure.valueOf(pixel);
   }
   
 }
\ No newline at end of file

Modified: myfaces/tobago/trunk/extension/math/src/test/java/org/apache/myfaces/tobago/layout/math/SystemOfEquationsUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/extension/math/src/test/java/org/apache/myfaces/tobago/layout/math/SystemOfEquationsUnitTest.java?rev=896930&r1=896929&r2=896930&view=diff
==============================================================================
--- myfaces/tobago/trunk/extension/math/src/test/java/org/apache/myfaces/tobago/layout/math/SystemOfEquationsUnitTest.java (original)
+++ myfaces/tobago/trunk/extension/math/src/test/java/org/apache/myfaces/tobago/layout/math/SystemOfEquationsUnitTest.java Thu Jan  7 17:13:58 2010
@@ -21,7 +21,6 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.myfaces.tobago.layout.LayoutTokens;
 import org.apache.myfaces.tobago.layout.Measure;
-import org.apache.myfaces.tobago.layout.PixelMeasure;
 import org.apache.myfaces.tobago.layout.RelativeLayoutToken;
 import org.junit.Assert;
 import org.junit.Test;
@@ -367,7 +366,7 @@
    */
 
   private Measure px(int pixel) {
-    return new PixelMeasure(pixel);
+    return Measure.valueOf(pixel);
   }
 
   private LayoutTokens tokens() {

Modified: myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/sandbox/standard/tag/NumberSliderRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/sandbox/standard/tag/NumberSliderRenderer.java?rev=896930&r1=896929&r2=896930&view=diff
==============================================================================
--- myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/sandbox/standard/tag/NumberSliderRenderer.java (original)
+++ myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/sandbox/standard/tag/NumberSliderRenderer.java Thu Jan  7 17:13:58 2010
@@ -22,7 +22,7 @@
 import org.apache.myfaces.tobago.context.ResourceManager;
 import org.apache.myfaces.tobago.context.ResourceManagerFactory;
 import org.apache.myfaces.tobago.context.TobagoFacesContext;
-import org.apache.myfaces.tobago.layout.PixelMeasure;
+import org.apache.myfaces.tobago.layout.Measure;
 import org.apache.myfaces.tobago.renderkit.LayoutComponentRendererBase;
 import org.apache.myfaces.tobago.renderkit.css.Position;
 import org.apache.myfaces.tobago.renderkit.css.Style;
@@ -95,7 +95,7 @@
     writer.writeClassAttribute(styleClasses);
 
     Style widthStyle = new Style();
-    widthStyle.setWidth(new PixelMeasure(sliderWidth / 2));
+    widthStyle.setWidth(Measure.valueOf(sliderWidth / 2));
     writer.writeStyleAttribute(widthStyle);
     writer.startElement(HtmlConstants.SPAN, null);
     writer.writeClassAttribute(styleClasses);
@@ -122,7 +122,7 @@
 
     writer.startElement(HtmlConstants.INPUT, null);
     writer.writeClassAttribute("tobago-in-default");
-    widthStyle.setWidth(new PixelMeasure(inputWidth));
+    widthStyle.setWidth(Measure.valueOf(inputWidth));
     writer.writeStyleAttribute(widthStyle);
     String inputIdAndName = getIdForInputField(facesContext, slider);
     writer.writeNameAttribute(inputIdAndName);
@@ -151,9 +151,9 @@
     writer.writeIdAttribute(getIdForSliderHandle(facesContext, slider));
     Style handleStyle = new Style();
     handleStyle.setPosition(Position.RELATIVE);
-    handleStyle.setTop(new PixelMeasure(-6));
-    handleStyle.setWidth(new PixelMeasure(12));
-    handleStyle.setHeight(new PixelMeasure(6));
+    handleStyle.setTop(Measure.valueOf(-6));
+    handleStyle.setWidth(Measure.valueOf(12));
+    handleStyle.setHeight(Measure.valueOf(6));
     writer.writeStyleAttribute(handleStyle); // todo: why not do that via the class?
     writer.startElement(HtmlConstants.IMG, null);
     writer.writeAttribute(HtmlAttributes.SRC, getAbsoluteImagePath(facesContext, "image/sliderTriangle.gif"), true);

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/BoxRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/BoxRenderer.java?rev=896930&r1=896929&r2=896930&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/BoxRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/BoxRenderer.java Thu Jan  7 17:13:58 2010
@@ -20,7 +20,6 @@
 import org.apache.myfaces.tobago.component.Facets;
 import org.apache.myfaces.tobago.component.UIBox;
 import org.apache.myfaces.tobago.layout.Measure;
-import org.apache.myfaces.tobago.layout.PixelMeasure;
 import org.apache.myfaces.tobago.renderkit.BoxRendererBase;
 import org.apache.myfaces.tobago.renderkit.css.Style;
 import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
@@ -79,7 +78,7 @@
       writer.endElement(HtmlConstants.DIV);
       writer.endElement(HtmlConstants.DIV);
       if (VariableResolverUtil.resolveClientProperties(facesContext).getUserAgent().isMsie()) {
-        innerStyle.setTop(new PixelMeasure(-10));
+        innerStyle.setTop(Measure.valueOf(-10));
       }
     }
     writer.startElement(HtmlConstants.DIV, box);

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MessagesRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MessagesRenderer.java?rev=896930&r1=896929&r2=896930&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MessagesRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MessagesRenderer.java Thu Jan  7 17:13:58 2010
@@ -41,7 +41,6 @@
 import org.apache.myfaces.tobago.context.ResourceManagerUtil;
 import org.apache.myfaces.tobago.context.TobagoFacesContext;
 import org.apache.myfaces.tobago.layout.Measure;
-import org.apache.myfaces.tobago.layout.PixelMeasure;
 import org.apache.myfaces.tobago.renderkit.LayoutComponentRendererBase;
 import org.apache.myfaces.tobago.renderkit.css.Style;
 import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
@@ -130,8 +129,8 @@
 
     popup.setWidth(page.getCurrentWidth().subtract(200));
     popup.setHeight(page.getCurrentHeight().subtract(200));
-    popup.setLeft(new PixelMeasure(100));
-    popup.setTop(new PixelMeasure(100));
+    popup.setLeft(Measure.valueOf(100));
+    popup.setTop(Measure.valueOf(100));
     popup.setRendered(true);
     popup.setActivated(true);
     ((TobagoFacesContext) facesContext).getPopups().add(popup);

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java?rev=896930&r1=896929&r2=896930&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java Thu Jan  7 17:13:58 2010
@@ -42,7 +42,6 @@
 import org.apache.myfaces.tobago.layout.LayoutToken;
 import org.apache.myfaces.tobago.layout.LayoutTokens;
 import org.apache.myfaces.tobago.layout.Measure;
-import org.apache.myfaces.tobago.layout.PixelMeasure;
 import org.apache.myfaces.tobago.layout.RelativeLayoutToken;
 import org.apache.myfaces.tobago.model.SheetState;
 import org.apache.myfaces.tobago.renderkit.LayoutComponentRendererBase;
@@ -188,7 +187,7 @@
     if (style.getHeight() == null) {
       // FIXME: nullpointer if height not defined
       LOG.error("no height in parent container, setting to 100");
-      sheetHeight = new PixelMeasure(100);
+      sheetHeight = Measure.valueOf(100);
     } else {
       sheetHeight = style.getHeight();
     }

Modified: myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/util/RenderUtil.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/util/RenderUtil.java?rev=896930&r1=896929&r2=896930&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/util/RenderUtil.java (original)
+++ myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/util/RenderUtil.java Thu Jan  7 17:13:58 2010
@@ -23,7 +23,6 @@
 import org.apache.myfaces.tobago.config.Configurable;
 import org.apache.myfaces.tobago.context.ResourceManagerUtil;
 import org.apache.myfaces.tobago.layout.Measure;
-import org.apache.myfaces.tobago.layout.PixelMeasure;
 import org.apache.myfaces.tobago.renderkit.RendererBase;
 import org.apache.myfaces.tobago.util.ComponentUtils;
 import org.apache.myfaces.tobago.util.RangeParser;
@@ -220,7 +219,7 @@
       width += charWidth;
     }
 
-    return new PixelMeasure(width);
+    return Measure.valueOf(width);
   }
 
   public static List<SelectItem> getItemsToRender(javax.faces.component.UISelectOne component) {

Modified: myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component1.1.stg
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component1.1.stg?rev=896930&r1=896929&r2=896930&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component1.1.stg (original)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component1.1.stg Thu Jan  7 17:13:58 2010
@@ -42,7 +42,6 @@
 <componentInfo.imports:import(); separator="\n">
 import org.apache.commons.lang.ArrayUtils;
 import org.apache.commons.lang.StringUtils;
-import org.apache.myfaces.tobago.layout.PixelMeasure;
 import org.apache.myfaces.tobago.renderkit.LayoutComponentRenderer;
 import org.apache.myfaces.tobago.renderkit.SpacingValues;
 import java.util.ArrayList;
@@ -467,16 +466,7 @@
   <getValueExpression(property)>
   if (vb != null) {
     Object object = <getValue(property)>
-    if (object instanceof Measure) {
-      Measure <property.propertyName> = (Measure) object;
-      return <property.propertyName>;
-    } else if (object instanceof Number) {
-      return new PixelMeasure(((Number)object).intValue());
-    } else if (object instanceof String) {
-      return Measure.parse((String)object);
-    } else if (object != null) {
-      return Measure.parse(object.toString());
-    }
+    return Measure.valueOf(object);
   }
   <if(property.defaultCode)>
   return <property.defaultCode>;

Modified: myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component1.2.stg
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component1.2.stg?rev=896930&r1=896929&r2=896930&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component1.2.stg (original)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component1.2.stg Thu Jan  7 17:13:58 2010
@@ -44,7 +44,6 @@
 import org.apache.commons.lang.StringUtils;
 import org.apache.myfaces.tobago.component.MethodBindingToMethodExpression;
 import org.apache.myfaces.tobago.component.MethodExpressionToMethodBinding;
-import org.apache.myfaces.tobago.layout.PixelMeasure;
 import org.apache.myfaces.tobago.renderkit.SpacingValues;
 import org.apache.myfaces.tobago.renderkit.LayoutComponentRenderer;
 import javax.el.ELException;
@@ -424,16 +423,7 @@
   if (ve != null) {
     try {
       Object object = <getValue(property)>
-      if (object instanceof Measure) {
-        Measure <property.propertyName> = (Measure) object;
-        return <property.propertyName>;
-      } else if (object instanceof Number) {
-        return new PixelMeasure(((Number)object).intValue());
-      } else if (object instanceof String) {
-        return Measure.parse((String)object);
-      } else if (object != null) {
-        return Measure.parse(object.toString());
-      }
+      return Measure.valueOf(object);
     } catch (ELException e) {
 		  throw new FacesException(e);
 	  }