public AstReadOptionNodeBuilder() { this(new AstReadOptionNode()); }
@Override protected final boolean equalTo(AstOptionNode that) { return that instanceof AstReadOptionNode && equalTo((AstReadOptionNode) that); }
public AstReadOptionNodeBuilder setOptionName(String optionName) { node.setOptionName(optionName); return this; }
@Override public Configuration visit(AstReadOptionNode node, State state) { TypeInfo<?> optionType = node.getOptionType(); if (optionType == DefaultTypeSystem.OPTION_MASK) { AstValue<?> maskValue = node.getOptionValue(); state.readUnmasker = maskValue.accept(new GenerateMaskOptionValueVisitor(), state); } else { ChannelHandler handler = behaviorSystem.newReadOptionHandler(node); String optionName = node.getOptionName(); if (handler != null) { String handlerName = String.format("readOption#%d (%s)", state.pipelineAsMap.size() + 1, optionName); state.pipelineAsMap.put(handlerName, handler); } else { throw new IllegalArgumentException("Unrecognized read option : " + optionName); } } return state.configuration; }
@Override public AstReadOptionNode visitReadOptionNode(ReadOptionNodeContext ctx) { String optionQName = ctx.optionName().getText(); TypeInfo<?> optionType = TYPE_SYSTEM.readOption(optionQName); Class<?> expectedType = optionType.getType(); AstValueVisitor<?> visitor = new AstValueVisitor<>(factory, environment, expectedType); AstValue<?> optionValue = visitor.visit(ctx); childInfos().add(optionValue.getRegionInfo()); node = new AstReadOptionNode(); node.setOptionType(optionType); node.setOptionName(optionQName); node.setOptionValue(optionValue); node.setRegionInfo(asSequentialRegion(childInfos, ctx)); return node; } }
@Override protected void describe(StringBuilder buf) { super.describe(buf); buf.append(format("read option %s %s\n", getOptionName(), getOptionValue())); } }
private static ReadOptionFileOffsetHandler newReadFileOffsetHandler( AstReadOptionNode node) { AstLiteralTextValue offsetValue = (AstLiteralTextValue) node.getOptionValue(); int offset = Integer.parseInt(offsetValue.getValue()); ReadOptionFileOffsetHandler handler = new ReadOptionFileOffsetHandler(offset); handler.setRegionInfo(node.getRegionInfo()); return handler; }
public AstReadOptionNodeBuilder setOptionValue(ValueExpression expression, ExpressionContext environment) { node.setOptionValue(new AstExpressionValue<>(expression, environment)); return this; }
@Override public AstReadOptionNode visitReadOptionNode(ReadOptionNodeContext ctx) { AstReadOptionNodeVisitor visitor = new AstReadOptionNodeVisitor(factory, environment); AstReadOptionNode optionNode = visitor.visitReadOptionNode(ctx); if (optionNode != null) { childInfos().add(optionNode.getRegionInfo()); } return optionNode; }
public AstReadOptionNodeBuilder setOptionType(TypeInfo<?> optionType) { node.setOptionType(optionType); return this; }
public ChannelHandler newReadOptionHandler( AstReadOptionNode node) { TypeInfo<?> optionType = node.getOptionType(); ReadOptionFactory factory = readOptions.getOrDefault(optionType, n -> null); return factory.newHandler(node); }
public StreamNested<R> setOptionValue(long optionValue) { node.setOptionValue(new AstLiteralLongValue(optionValue)); return this; }
public StreamNested<R> setOptionType(TypeInfo<?> optionType) { node.setOptionType(optionType); return this; }
public AstReadOptionNodeBuilder setOptionValue(long optionValue) { node.setOptionValue(new AstLiteralLongValue(optionValue)); return this; }
public StreamNested<R> setOptionName(String optionName) { node.setOptionName(optionName); return this; }
public StreamNested(R builder) { super(new AstReadOptionNode(), builder); }
public StreamNested<R> setOptionValue(byte[] optionValue) { node.setOptionValue(new AstLiteralBytesValue(optionValue)); return this; }
public StreamNested<R> setOptionValue(URI optionValue) { node.setOptionValue(new AstLiteralURIValue(optionValue)); return this; }
public StreamNested<R> setOptionValue(String optionValue) { node.setOptionValue(new AstLiteralTextValue(optionValue)); return this; }
public AstReadOptionNodeBuilder setOptionValue(URI optionValue) { node.setOptionValue(new AstLiteralURIValue(optionValue)); return this; }