harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ndbe...@apache.org
Subject svn commit: r469365 - /incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/
Date Tue, 31 Oct 2006 04:17:28 GMT
Author: ndbeyer
Date: Mon Oct 30 20:17:27 2006
New Revision: 469365

URL: http://svn.apache.org/viewvc?view=rev&rev=469365
Log:
Cleanup 'javax.print.attribute'
* add missing annotations
* add missing type variables
* uplift APIs to Java 5 spec
* format code

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/Attribute.java
    incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/AttributeSetUtilities.java
    incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/EnumSyntax.java
    incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/IntegerSyntax.java
    incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/Size2DSyntax.java
    incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/URISyntax.java
    incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/UnmodifiableSetException.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/Attribute.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/Attribute.java?view=diff&rev=469365&r1=469364&r2=469365
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/Attribute.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/Attribute.java
Mon Oct 30 20:17:27 2006
@@ -14,20 +14,13 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-/** 
- * @author Elena V. Sayapina 
- * @version $Revision: 1.6 $ 
- */ 
 
 package javax.print.attribute;
 
 import java.io.Serializable;
 
 public interface Attribute extends Serializable {
-
-    Class getCategory();
-    //1.5 support requires the following changes
-    //Class<? extends Attribute> getCategory();
+    Class<? extends Attribute> getCategory();
 
     String getName();
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/AttributeSetUtilities.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/AttributeSetUtilities.java?view=diff&rev=469365&r1=469364&r2=469365
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/AttributeSetUtilities.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/AttributeSetUtilities.java
Mon Oct 30 20:17:27 2006
@@ -323,54 +323,35 @@
     }
 
     
