Class MRZInfo

    • Field Detail

      • DOC_TYPE_UNSPECIFIED

        public static final int DOC_TYPE_UNSPECIFIED
        Unspecified document type (do not use, choose ID1 or ID3).
        See Also:
        Constant Field Values
      • DOC_TYPE_ID1

        public static final int DOC_TYPE_ID1
        ID1 document type for credit card sized identity cards. Specifies a 3-line MRZ, 30 characters wide.
        See Also:
        Constant Field Values
      • DOC_TYPE_ID2

        public static final int DOC_TYPE_ID2
        ID2 document type. Specifies a 2-line MRZ, 36 characters wide.
        See Also:
        Constant Field Values
      • DOC_TYPE_ID3

        public static final int DOC_TYPE_ID3
        ID3 document type for passport booklets. Specifies a 2-line MRZ, 44 characters wide.
        See Also:
        Constant Field Values
    • Constructor Detail

      • MRZInfo

        public MRZInfo​(String documentCode,
                       String issuingState,
                       String primaryIdentifier,
                       String secondaryIdentifier,
                       String documentNumber,
                       String nationality,
                       String dateOfBirth,
                       net.sf.scuba.data.Gender gender,
                       String dateOfExpiry,
                       String personalNumber)
        Creates a new 2-line MRZ compliant with ICAO Doc 9303 part 1 vol 1.
        Parameters:
        documentCode - document code (1 or 2 digit, has to start with "P" or "V")
        issuingState - issuing state as 3 digit string
        primaryIdentifier - card holder last name
        secondaryIdentifier - card holder first name(s)
        documentNumber - document number
        nationality - nationality as 3 digit string
        dateOfBirth - date of birth
        gender - gender
        dateOfExpiry - date of expiry
        personalNumber - either empty, or a personal number of maximum length 14, or other optional data of exact length 15
      • MRZInfo

        public MRZInfo​(String documentCode,
                       String issuingState,
                       String documentNumber,
                       String optionalData1,
                       String dateOfBirth,
                       net.sf.scuba.data.Gender gender,
                       String dateOfExpiry,
                       String nationality,
                       String optionalData2,
                       String primaryIdentifier,
                       String secondaryIdentifier)
        Creates a new 3-line MRZ compliant with ICAO Doc 9303 part 3 vol 1.
        Parameters:
        documentCode - document code (1 or 2 digit, has to start with "I", "C", or "A")
        issuingState - issuing state as 3 digit string
        primaryIdentifier - card holder last name
        secondaryIdentifier - card holder first name(s)
        documentNumber - document number
        nationality - nationality as 3 digit string
        dateOfBirth - date of birth in YYMMDD format
        gender - gender
        dateOfExpiry - date of expiry in YYMMDD format
        optionalData1 - optional data in line 1 of maximum length 15
        optionalData2 - optional data in line 2 of maximum length 11
      • MRZInfo

        public MRZInfo​(InputStream inputStream,
                       int length)
        Creates a new MRZ based on an input stream.
        Parameters:
        inputStream - contains the contents (value) of DG1 (without the tag and length)
        length - the length of the MRZInfo structure
      • MRZInfo

        public MRZInfo​(String str)
        Creates a new MRZ based on the text input. The text input may contain newlines, which will be ignored.
        Parameters:
        str - input text
    • Method Detail

      • writeObject

        public void writeObject​(OutputStream outputStream)
                         throws IOException
        Writes the MRZ to an output stream. This just outputs the MRZ characters, and does not add newlines.
        Specified by:
        writeObject in class AbstractLDSInfo
        Parameters:
        outputStream - the output stream to write to
        Throws:
        IOException - on error writing to the stream
      • getDateOfBirth

        public String getDateOfBirth()
        Returns the date of birth of the passport holder.
        Returns:
        date of birth
      • setDateOfBirth

        public void setDateOfBirth​(String dateOfBirth)
        Sets the date of birth.
        Parameters:
        dateOfBirth - new date of birth
      • getDateOfExpiry

        public String getDateOfExpiry()
        Returns the date of expiry.
        Returns:
        the date of expiry
      • setDateOfExpiry

        public void setDateOfExpiry​(String dateOfExpiry)
        Sets the date of expiry.
        Parameters:
        dateOfExpiry - new date of expiry
      • getDocumentNumber

        public String getDocumentNumber()
        Returns the document number.
        Returns:
        document number
      • setDocumentNumber

        public void setDocumentNumber​(String documentNumber)
        Sets the document number.
        Parameters:
        documentNumber - new document number
      • getDocumentType

        public int getDocumentType()
        Returns the document type.
        Returns:
        document type
      • getDocumentCode

        public String getDocumentCode()
        Returns the document type.
        Returns:
        document type
      • setDocumentCode

        public void setDocumentCode​(String documentCode)
        Sets the document code.
        Parameters:
        documentCode - the new document code
      • getIssuingState

        public String getIssuingState()
        Returns the issuing state as a 3 letter code.
        Returns:
        the issuing state
      • setIssuingState

        public void setIssuingState​(String issuingState)
        Sets the issuing state.
        Parameters:
        issuingState - new issuing state
      • getPrimaryIdentifier

        public String getPrimaryIdentifier()
        Returns the passport holder's last name.
        Returns:
        name
      • setPrimaryIdentifier

        public void setPrimaryIdentifier​(String primaryIdentifier)
        Sets the passport holder's last name.
        Parameters:
        primaryIdentifier - new primary identifier
      • getSecondaryIdentifier

        public String getSecondaryIdentifier()
        Returns the document holder's first names.
        Returns:
        the secondary identifier
      • getSecondaryIdentifierComponents

        public String[] getSecondaryIdentifierComponents()
        Returns the document holder's first names.
        Returns:
        first names
      • setSecondaryIdentifierComponents

        public void setSecondaryIdentifierComponents​(String[] secondaryIdentifiers)
        Sets the passport holder's first names.
        Parameters:
        secondaryIdentifiers - new secondary identifiers
      • setSecondaryIdentifiers

        public void setSecondaryIdentifiers​(String secondaryIdentifiers)
        Sets the passport holder's first names.
        Parameters:
        secondaryIdentifiers - new secondary identifiers
      • getNationality

        public String getNationality()
        Returns the passport holder's nationality as a 3 digit code.
        Returns:
        a country
      • setNationality

        public void setNationality​(String nationality)
        Sets the passport holder's nationality.
        Parameters:
        nationality - new nationality
      • getPersonalNumber

        public String getPersonalNumber()
        Returns the personal number (if a personal number is encoded in optional data 1).
        Returns:
        personal number
      • setPersonalNumber

        public void setPersonalNumber​(String personalNumber)
        Sets the personal number.
        Parameters:
        personalNumber - new personal number
      • getOptionalData1

        public String getOptionalData1()
        Returns the contents of the first optional data field for ID-1 and ID-3 style MRZs.
        Returns:
        optional data 1
      • getOptionalData2

        public String getOptionalData2()
        Returns the contents of the second optional data field for ID-1 style MRZs.
        Returns:
        optional data 2
      • setOptionalData2

        public void setOptionalData2​(String optionalData2)
        Sets the contents for the second optional data field for ID-1 style MRZs.
        Parameters:
        optionalData2 - optional data 2
      • getGender

        public net.sf.scuba.data.Gender getGender()
        Returns the passport holder's gender.
        Returns:
        gender
      • setGender

        public void setGender​(net.sf.scuba.data.Gender gender)
        Sets the gender.
        Parameters:
        gender - new gender
      • toString

        public String toString()
        Creates a textual representation of this MRZ. This is the 2 or 3 line representation (depending on the document type) as it appears in the document. All lines end in a newline char.
        Overrides:
        toString in class Object
        Returns:
        the MRZ as text
        See Also:
        Object.toString()
      • hashCode

        public int hashCode()
        Returns the hash code for this MRZ info.
        Overrides:
        hashCode in class Object
        Returns:
        the hash code
      • equals

        public boolean equals​(Object obj)
        Whether this MRZ info is identical to some other object.
        Overrides:
        equals in class Object
        Parameters:
        obj - the other object
        Returns:
        a boolean
      • checkDigit

        public static char checkDigit​(String str)
        Computes the 7-3-1 check digit for part of the MRZ.
        Parameters:
        str - a part of the MRZ.
        Returns:
        the resulting check digit (in '0' - '9')
      • equalsModuloFillerChars

        public static boolean equalsModuloFillerChars​(String str1,
                                                      String str2)
        Tests equality of two MRZ string while ignoring extra filler characters.
        Parameters:
        str1 - an MRZ string
        str2 - another MRZ string
        Returns:
        a boolean indicating whether the strings are equal modulo filler characters