final String readCodedString() throws IOException {
final byte valueType = input.readByte();
switch (valueType) {
- case TokenTypes.IS_NULL_VALUE:
+ case LithiumTokens.IS_NULL_VALUE:
return null;
- case TokenTypes.IS_CODE_VALUE:
+ case LithiumTokens.IS_CODE_VALUE:
final int code = input.readInt();
try {
return codedStringMap.get(code);
} catch (IndexOutOfBoundsException e) {
throw new IOException("String code " + code + " was not found", e);
}
- case TokenTypes.IS_STRING_VALUE:
+ case LithiumTokens.IS_STRING_VALUE:
final String value = input.readUTF().intern();
codedStringMap.add(value);
return value;
if (revision.isPresent()) {
writeString(revision.get().toString());
} else {
- writeByte(TokenTypes.IS_NULL_VALUE);
+ writeByte(LithiumTokens.IS_NULL_VALUE);
}
}
final Integer value = stringCodeMap.get(verifyNotNull(string));
if (value == null) {
stringCodeMap.put(string, stringCodeMap.size());
- writeByte(TokenTypes.IS_STRING_VALUE);
+ writeByte(LithiumTokens.IS_STRING_VALUE);
writeUTF(string);
} else {
- writeByte(TokenTypes.IS_CODE_VALUE);
+ writeByte(LithiumTokens.IS_CODE_VALUE);
writeInt(value);
}
}
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.cluster.datastore.node.utils.stream;
+
+/**
+ * Tokens related to Lithium/NeonSR2 encoding.
+ */
+final class LithiumTokens {
+ /**
+ * The value is a reference to a previously-defined entity, typically through {@link #IS_STRING_VALUE}.
+ */
+ static final byte IS_CODE_VALUE = 1;
+ /**
+ * The value is a String, which needs to be kept memoized for the purposes for being referenced by
+ * {@link #IS_CODE_VALUE}.
+ */
+ static final byte IS_STRING_VALUE = 2;
+ /**
+ * The value is an explicit null.
+ */
+ static final byte IS_NULL_VALUE = 3;
+
+ private LithiumTokens() {
+
+ }
+}
*/
static final short NEON_SR2_VERSION = 2;
- // Tokens supported in LITHIUM_VERSION
- static final byte IS_CODE_VALUE = 1;
- static final byte IS_STRING_VALUE = 2;
- static final byte IS_NULL_VALUE = 3;
-
// Tokens supported in NEON_SR2_VERSION
static final byte IS_QNAME_CODE = 4;
static final byte IS_QNAME_VALUE = 5;