|
1 | 1 | package org.md2k.datakitapi.datatype; |
2 | 2 |
|
3 | | -import org.md2k.datakitapi.Constants; |
4 | | -import org.md2k.datakitapi.time.DateTime; |
5 | 3 |
|
6 | | -import java.io.*; |
| 4 | +import org.md2k.datakitapi.time.DateTime; |
7 | 5 |
|
8 | | -/** |
| 6 | +/* |
9 | 7 | * Copyright (c) 2015, The University of Memphis, MD2K Center |
10 | 8 | * - Syed Monowar Hossain <monowar.hossain@gmail.com> |
11 | 9 | * All rights reserved. |
|
31 | 29 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
32 | 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
33 | 31 | */ |
34 | | -public class DataType implements Serializable{ |
35 | | - private static final long serialVersionUID = Constants.serialVersionUID; |
| 32 | +public class DataType { |
36 | 33 | long dateTime; |
37 | 34 | long offset; |
38 | 35 |
|
39 | 36 | public DataType(long dateTime) { |
40 | 37 | this.dateTime = dateTime; |
41 | 38 | this.offset= DateTime.getTimeZoneOffset(); |
42 | 39 | } |
43 | | - public long getDateTime() { |
44 | | - return dateTime; |
45 | | - } |
46 | 40 |
|
47 | | - public byte[] toBytes() { |
48 | | - ByteArrayOutputStream bos = new ByteArrayOutputStream(); |
49 | | - ObjectOutput out = null; |
50 | | - try { |
51 | | - out = new ObjectOutputStream(bos); |
52 | | - out.writeObject(this); |
53 | | - return bos.toByteArray(); |
54 | | - } catch (IOException e) { |
55 | | - e.printStackTrace(); |
56 | | - } finally { |
57 | | - try { |
58 | | - if (out != null) { |
59 | | - out.close(); |
60 | | - } |
61 | | - } catch (IOException ex) { |
62 | | - // ignore close exception |
63 | | - } |
64 | | - try { |
65 | | - bos.close(); |
66 | | - } catch (IOException ex) { |
67 | | - // ignore close exception |
68 | | - } |
69 | | - } |
70 | | - return null; |
| 41 | + public DataType() { |
71 | 42 | } |
72 | 43 |
|
73 | | - public static DataType fromBytes(byte[] dataSourceByteArray) { |
74 | | - ByteArrayInputStream bis = new ByteArrayInputStream(dataSourceByteArray); |
75 | | - DataType dataSource = null; |
76 | | - ObjectInput in = null; |
77 | | - try { |
78 | | - in = new ObjectInputStream(bis); |
79 | | - dataSource = (DataType) in.readObject(); |
80 | | - return dataSource; |
81 | | - } catch (ClassNotFoundException e) { |
82 | | - e.printStackTrace(); |
83 | | - } catch (IOException e) { |
84 | | - e.printStackTrace(); |
85 | | - } finally { |
86 | | - try { |
87 | | - bis.close(); |
88 | | - } catch (IOException ex) { |
89 | | - // ignore close exception |
90 | | - } |
91 | | - try { |
92 | | - if (in != null) { |
93 | | - in.close(); |
94 | | - } |
95 | | - } catch (IOException ex) { |
96 | | - // ignore close exception |
97 | | - } |
98 | | - } |
99 | | - return null; |
| 44 | + |
| 45 | + public long getDateTime() { |
| 46 | + return dateTime; |
100 | 47 | } |
101 | 48 | } |
0 commit comments