Coverage Report - eu.simuline.octave.type.OctaveString
 
Classes in this File Line Coverage Branch Coverage Complexity
OctaveString
72%
13/18
33%
4/12
2.143
 
 1  
 /*
 2  
  * Copyright 2007, 2008 Ange Optimization ApS
 3  
  *
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  *     http://www.apache.org/licenses/LICENSE-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 /**
 17  
  * @author kim
 18  
  */
 19  
 package eu.simuline.octave.type;
 20  
 
 21  
 /**
 22  
  * Represents an octave string. 
 23  
  */
 24  28
 public final class OctaveString implements OctaveObject {
 25  
 
 26  
     private static final int PRIME = 31;
 27  
 
 28  
     private String value;
 29  
 
 30  
     /**
 31  
      * @param string
 32  
      */
 33  572
     public OctaveString(final String string) {
 34  572
         this.value = string;
 35  572
     }
 36  
 
 37  
     /**
 38  
      * Returns the string represented by this object. 
 39  
      *
 40  
      * @return
 41  
      *    the string represented by this object. 
 42  
      */
 43  
     public String getString() {
 44  516
         return this.value;
 45  
     }
 46  
 
 47  
     /**
 48  
      * @param string
 49  
      *    the string to set
 50  
      */
 51  
     public void setString(final String string) {
 52  2
         this.value = string;
 53  2
     }
 54  
 
 55  
     @Override
 56  
     public int hashCode() {
 57  0
         return (this.value == null) ? PRIME : this.value.hashCode();
 58  
     }
 59  
 
 60  
     @Override
 61  
     public boolean equals(final Object obj) {
 62  28
         if (this == obj) {
 63  0
             return true;
 64  
         }
 65  28
         if (obj == null || getClass() != obj.getClass()) {
 66  0
             return false;
 67  
         }
 68  28
         final OctaveString other = (OctaveString) obj;
 69  28
         if (this.value == null) {
 70  0
             return other.value == null;
 71  
         }
 72  28
         return this.value.equals(other.value);
 73  
     }
 74  
 
 75  
     @Override
 76  
     public OctaveString shallowCopy() {
 77  28
         return new OctaveString(this.value);
 78  
     }
 79  
 
 80  
     @Override
 81  
     public String toString() {
 82  0
         return "OctaveString[" + this.value + "]";
 83  
     }
 84  
 
 85  
 }