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


Java XMLSchema类代码示例

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


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

示例1: getDatatype

import org.openrdf.model.vocabulary.XMLSchema; //导入依赖的package包/类
/**
 * Gets the datatype of the given val. If val is null, returns null. It
 * returns {@link XMLSchema#ANYURI} for a URI, {@link XMLSchema#ENTITY} for a
 * BNode, and {@link Literal#getDatatype()} if it's a literal. If it's not a
 * {@link Value}, then it is converted to a Value first, and reprocessed. If
 * we have a literal, but a null datatype, returns {@link XMLSchema#STRING}
 *
 * @param val
 * @return
 */
public static URI getDatatype( Object val ) {
	if ( null == val ) {
		return null;
	}

	if ( val instanceof URI ) {
		return XMLSchema.ANYURI;
	}
	else if ( val instanceof Literal ) {
		Literal l = Literal.class.cast( val );
		return ( null == l.getDatatype() ? XMLSchema.STRING : l.getDatatype() );
	}
	else if ( val instanceof BNode ) {
		return XMLSchema.ENTITY;
	}

	Class<?> theClass = val.getClass();
	return REVTYPELOOKUP.getOrDefault( theClass, XMLSchema.STRING );
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:30,代码来源:RDFDatatypeTools.java

示例2: createProcessors

import org.openrdf.model.vocabulary.XMLSchema; //导入依赖的package包/类
/**
 * Matches user inputed column type in prop file to the specific variable type
 * name within Java SuperCSV API
 */
public void createProcessors() {
	// Columns in prop file that are NON_OPTIMAL must contain a value
	Map<String, URI> dtlkp = new HashMap<>();
	dtlkp.put( "Double", XMLSchema.DOUBLE );
	dtlkp.put( "Int", XMLSchema.INT );
	dtlkp.put( "Integer", XMLSchema.INTEGER );
	dtlkp.put( "Float", XMLSchema.FLOAT );
	dtlkp.put( "String", XMLSchema.STRING );

	for ( int col = 0; col < header.length; col++ ) {
		// find the type for each column
		String type = rdfMap.getProperty( Integer.toString( col + 1 ), null );

		// we have some sort of datatype to worry about, so keep track of it
		if ( dtlkp.containsKey( type ) ) {
			datatypes.put( header[col], dtlkp.get( type ) );
		}
	}
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:24,代码来源:CSVReader.java

示例3: getType

import org.openrdf.model.vocabulary.XMLSchema; //导入依赖的package包/类
/**
 * Gets the currently-selected data type.
 *
 * @return The datatype, or null if the datatype is {@link XMLSchema#STRING},
 * or {@link XMLSchema#ANYURI} if "URI" was selected.
 */
public URI getType() {
	Enumeration<AbstractButton> radios = typegroup.getElements();
	while ( radios.hasMoreElements() ) {
		AbstractButton radio = radios.nextElement();
		if ( radio.isSelected() ) {
			String command = radio.getActionCommand();

			for ( Map.Entry<Class<?>, URI> types : typelookup.entrySet() ) {
				if ( types.getKey().getSimpleName().equalsIgnoreCase( command ) ) {
					if ( XMLSchema.STRING.equals( types.getValue() ) ) {
						return null;
					}
					return types.getValue();
				}
			}
		}
	}

	return XMLSchema.ANYURI;
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:27,代码来源:ConstraintPanel.java

示例4: populateRows

import org.openrdf.model.vocabulary.XMLSchema; //导入依赖的package包/类
public final void populateRows() {
	rows = new ArrayList<>();
	URI datatypeURI;
	for ( GraphElement vertex : pickedVertices ) {
		for ( Map.Entry<URI, Value> entry : vertex.getValues().entrySet() ) {
			// don't edit the SUBJECT field (it's just an ID for the vertex)
			if( !RDF.SUBJECT.equals( entry.getKey()) ){
				if ( entry.getValue() instanceof Literal ) {
					Literal literal = (Literal) entry.getValue();
					if ( literal.getDatatype() == null ) {
						datatypeURI = XMLSchema.STRING;
					}
					else {
						datatypeURI = literal.getDatatype();
					}
					rows.add( new PropertyEditorRow( vertex, entry.getKey(), datatypeURI,
							entry.getValue() ) );
				}
				else if ( entry.getValue() instanceof URI ) {
					rows.add( new PropertyEditorRow( vertex, entry.getKey(), XMLSchema.ANYURI,
							entry.getValue() ) );
				}
			}
		}
	}
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:27,代码来源:PropertyEditorTableModel.java

示例5: serializeAssociationTypes

import org.openrdf.model.vocabulary.XMLSchema; //导入依赖的package包/类
private void serializeAssociationTypes( final EntityDescriptor entityDescriptor,
                                        final Graph graph,
                                        final URI entityTypeUri
)
{
    ValueFactory values = graph.getValueFactory();
    // Associations
    entityDescriptor.state().associations().forEach( associationType -> {
        URI associationURI = values.createURI( associationType.qualifiedName().toURI() );
        graph.add( associationURI, Rdfs.DOMAIN, entityTypeUri );
        graph.add( associationURI, Rdfs.TYPE, Rdfs.PROPERTY );

        URI associatedURI = values.createURI( Classes.toURI( Classes.RAW_CLASS.apply( associationType.type() ) ) );
        graph.add( associationURI, Rdfs.RANGE, associatedURI );
        graph.add( associationURI, Rdfs.RANGE, XMLSchema.ANYURI );
    } );
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:18,代码来源:EntityTypeSerializer.java

示例6: testLiteralTypes

import org.openrdf.model.vocabulary.XMLSchema; //导入依赖的package包/类
@Test
public void testLiteralTypes() throws Exception {
    RyaURI cpu = new RyaURI(litdupsNS + "cpu");
    RyaURI loadPerc = new RyaURI(litdupsNS + "loadPerc");
    RyaType longLit = new RyaType(XMLSchema.LONG, "3");

    dao.add(new RyaStatement(cpu, loadPerc, longLit));

    AccumuloRyaQueryEngine queryEngine = dao.getQueryEngine();

    CloseableIteration<RyaStatement, RyaDAOException> query = queryEngine.query(new RyaStatement(cpu, null, null), conf);
    assertTrue(query.hasNext());
    RyaStatement next = query.next();
    assertEquals(new Long(longLit.getData()), new Long(next.getObject().getData()));
    query.close();

    RyaType doubleLit = new RyaType(XMLSchema.DOUBLE, "2.0");

    dao.add(new RyaStatement(cpu, loadPerc, doubleLit));

    query = queryEngine.query(new RyaStatement(cpu, loadPerc, doubleLit), conf);
    assertTrue(query.hasNext());
    next = query.next();
    assertEquals(Double.parseDouble(doubleLit.getData()), Double.parseDouble(next.getObject().getData()), 0.001);
    query.close();
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:27,代码来源:AccumuloRyaDAOTest.java

示例7: testLiterals

import org.openrdf.model.vocabulary.XMLSchema; //导入依赖的package包/类
@Test
public void testLiterals()
        throws OpenRDFException
{
    ValueFactory vf= conn.getValueFactory();
    URI fei = vf.createURI("http://marklogicsparql.com/id#3333");
    URI lname = vf.createURI("http://marklogicsparql.com/addressbook#lastName");
    URI age = vf.createURI("http://marklogicsparql.com/addressbook#age");

    Literal feilname = vf.createLiteral("Ling", "zh");
    //Literal shouldfail = vf.createLiteral(1, "zh");
    Literal invalidIntegerLiteral = vf.createLiteral("four", XMLSchema.INTEGER);
    Literal feiage = vf.createLiteral(25);

    conn.add(fei, lname, feilname);
    conn.add(fei, age, feiage);
    //conn.add(fei, age, invalidIntegerLiteral);
    logger.info("lang:{}", conn.hasStatement(vf.createStatement(fei, lname, vf.createLiteral("Ling", "zh")), false));
    logger.info("size:{}", conn.size());
    Assert.assertFalse("The lang tag of lname is not en", conn.hasStatement(vf.createStatement(fei, lname, vf.createLiteral("Ling", "en")), false));
    Assert.assertTrue("The lang tag of lname is zh", conn.hasStatement(vf.createStatement(fei, lname, feilname), false));
    Assert.assertFalse(conn.isEmpty());
}
 
开发者ID:marklogic,项目名称:marklogic-sesame,代码行数:24,代码来源:MarkLogicRepositoryConnectionTest.java

示例8: testGetStatementsMalformedTypedLiteral

import org.openrdf.model.vocabulary.XMLSchema; //导入依赖的package包/类
@Test
public void testGetStatementsMalformedTypedLiteral()
	throws Exception
{

	testAdminCon.getParserConfig().addNonFatalError(BasicParserSettings.VERIFY_DATATYPE_VALUES);
	Literal invalidIntegerLiteral = vf.createLiteral("four", XMLSchema.INTEGER);
	try {
		testAdminCon.add(micah, homeTel, invalidIntegerLiteral, dirgraph);

		RepositoryResult<Statement> statements = testAdminCon.getStatements(micah, homeTel, null, true);

		assertNotNull(statements);
		assertTrue(statements.hasNext());
		Statement st = statements.next();
		assertTrue(st.getObject() instanceof Literal);
		assertTrue(st.getObject().equals(invalidIntegerLiteral));
	}
	catch (RepositoryException e) {
		// shouldn't happen
		fail(e.getMessage());
	}
}
 
开发者ID:marklogic,项目名称:marklogic-sesame,代码行数:24,代码来源:MarkLogicRepositoryConnectionTest.java

示例9: testDay

import org.openrdf.model.vocabulary.XMLSchema; //导入依赖的package包/类
public void testDay() throws Exception {
	TestConcept tester = manager.addDesignation(manager.getObjectFactory().createObject(), TestConcept.class);
	Resource bNode = (Resource) manager.addObject(tester);
	Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
	cal.set(1970, 0, 1, 0, 0, 0);
	cal.set(Calendar.MILLISECOND, 0);
	Date date = cal.getTime();
	try {
		manager.add(bNode, dateURI, getValueFactory().createLiteral(
				"1970-01-01Z", XMLSchema.DATE));
	} catch (RepositoryException e) {
		throw new ObjectPersistException(e);
	}
	cal.setTime(tester.getADate());
	assertEquals(date, cal.getTime());
}
 
开发者ID:anno4j,项目名称:anno4j,代码行数:17,代码来源:LiteralTest.java

示例10: toValue

import org.openrdf.model.vocabulary.XMLSchema; //导入依赖的package包/类
/**
 * Creates a {@link Value} from a String representation of it.
 *
 * @param valueString - The String representation of the value. (not null)
 * @return The {@link Value} representation of the String.
 */
protected static Value toValue(final String valueString) {
    requireNonNull(valueString);

    // Split the String that was stored in Fluo into its Value and Type parts.
    final String[] valueAndType = valueString.split(TYPE_DELIM);
    if(valueAndType.length != 2) {
        throw new IllegalArgumentException("Array must contain data and type info!");
    }

    final String dataString = valueAndType[0];
    final String typeString = valueAndType[1];

    // Convert the String Type into a URI that describes the type.
    final URI typeURI = valueFactory.createURI(typeString);

    // Convert the String Value into a Value.
    final Value value = typeURI.equals(XMLSchema.ANYURI) ?
            valueFactory.createURI(dataString) :
            valueFactory.createLiteral(dataString, new URIImpl(typeString));

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

示例11: average

import org.openrdf.model.vocabulary.XMLSchema; //导入依赖的package包/类
@Test
public void average() throws Exception  {
    // A query that finds the average price for an item that is in the inventory.
    final String sparql =
            "SELECT (avg(?price) as ?averagePrice) { " +
                "?item <urn:price> ?price . " +
            "}";

    // Create the Statements that will be loaded into Rya.
    final ValueFactory vf = new ValueFactoryImpl();
    final Collection<Statement> statements = Sets.newHashSet(
            vf.createStatement(vf.createURI("urn:apple"), vf.createURI("urn:price"), vf.createLiteral(3)),
            vf.createStatement(vf.createURI("urn:gum"), vf.createURI("urn:price"), vf.createLiteral(4)),
            vf.createStatement(vf.createURI("urn:sandwich"), vf.createURI("urn:price"), vf.createLiteral(8)));

    // Create the PCJ in Fluo and load the statements into Rya.
    final String pcjId = loadDataAndCreateQuery(sparql, statements);

    // Create the expected results of the SPARQL query once the PCJ has been computed.
    final MapBindingSet expectedResult = new MapBindingSet();
    expectedResult.addBinding("averagePrice", vf.createLiteral("5", XMLSchema.DECIMAL));

    // Ensure the last result matches the expected result.
    final VisibilityBindingSet result = readLastResult(pcjId);
    assertEquals(expectedResult, result);
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:27,代码来源:KafkaExportIT.java

示例12: can_not_create_with_same_subject

import org.openrdf.model.vocabulary.XMLSchema; //导入依赖的package包/类
@Test
public void can_not_create_with_same_subject() throws Exception {
    // A Type that will be stored.
    final Entity entity = Entity.builder()
            .setSubject(new RyaURI("urn:GTIN-14/00012345600012"))
            .setExplicitType(new RyaURI("urn:icecream"))
            .setProperty(new RyaURI("urn:icecream"), new Property(new RyaURI("urn:brand"), new RyaType(XMLSchema.STRING, "Awesome Icecream")))
            .setProperty(new RyaURI("urn:icecream"), new Property(new RyaURI("urn:flavor"), new RyaType(XMLSchema.STRING, "Chocolate")))
            .build();

    // Create it.
    final EntityStorage storage = new MongoEntityStorage(super.getMongoClient(), RYA_INSTANCE_NAME);
    storage.create(entity);

    // Try to create it again. This will fail.
    boolean failed = false;
    try {
        storage.create(entity);
    } catch(final EntityAlreadyExistsException e) {
        failed = true;
    }
    assertTrue(failed);
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:24,代码来源:MongoEntityStorageIT.java

示例13: emit

import org.openrdf.model.vocabulary.XMLSchema; //导入依赖的package包/类
private Rendering emit(final Literal literal) {
    if (XMLSchema.INTEGER.equals(literal.getDatatype())) {
        this.builder.append(literal.getLabel());
    } else {
        this.builder.append("\"");
        escape(literal.getLabel(), this.builder);
        this.builder.append("\"");
        if (literal.getDatatype() != null) {
            this.builder.append("^^");
            emit(literal.getDatatype());
        } else if (literal.getLanguage() != null) {
            this.builder.append("@").append(literal.getLanguage());
        }
    }
    return this;
}
 
开发者ID:dkmfbk,项目名称:knowledgestore,代码行数:17,代码来源:SPARQLRenderer.java

示例14: to_and_from_document

import org.openrdf.model.vocabulary.XMLSchema; //导入依赖的package包/类
@Test
public void to_and_from_document() throws DocumentConverterException {
    // Convert an Entity into a Document.
    final Entity entity = Entity.builder()
            .setSubject(new RyaURI("urn:alice"))
            // Add some explicily typed properties.
            .setExplicitType(new RyaURI("urn:person"))
            .setProperty(new RyaURI("urn:person"), new Property(new RyaURI("urn:age"), new RyaType(XMLSchema.INT, "30")))
            .setProperty(new RyaURI("urn:person"), new Property(new RyaURI("urn:eye"), new RyaType("blue")))
            // Add some implicitly typed properties.
            .setProperty(new RyaURI("urn:employee"), new Property(new RyaURI("urn:hours"), new RyaType(XMLSchema.INT, "40")))
            .setProperty(new RyaURI("urn:employee"), new Property(new RyaURI("urn:employer"), new RyaType("Burger Joint")))
            .build();

    final Document document = new EntityDocumentConverter().toDocument(entity);

    // Convert the Document back into an Entity.
    final Entity converted = new EntityDocumentConverter().fromDocument(document);

    // Ensure the original matches the round trip converted Entity.
    assertEquals(entity, converted);
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:23,代码来源:EntityDocumentConverterTest.java

示例15: accumuloIndexSetTestAttemptJoinAccrossTypes

import org.openrdf.model.vocabulary.XMLSchema; //导入依赖的package包/类
@Test
public void accumuloIndexSetTestAttemptJoinAccrossTypes() throws Exception {
    // Setup the object that will be tested.
    final String pcjTableName = new PcjTableNameFactory().makeTableName(ryaInstanceName, pcjId);
    final AccumuloIndexSet ais = new AccumuloIndexSet(conf, pcjTableName);

    // Setup the binding sets that will be evaluated.
    final QueryBindingSet bs1 = new QueryBindingSet();
    bs1.addBinding("age", new NumericLiteralImpl(16, XMLSchema.INTEGER));
    final QueryBindingSet bs2 = new QueryBindingSet();
    bs2.addBinding("age", new NumericLiteralImpl(14, XMLSchema.INTEGER));

    final Set<BindingSet> bSets = Sets.<BindingSet> newHashSet(bs1, bs2);
    final CloseableIteration<BindingSet, QueryEvaluationException> results = ais.evaluate(bSets);

    final Set<BindingSet> fetchedResults = new HashSet<>();
    while (results.hasNext()) {
        final BindingSet next = results.next();
        fetchedResults.add(next);
    }

    final Set<BindingSet> expected = Sets.<BindingSet>newHashSet(pcjBs1, pcjBs2);
    assertEquals(expected, fetchedResults);
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:25,代码来源:AccumuloIndexSetColumnVisibilityTest.java


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