本文整理了Java中org.apache.jena.rdf.model.impl.Util.splitNamespaceXML()
方法的一些代码示例,展示了Util.splitNamespaceXML()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.splitNamespaceXML()
方法的具体详情如下:
包路径:org.apache.jena.rdf.model.impl.Util
类名称:Util
方法名:splitNamespaceXML
[英]Given an absolute URI, determine the split point between the namespace part and the localname part. If there is no valid localname part then the length of the string is returned. The algorithm tries to find the longest NCName at the end of the uri, not immediately preceeded by the first colon in the string.
This operation follows XML QName rules which are more complicated than needed for Turtle and TriG. For example, QName can't start with a digit.
[中]给定一个绝对URI,确定名称空间部分和localname部分之间的拆分点。如果没有有效的localname部分,则返回字符串的长度。该算法试图在uri的末尾找到最长的NCName,而不是紧跟在字符串中第一个冒号之前。
此操作遵循XML QName规则,这些规则比Turtle和TriG更复杂。例如,QName不能以数字开头。
代码示例来源: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: 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
@Override
public String getLocalName()
{
String s = (String) label;
return s.substring( Util.splitNamespaceXML( s ) );
}
代码示例来源:origin: org.apache.jena/jena-core
@Override
public String getNameSpace()
{
String s = (String) label;
return s.substring( 0, Util.splitNamespaceXML( s ) );
}
代码示例来源:origin: org.apache.jena/jena-core
@Override
public String getLocalName()
{
String s = (String) label;
return s.substring( Util.splitNamespaceXML( s ) );
}
代码示例来源:origin: apache/jena
@Override
public String getNameSpace()
{
String s = (String) label;
return s.substring( 0, Util.splitNamespaceXML( s ) );
}
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
/**
* Taken from Node_URI.getNameSpace()
*
* @return
*/
public static String getNameSpace(String s) {
return s.substring( 0, Util.splitNamespaceXML( s ) );
}
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
/**
* Taken from Node_URI.getLocalName()
*
* @return
*/
public static String getLocalName(String s) {
return s.substring( Util.splitNamespaceXML( s ) );
}
代码示例来源:origin: apache/jena
@Override
public String qnameFor(String uri) {
int split = Util.splitNamespaceXML(uri);
String ns = uri.substring(0, split);
String local = uri.substring(split);
if ( local.equals("") )
return null;
String prefix = prefixes.readByURI(graphName, ns);
return prefix == null ? null : prefix + ":" + local;
}
代码示例来源:origin: HuygensING/timbuctoo
private String getPredicateName(PredicateInUse pred) {
String predicateUri = pred.getPredicateUri();
return predicateUri.substring(Util.splitNamespaceXML(predicateUri));
}
}
代码示例来源:origin: franzinc/agraph-java-client
@Override
public String qnameFor(String uri) {
int split = Util.splitNamespaceXML(uri);
String ns = uri.substring(0, split), local = uri.substring(split);
if (local.equals("")) {
return null;
}
String prefix = getNsURIPrefix(ns);
return prefix == null ? null : prefix + ":" + local;
}
代码示例来源:origin: apache/jena
String splitTag(String uriref, int type) {
int split = Util.splitNamespaceXML( uriref );
if (split == uriref.length()) throw new InvalidPropertyURIException( uriref );
return tag( uriref.substring( 0, split ), uriref.substring( split ), type, true );
}
代码示例来源:origin: apache/jena
private void updateNamespace( Set<String> set, Iterator<Node> it )
{
while (it.hasNext())
{
Node node = it.next();
if (node.isURI())
{
String uri = node.getURI();
String ns = uri.substring( 0, Util.splitNamespaceXML( uri ) );
// String ns = IteratorFactory.asResource( node, this ).getNameSpace();
set.add( ns );
}
}
}
代码示例来源:origin: org.apache.jena/jena-core
String splitTag(String uriref, int type) {
int split = Util.splitNamespaceXML( uriref );
if (split == uriref.length()) throw new InvalidPropertyURIException( uriref );
return tag( uriref.substring( 0, split ), uriref.substring( split ), type, true );
}
代码示例来源:origin: com.powsybl/powsybl-triple-store-impl-jena
private static boolean validType(RDFNode n) {
if (!(n instanceof Resource)) {
return false;
}
if (n.isAnon()) {
return false;
}
// Only allow resources with namespace and fragment ID
String uri = ((Resource) n).getURI();
int split = Util.splitNamespaceXML(uri);
return !(split == 0 || split == uri.length());
}
代码示例来源:origin: apache/jena
private String getXMLNameSpace(Resource r) {
if (r.isAnon()) {
logger.error("Internal error - Unparser.getNameSpace; giving up");
throw new BrokenException("Internal error: getNameSpace(bNode)");
}
String uri = r.getURI();
int split = Util.splitNamespaceXML(uri);
return uri.substring(0, split);
}
代码示例来源:origin: apache/jena
private String getXMLLocalName(Resource r) {
if (r.isAnon()) {
logger.error("Internal error - giving up - Unparser.getLocalName");
throw new BrokenException("Internal error: getLocalName(bNode)");
}
String uri = r.getURI();
int split = Util.splitNamespaceXML(uri);
return uri.substring(split);
}
代码示例来源:origin: org.apache.jena/jena-core
private String getXMLNameSpace(Resource r) {
if (r.isAnon()) {
logger.error("Internal error - Unparser.getNameSpace; giving up");
throw new BrokenException("Internal error: getNameSpace(bNode)");
}
String uri = r.getURI();
int split = Util.splitNamespaceXML(uri);
return uri.substring(0, split);
}
代码示例来源:origin: org.apache.jena/jena-core
private String getXMLLocalName(Resource r) {
if (r.isAnon()) {
logger.error("Internal error - giving up - Unparser.getLocalName");
throw new BrokenException("Internal error: getLocalName(bNode)");
}
String uri = r.getURI();
int split = Util.splitNamespaceXML(uri);
return uri.substring(split);
}
代码示例来源:origin: apache/jena
/**
test that URI nodes have namespace/localname splits which are consistent
with Util.splitNamepace.
*/
public void testNamespace()
{
for ( String uri : someURIs )
{
int split = Util.splitNamespaceXML( uri );
Node n = NodeCreateUtils.create( uri );
assertEquals( "check namespace", uri.substring( 0, split ), n.getNameSpace() );
assertEquals( "check localname", uri.substring( split ), n.getLocalName() );
}
}
内容来源于网络,如有侵权,请联系作者删除!