KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jalisto > se > impl > server > DataWrapperImpl


1 /*
2  * Jalisto - JAva LIght STOrage
3  * Copyright (C) 2000-2005 Xcalia http://www.xcalia.com
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
18  *
19  * Xcalia
20  * 71, rue Desnouettes
21  * 75014 Paris - France
22  * http://www.xcalia.com
23  */

24 package org.objectweb.jalisto.se.impl.server;
25
26 import org.objectweb.jalisto.se.api.internal.DataWrapper;
27 import org.objectweb.jalisto.se.impl.InFileAddress;
28
29 public class DataWrapperImpl implements DataWrapper {
30     protected Object JavaDoc[] datas;
31
32     public DataWrapperImpl() {
33     }
34
35     public void init(Object JavaDoc[] theDatas) {
36         datas = new Object JavaDoc[theDatas.length];
37         System.arraycopy(theDatas, 0, datas, 0, theDatas.length);
38     }
39
40     public DataWrapper getClone() {
41         if (datas == null) {
42             return this;
43         }
44         return newInstance(datas);
45     }
46
47     public void setDatas(Object JavaDoc[] newDatas) {
48         if (newDatas.length != datas.length) {
49             datas = new Object JavaDoc[newDatas.length];
50         }
51         System.arraycopy(newDatas, 0, datas, 0, newDatas.length);
52     }
53
54     public Object JavaDoc[] getDatas() {
55         Object JavaDoc[] result = new Object JavaDoc[datas.length];
56         System.arraycopy(datas, 0, result, 0, datas.length);
57         return result;
58     }
59
60     public String JavaDoc toString() {
61         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
62         sb.append("[");
63         for (int i = 0; i < datas.length; i++) {
64             if (datas[i] == null) {
65                 sb.append("null");
66             } else {
67                 sb.append(datas[i]);
68             }
69             if (i != (datas.length - 1)) {
70                 sb.append(";");
71             }
72         }
73         sb.append(']');
74         return sb.toString();
75     }
76
77     public InFileAddress getIfa() {
78         return null;
79     }
80
81     public void setIfa(InFileAddress ifa) {
82     }
83
84     public static DataWrapperImpl newInstance(Object JavaDoc[] theDatas) {
85         DataWrapperImpl newObject = new DataWrapperImpl();
86         newObject.init(theDatas);
87         return newObject;
88     }
89
90
91     static final long serialVersionUID = -7589377097911761459L;
92 }
93
Popular Tags