Package com.asakusafw.utils.java.model.syntax

Examples of com.asakusafw.utils.java.model.syntax.ModelFactory


@TargetOperator(CoGroup.class)
public class CoGroupFlowProcessor extends RendezvousProcessor {

    @Override
    public void emitRendezvous(Context context) {
        ModelFactory f = context.getModelFactory();
        OperatorDescription desc = context.getOperatorDescription();
        InputBuffer bufferKind = desc.getAttribute(InputBuffer.class);
        assert bufferKind != null;

        List<Expression> arguments = Lists.create();
View Full Code Here


public class MasterJoinUpdateFlowProcessor extends RendezvousProcessor {

    @Override
    public void emitRendezvous(Context context) {
        MasterKindFlowAnalyzer masterAnalyzer = new MasterKindFlowAnalyzer(context);
        ModelFactory f = context.getModelFactory();
        OperatorDescription desc = context.getOperatorDescription();

        FlowElementPortDescription tx = context.getInputPort(MasterJoinUpdate.ID_INPUT_TRANSACTION);

        FlowElementPortDescription updatedPort = context.getOutputPort(MasterJoinUpdate.ID_OUTPUT_UPDATED);
        FlowElementPortDescription missedPort = context.getOutputPort(MasterJoinUpdate.ID_OUTPUT_MISSED);
        ResultMirror updated = context.getOutput(updatedPort);
        ResultMirror missed = context.getOutput(missedPort);

        Expression impl = context.createImplementation();
        List<Expression> arguments = Lists.create();
        arguments.add(masterAnalyzer.getGetRawMasterExpression());
        arguments.add(context.getProcessInput(tx));
        for (OperatorDescription.Parameter param : desc.getParameters()) {
            arguments.add(Models.toLiteral(f, param.getValue()));
        }

        context.addProcess(tx, f.newIfStatement(
                masterAnalyzer.getHasMasterExpresion(),
                f.newBlock(new Statement[] {
                        new ExpressionBuilder(f, impl)
                            .method(desc.getDeclaration().getName(), arguments)
                            .toStatement(),
                        updated.createAdd(context.getProcessInput(tx))
                }),
                f.newBlock(missed.createAdd(context.getProcessInput(tx)))));
    }
View Full Code Here

@TargetOperator(Extract.class)
public class ExtractFlowProcessor extends LineEndProcessor {

    @Override
    public void emitLineEnd(Context context) {
        ModelFactory f = context.getModelFactory();
        Expression input = context.getInput();
        Expression impl = context.createImplementation();
        OperatorDescription desc = context.getOperatorDescription();

        List<Expression> arguments = Lists.create();
View Full Code Here

@TargetOperator(Update.class)
public class UpdateFlowProcessor extends LinePartProcessor {

    @Override
    public void emitLinePart(Context context) {
        ModelFactory f = context.getModelFactory();
        Expression input = context.getInput();
        Expression impl = context.createImplementation();
        OperatorDescription desc = context.getOperatorDescription();

        List<Expression> arguments = Lists.create();
View Full Code Here

    @Override
    public void emitRendezvous(Context context) {
        MasterKindFlowAnalyzer masterAnalyzer = new MasterKindFlowAnalyzer(context);

        ModelFactory f = context.getModelFactory();

        FlowElementPortDescription tx = context.getInputPort(MasterCheck.ID_INPUT_TRANSACTION);

        FlowElementPortDescription foundPort = context.getOutputPort(MasterCheck.ID_OUTPUT_FOUND);
        FlowElementPortDescription missedPort = context.getOutputPort(MasterCheck.ID_OUTPUT_MISSED);
        ResultMirror found = context.getOutput(foundPort);
        ResultMirror missed = context.getOutput(missedPort);

        context.addProcess(tx, f.newIfStatement(
                masterAnalyzer.getHasMasterExpresion(),
                f.newBlock(found.createAdd(context.getProcessInput(tx))),
                f.newBlock(missed.createAdd(context.getProcessInput(tx)))));
    }
View Full Code Here

    private static Javadoc getJavadoc(
            OperatorCompilingEnvironment environment,
            Element element) {
        assert environment != null;
        assert element != null;
        ModelFactory f = environment.getFactory();
        String comment = environment.getElementUtils().getDocComment(element);
        if (comment == null) {
            return f.newJavadoc(Collections.<DocBlock>emptyList());
        }
        if (comment.startsWith("/**") == false) {
            comment = "/**" + comment;
        }
        if (comment.endsWith("*/") == false) {
            comment = comment + "*/";
        }

        try {
            return new JavadocConverter(f).convert(comment, 0);
        } catch (JavadocParseException e) {
            environment.getMessager().printMessage(Diagnostic.Kind.ERROR,
                    e.getMessage(),
                    element);
            return f.newJavadoc(Collections.<DocBlock>emptyList());
        }
    }
View Full Code Here

@TargetOperator(Branch.class)
public class BranchFlowProcessor extends LineEndProcessor {

    @Override
    public void emitLineEnd(Context context) {
        ModelFactory f = context.getModelFactory();
        Expression input = context.getInput();
        Expression impl = context.createImplementation();
        OperatorDescription desc = context.getOperatorDescription();

        Method method = desc.getDeclaration().toMethod();
        assert method != null : desc.getDeclaration();
        Class<?> enumType = method.getReturnType();

        List<Expression> arguments = Lists.create();
        arguments.add(input);
        for (OperatorDescription.Parameter param : desc.getParameters()) {
            arguments.add(Models.toLiteral(f, param.getValue()));
        }
        Expression result = context.createLocalVariable(
                enumType,
                new ExpressionBuilder(f, impl)
                    .method(desc.getDeclaration().getName(), arguments)
                    .toExpression());
        List<Tuple2<Enum<?>, FlowElementPortDescription>> constants =
            EnumUtil.extractConstants(enumType, desc.getOutputPorts());

        List<Statement> cases = Lists.create();
        for (Tuple2<Enum<?>, FlowElementPortDescription> tuple : constants) {
            Enum<?> constant = tuple.first;
            FlowElementPortDescription port = tuple.second;
            ResultMirror next = context.getOutput(port);
            cases.add(f.newSwitchCaseLabel(f.newSimpleName(constant.name())));
            cases.add(next.createAdd(input));
            cases.add(f.newBreakStatement());
        }
        cases.add(f.newSwitchDefaultLabel());
        cases.add(new TypeBuilder(f, context.convert(AssertionError.class))
            .newObject(result)
            .toThrowStatement());
        context.add(f.newSwitchStatement(result, cases));
    }
View Full Code Here

@TargetOperator(Logging.class)
public class LoggingFlowProcessor extends LinePartProcessor {

    @Override
    public void emitLinePart(Context context) {
        ModelFactory f = context.getModelFactory();
        Expression input = context.getInput();
        Expression impl = context.createImplementation();
        OperatorDescription desc = context.getOperatorDescription();

        List<Expression> arguments = Lists.create();
View Full Code Here

        assert workingDirectory != null;
        assert repositories != null;
        assert serviceClassLoader != null;
        assert flowCompilerOptions != null;
        FlowCompilerConfiguration config = new FlowCompilerConfiguration();
        ModelFactory factory = Models.getModelFactory();
        config.setBatchId(batchId);
        config.setFlowId(flowId);
        config.setFactory(factory);
        config.setProcessors(new SpiFlowElementProcessorRepository());
        config.setExternals(new SpiExternalIoDescriptionProcessorRepository());
View Full Code Here

         * @param constant 定数表記の{@link FlowElementAttribute}
         * @throws IllegalArgumentException 引数に{@code null}が指定された場合
         */
        public void addAttribute(Enum<? extends FlowElementAttribute> constant) {
            Precondition.checkMustNotBeNull(constant, "constant"); //$NON-NLS-1$
            ModelFactory f = context.environment.getFactory();
            ImportBuilder ib = context.importer;
            Expression attribute = new TypeBuilder(f, ib.toType(constant.getDeclaringClass()))
                .field(constant.name())
                .toExpression();
            addAttribute(attribute);
View Full Code Here

TOP

Related Classes of com.asakusafw.utils.java.model.syntax.ModelFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.