org.openrdf.model.util.Literals.createLiteral()方法的使用及代码示例

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

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

Literals.createLiteral介绍

[英]Creates a typed Literal out of the supplied object, mapping the runtime type of the object to the appropriate XML Schema type. If no mapping is available, the method returns a literal with the string representation of the supplied object as the value, and XMLSchema#STRING as the datatype. Recognized types are Boolean, Byte, Double, Float, Integer, Long, Short, XMLGregorianCalendar, and Date.
[中]从提供的对象中创建类型化文字,将对象的运行时类型映射到适当的XML架构类型。如果没有可用的映射,该方法将返回一个文本,其中所提供对象的字符串表示作为值,XMLSchema#string作为数据类型。识别的类型有布尔型、字节型、双精度型、浮点型、整数型、长型、短型、XMLGregorianCalendar型和日期型。

代码示例

代码示例来源:origin: org.openrdf.sesame/sesame-model

/**
 * Creates a typed {@link Literal} out of the supplied object, mapping the
 * runtime type of the object to the appropriate XML Schema type. If no
 * mapping is available, the method throws a {@link LiteralUtilException}.
 * Recognized types are {@link Boolean}, {@link Byte}, {@link Double},
 * {@link Float}, {@link Integer}, {@link Long}, {@link Short},
 * {@link XMLGregorianCalendar } , and {@link Date}.
 * 
 * @param valueFactory
 * @param object
 *        an object to be converted to a typed literal.
 * @return a typed literal representation of the supplied object.
 * @throws LiteralUtilException
 *         If the literal could not be created.
 * @throws NullPointerException
 *         If the object was null.
 * @since 2.7.0
 */
public static Literal createLiteralOrFail(ValueFactory valueFactory, Object object)
  throws LiteralUtilException
{
  return createLiteral(valueFactory, object, true);
}

代码示例来源:origin: org.openrdf.sesame/sesame-model

/**
 * Creates a typed {@link Literal} out of the supplied object, mapping the
 * runtime type of the object to the appropriate XML Schema type. If no
 * mapping is available, the method returns a literal with the string
 * representation of the supplied object as the value, and
 * {@link XMLSchema#STRING} as the datatype. Recognized types are
 * {@link Boolean}, {@link Byte}, {@link Double}, {@link Float},
 * {@link Integer}, {@link Long}, {@link Short}, {@link XMLGregorianCalendar }
 * , and {@link Date}.
 * 
 * @param valueFactory
 * @param object
 *        an object to be converted to a typed literal.
 * @return a typed literal representation of the supplied object.
 * @throws NullPointerException
 *         If the object was null.
 * @since 2.7.0
 */
public static Literal createLiteral(ValueFactory valueFactory, Object object) {
  try {
    return createLiteral(valueFactory, object, false);
  }
  catch (LiteralUtilException e) {
    // This should not happen by design
    throw new IllegalStateException(e);
  }
}

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

URI ctx = valueFactory.createURI(uri);
if (StringUtils.isNotBlank(label)) {
  conn.add(ctx, RDFS.LABEL, Literals.createLiteral(valueFactory, label), ctx);

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

URI ctx = valueFactory.createURI(uri);
if (StringUtils.isNotBlank(label)) {
  conn.add(ctx, RDFS.LABEL, Literals.createLiteral(valueFactory, label), ctx);

相关文章