private static long[] checkStringIndex(String term) {

		assert (term != null);

        // If second element is < 0, this is a dict key
		long[] result = {0L, 1L};

		// Empty strings are not allowed.
		if ("".equals(term)) { //$NON-NLS-1$
			throw EvaluationException.create(MSG_KEY_CANNOT_BE_EMPTY_STRING);
		}

		if (isIndexPattern.matcher(term).matches()) {
            if (isIndexLeadingZerosPattern.matcher(term).matches()) {
				throw EvaluationException.create(
						MSG_INVALID_LEADING_ZEROS_INDEX, term);
            } else {
                // This is digits only, so try to convert it to a long.
                try {
                    result[0] = Long.decode(term).longValue();
                    checkNumericIndex(result[0]);
                } catch (NumberFormatException nfe) {
                    throw EvaluationException.create(
						MSG_KEY_CANNOT_BEGIN_WITH_DIGIT, term);
                }
            }
		} else if (isKeyPattern.matcher(term).matches()) {

			// Return a negative number to indicate that this is an OK key
			// value.
			result[1] = -1L;

		} else {

			// Doesn't work for either a key or index.
			throw EvaluationException.create(MSG_INVALID_KEY, term);
		}

		return result;
	}
private static long [ ] checkStringIndex ( String term ) { assert ( term != null ) ; long [ ] result = { 0L , 1L } ; if ( "" . equals ( term ) ) { throw EvaluationException . create ( MSG_KEY_CANNOT_BE_EMPTY_STRING ) ; } if ( isIndexPattern . matcher ( term ) . matches ( ) ) { if ( isIndexLeadingZerosPattern . matcher ( term ) . matches ( ) ) { throw EvaluationException . create ( MSG_INVALID_LEADING_ZEROS_INDEX , term ) ; } else { try { result [ 0 ] = Long . decode ( term ) . longValue ( ) ; checkNumericIndex ( result [ 0 ] ) ; } catch ( NumberFormatException nfe ) { throw EvaluationException . create ( MSG_KEY_CANNOT_BEGIN_WITH_DIGIT , term ) ; } } } else if ( isKeyPattern . matcher ( term ) . matches ( ) ) { result [ 1 ] = - 1L ; } else { throw EvaluationException . create ( MSG_INVALID_KEY , term ) ; } return result ; }
An internal method to check that a string value is valid. It can either
be an Integer or String which is returned.

@param term
@return validated term as Integer or String