Package org.eclipse.jgit.lib
Class PersonIdent
- java.lang.Object
-
- org.eclipse.jgit.lib.PersonIdent
-
- All Implemented Interfaces:
java.io.Serializable
public class PersonIdent extends java.lang.Object implements java.io.SerializableA combination of a person identity and time in Git. Git combines Name + email + time + time zone to specify who wrote or committed something.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringemailAddressprivate java.lang.Stringnameprivate static longserialVersionUIDprivate inttzOffsetprivate longwhen
-
Constructor Summary
Constructors Modifier Constructor Description PersonIdent(java.lang.String aName, java.lang.String aEmailAddress)Construct a newPersonIdentwith current time.privatePersonIdent(java.lang.String aName, java.lang.String aEmailAddress, long when)PersonIdent(java.lang.String aName, java.lang.String aEmailAddress, long aWhen, int aTZ)Construct aPersonIdent.PersonIdent(java.lang.String aName, java.lang.String aEmailAddress, java.util.Date aWhen, java.util.TimeZone aTZ)Construct a PersonIdent from simple dataPersonIdent(java.lang.String aName, java.lang.String aEmailAddress, ProposedTimestamp when)Construct a newPersonIdentwith current time.PersonIdent(PersonIdent pi)Copy aPersonIdent.PersonIdent(PersonIdent pi, long aWhen, int aTZ)Copy a PersonIdent, but alter the clone's time stampPersonIdent(PersonIdent pi, java.util.Date aWhen)Copy aPersonIdent, but alter the clone's time stampPersonIdent(PersonIdent pi, java.util.Date when, java.util.TimeZone tz)Copy a PersonIdent, but alter the clone's time stampPersonIdent(Repository repo)Creates new PersonIdent from config info in repository, with current time.privatePersonIdent(UserConfig config)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidappendSanitized(java.lang.StringBuilder r, java.lang.String str)Sanitize the given string for use in an identity and append to output.static voidappendTimezone(java.lang.StringBuilder r, int offset)Format a timezone offset.booleanequals(java.lang.Object o)java.lang.StringgetEmailAddress()Get email address of personjava.lang.StringgetName()Get name of personjava.util.TimeZonegetTimeZone()Get this person's declared time zonestatic java.util.TimeZonegetTimeZone(int tzOffset)Get timezone object for the given offset.intgetTimeZoneOffset()Get this person's declared time zone as minutes east of UTC.java.util.DategetWhen()Get timestampinthashCode()java.lang.StringtoExternalString()Format for Git storage.java.lang.StringtoString()
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
name
private final java.lang.String name
-
emailAddress
private final java.lang.String emailAddress
-
when
private final long when
-
tzOffset
private final int tzOffset
-
-
Constructor Detail
-
PersonIdent
public PersonIdent(Repository repo)
Creates new PersonIdent from config info in repository, with current time. This new PersonIdent gets the info from the default committer as available from the configuration.- Parameters:
repo- aRepositoryobject.
-
PersonIdent
public PersonIdent(PersonIdent pi)
Copy aPersonIdent.- Parameters:
pi- OriginalPersonIdent
-
PersonIdent
public PersonIdent(java.lang.String aName, java.lang.String aEmailAddress)Construct a newPersonIdentwith current time.- Parameters:
aName- aStringobject.aEmailAddress- aStringobject.
-
PersonIdent
public PersonIdent(java.lang.String aName, java.lang.String aEmailAddress, ProposedTimestamp when)Construct a newPersonIdentwith current time.- Parameters:
aName- aStringobject.aEmailAddress- aStringobject.when- aProposedTimestampobject.- Since:
- 4.6
-
PersonIdent
public PersonIdent(PersonIdent pi, java.util.Date when, java.util.TimeZone tz)
Copy a PersonIdent, but alter the clone's time stamp- Parameters:
pi- originalPersonIdentwhen- local timetz- time zone
-
PersonIdent
public PersonIdent(PersonIdent pi, java.util.Date aWhen)
Copy aPersonIdent, but alter the clone's time stamp- Parameters:
pi- originalPersonIdentaWhen- local time
-
PersonIdent
public PersonIdent(java.lang.String aName, java.lang.String aEmailAddress, java.util.Date aWhen, java.util.TimeZone aTZ)Construct a PersonIdent from simple data- Parameters:
aName- aStringobject.aEmailAddress- aStringobject.aWhen- local time stampaTZ- time zone
-
PersonIdent
public PersonIdent(PersonIdent pi, long aWhen, int aTZ)
Copy a PersonIdent, but alter the clone's time stamp- Parameters:
pi- originalPersonIdentaWhen- local time stampaTZ- time zone
-
PersonIdent
private PersonIdent(java.lang.String aName, java.lang.String aEmailAddress, long when)
-
PersonIdent
private PersonIdent(UserConfig config)
-
PersonIdent
public PersonIdent(java.lang.String aName, java.lang.String aEmailAddress, long aWhen, int aTZ)Construct aPersonIdent.Whitespace in the name and email is preserved for the lifetime of this object, but are trimmed by
toExternalString(). This means that parsing the result oftoExternalString()may not return an equivalent instance.- Parameters:
aName- aStringobject.aEmailAddress- aStringobject.aWhen- local time stampaTZ- time zone
-
-
Method Detail
-
getTimeZone
public static java.util.TimeZone getTimeZone(int tzOffset)
Get timezone object for the given offset.- Parameters:
tzOffset- timezone offset as ingetTimeZoneOffset().- Returns:
- time zone object for the given offset.
- Since:
- 4.1
-
appendTimezone
public static void appendTimezone(java.lang.StringBuilder r, int offset)Format a timezone offset.- Parameters:
r- string builder to append to.offset- timezone offset as ingetTimeZoneOffset().- Since:
- 4.1
-
appendSanitized
public static void appendSanitized(java.lang.StringBuilder r, java.lang.String str)Sanitize the given string for use in an identity and append to output.Trims whitespace from both ends and special characters
\n < >that interfere with parsing; appends all other characters to the output. Analogous to the C git functionstrbuf_addstr_without_crud.- Parameters:
r- string builder to append to.str- input string.- Since:
- 4.4
-
getName
public java.lang.String getName()
Get name of person- Returns:
- Name of person
-
getEmailAddress
public java.lang.String getEmailAddress()
Get email address of person- Returns:
- email address of person
-
getWhen
public java.util.Date getWhen()
Get timestamp- Returns:
- timestamp
-
getTimeZone
public java.util.TimeZone getTimeZone()
Get this person's declared time zone- Returns:
- this person's declared time zone; null if time zone is unknown.
-
getTimeZoneOffset
public int getTimeZoneOffset()
Get this person's declared time zone as minutes east of UTC.- Returns:
- this person's declared time zone as minutes east of UTC. If the timezone is to the west of UTC it is negative.
-
hashCode
public int hashCode()
Hashcode is based only on the email address and timestamp.
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
toExternalString
public java.lang.String toExternalString()
Format for Git storage.- Returns:
- a string in the git author format
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-