Java API ReferenceClass Hierarchy | All Classes | All Fields and Methods

com.ibm.xtools.patterns.framework

Class PatternMultiplicity

+-- Object
      +-- PatternMultiplicity

public Class PatternMultiplicity
extends Object

Used to indicate multiplicity.

This is the framework implementation of the multiplicity class that specializes the pattern service version.

Nested Class Summary:


Fields
final static public java.lang.StringMANY

The default constructor provided automatically by the compiler.

final static public java.lang.StringONE

The default constructor provided automatically by the compiler.

final static public java.lang.StringONE_TO_MANY

The default constructor provided automatically by the compiler.

final static public java.lang.StringZERO_TO_MANY

The default constructor provided automatically by the compiler.

final static public java.lang.StringZERO_TO_ONE

The default constructor provided automatically by the compiler.

Constructor summary
PatternMultiplicity(int upperBound)

Constructs a new pattern multiplicity element given only an upper bound.

PatternMultiplicity(int lowerBound, int upperBound)

Constructs a new pattern multiplicity element given a lower and upper bound.

PatternMultiplicity(String identifier)

Constructs a new pattern multiplicity element given a string that will be parsed to set the pattern multiplicity internal state.

Method summary
booleanequals(Object object)

Compares for equality through the default implementation of java.lang.Object.equals(Object).

intgetLowerBound()

Returns the lower bound specified by this multiplicity object.

intgetUpperBound()

Returns the upper bound specified by this multiplicity object.

inthashCode()

Retrieves the parameter hash code value.

booleanisOptional()

Indicates whether this multiplicity allows optionality, in other words, if the lower bound is zero or not.

booleanisSatisfied(int valueCount)

Determines if the multiplicity is satisfied with the input number of values that are associated with this multiplicity.

booleanisSatisfied(int valueCount, PatternMultiplicity.BoundQualifier qualifier)

Determines if the multiplicity is satisfied with the input number of values that are associated with this multiplicity.

booleanisUnlimited()

Indicates whether this multiplicity is unlimited.

StringtoString()

Retrieves the string to the value.

Constructor detail

PatternMultiplicity

public PatternMultiplicity(int upperBound)

Constructs a new pattern multiplicity element given only an upper bound.

The lower bound is assumed to be one if unspecified. For example, a value of -1 indicates one to many instances allowed, same as "1..*".

Parameters:

upperBound
- The upper bound on the multiplicity.

PatternMultiplicity

public PatternMultiplicity(int lowerBound, int upperBound)

Constructs a new pattern multiplicity element given a lower and upper bound.

For example, a value of 0, -1 indicates zero to many instances allowed, same as "0..*".

Parameters:

lowerBound
- The lower bound on the multiplicity.
upperBound
- The upper bound on the multiplicity.

PatternMultiplicity

public PatternMultiplicity(String identifier)

Constructs a new pattern multiplicity element given a string that will be parsed to set the pattern multiplicity internal state.

The following are examples of properly formatted multiplicity identifiers:
  • "1" indicates only one instance allowed
  • "0..*" indicates zero to many instances allowed, also indicating optionality
  • "1..6" indicates one to six instances allowed
  • "*" indicates many instances allowed

Parameters:

identifier
- The textual representation of the multiplicity.

Method detail

equals

public boolean equals(Object object)

Compares for equality through the default implementation of java.lang.Object.equals(Object).

Parameters:

object
- The object to be compared.

Returns:

A boolean value of true if the object is equal. Otherwise, it returns a value of false.

getLowerBound

public int getLowerBound()

Returns the lower bound specified by this multiplicity object.

Returns:

The lower bound of the multiplicity.

getUpperBound

public int getUpperBound()

Returns the upper bound specified by this multiplicity object.

Returns:

The upper bound of the multiplicity.

hashCode

public int hashCode()

Retrieves the parameter hash code value.

Returns:

An integer representing the value.

isOptional

public boolean isOptional()

Indicates whether this multiplicity allows optionality, in other words, if the lower bound is zero or not.

Returns:

Indicates optionality or not.

isSatisfied

public boolean isSatisfied(int valueCount)

Determines if the multiplicity is satisfied with the input number of values that are associated with this multiplicity.

Parameters:

valueCount
- The number of values checked for multiplicity validity.

Returns:

A boolean value of true if the multiplicity would be satisfied with the specified number of values. Otherwise, it returns a value of false.

isSatisfied

public boolean isSatisfied(int valueCount, PatternMultiplicity.BoundQualifier qualifier)

Determines if the multiplicity is satisfied with the input number of values that are associated with this multiplicity.

A bound qualifier must be specified, a type-safe enumeration defined within an inner-class of this class:
  • if UPPER_BOUND_ONLY is specified, only the upper boundary will be checked for conformance
  • if LOWER_BOUND_ONLY is specified, only the lower boundary will be checked for conformance
.

Parameters:

valueCount
- The number of values.
qualifier
- A type-safe enumeration indicating lower or upper boundary only.

Returns:

A boolean value of true if the multiplicity is satisfied with the specified number of values. Otherwise, it returns a value of false.

isUnlimited

public boolean isUnlimited()

Indicates whether this multiplicity is unlimited.

Unlimited multiplicity means that the upper bound is unbounded or internally set to -1 (the same as many).

Returns:

Indicates unlimited upper bound or not.

toString

public String toString()

Retrieves the string to the value.

Returns:

A string to the value.


Feedback