com.sun.tools.xjc.model
Class Multiplicity

java.lang.Object
  extended by com.sun.tools.xjc.model.Multiplicity

public final class Multiplicity
extends Object

represents a possible number of occurence. Usually, denoted by a pair of integers like (1,1) or (5,10). A special value "unbounded" is allowed as the upper bound.

For example, (0,unbounded) corresponds to the '*' occurence of DTD. (0,1) corresponds to the '?' occurence of DTD.


Field Summary
 Integer max
           
 int min
           
static Multiplicity ONE
          the constant representing the (1,1) multiplicity.
static Multiplicity OPTIONAL
          the constant representing the (0,1) multiplicity.
static Multiplicity PLUS
          the constant representing the (1,unbounded) multiplicity.
static Multiplicity STAR
          the constant representing the (0,unbounded) multiplicity.
static Multiplicity ZERO
          the constant representing the (0,0) multiplicity.
 
Method Summary
static Multiplicity choice(Multiplicity lhs, Multiplicity rhs)
           
static Multiplicity create(int min, Integer max)
           
 boolean equals(Object o)
           
 String getMaxString()
          Returns the string representation of the 'max' property.
static Multiplicity group(Multiplicity lhs, Multiplicity rhs)
           
 int hashCode()
           
 boolean includes(Multiplicity rhs)
          Returns true if the multiplicity represented by this object completely includes the multiplicity represented by the other object.
 boolean isAtMostOnce()
          returns true if the multiplicity is (0,1) or (1,1).
 boolean isOptional()
          returns true if the multiplicity is (0,1)
 boolean isUnique()
          returns true if the multiplicity is (1,1).
 boolean isZero()
          returns true if the multiplicity is (0,0).
 Multiplicity makeOptional()
           
 Multiplicity makeRepeated()
           
static Multiplicity multiply(Multiplicity lhs, Multiplicity rhs)
           
static Multiplicity oneOrMore(Multiplicity c)
           
 String toString()
          gets the string representation.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

min

public final int min

max

public final Integer max

ZERO

public static final Multiplicity ZERO
the constant representing the (0,0) multiplicity.


ONE

public static final Multiplicity ONE
the constant representing the (1,1) multiplicity.


OPTIONAL

public static final Multiplicity OPTIONAL
the constant representing the (0,1) multiplicity.


STAR

public static final Multiplicity STAR
the constant representing the (0,unbounded) multiplicity.


PLUS

public static final Multiplicity PLUS
the constant representing the (1,unbounded) multiplicity.

Method Detail

create

public static Multiplicity create(int min,
                                  Integer max)

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

isUnique

public boolean isUnique()
returns true if the multiplicity is (1,1).


isOptional

public boolean isOptional()
returns true if the multiplicity is (0,1)


isAtMostOnce

public boolean isAtMostOnce()
returns true if the multiplicity is (0,1) or (1,1).


isZero

public boolean isZero()
returns true if the multiplicity is (0,0).


includes

public boolean includes(Multiplicity rhs)
Returns true if the multiplicity represented by this object completely includes the multiplicity represented by the other object. For example, we say [1,3] includes [1,2] but [2,4] doesn't include [1,3].


getMaxString

public String getMaxString()
Returns the string representation of the 'max' property. Either a number or a token "unbounded".


toString

public String toString()
gets the string representation. mainly debug purpose.

Overrides:
toString in class Object

choice

public static Multiplicity choice(Multiplicity lhs,
                                  Multiplicity rhs)

group

public static Multiplicity group(Multiplicity lhs,
                                 Multiplicity rhs)

multiply

public static Multiplicity multiply(Multiplicity lhs,
                                    Multiplicity rhs)

oneOrMore

public static Multiplicity oneOrMore(Multiplicity c)

makeOptional

public Multiplicity makeOptional()

makeRepeated

public Multiplicity makeRepeated()