protected abstract char getToken();
public BasePathAndGroupReference( String refStr ) {
if ( refStr == null || refStr.length() == 0 || getToken() != refStr.charAt( 0 ) ) {
throw new SpecException( "Invalid reference key=" + refStr + " either blank or doesn't start with correct character=" + getToken() );
}
int pI = 0;
int kG = 0;
try {
if ( refStr.length() > 1 ) {
String meat = refStr.substring( 1 );
if( meat.length() >= 3 && meat.startsWith( "(" ) && meat.endsWith( ")" ) ) {
// "&(1,2)" -> "1,2".split( "," ) -> String[] { "1", "2" } OR
// "&(3)" -> "3".split( "," ) -> String[] { "3" }
String parenMeat = meat.substring( 1, meat.length() -1 );
String[] intStrs = parenMeat.split( "," );
if ( intStrs.length > 2 ) {
throw new SpecException( "Invalid Reference=" + refStr );
}
pI = Integer.parseInt( intStrs[0] );
if ( intStrs.length == 2 ) {
kG = Integer.parseInt( intStrs[1] );
}
}
else { // &2
pI = Integer.parseInt( meat );
}
}
}
catch( NumberFormatException nfe ) {
throw new SpecException( "Unable to parse '" + getToken() + "' reference key:" + refStr, nfe );
}
if ( pI < 0 || kG < 0 ) {
throw new SpecException( "Reference:" + refStr + " can not have a negative value." );
}
pathIndex = pI;
keyGroup = kG;
}