-    public static Class
-        verifyAttributeCategory(Object object, Class interfaceName) {
-
-    //1.5 support requires the following changes 
-    //public static Class<?> verifyAttributeCategory(Object object,
-    //Class<?> interfaceName);   
-
-        if ( !(Attribute.class).isAssignableFrom(interfaceName) ){
-        throw new ClassCastException(interfaceName.getName()+" is not " +
-                            "interface Attribute or it's subinterface");
-        } else if ( interfaceName.isAssignableFrom((Class) object) ) {
-            return (Class) object;
+    public static Class<?> verifyAttributeCategory(Object object, Class<?> interfaceName)
{
+        if (!(Attribute.class).isAssignableFrom(interfaceName)) {
+            throw new ClassCastException(interfaceName.getName() + " is not "
+                    + "interface Attribute or it's subinterface");
+        } else if (interfaceName.isAssignableFrom((Class<?>) object)) {
+            return (Class<?>) object;
         } else {
-            throw new ClassCastException(object.getClass().getName()+
-                    "doesn't implement"+interfaceName.getName());
+            throw new ClassCastException(object.getClass().getName() + "doesn't implement"
+                    + interfaceName.getName());
         }
     }
- 
-    public static Attribute 
-        verifyAttributeValue(Object attribute, Class interfaceName) {
-    
-    //1.5 support requires the following changes 
-    //public static Attribute verifyAttributeValue(Object object,
-    //Class<?> interfaceName);
-        
+
+    public static Attribute verifyAttributeValue(Object attribute, Class<?> interfaceName)
{
         if (attribute == null) {
             throw new NullPointerException("Null attribute");
-        } else if ( interfaceName.isInstance(attribute) ) {
+        } else if (interfaceName.isInstance(attribute)) {
             return (Attribute) attribute;
         } else {
             throw new ClassCastException("Object is not an instance of "
-                            + interfaceName.getName());
+                    + interfaceName.getName());
         }
     }
-    
-    public static void 
-        verifyCategoryForValue(Class attributeCategory, Attribute attribute) {
-    
-    //1.5 support requires the following changes 
-    //public static void verifyCategoryForValue(Class<?> category,
-    //Attribute attribute);
-        
-        if (!attributeCategory.equals (attribute.getCategory())) {
-            throw new IllegalArgumentException(attributeCategory.getName()+
-                            "is not equal to the category of the attribute"+
-                                attribute.getCategory().getName());
-        }
 
+    public static void verifyCategoryForValue(Class<?> attributeCategory, Attribute
attribute) {
+        if (!attributeCategory.equals(attribute.getCategory())) {
+            throw new IllegalArgumentException(attributeCategory.getName()
+                    + "is not equal to the category of the attribute"
+                    + attribute.getCategory().getName());
+        }
     }
 
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/EnumSyntax.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/EnumSyntax.java?view=diff&rev=469365&r1=469364&r2=469365
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/EnumSyntax.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/EnumSyntax.java
Mon Oct 30 20:17:27 2006
@@ -14,10 +14,6 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-/** 
- * @author Elena V. Sayapina 
- * @version $Revision: 1.4 $ 
- */ 
 
 package javax.print.attribute;
 
@@ -26,75 +22,65 @@
 import java.io.Serializable;
 
 public abstract class EnumSyntax implements Cloneable, Serializable {
-
-
-    private int value;
+    private final int value;
 
     protected EnumSyntax(int intValue) {
+        super();
         value = intValue;
     }
 
-    public Object clone() {
-        return this;
-    }
-
-    protected  EnumSyntax[] getEnumValueTable() {
+    protected EnumSyntax[] getEnumValueTable() {
         return null;
     }
 
-    protected  int getOffset() {
+    protected int getOffset() {
         return 0;
     }
 
-    protected  String[] getStringTable() {
+    protected String[] getStringTable() {
         return null;
     }
 
     public int getValue() {
         return value;
-     }
+    }
 
+    @Override
     public int hashCode() {
         return value;
     }
 
-    protected Object readResolve() throws ObjectStreamException {
+    @Override
+    public Object clone() {
+        return this;
+    }
+
+    @Override
+    public String toString() {
+        int i = value - getOffset();
+        String[] stringTable = getStringTable();
+        if ((stringTable == null) || (i < 0) || (i > stringTable.length - 1)) {
+            //No string value corresponding to enumeration value
+            return Integer.toString(value);
+        }
+        return stringTable[i];
+    }
 
+    protected Object readResolve() throws ObjectStreamException {
         int offset = getOffset();
         int i = value - offset;
         EnumSyntax[] enumTable = getEnumValueTable();
-
         if (enumTable == null) {
             throw new InvalidObjectException("Null enumeration value table");
         }
-
-        if ( (i < 0) || (i > enumTable.length-1) ) {
-            throw new InvalidObjectException("Value = " + value +
-                    " is not in valid range (" + offset + ","
-                        +(offset + enumTable.length-1) + ")" );
+        if ((i < 0) || (i > enumTable.length - 1)) {
+            throw new InvalidObjectException("Value = " + value + " is not in valid range
("
+                    + offset + "," + (offset + enumTable.length - 1) + ")");
         }
-
         EnumSyntax outcome = enumTable[i];
-
         if (outcome == null) {
             throw new InvalidObjectException("Null enumeration value");
         }
-
         return outcome;
-
-    }
-
-    public String toString() {
-
-        int i = value - getOffset();
-        String[] stringTable = getStringTable();
-        if ( (stringTable == null) || (i < 0) || (i > stringTable.length-1) ) {
-            //No string value corresponding to enumeration value
-            return Integer.toString(value);
-        } else {
-            return stringTable[i];
-        }
     }
-
-
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/IntegerSyntax.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/IntegerSyntax.java?view=diff&rev=469365&r1=469364&r2=469365
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/IntegerSyntax.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/IntegerSyntax.java
Mon Oct 30 20:17:27 2006
@@ -14,56 +14,47 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-/** 
- * @author Elena V. Sayapina 
- * @version $Revision: 1.4 $ 
- */ 
 
 package javax.print.attribute;
 
 import java.io.Serializable;
 
 public abstract class IntegerSyntax implements Cloneable, Serializable {
-
-
-    private int value;
-
+    private final int value;
 
     protected IntegerSyntax(int intValue) {
+        super();
         value = intValue;
     }
 
     protected IntegerSyntax(int intValue, int lowerBound, int upperBound) {
-
+        super();
         if ((intValue < lowerBound) || (intValue > upperBound)) {
-            throw new IllegalArgumentException("Value " + value +
-                    " not in valid range (" + lowerBound + "," +
-                        upperBound + ")" );
+            throw new IllegalArgumentException("Value " + intValue + " not in valid range
("
+                    + lowerBound + "," + upperBound + ")");
         }
         value = intValue;
     }
 
+    public int getValue() {
+        return value;
+    }
 
+    @Override
     public boolean equals(Object object) {
-
-        if ((object instanceof IntegerSyntax) &&
-                value == ((IntegerSyntax) object).value) {
+        if ((object instanceof IntegerSyntax) && value == ((IntegerSyntax) object).value)
{
             return true;
-        } else {
-            return false;
         }
+        return false;
     }
 
-    public int getValue() {
-        return value;
-    }
-
+    @Override
     public int hashCode() {
         return value;
     }
 
+    @Override
     public String toString() {
         return Integer.toString(value);
     }
-
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/Size2DSyntax.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/Size2DSyntax.java?view=diff&rev=469365&r1=469364&r2=469365
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/Size2DSyntax.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/Size2DSyntax.java
Mon Oct 30 20:17:27 2006
@@ -14,80 +14,61 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-/** 
- * @author Elena V. Sayapina 
- * @version $Revision: 1.4 $ 
- */ 
 
 package javax.print.attribute;
 
 import java.io.Serializable;
 
-
 public abstract class Size2DSyntax implements Cloneable, Serializable {
-
-
     public static final int INCH = 25400;
 
     public static final int MM = 1000;
 
-    private int x;
-
-    private int y;
+    private final int x;
 
+    private final int y;
 
     protected Size2DSyntax(int x, int y, int units) {
-
         if ((x < 0) || (y < 0) || (units < 1)) {
-            throw new IllegalArgumentException("Valid values are:" +
-                                            "x>=0, y>=0, units>=1");
+            throw new IllegalArgumentException("Valid values are:" + "x>=0, y>=0, units>=1");
         }
-        this.x = x*units;
-        this.y = y*units;
-
+        this.x = x * units;
+        this.y = y * units;
     }
 
     protected Size2DSyntax(float x, float y, int units) {
-
-        if ( (x < 0.0f) || (y < 0.0f) || (units < 1) ) {
-            throw new IllegalArgumentException("Valid values are:" +
-                                            "x>=0.0, y>=0.0, units>=1");
+        if ((x < 0.0f) || (y < 0.0f) || (units < 1)) {
+            throw new IllegalArgumentException("Valid values are:" + "x>=0.0, y>=0.0,
units>=1");
         }
-        this.x = Math.round(x*units);
-        this.y = Math.round(y*units);
-
+        this.x = Math.round(x * units);
+        this.y = Math.round(y * units);
     }
 
+    @Override
     public boolean equals(Object object) {
-
-        if ((object instanceof Size2DSyntax) &&
-                (x == ((Size2DSyntax) object).x ) &&
-                    (y == ((Size2DSyntax) object).y)) {
-                            return true;
-        } else {
-            return false;
+        if ((object instanceof Size2DSyntax) && (x == ((Size2DSyntax) object).x)
+                && (y == ((Size2DSyntax) object).y)) {
+            return true;
         }
+        return false;
     }
 
     public float[] getSize(int units) {
-        return new float[] { getX(units),
-                             getY(units) };
+        return new float[] { getX(units), getY(units) };
     }
 
     public float getX(int units) {
-
         if (units < 1) {
             throw new IllegalArgumentException("units is less than 1");
         }
-        return ((float) x)/units;
+        return ((float) x) / units;
     }
 
     public float getY(int units) {
-
         if (units < 1) {
             throw new IllegalArgumentException("units is less than 1");
         }
-        return ((float) y)/units;
+        return ((float) y) / units;
     }
 
     protected int getXMicrometers() {
@@ -98,10 +79,12 @@
         return y;
     }
 
+    @Override
     public int hashCode() {
-        return ( y | (x << 16) );
+        return (y | (x << 16));
     }
 
+    @Override
     public String toString() {
         return (x + "x" + y + " um");
     }
@@ -112,5 +95,4 @@
         }
         return (getX(units) + "x" + getX(units) + " " + unitsName);
     }
-
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/URISyntax.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/URISyntax.java?view=diff&rev=469365&r1=469364&r2=469365
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/URISyntax.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/URISyntax.java
Mon Oct 30 20:17:27 2006
@@ -14,53 +14,42 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-/** 
- * @author Elena V. Sayapina 
- * @version $Revision: 1.4 $ 
- */ 
 
 package javax.print.attribute;
 
 import java.io.Serializable;
 import java.net.URI;
 
-
 public abstract class URISyntax implements Cloneable, Serializable {
+    private final URI uri;
 
-
-    private URI uri;
-
-
-    protected URISyntax (URI uriValue) {
-
+    protected URISyntax(URI uriValue) {
+        super();
         if (uriValue == null) {
             throw new NullPointerException("Null uri value");
-        } else {
-            uri = uriValue;
         }
+        uri = uriValue;
     }
 
-
+    @Override
     public boolean equals(Object object) {
-
-        if ((object instanceof URISyntax) &&
-                uri.equals (((URISyntax) object).uri)) {
+        if ((object instanceof URISyntax) && uri.equals(((URISyntax) object).uri))
{
             return true;
-        } else {
-            return false;
         }
+        return false;
     }
 
-    public URI getURI()  {
+    public URI getURI() {
         return uri;
     }
 
+    @Override
     public int hashCode() {
         return uri.hashCode();
-     }
+    }
 
+    @Override
     public String toString() {
         return uri.toString();
     }
-
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/UnmodifiableSetException.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/UnmodifiableSetException.java?view=diff&rev=469365&r1=469364&r2=469365
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/UnmodifiableSetException.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/UnmodifiableSetException.java
Mon Oct 30 20:17:27 2006
@@ -14,15 +14,11 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-/** 
- * @author Elena V. Sayapina 
- * @version $Revision: 1.4 $ 
- */ 
 
 package javax.print.attribute;
 
-
 public class UnmodifiableSetException extends RuntimeException {
+    private static final long serialVersionUID = 2255250308571511731L;
 
     public UnmodifiableSetException() {
         super();
@@ -30,7 +26,5 @@
 
     public UnmodifiableSetException(String exceptionInformation) {
         super(exceptionInformation);
-
     }
-
 }



Mime
View raw message