@Test public void testCanonicalization() { String even = "AaccccccCcccccdD"; String evenCanonical = "AA.CCCC.CCCC.CCCC.DD"; String odd = "AABBCCCCCCCCCCCCDD"; String oddCanonical = "AA.BBCC.CCCC.CCCC.CCDD"; assertThat(new IsoAddress(even).toString(), equalTo(evenCanonical)); assertThat(new IsoAddress(odd).toString(), equalTo(oddCanonical)); assertThat(new IsoAddress(evenCanonical).toString(), equalTo(evenCanonical)); assertThat(new IsoAddress(oddCanonical).toString(), equalTo(oddCanonical)); }
@Override @JsonValue public String toString() { StringBuilder sb = new StringBuilder(String.format("%02X", _afi)); if ((_areaId.length & 0x1) == 0) { for (int i = 0; i < _areaId.length; i += 2) { sb.append(String.format(".%02X%02X", _areaId[i], _areaId[i + 1])); } for (int i = 0; i < SYSTEM_ID_SIZE; i += 2) { sb.append(String.format(".%02X%02X", _systemId[i], _systemId[i + 1])); } sb.append(String.format(".%02X", _nSel)); } else { int areaIdOffset = 0; for (areaIdOffset = 0; areaIdOffset < _areaId.length - 1; areaIdOffset += 2) { sb.append(String.format(".%02X%02X", _areaId[areaIdOffset], _areaId[areaIdOffset + 1])); } sb.append(String.format(".%02X", _areaId[areaIdOffset])); sb.append(String.format("%02X", _systemId[0])); for (int i = 1; i < SYSTEM_ID_SIZE - 2; i += 2) { sb.append(String.format(".%02X%02X", _systemId[i], _systemId[i + 1])); } sb.append(String.format(".%02X", _systemId[SYSTEM_ID_SIZE - 1])); sb.append(String.format("%02X", _nSel)); } return sb.toString(); }
IsoAddress implements Serializable { @Override @JsonValue public String toString() { StringBuilder sb = new StringBuilder(String.format("%02X", _afi)); if ((_areaId.length & 0x1) == 0) { for (int i = 0; i < _areaId.length; i += 2) { sb.append(String.format(".%02X%02X", _areaId[i], _areaId[i + 1])); } for (int i = 0; i < SYSTEM_ID_SIZE; i += 2) { sb.append(String.format(".%02X%02X", _systemId[i], _systemId[i + 1])); } sb.append(String.format(".%02X", _nSel)); } else { int areaIdOffset = 0; for (areaIdOffset = 0; areaIdOffset < _areaId.length - 1; areaIdOffset += 2) { sb.append(String.format(".%02X%02X", _areaId[areaIdOffset], _areaId[areaIdOffset + 1])); } sb.append(String.format(".%02X", _areaId[areaIdOffset])); sb.append(String.format("%02X", _systemId[0])); for (int i = 1; i < SYSTEM_ID_SIZE - 2; i += 2) { sb.append(String.format(".%02X%02X", _systemId[i], _systemId[i + 1])); } sb.append(String.format(".%02X", _systemId[SYSTEM_ID_SIZE - 1])); sb.append(String.format("%02X", _nSel)); } return sb.toString(); } }
IsoAddress implements Serializable { @Override @JsonValue public String toString() { StringBuilder sb = new StringBuilder(String.format("%02X", _afi)); if ((_areaId.length & 0x1) == 0) { for (int i = 0; i < _areaId.length; i += 2) { sb.append(String.format(".%02X%02X", _areaId[i], _areaId[i + 1])); } for (int i = 0; i < SYSTEM_ID_SIZE; i += 2) { sb.append(String.format(".%02X%02X", _systemId[i], _systemId[i + 1])); } sb.append(String.format(".%02X", _nSel)); } else { int areaIdOffset = 0; for (areaIdOffset = 0; areaIdOffset < _areaId.length - 1; areaIdOffset += 2) { sb.append(String.format(".%02X%02X", _areaId[areaIdOffset], _areaId[areaIdOffset + 1])); } sb.append(String.format(".%02X", _areaId[areaIdOffset])); sb.append(String.format("%02X", _systemId[0])); for (int i = 1; i < SYSTEM_ID_SIZE - 2; i += 2) { sb.append(String.format(".%02X%02X", _systemId[i], _systemId[i + 1])); } sb.append(String.format(".%02X", _systemId[SYSTEM_ID_SIZE - 1])); sb.append(String.format("%02X", _nSel)); } return sb.toString(); } IsoAddress(@Nonnull String isoAddressStr); }
IsoAddress implements Serializable { @Override @JsonValue public String toString() { StringBuilder sb = new StringBuilder(String.format("%02X", _afi)); if ((_areaId.length & 0x1) == 0) { for (int i = 0; i < _areaId.length; i += 2) { sb.append(String.format(".%02X%02X", _areaId[i], _areaId[i + 1])); } for (int i = 0; i < SYSTEM_ID_SIZE; i += 2) { sb.append(String.format(".%02X%02X", _systemId[i], _systemId[i + 1])); } sb.append(String.format(".%02X", _nSel)); } else { int areaIdOffset = 0; for (areaIdOffset = 0; areaIdOffset < _areaId.length - 1; areaIdOffset += 2) { sb.append(String.format(".%02X%02X", _areaId[areaIdOffset], _areaId[areaIdOffset + 1])); } sb.append(String.format(".%02X", _areaId[areaIdOffset])); sb.append(String.format("%02X", _systemId[0])); for (int i = 1; i < SYSTEM_ID_SIZE - 2; i += 2) { sb.append(String.format(".%02X%02X", _systemId[i], _systemId[i + 1])); } sb.append(String.format(".%02X", _systemId[SYSTEM_ID_SIZE - 1])); sb.append(String.format("%02X", _nSel)); } return sb.toString(); } IsoAddress(@Nonnull String isoAddressStr); @Override boolean equals(Object obj); byte getAfi(); @Nonnull byte[] getAreaId(); @Nonnull String getAreaIdString(); byte getNSelector(); @Nonnull byte[] getSystemId(); @Nonnull String getSystemIdString(); @Override int hashCode(); @Override @JsonValue String toString(); }
IsoAddress implements Serializable { @Override @JsonValue public String toString() { StringBuilder sb = new StringBuilder(String.format("%02X", _afi)); if ((_areaId.length & 0x1) == 0) { for (int i = 0; i < _areaId.length; i += 2) { sb.append(String.format(".%02X%02X", _areaId[i], _areaId[i + 1])); } for (int i = 0; i < SYSTEM_ID_SIZE; i += 2) { sb.append(String.format(".%02X%02X", _systemId[i], _systemId[i + 1])); } sb.append(String.format(".%02X", _nSel)); } else { int areaIdOffset = 0; for (areaIdOffset = 0; areaIdOffset < _areaId.length - 1; areaIdOffset += 2) { sb.append(String.format(".%02X%02X", _areaId[areaIdOffset], _areaId[areaIdOffset + 1])); } sb.append(String.format(".%02X", _areaId[areaIdOffset])); sb.append(String.format("%02X", _systemId[0])); for (int i = 1; i < SYSTEM_ID_SIZE - 2; i += 2) { sb.append(String.format(".%02X%02X", _systemId[i], _systemId[i + 1])); } sb.append(String.format(".%02X", _systemId[SYSTEM_ID_SIZE - 1])); sb.append(String.format("%02X", _nSel)); } return sb.toString(); } IsoAddress(@Nonnull String isoAddressStr); @Override boolean equals(Object obj); byte getAfi(); @Nonnull byte[] getAreaId(); @Nonnull String getAreaIdString(); byte getNSelector(); @Nonnull byte[] getSystemId(); @Nonnull String getSystemIdString(); @Override int hashCode(); @Override @JsonValue String toString();  }