View Javadoc

1   package fr.in2p3.jsaga.impl.attributes;
2   
3   import org.ogf.saga.error.*;
4   
5   /* ***************************************************
6   * *** Centre de Calcul de l'IN2P3 - Lyon (France) ***
7   * ***             http://cc.in2p3.fr/             ***
8   * ***************************************************
9   * File:   DefaultAttributeScalar
10  * Author: Sylvain Reynaud (sreynaud@in2p3.fr)
11  * Date:   12 juin 2007
12  * ***************************************************
13  * Description:                                      */
14  /**
15   * This class is a friend of AbstractAttributesImpl
16   */
17  public class DefaultAttributeScalar extends DefaultAttributeAbstract implements AttributeScalar {
18      private String m_value;
19  
20      /** constructor for friend classes */
21      DefaultAttributeScalar(String key, boolean isSupported, boolean isReadOnly, String value) {
22          super(key, isSupported, isReadOnly);
23          m_value = value;
24      }
25      /** constructor */
26      public DefaultAttributeScalar(String key, String value) {
27          super(key);
28          m_value = value;
29      }
30  
31      /** clone */
32      public DefaultAttributeScalar clone() throws CloneNotSupportedException {
33          DefaultAttributeScalar clone = (DefaultAttributeScalar) super.clone();
34          clone.m_value = m_value;
35          return clone;
36      }
37  
38      public void setValue(String value) throws NotImplementedException, IncorrectStateException, PermissionDeniedException {
39          this.checkSupported();
40          this.checkWritable();
41          m_value = value;
42      }
43  
44      public String getValue() throws NotImplementedException, IncorrectStateException {
45          this.checkSupported();
46          return m_value;
47      }
48  
49      public boolean equals(Object o) {
50          if (!(o instanceof DefaultAttributeScalar)) {
51              return false;
52          }
53          DefaultAttributeScalar attribute = (DefaultAttributeScalar) o;
54          if (!super.getKey().equals(attribute.getKey())) {
55              return false;
56          }
57          if (m_value==null) {
58              return (attribute.m_value==null);
59          }
60          if (attribute.m_value==null) {
61              return (m_value==null);
62          }
63          return m_value.equals(attribute.m_value);
64      }
65  }