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


Java LiteralLabel.getValue方法代码示例

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


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

示例1: convertDateLiteral

import org.apache.jena.graph.impl.LiteralLabel; //导入方法依赖的package包/类
private String convertDateLiteral(LiteralLabel lit) {
	RDFDatatype dt = lit.getDatatype();
	String s = lit.getLexicalForm();

	try {
		Object value = lit.getValue();
		if (value instanceof XSDDateTime) {
			Calendar calendar = ((XSDDateTime) value).asCalendar();
			if (dt.equals(XSDDatatype.XSDgMonth)) {
				s = calendar.getDisplayName(Calendar.MONTH, Calendar.LONG, PORTUGUESE_LOCAL);
			} else if (dt.equals(XSDDatatype.XSDgMonthDay)) {
				s = calendar.get(Calendar.DAY_OF_MONTH)
						+ calendar.getDisplayName(Calendar.MONTH, Calendar.LONG, PORTUGUESE_LOCAL);
			} else if (dt.equals(XSDDatatype.XSDgYearMonth)) {
				s = calendar.getDisplayName(Calendar.MONTH, Calendar.LONG, PORTUGUESE_LOCAL) + " "
						+ calendar.get(Calendar.YEAR);
			} else if (dt.equals(XSDDatatype.XSDgYear)) {
				s = "" + calendar.get(Calendar.YEAR);
			} else {
				s = calendar.get(Calendar.DAY_OF_MONTH) + " de "
						+ calendar.getDisplayName(Calendar.MONTH, Calendar.LONG, PORTUGUESE_LOCAL) + " de "
						+ calendar.get(Calendar.YEAR);
				// dateFormat.format(calendar.getTime());
			}
		}
	} catch (DatatypeFormatException | IllegalDateTimeFieldException e) {
		logger.error("Conversion of date literal " + lit + " failed. Reason: " + e.getMessage());
		// fallback
		// DateTime time = ISODateTimeFormat.dateTime
		DateTime time;
		try {
			time = ISODateTimeFormat.dateTimeParser().parseDateTime(lit.getLexicalForm());
			s = time.toString("dd 'de' MMMM 'de' YYYY", PORTUGUESE_LOCAL);
		} catch (Exception e1) {
			try {
				time = ISODateTimeFormat.localDateParser().parseDateTime(lit.getLexicalForm());
				s = time.toString("dd 'de' MMMM 'de' YYYY", PORTUGUESE_LOCAL);
			} catch (Exception e2) {
				e2.printStackTrace();
				time = ISODateTimeFormat.dateParser().parseDateTime(lit.getLexicalForm());
				s = time.toString("dd 'de' MMMM 'de' YYYY", PORTUGUESE_LOCAL);
			}
		}
	}
	return s;
}
 
开发者ID:dice-group,项目名称:RDF2PT,代码行数:47,代码来源:LiteralConverterPortuguese.java

示例2: convertDateLiteral

import org.apache.jena.graph.impl.LiteralLabel; //导入方法依赖的package包/类
private String convertDateLiteral(LiteralLabel lit){
    	RDFDatatype dt = lit.getDatatype();
    	String s = lit.getLexicalForm();
    	
    	try {
			Object value = lit.getValue();
			if (value instanceof XSDDateTime) {
				Calendar calendar = ((XSDDateTime) value).asCalendar();
				if(dt.equals(XSDDatatype.XSDgMonth)){
					s = calendar.getDisplayName(Calendar.MONTH, Calendar.LONG, ENGLISH_LOCAL);
				} else if(dt.equals(XSDDatatype.XSDgMonthDay)){
					s = calendar.get(Calendar.DAY_OF_MONTH) + calendar.getDisplayName(Calendar.MONTH, Calendar.LONG, ENGLISH_LOCAL);
				} else if(dt.equals(XSDDatatype.XSDgYearMonth)) {
					s = calendar.getDisplayName(Calendar.MONTH, Calendar.LONG, ENGLISH_LOCAL) + " " + calendar.get(Calendar.YEAR);
				} else if(dt.equals(XSDDatatype.XSDgYear)) {
					s = "" + calendar.get(Calendar.YEAR);
				} else {
					s = calendar.getDisplayName(Calendar.MONTH, Calendar.LONG, ENGLISH_LOCAL) + " " + calendar.get(Calendar.DAY_OF_MONTH)
					+ ", " + calendar.get(Calendar.YEAR);
					// dateFormat.format(calendar.getTime());
				}
			}
		} catch (DatatypeFormatException | IllegalDateTimeFieldException e) {
			logger.error("Conversion of date literal " + lit + " failed. Reason: " + e.getMessage());
			//fallback
//			DateTime time = ISODateTimeFormat.dateTime
			DateTime time;
			try {
				time = ISODateTimeFormat.dateTimeParser().parseDateTime(lit.getLexicalForm());
				s = time.toString("MMMM dd, yyyy");
			} catch (Exception e1) {
				try {
					time = ISODateTimeFormat.localDateParser().parseDateTime(lit.getLexicalForm());
					s = time.toString("MMMM dd, yyyy");
				} catch (Exception e2) {
					e2.printStackTrace();
					time = ISODateTimeFormat.dateParser().parseDateTime(lit.getLexicalForm());
					s = time.toString("MMMM dd, yyyy");
				}
			}
		}
    	return s;
    }
 
