@Override public <A extends Appendable> A appendTo(StructuredReader activeReader, long id, A target) { return activeReader.readText(id,target); }
@Override public <A extends Appendable> A appendTo(StructuredReader activeReader, long id, A target) { return activeReader.readText(id,target); }
/** * Only call this method when NO routes have been defined. * @param <A> target appendable type * @param appendable * */ public <A extends Appendable> A getRoutePath(A appendable) { assert(isStructured()); assert(getStructType(this) == http1xRouterStageConfig.UNMAPPED_STRUCT); if (hasNoRoutes) { return structured().readText(http1xRouterStageConfig.unmappedPathField,appendable); } else { throw new UnsupportedOperationException("this method can only be used when no routes have been defined."); } }
@Override public boolean restRequest(HTTPRequestReader request) { StructuredReader record = request.structured(); int age = record.readInt(Field.PERSON_AGE); isLegal = age>=21; name.setLength(0); record.readText(Field.PERSON_NAME, name); return responseService.publishHTTPResponse(request, 200, HTTPContentTypeDefaults.JSON, w-> { jsonRenderer.render(w, this); }); }
public boolean productUpdate(HTTPRequestReader request) { StructuredReader structured = request.structured(); int idx = structured.readInt(Field.ID); quantity[idx] = structured.readInt(Field.QUANTITY); disabled[idx] = structured.readBoolean(Field.DISABLED); names[idx].setLength(0); structured.readText(Field.NAME, names[idx] ); return responseService.publishHTTPResponse(request, 200); }
/** * Reads text from specified field in pipe * @param association field association showing where to read * @return String data */ public String readText(Object association) { return readText(Pipe.structRegistry( DataInputBlobReader.getBackingPipe(channelReader)) .fieldLookupByIdentity(association, DataInputBlobReader.getStructType(channelReader))); }
/** * Reads text from specified field in pipe * @param association field association showing where to read * @return String data */ public String readText(Object association) { return readText(Pipe.structRegistry(DataInputBlobReader.getBackingPipe(channelReader)).fieldLookupByIdentity(association, DataInputBlobReader.getStructType(channelReader))); }
/** * Reads text from specified field in pipe * @param association field association showing where to read * @param target to append text * @return target with appended data */ public <A extends Appendable> A readText(Object association, A target) { return readText(Pipe.structRegistry(DataInputBlobReader.getBackingPipe(channelReader)).fieldLookupByIdentity(association, DataInputBlobReader.getStructType(channelReader)), target); }
/** * Reads text from specified field in pipe * @param association field association showing where to read * @return String data */ public String readText(Object association) { return readText(Pipe.structRegistry( DataInputBlobReader.getBackingPipe(channelReader)) .fieldLookupByIdentity(association, DataInputBlobReader.getStructType(channelReader))); }
/** * Reads text from specified field in pipe * @param association field association showing where to read * @param target to append text * @return target with appended data */ public <A extends Appendable> A readText(Object association, A target) { return readText(Pipe.structRegistry(DataInputBlobReader.getBackingPipe(channelReader)).fieldLookupByIdentity(association, DataInputBlobReader.getStructType(channelReader)), target); }
/** * Reads text from specified field in pipe * @param association field association showing where to read * @param target to append text * @return target with appended data */ public <A extends Appendable> A readText(Object association, A target) { return readText(Pipe.structRegistry(DataInputBlobReader.getBackingPipe(channelReader)).fieldLookupByIdentity(association, DataInputBlobReader.getStructType(channelReader)), target); }
@Override public boolean message(CharSequence topic, ChannelReader payload) { StructuredReader struct = payload.structured(); return responseService.publishHTTPResponse( struct.readLong(Field.CONNECTION), struct.readLong(Field.SEQUENCE), struct.readInt(Field.STATUS), HTTPContentTypeDefaults.JSON, w->{ struct.readText(Field.PAYLOAD, w); }); }
quantity = struct.readInt(Field.QUANTITY); disabled = struct.readBoolean(Field.DISABLED); name = struct.readText(Field.NAME); break;
@Override public void read(ChannelReader reader) { if (reader.available()<1) { //error return; } int age = reader.structured().readInt(Fields.AGE); String name = reader.structured().readText(Fields.NAME); Appendables.appendValue(console.append(name).append(" "),age).append("\n"); } };
@Override public boolean begin(Pipe<HTTPRequestSchema> input) { int msgIdx = Pipe.takeMsgIdx(input); channelId = Pipe.takeLong(input); sequence = Pipe.takeInt(input); verb = Pipe.takeInt(input); DataInputBlobReader<HTTPRequestSchema> params = Pipe.openInputStream(input); StructuredReader reader = params.structured(); requestId = reader.readInt(WebFields.id); if (requestId>=0) { name = reader.readText(WebFields.name); } revision = Pipe.takeInt(input); context = Pipe.takeInt(input); Pipe.confirmLowLevelRead(input, Pipe.sizeOf(input, msgIdx)); Pipe.releaseReadLock(input); return true; }
public boolean productUpdate(HTTPRequestReader request) { StructuredReader source = request.structured(); return publishService.publishTopic((w)->{ //write update message with new payload plus sequence and connectionID StructuredWriter target = w.structured(); target.writeInt(Field.ID, source.readInt(Field.ID)); target.writeInt(Field.QUANTITY, source.readInt(Field.QUANTITY)); target.writeBoolean(Field.DISABLED, source.readBoolean(Field.DISABLED)); //source.readText(Field.NAME, target.writeText(Field.NAME)); //Broken?? target.writeText(Field.NAME, source.readText(Field.NAME)); target.writeLong(Field.CONNECTION, request.getConnectionId()); target.writeLong(Field.SEQUENCE, request.getSequenceCode()); target.selectStruct(Struct.DB_PRODUCT_UPDATE); }); }
reader.readText(WebFields.proxyGet, outputStream); DataOutputBlobWriter.closeLowLevelField(outputStream);