public final class PK extends java.lang.Object implements java.io.Serializable, java.lang.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 java.lang.String |
COUNTER_PK_GENERATOR_FACTORY |
static java.lang.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.
since ages - call createFixedUUIDPK instead
|
static PK |
createFixedUUIDPK(int typecode,
long fixNr) |
static PK |
createPK(int typecode)
Deprecated.
since ages - call createUUIDPK instead
|
static PK |
createUUIDPK(int typecode)
create a UUID based PK.
|
boolean |
equals(java.lang.Object object) |
static PK |
fromLong(long longValue) |
byte |
getClusterID()
Deprecated.
since ages
|
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() |
java.lang.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. |
java.lang.Long |
getLong() |
long |
getLongValue() |
java.lang.String |
getLongValueAsString() |
static long |
getMaxTimeOffsetInMillis() |
byte |
getMilliCnt()
Deprecated.
since ages
|
int |
getTypeCode() |
java.lang.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 java.util.Collection<PK> |
parse(java.util.Collection<java.lang.String> pkStrings)
Parses the collection of String (in decimal Long format, e.g '123493920953093') and returns a Collection of PK
objects
|
static PK |
parse(java.lang.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(java.lang.String hexPkString)
Decodes a hexadecimal String into a PK.
|
java.lang.String |
toString() |
public static final java.lang.String COUNTER_PK_GENERATOR_FACTORY
public static final PK NULL_PK
public static final PK BIG_PK
public static final java.lang.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 java.lang.Long getLong()
public long getLongValue()
public java.lang.String getTypeCodeAsString()
public java.lang.String getLongValueAsString()
public int hashCode()
hashCode in class java.lang.Objectpublic static int hashCode(long longValue)
public boolean equals(java.lang.Object object)
equals in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String getHex()
public static PK parseHex(java.lang.String hexPkString)
hexPkString - hexadecimal represantation of the PK object.java.lang.NumberFormatException - - if the String does not contain a parsable long.public int compareTo(PK pk)
compareTo in interface java.lang.Comparable<PK>Comparable.compareTo(java.lang.Object)public static PK parse(java.lang.String pkString)
PK.PKException - if a number format error occurspublic static java.util.Collection<PK> parse(java.util.Collection<java.lang.String> pkStrings)
PK.PKException - if a number format error occursCopyright © 2018 SAP SE. All Rights Reserved.