@Test public void shouldReturnNullFromParseElementTestIfOpenParenthesisIsNotIncluded() { ElementTest result = parser.parseElementTest(tokenize("attribute foo")); assertThat(result, is(nullValue())); }
protected ElementTest parseElementTest( TokenStream tokens ) { if (tokens.canConsume("element", "(")) { if (tokens.canConsume(")") || tokens.canConsume("*", ")")) { return new ElementTest(new NameTest(null, null), new NameTest(null, null)); } ElementTest result = null; NameTest elementName = parseNameTest(tokens); if (tokens.canConsume(",")) { NameTest typeName = parseNameTest(tokens); result = new ElementTest(elementName, typeName); tokens.canConsume('?'); } else { result = new ElementTest(elementName, new NameTest(null, null)); } tokens.consume(")"); return result; } return null; }
XPathParser { protected ElementTest parseElementTest( TokenStream tokens ) { if (tokens.canConsume("element", "(")) { if (tokens.canConsume(")") || tokens.canConsume("*", ")")) { return new ElementTest(new NameTest(null, null), new NameTest(null, null)); } ElementTest result = null; NameTest elementName = parseNameTest(tokens); if (tokens.canConsume(",")) { NameTest typeName = parseNameTest(tokens); result = new ElementTest(elementName, typeName); tokens.canConsume('?'); } else { result = new ElementTest(elementName, new NameTest(null, null)); } tokens.consume(")"); return result; } return null; } }
XPathParser { protected ElementTest parseElementTest( TokenStream tokens ) { if (tokens.canConsume("element", "(")) { if (tokens.canConsume(")") || tokens.canConsume("*", ")")) { return new ElementTest(new NameTest(null, null), new NameTest(null, null)); } ElementTest result = null; NameTest elementName = parseNameTest(tokens); if (tokens.canConsume(",")) { NameTest typeName = parseNameTest(tokens); result = new ElementTest(elementName, typeName); tokens.canConsume('?'); } else { result = new ElementTest(elementName, new NameTest(null, null)); } tokens.consume(")"); return result; } return null; } XPathParser( TypeSystem context ); }
XPathParser { protected ElementTest parseElementTest( TokenStream tokens ) { if (tokens.canConsume("element", "(")) { if (tokens.canConsume(")") || tokens.canConsume("*", ")")) { return new ElementTest(new NameTest(null, null), new NameTest(null, null)); } ElementTest result = null; NameTest elementName = parseNameTest(tokens); if (tokens.canConsume(",")) { NameTest typeName = parseNameTest(tokens); result = new ElementTest(elementName, typeName); tokens.canConsume('?'); } else { result = new ElementTest(elementName, new NameTest(null, null)); } tokens.consume(")"); return result; } return null; } XPathParser( TypeSystem context ); Component parseXPath( String xpath ); }
XPathParser { protected ElementTest parseElementTest( TokenStream tokens ) { if (tokens.canConsume("element", "(")) { if (tokens.canConsume(")") || tokens.canConsume("*", ")")) { return new ElementTest(new NameTest(null, null), new NameTest(null, null)); } ElementTest result = null; NameTest elementName = parseNameTest(tokens); if (tokens.canConsume(",")) { NameTest typeName = parseNameTest(tokens); result = new ElementTest(elementName, typeName); tokens.canConsume('?'); } else { result = new ElementTest(elementName, new NameTest(null, null)); } tokens.consume(")"); return result; } return null; } XPathParser( TypeSystem context ); Component parseXPath( String xpath );  }