infovis.column.format
Class CategoricalFormat

java.lang.Object
  extended by java.text.Format
      extended by infovis.column.format.CategoricalFormat
All Implemented Interfaces:
Serializable, Cloneable

public class CategoricalFormat
extends Format

Format for storing categorical string data in an IntColumn.

Version:
$Revision: 1.4 $
Author:
Jean-Daniel Fekete
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.text.Format
Format.Field
 
Constructor Summary
CategoricalFormat()
          Constructor.
CategoricalFormat(String name)
          Constructor.
 
Method Summary
 int addCategory(String name)
          Creates a new index associated with the given name.
 void clear()
          Clears the association maps.
 boolean equals(Object obj)
          
 int findCategory(String name)
          Find a category associated with a name, creating it if it doesn't exist yet.
 StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos)
           
 Map getCategories()
          Returns the categories map.
 int getCategory(String name)
          Get the category associated with a name.
 int hashCode()
          
 String indexCategory(int index)
          Returns the category name given its index.
 boolean isSeparator(char c)
          Select valid characters for categories.
 Object parseObject(String source, ParsePosition pos)
           
 void putCategory(String name, int value)
          Associate a category name with a value.
 
Methods inherited from class java.text.Format
clone, format, formatToCharacterIterator, parseObject
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CategoricalFormat

public CategoricalFormat(String name)
Constructor.

Parameters:
name - the categorical format name.

CategoricalFormat

public CategoricalFormat()
Constructor.

Method Detail

hashCode

public int hashCode()

Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)

Overrides:
equals in class Object

putCategory

public void putCategory(String name,
                        int value)
Associate a category name with a value.

Parameters:
name - the category name
value - the integer value.

getCategory

public int getCategory(String name)
Get the category associated with a name.

Parameters:
name - the name.
Returns:
the category or -1 if not defined.

findCategory

public int findCategory(String name)
Find a category associated with a name, creating it if it doesn't exist yet.

Parameters:
name - the category name
Returns:
the integer value associated with the name.

indexCategory

public String indexCategory(int index)
Returns the category name given its index.

Parameters:
index - the category index
Returns:
the category name.

addCategory

public int addCategory(String name)
Creates a new index associated with the given name.

Parameters:
name - the name
Returns:
a new index associated with the given name.

clear

public void clear()
Clears the association maps.


format

public StringBuffer format(Object obj,
                           StringBuffer toAppendTo,
                           FieldPosition pos)
Specified by:
format in class Format
See Also:
Format.format(Object, StringBuffer, FieldPosition)

isSeparator

public boolean isSeparator(char c)
Select valid characters for categories.

Parameters:
c - a character
Returns:
true if the character is a separator.

parseObject

public Object parseObject(String source,
                          ParsePosition pos)
Specified by:
parseObject in class Format
See Also:
Format.parseObject(String, ParsePosition)

getCategories

public Map getCategories()
Returns the categories map.

Returns:
the categories map.


Copyright © 2005 by Jean-Daniel Fekete and INRIA, France All rights reserved.