本文整理汇总了Java中org.apache.jena.datatypes.DatatypeFormatException类的典型用法代码示例。如果您正苦于以下问题:Java DatatypeFormatException类的具体用法?Java DatatypeFormatException怎么用?Java DatatypeFormatException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DatatypeFormatException类属于org.apache.jena.datatypes包,在下文中一共展示了DatatypeFormatException类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getBooleanFromLiteral
import org.apache.jena.datatypes.DatatypeFormatException; //导入依赖的package包/类
private static boolean getBooleanFromLiteral(Literal literal) throws DatatypeFormatException {
try {
return literal.getBoolean();
} catch (DatatypeFormatException e) {
// This litral is not a boolean. Try to understand it
String lexicalForm = literal.getLexicalForm().toLowerCase();
boolean result;
if ("true".equals(lexicalForm) || "1".equals(lexicalForm)) {
result = true;
} else if ("false".equals(lexicalForm) || "0".equals(lexicalForm)) {
result = false;
} else {
throw e;
}
LOGGER.warn("Interpreted the non-boolean literal {} as {}. This should be avoided.", literal.toString(),
result);
return result;
}
}
开发者ID:hobbit-project,项目名称:platform,代码行数:20,代码来源:RdfModelHelper.java
示例2: NumericScorer
import org.apache.jena.datatypes.DatatypeFormatException; //导入依赖的package包/类
public NumericScorer(ComponentProperty property)
{
super(property);
// triggers Virtuoso bug https://github.com/openlink/virtuoso-opensource/issues/354 on some versions
String query = "select (min(xsd:double(?d)) as ?min) (max(xsd:double(?d)) as ?max) {?o a qb:Observation. ?o qb:dataSet <"+property.cube.uri+">."
+ "?o <"+property.uri+"> ?d.}";
QuerySolution qs = property.cube.sparql.select(query).next();
log.trace(query);
Range<Double> range2;
try {range2 = Range.closed(qs.get("min").asLiteral().getDouble(), qs.get("max").asLiteral().getDouble());}
// virtuoso bug
catch(DatatypeFormatException e)
{
log.error("Virtuoso Bug for property "+property+", query:\n"+query,e);
range2 = Range.closed(Double.MIN_VALUE, Double.MAX_VALUE);
}
range=range2;
}
开发者ID:AskNowQA,项目名称:cubeqa,代码行数:19,代码来源:NumericScorer.java
示例3: toResponse
import org.apache.jena.datatypes.DatatypeFormatException; //导入依赖的package包/类
@Override
public Response toResponse(DatatypeFormatException ex)
{
return com.atomgraph.core.model.impl.Response.fromRequest(getRequest()).
getResponseBuilder(toResource(ex, Response.Status.BAD_REQUEST,
ResourceFactory.createResource("http://www.w3.org/2011/http-statusCodes#BadRequest")).
getModel(), getVariants()).
status(Response.Status.BAD_REQUEST).
build();
}
开发者ID:AtomGraph,项目名称:Processor,代码行数:11,代码来源:DatatypeFormatExceptionMapper.java
示例4: convertDateLiteral
import org.apache.jena.datatypes.DatatypeFormatException; //导入依赖的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
示例5: convertDateLiteral
import org.apache.jena.datatypes.DatatypeFormatException; //导入依赖的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
示例6: convertDateLiteral
import org.apache.jena.datatypes.DatatypeFormatException; //导入依赖的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
示例7: convertDateLiteral
import org.apache.jena.datatypes.DatatypeFormatException; //导入依赖的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.datatypes.DatatypeFormatException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论