Top Description Fields Constructors Methods
org.eclipse.jgit.lib

public Class PersonIdent

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Static Imports
java.time.ZoneOffset.UTC

A combination of a person identity and time in Git. Git combines Name + email + time + time zone to specify who wrote or committed something.

Field Summary

Modifier and TypeField and Description
private final String
private final String
private static final DateTimeFormatter
private static final long
private final ZoneId
private final Instant

Constructor Summary

AccessConstructor and Description
public
PersonIdent(Repository repo)

Creates new PersonIdent from config info in repository, with current time.

public
public
PersonIdent(String aName, String aEmailAddress)

Construct a new org.eclipse.jgit.lib.PersonIdent with current time.

public
public
PersonIdent(PersonIdent pi, Date
local time
when
,
TimeZone
time zone
tz
)
Deprecated since 7.1. Use PersonIdent(PersonIdent, Instant, ZoneId) instead.

Copy a PersonIdent, but alter the clone's time stamp

public
PersonIdent(PersonIdent pi, Instant
local time
when
,
ZoneId
time zone offset
tz
)

Copy a PersonIdent, but alter the clone's time stamp

public
PersonIdent(PersonIdent pi, Date
local time
aWhen
)
Deprecated since 7.1. Use the variant with an Instant instead

Copy a org.eclipse.jgit.lib.PersonIdent, but alter the clone's time stamp

public
PersonIdent(PersonIdent pi, Instant
local time as Instant
aWhen
)

Copy a org.eclipse.jgit.lib.PersonIdent, but alter the clone's time stamp

public
PersonIdent(final String aName, final String aEmailAddress, final Date
local time stamp
aWhen
,
final TimeZone
time zone
aTZ
)
Deprecated since 7.1. Use the variant with Instant and ZoneId instead

Construct a PersonIdent from simple data

public
PersonIdent(final String aName, String aEmailAddress, Instant
local time stamp
aWhen
,
ZoneId
time zone id
zoneId
)

Construct a PersonIdent from simple data

public
PersonIdent(PersonIdent pi, long
local time stamp
aWhen
,
int
time zone
aTZ
)
Deprecated since 7.1. Use the variant with Instant and ZoneId instead

Copy a PersonIdent, but alter the clone's time stamp

private
PersonIdent(final String aName, final String aEmailAddress, Instant when)

private
public
PersonIdent(final String aName, final String aEmailAddress, final long
local time stamp
aWhen
,
final int
time zone
aTZ
)
Deprecated since 7.1. Use the variant with Instant and ZoneId instead

Construct a org.eclipse.jgit.lib.PersonIdent.

Method Summary

Modifier and TypeMethod and Description
public static void
appendSanitized(StringBuilder
string builder to append to.
r
,
String
input string.
str
)

Sanitize the given string for use in an identity and append to output.

public static void
appendTimezone(StringBuilder
string builder to append to.
r
,
int
timezone offset as in getTimeZoneOffset().
offset
)

Format a timezone offset.

public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public String

Returns:

email address of person
getEmailAddress
()

Get email address of person

public String

Returns:

Name of person
getName
()

Get name of person

public static TimeZone

Returns:

time zone object for the given offset.
getTimeZone
(int
timezone offset as in getTimeZoneOffset().
tzOffset
)
Deprecated since 7.2. use getZoneId(int) instead

Get timezone object for the given offset.

public TimeZone

Returns:

this person's declared time zone; null if time zone is unknown.
getTimeZone
()
Deprecated since 7.1. Use getZoneId instead

Get this person's declared time zone

public int

Returns:

this person's declared time zone as minutes east of UTC. If the timezone is to the west of UTC it is negative.
getTimeZoneOffset
()
Deprecated since 7.1. Use getZoneOffset() and read minutes from there

Get this person's declared time zone as minutes east of UTC.

public Date

Returns:

timestamp
getWhen
()
Deprecated since 7.1. Use getWhenAsInstant instead

Get timestamp

public Instant

Returns:

timestamp
getWhenAsInstant
()

Get when attribute as instant

public static ZoneId

Returns:

