harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ndbe...@apache.org
Subject svn commit: r468997 - in /incubator/harmony/enhanced/classlib/trunk/modules/print: META-INF/ src/main/java/common/javax/print/attribute/
Date Sun, 29 Oct 2006 21:12:43 GMT
Author: ndbeyer
Date: Sun Oct 29 13:12:42 2006
New Revision: 468997

URL: http://svn.apache.org/viewvc?view=rev&rev=468997
Log:
Uplift 'javax.print.attribute' classes to match Java 5 spec; minor code cleanup; add missing
entry to manifest

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/print/META-INF/MANIFEST.MF
    incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/AttributeSet.java
    incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/DateTimeSyntax.java
    incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/HashAttributeSet.java
    incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/HashDocAttributeSet.java
    incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/HashPrintJobAttributeSet.java
    incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/HashPrintRequestAttributeSet.java
    incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/HashPrintServiceAttributeSet.java
    incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/ResolutionSyntax.java
    incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/SetOfIntegerSyntax.java
    incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/TextSyntax.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/print/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/print/META-INF/MANIFEST.MF?view=diff&rev=468997&r1=468996&r2=468997
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/print/META-INF/MANIFEST.MF (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/print/META-INF/MANIFEST.MF Sun Oct 29
13:12:42 2006
@@ -15,6 +15,7 @@
  java.beans,
  java.io,
  java.lang,
+ java.lang.annotation,
  java.lang.reflect,
  java.net,
  java.nio,

Modified: incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/AttributeSet.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/AttributeSet.java?view=diff&rev=468997&r1=468996&r2=468997
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/AttributeSet.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/AttributeSet.java
Sun Oct 29 13:12:42 2006
@@ -14,49 +14,33 @@
  *  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;
 
-/*
- * @author esayapin
- */
-
 public interface AttributeSet {
-
     boolean add(Attribute attribute);
-    
+
     boolean addAll(AttributeSet attributeSet);
 
     void clear();
-    
-    boolean containsKey(Class attributeCategory);
-    //1.5 support requires the following changes 
-    //boolean containsKey(Class<?> attributeCategory);
-    
+
+    boolean containsKey(Class<?> attributeCategory);
+
     boolean containsValue(Attribute attribute);
-    
+
     boolean equals(Object object);
-    
-    Attribute get(Class attributeCategory);
-    //1.5 support requires the following changes 
-    //Attribute get(Class<?> attributeCategory);
-    
+
+    Attribute get(Class<?> attributeCategory);
+
     int hashCode();
-    
+
     boolean isEmpty();
-    
+
     boolean remove(Attribute attribute);
-    
-    boolean remove(Class attributeCategory);
-    //1.5 support requires the following changes 
-    //boolean remove(Class<?> attributeCategory);
+
+    boolean remove(Class<?> attributeCategory);
 
     int size();
-    
+
     Attribute[] toArray();
-    
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/DateTimeSyntax.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/DateTimeSyntax.java?view=diff&rev=468997&r1=468996&r2=468997
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/DateTimeSyntax.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/DateTimeSyntax.java
Sun Oct 29 13:12:42 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;
 
@@ -25,38 +21,36 @@
 import java.util.Date;
 
 public abstract class DateTimeSyntax implements Cloneable, Serializable {
-
-
-    private Date date;
+    private static final long serialVersionUID = -1400819079791208582L;
+    private final Date date;
 
     protected DateTimeSyntax(Date value) {
+        super();
         if (value == null) {
-            throw new NullPointerException("Null date value");
+            throw new NullPointerException();
         }
         date = value;
     }
 
+    @Override
     public boolean equals(Object object) {
-
-        if ((object instanceof DateTimeSyntax) &&
-                date.equals(((DateTimeSyntax) object).date) ) {
+        if ((object instanceof DateTimeSyntax) && date.equals(((DateTimeSyntax) object).date))
{
             return true;
-        } else {
-            return false;
         }
+        return false;
     }
 
     public Date getValue() {
-        return new Date ( date.getTime() );
+        return new Date(date.getTime());
     }
 
+    @Override
     public int hashCode() {
         return date.hashCode();
     }
 
+    @Override
     public String toString() {
         return date.toString();
     }
-
-
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/HashAttributeSet.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/HashAttributeSet.java?view=diff&rev=468997&r1=468996&r2=468997
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/HashAttributeSet.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/HashAttributeSet.java
Sun Oct 29 13:12:42 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.6 $ 
- */ 
 
 package javax.print.attribute;
 
@@ -28,46 +24,36 @@
 import java.util.HashMap;
 
 public class HashAttributeSet implements Serializable, AttributeSet {
+    private static final long serialVersionUID = 5311560590283707917L;
 
+    private Class<?> attributeInterfaceName;
 
-    private Class attributeInterfaceName;
-
-    private transient HashMap attributesMap = new HashMap();
-
-    public HashAttributeSet(){
+    private transient HashMap<Class<?>, Attribute> attributesMap = new HashMap<Class<?>,
Attribute>();
 
+    public HashAttributeSet() {
         this(Attribute.class);
     }
-    
-    public HashAttributeSet(Attribute attribute){
 
+    public HashAttributeSet(Attribute attribute) {
         this(attribute, Attribute.class);
     }
-    
-    public HashAttributeSet(Attribute[] attributes) {
 
+    public HashAttributeSet(Attribute[] attributes) {
         this(attributes, Attribute.class);
     }
-  
-    public HashAttributeSet(AttributeSet attributeSet) {
 
+    public HashAttributeSet(AttributeSet attributeSet) {
         this(attributeSet, Attribute.class);
     }
-    
-    protected  HashAttributeSet(Class interfaceName) {
-    //1.5 support requires the following changes
-    //protected HashAttributeSet(Class<?> interfaceName) {
 
+    protected HashAttributeSet(Class<?> interfaceName) {
         if (interfaceName == null) {
             throw new NullPointerException("Null attribute interface");
         }
         attributeInterfaceName = interfaceName;
     }
-    
-    protected  HashAttributeSet(Attribute attribute, Class interfaceName) {
-    //1.5 support requires the following changes
-    //protected HashAttributeSet(Attribute attribute, Class<?> interfaceName) {
 
+    protected HashAttributeSet(Attribute attribute, Class<?> interfaceName) {
         if (interfaceName == null) {
             throw new NullPointerException("Null attribute interface");
         }
@@ -75,53 +61,40 @@
         add(attribute);
     }
 
-    protected  HashAttributeSet(Attribute[] attributes, Class interfaceName) {
-    //1.5 support requires the following changes
-    //protected HashAttributeSet(Attribute[] attributes,
-    //Class<?> interfaceName) {
-
+    protected HashAttributeSet(Attribute[] attributes, Class<?> interfaceName) {
         if (interfaceName == null) {
             throw new NullPointerException("Null attribute interface");
         }
         attributeInterfaceName = interfaceName;
         if (attributes != null) {
-            for (int i = 0; i < attributes.length; i++) {
-            add(attributes[i]);
+            for (Attribute element : attributes) {
+                add(element);
             }
         }
     }
 
-    protected  HashAttributeSet(AttributeSet attributeSet, Class interfaceName) {
-    //1.5 support requires the following changes
-    //protected HashAttributeSet(AttributeSet attributeSet,
-    //Class<?> interfaceName) {
-        
+    protected HashAttributeSet(AttributeSet attributeSet, Class<?> interfaceName) {
         attributeInterfaceName = interfaceName;
         if (attributeSet != null) {
             Attribute[] attributes = attributeSet.toArray();
-            for (int i = 0; i < attributes.length; i++) {
-                add(attributes[i]);
+            for (Attribute element : attributes) {
+                add(element);
             }
         }
     }
 
-
-    private void readObject (ObjectInputStream ois)
-        throws ClassNotFoundException, IOException {
-
+    private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException
{
         ois.defaultReadObject();
         Attribute attribute;
-        attributesMap = new HashMap();
+        attributesMap = new HashMap<Class<?>, Attribute>();
         int n = ois.readInt();
         for (int i = 0; i < n; i++) {
             attribute = (Attribute) ois.readObject();
             add(attribute);
         }
-
     }
 
-    private void writeObject (ObjectOutputStream oos) throws IOException {
-
+    private void writeObject(ObjectOutputStream oos) throws IOException {
         oos.defaultWriteObject();
         Attribute[] attributes = toArray();
         int n = attributes.length;
@@ -131,22 +104,18 @@
         }
     }
 
-
     public boolean add(Attribute attribute) {
-
-        Attribute newValue =
-            AttributeSetUtilities.verifyAttributeValue(attribute,
-                    attributeInterfaceName);
+        Attribute newValue = AttributeSetUtilities.verifyAttributeValue(attribute,
+                attributeInterfaceName);
         Object oldValue = attributesMap.put(attribute.getCategory(), newValue);
-        return  !attribute.equals(oldValue);
+        return !attribute.equals(oldValue);
     }
 
     public boolean addAll(AttributeSet attributeSet) {
-
         boolean outcome = true;
         Attribute[] attributes = attributeSet.toArray();
-        for (int i = 0; i < attributes.length; i++) {
-            if ( !add(attributes[i])) {
+        for (Attribute element : attributes) {
+            if (!add(element)) {
                 outcome = false;
             }
         }
@@ -157,10 +126,7 @@
         attributesMap.clear();
     }
 
-    public boolean containsKey(Class attributeCategory) {
-    //1.5 support requires the following changes
-    //public boolean containsKey(Class<?> attributeCategory) {
-
+    public boolean containsKey(Class<?> attributeCategory) {
         if (attributeCategory == null) {
             return false;
         }
@@ -168,38 +134,35 @@
     }
 
     public boolean containsValue(Attribute attribute) {
-
-        if (attribute == null){
+        if (attribute == null) {
             return false;
         }
         Object curValue = attributesMap.get(attribute.getCategory());
         return attribute.equals(curValue);
     }
 
+    @Override
     public boolean equals(Object object) {
-
-        if ( !(object instanceof AttributeSet) ||
-                ((AttributeSet) object).size() != size() ) {
+        if (!(object instanceof AttributeSet) || ((AttributeSet) object).size() != size())
{
             return false;
         }
         Attribute[] attributes = toArray();
-        for (int i = 0; i < attributes.length; i++) {
-            if ( !((AttributeSet) object).containsValue(attributes[i]) ) {
+        for (Attribute element : attributes) {
+            if (!((AttributeSet) object).containsValue(element)) {
                 return false;
             }
         }
         return true;
     }
 
-    public Attribute get(Class attributeCategory) {
-    //1.5 support requires the following changes
-    //public Attribute get(Class<?> attributeCategory) {
-
-        AttributeSetUtilities.
-            verifyAttributeCategory(attributeCategory, Attribute.class);
-        return (Attribute) attributesMap.get(attributeCategory);
+    public Attribute get(Class<?> attributeCategory) {
+        //1.5 support requires the following changes
+        //public Attribute get(Class<?> attributeCategory) {
+        AttributeSetUtilities.verifyAttributeCategory(attributeCategory, Attribute.class);
+        return attributesMap.get(attributeCategory);
     }
 
+    @Override
     public int hashCode() {
         return attributesMap.hashCode();
     }
@@ -209,25 +172,17 @@
     }
 
     public boolean remove(Attribute attribute) {
-
-        if ( (attribute == null) ||
-                (attributesMap.remove(attribute.getCategory()) == null) ) {
+        if ((attribute == null) || (attributesMap.remove(attribute.getCategory()) == null))
{
             return false;
-        }else {
-            return true;
         }
+        return true;
     }
 
-    public boolean remove(Class attributeCategory) {
-    //1.5 support requires the following changes
-    //public boolean remove(Class<?> attributeCategory) {
-
-        if ((attributeCategory == null) ||
-                (attributesMap.remove(attributeCategory) == null) ) {
-                return false;
-        } else {
-            return true;
+    public boolean remove(Class<?> attributeCategory) {
+        if ((attributeCategory == null) || (attributesMap.remove(attributeCategory) == null))
{
+            return false;
         }
+        return true;
     }
 
     public int size() {
@@ -235,11 +190,8 @@
     }
 
     public Attribute[] toArray() {
-
         Attribute[] attributes = new Attribute[size()];
         attributesMap.values().toArray(attributes);
         return attributes;
     }
-
-
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/HashDocAttributeSet.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/HashDocAttributeSet.java?view=diff&rev=468997&r1=468996&r2=468997
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/HashDocAttributeSet.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/HashDocAttributeSet.java
Sun Oct 29 13:12:42 2006
@@ -14,19 +14,15 @@
  *  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 class HashDocAttributeSet 
-    extends HashAttributeSet implements Serializable, DocAttributeSet {
+public class HashDocAttributeSet extends HashAttributeSet implements Serializable,
+        DocAttributeSet {
+    private static final long serialVersionUID = -1128534486061432528L;
 
-    
     public HashDocAttributeSet() {
         super(DocAttribute.class);
     }
@@ -42,5 +38,4 @@
     public HashDocAttributeSet(DocAttributeSet attributeSet) {
         super(attributeSet, DocAttribute.class);
     }
-
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/HashPrintJobAttributeSet.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/HashPrintJobAttributeSet.java?view=diff&rev=468997&r1=468996&r2=468997
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/HashPrintJobAttributeSet.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/HashPrintJobAttributeSet.java
Sun Oct 29 13:12:42 2006
@@ -14,19 +14,15 @@
  *  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 class HashPrintJobAttributeSet 
-    extends HashAttributeSet implements Serializable, PrintJobAttributeSet {
+public class HashPrintJobAttributeSet extends HashAttributeSet implements Serializable,
+        PrintJobAttributeSet {
+    private static final long serialVersionUID = -4204473656070350348L;
 
-    
     public HashPrintJobAttributeSet() {
         super(PrintJobAttribute.class);
     }
@@ -42,5 +38,4 @@
     public HashPrintJobAttributeSet(PrintJobAttributeSet attributeSet) {
         super(attributeSet, PrintJobAttribute.class);
     }
-
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/HashPrintRequestAttributeSet.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/HashPrintRequestAttributeSet.java?view=diff&rev=468997&r1=468996&r2=468997
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/HashPrintRequestAttributeSet.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/HashPrintRequestAttributeSet.java
Sun Oct 29 13:12:42 2006
@@ -14,19 +14,15 @@
  *  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 class HashPrintRequestAttributeSet 
-    extends HashAttributeSet implements Serializable, PrintRequestAttributeSet {
+public class HashPrintRequestAttributeSet extends HashAttributeSet implements Serializable,
+        PrintRequestAttributeSet {
+    private static final long serialVersionUID = 2364756266107751933L;
 
-    
     public HashPrintRequestAttributeSet() {
         super(PrintRequestAttribute.class);
     }
@@ -42,5 +38,4 @@
     public HashPrintRequestAttributeSet(PrintRequestAttributeSet attributeSet) {
         super(attributeSet, PrintRequestAttribute.class);
     }
-
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/HashPrintServiceAttributeSet.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/HashPrintServiceAttributeSet.java?view=diff&rev=468997&r1=468996&r2=468997
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/HashPrintServiceAttributeSet.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/HashPrintServiceAttributeSet.java
Sun Oct 29 13:12:42 2006
@@ -14,18 +14,14 @@
  *  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 class HashPrintServiceAttributeSet 
-    extends HashAttributeSet implements Serializable, PrintServiceAttributeSet {
-
+public class HashPrintServiceAttributeSet extends HashAttributeSet implements Serializable,
+        PrintServiceAttributeSet {
+    private static final long serialVersionUID = 6642904616179203070L;
 
     public HashPrintServiceAttributeSet() {
         super(PrintServiceAttribute.class);
@@ -42,5 +38,4 @@
     public HashPrintServiceAttributeSet(PrintServiceAttributeSet attributeSet) {
         super(attributeSet, PrintServiceAttribute.class);
     }
-
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/ResolutionSyntax.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/ResolutionSyntax.java?view=diff&rev=468997&r1=468996&r2=468997
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/ResolutionSyntax.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/ResolutionSyntax.java
Sun Oct 29 13:12:42 2006
@@ -14,35 +14,25 @@
  *  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 ResolutionSyntax implements Cloneable, Serializable {
-
+    private static final long serialVersionUID = 2706743076526672017L;
 
     public static final int DPI = 100;
 
     public static final int DPCM = 254;
 
+    private final int crossFeedRes;
 
-    private int crossFeedRes;
-
-    private int feedRes;
-
-    
-    public ResolutionSyntax(int crossFeedResolution,
-                                        int feedResolution, int units) {
+    private final int feedRes;
 
+    public ResolutionSyntax(int crossFeedResolution, int feedResolution, int units) {
         if (crossFeedResolution < 1) {
-            throw new IllegalArgumentException("CrossFeedResolution " +
-                                                    "is less than 1");
+            throw new IllegalArgumentException("CrossFeedResolution " + "is less than 1");
         }
         if (feedResolution < 1) {
             throw new IllegalArgumentException("FeedResolution is less than 1");
@@ -54,38 +44,32 @@
         feedRes = feedResolution * units;
     }
 
-
+    @Override
     public boolean equals(Object object) {
-
-        if ((object instanceof ResolutionSyntax) &&
-                crossFeedRes == ((ResolutionSyntax) object).crossFeedRes &&
-                feedRes == ((ResolutionSyntax) object).feedRes) {
-                            return true;
-        } else {
-            return false;
+        if ((object instanceof ResolutionSyntax)
+                && crossFeedRes == ((ResolutionSyntax) object).crossFeedRes
+                && feedRes == ((ResolutionSyntax) object).feedRes) {
+            return true;
         }
-
+        return false;
     }
 
     public int getCrossFeedResolution(int units) {
-
         if (units < 1) {
             throw new IllegalArgumentException("units is less than 1");
         }
-        return Math.round( ((float) crossFeedRes)/units);
-
+        return Math.round(((float) crossFeedRes) / units);
     }
 
     protected int getCrossFeedResolutionDphi() {
         return crossFeedRes;
     }
 
-    public int getFeedResolution (int units) {
-
+    public int getFeedResolution(int units) {
         if (units < 1) {
             throw new IllegalArgumentException("units is less than 1");
         }
-        return Math.round( ((float) feedRes)/units);
+        return Math.round(((float) feedRes) / units);
     }
 
     protected int getFeedResolutionDphi() {
@@ -93,36 +77,31 @@
     }
 
     public int[] getResolution(int units) {
-        return new int[] { getCrossFeedResolution(units),
-                           getFeedResolution(units) };
+        return new int[] { getCrossFeedResolution(units), getFeedResolution(units) };
     }
 
+    @Override
     public int hashCode() {
-        return ( crossFeedRes | (feedRes << 16) );
+        return (crossFeedRes | (feedRes << 16));
     }
 
-    public boolean lessThanOrEquals (ResolutionSyntax resolutionSyntax) {
-
-        if ( crossFeedRes <= resolutionSyntax.crossFeedRes &&
-                feedRes <= resolutionSyntax.feedRes ) {
-                    return true;
-        } else {
-            return false;
+    public boolean lessThanOrEquals(ResolutionSyntax resolutionSyntax) {
+        if (crossFeedRes <= resolutionSyntax.crossFeedRes
+                && feedRes <= resolutionSyntax.feedRes) {
+            return true;
         }
-
+        return false;
     }
 
+    @Override
     public String toString() {
         return (crossFeedRes + "x" + feedRes + " dphi");
     }
 
-    public String toString (int units, String unitsName) {
+    public String toString(int units, String unitsName) {
         if (unitsName == null) {
             unitsName = "";
         }
-        return (getCrossFeedResolution(units) + "x" + getFeedResolution(units) +
-                    " " + unitsName);
+        return (getCrossFeedResolution(units) + "x" + getFeedResolution(units) + " " + unitsName);
     }
-
-
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/SetOfIntegerSyntax.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/SetOfIntegerSyntax.java?view=diff&rev=468997&r1=468996&r2=468997
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/SetOfIntegerSyntax.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/SetOfIntegerSyntax.java
Sun Oct 29 13:12:42 2006
@@ -14,48 +14,36 @@
  *  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.util.Vector;
 
-
 public abstract class SetOfIntegerSyntax implements Cloneable, Serializable {
-
+    private static final long serialVersionUID = 3666874174847632203L;
 
     private int[][] canonicalArray;
 
-
-    protected  SetOfIntegerSyntax(int value) {
-
+    protected SetOfIntegerSyntax(int value) {
         if (value < 0) {
-            throw new IllegalArgumentException ("Value " + value +
-                    " is less than 0");
+            throw new IllegalArgumentException("Value " + value + " is less than 0");
         }
-        canonicalArray = new int[][] {{value, value} };
-
+        canonicalArray = new int[][] { { value, value } };
     }
 
-    protected  SetOfIntegerSyntax(int lowerBound, int upperBound) {
-
+    protected SetOfIntegerSyntax(int lowerBound, int upperBound) {
         if (lowerBound <= upperBound) {
             if (lowerBound < 0) {
-                throw new IllegalArgumentException ("Lower bound is less than 0");
-            } else {
-                canonicalArray = new int[][] {{lowerBound, upperBound} };
+                throw new IllegalArgumentException("Lower bound is less than 0");
             }
+            canonicalArray = new int[][] { { lowerBound, upperBound } };
         } else {
             canonicalArray = new int[0][];
         }
-
     }
 
-    protected  SetOfIntegerSyntax(int[][] values) {
+    protected SetOfIntegerSyntax(int[][] values) {
         if (values == null) {
             canonicalArray = new int[0][];
         } else {
@@ -63,7 +51,7 @@
         }
     }
 
-    protected  SetOfIntegerSyntax(String values) {
+    protected SetOfIntegerSyntax(String values) {
         if (values == null) {
             canonicalArray = new int[0][];
         } else {
@@ -71,90 +59,81 @@
         }
     }
 
-    /*
+    /**
      * Parses given string containing set of integer and
-     * returns this set in cannonical array form.
+     * returns this set in canonical array form.
      * One after another integer intervals are extracted from the string
      * according comma-separated integer groups and than these intervals
-     * are organized in cannonical array form.
+     * are organized in canonical array form.
      */
     private static int[][] parse(String values) {
-
         int flag;
         long num1long; /*first number in a range*/
         long num2long; /*second number in a range*/
         char symbol;
-
-        /*vector for storing integer intervals in cannonical form*/
-        Vector vector = new Vector();
-
+        /*vector for storing integer intervals in canonical form*/
+        Vector<int[]> vector = new Vector<int[]>();
         /*obtain an array of intervals from the string*/
         String[] str = values.split(",");
         int n = str.length;
-
         /*take next interval*/
         for (int i = 0; i < n; i++) {
             flag = 0;
             num1long = 0;
             num2long = 0;
-
             /*take next literal in interval*/
             for (int j = 0; j < str[i].length(); j++) {
                 symbol = str[i].charAt(j);
-                switch(flag) {
-
+                switch (flag) {
                     /*before the first number*/
                     case 0:
-                        if(Character.isWhitespace(symbol)) {
+                        if (Character.isWhitespace(symbol)) {
                             continue;
-                        } else if(Character.isDigit(symbol) ) {
-                            num1long = Character.digit(symbol,10);
+                        } else if (Character.isDigit(symbol)) {
+                            num1long = Character.digit(symbol, 10);
                             num2long = num1long;
                             flag = 1;
                         } else {
                             throw new IllegalArgumentException();
                         }
                         break;
-
                     /*before the separator*/
                     case 1:
-                        if(Character.isWhitespace(symbol)) {
+                        if (Character.isWhitespace(symbol)) {
                             continue;
-                        } else if(Character.isDigit(symbol)) {
-                            num1long = num1long*10 + Character.digit(symbol,10);
+                        } else if (Character.isDigit(symbol)) {
+                            num1long = num1long * 10 + Character.digit(symbol, 10);
                             if (num1long > Integer.MAX_VALUE) {
-                                throw new IllegalArgumentException(num1long +
-                                            " is out of int range");
+                                throw new IllegalArgumentException(num1long
+                                        + " is out of int range");
                             }
                             num2long = num1long;
-                        } else if( (symbol == ':') || (symbol == '-')) {
+                        } else if ((symbol == ':') || (symbol == '-')) {
                             flag = 2;
                         } else {
                             throw new IllegalArgumentException();
                         }
                         break;
-
                     /*before the second number*/
                     case 2:
-                        if(Character.isWhitespace(symbol)) {
+                        if (Character.isWhitespace(symbol)) {
                             continue;
-                        } else if(Character.isDigit(symbol)) {
-                            num2long = Character.digit(symbol,10);
+                        } else if (Character.isDigit(symbol)) {
+                            num2long = Character.digit(symbol, 10);
                             flag = 3;
                         } else {
                             throw new IllegalArgumentException();
                         }
                         break;
-
                     /*afrer the first digit of second number*/
                     case 3:
-                        if(Character.isWhitespace(symbol)) {
+                        if (Character.isWhitespace(symbol)) {
                             continue;
-                        } else if(Character.isDigit(symbol)) {
-                            num2long = num2long*10 + Character.digit(symbol,10);
+                        } else if (Character.isDigit(symbol)) {
+                            num2long = num2long * 10 + Character.digit(symbol, 10);
                             if (num2long > Integer.MAX_VALUE) {
-                                throw new IllegalArgumentException(num2long +
-                                            " is out of int range");
+                                throw new IllegalArgumentException(num2long
+                                        + " is out of int range");
                             }
                         } else {
                             throw new IllegalArgumentException();
@@ -162,47 +141,43 @@
                         break;
                 }
             }
-
             /*Add the int interval to the vector if the interval in the
-              string form had legal syntax*/
-
+             string form had legal syntax*/
             if (((flag == 1) || (flag == 3)) && (num1long <= num2long)) {
                 addRange(vector, (int) num1long, (int) num2long);
             }
         }
-        return (int[][]) vector.toArray(new int[vector.size()][]);
+        return vector.toArray(new int[vector.size()][]);
     }
 
     /*
      * Work this array out to cannonical array form.
      */
     private static int[][] rearrange(int[][] values) {
-
-        Vector vector = new Vector();
+        Vector<int[]> vector = new Vector<int[]>();
         int num1;
         int num2;
-        for (int i = 0; i < values.length; i++) {
-            if (values[i] == null) {
+        for (int[] element : values) {
+            if (element == null) {
                 throw new NullPointerException("int[][] array has null element");
             }
-            if (values[i].length == 1) {
-                num1 = values[i][0];
-                num2 = values[i][0];
-            } else if (values[i].length == 2) {
-                num1 = values[i][0];
-                num2 = values[i][1];
+            if (element.length == 1) {
+                num1 = element[0];
+                num2 = element[0];
+            } else if (element.length == 2) {
+                num1 = element[0];
+                num2 = element[1];
             } else {
-                throw new IllegalArgumentException("Only array of length-1 " +
-                   "or length-2 arrays of ints are valid");
+                throw new IllegalArgumentException("Only array of length-1 "
+                        + "or length-2 arrays of ints are valid");
             }
             if (num1 < 0) {
-                throw new IllegalArgumentException("Valid values are " +
-                                                            "not less than 0");
+                throw new IllegalArgumentException("Valid values are " + "not less than 0");
             } else if (num1 <= num2) {
                 addRange(vector, num1, num2);
             }
         }
-        return (int[][]) vector.toArray(new int[vector.size()][]);
+        return vector.toArray(new int[vector.size()][]);
     }
 
     /*
@@ -210,54 +185,42 @@
      * intervals in cannoical form and modifies it so that cannonical form
      * is saved.
      */
-    private static void addRange(Vector vector,
-                                    int lowerBound, int upperBound) {
-
+    private static void addRange(Vector<int[]> vector, int lowerBound, int upperBound)
{
         int l1; /*lowerBound of the first interval*/
         int u1; /*upperBound of the first interval*/
-
         int l2; /*lowerBound of the next interval*/
         int u2; /*upperBound of the next interval*/
-
         /*add interval [lowerBound, upperBound] to the vector*/
-        vector.add(new int[] {lowerBound, upperBound});
-
+        vector.add(new int[] { lowerBound, upperBound });
         /*enumerate all intervals in the vector*/
-        for (int i = vector.size()-2; i >= 0; i--) {
-            l1 = ((int[]) vector.elementAt(i))[0];
-            u1 = ((int[]) vector.elementAt(i))[1];
-            l2 = ((int[]) vector.elementAt(i+1))[0];
-            u2 = ((int[]) vector.elementAt(i+1))[1];
-
+        for (int i = vector.size() - 2; i >= 0; i--) {
+            l1 = vector.elementAt(i)[0];
+            u1 = vector.elementAt(i)[1];
+            l2 = vector.elementAt(i + 1)[0];
+            u2 = vector.elementAt(i + 1)[1];
             /*check if two consecutive intervals overlap*/
-            if ( Math.max(l1, l2) - Math.min(u1, u2) <= 1) {
-
+            if (Math.max(l1, l2) - Math.min(u1, u2) <= 1) {
                 /*make new interval from two consecutive intervals
-                  contained all theirs elements*/
-                vector.setElementAt(new int[] { Math.min(l1, l2),
-                                                Math.max(u1, u2) }, i);
-                vector.removeElementAt(i+1);
-
-            /*if two consecutive intervals doesn't overlap but
-              lowerBound of the first interval is bigger than
-              upperBound of the next interval
-              than interchange theirs position*/
+                 contained all theirs elements*/
+                vector.setElementAt(new int[] { Math.min(l1, l2), Math.max(u1, u2) }, i);
+                vector.removeElementAt(i + 1);
+                /*if two consecutive intervals doesn't overlap but
+                 lowerBound of the first interval is bigger than
+                 upperBound of the next interval
+                 than interchange theirs position*/
             } else if (l1 > u2) {
-                vector.setElementAt(new int[] {l2,u2}, i);
-                vector.setElementAt(new int[] {l1,u1}, i+1);
+                vector.setElementAt(new int[] { l2, u2 }, i);
+                vector.setElementAt(new int[] { l1, u1 }, i + 1);
             } else {
                 break;
             }
         }
     }
 
-
     public boolean contains(int value) {
-
-        for (int i = 0; i < canonicalArray.length; i++) {
-            if ( (value >= canonicalArray[i][0]) &&
-                    (value <= canonicalArray[i][1]) ) {
-                        return true;
+        for (int[] element : canonicalArray) {
+            if ((value >= element[0]) && (value <= element[1])) {
+                return true;
             }
         }
         return false;
@@ -267,67 +230,62 @@
         return contains(attribute.getValue());
     }
 
+    @Override
     public boolean equals(Object object) {
-
         if (object instanceof SetOfIntegerSyntax) {
-
-            int[][] compare = ((SetOfIntegerSyntax)object).canonicalArray;
+            int[][] compare = ((SetOfIntegerSyntax) object).canonicalArray;
             int n = compare.length;
             if (n == canonicalArray.length) {
                 for (int i = 0; i < n; i++) {
-                    if ( (canonicalArray[i][0] != compare[i][0]) ||
-                            (canonicalArray[i][1] != compare[i][1]) ) {
-                                return false;
+                    if ((canonicalArray[i][0] != compare[i][0])
+                            || (canonicalArray[i][1] != compare[i][1])) {
+                        return false;
                     }
                 }
                 return true;
-            } else {
-                return false;
             }
-        } else {
             return false;
         }
+        return false;
     }
 
     public int[][] getMembers() {
-
         int n = canonicalArray.length;
         int[][] members = new int[n][];
         for (int i = 0; i < n; i++) {
-            members[i] = new int[] {canonicalArray[i][0], canonicalArray[i][1]};
+            members[i] = new int[] { canonicalArray[i][0], canonicalArray[i][1] };
         }
         return members;
     }
 
+    @Override
     public int hashCode() {
-
         int hashCode = 0;
-        for (int i = 0; i < canonicalArray.length; i++) {
-            hashCode += canonicalArray[i][0] + canonicalArray[i][1];
+        for (int[] element : canonicalArray) {
+            hashCode += element[0] + element[1];
         }
         return hashCode;
     }
 
     public int next(int value) {
-
-        for (int i = 0; i < canonicalArray.length; i++) {
-            if (value < canonicalArray[i][0]) {
-                return canonicalArray[i][0];
-            } else if (value < canonicalArray[i][1]) {
-                return value+1;
+        for (int[] element : canonicalArray) {
+            if (value < element[0]) {
+                return element[0];
+            } else if (value < element[1]) {
+                return value + 1;
             }
         }
         return -1;
     }
 
+    @Override
     public String toString() {
-
         StringBuffer stringSet = new StringBuffer("");
         for (int i = 0; i < canonicalArray.length; i++) {
             if (i > 0) {
                 stringSet.append(",");
             }
-            stringSet.append (canonicalArray[i][0]);
+            stringSet.append(canonicalArray[i][0]);
             if (canonicalArray[i][0] != canonicalArray[i][1]) {
                 stringSet.append("-");
                 stringSet.append(canonicalArray[i][1]);
@@ -335,5 +293,4 @@
         }
         return stringSet.toString();
     }
-
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/TextSyntax.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/TextSyntax.java?view=diff&rev=468997&r1=468996&r2=468997
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/TextSyntax.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/attribute/TextSyntax.java
Sun Oct 29 13:12:42 2006
@@ -14,65 +14,55 @@
  *  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.util.Locale;
 
-
 public abstract class TextSyntax implements Cloneable, Serializable {
+    private static final long serialVersionUID = -8130648736378144102L;
 
-
-    private String text;
+    private final String text;
 
     private Locale locale;
 
-
     protected TextSyntax(String textValue, Locale textLocale) {
-
         if (textValue == null) {
             throw new NullPointerException("Text is null");
-        } else {
-            text = textValue;
         }
-
+        text = textValue;
         if (textLocale == null) {
             locale = Locale.getDefault();
         } else {
             locale = textLocale;
         }
     }
-    
-    
-    public boolean equals(Object object) {
 
-        if ((object instanceof TextSyntax) &&
-                text.equals( ((TextSyntax) object).text ) &&
-                    locale.equals( ((TextSyntax) object).locale )) {
+    @Override
+    public boolean equals(Object object) {
+        if ((object instanceof TextSyntax) && text.equals(((TextSyntax) object).text)
+                && locale.equals(((TextSyntax) object).locale)) {
             return true;
         }
         return false;
     }
-    
+
     public Locale getLocale() {
         return locale;
-    } 
+    }
 
     public String getValue() {
         return text;
     }
 
+    @Override
     public int hashCode() {
         return text.hashCode() + locale.hashCode();
-    }   
-    
-    public String toString(){
+    }
+
+    @Override
+    public String toString() {
         return text;
     }
-           
 }



Mime
View raw message