org.eclipse.rdf4j.model.util.Literals.isLanguageLiteral()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(10.4k)|赞(0)|评价(0)|浏览(131)

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

Literals.isLanguageLiteral介绍

[英]Helper method to determine whether a literal is a language literal, and not a typed literal.
[中]Helper方法来确定文本是否为语言文本,而不是类型化文本。

代码示例

代码示例来源:origin: org.eclipse.rdf4j/rdf4j-client

private StringBuilder appendValue(StringBuilder sb, Literal lit) {
  sb.append('"');
  sb.append(lit.getLabel().replace("\"", "\\\""));
  sb.append('"');
  if (Literals.isLanguageLiteral(lit)) {
    sb.append('@');
    sb.append(lit.getLanguage().get());
  }
  else {
    sb.append("^^<");
    sb.append(lit.getDatatype().stringValue());
    sb.append('>');
  }
  return sb;
}

代码示例来源:origin: eclipse/rdf4j

private StringBuilder appendValue(StringBuilder sb, Literal lit) {
  sb.append('"');
  sb.append(lit.getLabel().replace("\"", "\\\""));
  sb.append('"');
  if (Literals.isLanguageLiteral(lit)) {
    sb.append('@');
    sb.append(lit.getLanguage().get());
  }
  else {
    sb.append("^^<");
    sb.append(lit.getDatatype().stringValue());
    sb.append('>');
  }
  return sb;
}

代码示例来源:origin: org.eclipse.rdf4j/rdf4j-repository-sparql

private StringBuilder appendValue(StringBuilder sb, Literal lit) {
  sb.append('"');
  sb.append(lit.getLabel().replace("\"", "\\\""));
  sb.append('"');
  if (Literals.isLanguageLiteral(lit)) {
    sb.append('@');
    sb.append(lit.getLanguage().get());
  }
  else {
    sb.append("^^<");
    sb.append(lit.getDatatype().stringValue());
    sb.append('>');
  }
  return sb;
}

代码示例来源:origin: org.eclipse.rdf4j/rdf4j-queryalgebra-evaluation

/**
 * Checks whether the supplied literal is a "simple literal". A "simple literal" is a literal with no
 * language tag and the datatype {@link XMLSchema#STRING}.
 * 
 * @see <a href="http://www.w3.org/TR/sparql11-query/#simple_literal">SPARQL Simple Literal
 *      Documentation</a>
 */
public static boolean isSimpleLiteral(Literal l) {
  return !Literals.isLanguageLiteral(l) && l.getDatatype().equals(XMLSchema.STRING);
}

代码示例来源:origin: de.tudarmstadt.ukp.inception.rdf4j/rdf4j-queryalgebra-evaluation

/**
 * Checks whether the supplied literal is a "string literal". A "string literal" is either a simple
 * literal, a plain literal with language tag, or a literal with datatype xsd:string.
 * 
 * @see <a href="http://www.w3.org/TR/sparql11-query/#func-string">SPARQL Functions on Strings
 *      Documentation</a>
 */
public static boolean isStringLiteral(Literal l) {
  IRI datatype = l.getDatatype();
  return Literals.isLanguageLiteral(l) || datatype.equals(XMLSchema.STRING);
}

代码示例来源:origin: de.tudarmstadt.ukp.inception.rdf4j/rdf4j-queryalgebra-evaluation

/**
 * Checks whether the supplied literal is a "simple literal". A "simple literal" is a literal with no
 * language tag and the datatype {@link XMLSchema#STRING}.
 * 
 * @see <a href="http://www.w3.org/TR/sparql11-query/#simple_literal">SPARQL Simple Literal
 *      Documentation</a>
 */
public static boolean isSimpleLiteral(Literal l) {
  return !Literals.isLanguageLiteral(l) && l.getDatatype().equals(XMLSchema.STRING);
}

代码示例来源:origin: org.eclipse.rdf4j/rdf4j-queryalgebra-evaluation

/**
 * Checks whether the supplied literal is a "string literal". A "string literal" is either a simple
 * literal, a plain literal with language tag, or a literal with datatype xsd:string.
 * 
 * @see <a href="http://www.w3.org/TR/sparql11-query/#func-string">SPARQL Functions on Strings
 *      Documentation</a>
 */
public static boolean isStringLiteral(Literal l) {
  IRI datatype = l.getDatatype();
  return Literals.isLanguageLiteral(l) || datatype.equals(XMLSchema.STRING);
}

代码示例来源:origin: eclipse/rdf4j

