public final class PK extends Object implements Serializable, Comparable<PK>
typecode = (int) ((longValue & 0xFFFF000000000000l) >> 48); clusterid = ((byte) ((longValue & 0x0000F00000000000l) >> 44 | ((longValue & 0x000000000000000Cl) << 2))); creationtime = ((longValue & 0x00000FFFFFFFFFF0l) >> 4) + DATE_01_01_1995; millicnt = (byte) ((longValue & 0x0000000000000003l));Calculation rules pk->long:
longValue = ((typecode << 48) & 0xFFFF000000000000l); longValue += (((clusterid & 0x000000000000000Fl) << 44) & 0x0000F00000000000l); longValue += ((creationtime - DATE_01_01_1995 << 4) & 0x00000FFFFFFFFFF0l); longValue += ((clusterid >> 2) & 0x000000000000000Cl); longValue += ((millicnt) & 0x0000000000000003l);*NOTE* CHANGE 081209: only the last two bits (&0x3) of millicnt are treated as millicount, the upper two bits (&0xC) are added to clusterID - See https://jira.hybris.com/browse/PLA-6829 - See https://wiki.hybris.com/x/XIRvAg Sample of an Serialized PK object:
| Modifier and Type | Class and Description |
|---|---|
static interface |
PK.PKCounterGenerator |
static class |
PK.PKException |
| Modifier and Type | Field and Description |
|---|---|
static PK |
BIG_PK |
static String |
COUNTER_PK_GENERATOR_FACTORY |
static String |
LEGACY_PK_31_DETECTION |
static PK |
NULL_PK |
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(PK pk)
The implementation is taken from java.lang.Long#compareTo(java.lang.Long).
|
static PK |
createCounterPK(int typecode)
create a Counter based PK.
|
static PK |
createFixedCounterPK(int typecode,
long fixNr) |
static PK |
createFixedPK(int typecode,
long fixNr)
Deprecated.
call createFixedUUIDPK instead
|
static PK |
createFixedUUIDPK(int typecode,
long fixNr) |
static PK |
createPK(int typecode)
Deprecated.
call createUUIDPK instead
|
static PK |
createUUIDPK(int typecode)
create a UUID based PK.
|
boolean |
equals(Object object) |
static PK |
fromLong(long longValue) |
byte |
getClusterID()
Deprecated.
|
long |
getCounter() |
long |
getCreationTime()
returns the creation time (for UUID based PK's) or the 'counter' value for counter based PK's
|
static long |
getCurrentTimeOffsetInMillis() |
String |
getHex()
Returns a string representation of the PK as an unsigned integer in base 16.
This method is an alias for PK.toHexString() that can be used within the Expression Language. |
Long |
getLong() |
long |
getLongValue() |
String |
getLongValueAsString() |
static long |
getMaxTimeOffsetInMillis() |
byte |
getMilliCnt()
Deprecated.
|
int |
getTypeCode() |
String |
getTypeCodeAsString() |
int |
hashCode()
see http://www.concentric.net/~Ttwang/tech/inthash.htm
|
static int |
hashCode(long longValue) |
boolean |
isCounterBased()
bit 43 is 0 -> definitely a UUID PK(returning false),
|
boolean |
isCounterBased(boolean legacyDetectionEnabled) |
static Collection<PK> |
parse(Collection<String> pkStrings)
Parses the collection of String (in decimal Long format, e.g '123493920953093') and returns a Collection of PK
objects
|
static PK |
parse(String pkString)
Parses the given String (in decimal Long format, e.g '1234939953093') and returns an PK object if the input string
was null, null is returned
|
static PK |
parseHex(String hexPkString)
Decodes a hexadecimal String into a PK.
|
String |
toString() |
public static final String COUNTER_PK_GENERATOR_FACTORY
public static final PK NULL_PK
public static final PK BIG_PK
public static final String LEGACY_PK_31_DETECTION
@Deprecated public static PK createFixedPK(int typecode, long fixNr)
public static PK createFixedUUIDPK(int typecode, long fixNr)
public static PK createFixedCounterPK(int typecode, long fixNr)
@Deprecated public static PK createPK(int typecode)
public static PK createUUIDPK(int typecode)
public static PK createCounterPK(int typecode)
public static PK fromLong(long longValue)
public static long getCurrentTimeOffsetInMillis()
public static long getMaxTimeOffsetInMillis()
public boolean isCounterBased()
bit 43 is 1 -> is counter if
public boolean isCounterBased(boolean legacyDetectionEnabled)
legacyDetectionEnabled - if true, will try to parse the pk to check if it is 3.1 legacy styleisCounterBased()public int getTypeCode()
public long getCreationTime()
public long getCounter()
@Deprecated public byte getClusterID()
@Deprecated public byte getMilliCnt()
public Long getLong()
public long getLongValue()
public String getTypeCodeAsString()
public String getLongValueAsString()
public int hashCode()
public static int hashCode(long longValue)
public String getHex()
public static PK parseHex(String hexPkString)
hexPkString - hexadecimal represantation of the PK object.NumberFormatException - - if the String does not contain a parsable long.public int compareTo(PK pk)
compareTo in interface Comparable<PK>Comparable.compareTo(java.lang.Object)public static PK parse(String pkString)
PK.PKException - if a number format error occurspublic static Collection<PK> parse(Collection<String> pkStrings)
PK.PKException - if a number format error occursCopyright © 2017 SAP SE. All Rights Reserved.