org.apache.mahout.common
Class StringTuple

java.lang.Object
  extended by org.apache.mahout.common.StringTuple
All Implemented Interfaces:
java.lang.Comparable<StringTuple>, org.apache.hadoop.io.Writable, org.apache.hadoop.io.WritableComparable<StringTuple>

public final class StringTuple
extends java.lang.Object
implements org.apache.hadoop.io.WritableComparable<StringTuple>

An Ordered List of Strings which can be used in a Hadoop Map/Reduce Job


Constructor Summary
StringTuple()
           
StringTuple(java.lang.Iterable<java.lang.String> entries)
           
StringTuple(java.lang.String firstEntry)
           
StringTuple(java.lang.String[] entries)
           
 
Method Summary
 boolean add(java.lang.String entry)
          add an entry to the end of the list
 int compareTo(StringTuple otherTuple)
           
 boolean equals(java.lang.Object obj)
           
 java.util.List<java.lang.String> getEntries()
          Fetch the list of entries from the tuple
 int hashCode()
           
 int length()
          Returns the length of the tuple
 void readFields(java.io.DataInput in)
           
 java.lang.String replaceAt(int index, java.lang.String newString)
          Replaces the string at the given index with the given newString
 java.lang.String stringAt(int index)
          Fetches the string at the given location
 java.lang.String toString()
           
 void write(java.io.DataOutput out)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StringTuple

public StringTuple()

StringTuple

public StringTuple(java.lang.String firstEntry)

StringTuple

public StringTuple(java.lang.Iterable<java.lang.String> entries)

StringTuple

public StringTuple(java.lang.String[] entries)
Method Detail

add

public boolean add(java.lang.String entry)
add an entry to the end of the list

Parameters:
entry -
Returns:
true if the items get added

stringAt

public java.lang.String stringAt(int index)
Fetches the string at the given location

Parameters:
index -
Returns:
String value at the given location in the tuple list

replaceAt

public java.lang.String replaceAt(int index,
                                  java.lang.String newString)
Replaces the string at the given index with the given newString

Parameters:
index -
newString -
Returns:
The previous value at that location

getEntries

public java.util.List<java.lang.String> getEntries()
Fetch the list of entries from the tuple

Returns:
a List containing the strings in the order of insertion

length

public int length()
Returns the length of the tuple

Returns:
length

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

readFields

public void readFields(java.io.DataInput in)
                throws java.io.IOException
Specified by:
readFields in interface org.apache.hadoop.io.Writable
Throws:
java.io.IOException

write

public void write(java.io.DataOutput out)
           throws java.io.IOException
Specified by:
write in interface org.apache.hadoop.io.Writable
Throws:
java.io.IOException

compareTo

public int compareTo(StringTuple otherTuple)
Specified by:
compareTo in interface java.lang.Comparable<StringTuple>


Copyright © 2008-2010 The Apache Software Foundation. All Rights Reserved.