XPathParser { protected NameTest parseWildcard( TokenStream tokens ) { if (tokens.canConsume('*')) { if (tokens.canConsume(':')) { if (tokens.canConsume('*')) { return new NameTest(null, null); } String localName = tokens.consume(); return new NameTest(null, decode(localName)); } return new NameTest(null, null); } if (tokens.matches(XPathTokenizer.NAME, XPathTokenizer.SYMBOL, XPathTokenizer.SYMBOL) && tokens.matches(TokenStream.ANY_VALUE, ":", "*")) { String prefix = tokens.consume(); tokens.consume(':'); tokens.consume('*'); return new NameTest(decode(prefix), null); } return null; } XPathParser( TypeSystem context ); Component parseXPath( String xpath );  }
@Test public void shouldParseWildcard() { assertThat(parser.parseWildcard(tokenize("*")), is(wildcard())); assertThat(parser.parseWildcard(tokenize("*:*")), is(wildcard())); assertThat(parser.parseWildcard(tokenize("*:name")), is(nameTest(null, "name"))); assertThat(parser.parseWildcard(tokenize("name:*")), is(nameTest("name", null))); }
@Test public void shouldReturnNullFromParseWildcardIfNotWildcard() { assertThat(parser.parseWildcard(tokenize("name")), is(nullValue())); assertThat(parser.parseWildcard(tokenize("name:foo")), is(nullValue())); }