本文整理汇总了Java中com.hp.hpl.jena.rdf.model.Literal.getString方法的典型用法代码示例。如果您正苦于以下问题:Java Literal.getString方法的具体用法?Java Literal.getString怎么用?Java Literal.getString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hp.hpl.jena.rdf.model.Literal
的用法示例。
在下文中一共展示了Literal.getString方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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>";
}
}
示例3: addResult
import com.hp.hpl.jena.rdf.model.Literal; //导入方法依赖的package包/类
public void addResult(RDFNode property, Literal value) {
String valueString = "";
if (getMap().containsKey(property)) {
valueString = getStringMap().get(property.asNode().getLocalName()) + ", ";
} else {
getMap().put(property, new LinkedList<Literal>());
}
valueString += value.getString();
getStringMap().put(property.asNode().getLocalName(), valueString);
getMap().get(property).add(value);
}
示例4: getLabel
import com.hp.hpl.jena.rdf.model.Literal; //导入方法依赖的package包/类
public static String getLabel(String key, QuerySolution querySolution) {
if (key == null) {
return null;
}
Literal literal = querySolution.getLiteral(key);
return literal != null ? literal.getString() : null;
}
示例5: flattenNode
import com.hp.hpl.jena.rdf.model.Literal; //导入方法依赖的package包/类
public Object flattenNode(Object o) {
if(!(o instanceof Literal))
return o;
Literal that=(Literal) o;
RDFDatatype t=that.getDatatype();
if (t== XSDDatatype.XSDfloat)
return that.getFloat();
if (t== XSDDatatype.XSDdouble)
return that.getDouble();
if (t== XSDDatatype.XSDinteger || t==XSDDatatype.XSDint)
return that.getInt();
if (t==XSDDatatype.XSDlong)
return that.getLong();
if (t==XSDDatatype.XSDshort)
return that.getShort();
if (t==XSDDatatype.XSDboolean)
return that.getBoolean();
if (t==XSDDatatype.XSDstring)
return that.getString();
// XXX -- it would be nice to have support for decimal, datetime, etc.
// one of the harder things to what to do about language tags... in some cases we want to deep
// six them, other times we want to keep them
return that;
}
示例6: obtainMessagePart
import com.hp.hpl.jena.rdf.model.Literal; //导入方法依赖的package包/类
private MessagePart obtainMessagePart(QuerySolution querySolution) {
MessagePart result = null;
Resource res = querySolution.getResource(MESSAGE_PART_VAR);
if (res != null) {
URI mpUri;
try {
mpUri = new URI(res.getURI());
result = new MessagePart(mpUri);
Literal lit = querySolution.getLiteral(WSDL_PART_VAR);
if (lit != null) {
URI wsdlGrounding = new URI(lit.getString());
result.setGrounding(wsdlGrounding);
// Get the type
lit = querySolution.getLiteral(MESSAGE_PART_TYPE_VAR);
if (lit != null) {
URI typeUri = new URI(lit.getString());
result.addModelReference(new uk.ac.open.kmi.msm4j.Resource(typeUri));
}
}
} catch (URISyntaxException e) {
log.error("Incorrect URI specified while parsing Message Content", e);
}
}
return result;
}
示例7: getBestLanguageMatch
import com.hp.hpl.jena.rdf.model.Literal; //导入方法依赖的package包/类
private String getBestLanguageMatch(Collection nodes, String lang) {
Iterator it = nodes.iterator();
String aLiteral = null;
while (it.hasNext()) {
RDFNode candidate = (RDFNode) it.next();
if (!candidate.isLiteral()) continue;
Literal literal = (Literal) candidate.as(Literal.class);
if (lang == null
|| lang.equals(literal.getLanguage())) {
return literal.getString();
}
aLiteral = literal.getString();
}
return aLiteral;
}
开发者ID:health-and-care-developer-network,项目名称:health-and-care-developer-network,代码行数:16,代码来源:ResourceDescription.java
示例8: object
import com.hp.hpl.jena.rdf.model.Literal; //导入方法依赖的package包/类
private void object(TreeWriter tree, 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 = null;
} else {
lang = escapeXml(lang);
}
if (lang == null) {
if (type == null) {
type = "http://www.w3.org/2001/XMLSchema#string";
}
type = escapeXml(type);
} else {
type = null;
}
tree.addStartElement(sem_object);
if (lang != null) {
tree.addAttribute(XProcConstants.xml_lang, lang);
}
if (type != null) {
tree.addAttribute(_datatype, type);
}
tree.startContent();
tree.addText(escapeXml(text));
tree.addEndElement();
} else if (node.isAnon()) {
String uri = "http://marklogic.com/semantics/blank/" + Long.toHexString(
fuse(scramble((long)node.hashCode()),fuse(scramble(milliSecs),randomValue)));
tree.addStartElement(sem_object);
tree.startContent();
tree.addText(uri);
tree.addEndElement();
} else {
tree.addStartElement(sem_object);
tree.startContent();
tree.addText(escapeXml(node.toString()));
tree.addEndElement();
}
}