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


Java ContextStatementImpl类代码示例

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


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

示例1: set

import org.openrdf.model.impl.ContextStatementImpl; //导入依赖的package包/类
private void set( URI ctx, URI subj, URI pref, boolean bool ) {
	try {
		rc.begin();
		rc.remove( subj, pref, null, ctx );
		rc.add( new ContextStatementImpl( subj, pref, vf.createLiteral( bool ), ctx ) );
		rc.commit();
	}
	catch ( Exception e ) {
		try {
			rc.rollback();
		}
		catch ( Exception ee ) {
			log.warn( ee, ee );
		}
		log.error( e, e );
	}
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:18,代码来源:StoredMetadata.java

示例2: readStatement

import org.openrdf.model.impl.ContextStatementImpl; //导入依赖的package包/类
public static Statement readStatement(String subjectString, String predicateString, String objectString, String contextString) {
    Resource subject = createResource(subjectString);
    URI predicate = VALUE_FACTORY.createURI(predicateString);

    boolean isObjectLiteral = objectString.startsWith("\"");

    Value object = null;
    if (isObjectLiteral) {
        object = parseLiteral(objectString);
    } else {
        object = createResource(objectString);
    }

    if (contextString == null || contextString.isEmpty()) {
        return new StatementImpl(subject, predicate, object);
    } else {
        Resource context = VALUE_FACTORY.createURI(contextString);
        return new ContextStatementImpl(subject, predicate, object, context);
    }
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:21,代码来源:StatementSerializer.java

示例3: readObject

import org.openrdf.model.impl.ContextStatementImpl; //导入依赖的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 input 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 TreeModel readObject(ObjectInput input) throws IOException, ClassNotFoundException {
    TreeModel model = new TreeModel();

    int size = input.readInt();
    for(int i=0; i<size; i++) {
        Resource subject = (Resource) input.readObject();
        URI predicate = (URI) input.readObject();
        Value object = (Value) input.readObject();

        boolean hasContext = input.readBoolean();
        if(hasContext) {
            Resource context = (Resource) input.readObject();

            model.add(new ContextStatementImpl(subject,predicate,object,context));
        } else {
            model.add(new StatementImpl(subject,predicate,object));
        }
    }

    return null;
}
 
开发者ID:apache,项目名称:marmotta,代码行数:34,代码来源:ModelExternalizer.java

示例4: preprocess

import org.openrdf.model.impl.ContextStatementImpl; //导入依赖的package包/类
private Statement preprocess(Statement st) {
	Resource context = st.getContext();
	URI trustyGraph = null;
	if (context != null) {
		if (context instanceof URI && moduleRB.matches((URI) context)) {
			trustyGraph = (URI) context;
		}
		context = transform(context, trustyGraph);
	}
	Resource subject = transform(st.getSubject(), trustyGraph);
	URI predicate = transform(st.getPredicate(), trustyGraph);
	Value object = st.getObject();
	if (object instanceof Resource) {
		object = transform((Resource) object, trustyGraph);
	}
	return new ContextStatementImpl(subject, predicate, object, context);
}
 
开发者ID:trustyuri,项目名称:trustyuri-java,代码行数:18,代码来源:RdfPreprocessor.java

示例5: testTrigInput

import org.openrdf.model.impl.ContextStatementImpl; //导入依赖的package包/类
@Test
public void testTrigInput() throws Exception {
    RdfFileInputFormat.setRDFFormat(job, RDFFormat.TRIG);
    init(TRIG_INPUT);
    Assert.assertTrue(reader.nextKeyValue());
    Assert.assertEquals(1, reader.getCurrentKey().get());
    Statement expected = new ContextStatementImpl(
        new URIImpl("http://www.example.org/exampleDocument#Monica"),
        new URIImpl("http://www.example.org/vocabulary#name"),
        new LiteralImpl("Monica Murphy"),
        new URIImpl("http://www.example.org/exampleDocument#G1"));
    Statement actual = RyaToRdfConversions.convertStatement(
        reader.getCurrentValue().getRyaStatement());
    Assert.assertEquals(expected, actual);
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:16,代码来源:RdfFileInputFormatTest.java

示例6: getStatements

import org.openrdf.model.impl.ContextStatementImpl; //导入依赖的package包/类
public Collection<Statement> getStatements() {
    Collection<Statement> statements = new ArrayList<Statement>();

    if (getContexts() != null && getContexts().length > 1) {
        for (Resource contxt : getContexts()) {
            statements.add(new ContextStatementImpl(getSubject(),
                    getPredicate(), getObject(), contxt));
        }
    } else
        statements.add(this);

    return statements;
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:14,代码来源:RdfCloudTripleStoreStatement.java

示例7: testDcSearch

import org.openrdf.model.impl.ContextStatementImpl; //导入依赖的package包/类
@Test
public void testDcSearch() throws Exception {
    // test a ring around dc
    try (final MongoGeoIndexer f = new MongoGeoIndexer()) {
        f.setConf(conf);
        f.init();

        final ValueFactory vf = new ValueFactoryImpl();
        final Resource subject = vf.createURI("foo:subj");
        final URI predicate = GeoConstants.GEO_AS_WKT;
        final Value object = vf.createLiteral("Point(-77.03524 38.889468)", GeoConstants.XMLSCHEMA_OGC_WKT);
        final Resource context = vf.createURI("foo:context");

        final Statement statement = new ContextStatementImpl(subject, predicate, object, context);
        f.storeStatement(convertStatement(statement));
        f.flush();

        final double[] IN = { -78, 39, -77, 39, -77, 38, -78, 38, -78, 39 };
        final LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(IN, 2));
        final Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});
        assertEquals(Sets.newHashSet(statement), getSet(f.queryWithin(p1, EMPTY_CONSTRAINTS)));

        // test a ring outside the point
        final double[] OUT = { -77, 39, -76, 39, -76, 38, -77, 38, -77, 39 };
        final LinearRing rOut = gf.createLinearRing(new PackedCoordinateSequence.Double(OUT, 2));
        final Polygon pOut = gf.createPolygon(rOut, new LinearRing[] {});
        assertEquals(Sets.newHashSet(), getSet(f.queryWithin(pOut, EMPTY_CONSTRAINTS)));
    }
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:30,代码来源:MongoGeoIndexerIT.java

示例8: testDeleteSearch

import org.openrdf.model.impl.ContextStatementImpl; //导入依赖的package包/类
@Test
public void testDeleteSearch() throws Exception {
    // test a ring around dc
    try (final MongoGeoIndexer f = new MongoGeoIndexer()) {
        f.setConf(conf);
        f.init();

        final ValueFactory vf = new ValueFactoryImpl();
        final Resource subject = vf.createURI("foo:subj");
        final URI predicate = GeoConstants.GEO_AS_WKT;
        final Value object = vf.createLiteral("Point(-77.03524 38.889468)", GeoConstants.XMLSCHEMA_OGC_WKT);
        final Resource context = vf.createURI("foo:context");

        final Statement statement = new ContextStatementImpl(subject, predicate, object, context);
        f.storeStatement(convertStatement(statement));
        f.flush();

        f.deleteStatement(convertStatement(statement));

        // test a ring that the point would be inside of if not deleted
        final double[] in = { -78, 39, -77, 39, -77, 38, -78, 38, -78, 39 };
        final LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(in, 2));
        final Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});
        assertEquals(Sets.newHashSet(), getSet(f.queryWithin(p1, EMPTY_CONSTRAINTS)));

        // test a ring that the point would be outside of if not deleted
        final double[] out = { -77, 39, -76, 39, -76, 38, -77, 38, -77, 39 };
        final LinearRing rOut = gf.createLinearRing(new PackedCoordinateSequence.Double(out, 2));
        final Polygon pOut = gf.createPolygon(rOut, new LinearRing[] {});
        assertEquals(Sets.newHashSet(), getSet(f.queryWithin(pOut, EMPTY_CONSTRAINTS)));

        // test a ring for the whole world and make sure the point is gone
        // Geomesa is a little sensitive around lon 180, so we only go to 179
        final double[] world = { -180, 90, 179, 90, 179, -90, -180, -90, -180, 90 };
        final LinearRing rWorld = gf.createLinearRing(new PackedCoordinateSequence.Double(world, 2));
        final Polygon pWorld = gf.createPolygon(rWorld, new LinearRing[] {});
        assertEquals(Sets.newHashSet(), getSet(f.queryWithin(pWorld, EMPTY_CONSTRAINTS)));
    }
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:40,代码来源:MongoGeoIndexerIT.java

