public AstReadOptionNodeBuilder setOptionValue(byte[] optionValue) { node.setOptionValue(new AstLiteralBytesValue(optionValue)); return this; }
@Override protected void describe(StringBuilder buf) { describe(buf, value); }
@Override protected boolean equalTo(AstRegion that) { return (that instanceof AstLiteralBytesValue) && equalTo((AstLiteralBytesValue) that); }
@Override public AstLiteralBytesValue visitLiteralBytes(LiteralBytesContext ctx) { String literal = ctx.literal.getText(); AstLiteralBytesValue value = new AstLiteralBytesValue(parseHexBytes(literal)); value.setRegionInfo(asSequentialRegion(childInfos, ctx)); return value; }
@Override public Configuration visit(AstPropertyNode propertyNode, State state) { String propertyName = propertyNode.getPropertyName(); Object value = propertyNode.resolve(); if (value instanceof AutoCloseable) { state.configuration.getResources().add((AutoCloseable) value); } if (LOGGER.isDebugEnabled()) { Object formatValue = (value instanceof byte[]) ? AstLiteralBytesValue.toString((byte[]) value) : value; LOGGER.debug(format("Setting value for ${%s} to %s", propertyName, formatValue)); } return state.configuration; }
@Override public Masker visit(AstLiteralBytesValue value, State state) { byte[] literalBytes = value.getValue(); for (byte literalByte : literalBytes) { if (literalByte != 0x00) { return Maskers.newMasker(literalBytes); } } // no need to unmask for all-zeros masking key return Masker.IDENTITY_MASKER; }
@Override public AstValue<T> visitLiteralBytes(LiteralBytesContext ctx) { AstLiteralBytesValueVisitor visitor = new AstLiteralBytesValueVisitor(factory, environment); AstLiteralBytesValue value = visitor.visit(ctx); if (value != null) { childInfos().add(value.getRegionInfo()); } return (AstValue<T>) value; }
@Override protected Object decodeBuffer(ChannelBuffer buffer) throws Exception { final int resolvedLength; // TODO: Remove when JUEL sync bug is fixed https://github.com/k3po/k3po/issues/147 synchronized (environment) { resolvedLength = (Integer) length.getValue(environment); } if (buffer.readableBytes() < resolvedLength) { return null; } if (captureName == null) { buffer.readSlice(resolvedLength); } else { byte[] bytes = new byte[resolvedLength]; buffer.readBytes(bytes, 0, resolvedLength); // TODO: Remove when JUEL sync bug is fixed https://github.com/k3po/k3po/issues/147 synchronized (environment) { environment.getELResolver().setValue(environment, null, captureName, bytes); } if (LOGGER.isDebugEnabled()) { LOGGER.debug(format("Setting value for ${%s} to %s", captureName, AstLiteralBytesValue.toString(bytes))); } } return buffer; }
@Override public MessageEncoder visit(AstLiteralBytesValue value, Void parameter) { return new WriteBytesEncoder(value.getValue()); }
public StreamNested<R> addValue(byte[] valueBytes) { node.addValue(new AstLiteralBytesValue(valueBytes)); return this; }
@Override protected Object decodeBuffer(ChannelBuffer buffer) throws Exception { if (buffer.readableBytes() < length) { return null; } if (captureName == null) { buffer.readSlice(length); } else { T value = readBuffer(buffer); // TODO: Remove when JUEL sync bug is fixed https://github.com/k3po/k3po/issues/147 synchronized (environment) { environment.getELResolver().setValue(environment, null, captureName, value); } if (LOGGER.isDebugEnabled()) { Object formatValue = (value instanceof byte[]) ? AstLiteralBytesValue.toString((byte[]) value) : value; LOGGER.debug(format("Setting value for ${%s} to %s", captureName, formatValue)); } } return buffer; }
public static String toString(byte[] value) { StringBuilder buf = new StringBuilder(); describe(buf, value); return buf.toString(); }
public AstWriteNodeBuilder addExactBytes(byte[] exactBytes) { node.addValue(new AstLiteralBytesValue(exactBytes)); return this; }
@Override protected Object decodeBufferLast(ChannelBuffer buffer) throws Exception { if (buffer.readableBytes() < length) { throw new ScriptProgressException(getRegionInfo(), String.format("Expected %d bytes, found %d", length, buffer.readableBytes())); } if (captureName == null) { buffer.readSlice(length); } else { T value = readBuffer(buffer); // TODO: Remove when JUEL sync bug is fixed https://github.com/k3po/k3po/issues/147 synchronized (environment) { environment.getELResolver().setValue(environment, null, captureName, value); } if (LOGGER.isDebugEnabled()) { Object formatValue = (value instanceof byte[]) ? AstLiteralBytesValue.toString((byte[]) value) : value; LOGGER.debug(format("Setting value for ${%s} to %s", captureName, formatValue)); } } return buffer; }
public StreamNested<R> addExactBytes(byte[] exactBytes) { node.addValue(new AstLiteralBytesValue(exactBytes)); return this; }
public AstWriteOptionNodeBuilder setOptionValue(byte[] optionValue) { node.setOptionValue(new AstLiteralBytesValue(optionValue)); return this; }
public StreamNested<R> setOptionValue(byte[] optionValue) { node.setOptionValue(new AstLiteralBytesValue(optionValue)); return this; }
public StreamNested<R> setOptionValue(byte[] optionValue) { node.setOptionValue(new AstLiteralBytesValue(optionValue)); return this; }
public AstWriteConfigNodeBuilder setValue(String name, byte[] value) { node.setValue(name, new AstLiteralBytesValue(value)); return this; }
public AstWriteConfigNodeBuilder addValue(byte[] value) { node.addValue(new AstLiteralBytesValue(value)); return this; }