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


Java Literal.getLanguage方法代码示例

本文整理汇总了Java中com.hp.hpl.jena.rdf.model.Literal.getLanguage方法的典型用法代码示例。如果您正苦于以下问题:Java Literal.getLanguage方法的具体用法?Java Literal.getLanguage怎么用?Java Literal.getLanguage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.hp.hpl.jena.rdf.model.Literal的用法示例。


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

示例1: asSesameLiteral

import com.hp.hpl.jena.rdf.model.Literal; //导入方法依赖的package包/类
/**
 * Convert the given Jena Literal to a Sesame Literal
 * @param theLiteral the Jena Literal to convert
 * @return the Jena Literal as a Sesame Literal
 */
public static org.openrdf.model.Literal asSesameLiteral(Literal theLiteral) {
    if (theLiteral == null) {
        return null;
    }
    else if (theLiteral.getLanguage() != null && !theLiteral.getLanguage().equals("")) {
        return FACTORY.createLiteral(theLiteral.getLexicalForm(),
                theLiteral.getLanguage());
    }
    else if (theLiteral.getDatatypeURI() != null) {
        return FACTORY.createLiteral(theLiteral.getLexicalForm(),
                FACTORY.createURI(theLiteral.getDatatypeURI()));
    }
    else {
        return FACTORY.createLiteral(theLiteral.getLexicalForm());
    }
}
 
开发者ID:anno4j,项目名称:anno4j,代码行数:22,代码来源:JenaSesameUtils.java

示例2: getSubclass

import com.hp.hpl.jena.rdf.model.Literal; //导入方法依赖的package包/类
public OntoRecord getSubclass(String resourceURI, String lang){
    
    StmtIterator iter1 = model.listStatements( new SimpleSelector(ResourceFactory.createResource(resourceURI), ResourceFactory.createProperty("http://www.w3.org/2000/01/rdf-schema#subClassOf"),  (RDFNode)null));
    OntoRecord record = new OntoRecord();
    StmtIterator iter2;
    
    while(iter1.hasNext()) {
        record.setUri(iter1.next().getObject().toString());
        iter2 = model.listStatements( new SimpleSelector(ResourceFactory.createResource(record.getUri()), ResourceFactory.createProperty("http://www.w3.org/2000/01/rdf-schema#label"),  (RDFNode)null));
        
        while(iter2.hasNext()){
            Literal res = (Literal) iter2.next().getObject();                
            String tmpLang = res.getLanguage();
            
            if( tmpLang.equals("en") ){
                record.setLabel(res.getString());
                return record;
                
            }
        }
    }
    return null;        
}
 
开发者ID:entityclassifier-eu,项目名称:entityclassifier-core,代码行数:24,代码来源:DBpediaOntologyManager.java

示例3: writeStatement

import com.hp.hpl.jena.rdf.model.Literal; //导入方法依赖的package包/类
private void writeStatement(Statement stmt, PrintStream out)
{
    String             name  = getQName(stmt.getPredicate());
    Map<String,String> attrs = null;
    String             value = null;
    RDFNode node = stmt.getObject();
    if ( node.isLiteral() )
    {
        Literal l = node.asLiteral();
        value = l.getString();

        String lang = l.getLanguage();
        if ( !lang.isEmpty()  ) { attrs = Collections.singletonMap("xml:lang", lang); }

        String datatype = l.getDatatypeURI();
        if ( datatype != null ) { attrs = Collections.singletonMap("rdf:datatype", datatype); }
    }
    else {
        attrs = Collections.singletonMap("rdf:resource", getURI(node.asResource()));
    }
    writeProperty(name, attrs, value, out);
}
 
开发者ID:hugomanguinhas,项目名称:europeana,代码行数:23,代码来源:EDMXMLWriter.java

示例4: fixLanguage

import com.hp.hpl.jena.rdf.model.Literal; //导入方法依赖的package包/类
public static void fixLanguage(StmtIterator iter, String sLang)
{
	if ( (sLang == null) || sLang.trim().isEmpty() ) { return; }

	List<Statement> list = iter.toList();
	for ( Statement stmt : list )
	{
		RDFNode n = stmt.getObject();
		if ( !n.isLiteral() ) { continue; }

		Literal l = n.asLiteral();
		String sL = l.getLanguage();
		if ( (sL != null) && !sL.trim().isEmpty() ) { continue; }

		stmt.changeObject(l.getString(), sLang);
	}
}
 
