CHAT { public byte[] toByteArray() throws TLVException { byte[] data = new byte[5]; switch (role) { case CVCA: data[0] |= 0xC0; break; case DV_OFFICIAL: data[0] |= 0x80; break; case DV_NON_OFFICIAL: data[0] |= 0x40; break; default: break; } Iterator<DataGroup> it1 = writeAccess.keySet().iterator(); for (int i = 2; i < 8; i++) { DataGroup item = it1.next(); if (writeAccess.get(item)) { ByteUtils.setBit(i, data); } } Iterator<DataGroup> it2 = readAccess.keySet().iterator(); for (int i = 31; i > 10; i--) { DataGroup item = it2.next(); if (readAccess.get(item)) { ByteUtils.setBit(i, data); } } Iterator<SpecialFunction> it3 = specialFunctions.keySet().iterator(); for (int i = 32; i < 40; i++) { SpecialFunction item = it3.next(); if (specialFunctions.get(item)) { ByteUtils.setBit(i, data); } } Iterator<AccessRight> it4 = accessRights.keySet().iterator(); for (int i = 6; i < 7; i++) { AccessRight item = it4.next(); if (accessRights.get(item)) { ByteUtils.setBit(i, data); } } TLV discretionaryDataObject = new TLV(); discretionaryDataObject.setTagNumWithClass((byte) 0x53); discretionaryDataObject.setValue(data); TLV oidObject = new TLV(); oidObject.setTagNumWithClass((byte) 0x06); oidObject.setValue(ObjectIdentifierUtils.getValue(oid)); oidObject.addToEnd(discretionaryDataObject); TLV chatObject = new TLV(); chatObject.setTagNum((byte) 0x4C); chatObject.setTagClass(TagClass.APPLICATION); chatObject.setChild(oidObject); return chatObject.toBER(true); } CHAT();  CHAT(byte[] chat);  CHAT(TLV tlv); Role getRole(); Map<DataGroup, Boolean> getWriteAccess(); boolean setWriteAccess(DataGroup dataGroup, boolean selected); boolean setWriteAccess(String dataGroup, boolean selected); void setWriteAccess(TreeMap<DataGroup, Boolean> writeAccess); Map<DataGroup, Boolean> getReadAccess(); boolean setReadAccess(DataGroup dataGroup, boolean selected); boolean setReadAccess(String dataGroup, boolean selected); void setReadAccess(TreeMap<DataGroup, Boolean> readAccess); Map<SpecialFunction, Boolean> getSpecialFunctions(); boolean setSpecialFunctions(SpecialFunction specialFunction, boolean selected); boolean setSpecialFunction(String specialFunction, boolean selected); void setSpecialFunctions(TreeMap<SpecialFunction, Boolean> specialFunctions); Map<AccessRight, Boolean> getAccessRights(); boolean setAccessRights(AccessRight accessRight, boolean selected); boolean setAccessRights(String accessRight, boolean selected); void setAccessRights(Map<AccessRight, Boolean> accessRights); void restrictAccessRights(CHAT mask); byte[] toByteArray(); boolean compareTo(CHAT chat); String toHexString(); @Override String toString();  }
@Test public void testEncoding() throws TLVException { assertEquals(chatBytes, chat.toByteArray()); }