@Test public void getAttributeStringValue() throws Exception { AstNode astNode = new AstNode(Token.builder() .setURI(new URI("tests: .setType(GenericTokenType.IDENTIFIER) .setLine(1) .setColumn(2) .setValueAndOriginalValue("foo", "bar") .build()); assertThat(navigator.getAttributeStringValue(new Attribute("tokenLine", astNode))).isEqualTo("1"); assertThat(navigator.getAttributeStringValue(new Attribute("tokenColumn", astNode))).isEqualTo("2"); assertThat(navigator.getAttributeStringValue(new Attribute("tokenValue", astNode))).isEqualTo("foo"); }
@Override public String getAttributeStringValue(Object attributeObject) { Attribute attribute = (Attribute) attributeObject; if ("tokenLine".equals(attribute.getName())) { return Integer.toString(attribute.getAstNode().getToken().getLine()); } else if ("tokenColumn".equals(attribute.getName())) { return Integer.toString(attribute.getAstNode().getToken().getColumn()); } else if ("tokenValue".equals(attribute.getName())) { return attribute.getAstNode().getToken().getValue(); } else { throw new UnsupportedOperationException("Unsupported attribute name \"" + attribute.getName() + "\""); } }
AstNodeNavigator extends DefaultNavigator { @Override public String getAttributeStringValue(Object attributeObject) { Attribute attribute = (Attribute) attributeObject; if ("tokenLine".equals(attribute.getName())) { return Integer.toString(attribute.getAstNode().getToken().getLine()); } else if ("tokenColumn".equals(attribute.getName())) { return Integer.toString(attribute.getAstNode().getToken().getColumn()); } else if ("tokenValue".equals(attribute.getName())) { return attribute.getAstNode().getToken().getValue(); } else { throw new UnsupportedOperationException("Unsupported attribute name \"" + attribute.getName() + "\""); } } }
AstNodeNavigator extends DefaultNavigator { @Override public String getAttributeStringValue(Object attributeObject) { Attribute attribute = (Attribute) attributeObject; if ("tokenLine".equals(attribute.getName())) { return Integer.toString(attribute.getAstNode().getToken().getLine()); } else if ("tokenColumn".equals(attribute.getName())) { return Integer.toString(attribute.getAstNode().getToken().getColumn()); } else if ("tokenValue".equals(attribute.getName())) { return attribute.getAstNode().getToken().getValue(); } else { throw new UnsupportedOperationException("Unsupported attribute name \"" + attribute.getName() + "\""); } }  }
AstNodeNavigator extends DefaultNavigator { @Override public String getAttributeStringValue(Object attributeObject) { Attribute attribute = (Attribute) attributeObject; if ("tokenLine".equals(attribute.getName())) { return Integer.toString(attribute.getAstNode().getToken().getLine()); } else if ("tokenColumn".equals(attribute.getName())) { return Integer.toString(attribute.getAstNode().getToken().getColumn()); } else if ("tokenValue".equals(attribute.getName())) { return attribute.getAstNode().getToken().getValue(); } else { throw new UnsupportedOperationException("Unsupported attribute name \"" + attribute.getName() + "\""); } }  void reset(); @Override String getTextStringValue(Object arg0); @Override String getCommentStringValue(Object arg0); @Override String getAttributeStringValue(Object attributeObject); @Override String getElementStringValue(Object arg0); @Override String getNamespacePrefix(Object arg0); @Override String getNamespaceStringValue(Object arg0); @Override String getAttributeName(Object attributeObject); @Override String getAttributeQName(Object attributeObject); @Override String getAttributeNamespaceUri(Object arg0); @Override String getElementName(Object astNodeObject); @Override String getElementQName(Object astNodeObject); @Override String getElementNamespaceUri(Object astNodeObject); @Override boolean isAttribute(Object object); @Override boolean isComment(Object object); @Override boolean isDocument(Object contextObject); @Override boolean isElement(Object object); @Override boolean isNamespace(Object arg0); @Override boolean isProcessingInstruction(Object arg0); @Override boolean isText(Object arg0); @Override Object getDocumentNode(Object contextNode); @Override Iterator getChildAxisIterator(Object contextNode); @Override Object getParentNode(Object contextNode); @SuppressWarnings("unchecked") @Override Iterator getParentAxisIterator(Object contextNode); @Override Iterator getAttributeAxisIterator(Object contextNode); @Override XPath parseXPath(String arg0); }
AstNodeNavigator extends DefaultNavigator { @Override public String getAttributeStringValue(Object attributeObject) { Attribute attribute = (Attribute) attributeObject; if ("tokenLine".equals(attribute.getName())) { return Integer.toString(attribute.getAstNode().getToken().getLine()); } else if ("tokenColumn".equals(attribute.getName())) { return Integer.toString(attribute.getAstNode().getToken().getColumn()); } else if ("tokenValue".equals(attribute.getName())) { return attribute.getAstNode().getToken().getValue(); } else { throw new UnsupportedOperationException("Unsupported attribute name \"" + attribute.getName() + "\""); } }  void reset(); @Override String getTextStringValue(Object arg0); @Override String getCommentStringValue(Object arg0); @Override String getAttributeStringValue(Object attributeObject); @Override String getElementStringValue(Object arg0); @Override String getNamespacePrefix(Object arg0); @Override String getNamespaceStringValue(Object arg0); @Override String getAttributeName(Object attributeObject); @Override String getAttributeQName(Object attributeObject); @Override String getAttributeNamespaceUri(Object arg0); @Override String getElementName(Object astNodeObject); @Override String getElementQName(Object astNodeObject); @Override String getElementNamespaceUri(Object astNodeObject); @Override boolean isAttribute(Object object); @Override boolean isComment(Object object); @Override boolean isDocument(Object contextObject); @Override boolean isElement(Object object); @Override boolean isNamespace(Object arg0); @Override boolean isProcessingInstruction(Object arg0); @Override boolean isText(Object arg0); @Override Object getDocumentNode(Object contextNode); @Override Iterator getChildAxisIterator(Object contextNode); @Override Object getParentNode(Object contextNode); @SuppressWarnings("unchecked") @Override Iterator getParentAxisIterator(Object contextNode); @Override Iterator getAttributeAxisIterator(Object contextNode); @Override XPath parseXPath(String arg0);  }