// The key is an undelimited string; it must adhere to Java
// identifier syntax
StringBuilder keyStringBuilder = new StringBuilder();
if (!Character.isJavaIdentifierStart(c)) {
throw new SerializationException("Illegal identifier start character.");
}
while (c != -1
&& c != ':' && !Character.isWhitespace(c)) {
if (!Character.isJavaIdentifierPart(c)) {
throw new SerializationException("Illegal identifier character.");
}
keyStringBuilder.append((char)c);
c = reader.read();
}
if (c == -1) {
throw new SerializationException("Unexpected end of input stream.");
}
key = keyStringBuilder.toString();
}
if (key == null
|| key.length() == 0) {
throw new SerializationException("\"" + key + "\" is not a valid key.");
}
skipWhitespaceAndComments(reader);
if (c != ':') {
throw new SerializationException("Unexpected character in input stream.");
}
// Move to the first character after ':'
c = reader.read();
map.put(key, readValue(reader));
skipWhitespaceAndComments(reader);
if (c == ',') {
c = reader.read();
skipWhitespaceAndComments(reader);
} else if (c == -1) {
throw new SerializationException("Unexpected end of input stream.");
} else {
if (c != '}') {
throw new SerializationException("Unexpected character in input stream.");
}
}
}
// Move to the first character after '}'