javax.print.attribute
Class SetOfIntegerSyntax

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by javax.print.attribute.SetOfIntegerSyntax
All Implemented Interfaces:
Serializable sample code for java.io.Serializable definition code for java.io.Serializable , Cloneable sample code for java.lang.Cloneable definition code for java.lang.Cloneable
Direct Known Subclasses:
CopiesSupported sample code for javax.print.attribute.standard.CopiesSupported definition code for javax.print.attribute.standard.CopiesSupported , JobImpressionsSupported sample code for javax.print.attribute.standard.JobImpressionsSupported definition code for javax.print.attribute.standard.JobImpressionsSupported , JobKOctetsSupported sample code for javax.print.attribute.standard.JobKOctetsSupported definition code for javax.print.attribute.standard.JobKOctetsSupported , JobMediaSheetsSupported sample code for javax.print.attribute.standard.JobMediaSheetsSupported definition code for javax.print.attribute.standard.JobMediaSheetsSupported , NumberUpSupported sample code for javax.print.attribute.standard.NumberUpSupported definition code for javax.print.attribute.standard.NumberUpSupported , PageRanges sample code for javax.print.attribute.standard.PageRanges definition code for javax.print.attribute.standard.PageRanges

public abstract class SetOfIntegerSyntax
extends Object sample code for java.lang.Object definition code for java.lang.Object
implements Serializable sample code for java.io.Serializable definition code for java.io.Serializable , Cloneable sample code for java.lang.Cloneable definition code for java.lang.Cloneable

Class SetOfIntegerSyntax is an abstract base class providing the common implementation of all attributes whose value is a set of nonnegative integers. This includes attributes whose value is a single range of integers and attributes whose value is a set of ranges of integers.

You can construct an instance of SetOfIntegerSyntax by giving it in "string form." The string consists of zero or more comma-separated integer groups. Each integer group consists of either one integer, two integers separated by a hyphen (-), or two integers separated by a colon (:). Each integer consists of one or more decimal digits (0 through 9). Whitespace characters cannot appear within an integer but are otherwise ignored. For example: "", "1", "5-10", "1:2, 4".

You can also construct an instance of SetOfIntegerSyntax by giving it in "array form." Array form consists of an array of zero or more integer groups where each integer group is a length-1 or length-2 array of ints; for example, int[0][], int[][]{{1}}, int[][]{{5,10}}, int[][]{{1,2},{4}}.

In both string form and array form, each successive integer group gives a range of integers to be included in the set. The first integer in each group gives the lower bound of the range; the second integer in each group gives the upper bound of the range; if there is only one integer in the group, the upper bound is the same as the lower bound. If the upper bound is less than the lower bound, it denotes a null range (no values). If the upper bound is equal to the lower bound, it denotes a range consisting of a single value. If the upper bound is greater than the lower bound, it denotes a range consisting of more than one value. The ranges may appear in any order and are allowed to overlap. The union of all the ranges gives the set's contents. Once a SetOfIntegerSyntax instance is constructed, its value is immutable.

The SetOfIntegerSyntax object's value is actually stored in "canonical array form." This is the same as array form, except there are no null ranges; the members of the set are represented in as few ranges as possible (i.e., overlapping ranges are coalesced); the ranges appear in ascending order; and each range is always represented as a length-two array of ints in the form {lower bound, upper bound}. An empty set is represented as a zero-length array.

Class SetOfIntegerSyntax has operations to return the set's members in canonical array form, to test whether a given integer is a member of the set, and to iterate through the members of the set.

See Also:
Serialized Form

Constructor Summary
protected SetOfIntegerSyntax sample code for javax.print.attribute.SetOfIntegerSyntax.SetOfIntegerSyntax(int) definition code for javax.print.attribute.SetOfIntegerSyntax.SetOfIntegerSyntax(int) (int member)
          Construct a new set-of-integer attribute containing a single integer.
protected SetOfIntegerSyntax sample code for javax.print.attribute.SetOfIntegerSyntax.SetOfIntegerSyntax(int[][]) definition code for javax.print.attribute.SetOfIntegerSyntax.SetOfIntegerSyntax(int[][]) (int[][] members)
          Construct a new set-of-integer attribute with the given members in array form.
protected SetOfIntegerSyntax sample code for javax.print.attribute.SetOfIntegerSyntax.SetOfIntegerSyntax(int, int) definition code for javax.print.attribute.SetOfIntegerSyntax.SetOfIntegerSyntax(int, int) (int lowerBound, int upperBound)
          Construct a new set-of-integer attribute containing a single range of integers.
