本文整理匯總了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();
}
}