1 package fr.in2p3.jsaga.impl.attributes;
2
3 import org.ogf.saga.error.NotImplementedException;
4 import org.ogf.saga.error.PermissionDeniedException;
5
6
7
8
9
10
11
12
13
14
15
16
17
18 public abstract class DefaultAttributeAbstract implements Attribute {
19 private String m_key;
20 private boolean m_isSupported;
21 private boolean m_isReadOnly;
22
23
24
25
26 protected DefaultAttributeAbstract(String key, boolean isSupported, boolean isReadOnly) {
27 m_key = key;
28 m_isSupported = isSupported;
29 m_isReadOnly = isReadOnly;
30 }
31
32 public DefaultAttributeAbstract(String key) {
33 this(key, true, false);
34 }
35
36
37 public DefaultAttributeAbstract clone() throws CloneNotSupportedException {
38 DefaultAttributeAbstract clone = (DefaultAttributeAbstract) super.clone();
39 clone.m_key = m_key;
40 clone.m_isSupported = m_isSupported;
41 clone.m_isReadOnly = m_isReadOnly;
42 return clone;
43 }
44
45 public String getKey() {
46 return m_key;
47 }
48 public boolean isSupported() {
49 return m_isSupported;
50 }
51 public boolean isReadOnly() {
52 return m_isReadOnly;
53 }
54
55
56 public abstract boolean equals(Object o);
57
58
59
60 protected void checkSupported() throws NotImplementedException {
61 if (!m_isSupported) {
62
63 throw new NotImplementedException("Attribute "+m_key+" not available in this implementation");
64 }
65 }
66 protected void checkWritable() throws PermissionDeniedException {
67 if (m_isReadOnly) {
68 throw new PermissionDeniedException("Attribute "+m_key+" not writable");
69 }
70 }
71 }