use of com.ociweb.pronghorn.pipe.FieldReferenceOffsetManager in project PronghornPipes by oci-pronghorn.
the class FROMValidation method testForMatchingFROMs.
private static boolean testForMatchingFROMs(String templateFile, FieldReferenceOffsetManager encodedFrom, Appendable target) throws ParserConfigurationException, SAXException, IOException {
boolean result = true;
FieldReferenceOffsetManager expectedFrom = TemplateHandler.loadFrom(templateFile);
if (null == expectedFrom) {
logger.error("Unable to find: " + templateFile);
result = false;
} else if (null == encodedFrom || !expectedFrom.equals(encodedFrom)) {
logger.error("Encoded source:" + expectedFrom);
if (null != encodedFrom) {
logger.error("Template file:" + encodedFrom);
}
logger.error("//replacement source");
String nameOfFROM = templateFile.substring(1 + templateFile.lastIndexOf('/'));
FieldReferenceOffsetManager.buildFROMConstructionSource(target, expectedFrom, "FROM", nameOfFROM);
result = false;
}
return result;
}
use of com.ociweb.pronghorn.pipe.FieldReferenceOffsetManager in project PronghornPipes by oci-pronghorn.
the class TemplateProcessGeneratorLowLevelWriter method footerConstruction.
@Override
protected void footerConstruction() throws IOException {
final FieldReferenceOffsetManager from = MessageSchema.from(schema);
if (!from.hasSimpleMessagesOnly) {
if (!baseText.contains("Runnable")) {
bodyTarget.append("@Override\n");
}
bodyTarget.append("public void startup() {\n");
bodyTarget.append(tab).append("navState").append(" = new ");
bodyTarget.append(LowLevelStateManager.class.getSimpleName()).append("(");
if (buildFullStageWritingToPipe()) {
bodyTarget.append(pipeClass.getSimpleName()).append(".from(").append(pipeVarName).append(")");
} else {
if (!(schema instanceof MessageSchemaDynamic)) {
bodyTarget.append(schema.getClass().getSimpleName()).append(".");
}
bodyTarget.append("FROM");
}
bodyTarget.append(");\n");
bodyTarget.append("}\n");
}
additionalMethods(bodyTarget);
bodyTarget.append("};\n");
}
use of com.ociweb.pronghorn.pipe.FieldReferenceOffsetManager in project PronghornPipes by oci-pronghorn.
the class TemplateProcessGeneratorLowLevelWriter method processCaller.
// TODO: Solution to mutation of method names,
// Add annotation to every method we wish to use, have annotation record method name in lookup table with immutable constant id
// When we use the method names for code generation look them up from the immutable constant id.
@Override
protected void processCaller(int cursor) throws IOException {
FieldReferenceOffsetManager from = MessageSchema.from(schema);
appendCaseMsgIdConstant(bodyTarget.append(tab).append(tab).append("case "), cursor, schema).append(":\n");
if (FieldReferenceOffsetManager.isTemplateStart(from, cursor)) {
beginMessage(bodyTarget, cursor);
}
bodyTarget.append(tab).append(tab).append(tab);
appendBusinessMethodName(cursor).append("();\n");
// Pipe.confirmLowLevelWrite(input, 8);
int fragmentSizeLiteral = from.fragDataSize[cursor];
if (buildFullStageWritingToPipe()) {
appendStaticCall(bodyTarget.append(tab).append(tab).append(tab), pipeClass, "confirmLowLevelWrite").append(pipeVarName).append(", ");
Appendables.appendValue(bodyTarget, fragmentSizeLiteral);
bodyTarget.append("/* fragment ");
Appendables.appendValue(bodyTarget, cursor).append(" size ");
Appendables.appendValue(bodyTarget, from.fragScriptSize[cursor]);
bodyTarget.append("*/);\n");
}
bodyTarget.append(tab).append(tab).append("break;\n");
}
use of com.ociweb.pronghorn.pipe.FieldReferenceOffsetManager in project PronghornPipes by oci-pronghorn.
the class TemplateProcessGeneratorLowLevelWriter method defineMembers.
protected void defineMembers() throws IOException {
final FieldReferenceOffsetManager from = MessageSchema.from(schema);
if (!from.hasSimpleMessagesOnly) {
bodyTarget.append("private ").append(LowLevelStateManager.class.getSimpleName()).append(" navState;\n");
}
if (buildFullStageWritingToPipe()) {
appendClass(bodyTarget.append("private "), pipeClass, schema.getClass()).append(pipeVarName).append(";\n");
}
additionalMembers(bodyTarget);
from.appendConstuctionSource(bodyTarget);
}
use of com.ociweb.pronghorn.pipe.FieldReferenceOffsetManager in project PronghornPipes by oci-pronghorn.
the class TemplateProcessGeneratorLowLevelReader method processCaller.
@Override
protected void processCaller(int cursor) throws IOException {
FieldReferenceOffsetManager from = MessageSchema.from(schema);
bodyTarget.append(tab).append(tab).append("case ");
appendMessageIdentifier(cursor, schema);
bodyTarget.append(":\n");
bodyTarget.append(tab).append(tab).append(tab);
appendInternalMethodName(cursor).append("();\n");
// Pipe.confirmLowLevelRead(input, 8);
int fragmentSizeLiteral = from.fragDataSize[cursor];
appendStaticCall(bodyTarget.append(tab).append(tab).append(tab), pipeClass, "confirmLowLevelRead").append(pipeVarName).append(", ").append(Integer.toString(fragmentSizeLiteral)).append(" /* fragment size */);\n");
bodyTarget.append(tab).append(tab).append("break;\n");
}
Aggregations