a ZoneId for this offset (UTC if invalid)
getZoneId
(int
as minutes east of UTC
tzOffset
)

Translate a minutes offset into a ZoneId

public ZoneId

Returns:

the time zone id
getZoneId
()

Get the time zone id

public ZoneOffset

Returns:

the offset
getZoneOffset
()

Return the offset in this timezone at the specific time

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public String

Returns:

a string in the git author format
toExternalString
()

Format for Git storage.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

emailAddressback to summary
private final String emailAddress
nameback to summary
private final String name
OFFSET_FORMATTERback to summary
private static final DateTimeFormatter OFFSET_FORMATTER
serialVersionUIDback to summary
private static final long serialVersionUID
tzOffsetback to summary
private final ZoneId tzOffset
whenback to summary
private final Instant when

Constructor Detail

PersonIdentback to summary
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:Repository

a org.eclipse.jgit.lib.Repository object.

PersonIdentback to summary
public PersonIdent(PersonIdent pi)

Copy a org.eclipse.jgit.lib.PersonIdent.

Parameters
pi:PersonIdent

Original org.eclipse.jgit.lib.PersonIdent

PersonIdentback to summary
public PersonIdent(String aName, String aEmailAddress)

Construct a new org.eclipse.jgit.lib.PersonIdent with current time.

Parameters
aName:String

a java.lang.String object.

aEmailAddress:String

a java.lang.String object.

PersonIdentback to summary
public PersonIdent(String aName, String aEmailAddress, ProposedTimestamp when)

Construct a new org.eclipse.jgit.lib.PersonIdent with current time.

Parameters
aName:String

a java.lang.String object.

aEmailAddress:String

a java.lang.String object.

when:ProposedTimestamp

a org.eclipse.jgit.util.time.ProposedTimestamp object.

Since
4.6
PersonIdentback to summary
public PersonIdent(PersonIdent pi, Date when, TimeZone tz)

Deprecated

since 7.1.

Use PersonIdent(PersonIdent, Instant, ZoneId) instead.

Copy a PersonIdent, but alter the clone's time stamp

Parameters
pi:PersonIdent

original org.eclipse.jgit.lib.PersonIdent

when:Date

local time

tz:TimeZone

time zone

Annotations
@Deprecated
since:7.1
PersonIdentback to summary
public PersonIdent(PersonIdent pi, Instant when, ZoneId tz)

Copy a PersonIdent, but alter the clone's time stamp

Parameters
pi:PersonIdent

original org.eclipse.jgit.lib.PersonIdent

when:Instant

local time

tz:ZoneId

time zone offset

Since
7.1
PersonIdentback to summary
public PersonIdent(PersonIdent pi, Date aWhen)

Deprecated

since 7.1.

Use the variant with an Instant instead

Copy a org.eclipse.jgit.lib.PersonIdent, but alter the clone's time stamp

Parameters
pi:PersonIdent

original org.eclipse.jgit.lib.PersonIdent

aWhen:Date

local time

Annotations
@Deprecated
since:7.1
PersonIdentback to summary
public PersonIdent(PersonIdent pi, Instant aWhen)

Copy a org.eclipse.jgit.lib.PersonIdent, but alter the clone's time stamp

Parameters
pi:PersonIdent

original org.eclipse.jgit.lib.PersonIdent

aWhen:Instant

local time as Instant

Since
6.1
PersonIdentback to summary
public PersonIdent(final String aName, final String aEmailAddress, final Date aWhen, final TimeZone aTZ)

Deprecated

since 7.1.

Use the variant with Instant and ZoneId instead

Construct a PersonIdent from simple data

Parameters
aName:String

a java.lang.String object.

aEmailAddress:String

a java.lang.String object.

aWhen:Date

local time stamp

aTZ:TimeZone

time zone

Annotations
@Deprecated
since:7.1
PersonIdentback to summary
public PersonIdent(final String aName, String aEmailAddress, Instant aWhen, ZoneId zoneId)

Construct a PersonIdent from simple data

Parameters
aName:String

a java.lang.String object.

aEmailAddress:String

a java.lang.String object.

aWhen:Instant

