Class Identifier


  • public class Identifier
    extends java.lang.Object
    This class implements an abstraction layer to 4 byte character identifiers used for block codes and markers in StructDNA. It provides convenient methods to read a code from file and compare it to some code you expect.

    Note on ID2 Values

    Blender uses a couple of IDs with just two significant positions, such as SC.. etc. Those IDs always have 4 bytes since they are used as block codes. Since codes are stored as byte array (ASCII string), byte order of the file will not influence the order of the bytes in the code. Internally blender converts codes to system byte order to allow comparison to globally defined constants. Because we compare codes based on the bytes given, we don't have to consider byte order here.
    Author:
    homac
    • Constructor Detail

      • Identifier

        public Identifier()
      • Identifier

        public Identifier​(java.lang.String strCode)
        This constructor creates an identifier using the characters in the given string interpreted as ASCII.
        Parameters:
        strCode -
      • Identifier

        public Identifier​(byte[] code)
    • Method Detail

      • read

        public void read​(CDataReadWriteAccess in)
                  throws java.io.IOException
        This method reads the code from the give input stream.
        Parameters:
        in -
        Throws:
        java.io.IOException
      • write

        public void write​(CDataReadWriteAccess io)
                   throws java.io.IOException
        Throws:
        java.io.IOException
      • 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
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • consume

        public void consume​(CDataReadWriteAccess in,
                            Identifier expected)
                     throws java.io.IOException
        This reads a code from the input stream and compares it to the 'expected' value. A mismatch is considered as an I/O error and treated with an IOException.
        Parameters:
        in -
        expected -
        Throws:
        java.io.IOException
      • getDataString

        public java.lang.String getDataString()
      • getData

        public byte[] getData()
        Returns the sequence of bytes which represents the actual code.