示例9: testDcSearchWithContext

import org.openrdf.model.impl.ContextStatementImpl; //导入依赖的package包/类
@Test
public void testDcSearchWithContext() throws Exception {
    // test a ring around dc
    try (final MongoGeoIndexer f = new MongoGeoIndexer()) {
        f.setConf(conf);
        f.init();

        final ValueFactory vf = new ValueFactoryImpl();
        final Resource subject = vf.createURI("foo:subj");
        final URI predicate = GeoConstants.GEO_AS_WKT;
        final Value object = vf.createLiteral("Point(-77.03524 38.889468)", GeoConstants.XMLSCHEMA_OGC_WKT);
        final Resource context = vf.createURI("foo:context");

        final Statement statement = new ContextStatementImpl(subject, predicate, object, context);
        f.storeStatement(convertStatement(statement));
        f.flush();

        final double[] IN = { -78, 39, -77, 39, -77, 38, -78, 38, -78, 39 };
        final LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(IN, 2));
        final Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});

        // query with correct context
        assertEquals(Sets.newHashSet(statement), getSet(f.queryWithin(p1, new StatementConstraints().setContext(context))));

        // query with wrong context
        assertEquals(Sets.newHashSet(),
                getSet(f.queryWithin(p1, new StatementConstraints().setContext(vf.createURI("foo:context2")))));
    }
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:30,代码来源:MongoGeoIndexerIT.java

