View Javadoc

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   * *** Centre de Calcul de l'IN2P3 - Lyon (France) ***
8   * ***             http://cc.in2p3.fr/             ***
9   * ***************************************************
10  * File:   DefaultAttributeAbstract
11  * Author: Sylvain Reynaud (sreynaud@in2p3.fr)
12  * Date:   12 juin 2007
13  * ***************************************************
14  * Description:                                      */
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      ///////////////////////////////////////// public methods //////////////////////////////////////////
24  
25      /** constructor */
26      protected DefaultAttributeAbstract(String key, boolean isSupported, boolean isReadOnly) {
27          m_key = key;
28          m_isSupported = isSupported;
29          m_isReadOnly = isReadOnly;
30      }
31      /** constructor */
32      public DefaultAttributeAbstract(String key) {
33          this(key, true, false);
34      }
35  
36      /** clone */
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      /** Attribute comparator */
56      public abstract boolean equals(Object o);
57  
58      //////////////////////////////////////// protected methods ////////////////////////////////////////
59  
60      protected void checkSupported() throws NotImplementedException {
61          if (!m_isSupported) {
62              // as specified in SAGA document
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  }