Class Label
- java.lang.Object
-
- ru.ispras.microtesk.test.template.Label
-
public final class Label extends java.lang.Object
TheLabel
class describes a label set in test templates and symbolic test programs.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Label.Kind
-
Field Summary
Fields Modifier and Type Field Description static int
NO_REFERENCE_NUMBER
static int
NO_SEQUENCE_INDEX
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.util.List<Label>
copyAll(java.util.List<Label> labels)
Creates a deep copy of the specified label list.boolean
equals(java.lang.Object obj)
BlockId
getBlockId()
Returns the identifier of the block where the label was defined.java.lang.String
getName()
Returns the name of the label as it was defined in a test template.int
getReferenceNumber()
Returns a number that uniquely identifies the label among labels that have the same name.int
getSequenceIndex()
Returns an index that identifies the instruction sequence where the label is defined.java.lang.String
getUniqueName()
Returns a unique name for the label based on: Label name Block identifier if it is not a root (no parent) block Reference number if it set Sequence index if it set N.B.int
hashCode()
boolean
isGlobal()
Checks whether the label is global.boolean
isNumeric()
Checks whether the label is numeric.boolean
isWeak()
Checks whether the label is weak.static Label
newGlobal(java.lang.String name, BlockId blockId)
Creates a new global label.static Label
newLabel(java.lang.String name, BlockId blockId)
Creates a new normal label.static Label
newNumeric(int index, BlockId blockId)
Creates a new numeric label.static Label
newWeak(java.lang.String name, BlockId blockId)
Creates a new weak label.void
setReferenceNumber(int value)
Assigns a number that uniquely identifies the label which is duplicated within an instruction sequence.void
setSequenceIndex(int value)
Assigns an index that identifies the instruction sequence where the label is defined.java.lang.String
toString()
Returns textual representation of the label based on its unique name.
-
-
-
Field Detail
-
NO_REFERENCE_NUMBER
public static final int NO_REFERENCE_NUMBER
- See Also:
- Constant Field Values
-
NO_SEQUENCE_INDEX
public static final int NO_SEQUENCE_INDEX
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Label
public Label(Label other)
Constructs a copy of the specified label.- Parameters:
other
- Label to be copied.- Throws:
java.lang.IllegalStateException
- if theother
argument equalsnull
;
-
-
Method Detail
-
newLabel
public static Label newLabel(java.lang.String name, BlockId blockId)
Creates a new normal label. The label is considered non-global and non-numeric.- Parameters:
name
- The name of the label.blockId
- The identifier of the block where the label is defined.- Returns:
- New
Label
object. - Throws:
java.lang.IllegalStateException
- if any of the arguments isnull
.
-
newGlobal
public static Label newGlobal(java.lang.String name, BlockId blockId)
Creates a new global label.- Parameters:
name
- The name of the label.blockId
- The identifier of the block where the label is defined.- Returns:
- New
Label
object. - Throws:
java.lang.IllegalStateException
- if any of the arguments isnull
.
-
newNumeric
public static Label newNumeric(int index, BlockId blockId)
Creates a new numeric label.- Parameters:
index
- The index of the label.blockId
- The identifier of the block where the label is defined.- Returns:
- New
Label
object. - Throws:
java.lang.IllegalStateException
- if theblockId
argument isnull
.
-
newWeak
public static Label newWeak(java.lang.String name, BlockId blockId)
Creates a new weak label.- Parameters:
name
- The name of the label.blockId
- The identifier of the block where the label is defined.- Returns:
- New
Label
object. - Throws:
java.lang.IllegalStateException
- if any of the arguments isnull
.
-
copyAll
public static java.util.List<Label> copyAll(java.util.List<Label> labels)
Creates a deep copy of the specified label list.- Parameters:
labels
- List of labels to be copied.- Returns:
- Copy of the list.
- Throws:
java.lang.IllegalArgumentException
- if the parameter isnull
.
-
setReferenceNumber
public void setReferenceNumber(int value)
Assigns a number that uniquely identifies the label which is duplicated within an instruction sequence. This is required to resolve name conflicts that occur when a subsequence containing labels (e.g. a preparator) is inserted multiple times into the same sequence.- Parameters:
value
- Number that uniquely identifies a label which is duplicated within a sequence.
-
getReferenceNumber
public int getReferenceNumber()
Returns a number that uniquely identifies the label among labels that have the same name.- Returns:
- Number that uniquely identifies the label among labels that have the same name.
-
setSequenceIndex
public void setSequenceIndex(int value)
Assigns an index that identifies the instruction sequence where the label is defined. This is required to resolve name conflicts that occur when different sequences produced by the same block use the same labels.- Parameters:
value
- Index that identifies the instruction sequence where the label is defined.
-
getSequenceIndex
public int getSequenceIndex()
Returns an index that identifies the instruction sequence where the label is defined.- Returns:
- Index that identifies the instruction sequence where the label is defined.
-
getName
public java.lang.String getName()
Returns the name of the label as it was defined in a test template.- Returns:
- The name of the label.
-
getUniqueName
public java.lang.String getUniqueName()
Returns a unique name for the label based on:- Label name
- Block identifier if it is not a root (no parent) block
- Reference number if it set
- Sequence index if it set
- Returns:
- Unique name based on the label name and the context in which it is defined.
-
getBlockId
public BlockId getBlockId()
Returns the identifier of the block where the label was defined.- Returns:
- Block identifier.
-
isGlobal
public boolean isGlobal()
Checks whether the label is global.- Returns:
true
if the label is global orfalse
otherwise.
-
isNumeric
public boolean isNumeric()
Checks whether the label is numeric.- Returns:
true
if the label is numeric orfalse
otherwise.
-
isWeak
public boolean isWeak()
Checks whether the label is weak.- Returns:
true
if the label is weak orfalse
otherwise.
-
toString
public java.lang.String toString()
Returns textual representation of the label based on its unique name.- Overrides:
toString
in classjava.lang.Object
- Returns:
- Textual representation based on the unique name.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
-