Search in sources :

Example 6 with FieldReferenceOffsetManager

use of com.ociweb.pronghorn.pipe.FieldReferenceOffsetManager in project PronghornPipes by oci-pronghorn.

the class TemplateProcessGeneratorLowLevelReader method processSchema.

public void processSchema() throws IOException {
    final FieldReferenceOffsetManager from = MessageSchema.from(schema);
    workspacesDefinedCount = 0;
    super.processSchema();
    // place at the end the business methods which are overridden
    bodyTarget.append('\n').append('\n').append(workspace1);
}
Also used : FieldReferenceOffsetManager(com.ociweb.pronghorn.pipe.FieldReferenceOffsetManager)

Example 7 with FieldReferenceOffsetManager

use of com.ociweb.pronghorn.pipe.FieldReferenceOffsetManager in project PronghornPipes by oci-pronghorn.

the class TemplateProcessGeneratorLowLevelReader method appendFragmentName.

private Appendable appendFragmentName(Appendable target, int cursor) throws IOException {
    FieldReferenceOffsetManager from = MessageSchema.from(schema);
    if (null != from.fieldNameScript[cursor]) {
        // if this is NOT a message start then also prefix with its name
        if (Arrays.binarySearch(from.messageStarts, cursor) < 0) {
            appendMessageName(target, cursor, from);
        }
        target.append(from.fieldNameScript[cursor]);
    } else {
        // Go Up and find parent name then add cursor position to make it unique
        int msgCursor = appendMessageName(target, cursor, from);
        appendSequenceName(cursor, from, msgCursor);
        target.append("End");
    }
    return target;
}
Also used : FieldReferenceOffsetManager(com.ociweb.pronghorn.pipe.FieldReferenceOffsetManager)

Example 8 with FieldReferenceOffsetManager

use of com.ociweb.pronghorn.pipe.FieldReferenceOffsetManager in project PronghornPipes by oci-pronghorn.

the class TemplateProcessGeneratorLowLevelWriter method processCallerPrep.

@Override
protected void processCallerPrep() throws IOException {
    FieldReferenceOffsetManager from = MessageSchema.from(schema);
    if (buildFullStageWritingToPipe()) {
        from.appendGUID(bodyTarget.append("private final int[] FROM_GUID = ")).append(";\n");
    }
    bodyTarget.append("private final long BUILD_TIME = ");
    Appendables.appendValue(bodyTarget, System.currentTimeMillis()).append("L;\n");
    bodyTarget.append("private static final int ").append(doNothingConstant).append(" = ").append(doNothingConstantValue).append(";\n");
    bodyTarget.append("\n");
    bodyTarget.append(methodScope).append(" int nextMessageIdx() {\n");
    bodyOfNextMessageIdx(bodyTarget);
    bodyTarget.append("}\n\n");
    generateStartup(bodyTarget);
    bodyTarget.append("\n");
    bodyTarget.append("@Override\n");
    bodyTarget.append("public void run() {\n");
    if (buildFullStageWritingToPipe()) {
        // if (!Pipe.hasRoomForWrite(input)) {
        // return;
        // }
        appendStaticCall(bodyTarget.append(tab).append("while ("), pipeClass, "hasRoomForWrite").append(pipeVarName).append(")");
        additionalLoopLogic(bodyTarget);
        bodyTarget.append("){\n");
    }
    if (hasSimpleMessagesOnly) {
        // switch(cursor)) {
        bodyTarget.append(tab).append("switch(").append("nextMessageIdx()").append(") {\n");
    } else {
        bodyTarget.append(tab).append("int ").append(cursorVarName).append(";\n");
        bodyTarget.append("\n");
        // if (LowLevelStateManager.isStartNewMessage(navState)) {
        bodyTarget.append(tab).append("if (").append(stageMgrClassName).append(".isStartNewMessage(").append(stageMgrVarName).append(")) {\n");
        bodyTarget.append(tab).append(tab).append(cursorVarName).append(" = nextMessageIdx();\n");
        // } else {
        bodyTarget.append(tab).append("} else {\n");
        // cursor = LowLevelStateManager.activeCursor(navState);
        bodyTarget.append(tab).append(tab).append(cursorVarName).append(" = ").append(stageMgrClassName).append(".activeCursor(").append(stageMgrVarName).append(");\n");
        // }
        bodyTarget.append(tab).append("}\n");
        bodyTarget.append("\n");
        // bodyTarget.append("System.out.println(cursor);//WHYHAPPEN\n");
        // switch(cursor)) {
        bodyTarget.append(tab).append("switch(").append(cursorVarName).append(") {\n");
    }
}
Also used : FieldReferenceOffsetManager(com.ociweb.pronghorn.pipe.FieldReferenceOffsetManager)

