本文整理了Java中org.apache.jena.rdf.model.impl.Util
类的一些代码示例,展示了Util
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util
类的具体详情如下:
包路径:org.apache.jena.rdf.model.impl.Util
类名称:Util
[英]Some utility functions.
[中]一些实用功能。
代码示例来源:origin: org.apache.jena/jena-core
/** Split point, according to XML qname rules.
* This is the longest NCName at the end of the uri.
* See {@link Util#splitNamespaceXML}.
*/
public static int splitXML(String string) { return Util.splitNamespaceXML(string) ; }
代码示例来源: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: apache/jena
public static String substituteStandardEntities( String s )
{
if (standardEntities.matcher( s ).find())
{
return substituteEntitiesInElementContent( s )
.replaceAll( "'", "'" )
.replaceAll( "\t","	" )
.replaceAll( "\n", "
" )
.replaceAll( "\r", "
" )
.replaceAll( "\"", """ )
;
}
else
return s;
}
代码示例来源: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: 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) { return Util.isSimpleString(n) ; }
代码示例来源:origin: apache/jena
protected String substitutedAttribute( String s )
{
String substituted = Util.substituteStandardEntities( s );
if (!showDoctypeDeclaration.booleanValue())
return attributeQuoted( substituted );
else
{
int split = Util.splitNamespaceXML( substituted );
String namespace = substituted.substring( 0, split );
String prefix = modelPrefixMapping.getNsURIPrefix( namespace );
return prefix == null || isPredefinedEntityName( prefix )
? attributeQuoted( substituted )
: attributeQuoted( "&" + strForPrefix(prefix) + ";" + substituted.substring( split ) )
;
}
}
代码示例来源:origin: apache/jena
assertEquals( "", Util.substituteEntitiesInElementContent( "" ) );
assertEquals( "abc", Util.substituteEntitiesInElementContent( "abc" ) );
assertEquals( "a<b", Util.substituteEntitiesInElementContent( "a<b" ) );
assertEquals( "a>b", Util.substituteEntitiesInElementContent( "a>b" ) );
assertEquals( "a&b", Util.substituteEntitiesInElementContent( "a&b" ) );
assertEquals( "a;b", Util.substituteEntitiesInElementContent( "a;b" ) );
assertEquals( "a b", Util.substituteEntitiesInElementContent( "a b" ) );
assertEquals( "a\nb", Util.substituteEntitiesInElementContent( "a\nb" ) );
assertEquals( "a'b", Util.substituteEntitiesInElementContent( "a'b" ) );
assertEquals( "a<b<c", Util.substituteEntitiesInElementContent( "a<b<c" ) );
assertEquals( "a<b>c", Util.substituteEntitiesInElementContent( "a<b>c" ) );
assertEquals( "a<b&c", Util.substituteEntitiesInElementContent( "a<b&c" ) );
assertEquals( "a&b&c", Util.substituteEntitiesInElementContent( "a&b&c" ) );
assertEquals( "a&b>c", Util.substituteEntitiesInElementContent( "a&b>c" ) );
assertEquals( "a&b<c", Util.substituteEntitiesInElementContent( "a&b<c" ) );
assertEquals( "
", Util.substituteEntitiesInElementContent( "\r" ) );
assertEquals( "\n", Util.substituteEntitiesInElementContent( "\n" ) );
assertEquals( "", Util.substituteStandardEntities( "" ) );
assertEquals( "<", Util.substituteStandardEntities( "<" ) );
assertEquals( ">", Util.substituteStandardEntities( ">" ) );
assertEquals( "&", Util.substituteStandardEntities( "&" ) );
assertEquals( "'", Util.substituteStandardEntities( "\'" ) );
assertEquals( """, Util.substituteStandardEntities( "\"" ) );
assertEquals( "
", Util.substituteStandardEntities( "\n" ) );
assertEquals( "
", Util.substituteStandardEntities( "\r" ) );
assertEquals( "	", Util.substituteStandardEntities( "\t" ) );
代码示例来源: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: org.apache.jena/jena-core
String regexPresent = it.next();
assertTrue("Looking for /" + regexPresent + "/", Pattern
.compile(Util.substituteStandardEntities(regexPresent),
Pattern.DOTALL).matcher(contents).find()
assertTrue(
"Looking for (not) /" + regexAbsent + "/",
!Pattern.compile("[\"']"+ Util.substituteStandardEntities(regexAbsent)+ "[\"']", Pattern.DOTALL)
.matcher(contents).find()
代码示例来源: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
.filter(rn -> ! Util.isSimpleString(rn))
.map(rn->rn.toString())
.collect(toList());
代码示例来源:origin: org.apache.jena/jena-core
protected String substitutedAttribute( String s )
{
String substituted = Util.substituteStandardEntities( s );
if (!showDoctypeDeclaration.booleanValue())
return attributeQuoted( substituted );
else
{
int split = Util.splitNamespaceXML( substituted );
String namespace = substituted.substring( 0, split );
String prefix = modelPrefixMapping.getNsURIPrefix( namespace );
return prefix == null || isPredefinedEntityName( prefix )
? attributeQuoted( substituted )
: attributeQuoted( "&" + strForPrefix(prefix) + ";" + substituted.substring( split ) )
;
}
}
代码示例来源:origin: org.apache.jena/jena-core
assertEquals( "", Util.substituteEntitiesInElementContent( "" ) );
assertEquals( "abc", Util.substituteEntitiesInElementContent( "abc" ) );
assertEquals( "a<b", Util.substituteEntitiesInElementContent( "a<b" ) );
assertEquals( "a>b", Util.substituteEntitiesInElementContent( "a>b" ) );
assertEquals( "a&b", Util.substituteEntitiesInElementContent( "a&b" ) );
assertEquals( "a;b", Util.substituteEntitiesInElementContent( "a;b" ) );
assertEquals( "a b", Util.substituteEntitiesInElementContent( "a b" ) );
assertEquals( "a\nb", Util.substituteEntitiesInElementContent( "a\nb" ) );
assertEquals( "a'b", Util.substituteEntitiesInElementContent( "a'b" ) );
assertEquals( "a<b<c", Util.substituteEntitiesInElementContent( "a<b<c" ) );
assertEquals( "a<b>c", Util.substituteEntitiesInElementContent( "a<b>c" ) );
assertEquals( "a<b&c", Util.substituteEntitiesInElementContent( "a<b&c" ) );
assertEquals( "a&b&c", Util.substituteEntitiesInElementContent( "a&b&c" ) );
assertEquals( "a&b>c", Util.substituteEntitiesInElementContent( "a&b>c" ) );
assertEquals( "a&b<c", Util.substituteEntitiesInElementContent( "a&b<c" ) );
assertEquals( "
", Util.substituteEntitiesInElementContent( "\r" ) );
assertEquals( "\n", Util.substituteEntitiesInElementContent( "\n" ) );
assertEquals( "", Util.substituteStandardEntities( "" ) );
assertEquals( "<", Util.substituteStandardEntities( "<" ) );
assertEquals( ">", Util.substituteStandardEntities( ">" ) );
assertEquals( "&", Util.substituteStandardEntities( "&" ) );
assertEquals( "'", Util.substituteStandardEntities( "\'" ) );
assertEquals( """, Util.substituteStandardEntities( "\"" ) );
assertEquals( "
", Util.substituteStandardEntities( "\n" ) );
assertEquals( "
", Util.substituteStandardEntities( "\r" ) );
assertEquals( "	", Util.substituteStandardEntities( "\t" ) );
代码示例来源: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: apache/jena
static void startTag(IndentedWriter out, String text, String attr, String attrValue) {
out.print("<") ;
out.print(text) ;
out.print(" ") ;
out.print(attr) ;
out.print("=\"") ;
attrValue = Util.substituteStandardEntities(attrValue) ;
out.print(attrValue) ;
out.print("\"") ;
out.print(">") ;
out.incIndent();
}
代码示例来源:origin: apache/jena
/** Split point, according to XML qname rules.
* This is the longest NCName at the end of the uri.
* See {@link Util#splitNamespaceXML}.
*/
public static int splitXML(String string) { return Util.splitNamespaceXML(string) ; }
代码示例来源: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: 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
/** Format:: access:entry ("user1" <http://host/graphname1> <http://host/graphname2> ) ; */
private void parseList(Multimap<String, Node> map, Resource root, GNode entry) {
List<Node> members = GraphList.members(entry);
// string, then URIs.
if ( members.isEmpty() )
throw new AssemblerException(root, "Found access:entry with an empty list");
Node userNode = members.get(0);
if ( ! Util.isSimpleString(userNode) )
throw new AssemblerException(root, "User name is not a string: "+NodeFmtLib.str(userNode));
String user = userNode.getLiteralLexicalForm();
List<Node> graphs = members.subList(1, members.size());
accessEntries(root, map, user, graphs);
}
代码示例来源: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 ;
}
内容来源于网络,如有侵权,请联系作者删除!