本文整理汇总了Java中org.apache.jena.datatypes.RDFDatatype.equals方法的典型用法代码示例。如果您正苦于以下问题:Java RDFDatatype.equals方法的具体用法?Java RDFDatatype.equals怎么用?Java RDFDatatype.equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.jena.datatypes.RDFDatatype
的用法示例。
在下文中一共展示了RDFDatatype.equals方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convert
import org.apache.jena.datatypes.RDFDatatype; //导入方法依赖的package包/类
/**
* Convert the literal into natural language.
*
* @param lit
* the literal
* @return the natural language expression
*/
public String convert(LiteralLabel lit) {
logger.debug("Literal to be converted" + lit.toString());
RDFDatatype dt = lit.getDatatype();
String s = lit.getLexicalForm();
if (dt == null || dt instanceof RDFLangString) {// plain literal, i.e.
// omit language tag if
// exists
s = lit.getLexicalForm();
s = s.replaceAll("_", " ");
s = s.replace('*', ' ');
s = s.trim();
if (encapsulateStringLiterals) {
s = '"' + s + '"';
}
} else {// typed literal
if (dt instanceof XSDDatatype) {// built-in XSD datatype
if (dt instanceof XSDAbstractDateTimeType) {// date datetypes
s = convertDateLiteral(lit);
} else if (encapsulateStringLiterals && dt.equals(XSDDatatype.XSDstring)) {
s = s.replace('*', ' ');
s = s.trim();
s = '"' + s + '"';
}
} else {// user-defined datatype
String text = iriConverter.convert(dt.getURI(), false).toLowerCase();
String[] split = StringUtils.splitByCharacterTypeCamelCase(text.trim());
String datatype = Joiner.on(" ").join(Arrays.asList(split).stream().filter(str -> !str.trim().isEmpty())
.collect(Collectors.toList()));
s = lit.getLexicalForm() + " " + datatype;
}
}
return s;
}
示例2: convert
import org.apache.jena.datatypes.RDFDatatype; //导入方法依赖的package包/类
/**
* Convert the literal into natural language.
* @param lit the literal
* @return the natural language expression
*/
public String convert(LiteralLabel lit) {
RDFDatatype dt = lit.getDatatype();
String s = lit.getLexicalForm();
if (dt == null || dt instanceof RDFLangString) {// plain literal, i.e. omit language tag if exists
s = lit.getLexicalForm();
s = s.replaceAll("_", " ");
if(encapsulateStringLiterals){
s = '"' + s + '"';
}
} else {// typed literal
if (dt instanceof XSDDatatype) {// built-in XSD datatype
if(dt instanceof XSDAbstractDateTimeType){//date datetypes
s = convertDateLiteral(lit);
} else if(encapsulateStringLiterals && dt.equals(XSDDatatype.XSDstring)){
s = '"' + s + '"';
}
} else {// user-defined datatype
String text = iriConverter.convert(dt.getURI(), false).toLowerCase();
String[] split = StringUtils.splitByCharacterTypeCamelCase(text.trim());
String datatype = Joiner.on(" ").join(Arrays.asList(split).stream().filter(str -> !str.trim().isEmpty()).collect(Collectors.toList()));
s = lit.getLexicalForm() + " " + datatype;
}
}
return s;
}
示例3: convert
import org.apache.jena.datatypes.RDFDatatype; //导入方法依赖的package包/类
/**
* Convert the literal into natural language.
*
* @param lit
* the literal
* @return the natural language expression
*/
public String convert(LiteralLabel lit) {
RDFDatatype dt = lit.getDatatype();
String s = lit.getLexicalForm();
if (dt == null || dt instanceof RDFLangString) {// plain literal, i.e.
// omit language tag if
// exists
s = lit.getLexicalForm();
s = s.replaceAll("_", " ");
if (encapsulateStringLiterals) {
s = '"' + s + '"';
}
} else {// typed literal
if (dt instanceof XSDDatatype) {// built-in XSD datatype
if (dt instanceof XSDAbstractDateTimeType) {// date datetypes
s = convertDateLiteral(lit);
} else if (encapsulateStringLiterals && dt.equals(XSDDatatype.XSDstring)) {
s = '"' + s + '"';
}
} else {// user-defined datatype
String text = iriConverter.convert(dt.getURI(), false).toLowerCase();
String[] split = StringUtils.splitByCharacterTypeCamelCase(text.trim());
String datatype = Joiner.on(" ").join(Arrays.asList(split).stream().filter(str -> !str.trim().isEmpty())
.collect(Collectors.toList()));
s = lit.getLexicalForm() + " " + datatype;
}
}
return s;
}
示例4: RefTimeRepresentation
import org.apache.jena.datatypes.RDFDatatype; //导入方法依赖的package包/类
public RefTimeRepresentation(XSDDateTime time, RDFDatatype type) {
this.time = time;
int i_woy_year = 0;
int i_woy_week = 0;
if (type.equals(XSDDatatype.XSDdateTime)) {
bcal = new BritishCalendar(
time.getYears(), time.getMonths()-1, time.getDays(),
time.getHours(), time.getMinutes(), time.getFullSeconds() );
// Remove any trailing fractional seconds if present
ref = NodeFactory.createURI("http://reference.data.gov.uk/id/gregorian-instant/" + value.getLiteralLexicalForm().replaceAll("\\.[0-9]*$", ""));
i_woy_year = CalendarUtils.getWeekOfYearYear(bcal);
i_woy_week = bcal.get(Calendar.WEEK_OF_YEAR);
new CalendarInstant(model, bcal, true);
new CalendarDay(model, bcal, true);
new CalendarWeek(model, i_woy_year, i_woy_week, false, false);
} else if (type.equals(XSDDatatype.XSDdate)) {
bcal = new BritishCalendar(
time.getYears(), time.getMonths()-1, time.getDays());
ref = NodeFactory.createURI("http://reference.data.gov.uk/id/day/" + value.getLiteralLexicalForm());
i_woy_year = CalendarUtils.getWeekOfYearYear(bcal);
i_woy_week = bcal.get(Calendar.WEEK_OF_YEAR);
new CalendarDay(model, bcal, true);
new CalendarWeek(model, i_woy_year, i_woy_week, false, false);
} else {
ref = NodeFactory.createURI("http://reference.data.gov.uk/id/year/" + time.getYears());
}
week = NodeFactory.createURI("http://reference.data.gov.uk/id/week/"
+ String.format("%04d", i_woy_year)
+ "-W" + String.format("%02d", i_woy_week));
new CalendarYear(model, time.getYears(), false, false);
}
示例5: convertDateLiteral
import org.apache.jena.datatypes.RDFDatatype; //导入方法依赖的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;
}
示例6: convertDateLiteral
import org.apache.jena.datatypes.RDFDatatype; //导入方法依赖的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;
}
示例7: convertDateLiteral
import org.apache.jena.datatypes.RDFDatatype; //导入方法依赖的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;
}
示例8: convertDateLiteral
import org.apache.jena.datatypes.RDFDatatype; //导入方法依赖的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;
}