01: // IntegerArrayAttribute.java
02: // $Id: IntegerArrayAttribute.java,v 1.4 2002/06/09 10:14:29 ylafon Exp $
03: // (c) COPYRIGHT MIT and INRIA, 1996.
04: // Please first read the full copyright statement in file COPYRIGHT.html
05:
06: package org.w3c.tools.resources;
07:
08: /**
09: * The generic description of an IntegerArrayAttribute.
10: */
11:
12: public class IntegerArrayAttribute extends ArrayAttribute {
13:
14: /**
15: * Is the given object a valid IntegerArrayAttribute value ?
16: * @param obj The object to test.
17: * @return A boolean <strong>true</strong> if okay.
18: */
19:
20: public boolean checkValue(Object obj) {
21: return (obj instanceof int[]);
22: }
23:
24: public String[] pickle(Object array) {
25: if (array == null)
26: return null;
27: int ints[] = (int[]) array;
28: int len = ints.length;
29: String strings[] = new String[len];
30: for (int i = 0; i < len; i++) {
31: strings[i] = String.valueOf(ints[i]);
32: }
33: return strings;
34: }
35:
36: public Object unpickle(String array[]) {
37: if (array.length < 1)
38: return null;
39: int len = array.length;
40: int ints[] = new int[len];
41: for (int i = 0; i < len; i++) {
42: ints[i] = Integer.parseInt(array[i]);
43: }
44: return ints;
45: }
46:
47: public IntegerArrayAttribute(String name, int def[], int flags) {
48: super (name, def, flags);
49: this .type = "int[]".intern();
50: }
51:
52: public IntegerArrayAttribute() {
53: super();
54: }
55:
56: }
|