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

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

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

/**
 * 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.
 */
public static Literal createLiteralOrFail(ValueFactory valueFactory, Object object)
  throws LiteralUtilException
{
  return createLiteral(valueFactory, object, true);
}

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

/**
 * 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.
 */
public static Literal createLiteralOrFail(ValueFactory valueFactory, Object object)
  throws LiteralUtilException
{
  return createLiteral(valueFactory, object, true);
}

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

/**
 * 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.
 */
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: org.eclipse.rdf4j/rdf4j-client

/**
 * 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.
 */
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: eclipse/rdf4j

objectValue = Literals.createLiteral(SimpleValueFactory.getInstance(), object);

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

objectValue = Literals.createLiteral(SimpleValueFactory.getInstance(), object);

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

/**
 * Converts a data structure to {@link ModelHolder}. where value
 * is a root node of the data structure and model is a content of the RDF
 * graph.
 *
 * If requested object is simple object (i.e. is neither List or Map) than
 * method returns map entry of relevant instance of {@link Literal} as key
 * and empty model as value.
 *
 * @param namespace Namespace for predicates
 * @param t Object (or data structure) converting to RDF graph
 * @param rootNode root node of the graph. If not given then blank node is
 * created.
 * @return instance of {@link ModelHolder},
 */
@SuppressWarnings("unchecked")
public ModelHolder asModel(IRI namespace, final Object t, Value rootNode) {
  if (t instanceof List) {
    return processList(namespace, (List<Object>) t);
  } else if (t instanceof Map) {
    return processMap(namespace, (Map<String, Object>) t, rootNode);
  } else if (t instanceof String) {
    return asModelHolder(RDFUtils.makeIRI(t.toString()), modelFactory.createEmptyModel());
  } else if (t == null) {
    return asModelHolder(vocab.nullValue, modelFactory.createEmptyModel());
  } else {
    return asModelHolder(Literals.createLiteral(vf, t), modelFactory.createEmptyModel());
  }
}

相关文章