FormattingNode SINGLE() throws ScanException { // System.out.println("in SINGLE()"); Token t = getNextToken(); // System.out.println("==" + t); SimpleKeywordNode keywordNode = new SimpleKeywordNode(t.getValue()); Token ot = getCurentToken(); if (ot != null && ot.getType() == Token.OPTION) { List<String> optionList = (List<String>) ot.getValue(); keywordNode.setOptions(optionList); advanceTokenPointer(); } return keywordNode; }
public boolean equals(Object o) { if(!super.equals(o)) { return false; } if (!(o instanceof CompositeNode)) { return false; } CompositeNode r = (CompositeNode) o; return (childNode != null) ? childNode.equals(r.childNode) : (r.childNode == null); }
DynamicConverter<E> dynaConverter = createConverter(kn); if (dynaConverter != null) { dynaConverter.setFormattingInfo(kn.getFormatInfo()); dynaConverter.setOptionList(kn.getOptions()); addToList(dynaConverter); } else { + kn.getValue() + "]"); addStatus(new ErrorStatus("[" + kn.getValue() + "] is not a valid conversion word", this)); addToList(errConveter);
@Test public void testOptions1() throws Exception { Parser<Object> p = new Parser("%45x{a, b}"); Node t = p.parse(); SimpleKeywordNode witness = new SimpleKeywordNode("x"); witness.setFormatInfo(new FormatInfo(45, Integer.MAX_VALUE)); List<String> ol = new ArrayList<String>(); ol.add("a"); ol.add("b"); witness.setOptions(ol); assertEquals(witness, t); }
public String toString() { StringBuilder buf = new StringBuilder(); if (optionList == null) { buf.append("KeyWord(" + value + "," + formatInfo + ")"); } else { buf.append("KeyWord(" + value + ", " + formatInfo + "," + optionList + ")"); } buf.append(printNext()); return buf.toString(); } }
/** * Attempt to create a converter using the information found in * 'converterMap'. * * @param kn * @return */ @SuppressWarnings("unchecked") DynamicConverter<E> createConverter(SimpleKeywordNode kn) { String keyword = (String) kn.getValue(); String converterClassStr = (String) converterMap.get(keyword); if (converterClassStr != null) { try { return (DynamicConverter) OptionHelper.instantiateByClassName( converterClassStr, DynamicConverter.class, context); } catch (Exception e) { addError("Failed to instantiate converter class [" + converterClassStr + "] for keyword ["+keyword+"]", e); return null; } } else { addError("There is no conversion class registered for conversion word [" + keyword + "]"); return null; } }
@Test public void testNested() throws Exception { { Parser<Object> p = new Parser("%top %(%child%(%h))"); Node t = p.parse(); Node witness = new SimpleKeywordNode("top"); Node w = witness.next = new Node(Node.LITERAL, " "); CompositeNode composite = new CompositeNode(BARE); w = w.next = composite; Node child = new SimpleKeywordNode("child"); composite.setChildNode(child); composite = new CompositeNode(BARE); child.next = composite; composite.setChildNode(new SimpleKeywordNode("h")); assertEquals(witness, t); } }
@Override public int hashCode() { return super.hashCode(); }
@Test public void testOptions0() throws Exception { Parser<Object> p = new Parser("%45x{'test '}"); Node t = p.parse(); SimpleKeywordNode witness = new SimpleKeywordNode("x"); witness.setFormatInfo(new FormatInfo(45, Integer.MAX_VALUE)); List<String> ol = new ArrayList<String>(); ol.add("test "); witness.setOptions(ol); assertEquals(witness, t); }
public String toString() { StringBuilder buf = new StringBuilder(); if (optionList == null) { buf.append("KeyWord(" + value + "," + formatInfo + ")"); } else { buf.append("KeyWord(" + value + ", " + formatInfo + "," + optionList + ")"); } buf.append(printNext()); return buf.toString(); } }
/** * Attempt to create a converter using the information found in * 'converterMap'. * * @param kn * @return */ @SuppressWarnings("unchecked") DynamicConverter<E> createConverter(SimpleKeywordNode kn) { String keyword = (String) kn.getValue(); String converterClassStr = (String) converterMap.get(keyword); if (converterClassStr != null) { try { return (DynamicConverter) OptionHelper.instantiateByClassName(converterClassStr, DynamicConverter.class, context); } catch (Exception e) { addError("Failed to instantiate converter class [" + converterClassStr + "] for keyword [" + keyword + "]", e); return null; } } else { addError("There is no conversion class registered for conversion word [" + keyword + "]"); return null; } }
FormattingNode witness = new SimpleKeywordNode("x"); witness.setFormatInfo(new FormatInfo(45, Integer.MAX_VALUE)); assertEquals(witness, t); FormattingNode witness = new SimpleKeywordNode("x"); witness.setFormatInfo(new FormatInfo(4, 5)); assertEquals(witness, t); FormattingNode witness = new SimpleKeywordNode("x"); witness.setFormatInfo(new FormatInfo(4, 5, false, true)); assertEquals(witness, t); FormattingNode witness = new SimpleKeywordNode("x"); witness.setFormatInfo(new FormatInfo(4, 5, false, false)); assertEquals(witness, t); FormattingNode witness = new SimpleKeywordNode("x"); witness.setFormatInfo(new FormatInfo(4, 5, false, true)); Node n = witness.next = new Node(Node.LITERAL, " "); n = n.next = new SimpleKeywordNode("y"); ((FormattingNode) n).setFormatInfo(new FormatInfo(12, Integer.MAX_VALUE)); assertEquals(witness, t);
@Override public int hashCode() { return super.hashCode(); }
DynamicConverter<E> dynaConverter = createConverter(kn); if (dynaConverter != null) { dynaConverter.setFormattingInfo(kn.getFormatInfo()); dynaConverter.setOptionList(kn.getOptions()); addToList(dynaConverter); } else { + kn.getValue() + "]"); addStatus(new ErrorStatus("[" + kn.getValue() + "] is not a valid conversion word", this)); addToList(errConveter);
FormattingNode SINGLE() throws ScanException { // System.out.println("in SINGLE()"); Token t = getNextToken(); // System.out.println("==" + t); SimpleKeywordNode keywordNode = new SimpleKeywordNode(t.getValue()); Token ot = getCurentToken(); if (ot != null && ot.getType() == Token.OPTION) { List<String> optionList = (List<String>) ot.getValue(); keywordNode.setOptions(optionList); advanceTokenPointer(); } return keywordNode; }
public String toString() { StringBuilder buf = new StringBuilder(); if (optionList == null) { buf.append("KeyWord(" + value + "," + formatInfo + ")"); } else { buf.append("KeyWord(" + value + ", " + formatInfo + "," + optionList + ")"); } buf.append(printNext()); return buf.toString(); } }
public boolean equals(Object o) { //System.out.println("CompositeNode.equals()"); if(!super.equals(o)) { return false; } if (!(o instanceof CompositeNode)) { return false; } CompositeNode r = (CompositeNode) o; return (childNode != null) ? childNode.equals(r.childNode) : (r.childNode == null); }
/** * Attempt to create a converter using the information found in * 'converterMap'. * * @param kn * @return */ @SuppressWarnings("unchecked") DynamicConverter<E> createConverter(SimpleKeywordNode kn) { String keyword = (String) kn.getValue(); String converterClassStr = (String) converterMap.get(keyword); if (converterClassStr != null) { try { return (DynamicConverter) OptionHelper.instantiateByClassName(converterClassStr, DynamicConverter.class, context); } catch (Exception e) { addError("Failed to instantiate converter class [" + converterClassStr + "] for keyword [" + keyword + "]", e); return null; } } else { addError("There is no conversion class registered for conversion word [" + keyword + "]"); return null; } }
Node child = new SimpleKeywordNode("child"); composite.setChildNode(child); witness.next = composite; Node child = new SimpleKeywordNode("child"); composite.setChildNode(child); witness.next = composite; Node witness = new Node(Node.LITERAL, "hello"); CompositeNode composite = new CompositeNode(BARE); Node child = new SimpleKeywordNode("child"); composite.setChildNode(child); child.next = new Node(Node.LITERAL, " "); child.next.next = new SimpleKeywordNode("h"); witness.next = composite; assertEquals(witness, t); Node witness = new Node(Node.LITERAL, "hello"); CompositeNode composite = new CompositeNode(BARE); Node child = new SimpleKeywordNode("child"); composite.setChildNode(child); child.next = new Node(Node.LITERAL, " "); child.next.next = new SimpleKeywordNode("h"); witness.next = composite; composite.next = new Node(Node.LITERAL, " "); composite.next.next = new SimpleKeywordNode("m"); assertEquals(witness, t); composite.setChildNode(child);
@Override public int hashCode() { return super.hashCode(); }