开发者ID:hugomanguinhas,项目名称:europeana,代码行数:18,代码来源:VocsUtils.java

示例5: literal

import com.hp.hpl.jena.rdf.model.Literal; //导入方法依赖的package包/类
private void literal(Literal l) {
    atts.clear();
    try {
        String s = l.getLexicalForm();
        String lang = l.getLanguage();
        String dt = l.getDatatypeURI();
        // Literal with lang?
        if (lang != null && lang.length() != 0) {
            atts.addAttribute(ARQConstants.XML_NS, "lang", "xml:lang", "CDATA", lang);
        }
        // Literal with datatype?
        if (dt != null && dt.length() != 0) {
            atts.addAttribute(dfNamespace, dfAttrDatatype, dfAttrDatatype, "CDATA", dt);
        }
        handler.startElement(dfNamespace, dfLiteral, dfLiteral, atts);
        handler.characters(s.toCharArray(), 0, s.length());
        handler.endElement(dfNamespace, dfLiteral, dfLiteral);
    } catch (SAXException ex) {
    }
}
 
开发者ID:ljo,项目名称:exist-sparql,代码行数:21,代码来源:JenaResultSet2Sax.java

示例6: writeLiteral

import com.hp.hpl.jena.rdf.model.Literal; //导入方法依赖的package包/类
protected void writeLiteral( Literal l, PrintWriter writer ) {
	String lang = l.getLanguage();
       String form = l.getLexicalForm();
	if (!lang.equals("")) {
		writer.print(" xml:lang=" + attributeQuoted( lang ));
	}
	if (l.isWellFormedXML() && !blockLiterals) {
		writer.print(" " + rdfAt("parseType") + "=" + attributeQuoted( "Literal" )+">");
		writer.print( form );
	} else {
		String dt = l.getDatatypeURI();
		if (dt != null) writer.print( " " + rdfAt( "datatype" ) + "=" + substitutedAttribute( dt ) );
           writer.print(">");
           writer.print( Util.substituteEntitiesInElementContent( form ) );
	}
}
 
开发者ID:jacekkopecky,项目名称:parkjam,代码行数:17,代码来源:Basic.java

示例7: asSesameLiteral

import com.hp.hpl.jena.rdf.model.Literal; //导入方法依赖的package包/类
/**
 * Convert the given Jena Literal to a Sesame Literal
 * @param theLiteral the Jena Literal to convert
 * @return the Jena Literal as a Sesame Literal
 */
public static org.openrdf.model.Literal asSesameLiteral(Literal theLiteral) {
	if (theLiteral == null) {
		return null;
	}
	else if (theLiteral.getLanguage() != null && !theLiteral.getLanguage().equals("")) {
		return FACTORY.createLiteral(theLiteral.getLexicalForm(),
									 theLiteral.getLanguage());
	}
	else if (theLiteral.getDatatypeURI() != null) {
		return FACTORY.createLiteral(theLiteral.getLexicalForm(),
									 FACTORY.createURI(theLiteral.getDatatypeURI()));
	}
	else {
		return FACTORY.createLiteral(theLiteral.getLexicalForm());
	}
}
 
开发者ID:SEMOSS,项目名称:semoss,代码行数:22,代码来源:JenaSesameUtils.java

示例8: compute

import com.hp.hpl.jena.rdf.model.Literal; //导入方法依赖的package包/类
@Override
public void compute(Quad quad) {
	Node obj = quad.getObject();
	
	if (obj.isLiteral()){
		RDFNode n = Commons.asRDFNode(obj);
		Literal lt = (Literal) n;
		String language = lt.getLanguage();
		
		if (!language.equals("")){
			totalvalidLangStrings++;
			try {
				if (this.correctLanguageTag(obj)) totalCorrectStrings++;
			} catch (UnsupportedEncodingException e) {
				e.printStackTrace();
			}
		}
	}
}
 
开发者ID:diachron,项目名称:quality,代码行数:20,代码来源:CorrectLanguageTag.java

示例9: indexAnnotation