示例10: testDcSearchWithSubject

import org.openrdf.model.impl.ContextStatementImpl; //导入依赖的package包/类
@Test
public void testDcSearchWithSubject() throws Exception {
    // test a ring around dc
    try (final MongoGeoIndexer f = new MongoGeoIndexer()) {
        f.setConf(conf);
        f.init();

        final ValueFactory vf = new ValueFactoryImpl();
        final Resource subject = vf.createURI("foo:subj");
        final URI predicate = GeoConstants.GEO_AS_WKT;
        final Value object = vf.createLiteral("Point(-77.03524 38.889468)", GeoConstants.XMLSCHEMA_OGC_WKT);
        final Resource context = vf.createURI("foo:context");

        final Statement statement = new ContextStatementImpl(subject, predicate, object, context);
        f.storeStatement(convertStatement(statement));
        f.flush();

        final double[] IN = { -78, 39, -77, 39, -77, 38, -78, 38, -78, 39 };
        final LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(IN, 2));
        final Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});

        // query with correct subject
        assertEquals(Sets.newHashSet(statement), getSet(f.queryWithin(p1, new StatementConstraints().setSubject(subject))));

        // query with wrong subject
        assertEquals(Sets.newHashSet(), getSet(f.queryWithin(p1, new StatementConstraints().setSubject(vf.createURI("foo:subj2")))));
    }
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:29,代码来源:MongoGeoIndexerIT.java

示例11: testDcSearchWithSubjectAndContext

