< prev index next >

src/java.desktop/share/classes/javax/print/attribute/IntegerSyntax.java

Print this page




  52     private int value;
  53 
  54     /**
  55      * Construct a new integer attribute with the given integer value.
  56      *
  57      * @param  value  Integer value.
  58      */
  59     protected IntegerSyntax(int value) {
  60         this.value = value;
  61     }
  62 
  63     /**
  64      * Construct a new integer attribute with the given integer value, which
  65      * must lie within the given range.
  66      *
  67      * @param  value       Integer value.
  68      * @param  lowerBound  Lower bound.
  69      * @param  upperBound  Upper bound.
  70      *
  71      * @exception  IllegalArgumentException
  72      *     (Unchecked exception) Thrown if <CODE>value</CODE> is less than
  73      *     <CODE>lowerBound</CODE> or greater than
  74      *     <CODE>upperBound</CODE>.
  75      */
  76     protected IntegerSyntax(int value, int lowerBound, int upperBound) {
  77         if (lowerBound > value || value > upperBound) {
  78             throw new IllegalArgumentException("Value " + value +
  79                                                " not in range " + lowerBound +
  80                                                ".." + upperBound);
  81         }
  82         this.value = value;
  83     }
  84 
  85     /**
  86      * Returns this integer attribute's integer value.
  87      * @return the integer value
  88      */
  89     public int getValue() {
  90         return value;
  91     }
  92 
  93     /**
  94      * Returns whether this integer attribute is equivalent to the passed in
  95      * object. To be equivalent, all of the following conditions must be true:
  96      * <OL TYPE=1>
  97      * <LI>
  98      * <CODE>object</CODE> is not null.
  99      * <LI>
 100      * <CODE>object</CODE> is an instance of class IntegerSyntax.
 101      * <LI>
 102      * This integer attribute's value and <CODE>object</CODE>'s value are
 103      * equal.
 104      * </OL>
 105      *
 106      * @param  object  Object to compare to.
 107      *
 108      * @return  True if <CODE>object</CODE> is equivalent to this integer
 109      *          attribute, false otherwise.
 110      */
 111     public boolean equals(Object object) {
 112 
 113         return (object != null && object instanceof IntegerSyntax &&
 114                 value == ((IntegerSyntax) object).value);
 115     }
 116 
 117     /**
 118      * Returns a hash code value for this integer attribute. The hash code is
 119      * just this integer attribute's integer value.
 120      */
 121     public int hashCode() {
 122         return value;
 123     }
 124 
 125     /**
 126      * Returns a string value corresponding to this integer attribute. The
 127      * string value is just this integer attribute's integer value converted to
 128      * a string.


  52     private int value;
  53 
  54     /**
  55      * Construct a new integer attribute with the given integer value.
  56      *
  57      * @param  value  Integer value.
  58      */
  59     protected IntegerSyntax(int value) {
  60         this.value = value;
  61     }
  62 
  63     /**
  64      * Construct a new integer attribute with the given integer value, which
  65      * must lie within the given range.
  66      *
  67      * @param  value       Integer value.
  68      * @param  lowerBound  Lower bound.
  69      * @param  upperBound  Upper bound.
  70      *
  71      * @exception  IllegalArgumentException
  72      *     (Unchecked exception) Thrown if {@code value} is less than
  73      *     {@code lowerBound} or greater than
  74      *     {@code upperBound}.
  75      */
  76     protected IntegerSyntax(int value, int lowerBound, int upperBound) {
  77         if (lowerBound > value || value > upperBound) {
  78             throw new IllegalArgumentException("Value " + value +
  79                                                " not in range " + lowerBound +
  80                                                ".." + upperBound);
  81         }
  82         this.value = value;
  83     }
  84 
  85     /**
  86      * Returns this integer attribute's integer value.
  87      * @return the integer value
  88      */
  89     public int getValue() {
  90         return value;
  91     }
  92 
  93     /**
  94      * Returns whether this integer attribute is equivalent to the passed in
  95      * object. To be equivalent, all of the following conditions must be true:
  96      * <OL TYPE=1>
  97      * <LI>
  98      * {@code object} is not null.
  99      * <LI>
 100      * {@code object} is an instance of class IntegerSyntax.
 101      * <LI>
 102      * This integer attribute's value and {@code object}'s value are
 103      * equal.
 104      * </OL>
 105      *
 106      * @param  object  Object to compare to.
 107      *
 108      * @return  True if {@code object} is equivalent to this integer
 109      *          attribute, false otherwise.
 110      */
 111     public boolean equals(Object object) {
 112 
 113         return (object != null && object instanceof IntegerSyntax &&
 114                 value == ((IntegerSyntax) object).value);
 115     }
 116 
 117     /**
 118      * Returns a hash code value for this integer attribute. The hash code is
 119      * just this integer attribute's integer value.
 120      */
 121     public int hashCode() {
 122         return value;
 123     }
 124 
 125     /**
 126      * Returns a string value corresponding to this integer attribute. The
 127      * string value is just this integer attribute's integer value converted to
 128      * a string.
< prev index next >