当前位置: 首页>>代码示例>>Java>>正文


Java LiteralImpl类代码示例

本文整理汇总了Java中org.openrdf.model.impl.LiteralImpl的典型用法代码示例。如果您正苦于以下问题:Java LiteralImpl类的具体用法?Java LiteralImpl怎么用?Java LiteralImpl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


LiteralImpl类属于org.openrdf.model.impl包,在下文中一共展示了LiteralImpl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testExec3

import org.openrdf.model.impl.LiteralImpl; //导入依赖的package包/类
@Test
public void testExec3() throws Exception {
	InMemorySesameEngine eng = InMemorySesameEngine.open();
	StatementAddingExecutor sae = new StatementAddingExecutor(
			Arrays.asList( new StatementImpl( RDFS.DOMAIN, RDFS.LABEL,
							new LiteralImpl( "label" ) ) ), true );
	sae.resetStatements( new StatementImpl( RDFS.DOMAIN, RDFS.LABEL,
			new LiteralImpl( "tester" ) ) );

	Model before = eng.toModel();
	eng.execute( sae );
	Model after = eng.toModel();
	eng.closeDB();
	assertTrue( ( before.size() + 1 ) == after.size() );

	assertTrue( after.contains( RDFS.DOMAIN, RDFS.LABEL, new LiteralImpl( "tester" ) ) );
	assertFalse( after.contains( RDFS.DOMAIN, RDFS.LABEL, new LiteralImpl( "label" ) ) );
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:19,代码来源:StatementAddingExecutorTest.java

示例2: setUp

import org.openrdf.model.impl.LiteralImpl; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
	Repository fromrepo = new SailRepository( new MemoryStore() );
	Repository torepo = new SailRepository( new MemoryStore() );

	fromrepo.initialize();
	torepo.initialize();

	from = fromrepo.getConnection();
	to = torepo.getConnection();

	from.add( new StatementImpl( RDFS.DOMAIN, RDFS.LABEL,
			new LiteralImpl( "test" ) ) );
	from.add( new StatementImpl( RDFS.DOMAIN, RDFS.LABEL,
			new LiteralImpl( "test2" ) ) );
	from.setNamespace( OWL.PREFIX, OWL.NAMESPACE );
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:18,代码来源:RepositoryCopierTest.java

示例3: testClear

import org.openrdf.model.impl.LiteralImpl; //导入依赖的package包/类
@Test
public void testClear() throws Exception {
	StatementAddingExecutor sae = new StatementAddingExecutor();
	sae.addStatement( new StatementImpl( RDFS.DATATYPE, RDFS.LABEL,
			new LiteralImpl( "test label" ) ) );
	eng.execute( sae );

	ListQueryAdapter<URI> q
			= OneVarListQueryAdapter.getUriList( "SELECT ?s WHERE { ?s rdfs:label ?o }" );

	List<URI> addeduris = new ArrayList<>( eng.queryNoEx( q ) );
	q.clear();

	EngineUtil2.clear( eng );
	List<URI> newuris = eng.queryNoEx( q );

	assertNotEquals( addeduris, newuris );
	assertTrue( newuris.isEmpty() );
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:20,代码来源:EngineUtil2Test.java

示例4: compareData

import org.openrdf.model.impl.LiteralImpl; //导入依赖的package包/类
private void compareData( RepositoryConnection testRc, Model expected,
		UriBuilder owl, UriBuilder base ) throws Exception {
	List<Statement> stmts
			= Iterations.asList( testRc.getStatements( null, null, null, false ) );

	Model test = new LinkedHashModel( stmts );

	assertEquals( "dataset size", expected.size(), test.size() );

	compare( "category concept", expected, test, null, RDF.TYPE,
			owl.getConceptUri( "Category" ) );
	compare( "beverages concept", expected, test,
			base.getConceptUri().add( "Category" ).add( "Beverages" ).build(),
			null, null );
	compare( "dairy products", expected, test,
			null, RDFS.LABEL, new LiteralImpl( "Dairy Products" ) );
	compare( "chai-beverages link", expected, test,
			null, RDFS.LABEL, new LiteralImpl( "Chai Category Beverages" ) );

	URI bev
			= base.getRelationUri().add( "Category" ).add( "Chai_x_Beverages" ).build();
	compare( "chai-beverages category", expected, test,
			bev, RDFS.SUBPROPERTYOF, owl.getRelationUri( "Category" ) );
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:25,代码来源:EngineLoaderTest.java

示例5: testModifyData

import org.openrdf.model.impl.LiteralImpl; //导入依赖的package包/类
@Test
public void testModifyData() throws Exception {
	instance.execute( new ModificationExecutorAdapter( true ) {

		@Override
		public void exec( RepositoryConnection conn ) throws RepositoryException {
			conn.add( new URIImpl( "http://foo.bar/testuri" ), RDFS.LABEL,
					new LiteralImpl( "extra" ) );
		}

	} );

	OneVarListQueryAdapter<String> lqa
			= OneVarListQueryAdapter.getStringList( "SELECT ?label { ?s rdfs:label ?label }" );
	Set<String> names = new HashSet<>( instance.query( lqa ) );
	Set<String> expected = new HashSet<>( Arrays.asList( "Reification", "RDR Reification",
			"Alan", "First Name", "Purchased", "Reification Model", "Date", "Yugo",
			"Cadillac", "Price", "Car", "Database", "Yuri", "OS-EM Semantic Toolkit Reification",
			"Has", "Last Name", "W3C Reification", "Human Being", "Data View", "extra" ) );
	instance.closeDB();
	assertEquals( expected, names );
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:23,代码来源:JenaEngineTest.java

示例6: setUp

import org.openrdf.model.impl.LiteralImpl; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
	eng = InMemorySesameEngine.open();

	RepositoryConnection rc = eng.getRawConnection();
	rc.begin();
	rc.add( DATA, null, RDFFormat.NTRIPLES );
	rc.add( new StatementImpl( RDFS.DOMAIN, RDFS.LABEL,
			new LiteralImpl( "label" ) ) );

	rc.remove( eng.getBaseUri(), MetadataConstants.DCT_MODIFIED, null );
	rc.add( eng.getBaseUri(), MetadataConstants.DCT_MODIFIED,
			rc.getValueFactory().createLiteral( new Date() ) );

	rc.commit();
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:17,代码来源:InMemorySesameEngineTest.java

示例7: testGetLabels

import org.openrdf.model.impl.LiteralImpl; //导入依赖的package包/类
@Test
public void testGetLabels() throws Exception {
	InMemorySesameEngine eng = InMemorySesameEngine.open();
	eng.getRawConnection().begin();
	eng.getRawConnection().add( new StatementImpl( RDFS.ISDEFINEDBY,
			RDFS.LABEL, new LiteralImpl( "my label" ) ) );
	eng.getRawConnection().add( new StatementImpl( RDFS.MEMBER,
			RDFS.LABEL, new LiteralImpl( "my label 2" ) ) );
	eng.getRawConnection().commit();

	String label = Utility.getInstanceLabel( RDFS.ISDEFINEDBY, eng );
	assertEquals( "my label", label );

	Map<Resource, String> labels = Utility.getInstanceLabels( null, eng );
	assertTrue( labels.isEmpty() );

	labels = Utility.getInstanceLabels( Arrays.asList(
			RDFS.MEMBER, RDFS.DOMAIN ), eng );
	assertEquals( "domain", labels.get( RDFS.DOMAIN ) );
	assertEquals( "my label 2", labels.get( RDFS.MEMBER ) );

	labels = Utility.getInstanceLabels( Arrays.asList( RDFS.ISDEFINEDBY,
			RDFS.LITERAL ), null );
	assertEquals( 2, labels.size() );
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:26,代码来源:UtilityTest.java

示例8: simpleQueryWithoutBindingSet

import org.openrdf.model.impl.LiteralImpl; //导入依赖的package包/类
@Test
public void simpleQueryWithoutBindingSet() throws Exception {
    StatementMetadata metadata = new StatementMetadata();
    metadata.addMetadata(new RyaURI("http://createdBy"), new RyaType("Joe"));
    metadata.addMetadata(new RyaURI("http://createdOn"), new RyaType(XMLSchema.DATE, "2017-01-04"));

    RyaStatement statement = new RyaStatement(new RyaURI("http://Joe"), new RyaURI("http://worksAt"),
            new RyaType("CoffeeShop"), new RyaURI("http://context"), "", metadata);
    dao.add(statement);

    TupleQueryResult result = conn.prepareTupleQuery(QueryLanguage.SPARQL, query1).evaluate();

    QueryBindingSet bs = new QueryBindingSet();
    bs.addBinding("x", new LiteralImpl("CoffeeShop"));
    bs.addBinding("y", new LiteralImpl("Joe"));

    List<BindingSet> bsList = new ArrayList<>();
    while (result.hasNext()) {
        bsList.add(result.next());
    }

    System.out.println(bsList);
    Assert.assertEquals(1, bsList.size());
    Assert.assertEquals(bs, bsList.get(0));
    dao.delete(statement, (AccumuloRdfConfiguration) conf);
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:27,代码来源:AccumuloStatementMetadataOptimizerIT.java

示例9: basicMixUriLiteralBsTest

import org.openrdf.model.impl.LiteralImpl; //导入依赖的package包/类
@Test
public void basicMixUriLiteralBsTest() throws BindingSetConversionException {
	final QueryBindingSet bs = new QueryBindingSet();
	bs.addBinding("X",new LiteralImpl("literal1"));
	bs.addBinding("Y",new LiteralImpl("5", new URIImpl("http://www.w3.org/2001/XMLSchema#integer")));
	bs.addBinding("Z",new LiteralImpl("5.0", new URIImpl("http://www.w3.org/2001/XMLSchema#double")));
	bs.addBinding("W",new LiteralImpl("1000", new URIImpl("http://www.w3.org/2001/XMLSchema#long")));
	bs.addBinding("A",new URIImpl("http://uri1"));
	bs.addBinding("B",new URIImpl("http://uri2"));
	bs.addBinding("C",new URIImpl("http://uri3"));
	final VariableOrder varOrder = new VariableOrder("A","W","X","Y","Z","B","C");

	BindingSetConverter<byte[]> converter = new AccumuloPcjSerializer();
	final byte[] byteVal = converter.convert(bs, varOrder);
	final BindingSet newBs = converter.convert(byteVal, varOrder);
	assertEquals(bs, newBs);
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:18,代码来源:AccumuloPcjSerializerTest.java

示例10: getDefaultValue

import org.openrdf.model.impl.LiteralImpl; //导入依赖的package包/类
private Object getDefaultValue(String value, Type type, ObjectConnection con) {
	Class<?> ctype = asClass(type);
	if (Set.class.equals(ctype)) {
		Object v = getDefaultValue(value, getComponentType(ctype, type), con);
		if (v == null)
			return null;
		return Collections.singleton(v);
	}
	ValueFactory vf = con.getValueFactory();
	ObjectFactory of = con.getObjectFactory();
	if (of.isDatatype(ctype)) {
		URIImpl datatype = new URIImpl("java:" + ctype.getName());
		return of.createValue(of.createObject(new LiteralImpl(value, datatype)));
	}
	return vf.createURI(value);
}
 
开发者ID:anno4j,项目名称:anno4j,代码行数:17,代码来源:SparqlParameters.java

示例11: checkPrimitive

import org.openrdf.model.impl.LiteralImpl; //导入依赖的package包/类
/**
 * Checks whether the given object is a primitive type and, if so, will
 * return a Node that encodes it. Otherwise NULL is returned.
 *
 * @param o The object to check
 * @return a Node or NULL
 */
private Value checkPrimitive( final Object o )
{
	if( o instanceof String ) return new LiteralImpl( o.toString() );

	if( o instanceof Integer )
		return new ValueFactoryImpl().createLiteral( (Integer) o );

	if( o instanceof Float )
		return new ValueFactoryImpl().createLiteral( (Float) o );

	if( o instanceof Double )
		return new ValueFactoryImpl().createLiteral( (Double) o );

	if( o instanceof URI || o instanceof URL || o instanceof java.net.URI )
		return new URIImpl( o.toString() );

	return null;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:26,代码来源:RDFSerializer.java

示例12: asRdbmsLiteral

import org.openrdf.model.impl.LiteralImpl; //导入依赖的package包/类
/****************************************************/
public RdbmsLiteral asRdbmsLiteral(GeneralDBPolyhedron polyhedron) {
  try {
    URI wkt = new URIImpl(GeoConstants.WKT);
    RdbmsLiteral literal =
        new RdbmsLiteral(polyhedron.getInternalId(), polyhedron.getVersion(), new LiteralImpl(
            polyhedron.stringValue(), wkt));

    if (polyhedron instanceof GeneralDBPolyhedron) {
      literals.cache(literal);
      return (RdbmsLiteral) literal;
    }

    RdbmsLiteral lit = literals.findInCache(literal);

    if (lit == null) {
      lit = new RdbmsLiteral(literal);
      literals.cache(lit);
    }
    return lit;
  } catch (InterruptedException e) {
    throw new RdbmsRuntimeException(e);
  }
}
 
开发者ID:esarbanis,项目名称:strabon,代码行数:25,代码来源:GeneralDBValueFactory.java

示例13: readObject

import org.openrdf.model.impl.LiteralImpl; //导入依赖的package包/类
/**
 * Read an instance from the stream.  The instance will have been written by the
 * {@link #writeObject(java.io.ObjectOutput, Object)} method.  Implementations are free
 * to create instances of the object read from the stream in any way that they
 * feel like. This could be via constructor, factory or reflection.
 *
 * @param in the object input to read from
 * @return the object instance
 * @throws java.io.IOException            if an I/O error occurs
 * @throws ClassNotFoundException if a class could not be found
 */
@Override
public Value readObject(ObjectInput in) throws IOException, ClassNotFoundException {
    int type = in.readInt();

    String label = DataIO.readString(in);
    switch (type) {
        case TYPE_URI:
            return new URIImpl(label);
        case TYPE_BNODE:
            return new BNodeImpl(label);
        case TYPE_LITERAL:
            String lang  = DataIO.readString(in);
            String dtype  = DataIO.readString(in);

            if(lang != null) {
                return new LiteralImpl(label,lang);
            } else if(dtype != null) {
                return new LiteralImpl(label, new URIImpl(dtype));
            } else {
                return new LiteralImpl(label);
            }
    }
    throw new ClassNotFoundException("could not find class with type "+type);
}
 
开发者ID:apache,项目名称:marmotta,代码行数:36,代码来源:ValueExternalizer.java

示例14: setLabels

import org.openrdf.model.impl.LiteralImpl; //导入依赖的package包/类
private void setLabels(URI concept1uri, URI concept2uri, int delay) throws RepositoryException, InterruptedException {        
    Statement defPrefLabel = new StatementImpl(concept1uri, SKOS.PREF_LABEL, new LiteralImpl("concept"));
    Statement updatePrefLabel = new StatementImpl(concept2uri, SKOS.PREF_LABEL, new LiteralImpl("updated concept"));

    persistAndNotifyProvider.persistAndNotify(
            Helper.createChangeSetModel(defPrefLabel, ChangeTripleService.CHANGETYPE_ADD),
            true);

    persistAndNotifyProvider.persistAndNotify(
            Helper.createChangeSetModel(defPrefLabel, ChangeTripleService.CHANGETYPE_REMOVE),
            true);

    Thread.sleep(delay);

    persistAndNotifyProvider.persistAndNotify(
            Helper.createChangeSetModel(updatePrefLabel, ChangeTripleService.CHANGETYPE_ADD),
            true);
}
 
开发者ID:rsine,项目名称:rsine,代码行数:19,代码来源:LabelUpdateTest.java

示例15: enrichIncompleteIndex

import org.openrdf.model.impl.LiteralImpl; //导入依赖的package包/类
@Override
public void enrichIncompleteIndex(NanopubCreator npCreator) {
	if (title != null) {
		npCreator.addPubinfoStatement(DC.TITLE, new LiteralImpl(title));
	}
	for (String creator : creators) {
		if (creator.indexOf("://") > 0) {
			npCreator.addCreator(new URIImpl(creator));
		} else if (creator.matches("[0-9]{4}-[0-9]{4}-[0-9]{4}-[0-9]{3}[0-9X]")) {
			npCreator.addCreator(creator);
		} else {
			throw new IllegalArgumentException("Author has to be URI or ORCID: " + creator);
		}
	}
	for (URI seeAlsoUri : seeAlsoUris) {
		npCreator.addPubinfoStatement(RDFS.SEEALSO, seeAlsoUri);
	}
}
 
开发者ID:Nanopublication,项目名称:nanopub-java,代码行数:19,代码来源:SimpleIndexCreator.java


注:本文中的org.openrdf.model.impl.LiteralImpl类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。