@Override public <A extends Appendable> A readUTFOfLength(int length, A target) { try { return readUTF(this, length, target); } catch (Exception e) { throw new RuntimeException(e); } }
@Override public <A extends Appendable> A readUTFOfLength(int length, A target) { try { return readUTF(this, length, target); } catch (Exception e) { throw new RuntimeException(e); } }
@Override public <A extends Appendable> A readUTFOfLength(int length, A target) { try { return readUTF(this, length, target); } catch (Exception e) { throw new RuntimeException(e); } }
@Override public String readUTFOfLength(int length) { if (length >= 0) { workspace.setLength(0); try { return readUTF(this, length, workspace).toString(); } catch (Exception e) { throw new RuntimeException(e); } } else { return null; } }
@Override public String readUTFOfLength(int length) { if (length >= 0) { workspace.setLength(0); try { return readUTF(this, length, workspace).toString(); } catch (Exception e) { throw new RuntimeException(e); } } else { return null; } }
@Override public String readUTFOfLength(int length) { if (length >= 0) { workspace.setLength(0); try { return readUTF(this, length, workspace).toString(); } catch (Exception e) { throw new RuntimeException(e); } } else { return null; } }
@Override public String readUTFFully() { workspace.setLength(0); try { return readUTF(this, available(), workspace).toString(); } catch (Exception e) { throw new RuntimeException(e); } }
@Override public String readUTF() { checkLimit(this,2); return super.readUTF(); }
@Override public String readUTFFully() { workspace.setLength(0); try { return readUTF(this, available(), workspace).toString(); } catch (Exception e) { throw new RuntimeException(e); } }
@Override public String readUTFFully() { workspace.setLength(0); try { return readUTF(this, available(), workspace).toString(); } catch (Exception e) { throw new RuntimeException(e); } }
@Override public <A extends Appendable> A readUTF(A target) { checkLimit(this,2); return super.readUTF(target); }
/** * Reads text at given field * @param fieldId to read from * @return text if data exists, else <code>null</code> */ public String readText(long fieldId) { assert(0==Pipe.structRegistry(DataInputBlobReader.getBackingPipe(channelReader)).dims(fieldId)) : "This method only used for non dim fields."; final int index = channelReader.readFromEndLastInt(StructRegistry.FIELD_MASK&(int)fieldId); if (index>=0) { channelReader.position(index); return channelReader.readUTF(); } else { return null; } }
/** * Reads text at given field * @param fieldId to read from * @return text if data exists, else <code>null</code> */ public String readText(long fieldId) { assert(0==Pipe.structRegistry(DataInputBlobReader.getBackingPipe(channelReader)).dims(fieldId)) : "This method only used for non dim fields."; final int index = channelReader.readFromEndLastInt(StructRegistry.FIELD_MASK&(int)fieldId); if (index>=0) { channelReader.position(index); return channelReader.readUTF(); } else { return null; } }
/** * Reads text at given field * @param fieldId to read from * @return text if data exists, else <code>null</code> */ public String readText(long fieldId) { assert(0==Pipe.structRegistry(DataInputBlobReader.getBackingPipe(channelReader)).dims(fieldId)) : "This method only used for non dim fields."; final int index = channelReader.readFromEndLastInt(StructRegistry.FIELD_MASK&(int)fieldId); if (index>=0) { channelReader.position(index); return channelReader.readUTF(); } else { return null; } }
/** * Reads text from specified field in pipe * @param fieldId field to read from * @param target to append text * @return target with appended data */ public <A extends Appendable> A readText(long fieldId, A target) { assert(0==Pipe.structRegistry(DataInputBlobReader.getBackingPipe(channelReader)).dims(fieldId)) : "This method only used for non dim fields."; assert isTextOrBlob(fieldId) : "Field type is expected to be text or blob but was "+Pipe.structRegistry(DataInputBlobReader.getBackingPipe(channelReader)).fieldType(fieldId); int index = channelReader.readFromEndLastInt(StructRegistry.FIELD_MASK&(int)fieldId); if (index>=0) { channelReader.position(index); channelReader.readUTF(target); } return target; }
/** * Reads text from specified field in pipe * @param fieldId field to read from * @param target to append text * @return target with appended data */ public <A extends Appendable> A readText(long fieldId, A target) { assert(0==Pipe.structRegistry(DataInputBlobReader.getBackingPipe(channelReader)).dims(fieldId)) : "This method only used for non dim fields."; assert isTextOrBlob(fieldId) : "Field type is expected to be text or blob but was "+Pipe.structRegistry(DataInputBlobReader.getBackingPipe(channelReader)).fieldType(fieldId); int index = channelReader.readFromEndLastInt(StructRegistry.FIELD_MASK&(int)fieldId); if (index>=0) { channelReader.position(index); channelReader.readUTF(target); } return target; }
/** * Reads text from specified field in pipe * @param fieldId field to read from * @param target to append text * @return target with appended data */ public <A extends Appendable> A readText(long fieldId, A target) { assert(0==Pipe.structRegistry(DataInputBlobReader.getBackingPipe(channelReader)).dims(fieldId)) : "This method only used for non dim fields."; assert isTextOrBlob(fieldId) : "Field type is expected to be text or blob but was "+Pipe.structRegistry(DataInputBlobReader.getBackingPipe(channelReader)).fieldType(fieldId); int index = channelReader.readFromEndLastInt(StructRegistry.FIELD_MASK&(int)fieldId); if (index>=0) { channelReader.position(index); channelReader.readUTF(target); } return target; }
@Test public void testEncodeString() throws IOException{ //create a new blob pipe to put a string on Pipe<RawDataSchema> pipe = new Pipe<RawDataSchema>(new PipeConfig<RawDataSchema>(RawDataSchema.instance, 100, 4000)); pipe.initBuffers(); DataOutputBlobWriter<RawDataSchema> writer = new DataOutputBlobWriter<RawDataSchema>(pipe); //encode a string on blob using the static method StringBuilder testString = new StringBuilder("This is a test"); PhastEncoder.encodeString(writer, testString , 0, 0, false); writer.close(); //check what is on the pipe DataInputBlobReader<RawDataSchema> reader = new DataInputBlobReader<RawDataSchema>(pipe); //should be -63 int test = reader.readPackedInt(); //the string String value = reader.readUTF(); reader.close(); String s = value.toString(); assertTrue((test==-63) && (s.compareTo("This is a test")==0)); }
state.beginFileRead(inputStream.readUTF());