private static StringBuilder appendValue(StringBuilder sb, Literal lit) {
    sb.append('"');
    sb.append(SPARQLUtil.encodeString(lit.getLabel()));
    sb.append('"');

    if (Literals.isLanguageLiteral(lit)) {
      sb.append('@');
      sb.append(lit.getLanguage().get());
    }
    else if (!lit.getDatatype().equals(XMLSchema.STRING)) {
      // Don't append type if it's xsd:string, this keeps it compatible with RDF 1.0
      sb.append("^^<");
      sb.append(lit.getDatatype().stringValue());
      sb.append('>');
    }
    return sb;
  }
}

代码示例来源:origin: org.eclipse.rdf4j/rdf4j-repository-sparql

private static StringBuilder appendValue(StringBuilder sb, Literal lit) {
    sb.append('"');
    sb.append(SPARQLUtil.encodeString(lit.getLabel()));
    sb.append('"');

    if (Literals.isLanguageLiteral(lit)) {
      sb.append('@');
      sb.append(lit.getLanguage().get());
    }
    else if (!lit.getDatatype().equals(XMLSchema.STRING)) {
      // Don't append type if it's xsd:string, this keeps it compatible with RDF 1.0
      sb.append("^^<");
      sb.append(lit.getDatatype().stringValue());
      sb.append('>');
    }
    return sb;
  }
}

代码示例来源:origin: org.eclipse.rdf4j/rdf4j-client

private static StringBuilder appendValue(StringBuilder sb, Literal lit) {
    sb.append('"');
    sb.append(SPARQLUtil.encodeString(lit.getLabel()));
    sb.append('"');

    if (Literals.isLanguageLiteral(lit)) {
      sb.append('@');
      sb.append(lit.getLanguage().get());
    }
    else if (!lit.getDatatype().equals(XMLSchema.STRING)) {
      // Don't append type if it's xsd:string, this keeps it compatible with RDF 1.0
      sb.append("^^<");
      sb.append(lit.getDatatype().stringValue());
      sb.append('>');
    }
    return sb;
  }
}

代码示例来源:origin: org.eclipse.rdf4j/rdf4j-rio-binary

private void writeLiteral(Literal literal)
  throws IOException
{
  String label = literal.getLabel();
  IRI datatype = literal.getDatatype();
  if (Literals.isLanguageLiteral(literal)) {
    out.writeByte(LANG_LITERAL_VALUE);
    writeString(label);
    writeString(literal.getLanguage().get());
  }
  else {
    out.writeByte(DATATYPE_LITERAL_VALUE);
    writeString(label);
    writeString(datatype.toString());
  }
}

代码示例来源:origin: org.eclipse.rdf4j/rdf4j-client

private void writeLiteral(Literal literal)
  throws IOException
{
  String label = literal.getLabel();
  IRI datatype = literal.getDatatype();
  if (Literals.isLanguageLiteral(literal)) {
    out.writeByte(LANG_LITERAL_VALUE);
    writeString(label);
    writeString(literal.getLanguage().get());
  }
  else {
    out.writeByte(DATATYPE_LITERAL_VALUE);
    writeString(label);
    writeString(datatype.toString());
  }
}

代码示例来源:origin: eclipse/rdf4j

private void writeLiteral(Literal literal)
  throws IOException
{
  String label = literal.getLabel();
  IRI datatype = literal.getDatatype();
  if (Literals.isLanguageLiteral(literal)) {
    out.writeByte(LANG_LITERAL_VALUE);
    writeString(label);
    writeString(literal.getLanguage().get());
  }
  else {
    out.writeByte(DATATYPE_LITERAL_VALUE);
    writeString(label);
    writeString(datatype.toString());
  }
}

代码示例来源:origin: de.tudarmstadt.ukp.inception.rdf4j/rdf4j-sail-nativerdf

/**
 * Creates an NativeLiteral that is equal to the supplied literal. This method returns the supplied
 * literal itself if it is already a NativeLiteral that has been created by this ValueStore, which
 * prevents unnecessary object creations.
 * 
 * @return A NativeLiteral for the specified literal.
 */
public NativeLiteral getNativeLiteral(Literal l) {
  if (isOwnValue(l)) {
    return (NativeLiteral)l;
  }
  if (Literals.isLanguageLiteral(l)) {
    return new NativeLiteral(revision, l.getLabel(), l.getLanguage().get());
  }
  else {
    NativeIRI datatype = getNativeURI(l.getDatatype());
    return new NativeLiteral(revision, l.getLabel(), datatype);
  }
}

代码示例来源:origin: org.eclipse.rdf4j/rdf4j-sail-nativerdf

