Converters { public static Node makeNode(Object o, PrefixMapping pMapping) { if (o == null) { return Node.ANY; } if (o instanceof FrontsNode) { return checkVar(((FrontsNode) o).asNode()); } if (o instanceof Node) { return checkVar( (Node) o ); } if (o instanceof String) { try { return checkVar(NodeFactoryExtra.parseNode((String) o, PrefixMapFactory .createForInput(pMapping))); } catch (final RiotException e) { } } return makeLiteral( o ); } 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 makeNodeTest() { PrefixMapping pMap = PrefixMapping.Factory.create(); pMap.setNsPrefixes(PrefixMapping.Standard ); Node n = Converters.makeNode(null, pMap); assertEquals(Node.ANY, n); n = Converters.makeNode(RDF.type, pMap); assertEquals(RDF.type.asNode(), n); Node n2 = NodeFactory.createBlankNode(); n = Converters.makeNode(n2, pMap); assertEquals(n2, n); pMap.setNsPrefix("demo", "http: n = Converters.makeNode("demo:type", pMap); assertEquals(NodeFactory.createURI("http: n = Converters.makeNode("<one>", pMap); assertEquals(NodeFactory.createURI("one"), n); UUID uuid = UUID.randomUUID(); try { Converters.makeNode( uuid, pMap); fail( "Should have thrown IllegalArgumentException"); } catch (IllegalArgumentException expected) { } TypeMapper.getInstance().registerDatatype(new UuidDataType()); n = Converters.makeNode( uuid, pMap ); LiteralLabel ll = LiteralLabelFactory.createTypedLiteral(uuid); assertEquals(NodeFactory.createLiteral(ll), n); n = Converters.makeNode( NodeFactory.createVariable("foo"), pMap); assertTrue( n.isVariable()); assertEquals( "foo", n.getName()); assertTrue( n instanceof Var ); n = Converters.makeNode( "'text'@en", pMap); assertEquals( "text", n.getLiteralLexicalForm()); assertEquals( "en", n.getLiteralLanguage()); }