Example 9 with FieldReferenceOffsetManager

use of com.ociweb.pronghorn.pipe.FieldReferenceOffsetManager in project PronghornPipes by oci-pronghorn.

the class TemplateProcessGeneratorLowLevelWriter method appendFragmentName.

private Appendable appendFragmentName(Appendable target, int cursor) throws IOException {
    FieldReferenceOffsetManager from = MessageSchema.from(schema);
    if (null != from.fieldNameScript[cursor]) {
        // if this is NOT a message start then also prefix with its name
        if (Arrays.binarySearch(from.messageStarts, cursor) < 0) {
            appendMessageName(target, cursor, from);
        }
        target.append(from.fieldNameScript[cursor]);
    } else {
        // Go Up and find parent name then add cursor position to make it unique
        int msgCursor = appendMessageName(target, cursor, from);
        appendSequenceName(cursor, from, msgCursor);
        target.append("End");
    }
    return target;
}
Also used : FieldReferenceOffsetManager(com.ociweb.pronghorn.pipe.FieldReferenceOffsetManager)

Example 10 with FieldReferenceOffsetManager

use of com.ociweb.pronghorn.pipe.FieldReferenceOffsetManager in project PronghornPipes by oci-pronghorn.

the class FROMValidation method testForMatchingFROMs.

private static <S extends MessageSchema<S>> boolean testForMatchingFROMs(String templateFile, S schema) {
    boolean result = false;
    StringBuilder target = new StringBuilder();
    try {
        FieldReferenceOffsetManager encodedFrom = null;
        try {
            // TODO: new projects get null pointer here, fix so they are given correct source.
            encodedFrom = MessageSchema.from(schema);
        } catch (NullPointerException npe) {
        // continue with no previous FROM
        }
        result = testForMatchingFROMs(templateFile, encodedFrom, target);
        if (!result) {
            System.out.println(target);
        }
    } catch (Exception e) {
        e.printStackTrace();
        result = false;
    }
    return result;
}
Also used : FieldReferenceOffsetManager(com.ociweb.pronghorn.pipe.FieldReferenceOffsetManager) IOException(java.io.IOException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) SAXException(org.xml.sax.SAXException)

Aggregations

FieldReferenceOffsetManager (com.ociweb.pronghorn.pipe.FieldReferenceOffsetManager)19 MessageSchemaDynamic (com.ociweb.pronghorn.pipe.MessageSchemaDynamic)5 IOException (java.io.IOException)4 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)4 SAXException (org.xml.sax.SAXException)4 Test (org.junit.Test)3 MessageSchema (com.ociweb.pronghorn.pipe.MessageSchema)2 Pipe (com.ociweb.pronghorn.pipe.Pipe)1 PipeConfig (com.ociweb.pronghorn.pipe.PipeConfig)1 TemplateProcessGeneratorLowLevelReader (com.ociweb.pronghorn.pipe.util.build.TemplateProcessGeneratorLowLevelReader)1 TemplateProcessGeneratorLowLevelWriter (com.ociweb.pronghorn.pipe.util.build.TemplateProcessGeneratorLowLevelWriter)1