| | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizedIllegalArgumentException; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteSequenceReader; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | |
| | | * @param s |
| | | * The string to be parsed. |
| | | * @return The parsed CSN. |
| | | * @throws LocalizedIllegalArgumentException |
| | | * If the provided string is not a valid {@link #toString()} representation of a CSN |
| | | * @see #toString() |
| | | */ |
| | | public static CSN valueOf(String s) |
| | |
| | | * |
| | | * @param str |
| | | * the string from which to create a {@link CSN} |
| | | * @throws LocalizedIllegalArgumentException |
| | | * If the provided string is not a valid {@link #toString()} representation of a CSN |
| | | */ |
| | | public CSN(String str) |
| | | { |
| | | String temp = str.substring(0, 16); |
| | | timeStamp = Long.parseLong(temp, 16); |
| | | if (str == null || str.length() < STRING_ENCODING_LENGTH) |
| | | { |
| | | throw new LocalizedIllegalArgumentException(LocalizableMessage.raw("Invalid CSN: \"%s\"", str)); |
| | | } |
| | | |
| | | temp = str.substring(16, 20); |
| | | serverId = Integer.parseInt(temp, 16); |
| | | |
| | | temp = str.substring(20, 28); |
| | | seqnum = Integer.parseInt(temp, 16); |
| | | try |
| | | { |
| | | timeStamp = Long.parseLong(str.substring(0, 16), 16); |
| | | serverId = Integer.parseInt(str.substring(16, 20), 16); |
| | | seqnum = Integer.parseInt(str.substring(20, STRING_ENCODING_LENGTH), 16); |
| | | } |
| | | catch (NumberFormatException e) |
| | | { |
| | | throw new LocalizedIllegalArgumentException(LocalizableMessage.raw("Invalid CSN: \"%s\"", str)); |
| | | } |
| | | } |
| | | |
| | | /** |