// from the ObjectName. This allows us to provide a more
// accurate exception message.
int i = ++index;
while ((i < len) && (name_chars[i++] != ':'))
if (i == len)
throw new MalformedObjectNameException(
"Domain part must be specified");
break;
case '\n' :
throw new MalformedObjectNameException(
"Invalid character '\\n' in domain name");
case '*' :
case '?' :
_domain_pattern = true;
index++;
break;
default :
index++;
break;
}
}
// check for non-empty properties
if (index == len)
throw new MalformedObjectNameException(
"Key properties cannot be empty");
// we have got the domain part, begins building of _canonicalName
System.arraycopy(name_chars, 0, canonical_chars, 0, _domain_length);
canonical_chars[_domain_length] = ':';
cname_index = _domain_length + 1;
// parses property list
Property prop;
Map<String,Property> keys_map = new HashMap<String,Property>();
String[] keys;
String key_name;
boolean quoted_value;
int property_index = 0;
int in_index;
int key_index, key_length, value_index, value_length;
keys = new String[10];
_kp_array = new Property[10];
_property_list_pattern = false;
_property_value_pattern = false;
while (index < len) {
c = name_chars[index];
// case of pattern properties
if (c == '*') {
if (_property_list_pattern)
throw new MalformedObjectNameException(
"Cannot have several '*' characters in pattern " +
"property list");
else {
_property_list_pattern = true;
if ((++index < len ) && (name_chars[index] != ','))
throw new MalformedObjectNameException(
"Invalid character found after '*': end of " +
"name or ',' expected");
else if (index == len) {
if (property_index == 0) {
// empty properties case
_kp_array = _Empty_property_array;
_ca_array = _Empty_property_array;
_propertyList = Collections.emptyMap();
}
break;
} else {
// correct pattern spec in props, continue
index++;
continue;
}
}
}
// standard property case, key part
in_index = index;
key_index = in_index;
if (name_chars[in_index] == '=')
throw new MalformedObjectNameException("Invalid key (empty)");
while ((in_index < len) && ((c1 = name_chars[in_index++]) != '='))
switch (c1) {
// '=' considered to introduce value part
case '*' :
case '?' :
case ',' :
case ':' :
case '\n' :
final String ichar = ((c1=='\n')?"\\n":""+c1);
throw new MalformedObjectNameException(
"Invalid character '" + ichar +
"' in key part of property");
}
if (name_chars[in_index - 1] != '=')
throw new MalformedObjectNameException(
"Unterminated key property part");
value_index = in_index; // in_index pointing after '=' char
key_length = value_index - key_index - 1; // found end of key
// standard property case, value part
boolean value_pattern = false;
if (in_index < len && name_chars[in_index] == '\"') {
quoted_value = true;
// the case of quoted value part
quoted_value_parsing:
while ((++in_index < len) &&
((c1 = name_chars[in_index]) != '\"')) {
// the case of an escaped character
if (c1 == '\\') {
if (++in_index == len)
throw new MalformedObjectNameException(
"Unterminated quoted value");
switch (c1 = name_chars[in_index]) {
case '\\' :
case '\"' :
case '?' :
case '*' :
case 'n' :
break; // valid character
default :
throw new MalformedObjectNameException(
"Invalid escape sequence '\\" +
c1 + "' in quoted value");
}
} else if (c1 == '\n') {
throw new MalformedObjectNameException(
"Newline in quoted value");
} else {
switch (c1) {
case '?' :
case '*' :
value_pattern = true;
break;
}
}
}
if (in_index == len)
throw new MalformedObjectNameException(
"Unterminated quoted value");
else value_length = ++in_index - value_index;
} else {
// the case of standard value part
quoted_value = false;
while ((in_index < len) && ((c1 = name_chars[in_index]) != ','))
switch (c1) {
// ',' considered to be the value separator
case '*' :
case '?' :
value_pattern = true;
in_index++;
break;
case '=' :
case ':' :
case '"' :
case '\n' :
final String ichar = ((c1=='\n')?"\\n":""+c1);
throw new MalformedObjectNameException(
"Invalid character '" + c1 +
"' in value part of property");
default :
in_index++;
break;
}
value_length = in_index - value_index;
}
// Parsed property, checks the end of name
if (in_index == len - 1) {
if (quoted_value)
throw new MalformedObjectNameException(
"Invalid ending character `" +
name_chars[in_index] + "'");
else throw new MalformedObjectNameException(
"Invalid ending comma");
} else in_index++;
// we got the key and value part, prepare a property for this
if (!value_pattern) {