public Object getObject(boolean unzip) throws IOException, ClassNotFoundException { if (isBytes()) { return this.part; } else { if (this.version != null) { return CacheServerHelper.deserialize((byte[]) this.part, this.version, unzip); } else { return CacheServerHelper.deserialize((byte[]) this.part, unzip); } } }
public String getString() { if (this.part == null) { return null; } if (!isBytes()) { Assert.assertTrue(false, "expected String part to be of type BYTE, part =" + this.toString()); } return CacheServerHelper.fromUTF((byte[]) this.part); }
protected static Operation getOperation(final Part operationPart, final Operation defaultOperation) throws Exception { if (operationPart.isBytes()) { final byte[] bytes = operationPart.getSerializedForm(); if (null == bytes || 0 == bytes.length) { // older clients can send empty bytes for default operation. return defaultOperation; } else { return Operation.fromOrdinal(bytes[0]); } } // Fallback for older clients. final Operation operation = (Operation) operationPart.getObject(); if (operation == null) { // native clients may send a null since the op is java-serialized. return defaultOperation; } return operation; }
public byte getByte() { if (!isBytes()) { Assert.assertTrue(false, "expected int part to be of type BYTE, part = " + this.toString()); } if (getLength() != 1) { Assert.assertTrue(false, "expected int length to be 1 but it was " + getLength() + "; part = " + this.toString()); } final byte[] bytes = getSerializedForm(); return bytes[0]; }
public int getInt() { if (!isBytes()) { Assert.assertTrue(false, "expected int part to be of type BYTE, part = " + this.toString()); } if (getLength() != 4) { Assert.assertTrue(false, "expected int length to be 4 but it was " + getLength() + "; part = " + this.toString()); } byte[] bytes = getSerializedForm(); return decodeInt(bytes, 0); }
public long getLong() { if (!isBytes()) { Assert.assertTrue(false, "expected long part to be of type BYTE, part = " + this.toString()); } if (getLength() != 8) { Assert.assertTrue(false, "expected long length to be 8 but it was " + getLength() + "; part = " + this.toString()); } byte[] bytes = getSerializedForm(); return ((((long) bytes[0]) << 56) & 0xFF00000000000000l) | ((((long) bytes[1]) << 48) & 0x00FF000000000000l) | ((((long) bytes[2]) << 40) & 0x0000FF0000000000l) | ((((long) bytes[3]) << 32) & 0x000000FF00000000l) | ((((long) bytes[4]) << 24) & 0x00000000FF000000l) | ((((long) bytes[5]) << 16) & 0x0000000000FF0000l) | ((((long) bytes[6]) << 8) & 0x000000000000FF00l) | (bytes[7] & 0x00000000000000FFl); }
if (part0.isBytes() && part0.getLength() == 1 && part0.getSerializedForm()[0] == 0) {