import org.openrdf.model.impl.ContextStatementImpl; //导入依赖的package包/类
@Test
public void testDcSearchWithSubjectAndContext() throws Exception {
    // test a ring around dc
    try (final MongoGeoIndexer f = new MongoGeoIndexer()) {
        f.setConf(conf);
        f.init();

        final ValueFactory vf = new ValueFactoryImpl();
        final Resource subject = vf.createURI("foo:subj");
        final URI predicate = GeoConstants.GEO_AS_WKT;
        final Value object = vf.createLiteral("Point(-77.03524 38.889468)", GeoConstants.XMLSCHEMA_OGC_WKT);
        final Resource context = vf.createURI("foo:context");

        final Statement statement = new ContextStatementImpl(subject, predicate, object, context);
        f.storeStatement(convertStatement(statement));
        f.flush();

        final double[] IN = { -78, 39, -77, 39, -77, 38, -78, 38, -78, 39 };
        final LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(IN, 2));
        final Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});

        // query with correct context subject
        assertEquals(Sets.newHashSet(statement),
                getSet(f.queryWithin(p1, new StatementConstraints().setContext(context).setSubject(subject))));

        // query with wrong context
        assertEquals(Sets.newHashSet(),
                getSet(f.queryWithin(p1, new StatementConstraints().setContext(vf.createURI("foo:context2")))));

        // query with wrong subject
        assertEquals(Sets.newHashSet(), getSet(f.queryWithin(p1, new StatementConstraints().setSubject(vf.createURI("foo:subj2")))));
    }
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:34,代码来源:MongoGeoIndexerIT.java

示例12: testDcSearchWithPredicate

import org.openrdf.model.impl.ContextStatementImpl; //导入依赖的package包/类
@Test
public void testDcSearchWithPredicate() throws Exception {
    // test a ring around dc
    try (final MongoGeoIndexer f = new MongoGeoIndexer()) {
        f.setConf(conf);
        f.init();

        final ValueFactory vf = new ValueFactoryImpl();
        final Resource subject = vf.createURI("foo:subj");
        final URI predicate = GeoConstants.GEO_AS_WKT;
        final Value object = vf.createLiteral("Point(-77.03524 38.889468)", GeoConstants.XMLSCHEMA_OGC_WKT);
        final Resource context = vf.createURI("foo:context");

        final Statement statement = new ContextStatementImpl(subject, predicate, object, context);
        f.storeStatement(convertStatement(statement));
        f.flush();

        final double[] IN = { -78, 39, -77, 39, -77, 38, -78, 38, -78, 39 };
        final LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(IN, 2));
        final Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});

        // query with correct Predicate
        assertEquals(Sets.newHashSet(statement),
                getSet(f.queryWithin(p1, new StatementConstraints().setPredicates(Collections.singleton(predicate)))));

        // query with wrong predicate
        assertEquals(Sets.newHashSet(),
                getSet(f.queryWithin(p1, new StatementConstraints().setPredicates(Collections.singleton(vf.createURI("other:pred"))))));
    }
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:31,代码来源:MongoGeoIndexerIT.java

示例13: testAntiMeridianSearch

import org.openrdf.model.impl.ContextStatementImpl; //导入依赖的package包/类
public void testAntiMeridianSearch() throws Exception {
    // verify that a search works if the bounding box crosses the anti meridian
    try (final MongoGeoIndexer f = new MongoGeoIndexer()) {
        f.setConf(conf);
        f.init();

        final ValueFactory vf = new ValueFactoryImpl();
        final Resource context = vf.createURI("foo:context");

        final Resource subjectEast = vf.createURI("foo:subj:east");
        final URI predicateEast = GeoConstants.GEO_AS_WKT;
        final Value objectEast = vf.createLiteral("Point(179 0)", GeoConstants.XMLSCHEMA_OGC_WKT);
        final Statement statementEast = new ContextStatementImpl(subjectEast, predicateEast, objectEast, context);
        f.storeStatement(convertStatement(statementEast));

        final Resource subjectWest = vf.createURI("foo:subj:west");
        final URI predicateWest = GeoConstants.GEO_AS_WKT;
        final Value objectWest = vf.createLiteral("Point(-179 0)", GeoConstants.XMLSCHEMA_OGC_WKT);
        final Statement statementWest = new ContextStatementImpl(subjectWest, predicateWest, objectWest, context);
        f.storeStatement(convertStatement(statementWest));

        f.flush();

        final double[] ONE = { 178.1, 1, -178, 1, -178, -1, 178.1, -1, 178.1, 1 };

        final LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(ONE, 2));

        final Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});

        assertEquals(Sets.newHashSet(statementEast, statementWest), getSet(f.queryWithin(p1, EMPTY_CONSTRAINTS)));
    }
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:33,代码来源:MongoGeoIndexerIT.java