/**
 * Creates an NativeLiteral that is equal to the supplied literal. This method returns the supplied
 * literal itself if it is already a NativeLiteral that has been created by this ValueStore, which
 * prevents unnecessary object creations.
 * 
 * @return A NativeLiteral for the specified literal.
 */
public NativeLiteral getNativeLiteral(Literal l) {
  if (isOwnValue(l)) {
    return (NativeLiteral)l;
  }
  if (Literals.isLanguageLiteral(l)) {
    return new NativeLiteral(revision, l.getLabel(), l.getLanguage().get());
  }
  else {
    NativeIRI datatype = getNativeURI(l.getDatatype());
    return new NativeLiteral(revision, l.getLabel(), datatype);
  }
}

代码示例来源:origin: org.eclipse.rdf4j/rdf4j-sail-nativerdf

private Value copy(Value value) {
  if (value instanceof IRI) {
    return createIRI(value.stringValue());
  }
  else if (value instanceof Literal) {
    Literal lit = (Literal)value;
    if (Literals.isLanguageLiteral(lit)) {
      return createLiteral(value.stringValue(), lit.getLanguage().orElse(null));
    }
    else {
      return createLiteral(value.stringValue(), lit.getDatatype());
    }
  }
  else {
    return createBNode(value.stringValue());
  }
}

代码示例来源:origin: de.tudarmstadt.ukp.inception.rdf4j/rdf4j-sail-nativerdf

private Value copy(Value value) {
  if (value instanceof IRI) {
    return createIRI(value.stringValue());
  }
  else if (value instanceof Literal) {
    Literal lit = (Literal)value;
    if (Literals.isLanguageLiteral(lit)) {
      return createLiteral(value.stringValue(), lit.getLanguage().orElse(null));
    }
    else {
      return createLiteral(value.stringValue(), lit.getDatatype());
    }
  }
  else {
    return createBNode(value.stringValue());
  }
}

代码示例来源:origin: eclipse/rdf4j

private void writeLiteral(Literal literal)
    throws IOException
  {
    if (Literals.isLanguageLiteral(literal)) {
      xmlWriter.setAttribute(LITERAL_LANG_ATT, literal.getLanguage().get());
    }
    // Only enter this section for non-language literals now, as the
    // rdf:langString datatype is handled implicitly above
    else {
      IRI datatype = literal.getDatatype();
      boolean ignoreDatatype = datatype.equals(XMLSchema.STRING) && xsdStringToPlainLiteral();
      if (!ignoreDatatype) {
        if (isQName(datatype)) {
          writeQName(datatype);
        }
        xmlWriter.setAttribute(LITERAL_DATATYPE_ATT, datatype.stringValue());
      }
    }

    xmlWriter.textElement(LITERAL_TAG, literal.getLabel());
  }
}

代码示例来源:origin: org.eclipse.rdf4j/rdf4j-client

private void writeLiteral(Literal literal)
    throws IOException
  {
    if (Literals.isLanguageLiteral(literal)) {
      xmlWriter.setAttribute(LITERAL_LANG_ATT, literal.getLanguage().get());
    }
    // Only enter this section for non-language literals now, as the
    // rdf:langString datatype is handled implicitly above
    else {
      IRI datatype = literal.getDatatype();
      boolean ignoreDatatype = datatype.equals(XMLSchema.STRING) && xsdStringToPlainLiteral();
      if (!ignoreDatatype) {
        if (isQName(datatype)) {
          writeQName(datatype);
        }
        xmlWriter.setAttribute(LITERAL_DATATYPE_ATT, datatype.stringValue());
      }
    }

    xmlWriter.textElement(LITERAL_TAG, literal.getLabel());
  }
}

代码示例来源:origin: org.eclipse.rdf4j/rdf4j-queryresultio-sparqlxml

private void writeLiteral(Literal literal)
    throws IOException
  {
    if (Literals.isLanguageLiteral(literal)) {
      xmlWriter.setAttribute(LITERAL_LANG_ATT, literal.getLanguage().get());
    }
    // Only enter this section for non-language literals now, as the
    // rdf:langString datatype is handled implicitly above
    else {
      IRI datatype = literal.getDatatype();
      boolean ignoreDatatype = datatype.equals(XMLSchema.STRING) && xsdStringToPlainLiteral();
      if (!ignoreDatatype) {
        if (isQName(datatype)) {
          writeQName(datatype);
        }
        xmlWriter.setAttribute(LITERAL_DATATYPE_ATT, datatype.stringValue());
      }
    }

    xmlWriter.textElement(LITERAL_TAG, literal.getLabel());
  }
}

相关文章