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; }
public int encode(BerByteArrayOutputStream berOStream, boolean explicit) throws IOException { int codeLength; if (code != null) { codeLength = code.length; for (int i = code.length - 1; i >= 0; i--) { berOStream.write(code[i]); } } else { codeLength = 0; codeLength += mmsInitResponseDetail.encode(berOStream, false); codeLength += (new BerIdentifier(BerIdentifier.CONTEXT_CLASS, BerIdentifier.CONSTRUCTED, 4)) .encode(berOStream); if (negotiatedDataStructureNestingLevel != null) { codeLength += negotiatedDataStructureNestingLevel.encode(berOStream, false); codeLength += (new BerIdentifier(BerIdentifier.CONTEXT_CLASS, BerIdentifier.PRIMITIVE, 3)) .encode(berOStream); } codeLength += negotiatedMaxServOutstandingCalled.encode(berOStream, false); codeLength += (new BerIdentifier(BerIdentifier.CONTEXT_CLASS, BerIdentifier.PRIMITIVE, 2)) .encode(berOStream); codeLength += negotiatedMaxServOutstandingCalling.encode(berOStream, false); codeLength += (new BerIdentifier(BerIdentifier.CONTEXT_CLASS, BerIdentifier.PRIMITIVE, 1)) .encode(berOStream); if (localDetailCalled != null) { codeLength += localDetailCalled.encode(berOStream, false); codeLength += (new BerIdentifier(BerIdentifier.CONTEXT_CLASS, BerIdentifier.PRIMITIVE, 0)) .encode(berOStream); } codeLength += BerLength.encodeLength(berOStream, codeLength); } if (explicit) { codeLength += id.encode(berOStream); } return codeLength; }
public int encode(BerByteArrayOutputStream berOStream, boolean explicit) throws IOException { int codeLength; if (code != null) { codeLength = code.length; for (int i = code.length - 1; i >= 0; i--) { berOStream.write(code[i]); } } else { codeLength = 0; codeLength += confirmedServiceRequest.encode(berOStream, true); codeLength += invokeID.encode(berOStream, true); codeLength += BerLength.encodeLength(berOStream, codeLength); } if (explicit) { codeLength += id.encode(berOStream); } return codeLength; }
public int decode(InputStream iStream, boolean explicit) throws IOException { int codeLength = 0; int subCodeLength = 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(BerIdentifier.CONTEXT_CLASS, BerIdentifier.PRIMITIVE, 0)) { localDetailCalled = new BerInteger(); subCodeLength += localDetailCalled.decode(iStream, false); decodedIdentifier = false; } } if (subCodeLength < length.val) { if (decodedIdentifier == false) { subCodeLength += berIdentifier.decode(iStream); decodedIdentifier = true; } if (berIdentifier.equals(BerIdentifier.CONTEXT_CLASS, BerIdentifier.PRIMITIVE, 1)) { negotiatedMaxServOutstandingCalling = new BerInteger(); subCodeLength += negotiatedMaxServOutstandingCalling.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; } if (berIdentifier.equals(BerIdentifier.CONTEXT_CLASS, BerIdentifier.PRIMITIVE, 2)) { negotiatedMaxServOutstandingCalled = new BerInteger(); subCodeLength += negotiatedMaxServOutstandingCalled.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; } if (berIdentifier.equals(BerIdentifier.CONTEXT_CLASS, BerIdentifier.PRIMITIVE, 3)) { negotiatedDataStructureNestingLevel = new BerInteger(); subCodeLength += negotiatedDataStructureNestingLevel.decode(iStream, false); decodedIdentifier = false; } } if (subCodeLength < length.val) { if (decodedIdentifier == false) { subCodeLength += berIdentifier.decode(iStream); decodedIdentifier = true; } if (berIdentifier.equals(BerIdentifier.CONTEXT_CLASS, BerIdentifier.CONSTRUCTED, 4)) { mmsInitResponseDetail = new InitResponseDetail(); subCodeLength += mmsInitResponseDetail.decode(iStream, false); decodedIdentifier = false; } else { throw new IOException("Identifier does not macht required sequence element identifer."); } } if (subCodeLength != length.val) { throw new IOException("Decoded sequence has wrong length tag"); } codeLength += subCodeLength; return codeLength; }