@Test public void shouldReturnNullFromParseAttributeTestIfOpenParenthesisIsNotIncluded() { AttributeTest result = parser.parseAttributeTest(tokenize("attribute foo")); assertThat(result, is(nullValue())); }
protected AttributeTest parseAttributeTest( TokenStream tokens ) { if (tokens.canConsume("attribute", "(")) { if (tokens.canConsume(")") || tokens.canConsume("*", ")")) { return new AttributeTest(new NameTest(null, null), new NameTest(null, null)); } AttributeTest result = null; NameTest attributeName = parseNameTest(tokens); if (tokens.canConsume(",")) { NameTest typeName = parseNameTest(tokens); result = new AttributeTest(attributeName, typeName); } else { result = new AttributeTest(attributeName, new NameTest(null, null)); } tokens.consume(")"); return result; } return null; }
XPathParser { protected AttributeTest parseAttributeTest( TokenStream tokens ) { if (tokens.canConsume("attribute", "(")) { if (tokens.canConsume(")") || tokens.canConsume("*", ")")) { return new AttributeTest(new NameTest(null, null), new NameTest(null, null)); } AttributeTest result = null; NameTest attributeName = parseNameTest(tokens); if (tokens.canConsume(",")) { NameTest typeName = parseNameTest(tokens); result = new AttributeTest(attributeName, typeName); } else { result = new AttributeTest(attributeName, new NameTest(null, null)); } tokens.consume(")"); return result; } return null; } }
XPathParser { protected AttributeTest parseAttributeTest( TokenStream tokens ) { if (tokens.canConsume("attribute", "(")) { if (tokens.canConsume(")") || tokens.canConsume("*", ")")) { return new AttributeTest(new NameTest(null, null), new NameTest(null, null)); } AttributeTest result = null; NameTest attributeName = parseNameTest(tokens); if (tokens.canConsume(",")) { NameTest typeName = parseNameTest(tokens); result = new AttributeTest(attributeName, typeName); } else { result = new AttributeTest(attributeName, new NameTest(null, null)); } tokens.consume(")"); return result; } return null; } XPathParser( TypeSystem context ); }
XPathParser { protected AttributeTest parseAttributeTest( TokenStream tokens ) { if (tokens.canConsume("attribute", "(")) { if (tokens.canConsume(")") || tokens.canConsume("*", ")")) { return new AttributeTest(new NameTest(null, null), new NameTest(null, null)); } AttributeTest result = null; NameTest attributeName = parseNameTest(tokens); if (tokens.canConsume(",")) { NameTest typeName = parseNameTest(tokens); result = new AttributeTest(attributeName, typeName); } else { result = new AttributeTest(attributeName, new NameTest(null, null)); } tokens.consume(")"); return result; } return null; } XPathParser( TypeSystem context ); Component parseXPath( String xpath ); }
XPathParser { protected AttributeTest parseAttributeTest( TokenStream tokens ) { if (tokens.canConsume("attribute", "(")) { if (tokens.canConsume(")") || tokens.canConsume("*", ")")) { return new AttributeTest(new NameTest(null, null), new NameTest(null, null)); } AttributeTest result = null; NameTest attributeName = parseNameTest(tokens); if (tokens.canConsume(",")) { NameTest typeName = parseNameTest(tokens); result = new AttributeTest(attributeName, typeName); } else { result = new AttributeTest(attributeName, new NameTest(null, null)); } tokens.consume(")"); return result; } return null; } XPathParser( TypeSystem context ); Component parseXPath( String xpath );  }