@Test public void toVar_string() { final String varString = prependConstant("Chipotle<<~>>http: final Var result = FluoStringConverter.toVar(varString); final Var expected = new Var(prependConstant("Chipotle"), VF.createLiteral("Chipotle", XMLSchema.STRING)); expected.setConstant(true); assertEquals(expected, result); }
public static Var toVar(final String varString) { checkNotNull(varString); final String[] varParts = varString.split(TYPE_DELIM); final String name = varParts[0]; final ValueFactory vf = SimpleValueFactory.getInstance(); if(varParts.length > 1) { final String dataTypeString = varParts[1]; if(dataTypeString.equals(URI_TYPE)) { Preconditions.checkArgument(varParts.length == 2); final String valueString = VarNameUtils.removeConstant(name); final Var var = new Var(name, vf.createIRI(valueString)); var.setConstant(true); return var; } else if(dataTypeString.equals(RyaSchema.BNODE_NAMESPACE)) { Preconditions.checkArgument(varParts.length == 3); final Var var = new Var(name); var.setValue(vf.createBNode(varParts[2])); return var; } else { Preconditions.checkArgument(varParts.length == 2); final String valueString = VarNameUtils.removeConstant(name); final IRI dataType = vf.createIRI(dataTypeString); final Literal value = vf.createLiteral(valueString, dataType); final Var var = new Var(name, value); var.setConstant(true); return var; } } else { return new Var(varString); } }
FluoStringConverter { public static Var toVar(final String varString) { checkNotNull(varString); final String[] varParts = varString.split(TYPE_DELIM); final String name = varParts[0]; final ValueFactory vf = SimpleValueFactory.getInstance(); if(varParts.length > 1) { final String dataTypeString = varParts[1]; if(dataTypeString.equals(URI_TYPE)) { Preconditions.checkArgument(varParts.length == 2); final String valueString = VarNameUtils.removeConstant(name); final Var var = new Var(name, vf.createIRI(valueString)); var.setConstant(true); return var; } else if(dataTypeString.equals(RyaSchema.BNODE_NAMESPACE)) { Preconditions.checkArgument(varParts.length == 3); final Var var = new Var(name); var.setValue(vf.createBNode(varParts[2])); return var; } else { Preconditions.checkArgument(varParts.length == 2); final String valueString = VarNameUtils.removeConstant(name); final IRI dataType = vf.createIRI(dataTypeString); final Literal value = vf.createLiteral(valueString, dataType); final Var var = new Var(name, value); var.setConstant(true); return var; } } else { return new Var(varString); } } }
FluoStringConverter { public static Var toVar(final String varString) { checkNotNull(varString); final String[] varParts = varString.split(TYPE_DELIM); final String name = varParts[0]; final ValueFactory vf = SimpleValueFactory.getInstance(); if(varParts.length > 1) { final String dataTypeString = varParts[1]; if(dataTypeString.equals(URI_TYPE)) { Preconditions.checkArgument(varParts.length == 2); final String valueString = VarNameUtils.removeConstant(name); final Var var = new Var(name, vf.createIRI(valueString)); var.setConstant(true); return var; } else if(dataTypeString.equals(RyaSchema.BNODE_NAMESPACE)) { Preconditions.checkArgument(varParts.length == 3); final Var var = new Var(name); var.setValue(vf.createBNode(varParts[2])); return var; } else { Preconditions.checkArgument(varParts.length == 2); final String valueString = VarNameUtils.removeConstant(name); final IRI dataType = vf.createIRI(dataTypeString); final Literal value = vf.createLiteral(valueString, dataType); final Var var = new Var(name, value); var.setConstant(true); return var; } } else { return new Var(varString); } }  }
FluoStringConverter { public static Var toVar(final String varString) { checkNotNull(varString); final String[] varParts = varString.split(TYPE_DELIM); final String name = varParts[0]; final ValueFactory vf = SimpleValueFactory.getInstance(); if(varParts.length > 1) { final String dataTypeString = varParts[1]; if(dataTypeString.equals(URI_TYPE)) { Preconditions.checkArgument(varParts.length == 2); final String valueString = VarNameUtils.removeConstant(name); final Var var = new Var(name, vf.createIRI(valueString)); var.setConstant(true); return var; } else if(dataTypeString.equals(RyaSchema.BNODE_NAMESPACE)) { Preconditions.checkArgument(varParts.length == 3); final Var var = new Var(name); var.setValue(vf.createBNode(varParts[2])); return var; } else { Preconditions.checkArgument(varParts.length == 2); final String valueString = VarNameUtils.removeConstant(name); final IRI dataType = vf.createIRI(dataTypeString); final Literal value = vf.createLiteral(valueString, dataType); final Var var = new Var(name, value); var.setConstant(true); return var; } } else { return new Var(varString); } }  static String[] toBindingStrings(final String bindingSetString); static StatementPattern toStatementPattern(final String patternString); static Var toVar(final String varString); static String toStatementPatternString(final StatementPattern sp); }
FluoStringConverter { public static Var toVar(final String varString) { checkNotNull(varString); final String[] varParts = varString.split(TYPE_DELIM); final String name = varParts[0]; final ValueFactory vf = SimpleValueFactory.getInstance(); if(varParts.length > 1) { final String dataTypeString = varParts[1]; if(dataTypeString.equals(URI_TYPE)) { Preconditions.checkArgument(varParts.length == 2); final String valueString = VarNameUtils.removeConstant(name); final Var var = new Var(name, vf.createIRI(valueString)); var.setConstant(true); return var; } else if(dataTypeString.equals(RyaSchema.BNODE_NAMESPACE)) { Preconditions.checkArgument(varParts.length == 3); final Var var = new Var(name); var.setValue(vf.createBNode(varParts[2])); return var; } else { Preconditions.checkArgument(varParts.length == 2); final String valueString = VarNameUtils.removeConstant(name); final IRI dataType = vf.createIRI(dataTypeString); final Literal value = vf.createLiteral(valueString, dataType); final Var var = new Var(name, value); var.setConstant(true); return var; } } else { return new Var(varString); } }  static String[] toBindingStrings(final String bindingSetString); static StatementPattern toStatementPattern(final String patternString); static Var toVar(final String varString); static String toStatementPatternString(final StatementPattern sp);  }