JMRTD 0.4.5

org.jmrtd.lds
Class MRZInfo

java.lang.Object
  extended by org.jmrtd.lds.MRZInfo
All Implemented Interfaces:
Serializable

public class MRZInfo
extends Object
implements Serializable

Data structure for storing the MRZ information as found in DG1. Based on ICAO Doc 9303 part 1 and 3.

Version:
$Revision: 1208 $
Author:
Martijn Oostdijk (martijn.oostdijk@gmail.com)
See Also:
Serialized Form

Field Summary
static int DOC_TYPE_ID1
          ID1 document type for credit card sized national identity cards.
static int DOC_TYPE_ID2
          ID2 document type.
static int DOC_TYPE_ID3
          ID3 document type for passport booklets.
static int DOC_TYPE_UNSPECIFIED
          Unspecified document type (do not use, choose ID1 or ID3).
 
Constructor Summary
MRZInfo(InputStream in)
          Creates a new MRZ based on an input stream.
MRZInfo(int documentType, Country issuingState, String primaryIdentifier, String[] secondaryIdentifiers, String documentNumber, Country nationality, Date dateOfBirth, Gender gender, Date dateOfExpiry, String personalNumber)
          Creates a new MRZ.
 
Method Summary
static char checkDigit(String str)
          Computes the 7-3-1 check digit for part of the MRZ.
 boolean equals(Object obj)
          Whether this MRZ info is identical to the other one.
 Date getDateOfBirth()
          Gets the date of birth of the passport holder.
 Date getDateOfExpiry()
          Gets the date of expiry
 String getDocumentNumber()
          Gets the document number.
 int getDocumentType()
          Gets the document type.
 byte[] getEncoded()
          Gets this MRZ info as byte array.
 Gender getGender()
          Gets the passport holder's gender.
 Country getIssuingState()
          Gets the issuing state
 Country getNationality()
          Gets the passport holder's nationality.
 String getPersonalNumber()
          Gets the personal number.
 String getPrimaryIdentifier()
          Gets the passport holder's last name.
 String[] getSecondaryIdentifiers()
          Gets the passport holder's first names.
 int hashCode()
          Gets a hash code for this MRZ info.
 void setDateOfBirth(Date dateOfBirth)
          Sets the date of birth.
 void setDateOfExpiry(Date dateOfExpiry)
          Sets the date of expiry.
 void setDocumentNumber(String documentNumber)
          Sets the document number.
 void setGender(Gender gender)
          Sets the gender.
 void setIssuingState(Country issuingState)
          Sets the issuing state.
 void setNationality(Country nationality)
          Sets the passport holder's nationality.
 void setPersonalNumber(String personalNumber)
          Sets the personal number.
 void setPrimaryIdentifier(String primaryIdentifier)
          Sets the passport holder's last name.
 void setSecondaryIdentifiers(String secondaryIdentifiers)
          Sets the passport holder's first names.
 void setSecondaryIdentifiers(String[] secondaryIdentifiers)
          Sets the passport holder's first names.
 String toString()
          Creates a textual representation of this MRZ.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

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 national identity cards.

See Also:
Constant Field Values

DOC_TYPE_ID2

public static final int DOC_TYPE_ID2
ID2 document type.

See Also:
Constant Field Values

DOC_TYPE_ID3

public static final int DOC_TYPE_ID3
ID3 document type for passport booklets.

See Also:
Constant Field Values
Constructor Detail

MRZInfo

public MRZInfo(int documentType,
               Country issuingState,
               String primaryIdentifier,
               String[] secondaryIdentifiers,
               String documentNumber,
               Country nationality,
               Date dateOfBirth,
               Gender gender,
               Date dateOfExpiry,
               String personalNumber)
Creates a new MRZ.

Parameters:
documentType - document type
issuingState - issuing state
primaryIdentifier - card holder name
secondaryIdentifiers - card holder name
documentNumber - document number
nationality - nationality
dateOfBirth - date of birth
gender - gender
dateOfExpiry - date of expiry
personalNumber - personal number

MRZInfo

public MRZInfo(InputStream in)
Creates a new MRZ based on an input stream.

Parameters:
in - contains the contents of DG1 (without the tag and length)
Method Detail

getEncoded

public byte[] getEncoded()
Gets this MRZ info as byte array.

Returns:
an encoded version of this MRZ info

getDateOfBirth

public Date getDateOfBirth()
Gets the date of birth of the passport holder.

Returns:
date of birth (with 1900 as base year)

setDateOfBirth

public void setDateOfBirth(Date dateOfBirth)
Sets the date of birth.

Parameters:
dateOfBirth - new date of birth

getDateOfExpiry

public Date getDateOfExpiry()
Gets the date of expiry

Returns:
date of expiry (with 2000 as base year)

setDateOfExpiry

public void setDateOfExpiry(Date dateOfExpiry)
Sets the date of expiry.

Parameters:
dateOfExpiry - new date of expiry

getDocumentNumber

public String getDocumentNumber()
Gets 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()
Gets the document type.

Returns:
document type

getIssuingState

public Country getIssuingState()
Gets the issuing state

Returns:
issuing state

setIssuingState

public void setIssuingState(Country issuingState)
Sets the issuing state.

Parameters:
issuingState - new issuing state

getPrimaryIdentifier

public String getPrimaryIdentifier()
Gets 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

getSecondaryIdentifiers

public String[] getSecondaryIdentifiers()
Gets the passport holder's first names.

Returns:
first names

setSecondaryIdentifiers

public void setSecondaryIdentifiers(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 Country getNationality()
Gets the passport holder's nationality.

Returns:
a country

setNationality

public void setNationality(Country nationality)
Sets the passport holder's nationality.

Parameters:
nationality - new nationality

getPersonalNumber

public String getPersonalNumber()
Gets the personal number.

Returns:
personal number

setPersonalNumber

public void setPersonalNumber(String personalNumber)
Sets the personal number.

Parameters:
personalNumber - new personal number

getGender

public Gender getGender()
Gets the passport holder's gender.

Returns:
gender

setGender

public void setGender(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()
Gets a hash code for this MRZ info.

Overrides:
hashCode in class Object
Returns:
a hash code

equals

public boolean equals(Object obj)
Whether this MRZ info is identical to the other one.

Overrides:
equals in class 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.

JMRTD 0.4.5