Class Label


  • public final class Label
    extends java.lang.Object
    The Label 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  
    • Constructor Summary

      Constructors 
      Constructor Description
      Label​(Label other)
      Constructs a copy of the specified label.
    • 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.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • 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 the other argument equals null;
    • 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 is null.
      • 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 is null.
      • 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 the blockId argument is null.
      • 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 is null.
      • 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 is null.
      • 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:
        1. Label name
        2. Block identifier if it is not a root (no parent) block
        3. Reference number if it set
        4. Sequence index if it set
        N.B. Numeric labels do not have unique names. For such labels, a unique name includes only label name.
        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 or false otherwise.
      • isNumeric

        public boolean isNumeric()
        Checks whether the label is numeric.
        Returns:
        true if the label is numeric or false otherwise.
      • isWeak

        public boolean isWeak()
        Checks whether the label is weak.
        Returns:
        true if the label is weak or false otherwise.
      • toString

        public java.lang.String toString()
        Returns textual representation of the label based on its unique name.
        Overrides:
        toString in class java.lang.Object
        Returns:
        Textual representation based on the unique name.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object