Package org.alfresco.repo.domain
Class CrcHelper
- java.lang.Object
-
- org.alfresco.repo.domain.CrcHelper
-
public class CrcHelper extends java.lang.ObjectHelper class to calculate CRC values for string persistence.- Since:
- 3.2
- Author:
- Derek Hulley
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringEMPTY_STRING
-
Constructor Summary
Constructors Constructor Description CrcHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static org.alfresco.util.Pair<java.lang.String,java.lang.Long>getStringCrcPair(java.lang.String value, int dataLength, boolean useCharsFromStart, boolean caseSensitive)Calculate a persistable, unique pair of values that can be persisted in a database unique key and guarantee correct case-sensitivity.
-
-
-
Field Detail
-
EMPTY_STRING
public static final java.lang.String EMPTY_STRING
- See Also:
- Constant Field Values
-
-
Method Detail
-
getStringCrcPair
public static org.alfresco.util.Pair<java.lang.String,java.lang.Long> getStringCrcPair(java.lang.String value, int dataLength, boolean useCharsFromStart, boolean caseSensitive)Calculate a persistable, unique pair of values that can be persisted in a database unique key and guarantee correct case-sensitivity.While the short-string version of the value is always lowercase, the CRC is calculated from the virgin string if case-sensitivity is enforced; in the case-insensitive case, the CRC is calculated from a lowercase version of the string.
If the value is an empty string, then
EMPTY_STRINGis used instead. This ensures that persisted values don't fall foul of the Oracle empty string comparison "behaviour" i.e you should never persist an empty string in Oracle as it equates to a SQL NULL.- Parameters:
value- the raw value that will be persisteddataLength- the maximum number of characters that can be persisteduseCharsFromStart- true if the shortened string value must be made from the first characters of the string or false to use characters from the end of the string.caseSensitive- true if the resulting pair must be case-sensitive or false if the pair must be case-insensitive.- Returns:
- Return the persistable pair. The result will never be null, but the individual pair values will be null if the value given is null
-
-