public XMLGregorianCalendar deserialize(Literal literal) { return literal.calendarValue(); }
public XMLGregorianCalendar deserialize(Literal literal) { return literal.calendarValue(); }
public XMLGregorianCalendar calendarValue() { return lit.calendarValue(); }
public XMLGregorianCalendar deserialize(Literal literal) { return literal.calendarValue(); }
@Override public Date dateTimeValue(Value node) { try { XMLGregorianCalendar cal = ((Literal)node).calendarValue(); //TODO: check if we need to deal with timezone and Local here return cal.toGregorianCalendar().getTime(); } catch (ClassCastException e) { throw new IllegalArgumentException("Value "+node.stringValue()+" is not a literal" + "but of type "+debugType(node)); } }
@Override public Date dateTimeValue(Value node) { try { XMLGregorianCalendar cal = ((Literal)node).calendarValue(); //TODO: check if we need to deal with timezone and Local here return cal.toGregorianCalendar().getTime(); } catch (ClassCastException e) { throw new IllegalArgumentException("Value "+node.stringValue()+" is not a literal" + "but of type "+debugType(node)); } }
@Override public Date dateValue(Value node) { try { XMLGregorianCalendar cal = ((Literal)node).calendarValue(); return cal.toGregorianCalendar().getTime(); } catch (ClassCastException e) { throw new IllegalArgumentException("Value "+node.stringValue()+" is not a literal" + "but of type "+debugType(node)); } }
@Override public Date dateTimeValue(Value node) { try { XMLGregorianCalendar cal = ((Literal)node).calendarValue(); //TODO: check if we need to deal with timezone and Local here return cal.toGregorianCalendar().getTime(); } catch (ClassCastException e) { throw new IllegalArgumentException("Value "+node.stringValue()+" is not a literal" + "but of type "+debugType(node)); } }
@Override public Date dateTimeValue(Value node) { try { XMLGregorianCalendar cal = ((Literal)node).calendarValue(); //TODO: check if we need to deal with timezone and Local here return cal.toGregorianCalendar().getTime(); } catch (ClassCastException e) { throw new IllegalArgumentException("Value "+node.stringValue()+" is not a literal" + "but of type "+debugType(node)); } }
@Override protected Value evaluate(ValueFactory valueFactory, Value arg) throws ValueExprEvaluationException { if (!(arg instanceof Literal)) { throw new ValueExprEvaluationException("Argument must be a literal"); } return valueFactory.createLiteral(((Literal)arg).calendarValue().toGregorianCalendar().getTimeInMillis()); } }
@Override public Date toDate(final Object v) throws RippleException { Literal l = castToLiteral(toRDF(v)); XMLGregorianCalendar c = l.calendarValue(); return c.toGregorianCalendar().getTime(); }
/** * Implements {@link Literal#calendarValue()}. */ @Override public XMLGregorianCalendar calendarValue() { if (!isLiteral()) throw new ClassCastException(); return ((Literal) getValue()).calendarValue(); }
/** * Implements {@link Literal#calendarValue()}. */ @Override public XMLGregorianCalendar calendarValue() { if (!isLiteral()) throw new ClassCastException(); return ((Literal) getValue()).calendarValue(); }
@Override protected Value evaluate(ValueFactory valueFactory, Value arg1, Value arg2) throws ValueExprEvaluationException { if (!(arg1 instanceof Literal) || !(arg2 instanceof Literal)) { throw new ValueExprEvaluationException("Both arguments must be literals"); } Literal date = (Literal) arg1; Literal format = (Literal) arg2; SimpleDateFormat formatter = new SimpleDateFormat(format.getLabel()); String value = formatter.format(date.calendarValue().toGregorianCalendar().getTime()); return valueFactory.createLiteral(value); } }
/******************************************************************************************************************* * * ******************************************************************************************************************/ @Nonnull protected static XMLGregorianCalendar toXMLGregorianCalendar (final @Nonnull Date date) { final Literal literal = ((SesameManager)(ElmoManagerThreadLocal.get())).getLiteralManager().getLiteral(date); assert literal != null : "null literal"; return literal.calendarValue(); }
@Override public Date dateValue(Value node) { try { XMLGregorianCalendar cal = ((Literal)node).calendarValue(); return new GregorianCalendar(cal.getYear(), cal.getMonth(), cal.getDay()).getTime(); } catch (ClassCastException e) { throw new IllegalArgumentException("Value "+node.stringValue()+" is not a literal" + "but of type "+debugType(node)); } }
@Override public Date dateValue(Value node) { try { XMLGregorianCalendar cal = ((Literal)node).calendarValue(); return new GregorianCalendar(cal.getYear(), cal.getMonth(), cal.getDay()).getTime(); } catch (ClassCastException e) { throw new IllegalArgumentException("Value "+node.stringValue()+" is not a literal" + "but of type "+debugType(node)); } }
@Override public Date dateValue(Value node) { try { XMLGregorianCalendar cal = ((Literal)node).calendarValue(); return new GregorianCalendar(cal.getYear(), cal.getMonth(), cal.getDay()).getTime(); } catch (ClassCastException e) { throw new IllegalArgumentException("Value "+node.stringValue()+" is not a literal" + "but of type "+debugType(node)); } }
private Instant convertToInstant(Literal literal) { String stringVal = literal.getLabel(); URI dataType = literal.getDatatype(); checkArgument(dataType.equals(XMLSchema.DATETIME) || dataType.equals(XMLSchema.DATE), String.format("Invalid data type for date time. Data Type must be of type %s or %s .", XMLSchema.DATETIME, XMLSchema.DATE)); checkArgument(XMLDatatypeUtil.isValidDateTime(stringVal) || XMLDatatypeUtil.isValidDate(stringVal), "Invalid date time value."); return literal.calendarValue().toGregorianCalendar().toInstant(); }
/** * Test method for {@link com.github.ansell.oas.utils.DateUtils#getCurrentDateLiteral()}. */ @Test public final void testGetCurrentDateLiteral() { Assert.assertNotNull("Date literal was null", DateUtils.getCurrentDateLiteral()); Assert.assertNotNull("Date literal date type was null", DateUtils.getCurrentDateLiteral().getDatatype()); Assert.assertNotNull("Date literal calendar value was null", DateUtils.getCurrentDateLiteral().calendarValue()); }