/** * Set the parser flags for the generated class, by default the flags are * imported from the base parser. * * @param value parser flags. * @return the builder instance, must not be null */ public Builder setParserFlags(final int value) { assertNonLocked(); this.parserFlags = value; return this; }
@Override public void visitItems(JBBPCompiledBlock block, int currentCompiledBlockOffset, ExpressionEvaluatorVisitor visitor) { visitor.visitStart(); visitor.visitConstant(this.value); visitor.visitEnd(); }
static FieldType findForCode(final int code) { for (final FieldType t : values()) { if (t.code == code) { return t; } } return UNKNOWN; }
private void processSkipRemainingFlag() { if (this.isFlagSkipRemainingFieldsIfEOF()) { this.getCurrentStruct().getReadFunc().indent().println(String.format("if (!%s.hasAvailableData()) return this;", NAME_INPUT_STREAM)); } }
private void processSkipRemainingFlagForWriting(final String structFieldName) { if (this.isFlagSkipRemainingFieldsIfEOF()) { this.getCurrentStruct().getWriteFunc().indent().println(String.format("if (%s == null) return this;", structFieldName)); } }
private void registerNamedField(final JBBPNamedFieldInfo fieldInfo, final FieldType fieldType) { if (fieldInfo != null) { if (this.foundNamedFields.containsKey(fieldInfo)) { throw new Error("Detected duplication of named field : " + fieldInfo); } this.foundNamedFields.put(fieldInfo, new NamedFieldInfo(fieldInfo, this.getCurrentStruct(), fieldType)); } }
private void registerGetterSetter(final String fieldType, final String fieldName, final boolean makeSetter) { if (!this.getCurrentStruct().getGettersSetters().isEmpty()) { this.getCurrentStruct().getGettersSetters().println(); } if (makeSetter) { this.getCurrentStruct().getGettersSetters().indent().printf("public void set%s(%s value) { this.%s = value;}%n", fieldName.toUpperCase(Locale.ENGLISH), fieldType, fieldName); } this.getCurrentStruct().getGettersSetters().indent().printf("public %s get%s() { return this.%s;}%n", fieldType, fieldName.toUpperCase(Locale.ENGLISH), fieldName); }
String asJavaSingleFieldType() { assertNotUnknown(); return this.javaSingleType; }
/** * Make new builder. * * @param parser parser instance to be used as the base for translation, must * not be null * @return the new builder instance, must not be null. */ public static Builder makeBuilder(final JBBPParser parser) { return new Builder(parser); }
Struct findRoot() { if (this.parent == null) { return this; } return this.parent.findRoot(); }
/** * Set commentaries placed just before first package directive of the * generated class. * * @param text text to be used as comment, it can be null * @return the builder instance, must not be null */ public Builder setHeadComment(final String text) { assertNonLocked(); this.headComment = text; return this; }
String asJavaArrayFieldType() { assertNotUnknown(); return this.javaArrayType; }
/** * Set flag to force abstract modifier for the generated class, by default * the class is abstract one only if it contains abstract methods. * * @param value true if to force the abstract modifier, false otherwise * @return the builder instance, must not be null */ public Builder setDoMainClassAbstract(final boolean value) { assertNonLocked(); this.doMainClassAbstract = value; return this; }
/** * Don't make insternal generated classes as static ones * * @return the builder instance, must not be null * @since 1.4.0 */ public Builder doInternalClassesNonStatic() { assertNonLocked(); this.internalClassesNotStatic = true; return this; }
/** * Set the package for the generated class. * * @param value name of the package, it can be empty or null in the case the * class will be in the default package * @return the builder instance, must not be null */ public Builder setMainClassPackage(final String value) { assertNonLocked(); this.mainClassPackage = value; return this; }
/** * The Name of the generated class. Must be provided. * * @param value the class name for the generated class, must not be null * @return the builder instance, must not be null */ public Builder setMainClassName(final String value) { assertNonLocked(); this.mainClassName = value; return this; }
/** * Set custom text, the text will be added into the end of the result class. * * @param value text value, it can be null * @return the builder instance, must not be null */ public Builder setMainClassCustomText(final String value) { assertNonLocked(); this.mainClassCustomText = value; return this; }
/** * Set flag to generate getters setters. <b>NB! All fields will be private * ones in the case.</b> * * @param value flag, if true then generate getters setters, false otherwise * @return the builder instance, must not be null */ public Builder setAddGettersSetters(final boolean value) { assertNonLocked(); this.addGettersSetters = value; return this; }
/** * Set the superclass for the main generated class. <b>NB! Also it affects * read and write methods of the main class, the class will be used as the * return type.</b> * * @param value the superclass name, it can be null * @return the builder instance, must not be null */ public Builder setSuperClass(final String value) { assertNonLocked(); this.superClass = value; return this; }