本文整理了Java中org.apache.jena.rdf.model.impl.Util.isLangString()
方法的一些代码示例,展示了Util.isLangString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.isLangString()
方法的具体详情如下:
包路径:org.apache.jena.rdf.model.impl.Util
类名称:Util
方法名:isLangString
[英]A Node is a language string if it has a language tag. (RDF 1.0 and RDF 1.1)
[中]如果一个节点有一个语言标记,那么它就是一个语言字符串。(RDF 1.0和RDF 1.1)
代码示例来源:origin: apache/jena
/**
* A Node is a language string if it has a language tag.
* (RDF 1.0 and RDF 1.1)
*/
public static boolean isLangString(Node n) { return Util.isLangString(n) ; }
代码示例来源:origin: apache/jena
/** Return true if the literal is a simple string.
* <p>RDF 1.0 {@literal =>} it is a plain literal, with no language tag
* <p>RDF 1.1 {@literal =>} it has datatype xsd:string
*/
public static boolean isSimpleString(Literal lit) {
Objects.requireNonNull(lit) ;
String dtStr = lit.getDatatypeURI() ;
if ( dtStr == null )
return ! isLangString(lit) ;
if ( JenaRuntime.isRDF11 )
return dtStr.equals(XSDDatatype.XSDstring.getURI());
return false ;
}
代码示例来源:origin: org.apache.jena/jena-core
/** Return true if the literal is a simple string.
* <p>RDF 1.0 {@literal =>} it is a plain literal, with no language tag
* <p>RDF 1.1 {@literal =>} it has datatype xsd:string
*/
public static boolean isSimpleString(Literal lit) {
Objects.requireNonNull(lit) ;
String dtStr = lit.getDatatypeURI() ;
if ( dtStr == null )
return ! isLangString(lit) ;
if ( JenaRuntime.isRDF11 )
return dtStr.equals(XSDDatatype.XSDstring.getURI());
return false ;
}
代码示例来源:origin: apache/jena
/**
* A Node is a simple string if:
* <li>(RDF 1.0) No datatype and no language tag.
* <li>(RDF 1.1) xsd:string
*/
public static boolean isSimpleString(Node n) {
Objects.requireNonNull(n) ;
if ( ! n.isLiteral() )
return false ;
RDFDatatype dt = n.getLiteralDatatype() ;
if ( dt == null )
return !isLangString(n) ;
if ( JenaRuntime.isRDF11 )
return dt.equals(XSDDatatype.XSDstring) ;
return false ;
}
代码示例来源:origin: org.apache.jena/jena-core
/**
* A Node is a simple string if:
* <li>(RDF 1.0) No datatype and no language tag.
* <li>(RDF 1.1) xsd:string
*/
public static boolean isSimpleString(Node n) {
Objects.requireNonNull(n) ;
if ( ! n.isLiteral() )
return false ;
RDFDatatype dt = n.getLiteralDatatype() ;
if ( dt == null )
return !isLangString(n) ;
if ( JenaRuntime.isRDF11 )
return dt.equals(XSDDatatype.XSDstring) ;
return false ;
}
代码示例来源:origin: apache/jena
/**
* Match a ground RDF Term (ANY and variables are considered ground terms in the
* data term) with a node which can be a wildcard (ANY or null).
* Language tags compare case-insensitively.
*/
private static boolean sameTermMatch(Node match, Node data) {
if ( ! Util.isLangString(data) || ! Util.isLangString(match) )
// No lang tag
return (match==null) || (match == Node.ANY) || match.equals(data) ;
// Concrete match, which is a lang tag literal.
// Language tags compare case insensitively.
String lex1 = data.getLiteralLexicalForm();
String lex2 = data.getLiteralLexicalForm();
String lang1 = data.getLiteralLanguage();
String lang2 = data.getLiteralLanguage();
return lex1.equals(lex2) && lang1.equalsIgnoreCase(lang2);
}
}
代码示例来源:origin: org.apache.jena/jena-core
/**
* Match a ground RDF Term (ANY and variables are considered ground terms in the
* data term) with a node which can be a wildcard (ANY or null).
* Language tags compare case-insensitively.
*/
private static boolean sameTermMatch(Node match, Node data) {
if ( ! Util.isLangString(data) || ! Util.isLangString(match) )
// No lang tag
return (match==null) || (match == Node.ANY) || match.equals(data) ;
// Concrete match, which is a lang tag literal.
// Language tags compare case insensitively.
String lex1 = data.getLiteralLexicalForm();
String lex2 = data.getLiteralLexicalForm();
String lang1 = data.getLiteralLanguage();
String lang2 = data.getLiteralLanguage();
return lex1.equals(lex2) && lang1.equalsIgnoreCase(lang2);
}
}
代码示例来源:origin: apache/jena
/**
* Return true if this is a "plain" (i.e. old style, not typed) literal.
* For RDF 1.1, the most compatible choice is "xsd:string" or "rdf:langString".
*/
private boolean isPlainLiteral() {
if ( JenaRuntime.isRDF11 )
return Util.isLangString(this) || Util.isSimpleString(this) ;
else
return asNode().getLiteralDatatype() == null;
}
代码示例来源:origin: org.apache.jena/jena-core
/**
* Return true if this is a "plain" (i.e. old style, not typed) literal.
* For RDF 1.1, the most compatible choice is "xsd:string" or "rdf:langString".
*/
private boolean isPlainLiteral() {
if ( JenaRuntime.isRDF11 )
return Util.isLangString(this) || Util.isSimpleString(this) ;
else
return asNode().getLiteralDatatype() == null;
}
代码示例来源:origin: org.apache.jena/jena-core
sbuff.append(quoteMarks);
if ( Util.isLangString(literal) ) {
sbuff.append("@") ;
sbuff.append(lang) ;
代码示例来源:origin: apache/jena
protected void writeLiteral( Literal l, PrintWriter writer ) {
String lang = l.getLanguage();
String form = l.getLexicalForm();
if (Util.isLangString(l)) {
writer.print(" xml:lang=" + attributeQuoted( lang ));
} else if (l.isWellFormedXML() && !blockLiterals) {
// RDF XML Literals inline.
writer.print(" " + rdfAt("parseType") + "=" + attributeQuoted( "Literal" )+">");
writer.print( form );
return ;
} else {
// Datatype (if not xsd:string and RDF 1.1)
String dt = l.getDatatypeURI();
if ( ! Util.isSimpleString(l) )
writer.print( " " + rdfAt( "datatype" ) + "=" + substitutedAttribute( dt ) );
}
// Content.
writer.print(">");
writer.print( Util.substituteEntitiesInElementContent( form ) );
}
代码示例来源:origin: org.apache.jena/jena-core
protected void writeLiteral( Literal l, PrintWriter writer ) {
String lang = l.getLanguage();
String form = l.getLexicalForm();
if (Util.isLangString(l)) {
writer.print(" xml:lang=" + attributeQuoted( lang ));
} else if (l.isWellFormedXML() && !blockLiterals) {
// RDF XML Literals inline.
writer.print(" " + rdfAt("parseType") + "=" + attributeQuoted( "Literal" )+">");
writer.print( form );
return ;
} else {
// Datatype (if not xsd:string and RDF 1.1)
String dt = l.getDatatypeURI();
if ( ! Util.isSimpleString(l) )
writer.print( " " + rdfAt( "datatype" ) + "=" + substitutedAttribute( dt ) );
}
// Content.
writer.print(">");
writer.print( Util.substituteEntitiesInElementContent( form ) );
}
代码示例来源:origin: apache/jena
if (! isLangString(o) && ! isSimpleString(o) )
代码示例来源:origin: apache/jena
public static NodeValue strEncodeForURI(NodeValue v) {
Node n = v.asNode() ;
if ( !n.isLiteral() )
throw new ExprEvalException("Not a literal") ;
if ( ! Util.isSimpleString(n) && ! Util.isLangString(n) )
throw new ExprEvalException("Not a string literal") ;
String str = n.getLiteralLexicalForm() ;
String encStr = IRILib.encodeUriComponent(str) ;
encStr = IRILib.encodeNonASCII(encStr) ;
return NodeValue.makeString(encStr) ;
}
代码示例来源:origin: apache/jena
private void printLiteral(Literal literal) {
String datatype = literal.getDatatypeURI();
String lang = literal.getLanguage();
if ( Util.isSimpleString(literal) || Util.isLangString(literal) ) {
print(quoteName(kType), ": ", quote(kLiteral), " , ");
if ( multiLineValues )
println();
if ( lang != null && !lang.equals("") ) {
print(quoteName(kXmlLang), ": ", quote(lang), " , ");
if ( multiLineValues )
println();
}
} else {
print(quoteName(kType), ": ", quote(kLiteral), " , ");
if ( multiLineValues )
println();
print(quoteName(kDatatype), ": ", quote(datatype), " , ");
if ( multiLineValues )
println();
}
print(quoteName(kValue), ": ", quote(literal.getLexicalForm()));
if ( multiLineValues )
println();
}
代码示例来源:origin: org.apache.jena/jena-core
private boolean wPropertyEltDatatype(WType wt, Property prop, Statement s,
RDFNode r) {
if (! (r instanceof Literal) )
return false ;
Literal lit = ((Literal) r) ;
if ( Util.isSimpleString(lit) )
return false;
if ( Util.isLangString(lit) )
return false;
// print out with "datatype="
done(s);
tab();
print("<");
wt.wTypeStart(prop);
wIdAttrReified(s);
maybeNewline();
wDatatype(((Literal) r).getDatatypeURI());
maybeNewline();
print(">");
print(Util.substituteEntitiesInElementContent(((Literal) r)
.getLexicalForm()));
print("</");
wt.wTypeEnd(prop);
print(">");
return true;
}
代码示例来源:origin: apache/jena
private boolean wPropertyEltDatatype(WType wt, Property prop, Statement s,
RDFNode r) {
if (! (r instanceof Literal) )
return false ;
Literal lit = ((Literal) r) ;
if ( Util.isSimpleString(lit) )
return false;
if ( Util.isLangString(lit) )
return false;
// print out with "datatype="
done(s);
tab();
print("<");
wt.wTypeStart(prop);
wIdAttrReified(s);
maybeNewline();
wDatatype(((Literal) r).getDatatypeURI());
maybeNewline();
print(">");
print(Util.substituteEntitiesInElementContent(((Literal) r)
.getLexicalForm()));
print("</");
wt.wTypeEnd(prop);
print(">");
return true;
}
代码示例来源:origin: apache/jena
void printLiteral(Literal literal) {
out.print("<");
out.print(dfLiteral);
if ( Util.isLangString(literal) ) {
String lang = literal.getLanguage();
out.print(" xml:lang=\"");
out.print(literal.getLanguage());
out.print("\"");
} else if ( !Util.isSimpleString(literal) ) {
// Datatype
// (RDF 1.1) not xsd:string nor rdf:langString.
// (RDF 1.0) any datatype.
String datatype = literal.getDatatypeURI();
out.print(" ");
out.print(dfAttrDatatype);
out.print("=\"");
out.print(datatype);
out.print("\"");
}
out.print(">");
out.print(xml_escape(literal.getLexicalForm()));
out.print("</");
out.print(dfLiteral);
out.println(">");
}
代码示例来源:origin: apache/jena
if ( Util.isLangString(node) ) {
String lang = node.getLiteralLanguage() ;
startTag(out, TriX.tagPlainLiteral, "xml:lang", lang) ;
代码示例来源:origin: apache/jena
if ( Util.isSimpleString(node) || Util.isLangString(node) )
return new JsonString(node.getLiteralLexicalForm());
内容来源于网络,如有侵权,请联系作者删除!