com.flexive.shared.structure
Class FxMultiplicity

java.lang.Object
  extended by com.flexive.shared.structure.FxMultiplicity
All Implemented Interfaces:
java.io.Serializable

public class FxMultiplicity
extends java.lang.Object
implements java.io.Serializable

Multiplicity of groups and properties

Author:
Markus Plesser (markus.plesser@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)
See Also:
Serialized Form

Field Summary
static FxMultiplicity MULT_0_1
           
static FxMultiplicity MULT_0_N
           
static FxMultiplicity MULT_1_1
           
static FxMultiplicity MULT_1_N
           
static int N
          Unlimited occurances
static int RANDOM_MAX
          No more than 20 elements to be created in random creations
 
Constructor Summary
FxMultiplicity(FxMultiplicity m)
          Copy Constructor
FxMultiplicity(int min, int max)
          Constructor
 
Method Summary
 boolean equals(java.lang.Object obj)
          
static FxMultiplicity fromString(java.lang.String s)
          Get an FxMultiplicity from a String representation
static java.lang.String getIntToString(int m)
          Converts a int into a String holding its number or SYMBOL_UNLIMITED
 int getMax()
          Get the maximum multiplicity
 int getMin()
          Get the minimum multiplicity
 int getRandomRange(java.util.Random rnd, int maxMultiplicity)
          Get the number of elements to create for this multiplicity if creating random test data
static int getStringToInt(java.lang.String m)
          Converts a String that represents a Number or "N" to int
 int hashCode()
          
 boolean isMultiple()
          More than one possible?
 boolean isOptional()
          Is an occurance optional?
 boolean isRequired()
          Is at least one occurance required?
 boolean isUnlimited()
          May occur unlimited?
 boolean isValid(int index)
          Check if the given index is valid for this multiplicity
 java.lang.String toString()
          String representation, uses SYMBOL_UNLIMITED for unlimited max occurances
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

N

public static final int N
Unlimited occurances

See Also:
Constant Field Values

RANDOM_MAX

public static final int RANDOM_MAX
No more than 20 elements to be created in random creations

See Also:
Constant Field Values

MULT_0_1

public static final FxMultiplicity MULT_0_1

MULT_1_1

public static final FxMultiplicity MULT_1_1

MULT_0_N

public static final FxMultiplicity MULT_0_N

MULT_1_N

public static final FxMultiplicity MULT_1_N
Constructor Detail

FxMultiplicity

public FxMultiplicity(int min,
                      int max)
Constructor

Parameters:
min - minimum multiplicity
max - maximum multiplicity, Integer.MAX_VALUE if unlimited

FxMultiplicity

public FxMultiplicity(FxMultiplicity m)
Copy Constructor

Parameters:
m - an FxMultiplicity object
Method Detail

isOptional

public boolean isOptional()
Is an occurance optional?

Returns:
if an occurance is optional

isRequired

public boolean isRequired()
Is at least one occurance required?

Returns:
if at least one occurance is required

isUnlimited

public boolean isUnlimited()
May occur unlimited?

Returns:
unlimited?

isMultiple

public boolean isMultiple()
More than one possible?

Returns:
if more than one are possible

getMin

public int getMin()
Get the minimum multiplicity

Returns:
minimum multiplicity

getMax

public int getMax()
Get the maximum multiplicity

Returns:
maximum multiplicity

toString

public java.lang.String toString()
String representation, uses SYMBOL_UNLIMITED for unlimited max occurances

Overrides:
toString in class java.lang.Object
Returns:
String representation, uses SYMBOL_UNLIMITED for unlimited max occurances

fromString

public static FxMultiplicity fromString(java.lang.String s)
Get an FxMultiplicity from a String representation

Parameters:
s - string representation
Returns:
FxMultiplicity

equals

public boolean equals(java.lang.Object obj)

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object

getRandomRange

public int getRandomRange(java.util.Random rnd,
                          int maxMultiplicity)
Get the number of elements to create for this multiplicity if creating random test data

Parameters:
rnd - Random
maxMultiplicity - the maximum (random) multiplicity
Returns:
number of elements to create for this multiplicity if creating random test data

isValid

public boolean isValid(int index)
Check if the given index is valid for this multiplicity

Parameters:
index - the index to check
Returns:
valid

getStringToInt

public static int getStringToInt(java.lang.String m)
Converts a String that represents a Number or "N" to int

Parameters:
m - representing a Number or "N"
Returns:
the number as int or Integer.MAX_VALUE

getIntToString

public static java.lang.String getIntToString(int m)
Converts a int into a String holding its number or SYMBOL_UNLIMITED

Parameters:
m - representing a Number
Returns:
the number as String