01: /*
02: * Copyright Aduna (http://www.aduna-software.com/) (c) 2007.
03: *
04: * Licensed under the Aduna BSD-style license.
05: */
06: package org.openrdf.sail.memory.model;
07:
08: import java.io.IOException;
09:
10: import javax.xml.datatype.XMLGregorianCalendar;
11:
12: import org.openrdf.model.datatypes.XMLDatatypeUtil;
13:
14: /**
15: * An extension of MemLiteral that stores a Calendar value to avoid parsing.
16: *
17: * @author David Huynh
18: * @author Arjohn Kampman
19: */
20: public class CalendarMemLiteral extends MemLiteral {
21:
22: private static final long serialVersionUID = -7903843639313451580L;
23:
24: /*-----------*
25: * Variables *
26: *-----------*/
27:
28: transient private XMLGregorianCalendar calendar;
29:
30: /*--------------*
31: * Constructors *
32: *--------------*/
33:
34: public CalendarMemLiteral(Object creator,
35: XMLGregorianCalendar calendar) {
36: this (creator, calendar.toXMLFormat(), calendar);
37: }
38:
39: public CalendarMemLiteral(Object creator, String label,
40: XMLGregorianCalendar calendar) {
41: super (creator, label, XMLDatatypeUtil.qnameToURI(calendar
42: .getXMLSchemaType()));
43: this .calendar = calendar;
44: }
45:
46: /*---------*
47: * Methods *
48: *---------*/
49:
50: @Override
51: public XMLGregorianCalendar calendarValue() {
52: return calendar;
53: }
54:
55: private void readObject(java.io.ObjectInputStream in)
56: throws IOException {
57: try {
58: in.defaultReadObject();
59: calendar = XMLDatatypeUtil.parseCalendar(this .getLabel());
60: } catch (ClassNotFoundException e) {
61: throw new IOException(e.getMessage());
62: }
63: }
64: }
|