| | |
| | | |
| | | /** |
| | | * Get the length of the next String encoded in the in byte array. |
| | | * This method is used to cut the different parts (server ids, change number) |
| | | * of a server state. |
| | | * |
| | | * @param in the byte array where to calculate the string. |
| | | * @param pos the position whre to start from in the byte array. |
| | |
| | | while (in[offset++] != 0) |
| | | { |
| | | if (offset >= in.length) |
| | | throw new DataFormatException("byte[] is not a valid modify msg"); |
| | | throw new DataFormatException("byte[] is not a valid server state"); |
| | | length++; |
| | | } |
| | | return length; |
| | |
| | | * Return the text representation of ServerState. |
| | | * @return the text representation of ServerState |
| | | */ |
| | | @Override |
| | | public String toString() |
| | | { |
| | | StringBuilder buffer = new StringBuilder(); |
| | |
| | | for (Short key : list.keySet()) |
| | | { |
| | | ChangeNumber change = list.get(key); |
| | | buffer.append(change.toString()); |
| | | buffer.append(" "); |
| | | buffer.append(change.toStringUI()); |
| | | } |
| | | if (!list.isEmpty()) |
| | | buffer.deleteCharAt(buffer.length()-1); |
| | | } |
| | | |
| | | return buffer.toString(); |