org.apache.jena.rdf.model.impl.Util.isSimpleString()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(9.1k)|赞(0)|评价(0)|浏览(153)

本文整理了Java中org.apache.jena.rdf.model.impl.Util.isSimpleString()方法的一些代码示例,展示了Util.isSimpleString()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.isSimpleString()方法的具体详情如下:
包路径:org.apache.jena.rdf.model.impl.Util
类名称:Util
方法名:isSimpleString

Util.isSimpleString介绍

[英]A Node is a simple string if:

  • (RDF 1.0) No datatype and no language tag.
  • (RDF 1.1) xsd:string
    [中]节点是一个简单的字符串,如果:
    *(RDF 1.0)没有数据类型和语言标记。
    *(RDF 1.1)xsd:string

代码示例

代码示例来源: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

.filter(rn -> ! Util.isSimpleString(rn))
.map(rn->rn.toString())
.collect(toList());

代码示例来源:origin: org.apache.jena/jena-fuseki-core

.filter(rn -> ! Util.isSimpleString(rn))
.map(rn->rn.toString())
.collect(toList());

代码示例来源: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

/** 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: 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.seaborne.rdf-delta/rdf-delta-base

/**
 * Convert a {@link Node} to an {@code Id}. The {@link Node} can be a URI or
 * a string literal. The preferred form is a {@code <uuid:...>}.
 * <p>
 * An argument of {@code null} returns {@code null}.
 *
 * @param node
 * @return Id
 */
public static Id fromNode(Node node) {
  if ( node == null )
    return null ;
  String s = null ;
  if ( node.isURI() )
    s = node.getURI() ;
  else if ( Util.isSimpleString(node) )
    s = node.getLiteralLexicalForm() ;
  if ( s == null )
    throw new IllegalArgumentException("Id input is not a URI or a string") ;
  return fromString$(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: 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

/**
 * Return a simplified print string for a Node. 
 */
public static String print(Node node) {
  if (node instanceof Node_URI) {
    String uri = ((Node_URI)node).getURI();
    String suri = prefixMapping == null ? uri : prefixMapping.shortForm(uri);
    if (uri.equals(suri)) {
      return "<" + uri + ">";
    } else {
      return suri;
    }
  } else if (node instanceof Node_Literal) {
    String lf = node.getLiteralLexicalForm();
    // RDF 1.1 : Print xsd:string without ^^xsd:string 
    return "'" + lf + "'" + (Util.isSimpleString(node) ? "" : "^^" + node.getLiteralDatatypeURI());
  } else if (node instanceof Node_ANY) {
    return "*";
  }
  if (node == null) {
    return "null";
  }
  return node.toString();
}

代码示例来源:origin: org.apache.jena/jena-core

/**
 * Return a simplified print string for a Node. 
 */
public static String print(Node node) {
  if (node instanceof Node_URI) {
    String uri = ((Node_URI)node).getURI();
    String suri = prefixMapping == null ? uri : prefixMapping.shortForm(uri);
    if (uri.equals(suri)) {
      return "<" + uri + ">";
    } else {
      return suri;
    }
  } else if (node instanceof Node_Literal) {
    String lf = node.getLiteralLexicalForm();
    // RDF 1.1 : Print xsd:string without ^^xsd:string 
    return "'" + lf + "'" + (Util.isSimpleString(node) ? "" : "^^" + node.getLiteralDatatypeURI());
  } else if (node instanceof Node_ANY) {
    return "*";
  }
  if (node == null) {
    return "null";
  }
  return node.toString();
}

代码示例来源:origin: apache/jena

if ( ! Util.isSimpleString(l) )

代码示例来源: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

return new QueryIterPlainWrapper(it, execCxt);
} else if ( Util.isSimpleString(subject) ) {

代码示例来源: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: 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: 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

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.isSimpleString(node) || Util.isLangString(node) ) 
  return new JsonString(node.getLiteralLexicalForm());

相关文章