public int decode(InputStream iStream, boolean explicit) throws IOException { int codeLength = 0; int subCodeLength = 0; int choiceDecodeLength = 0; BerIdentifier berIdentifier = new BerIdentifier(); boolean decodedIdentifier = false; if (explicit) { codeLength += id.decodeAndCheck(iStream); } BerLength length = new BerLength(); codeLength += length.decode(iStream); if (subCodeLength < length.val) { if (decodedIdentifier == false) { subCodeLength += berIdentifier.decode(iStream); decodedIdentifier = true; } if (berIdentifier.equals(BerInteger.identifier)) { invokeID = new BerInteger(); subCodeLength += invokeID.decode(iStream, false); decodedIdentifier = false; } else { throw new IOException("Identifier does not macht required sequence element identifer."); } } if (subCodeLength < length.val) { if (decodedIdentifier == false) { subCodeLength += berIdentifier.decode(iStream); decodedIdentifier = true; } confirmedServiceRequest = new ConfirmedServiceRequest(); choiceDecodeLength = confirmedServiceRequest.decode(iStream, berIdentifier); if (choiceDecodeLength != 0) { decodedIdentifier = false; subCodeLength += choiceDecodeLength; } } if (subCodeLength != length.val) { throw new IOException("Decoded sequence has wrong length tag"); } codeLength += subCodeLength; return codeLength; }