protected SetOfIntegerSyntax sample code for javax.print.attribute.SetOfIntegerSyntax.SetOfIntegerSyntax(java.lang.String) definition code for javax.print.attribute.SetOfIntegerSyntax.SetOfIntegerSyntax(java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  members)
          Construct a new set-of-integer attribute with the given members in string form.
 
Method Summary
 boolean contains sample code for javax.print.attribute.SetOfIntegerSyntax.contains(int) definition code for javax.print.attribute.SetOfIntegerSyntax.contains(int) (int x)
          Determine if this set-of-integer attribute contains the given value.
 boolean contains sample code for javax.print.attribute.SetOfIntegerSyntax.contains(javax.print.attribute.IntegerSyntax) definition code for javax.print.attribute.SetOfIntegerSyntax.contains(javax.print.attribute.IntegerSyntax) (IntegerSyntax sample code for javax.print.attribute.IntegerSyntax definition code for javax.print.attribute.IntegerSyntax  attribute)
          Determine if this set-of-integer attribute contains the given integer attribute's value.
 boolean equals sample code for javax.print.attribute.SetOfIntegerSyntax.equals(java.lang.Object) definition code for javax.print.attribute.SetOfIntegerSyntax.equals(java.lang.Object) (Object sample code for java.lang.Object definition code for java.lang.Object  object)
          Returns whether this set-of-integer attribute is equivalent to the passed in object.
 int[][] getMembers sample code for javax.print.attribute.SetOfIntegerSyntax.getMembers() definition code for javax.print.attribute.SetOfIntegerSyntax.getMembers() ()
          Obtain this set-of-integer attribute's members in canonical array form.
 int hashCode sample code for javax.print.attribute.SetOfIntegerSyntax.hashCode() definition code for javax.print.attribute.SetOfIntegerSyntax.hashCode() ()
          Returns a hash code value for this set-of-integer attribute.
 int next sample code for javax.print.attribute.SetOfIntegerSyntax.next(int) definition code for javax.print.attribute.SetOfIntegerSyntax.next(int) (int x)
          Determine the smallest integer in this set-of-integer attribute that is greater than the given value.
 String sample code for java.lang.String definition code for java.lang.String toString sample code for javax.print.attribute.SetOfIntegerSyntax.toString() definition code for javax.print.attribute.SetOfIntegerSyntax.toString() ()
          Returns a string value corresponding to this set-of-integer attribute.
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Constructor Detail

SetOfIntegerSyntax sample code for javax.print.attribute.SetOfIntegerSyntax(java.lang.String) definition code for javax.print.attribute.SetOfIntegerSyntax(java.lang.String)

protected SetOfIntegerSyntax(String sample code for java.lang.String definition code for java.lang.String  members)
Construct a new set-of-integer attribute with the given members in string form.

Parameters:
members - Set members in string form. If null, an empty set is constructed.
Throws:
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - (Unchecked exception) Thrown if members does not obey the proper syntax.

SetOfIntegerSyntax sample code for javax.print.attribute.SetOfIntegerSyntax(int[][]) definition code for javax.print.attribute.SetOfIntegerSyntax(int[][])

protected SetOfIntegerSyntax(int[][] members)
Construct a new set-of-integer attribute with the given members in array form.

Parameters:
members - Set members in array form. If null, an empty set is constructed.
Throws:
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - (Unchecked exception) Thrown if any element of members is null.
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - (Unchecked exception) Thrown if any element of members is not a length-one or length-two array or if any non-null range in members has a lower bound less than zero.

SetOfIntegerSyntax sample code for javax.print.attribute.SetOfIntegerSyntax(int) definition code for javax.print.attribute.SetOfIntegerSyntax(int)

protected SetOfIntegerSyntax(int member)
Construct a new set-of-integer attribute containing a single integer.

Parameters:
member - Set member.
Throws:
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - (Unchecked exception) Thrown if member is less than zero.

SetOfIntegerSyntax sample code for javax.print.attribute.SetOfIntegerSyntax(int, int) definition code for javax.print.attribute.SetOfIntegerSyntax(int, int)

protected SetOfIntegerSyntax(int lowerBound,
                             int upperBound)
Construct a new set-of-integer attribute containing a single range of integers. If the lower bound is greater than the upper bound (a null range), an empty set is constructed.