示例14: testDcSearch

import org.openrdf.model.impl.ContextStatementImpl; //导入依赖的package包/类
@Test
public void testDcSearch() throws Exception {
    // test a ring around dc
    try (final GeoWaveGeoIndexer f = new GeoWaveGeoIndexer()) {
        f.setConf(conf);
        f.purge(conf);

        final ValueFactory vf = new ValueFactoryImpl();
        final Resource subject = vf.createURI("foo:subj");
        final URI predicate = GeoConstants.GEO_AS_WKT;
        final Value object = vf.createLiteral("Point(-77.03524 38.889468)", GeoConstants.XMLSCHEMA_OGC_WKT);
        final Resource context = vf.createURI("foo:context");

        final Statement statement = new ContextStatementImpl(subject, predicate, object, context);
        f.storeStatement(convertStatement(statement));
        f.flush();

        final double[] IN = { -78, 39, -77, 39, -77, 38, -78, 38, -78, 39 };
        final LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(IN, 2));
        final Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});
        Assert.assertEquals(Sets.newHashSet(statement), getSet(f.queryWithin(p1, EMPTY_CONSTRAINTS)));

        // test a ring outside the point
        final double[] OUT = { -77, 39, -76, 39, -76, 38, -77, 38, -77, 39 };
        final LinearRing rOut = gf.createLinearRing(new PackedCoordinateSequence.Double(OUT, 2));
        final Polygon pOut = gf.createPolygon(rOut, new LinearRing[] {});
        Assert.assertEquals(Sets.newHashSet(), getSet(f.queryWithin(pOut, EMPTY_CONSTRAINTS)));
    }
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:30,代码来源:GeoWaveIndexerTest.java

示例15: testDeleteSearch

import org.openrdf.model.impl.ContextStatementImpl; //导入依赖的package包/类
@Test
public void testDeleteSearch() throws Exception {
    // test a ring around dc
    try (final GeoWaveGeoIndexer f = new GeoWaveGeoIndexer()) {
        f.setConf(conf);
        f.purge(conf);

        final ValueFactory vf = new ValueFactoryImpl();
        final Resource subject = vf.createURI("foo:subj");
        final URI predicate = GeoConstants.GEO_AS_WKT;
        final Value object = vf.createLiteral("Point(-77.03524 38.889468)", GeoConstants.XMLSCHEMA_OGC_WKT);
        final Resource context = vf.createURI("foo:context");

        final Statement statement = new ContextStatementImpl(subject, predicate, object, context);
        f.storeStatement(convertStatement(statement));
        f.flush();

        f.deleteStatement(convertStatement(statement));

        // test a ring that the point would be inside of if not deleted
        final double[] in = { -78, 39, -77, 39, -77, 38, -78, 38, -78, 39 };
        final LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(in, 2));
        final Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});
        Assert.assertEquals(Sets.newHashSet(), getSet(f.queryWithin(p1, EMPTY_CONSTRAINTS)));

        // test a ring that the point would be outside of if not deleted
        final double[] out = { -77, 39, -76, 39, -76, 38, -77, 38, -77, 39 };
        final LinearRing rOut = gf.createLinearRing(new PackedCoordinateSequence.Double(out, 2));
        final Polygon pOut = gf.createPolygon(rOut, new LinearRing[] {});
        Assert.assertEquals(Sets.newHashSet(), getSet(f.queryWithin(pOut, EMPTY_CONSTRAINTS)));

        // test a ring for the whole world and make sure the point is gone
        final double[] world = { -180, 90, 180, 90, 180, -90, -180, -90, -180, 90 };
        final LinearRing rWorld = gf.createLinearRing(new PackedCoordinateSequence.Double(world, 2));
        final Polygon pWorld = gf.createPolygon(rWorld, new LinearRing[] {});
        Assert.assertEquals(Sets.newHashSet(), getSet(f.queryWithin(pWorld, EMPTY_CONSTRAINTS)));
    }
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:39,代码来源:GeoWaveIndexerTest.java


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