geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r1081045 - in /geronimo/specs/trunk/geronimo-ccpp_1.0_spec/src/main/java/javax/ccpp/uaprof: Dimension.java DimensionComparator.java
Date Sun, 13 Mar 2011 07:10:47 GMT
Author: djencks
Date: Sun Mar 13 07:10:47 2011
New Revision: 1081045

URL: http://svn.apache.org/viewvc?rev=1081045&view=rev
Log:
GERONIMO-4982 implement a couple easy bits

Modified:
    geronimo/specs/trunk/geronimo-ccpp_1.0_spec/src/main/java/javax/ccpp/uaprof/Dimension.java
    geronimo/specs/trunk/geronimo-ccpp_1.0_spec/src/main/java/javax/ccpp/uaprof/DimensionComparator.java

Modified: geronimo/specs/trunk/geronimo-ccpp_1.0_spec/src/main/java/javax/ccpp/uaprof/Dimension.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-ccpp_1.0_spec/src/main/java/javax/ccpp/uaprof/Dimension.java?rev=1081045&r1=1081044&r2=1081045&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-ccpp_1.0_spec/src/main/java/javax/ccpp/uaprof/Dimension.java
(original)
+++ geronimo/specs/trunk/geronimo-ccpp_1.0_spec/src/main/java/javax/ccpp/uaprof/Dimension.java
Sun Mar 13 07:10:47 2011
@@ -35,14 +35,26 @@ public class Dimension implements Compar
     }
 
     public Dimension(String str) throws NumberFormatException {
-        height = 0;
-        width = 0;
+        String[] bits = str.split("x");
+        if (bits.length != 2) {
+            throw new NumberFormatException("can not parse as <width>x<height>
string: " + str);
+        }
+        height = Integer.parseInt(bits[1]);
+        width = Integer.parseInt(bits[0]);
     }
 
     public int compareTo(Object o) {
         return DimensionComparator.getInstance().compare(this, o);
     }
 
+    public int getHeight() {
+        return height;
+    }
+
+    public int getWidth() {
+        return width;
+    }
+
     @Override
     public boolean equals(Object o) {
         if (this == o) return true;

Modified: geronimo/specs/trunk/geronimo-ccpp_1.0_spec/src/main/java/javax/ccpp/uaprof/DimensionComparator.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-ccpp_1.0_spec/src/main/java/javax/ccpp/uaprof/DimensionComparator.java?rev=1081045&r1=1081044&r2=1081045&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-ccpp_1.0_spec/src/main/java/javax/ccpp/uaprof/DimensionComparator.java
(original)
+++ geronimo/specs/trunk/geronimo-ccpp_1.0_spec/src/main/java/javax/ccpp/uaprof/DimensionComparator.java
Sun Mar 13 07:10:47 2011
@@ -37,6 +37,11 @@ public class DimensionComparator impleme
     }
 
     public int compare(Object o, Object o1) {
-        return 0;
+        Dimension d1 = (Dimension) o;
+        Dimension d2 = (Dimension) o1;
+        if (d1.getWidth() == d2.getWidth()) {
+            return d1.getHeight() - d2.getHeight();
+        }
+        return d1.getWidth() - d1.getWidth();
     }
 }



Mime
View raw message