Parameters:
lowerBound - Lower bound of the range.
upperBound - Upper bound of the range.
Throws:
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - (Unchecked exception) Thrown if the range is non-null and lowerBound is less than zero.
Method Detail

getMembers sample code for javax.print.attribute.SetOfIntegerSyntax.getMembers() definition code for javax.print.attribute.SetOfIntegerSyntax.getMembers()

public int[][] getMembers()
Obtain this set-of-integer attribute's members in canonical array form. The returned array is "safe;" the client may alter it without affecting this set-of-integer attribute.

Returns:
This set-of-integer attribute's members in canonical array form.

contains sample code for javax.print.attribute.SetOfIntegerSyntax.contains(int) definition code for javax.print.attribute.SetOfIntegerSyntax.contains(int)

public boolean contains(int x)
Determine if this set-of-integer attribute contains the given value.

Parameters:
x - Integer value.
Returns:
True if this set-of-integer attribute contains the value x, false otherwise.

contains sample code for javax.print.attribute.SetOfIntegerSyntax.contains(javax.print.attribute.IntegerSyntax) definition code for javax.print.attribute.SetOfIntegerSyntax.contains(javax.print.attribute.IntegerSyntax)

public boolean contains(IntegerSyntax sample code for javax.print.attribute.IntegerSyntax definition code for javax.print.attribute.IntegerSyntax  attribute)
Determine if this set-of-integer attribute contains the given integer attribute's value.

Parameters:
attribute - Integer attribute.
Returns:
True if this set-of-integer attribute contains theAttribute's value, false otherwise.

next sample code for javax.print.attribute.SetOfIntegerSyntax.next(int) definition code for javax.print.attribute.SetOfIntegerSyntax.next(int)

public int next(int x)
Determine the smallest integer in this set-of-integer attribute that is greater than the given value. If there are no integers in this set-of-integer attribute greater than the given value, -1 is returned. (Since a set-of-integer attribute can only contain nonnegative values, -1 will never appear in the set.) You can use the next() method to iterate through the integer values in a set-of-integer attribute in ascending order, like this:
     SetOfIntegerSyntax attribute = . . .;
     int i = -1;
     while ((i = attribute.next (i)) != -1)
         {
         foo (i);
         }
 

Parameters:
x - Integer value.
Returns:
The smallest integer in this set-of-integer attribute that is greater than x, or -1 if no integer in this set-of-integer attribute is greater than x.

equals sample code for javax.print.attribute.SetOfIntegerSyntax.equals(java.lang.Object) definition code for javax.print.attribute.SetOfIntegerSyntax.equals(java.lang.Object)

public boolean equals(Object sample code for java.lang.Object definition code for java.lang.Object  object)
Returns whether this set-of-integer attribute is equivalent to the passed in object. To be equivalent, all of the following conditions must be true:
  1. object is not null.
  2. object is an instance of class SetOfIntegerSyntax.
  3. This set-of-integer attribute's members and object's members are the same.

Overrides:
equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) in class Object sample code for java.lang.Object definition code for java.lang.Object
Parameters:
object - Object to compare to.
Returns:
True if object is equivalent to this set-of-integer attribute, false otherwise.
See Also:
Object.hashCode() sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , Hashtable sample code for java.util.Hashtable definition code for java.util.Hashtable

hashCode sample code for javax.print.attribute.SetOfIntegerSyntax.hashCode() definition code for javax.print.attribute.SetOfIntegerSyntax.hashCode()

public int hashCode()
Returns a hash code value for this set-of-integer attribute. The hash code is the sum of the lower and upper bounds of the ranges in the canonical array form, or 0 for an empty set.

Overrides:
hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() in class Object sample code for java.lang.Object definition code for java.lang.Object
Returns:
a hash code value for this object.
See Also:
Object.equals(java.lang.Object) sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , Hashtable sample code for java.util.Hashtable definition code for java.util.Hashtable

toString sample code for javax.print.attribute.SetOfIntegerSyntax.toString() definition code for javax.print.attribute.SetOfIntegerSyntax.toString()

public String sample code for java.lang.String definition code for java.lang.String  toString()
Returns a string value corresponding to this set-of-integer attribute. The string value is a zero-length string if this set is empty. Otherwise, the string value is a comma-separated list of the ranges in the canonical array form, where each range is represented as "i" if the lower bound equals the upper bound or "i-j" otherwise.

Overrides:
toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() in class Object sample code for java.lang.Object definition code for java.lang.Object
Returns:
a string representation of the object.