local time stamp

zoneId:ZoneId

time zone id

Since
6.1
PersonIdentback to summary
public PersonIdent(PersonIdent pi, long aWhen, int aTZ)

Deprecated

since 7.1.

Use the variant with Instant and ZoneId instead

Copy a PersonIdent, but alter the clone's time stamp

Parameters
pi:PersonIdent

original org.eclipse.jgit.lib.PersonIdent

aWhen:long

local time stamp

aTZ:int

time zone

Annotations
@Deprecated
since:7.1
PersonIdentback to summary
private PersonIdent(final String aName, final String aEmailAddress, Instant when)
PersonIdentback to summary
private PersonIdent(UserConfig config)
PersonIdentback to summary
public PersonIdent(final String aName, final String aEmailAddress, final long aWhen, final int aTZ)

Deprecated

since 7.1.

Use the variant with Instant and ZoneId instead

Construct a org.eclipse.jgit.lib.PersonIdent.

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 of toExternalString() may not return an equivalent instance.

Parameters
aName:String

a java.lang.String object.

aEmailAddress:String

a java.lang.String object.

aWhen:long

local time stamp

aTZ:int

time zone

Annotations
@Deprecated
since:7.1

Method Detail

appendSanitizedback to summary
public static void appendSanitized(StringBuilder r, 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 function strbuf_addstr_without_crud.

Parameters
r:StringBuilder

string builder to append to.

str:String

input string.

Since
4.4
appendTimezoneback to summary
public static void appendTimezone(StringBuilder r, int offset)

Format a timezone offset.

Parameters
r:StringBuilder

string builder to append to.

offset:int

timezone offset as in getTimeZoneOffset().

Since
4.1
equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getEmailAddressback to summary
public String getEmailAddress()

Get email address of person

Returns:String

email address of person

getNameback to summary
public String getName()

Get name of person

Returns:String

Name of person

getTimeZoneback to summary
public static TimeZone getTimeZone(int tzOffset)

Deprecated

since 7.2.

use getZoneId(int) instead

Get timezone object for the given offset.

Parameters
tzOffset:int

timezone offset as in getTimeZoneOffset().

Returns:TimeZone

time zone object for the given offset.

Annotations
@Deprecated
since:7.2
Since
4.1
getTimeZoneback to summary
public TimeZone getTimeZone()

Deprecated

since 7.1.

Use getZoneId instead

Get this person's declared time zone

Returns:TimeZone

this person's declared time zone; null if time zone is unknown.

Annotations
@Deprecated
since:7.1
getTimeZoneOffsetback to summary
public int getTimeZoneOffset()

Deprecated

since 7.1.

Use getZoneOffset() and read minutes from there

Get this person's declared time zone as minutes east of UTC.

Returns:int

this person's declared time zone as minutes east of UTC. If the timezone is to the west of UTC it is negative.

Annotations
@Deprecated
since:7.1
getWhenback to summary
public Date getWhen()

Deprecated

since 7.1.

Use getWhenAsInstant instead

Get timestamp

Returns:Date

timestamp

Annotations
@Deprecated
since:7.1
getWhenAsInstantback to summary
public Instant getWhenAsInstant()

Get when attribute as instant

Returns:Instant

timestamp

Since
6.1
getZoneIdback to summary
public static ZoneId getZoneId(int tzOffset)

Translate a minutes offset into a ZoneId

Parameters
tzOffset:int

as minutes east of UTC

Returns:ZoneId

a ZoneId for this offset (UTC if invalid)

Since
7.1
getZoneIdback to summary
public ZoneId getZoneId()

Get the time zone id

Returns:ZoneId

the time zone id

Since
6.1
getZoneOffsetback to summary
public ZoneOffset getZoneOffset()

Return the offset in this timezone at the specific time

Returns:ZoneOffset

the offset

Since
7.1
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.

Hashcode is based only on the email address and timestamp.

Returns:int

a hash code value for this object

Annotations
@Override
toExternalStringback to summary
public String toExternalString()

Format for Git storage.

Returns:String

a string in the git author format

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
@SuppressWarnings:nls