import com.hp.hpl.jena.rdf.model.Literal; //导入方法依赖的package包/类
private void indexAnnotation(Resource skos_concept, Document conceptDoc,
    AnnotationProperty property, String field) {
  StmtIterator stmt_iter = skos_concept.listProperties(property);
  while (stmt_iter.hasNext()) {
    Literal labelLiteral = stmt_iter.nextStatement().getObject()
        .as(Literal.class);
    String label = labelLiteral.getLexicalForm();
    String labelLang = labelLiteral.getLanguage();
    
    if (this.languages != null && !this.languages.contains(labelLang)) {
      continue;
    }
    
    // converting label to lower-case
    label = label.toLowerCase();
    
    Field labelField = new Field(field, label, StringField.TYPE_STORED);
    
    conceptDoc.add(labelField);
  }
}
 
开发者ID:KepaJRodriguez,项目名称:lucene-skos-ehri,代码行数:22,代码来源:SKOSEngineImpl.java

示例10: object

import com.hp.hpl.jena.rdf.model.Literal; //导入方法依赖的package包/类
private String object(RDFNode node) {
    if (node.isLiteral()) {
        Literal lit = node.asLiteral();
        String text = lit.getString();
        String lang = lit.getLanguage();
        String type = lit.getDatatypeURI();

        if (lang == null || "".equals(lang)) {
            lang = "";
        } else {
            lang = " xml:lang='" + escapeXml(lang) + "'";
        }

        if ("".equals(lang)) {
            if (type == null) {
                type = "http://www.w3.org/2001/XMLSchema#string";
            }
            type = " datatype='" + escapeXml(type) + "'";
        } else {
            type = "";
        }

        return "<sem:object" + type + lang + ">" + escapeXml(text) + "</sem:object>";
    } else if (node.isAnon()) {
        return "<sem:object>http://marklogic.com/semantics/blank/" + Long.toHexString(
                fuse(scramble((long)node.hashCode()),fuse(scramble(milliSecs),randomValue)))
                +"</sem:object>";
    } else {
        return "<sem:object>" + escapeXml(node.toString()) + "</sem:object>";
    }
}
 
开发者ID:marklogic,项目名称:marklogic-contentpump,代码行数:32,代码来源:RDFReader.java

示例11: checkLiteral

import com.hp.hpl.jena.rdf.model.Literal; //导入方法依赖的package包/类
private boolean checkLiteral(Literal l)
{
    String lang = l.getLanguage();
    if ( ignore.contains(lang) ) { return false; }
    
    String str = YorgosUtils.cleanExcess(l.getString());
    return ( str.split(" ").length <= 1);
}
 
开发者ID:hugomanguinhas,项目名称:europeana,代码行数:9,代码来源:AgentEnrichIssuesAnalyser.java

示例12: getLanguage

import com.hp.hpl.jena.rdf.model.Literal; //导入方法依赖的package包/类
public static String getLanguage(String key, QuerySolution querySolution) {
  if (key == null) {
    return null;
  }
  Literal literal = querySolution.getLiteral(key);
  return literal != null ? literal.getLanguage() : null;
}
 
开发者ID:eENVplus,项目名称:tf-exploitation-server,代码行数:8,代码来源:QuerySolutionItemExtractors.java

示例13: processProperty

import com.hp.hpl.jena.rdf.model.Literal; //导入方法依赖的package包/类
private void processProperty(Statement property) throws IOException {
	write("{ \"value\" : \"");
	if (property.getObject().isURIResource()) {
		Resource r = (Resource) property.getObject();
		write(escape(r.getURI()));
		write("\", \"type\" : \"uri\"");
	} else if (property.getObject().isLiteral()) {
		Literal l = (Literal) property.getObject();
		write(escape(l.getLexicalForm()));
		write("\", \"type\" : \"literal\"");
		String languageValue = l.getLanguage();
		if (languageValue != null && !languageValue.trim().equals("")) {
			write(", \"lang\" : \"");
			write(languageValue);
			write("\"");
		}
		String dataTypeValue = l.getDatatypeURI();
		if (dataTypeValue != null && !dataTypeValue.trim().equals("")) {
			write(", \"datatype\" : \"");
			write(escape(dataTypeValue));
			write("\"");
		}
	} else if (property.getObject().isAnon()) {
		write("_:");
		write(escape(property.getObject().asNode().getBlankNodeId()
				.getLabelString()));
		write("\", \"type\" : \"bnode\"");
	}
	write(" }");
}
 
