use of org.openmuc.jasn1.ber.BerLength in project jasn1 by openmuc.
the class LoadCRLRequest method decode.
public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0;
int subCodeLength = 0;
BerTag berTag = new BerTag();
if (withTag) {
codeLength += tag.decodeAndCheck(is);
}
BerLength length = new BerLength();
codeLength += length.decode(is);
int totalLength = length.val;
if (totalLength == -1) {
subCodeLength += berTag.decode(is);
if (berTag.tagNumber == 0 && berTag.tagClass == 0 && berTag.primitive == 0) {
int nextByte = is.read();
if (nextByte != 0) {
if (nextByte == -1) {
throw new EOFException("Unexpected end of input stream.");
}
throw new IOException("Decoded sequence has wrong end of contents octets");
}
codeLength += subCodeLength + 1;
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
crl = new CertificateList();
subCodeLength += crl.decode(is, false);
subCodeLength += berTag.decode(is);
}
int nextByte = is.read();
if (berTag.tagNumber != 0 || berTag.tagClass != 0 || berTag.primitive != 0 || nextByte != 0) {
if (nextByte == -1) {
throw new EOFException("Unexpected end of input stream.");
}
throw new IOException("Decoded sequence has wrong end of contents octets");
}
codeLength += subCodeLength + 1;
return codeLength;
}
codeLength += totalLength;
subCodeLength += berTag.decode(is);
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
crl = new CertificateList();
subCodeLength += crl.decode(is, false);
if (subCodeLength == totalLength) {
return codeLength;
}
}
throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
}
use of org.openmuc.jasn1.ber.BerLength in project jasn1 by openmuc.
the class BerClassWriter method writeSequenceOrSetOfDecodeFunction.
private void writeSequenceOrSetOfDecodeFunction(AsnElementType componentType, String classNameOfSequenceOfElement, boolean hasExplicitTag, boolean isSequence) throws IOException {
Tag componentTag = getTag(componentType);
write("public int decode(InputStream is, boolean withTag) throws IOException {");
write("int codeLength = 0;");
write("int subCodeLength = 0;");
if (componentTag != null || supportIndefiniteLength) {
write("BerTag berTag = new BerTag();");
}
write("if (withTag) {");
write("codeLength += tag.decodeAndCheck(is);");
write("}\n");
write("BerLength length = new BerLength();");
write("codeLength += length.decode(is);");
write("int totalLength = length.val;\n");
if (supportIndefiniteLength) {
writeSequenceOfDecodeIndefiniteLenghtPart(componentType, classNameOfSequenceOfElement, hasExplicitTag);
}
if (hasExplicitTag) {
write("int nextByte = is.read();");
write("if (nextByte == -1) {");
write("throw new EOFException(\"Unexpected end of input stream.\");");
write("}");
if (isSequence) {
write("if (nextByte != (0x30)) {");
} else {
write("if (nextByte != (0x31)) {");
}
write("throw new IOException(\"Tag does not match!\");");
write("}");
write("length.decode(is);");
write("totalLength = length.val;\n");
}
write("while (subCodeLength < totalLength) {");
write(classNameOfSequenceOfElement + " element = new " + classNameOfSequenceOfElement + "();");
String explicitEncoding = getExplicitDecodingParameter(componentType);
if (componentTag != null) {
if (componentTag.type == TagType.EXPLICIT) {
write("subCodeLength += berTag.decode(is);");
write("subCodeLength += length.decode(is);");
explicitEncoding = ", true";
} else {
write("subCodeLength += berTag.decode(is);");
if (isDirectAnyOrChoice(componentType)) {
explicitEncoding = ", berTag";
} else {
explicitEncoding = ", false";
}
}
write("subCodeLength += element.decode(is" + explicitEncoding + ");");
} else {
if (isDirectAnyOrChoice(componentType)) {
write("subCodeLength += element.decode(is, null);");
} else {
write("subCodeLength += element.decode(is, true);");
}
}
write("seqOf.add(element);");
write("}");
write("if (subCodeLength != totalLength) {");
write("throw new IOException(\"Decoded SequenceOf or SetOf has wrong length. Expected \" + totalLength + \" but has \" + subCodeLength);\n");
write("}");
write("codeLength += subCodeLength;\n");
write("return codeLength;");
write("}\n");
}
use of org.openmuc.jasn1.ber.BerLength in project jasn1 by openmuc.
the class BerClassWriter method writeSequenceDecodeFunction.
private void writeSequenceDecodeFunction(List<AsnElementType> componentTypes, boolean hasExplicitTag) throws IOException {
write("public int decode(InputStream is, boolean withTag) throws IOException {");
write("int codeLength = 0;");
write("int subCodeLength = 0;");
write("BerTag berTag = new BerTag();\n");
write("if (withTag) {");
write("codeLength += tag.decodeAndCheck(is);");
write("}\n");
write("BerLength length = new BerLength();");
write("codeLength += length.decode(is);\n");
write("int totalLength = length.val;");
if (supportIndefiniteLength == true) {
writeSequenceDecodeIndefiniteLenghtPart(componentTypes);
}
write("codeLength += totalLength;\n");
if (hasExplicitTag) {
write("int nextByte = is.read();");
write("if (nextByte == -1) {");
write("throw new EOFException(\"Unexpected end of input stream.\");");
write("}");
write("if (nextByte != (0x30)) {");
write("throw new IOException(\"Tag does not match!\");");
write("}");
write("length.decode(is);");
write("totalLength = length.val;\n");
}
int lastNoneOptionalFieldIndex = -1;
for (int j = 0; j < componentTypes.size(); j++) {
AsnElementType componentType = componentTypes.get(componentTypes.size() - 1 - j);
if (!isOptional(componentType)) {
lastNoneOptionalFieldIndex = componentTypes.size() - 1 - j;
break;
}
}
if (lastNoneOptionalFieldIndex == -1) {
write("if (totalLength == 0) {");
write("return codeLength;");
write("}");
}
write("subCodeLength += berTag.decode(is);");
String initChoiceDecodeLength = "int ";
for (int j = 0; j < componentTypes.size(); j++) {
AsnElementType componentType = componentTypes.get(j);
String explicitEncoding = getExplicitDecodingParameter(componentType);
Tag componentTag = getTag(componentType);
if (componentTag != null) {
write("if (berTag.equals(" + getBerTagParametersString(componentTag) + ")) {");
if (isExplicit(componentTag)) {
write("subCodeLength += length.decode(is);");
}
write(getName(componentType) + " = new " + getClassNameOfComponent(componentType) + "();");
write("subCodeLength += " + getName(componentType) + ".decode(is" + explicitEncoding + ");");
if (lastNoneOptionalFieldIndex <= j) {
write("if (subCodeLength == totalLength) {");
write("return codeLength;");
write("}");
}
if (j != (componentTypes.size() - 1)) {
write("subCodeLength += berTag.decode(is);");
}
write("}");
if (j == (componentTypes.size() - 1)) {
write("throw new IOException(\"Unexpected end of sequence, length tag: \" + totalLength + \", actual sequence length: \" + subCodeLength);\n");
} else if (!isOptional(componentType)) {
write("else {");
write("throw new IOException(\"Tag does not match the mandatory sequence element tag.\");");
write("}");
}
} else {
if (isDirectAnyOrChoice(componentType)) {
write(getName(componentType) + " = new " + getClassNameOfComponent(componentType) + "();");
if (isOptional(componentType)) {
write(initChoiceDecodeLength + "choiceDecodeLength = " + getName(componentType) + ".decode(is" + explicitEncoding + ");");
initChoiceDecodeLength = "";
if (j != (componentTypes.size() - 1)) {
write("if (choiceDecodeLength != 0) {");
write("subCodeLength += choiceDecodeLength;");
if (lastNoneOptionalFieldIndex <= j) {
write("if (subCodeLength == totalLength) {");
write("return codeLength;");
write("}");
}
write("subCodeLength += berTag.decode(is);");
write("}");
write("else {");
write(getName(componentType) + " = null;");
write("}");
} else {
// if last sequence element
write("subCodeLength += choiceDecodeLength;");
write("if (subCodeLength == totalLength) {");
write("return codeLength;");
write("}");
}
} else {
write("subCodeLength += " + getName(componentType) + ".decode(is" + explicitEncoding + ");");
if (j != (componentTypes.size() - 1)) {
if (lastNoneOptionalFieldIndex <= j) {
write("if (subCodeLength == totalLength) {");
write("return codeLength;");
write("}");
}
write("subCodeLength += berTag.decode(is);");
} else {
write("if (subCodeLength == totalLength) {");
write("return codeLength;");
write("}");
}
}
if (j == (componentTypes.size() - 1)) {
write("throw new IOException(\"Unexpected end of sequence, length tag: \" + totalLength + \", actual sequence length: \" + subCodeLength);\n");
}
} else {
write("if (berTag.equals(" + getClassNameOfComponent(componentType) + ".tag)) {");
write(getName(componentType) + " = new " + getClassNameOfComponent(componentType) + "();");
write("subCodeLength += " + getName(componentType) + ".decode(is" + explicitEncoding + ");");
if (lastNoneOptionalFieldIndex <= j) {
write("if (subCodeLength == totalLength) {");
write("return codeLength;");
write("}");
}
if (j != (componentTypes.size() - 1)) {
write("subCodeLength += berTag.decode(is);");
}
write("}");
if (j == (componentTypes.size() - 1)) {
write("throw new IOException(\"Unexpected end of sequence, length tag: \" + totalLength + \", actual sequence length: \" + subCodeLength);\n");
} else if (!isOptional(componentType)) {
write("else {");
write("throw new IOException(\"Tag does not match the mandatory sequence element tag.\");");
write("}");
}
}
}
write("");
}
if (componentTypes.isEmpty()) {
write("return subCodeLength;");
}
write("}\n");
}
use of org.openmuc.jasn1.ber.BerLength in project jasn1 by openmuc.
the class BerClassWriter method writeChoiceDecodeFunction.
private void writeChoiceDecodeFunction(List<AsnElementType> componentTypes, boolean hasExplicitTag) throws IOException {
if (hasExplicitTag) {
writeSimpleDecodeFunction("true");
write("public int decode(InputStream is, boolean withTag) throws IOException {");
write("int codeLength = 0;");
write("BerLength length = new BerLength();");
write("BerTag berTag = new BerTag();\n");
write("if (withTag) {");
write("codeLength += tag.decodeAndCheck(is);");
write("}\n");
write("codeLength += length.decode(is);");
write("codeLength += berTag.decode(is);\n");
} else {
writeSimpleDecodeFunction("null");
write("public int decode(InputStream is, BerTag berTag) throws IOException {\n");
write("int codeLength = 0;");
write("BerTag passedTag = berTag;\n");
write("if (berTag == null) {");
write("berTag = new BerTag();");
write("codeLength += berTag.decode(is);");
write("}\n");
}
// TODO rename "choiceDecodeLength" because it could also be of type ANY
String initChoiceDecodeLength = "int ";
for (int j = 0; j < componentTypes.size(); j++) {
AsnElementType componentType = componentTypes.get(j);
String explicitEncoding = getExplicitDecodingParameter(componentType);
Tag componentTag = getTag(componentType);
if (componentTag != null) {
write("if (berTag.equals(" + getBerTagParametersString(componentTag) + ")) {");
if (componentTag.type == TagType.EXPLICIT) {
write("codeLength += BerLength.skip(is);");
}
write(getName(componentType) + " = new " + getClassNameOfComponent(componentType) + "();");
write("codeLength += " + getName(componentType) + ".decode(is" + explicitEncoding + ");");
write("return codeLength;");
write("}\n");
} else {
if (isDirectAnyOrChoice(componentType)) {
write(getName(componentType) + " = new " + getClassNameOfComponent(componentType) + "();");
write(initChoiceDecodeLength + "choiceDecodeLength = " + getName(componentType) + ".decode(is" + explicitEncoding + ");");
initChoiceDecodeLength = "";
write("if (choiceDecodeLength != 0) {");
write("return codeLength + choiceDecodeLength;");
write("}");
write("else {");
write(getName(componentType) + " = null;");
write("}\n");
} else {
write("if (berTag.equals(" + getClassNameOfComponent(componentType) + ".tag)) {");
write(getName(componentType) + " = new " + getClassNameOfComponent(componentType) + "();");
write("codeLength += " + getName(componentType) + ".decode(is" + explicitEncoding + ");");
write("return codeLength;");
write("}\n");
}
}
}
if (!hasExplicitTag) {
write("if (passedTag != null) {");
write("return 0;");
write("}\n");
}
write("throw new IOException(\"Error decoding CHOICE: Tag \" + berTag + \" matched to no item.\");");
write("}\n");
}
use of org.openmuc.jasn1.ber.BerLength in project jasn1 by openmuc.
the class PersonnelRecord method decode.
public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0;
int subCodeLength = 0;
BerTag berTag = new BerTag();
if (withTag) {
codeLength += tag.decodeAndCheck(is);
}
BerLength length = new BerLength();
codeLength += length.decode(is);
int totalLength = length.val;
if (totalLength == -1) {
subCodeLength += berTag.decode(is);
if (berTag.tagNumber == 0 && berTag.tagClass == 0 && berTag.primitive == 0) {
int nextByte = is.read();
if (nextByte != 0) {
if (nextByte == -1) {
throw new EOFException("Unexpected end of input stream.");
}
throw new IOException("Decoded sequence has wrong end of contents octets");
}
codeLength += subCodeLength + 1;
return codeLength;
}
if (berTag.equals(Name.tag)) {
name = new Name();
subCodeLength += name.decode(is, false);
subCodeLength += berTag.decode(is);
}
if (berTag.tagNumber == 0 && berTag.tagClass == 0 && berTag.primitive == 0) {
int nextByte = is.read();
if (nextByte != 0) {
if (nextByte == -1) {
throw new EOFException("Unexpected end of input stream.");
}
throw new IOException("Decoded sequence has wrong end of contents octets");
}
codeLength += subCodeLength + 1;
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
title = new BerVisibleString();
subCodeLength += title.decode(is, false);
subCodeLength += berTag.decode(is);
}
if (berTag.tagNumber == 0 && berTag.tagClass == 0 && berTag.primitive == 0) {
int nextByte = is.read();
if (nextByte != 0) {
if (nextByte == -1) {
throw new EOFException("Unexpected end of input stream.");
}
throw new IOException("Decoded sequence has wrong end of contents octets");
}
codeLength += subCodeLength + 1;
return codeLength;
}
if (berTag.equals(org.openmuc.jasn1.compiler.modules.module2.EmployeeNumberZ.tag)) {
number = new org.openmuc.jasn1.compiler.modules.module2.EmployeeNumberZ();
subCodeLength += number.decode(is, false);
subCodeLength += berTag.decode(is);
}
if (berTag.tagNumber == 0 && berTag.tagClass == 0 && berTag.primitive == 0) {
int nextByte = is.read();
if (nextByte != 0) {
if (nextByte == -1) {
throw new EOFException("Unexpected end of input stream.");
}
throw new IOException("Decoded sequence has wrong end of contents octets");
}
codeLength += subCodeLength + 1;
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
dateOfHire = new Date();
subCodeLength += dateOfHire.decode(is, false);
subCodeLength += berTag.decode(is);
}
if (berTag.tagNumber == 0 && berTag.tagClass == 0 && berTag.primitive == 0) {
int nextByte = is.read();
if (nextByte != 0) {
if (nextByte == -1) {
throw new EOFException("Unexpected end of input stream.");
}
throw new IOException("Decoded sequence has wrong end of contents octets");
}
codeLength += subCodeLength + 1;
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
nameOfSpouse = new Name();
subCodeLength += nameOfSpouse.decode(is, false);
subCodeLength += berTag.decode(is);
}
if (berTag.tagNumber == 0 && berTag.tagClass == 0 && berTag.primitive == 0) {
int nextByte = is.read();
if (nextByte != 0) {
if (nextByte == -1) {
throw new EOFException("Unexpected end of input stream.");
}
throw new IOException("Decoded sequence has wrong end of contents octets");
}
codeLength += subCodeLength + 1;
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 3)) {
children = new Children();
subCodeLength += children.decode(is, false);
subCodeLength += berTag.decode(is);
}
if (berTag.tagNumber == 0 && berTag.tagClass == 0 && berTag.primitive == 0) {
int nextByte = is.read();
if (nextByte != 0) {
if (nextByte == -1) {
throw new EOFException("Unexpected end of input stream.");
}
throw new IOException("Decoded sequence has wrong end of contents octets");
}
codeLength += subCodeLength + 1;
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 4)) {
testBitString = new MyBitString();
subCodeLength += testBitString.decode(is, false);
subCodeLength += berTag.decode(is);
}
if (berTag.tagNumber == 0 && berTag.tagClass == 0 && berTag.primitive == 0) {
int nextByte = is.read();
if (nextByte != 0) {
if (nextByte == -1) {
throw new EOFException("Unexpected end of input stream.");
}
throw new IOException("Decoded sequence has wrong end of contents octets");
}
codeLength += subCodeLength + 1;
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 6)) {
test = new MyInt();
subCodeLength += test.decode(is, false);
subCodeLength += berTag.decode(is);
}
if (berTag.tagNumber == 0 && berTag.tagClass == 0 && berTag.primitive == 0) {
int nextByte = is.read();
if (nextByte != 0) {
if (nextByte == -1) {
throw new EOFException("Unexpected end of input stream.");
}
throw new IOException("Decoded sequence has wrong end of contents octets");
}
codeLength += subCodeLength + 1;
return codeLength;
}
test2 = new TestChoice();
int choiceDecodeLength = test2.decode(is, berTag);
if (choiceDecodeLength != 0) {
subCodeLength += choiceDecodeLength;
subCodeLength += berTag.decode(is);
} else {
test2 = null;
}
if (berTag.tagNumber == 0 && berTag.tagClass == 0 && berTag.primitive == 0) {
int nextByte = is.read();
if (nextByte != 0) {
if (nextByte == -1) {
throw new EOFException("Unexpected end of input stream.");
}
throw new IOException("Decoded sequence has wrong end of contents octets");
}
codeLength += subCodeLength + 1;
return codeLength;
}
test3 = new TestChoice();
choiceDecodeLength = test3.decode(is, berTag);
if (choiceDecodeLength != 0) {
subCodeLength += choiceDecodeLength;
subCodeLength += berTag.decode(is);
} else {
test3 = null;
}
if (berTag.tagNumber == 0 && berTag.tagClass == 0 && berTag.primitive == 0) {
int nextByte = is.read();
if (nextByte != 0) {
if (nextByte == -1) {
throw new EOFException("Unexpected end of input stream.");
}
throw new IOException("Decoded sequence has wrong end of contents octets");
}
codeLength += subCodeLength + 1;
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 8)) {
subCodeLength += length.decode(is);
test4 = new TestChoice();
choiceDecodeLength = test4.decode(is, null);
if (choiceDecodeLength != 0) {
subCodeLength += choiceDecodeLength;
subCodeLength += berTag.decode(is);
} else {
test4 = null;
}
}
if (berTag.tagNumber == 0 && berTag.tagClass == 0 && berTag.primitive == 0) {
int nextByte = is.read();
if (nextByte != 0) {
if (nextByte == -1) {
throw new EOFException("Unexpected end of input stream.");
}
throw new IOException("Decoded sequence has wrong end of contents octets");
}
codeLength += subCodeLength + 1;
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 9)) {
subCodeLength += length.decode(is);
test5 = new TestChoice();
choiceDecodeLength = test5.decode(is, null);
if (choiceDecodeLength != 0) {
subCodeLength += choiceDecodeLength;
subCodeLength += berTag.decode(is);
} else {
test5 = null;
}
}
if (berTag.tagNumber == 0 && berTag.tagClass == 0 && berTag.primitive == 0) {
int nextByte = is.read();
if (nextByte != 0) {
if (nextByte == -1) {
throw new EOFException("Unexpected end of input stream.");
}
throw new IOException("Decoded sequence has wrong end of contents octets");
}
codeLength += subCodeLength + 1;
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 10)) {
subCodeLength += length.decode(is);
test6 = new TestChoice();
choiceDecodeLength = test6.decode(is, null);
if (choiceDecodeLength != 0) {
subCodeLength += choiceDecodeLength;
subCodeLength += berTag.decode(is);
} else {
test6 = null;
}
}
if (berTag.tagNumber == 0 && berTag.tagClass == 0 && berTag.primitive == 0) {
int nextByte = is.read();
if (nextByte != 0) {
if (nextByte == -1) {
throw new EOFException("Unexpected end of input stream.");
}
throw new IOException("Decoded sequence has wrong end of contents octets");
}
codeLength += subCodeLength + 1;
return codeLength;
}
employeeNumberZ = new EmployeeNumberZ();
choiceDecodeLength = employeeNumberZ.decode(is, berTag);
if (choiceDecodeLength != 0) {
subCodeLength += choiceDecodeLength;
subCodeLength += berTag.decode(is);
} else {
employeeNumberZ = null;
}
if (berTag.tagNumber == 0 && berTag.tagClass == 0 && berTag.primitive == 0) {
int nextByte = is.read();
if (nextByte != 0) {
if (nextByte == -1) {
throw new EOFException("Unexpected end of input stream.");
}
throw new IOException("Decoded sequence has wrong end of contents octets");
}
codeLength += subCodeLength + 1;
return codeLength;
}
if (berTag.equals(BerVisibleString.tag)) {
code_ = new BerVisibleString();
subCodeLength += code_.decode(is, false);
subCodeLength += berTag.decode(is);
}
if (berTag.tagNumber == 0 && berTag.tagClass == 0 && berTag.primitive == 0) {
int nextByte = is.read();
if (nextByte != 0) {
if (nextByte == -1) {
throw new EOFException("Unexpected end of input stream.");
}
throw new IOException("Decoded sequence has wrong end of contents octets");
}
codeLength += subCodeLength + 1;
return codeLength;
}
if (berTag.equals(TestSequenceOf.tag)) {
testSequenceOf = new TestSequenceOf();
subCodeLength += testSequenceOf.decode(is, false);
subCodeLength += berTag.decode(is);
}
if (berTag.tagNumber == 0 && berTag.tagClass == 0 && berTag.primitive == 0) {
int nextByte = is.read();
if (nextByte != 0) {
if (nextByte == -1) {
throw new EOFException("Unexpected end of input stream.");
}
throw new IOException("Decoded sequence has wrong end of contents octets");
}
codeLength += subCodeLength + 1;
return codeLength;
}
if (berTag.equals(TestSequenceOf2.tag)) {
testSequenceOf2 = new TestSequenceOf2();
subCodeLength += testSequenceOf2.decode(is, false);
subCodeLength += berTag.decode(is);
}
if (berTag.tagNumber == 0 && berTag.tagClass == 0 && berTag.primitive == 0) {
int nextByte = is.read();
if (nextByte != 0) {
if (nextByte == -1) {
throw new EOFException("Unexpected end of input stream.");
}
throw new IOException("Decoded sequence has wrong end of contents octets");
}
codeLength += subCodeLength + 1;
return codeLength;
}
if (berTag.equals(BerEmbeddedPdv.tag)) {
embeddedPdv = new BerEmbeddedPdv();
subCodeLength += embeddedPdv.decode(is, false);
subCodeLength += berTag.decode(is);
}
int nextByte = is.read();
if (berTag.tagNumber != 0 || berTag.tagClass != 0 || berTag.primitive != 0 || nextByte != 0) {
if (nextByte == -1) {
throw new EOFException("Unexpected end of input stream.");
}
throw new IOException("Decoded sequence has wrong end of contents octets");
}
codeLength += subCodeLength + 1;
return codeLength;
}
codeLength += totalLength;
subCodeLength += berTag.decode(is);
if (berTag.equals(Name.tag)) {
name = new Name();
subCodeLength += name.decode(is, false);
subCodeLength += berTag.decode(is);
} else {
throw new IOException("Tag does not match the mandatory sequence element tag.");
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
title = new BerVisibleString();
subCodeLength += title.decode(is, false);
subCodeLength += berTag.decode(is);
} else {
throw new IOException("Tag does not match the mandatory sequence element tag.");
}
if (berTag.equals(org.openmuc.jasn1.compiler.modules.module2.EmployeeNumberZ.tag)) {
number = new org.openmuc.jasn1.compiler.modules.module2.EmployeeNumberZ();
subCodeLength += number.decode(is, false);
subCodeLength += berTag.decode(is);
} else {
throw new IOException("Tag does not match the mandatory sequence element tag.");
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
dateOfHire = new Date();
subCodeLength += dateOfHire.decode(is, false);
subCodeLength += berTag.decode(is);
} else {
throw new IOException("Tag does not match the mandatory sequence element tag.");
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
nameOfSpouse = new Name();
subCodeLength += nameOfSpouse.decode(is, false);
subCodeLength += berTag.decode(is);
} else {
throw new IOException("Tag does not match the mandatory sequence element tag.");
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 3)) {
children = new Children();
subCodeLength += children.decode(is, false);
subCodeLength += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 4)) {
testBitString = new MyBitString();
subCodeLength += testBitString.decode(is, false);
subCodeLength += berTag.decode(is);
} else {
throw new IOException("Tag does not match the mandatory sequence element tag.");
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 6)) {
test = new MyInt();
subCodeLength += test.decode(is, false);
subCodeLength += berTag.decode(is);
} else {
throw new IOException("Tag does not match the mandatory sequence element tag.");
}
test2 = new TestChoice();
int choiceDecodeLength = test2.decode(is, berTag);
if (choiceDecodeLength != 0) {
subCodeLength += choiceDecodeLength;
subCodeLength += berTag.decode(is);
} else {
test2 = null;
}
test3 = new TestChoice();
subCodeLength += test3.decode(is, berTag);
subCodeLength += berTag.decode(is);
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 8)) {
subCodeLength += length.decode(is);
test4 = new TestChoice();
subCodeLength += test4.decode(is, null);
subCodeLength += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 9)) {
subCodeLength += length.decode(is);
test5 = new TestChoice();
subCodeLength += test5.decode(is, null);
subCodeLength += berTag.decode(is);
} else {
throw new IOException("Tag does not match the mandatory sequence element tag.");
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 10)) {
subCodeLength += length.decode(is);
test6 = new TestChoice();
subCodeLength += test6.decode(is, null);
subCodeLength += berTag.decode(is);
} else {
throw new IOException("Tag does not match the mandatory sequence element tag.");
}
employeeNumberZ = new EmployeeNumberZ();
choiceDecodeLength = employeeNumberZ.decode(is, berTag);
if (choiceDecodeLength != 0) {
subCodeLength += choiceDecodeLength;
subCodeLength += berTag.decode(is);
} else {
employeeNumberZ = null;
}
if (berTag.equals(BerVisibleString.tag)) {
code_ = new BerVisibleString();
subCodeLength += code_.decode(is, false);
subCodeLength += berTag.decode(is);
} else {
throw new IOException("Tag does not match the mandatory sequence element tag.");
}
if (berTag.equals(TestSequenceOf.tag)) {
testSequenceOf = new TestSequenceOf();
subCodeLength += testSequenceOf.decode(is, false);
subCodeLength += berTag.decode(is);
} else {
throw new IOException("Tag does not match the mandatory sequence element tag.");
}
if (berTag.equals(TestSequenceOf2.tag)) {
testSequenceOf2 = new TestSequenceOf2();
subCodeLength += testSequenceOf2.decode(is, false);
subCodeLength += berTag.decode(is);
} else {
throw new IOException("Tag does not match the mandatory sequence element tag.");
}
if (berTag.equals(BerEmbeddedPdv.tag)) {
embeddedPdv = new BerEmbeddedPdv();
subCodeLength += embeddedPdv.decode(is, false);
if (subCodeLength == totalLength) {
return codeLength;
}
}
throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
}
Aggregations