1 package fr.in2p3.jsaga.impl.attributes;
2
3 import org.ogf.saga.error.*;
4
5
6
7
8
9
10
11
12
13
14
15
16
17 public class DefaultAttributeVector extends DefaultAttributeAbstract implements AttributeVector {
18 private String[] m_values;
19
20
21 DefaultAttributeVector(String key, boolean isSupported, boolean isReadOnly, String[] values) {
22 super(key, isSupported, isReadOnly);
23 m_values = values;
24 }
25
26 public DefaultAttributeVector(String key, String[] values) {
27 super(key);
28 m_values = values;
29 }
30
31
32 public DefaultAttributeVector clone() throws CloneNotSupportedException {
33 DefaultAttributeVector clone = (DefaultAttributeVector) super.clone();
34 clone.m_values = new String[m_values.length];
35 System.arraycopy(m_values, 0, clone.m_values, 0, m_values.length);
36 return clone;
37 }
38
39 public void setValues(String[] values) throws NotImplementedException, IncorrectStateException, PermissionDeniedException {
40 this.checkSupported();
41 this.checkWritable();
42 m_values = values;
43 }
44
45 public String[] getValues() throws NotImplementedException, IncorrectStateException {
46 this.checkSupported();
47 return m_values;
48 }
49
50 public boolean equals(Object o) {
51 if (!(o instanceof DefaultAttributeVector)) {
52 return false;
53 }
54 DefaultAttributeVector attribute = (DefaultAttributeVector) o;
55 if (!super.getKey().equals(attribute.getKey())) {
56 return false;
57 }
58 if (m_values==null) {
59 return (attribute.m_values==null);
60 }
61 if (attribute.m_values==null) {
62 return (m_values==null);
63 }
64 if (m_values.length != attribute.m_values.length) {
65 return false;
66 }
67 for (int i=0; i<m_values.length; i++) {
68 String v1 = m_values[i];
69 String v2 = attribute.m_values[i];
70 if (v1==null) {
71 if (v2 != null) {
72 return false;
73 }
74 } else {
75 if (!v1.equals(v2)) {
76 return false;
77 }
78 }
79 }
80 return true;
81 }
82 }