开发者ID:jhu-digital-manuscripts,项目名称:rosa,代码行数:31,代码来源:JsonJenaWriter.java

示例14: getServiceTypes

import com.hp.hpl.jena.rdf.model.Literal; //导入方法依赖的package包/类
/**
 * Retreives existing types of services in the ldi-schema ontology
 * 
 * @return Collection<ServiceType> collection with the existing services uris and labels
 * @throws IOException
 */

public Collection<ServiceType> getServiceTypes() throws IOException {

  if (serviceTypes == null) {

    Map<String, ServiceType> services = new HashMap<String, ServiceType>();

    // read the ontology file and get the list
    String query =
        "SELECT ?uri ?label {?uri <" + RDFS.subClassOf.getURI() + "> <"
            + LDIS.ComponentService.getURI() + "> ; <" + RDFS.label.getURI() + "> ?label}";
    log.debug(query);

    QueryExecution qexec = QueryExecutionFactory.create(query, LDIS.getModel());
    ResultSet results = qexec.execSelect();
    while (results.hasNext()) {
      QuerySolution soln = results.next();
      String uri = soln.get("uri").asResource().getURI();

      Literal literal = soln.get("label").asLiteral();
      String language = literal.getLanguage();

      if (literal.getLanguage().equals(""))
        language = "default";

      ServiceType st = null;
      if (services.containsKey(uri))
        st = services.get(uri);
      else {
        st = new ServiceType();
        st.setUri(uri);
        services.put(uri, st);
      }
      st.getLabels().put(language, literal.getString());
    }
    serviceTypes = services.values();
  }
  return serviceTypes;
}
 
开发者ID:GeoKnow,项目名称:GeoKnowGeneratorUI,代码行数:46,代码来源:ComponentManager.java

示例15: copyFromTdb

import com.hp.hpl.jena.rdf.model.Literal; //导入方法依赖的package包/类
private void copyFromTdb( Dataset dataset ) throws RepositoryException {
	ValueFactory vf = rc.getValueFactory();

	if ( dataset.supportsTransactions() ) {
		dataset.begin( ReadWrite.READ );
	}

	// Get model inside the transaction
	Model model = dataset.getDefaultModel();
	StmtIterator si = model.listStatements();

	try {
		rc.begin();
		while ( si.hasNext() ) {
			Statement stmt = si.next();
			com.hp.hpl.jena.rdf.model.Resource rsr = stmt.getSubject();
			Property pred = stmt.getPredicate();
			RDFNode val = stmt.getObject();
			Node valnode = val.asNode();
			
			Resource sub;
			try {
				sub = ( rsr.isAnon()
						? vf.createBNode( valnode.getBlankNodeLabel() )
						: vf.createURI( rsr.toString() ) );
			}
			catch ( UnsupportedOperationException uoo ) {
				log.warn( uoo, uoo );
				continue;
			}
			
			URI pred2 = vf.createURI( pred.toString() );
			Value val2;

			if ( val.isLiteral() ) {
				Literal lit = val.asLiteral();
				String dtstr = lit.getDatatypeURI();
				URI dt = ( null == dtstr ? null : vf.createURI( dtstr ) );
				String langstr = lit.getLanguage();

				if ( null == dt ) {
					if ( langstr.isEmpty() ) {
						val2 = vf.createLiteral( lit.toString() );
					}
					else {
						val2 = vf.createLiteral( lit.toString(), langstr );
					}
				}
				else {
					val2 = vf.createLiteral( lit.toString(), dt );
				}
			}
			else {
				if ( val.isAnon() ) {
					val2 = vf.createBNode( valnode.getBlankNodeLabel() );
				}
				else {
					val2 = vf.createURI( val.toString() );
				}
			}
			rc.add( sub, pred2, val2 );
		}
		rc.commit();
	}
	catch ( RepositoryException re ) {
		rc.rollback();
		throw re;
	}
	finally {
		if ( dataset.supportsTransactions() ) {
			dataset.end();
		}
	}
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:75,代码来源:JenaEngine.java


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