if ( key.charAt( 0 ) != '[' || key.charAt( key.length() - 1 ) != ']') {
throw new SpecException( "Invalid ArrayPathElement key:" + key );
}
ArrayPathType apt;
PathReference r = null;
String aI = "";
if ( key.length() == 2 ) {
apt = ArrayPathType.AUTO_EXPAND;
canonicalForm = "[]";
}
else {
String meat = key.substring( 1, key.length() - 1 ); // trim the [ ]
if ( AmpReference.TOKEN.equals( meat.charAt( 0 ) ) ) {
r = new AmpReference( meat );
apt = ArrayPathType.REFERENCE;
canonicalForm = "[" + r.getCanonicalForm() + "]";
}
else if ( HashReference.TOKEN.equals( meat.charAt( 0 ) ) ) {
r = new HashReference( meat );
apt = ArrayPathType.HASH;
canonicalForm = "[" + r.getCanonicalForm() + "]";
}
else {
try {
Integer.parseInt( meat );
apt = ArrayPathType.EXPLICIT_INDEX;