use of org.openmuc.jasn1.compiler.model.AsnParameter in project jasn1 by openmuc.
the class BerClassWriter method writeChoiceClass.
private void writeChoiceClass(String className, AsnChoice asn1TypeElement, Tag tag, String isStaticStr, List<String> listOfSubClassNames) throws IOException {
write("public" + isStaticStr + " class " + className + " implements " + berTypeInterfaceString + "Serializable {\n");
write("private static final long serialVersionUID = 1L;\n");
write("public byte[] code = null;");
if (tag != null) {
write("public static final BerTag tag = new BerTag(" + getBerTagParametersString(tag) + ");\n");
}
List<AsnElementType> componentTypes = asn1TypeElement.componentTypes;
addAutomaticTagsIfNeeded(componentTypes);
if (asn1TypeElement.parameters != null) {
List<AsnParameter> parameters = asn1TypeElement.parameters;
replaceParamtersByAnyTypes(componentTypes, parameters);
}
for (AsnElementType componentType : componentTypes) {
if (componentType.typeReference != null && (componentType.typeReference instanceof AsnConstructedType)) {
listOfSubClassNames.add(getClassNameOfComponent(componentType));
}
}
for (AsnElementType componentType : componentTypes) {
if (isInnerType(componentType)) {
String subClassName = getClassNameOfComponent(componentType);
writeConstructedTypeClass(subClassName, componentType.typeReference, null, true, listOfSubClassNames);
}
}
setClassNamesOfComponents(listOfSubClassNames, componentTypes);
writePublicMembers(componentTypes);
writeEmptyConstructor(className);
if (!jaxbMode) {
writeEncodeConstructor(className, componentTypes);
}
if (jaxbMode) {
writeGetterAndSetter(componentTypes);
}
writeChoiceEncodeFunction(componentTypes, tag != null);
writeChoiceDecodeFunction(componentTypes, tag != null);
writeEncodeAndSaveFunction(tag == null);
writeChoiceToStringFunction(componentTypes);
write("}\n");
}
use of org.openmuc.jasn1.compiler.model.AsnParameter in project jasn1 by openmuc.
the class BerClassWriter method writeSequenceOrSetClass.
private void writeSequenceOrSetClass(String className, AsnSequenceSet asnSequenceSet, Tag tag, String isStaticStr, List<String> listOfSubClassNames) throws IOException {
write("public" + isStaticStr + " class " + className + " implements " + berTypeInterfaceString + "Serializable {\n");
write("private static final long serialVersionUID = 1L;\n");
List<AsnElementType> componentTypes = asnSequenceSet.componentTypes;
addAutomaticTagsIfNeeded(componentTypes);
if (asnSequenceSet.parameters != null) {
List<AsnParameter> parameters = asnSequenceSet.parameters;
replaceParamtersByAnyTypes(componentTypes, parameters);
}
for (AsnElementType componentType : componentTypes) {
if (componentType.typeReference != null && (componentType.typeReference instanceof AsnConstructedType)) {
listOfSubClassNames.add(getClassNameOfComponent(componentType));
}
}
for (AsnElementType componentType : componentTypes) {
if (isInnerType(componentType)) {
String subClassName = getClassNameOfComponent(componentType);
writeConstructedTypeClass(subClassName, componentType.typeReference, null, true, listOfSubClassNames);
}
}
Tag mainTag;
if (tag == null) {
if (asnSequenceSet.isSequence) {
mainTag = stdSeqTag;
} else {
mainTag = stdSetTag;
}
} else {
mainTag = tag;
}
write("public static final BerTag tag = new BerTag(" + getBerTagParametersString(mainTag) + ");\n");
write("public byte[] code = null;");
setClassNamesOfComponents(listOfSubClassNames, componentTypes);
writePublicMembers(componentTypes);
writeEmptyConstructor(className);
if (!jaxbMode) {
writeEncodeConstructor(className, componentTypes);
}
if (jaxbMode) {
writeGetterAndSetter(componentTypes);
}
boolean hasExplicitTag = (tag != null) && (tag.type == TagType.EXPLICIT);
writeSimpleEncodeFunction();
writeSequenceOrSetEncodeFunction(componentTypes, hasExplicitTag, asnSequenceSet.isSequence);
writeSimpleDecodeFunction("true");
if (asnSequenceSet.isSequence) {
writeSequenceDecodeFunction(componentTypes, hasExplicitTag);
} else {
writeSetDecodeFunction(componentTypes);
}
writeEncodeAndSaveFunction();
writeSequenceOrSetToStringFunction(componentTypes);
write("}\n");
}
use of org.openmuc.jasn1.compiler.model.AsnParameter in project jasn1 by openmuc.
the class BerClassWriter method replaceParamtersByAnyTypes.
private void replaceParamtersByAnyTypes(List<AsnElementType> componentTypes, List<AsnParameter> parameters) {
for (AsnParameter parameter : parameters) {
if (parameter.paramGovernor == null) {
for (AsnElementType componentType : componentTypes) {
if (componentType.definedType != null && componentType.definedType.typeName.equals(parameter.dummyReference)) {
componentType.typeReference = new AsnAny();
componentType.definedType = null;
componentType.isDefinedType = false;
}
}
}
}
}
Aggregations