Converters { public static Var makeVar(Object o) throws ARQInternalErrorException { if (o == null) { return Var.ANON; } if (o instanceof Var) { return (Var) o; } Var retval = null; if (o instanceof FrontsNode) { retval = Var.alloc(((FrontsNode) o).asNode()); } else if (o instanceof Node) { retval = Var.alloc((Node) o); } else if (o instanceof ExprVar) { retval = Var.alloc((ExprVar) o); } else { retval = Var.alloc(Var.canonical(o.toString())); } if ("*".equals(Var.canonical(retval.toString()))) { return null; } return retval; } private  Converters(); static Node checkVar(Node n ); static Node makeLiteral(Object o); static Node makeLiteral(String value, String typeUri); static Node makeNode(Object o, PrefixMapping pMapping); static Object makeNodeOrPath(Object o, PrefixMapping pMapping); static Var makeVar(Object o); static String quoted(String q); static Collection<Node> makeValueNodes( Iterator<?> iter, PrefixMapping prefixMapping );  }
@Test public void makeVarTest() { Var v = Converters.makeVar(null); assertEquals(Var.ANON, v); v = Converters.makeVar("a"); assertEquals(Var.alloc("a"), v); v = Converters.makeVar("?a"); assertEquals(Var.alloc("a"), v); Node n = NodeFactory.createVariable("foo"); v = Converters.makeVar(n); assertEquals(Var.alloc("foo"), v); NodeFront nf = new NodeFront(n); v = Converters.makeVar(nf); assertEquals(Var.alloc("foo"), v); v = Converters.makeVar(Node_RuleVariable.WILD); assertNull(v); ExprVar ev = new ExprVar("bar"); v = Converters.makeVar(ev); assertEquals(Var.alloc("bar"), v); ev = new ExprVar(n); v = Converters.makeVar(ev); assertEquals(Var.alloc("foo"), v); ev = new ExprVar(Var.ANON); v = Converters.makeVar(ev); assertEquals(Var.ANON, v); }