开发者ID:dice-group,项目名称:RDF2PT,代码行数:44,代码来源:LiteralConverter.java

示例3: convertDateLiteral

import org.apache.jena.graph.impl.LiteralLabel; //导入方法依赖的package包/类
private String convertDateLiteral(LiteralLabel lit) {
	RDFDatatype dt = lit.getDatatype();
	String s = lit.getLexicalForm();

	try {
		Object value = lit.getValue();
		if (value instanceof XSDDateTime) {
			Calendar calendar = ((XSDDateTime) value).asCalendar();
			if (dt.equals(XSDDatatype.XSDgMonth)) {
				s = calendar.getDisplayName(Calendar.MONTH, Calendar.LONG, FRENCH_LOCAL);
			} else if (dt.equals(XSDDatatype.XSDgMonthDay)) {
				s = calendar.get(Calendar.DAY_OF_MONTH)
						+ calendar.getDisplayName(Calendar.MONTH, Calendar.LONG, FRENCH_LOCAL);
			} else if (dt.equals(XSDDatatype.XSDgYearMonth)) {
				s = calendar.getDisplayName(Calendar.MONTH, Calendar.LONG, FRENCH_LOCAL) + " "
						+ calendar.get(Calendar.YEAR);
			} else if (dt.equals(XSDDatatype.XSDgYear)) {
				s = "" + calendar.get(Calendar.YEAR);
			} else {
				s = calendar.get(Calendar.DAY_OF_MONTH) + " "
						+ calendar.getDisplayName(Calendar.MONTH, Calendar.LONG, FRENCH_LOCAL) + " "
						+ calendar.get(Calendar.YEAR);
				// dateFormat.format(calendar.getTime());
			}
		}
	} catch (DatatypeFormatException | IllegalDateTimeFieldException e) {
		logger.error("Conversion of date literal " + lit + " failed. Reason: " + e.getMessage());
		// fallback
		// DateTime time = ISODateTimeFormat.dateTime
		DateTime time;
		try {
			time = ISODateTimeFormat.dateTimeParser().parseDateTime(lit.getLexicalForm());
			s = time.toString("dd MMMM YYYY", FRENCH_LOCAL);
		} catch (Exception e1) {
			try {
				time = ISODateTimeFormat.localDateParser().parseDateTime(lit.getLexicalForm());
				s = time.toString("dd MMMM YYYY", FRENCH_LOCAL);
			} catch (Exception e2) {
				e2.printStackTrace();
				time = ISODateTimeFormat.dateParser().parseDateTime(lit.getLexicalForm());
				s = time.toString("dd MMMM YYYY", FRENCH_LOCAL);
			}
		}
	}
	return s;
}
 
开发者ID:dice-group,项目名称:RDF2PT,代码行数:47,代码来源:LiteralConverterFrench.java

示例4: convertDateLiteral

import org.apache.jena.graph.impl.LiteralLabel; //导入方法依赖的package包/类
private String convertDateLiteral(LiteralLabel lit) {
	RDFDatatype dt = lit.getDatatype();
	String s = lit.getLexicalForm();

	try {
		Object value = lit.getValue();
		if (value instanceof XSDDateTime) {
			Calendar calendar = ((XSDDateTime) value).asCalendar();
			if (dt.equals(XSDDatatype.XSDgMonth)) {
				s = calendar.getDisplayName(Calendar.MONTH, Calendar.LONG, ENGLISH_LOCAL);
			} else if (dt.equals(XSDDatatype.XSDgMonthDay)) {
				s = calendar.get(Calendar.DAY_OF_MONTH)
						+ calendar.getDisplayName(Calendar.MONTH, Calendar.LONG, ENGLISH_LOCAL);
			} else if (dt.equals(XSDDatatype.XSDgYearMonth)) {
				s = calendar.getDisplayName(Calendar.MONTH, Calendar.LONG, ENGLISH_LOCAL) + " "
						+ calendar.get(Calendar.YEAR);
			} else if (dt.equals(XSDDatatype.XSDgYear)) {
				s = "" + calendar.get(Calendar.YEAR);
			} else {
				s = calendar.getDisplayName(Calendar.MONTH, Calendar.LONG, ENGLISH_LOCAL) + " "
						+ calendar.get(Calendar.DAY_OF_MONTH) + ", " + calendar.get(Calendar.YEAR);
				// dateFormat.format(calendar.getTime());
			}
		}
	} catch (DatatypeFormatException | IllegalDateTimeFieldException e) {
		logger.error("Conversion of date literal " + lit + " failed. Reason: " + e.getMessage());
		// fallback
		// DateTime time = ISODateTimeFormat.dateTime
		DateTime time;
		try {
			time = ISODateTimeFormat.dateTimeParser().parseDateTime(lit.getLexicalForm());
			s = time.toString("MMMM dd, yyyy");
		} catch (Exception e1) {
			try {
				time = ISODateTimeFormat.localDateParser().parseDateTime(lit.getLexicalForm());
				s = time.toString("MMMM dd, yyyy");
			} catch (Exception e2) {
				e2.printStackTrace();
				time = ISODateTimeFormat.dateParser().parseDateTime(lit.getLexicalForm());
				s = time.toString("MMMM dd, yyyy");
			}
		}
	}
	return s;
}
 
开发者ID:dice-group,项目名称:BENGAL,代码行数:46,代码来源:LiteralConverter.java


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