Skip navigation links

Oracle® Coherence Java API Reference
Release 12.1.2.0.3

E26043-02


com.tangosol.util
Class StringTable

java.lang.Object
  extended by com.tangosol.util.Base
      extended by com.tangosol.util.StringTable

All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public final class StringTable
extends Base
implements java.lang.Cloneable, java.io.Serializable

Like a hash table, but built specifically for strings. Enumerates contents in order.

Version:
1.00 09/03/97
Author:
Cameron Purdy

Constructor Summary
StringTable()
          Construct a string table using all defaults.
StringTable(java.text.Collator collator)
          Construct a string table using the specified collator.
StringTable(int nStrength)
          Construct a string table using the specified collator strength.

 

Method Summary
 void add(java.lang.String string)
          Add the passed string to the table.
 boolean addAll(StringTable that)
          Adds all of the nodes in the specified StringTable to this StringTable if they are not already present.
 void clear()
          Remove all strings from the table.
 java.lang.Object clone()
          Make a new string table with a copy of the tree and a copy of the collator.
 boolean contains(java.lang.String string)
          Determine if the passed string is in the table.
 java.util.Enumeration elements()
          Create an enumerator for the values in the table.
 boolean equals(java.lang.Object obj)
          Test for equality of two string tables.
 java.lang.Object get(java.lang.String string)
          Find the specified string in the table and return its value.
 int getSize()
          Determine the number of strings in the table.
 boolean isEmpty()
          Test for empty table.
 java.util.Enumeration keys()
          Enumerate the table's strings.
 boolean keysEquals(StringTable that)
          Test for equality of the keys in two string tables.
 void put(java.lang.String string, java.lang.Object value)
          Add the passed string to the table and associate the passed value with the string.
 void putAll(StringTable that)
          Puts all of the nodes in the specified StringTable to this StringTable including the ones that are already present.
 java.lang.Object remove(java.lang.String string)
          Remove the specified string from the table, returning its associated value.
 boolean removeAll(StringTable that)
          Removes from this StringTable all of its nodes that are contained in the specified StringTable.
 boolean retainAll(StringTable that)
          Retains only the nodes in this StringTable that are contained in the specified StringTable.
 java.lang.String[] strings()
          Get the table's strings.
 java.lang.String[] stringsStartingWith(java.lang.String prefix)
          Get the table's strings that start with a specific string.
 java.lang.String toString()
          Provide a string representation of the string table.

 

Constructor Detail

StringTable

public StringTable()
Construct a string table using all defaults.

StringTable

public StringTable(java.text.Collator collator)
Construct a string table using the specified collator.
Parameters:
collator - an instance of java.text.Collator to use to compare strings
See Also:
Collator

StringTable

public StringTable(int nStrength)
Construct a string table using the specified collator strength.
Parameters:
nStrength - a valid value for java.text.Collator
See Also:
Collator.setStrength(int), Collator.PRIMARY, Collator.SECONDARY, Collator.TERTIARY, Collator.IDENTICAL

Method Detail

add

public void add(java.lang.String string)
Add the passed string to the table.
Parameters:
string - the string to add to the table

put

public void put(java.lang.String string,
                java.lang.Object value)
Add the passed string to the table and associate the passed value with the string. If the string is already in the table, the passed value will replace the current value stored with the string.
Parameters:
string - the string to add to the table
value - the object to associate with the string

get

public java.lang.Object get(java.lang.String string)
Find the specified string in the table and return its value.
Parameters:
string - the string to look for in the table
Returns:
the associated value or null if the string is not in the table

contains

public boolean contains(java.lang.String string)
Determine if the passed string is in the table.
Parameters:
string - the string to look for in the table
Returns:
true if the string is in the table, false otherwise

remove

public java.lang.Object remove(java.lang.String string)
Remove the specified string from the table, returning its associated value.
Parameters:
string - the string to look for in the table
Returns:
the associated value (which can be null) or null if the string is not in the table

clear

public void clear()
Remove all strings from the table.

getSize

public int getSize()
Determine the number of strings in the table.
Returns:
the number of strings in the table

isEmpty

public boolean isEmpty()
Test for empty table.
Returns:
true if table has no strings

strings

public java.lang.String[] strings()
Get the table's strings.
Returns:
an array of strings.

stringsStartingWith

public java.lang.String[] stringsStartingWith(java.lang.String prefix)
Get the table's strings that start with a specific string.
Returns:
an array of strings.

keys

public java.util.Enumeration keys()
Enumerate the table's strings.
Returns:
an enumerator of the table's strings

elements

public java.util.Enumeration elements()
Create an enumerator for the values in the table.
Returns:
an enumerator of the table's values (in the same order that the strings were returned)

addAll

public boolean addAll(StringTable that)
Adds all of the nodes in the specified StringTable to this StringTable if they are not already present. This operation effectively modifies this StringTable so that its value is the union of the two StringTables. The behavior of this operation is unspecified if the specified StringTable is modified while the operation is in progress.
Returns:
true if this StringTable changed as a result of the call.
See Also:
Collection.addAll(Collection)

putAll

public void putAll(StringTable that)
Puts all of the nodes in the specified StringTable to this StringTable including the ones that are already present. This operation effectively modifies this StringTable so that its value is the union of the two StringTables. The behavior of this operation is unspecified if the specified StringTable is modified while the operation is in progress.

retainAll

public boolean retainAll(StringTable that)
Retains only the nodes in this StringTable that are contained in the specified StringTable. In other words, removes from this StringTable all of its nodes that are not contained in the specified StringTable. This operation effectively modifies this StringTable so that its value is the intersection of the two StringTables.
Returns:
true if this Collection changed as a result of the call.
See Also:
Collection.retainAll(Collection)

removeAll

public boolean removeAll(StringTable that)
Removes from this StringTable all of its nodes that are contained in the specified StringTable. This operation effectively modifies this StringTable so that its value is the asymmetric set difference of the two StringTables.
Returns:
true if this StringTable changed as a result of the call.
See Also:
Collection.removeAll(Collection)

toString

public java.lang.String toString()
Provide a string representation of the string table.

equals

public boolean equals(java.lang.Object obj)
Test for equality of two string tables.
Parameters:
obj - the object to compare to
Returns:
true if the both objects are string tables with the same keys and elements

keysEquals

public boolean keysEquals(StringTable that)
Test for equality of the keys in two string tables.
Parameters:
that - the string table to compare to
Returns:
true if the both string tables have the same keys

clone

public java.lang.Object clone()
Make a new string table with a copy of the tree and a copy of the collator.

Skip navigation links

Oracle® Coherence Java API Reference
Release 12.1.2.0.3

E26043-02


Copyright © 2000, 2014, Oracle and/or its affiliates. All rights reserved.