当前位置: 首页>>代码示例>>Java>>正文


Java OWLLiteral.getDatatype方法代码示例

本文整理汇总了Java中org.semanticweb.owlapi.model.OWLLiteral.getDatatype方法的典型用法代码示例。如果您正苦于以下问题:Java OWLLiteral.getDatatype方法的具体用法?Java OWLLiteral.getDatatype怎么用?Java OWLLiteral.getDatatype使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.semanticweb.owlapi.model.OWLLiteral的用法示例。


在下文中一共展示了OWLLiteral.getDatatype方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getType

import org.semanticweb.owlapi.model.OWLLiteral; //导入方法依赖的package包/类
private static String getType(OWLLiteral literal) {
	OWLDatatype datatype = literal.getDatatype();
	String type = null;
	if (datatype.isString() || datatype.isRDFPlainLiteral()) {
		// do nothing
	}
	else if (datatype.isBuiltIn()) {
		type = datatype.getBuiltInDatatype().getPrefixedName();
	}
	return type;
}
 
开发者ID:geneontology,项目名称:minerva,代码行数:12,代码来源:JsonTools.java

示例2: owlLiteralToValue

import org.semanticweb.owlapi.model.OWLLiteral; //导入方法依赖的package包/类
/**
 * Transforms OWLLiteral to a plain Java object (boxed primitive or date/time).
 *
 * @param literal The literal to transform
 * @return Transformed value
 * @throws IllegalArgumentException If the literal is of unsupported type
 */
public static Object owlLiteralToValue(final OWLLiteral literal) {
    if (literal.isRDFPlainLiteral()) {
        return literal.getLiteral();
    } else if (literal.getDatatype().isBuiltIn())
        switch (literal.getDatatype().getBuiltInDatatype()) {
            case XSD_SHORT:
                return Short.parseShort(literal.getLiteral());
            case XSD_LONG:
                return Long.parseLong(literal.getLiteral());
            case XSD_INT:
            case XSD_INTEGER:
                return Integer.parseInt(literal.getLiteral());
            case XSD_DOUBLE:
            case XSD_DECIMAL:
                return Double.parseDouble(literal.getLiteral());
            case XSD_FLOAT:
                return Float.parseFloat(literal.getLiteral());
            case XSD_STRING:
            case RDF_XML_LITERAL:
            case RDF_LANG_STRING:
                return literal.getLiteral();
            case XSD_BOOLEAN:
                return Boolean.parseBoolean(literal.getLiteral());
            case XSD_ANY_URI:
                return URI.create(literal.getLiteral());
            case XSD_DATE_TIME_STAMP:
            case XSD_DATE_TIME:
                try {
                    return new SimpleDateFormat(DATE_TIME_FORMAT).parse(literal.getLiteral());
                } catch (ParseException e) {
                    throw new IllegalArgumentException(
                            "The date time '" + literal.getLiteral() + "' cannot be parsed.");
                }
        }

    throw new IllegalArgumentException("Unsupported datatype: " + literal.getDatatype());
}
 
开发者ID:kbss-cvut,项目名称:jopa,代码行数:45,代码来源:OwlapiUtils.java

示例3: transform

import org.semanticweb.owlapi.model.OWLLiteral; //导入方法依赖的package包/类
public static Object transform(final OWLLiteral l) {
	if (l.isRDFPlainLiteral()) {
		return l.getLiteral();
	} else if (l.getDatatype().isBuiltIn())
		switch (l.getDatatype().getBuiltInDatatype()) {
		case XSD_SHORT:
			return Short.parseShort(l.getLiteral());
		case XSD_LONG:
			return Long.parseLong(l.getLiteral());
		case XSD_INT:
		case XSD_INTEGER:
			return Integer.parseInt(l.getLiteral());
		case XSD_DOUBLE:
		case XSD_DECIMAL:
			return Double.parseDouble(l.getLiteral());
		case XSD_FLOAT:
			return Float.parseFloat(l.getLiteral());
		case XSD_STRING:
		case RDF_XML_LITERAL:
			return l.getLiteral();
		case XSD_BOOLEAN:
			return Boolean.parseBoolean(l.getLiteral());
		case XSD_ANY_URI:
			return URI.create(l.getLiteral());
		case XSD_DATE_TIME_STAMP:
		case XSD_DATE_TIME:
			try {
				return new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss")
						.parse(l.getLiteral());
			} catch (ParseException e) {
				throw new IllegalArgumentException("The date time '"
						+ l.getLiteral() + "' cannot be parsed");
			}
		}

	throw new IllegalArgumentException("Unsupported datatype: "
			+ l.getDatatype());
}
 
开发者ID:kbss-cvut,项目名称:jopa,代码行数:39,代码来源:DatatypeTransformer.java


注:本文中的org.semanticweb.owlapi.model.OWLLiteral.getDatatype方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。