|
From: Bryan T. <tho...@us...> - 2007-04-12 23:59:25
|
Update of /cvsroot/cweb/bigdata-rdf/src/java/com/bigdata/rdf/model In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv2483/src/java/com/bigdata/rdf/model Modified Files: OptimizedValueFactory.java Log Message: Added a Sesame 1.x SAIL implementation. This is NOT intended for production use. It is just being done to gain a high-level query language integration for the triple store. Index: OptimizedValueFactory.java =================================================================== RCS file: /cvsroot/cweb/bigdata-rdf/src/java/com/bigdata/rdf/model/OptimizedValueFactory.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** OptimizedValueFactory.java 9 Feb 2007 20:18:57 -0000 1.5 --- OptimizedValueFactory.java 12 Apr 2007 23:59:21 -0000 1.6 *************** *** 71,74 **** --- 71,124 ---- public class OptimizedValueFactory implements ValueFactory { + /** + * Converts a {@link Value} for a different {@link ValueFactory} into a + * {@link _Value}. + * + * @param v + * The value. + * + * @return The value iff it is a {@link _Value} and otherwise a + * {@link _Value} with the same data. + */ + public Value toNativeValue( Value v ) { + + if( v == null ) throw new IllegalArgumentException(); + + if( v instanceof URI && ! ( v instanceof _URI) ) { + + v = createURI(v.toString()); + + } else if( v instanceof Literal && ! ( v instanceof _Literal )) { + + String label = ((Literal)v).getLabel(); + + String language = ((Literal)v).getLanguage(); + + URI datatype = ((Literal)v).getDatatype(); + + if( language != null ) { + + v = createLiteral(label,language); + + } else if( datatype != null ) { + + v = createLiteral(label,createURI(datatype.toString())); + + } else { + + v = createLiteral(label); + + } + + } else if( v instanceof BNode && ! ( v instanceof _BNode )) { + + v = createBNode( ((BNode)v).getID() ); + + } + + return v; + + } + public BNode createBNode() { |