databionics.io
Class ClassmaskFile

java.lang.Object
  extended by databionics.io.BaseFile
      extended by databionics.io.ListFile
          extended by databionics.io.MapFile
              extended by databionics.io.ClassmaskFile

public class ClassmaskFile
extends MapFile

Author:
stammi

Field Summary
protected  ColorTable classColors
          Default color table
protected  cern.colt.list.IntArrayList classes
          Column with class numbers
protected  cern.colt.map.OpenIntIntHashMap key2pos
          Column with data point keys
protected  cern.colt.list.IntArrayList keys
          Column with data point keys
protected static org.apache.log4j.Logger log
          Log4j logging.
 
Fields inherited from class databionics.io.MapFile
map
 
Fields inherited from class databionics.io.ListFile
data
 
Fields inherited from class databionics.io.BaseFile
allowEmptyLines, comment, commentPrefix, delimiter, delimiters, file, header, headerPrefix, loc, nf
 
Constructor Summary
ClassmaskFile()
          Standard constructor
ClassmaskFile(int size)
           
ClassmaskFile(java.lang.String filename)
          Constructor with a filename
 
Method Summary
 void add(int index, int cls)
          Add an index - class number pair
 void addClass(int cls)
          Add a data class if it's not in the list
protected  void buildHeader()
          Generate header.
protected  java.lang.String buildLine(int row)
          Construct a line for saving.
 boolean changeIndex(int from, int to)
          Change Index of class.
protected  void checkHeader()
          Check consistency of header information.
 void clear()
          Clear class list, set all class numbers to 0
 java.lang.Object clone()
          Deprecated. might not work correct
 int getByIndex(int index)
          Get class number of a classification by its index
 DataClass getClass(int pos)
          Get a data class by its position in the list
 DataClass getClassByIndex(int index)
          Get a data class by its index
 cern.colt.list.IntArrayList getClasses()
          Get classes.
static FileType getFileType()
          Get the type of file.
 int getHighestClassIndex()
           
 cern.colt.list.IntArrayList getKeys()
          Get keys.
 int getQuick(int pos)
          Get class number of a classification by its position in the list
 int getSize()
          Get the number of lines in file.
protected  void parseHeader()
          Parse the header.
protected  void parseLine(int row, java.lang.String line)
          Parse a line.
 void remove(DataClass cls)
          Remove a class, set all corresponding class numbers to 0
 void remove(int cls)
          Remove a class, set all corresponding class numbers to 0.
 void removeOne(int index, int classes)
           
 void set(int index, int cls)
          Set an index - class number pair
 void setClasses(int[] classes)
          Set classes.
 void setClasses(cern.colt.list.IntArrayList classes)
          Set classes.
 void setKeys()
          Add automatically generated keys.
 void setKeys(int[] keys)
          Set keys.
 void setKeys(cern.colt.list.IntArrayList keys)
          Set keys.
 int size(DataClass cls)
          Get size of a class
 int size(int cls)
          Get size of a class
 void sort()
          Sort classifications by key number.
 
Methods inherited from class databionics.io.MapFile
add, getMap, remove, setData, setMap
 
Methods inherited from class databionics.io.ListFile
getData
 
Methods inherited from class databionics.io.BaseFile
checkHeaderAgainstSize, getComment, getFile, getFilename, getHeader, getLocale, getNumberFormat, init, isHeader, isNaN, isNumber, load, load, parseError, save, save, setComment, setFilename, setLocale, writeStringList, writeStringList
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static final org.apache.log4j.Logger log
Log4j logging.


keys

protected cern.colt.list.IntArrayList keys
Column with data point keys


classes

protected cern.colt.list.IntArrayList classes
Column with class numbers


key2pos

protected cern.colt.map.OpenIntIntHashMap key2pos
Column with data point keys


classColors

protected ColorTable classColors
Default color table

Constructor Detail

ClassmaskFile

public ClassmaskFile()
Standard constructor


ClassmaskFile

public ClassmaskFile(int size)

ClassmaskFile

public ClassmaskFile(java.lang.String filename)
Constructor with a filename

Parameters:
filename - Name of the file
Method Detail

sort

public void sort()
Sort classifications by key number.


parseHeader

protected void parseHeader()
Parse the header.

Overrides:
parseHeader in class BaseFile

parseLine

protected void parseLine(int row,
                         java.lang.String line)
Parse a line.

Overrides:
parseLine in class BaseFile
Parameters:
row - Number of current line.
line - Current line.

checkHeader

protected void checkHeader()
Check consistency of header information.

Overrides:
checkHeader in class BaseFile

buildHeader

protected void buildHeader()
Generate header.

Overrides:
buildHeader in class BaseFile

buildLine

protected java.lang.String buildLine(int row)
Construct a line for saving.

Overrides:
buildLine in class ListFile
Parameters:
row - Number of current line.
Returns:
Line with that number.

getClass

public DataClass getClass(int pos)
Get a data class by its position in the list

Parameters:
position - of data class

addClass

public void addClass(int cls)
Add a data class if it's not in the list

Parameters:
class - number

getClassByIndex

public DataClass getClassByIndex(int index)
Get a data class by its index

Parameters:
index - class number

getSize

public int getSize()
Get the number of lines in file.

Overrides:
getSize in class ListFile
Returns:
Number of lines in file.

add

public void add(int index,
                int cls)
Add an index - class number pair

Parameters:
index - of data point or best match
cls - class number

set

public void set(int index,
                int cls)
Set an index - class number pair

Parameters:
index - of data point or best match
cls - class number

remove

public void remove(int cls)
Remove a class, set all corresponding class numbers to 0. Ignores 0 as parameter.

Overrides:
remove in class MapFile
Parameters:
cls - class number

removeOne

public void removeOne(int index,
                      int classes)
Parameters:
index -
classes -

remove

public void remove(DataClass cls)
Remove a class, set all corresponding class numbers to 0

Parameters:
cls - class

changeIndex

public boolean changeIndex(int from,
                           int to)
Change Index of class.

Parameters:
from - old Index
to - new Index

clear

public void clear()
Clear class list, set all class numbers to 0


size

public int size(int cls)
Get size of a class

Parameters:
cls - class number
Returns:
number of data points in this class

size

public int size(DataClass cls)
Get size of a class

Parameters:
cls - class
Returns:
number of data points in this class

getQuick

public int getQuick(int pos)
Get class number of a classification by its position in the list

Parameters:
position - of classification

getByIndex

public int getByIndex(int index)
Get class number of a classification by its index

Parameters:
index - index of the data point

clone

public java.lang.Object clone()
Deprecated. might not work correct

This function makes a copy of the special Instance of this class

Overrides:
clone in class java.lang.Object
Returns:
an independent copy of this

getKeys

public cern.colt.list.IntArrayList getKeys()
Get keys.


setKeys

public void setKeys(cern.colt.list.IntArrayList keys)
Set keys.


setKeys

public void setKeys(int[] keys)
Set keys.


setKeys

public void setKeys()
Add automatically generated keys.


getClasses

public cern.colt.list.IntArrayList getClasses()
Get classes.


setClasses

public void setClasses(cern.colt.list.IntArrayList classes)
Set classes.


setClasses

public void setClasses(int[] classes)
Set classes.


getFileType

public static FileType getFileType()
Get the type of file.


getHighestClassIndex

public int getHighestClassIndex()
Returns:
The highest classIndex


Copyright © 2005-2006 Databionics Research Group. All Rights Reserved.