net.sourceforge.cilib.type.types
Class StringType

java.lang.Object
  extended by net.sourceforge.cilib.type.types.StringType
All Implemented Interfaces:
Serializable, Type, Cloneable

public class StringType
extends Object
implements Type

Author:
Gary Pampara
See Also:
Serialized Form

Constructor Summary
StringType()
          Create an StringType instance, which is empty and uninitialised.
StringType(String string)
          Create an instance with the given string as the contents.
StringType(StringType copy)
          Copy constructor.
 
Method Summary
 boolean equals(Object other)
          Compare the specified object with this type for equality.
 StringType getClone()
          Create a cloned copy of the current object and return it.
 String getString()
          Get the contained string.
 int hashCode()
          Returns the hash code value for this list.
 void readExternal(ObjectInput ois)
          Read the contents from a given ObjectInput.
 void setString(String newString)
          Set the contained String value.
 String toString()
          
 void writeExternal(ObjectOutput oos)
          Write the contents of the StringType to an ObjectOutput.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StringType

public StringType()
Create an StringType instance, which is empty and uninitialised.


StringType

public StringType(String string)
Create an instance with the given string as the contents.

Parameters:
string - The string value to have.

StringType

public StringType(StringType copy)
Copy constructor. Copy the given instance.

Parameters:
copy - The instance to copy.
Method Detail

getClone

public StringType getClone()
Create a cloned copy of the current object and return it. In general the created copy will be a deep copy of the provided instance. As a result this operation an be quite expensive if used incorrectly.

Specified by:
getClone in interface Type
Specified by:
getClone in interface Cloneable
Returns:
An exact clone of the current object instance.
See Also:
Object.clone()

getString

public String getString()
Get the contained string.

Returns:
the contained String.

setString

public void setString(String newString)
Set the contained String value.

Parameters:
newString - The value to be contained by the StringType.

equals

public boolean equals(Object other)
Compare the specified object with this type for equality. Returns true if and only if the specified object is also an instance of the same type.

Specified by:
equals in interface Type
Overrides:
equals in class Object
Parameters:
other - The object to compare.
Returns:
true if equality exists, false otherwise.
See Also:
Object.equals(Object)

hashCode

public int hashCode()
Returns the hash code value for this list. The hash code of a list is defined to be the result of the following calculation:
  int hashCode = 7;
  Iterator<E> i = list.iterator();
  while (i.hasNext()) {
      E obj = i.next();
      hashCode = 31*hashCode + (obj==null ? 0 : obj.hashCode());
  }
 
This ensures that type1.equals(type2) implies that type1.hashCode()==type2.hashCode() for any two types, type1 and type2, as required by the general contract of Object.hashCode().

Specified by:
hashCode in interface Type
Overrides:
hashCode in class Object
Returns:
the hash code value for this list
See Also:
Object.equals(Object), Type.equals(Object)

toString

public String toString()

Overrides:
toString in class Object

writeExternal

public void writeExternal(ObjectOutput oos)
                   throws IOException
Write the contents of the StringType to an ObjectOutput.

Parameters:
oos - the ObjectOutput to write to.
Throws:
IOException - If an exception occurs.

readExternal

public void readExternal(ObjectInput ois)
                  throws IOException,
                         ClassNotFoundException
Read the contents from a given ObjectInput.

Parameters:
ois - The ObjectInput to use.
Throws:
IOException - If an IO problem occurs.
ClassNotFoundException - If the desired class is not found.


Copyright © 2009 CIRG. All Rights Reserved.