iitb.con.ds
Class TypeTable

java.lang.Object
  extended by iitb.con.ds.TypeTable
All Implemented Interfaces:
ItemTable<java.lang.String,java.lang.Short,Type>

public class TypeTable
extends java.lang.Object
implements ItemTable<java.lang.String,java.lang.Short,Type>

TypeTable holds the Type as value objects. The super key is the type id and the sub key is the type name. In the case both super and sub key act at the same level.

Types are managed in the concept-net in the .meta file.

See Also:
Type

Constructor Summary
TypeTable(java.lang.String fileName, java.lang.String mode)
          Initializes the type table
 
Method Summary
 void close()
          Close the file associate with the table
 void commit()
          Commits the types to the respective file
 Type get(java.lang.Short id)
          Gets the Type for the specified type id
 Type get(java.lang.String name, java.lang.Short id)
          Gets the Type for the specified type name or type id
 java.util.List<Type> getAllItems()
          Gets all the types from the type table
 java.lang.Object getObject(java.lang.Object o)
          Return NULL, since there is no implementation for this
 boolean hasType(java.lang.String name)
          Returns true if type present in the table
 void put(java.lang.String name, java.lang.Short id, Type type)
          Puts the given Type into the Type table with type name and type id as key.
 void put(java.lang.String name, Type type)
          Puts the given Type into the Type table with type name as key
 void put(Type type)
          Puts the given Type into the Type table
 boolean remove(java.lang.Short id)
          Removes the Type with specified type id
 boolean remove(java.lang.String name, java.lang.Short id)
          Removes the Type with specified type name or type id
 int size()
          Returns the size of the table i.e.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface iitb.con.ds.ItemTable
get
 

Constructor Detail

TypeTable

public TypeTable(java.lang.String fileName,
                 java.lang.String mode)
          throws java.io.FileNotFoundException,
                 java.io.IOException
Initializes the type table

Parameters:
fileName - .meta file name
mode - opening mode (r, rw)
Throws:
java.io.FileNotFoundException - if file not found
java.io.IOException - if file operation fails
Method Detail

close

public void close()
           throws java.io.IOException
Close the file associate with the table

Specified by:
close in interface ItemTable<java.lang.String,java.lang.Short,Type>
Throws:
java.io.IOException - if file operations fail

commit

public void commit()
            throws java.io.IOException
Commits the types to the respective file

Specified by:
commit in interface ItemTable<java.lang.String,java.lang.Short,Type>
Throws:
java.io.IOException - if file operations fail

get

public Type get(java.lang.Short id)
Gets the Type for the specified type id

Specified by:
get in interface ItemTable<java.lang.String,java.lang.Short,Type>
Parameters:
id - type id
Returns:
Type

get

public Type get(java.lang.String name,
                java.lang.Short id)
Gets the Type for the specified type name or type id

Specified by:
get in interface ItemTable<java.lang.String,java.lang.Short,Type>
Parameters:
name - type name
id - type id
Returns:
Type

getAllItems

public java.util.List<Type> getAllItems()
Gets all the types from the type table

Specified by:
getAllItems in interface ItemTable<java.lang.String,java.lang.Short,Type>
Returns:
Type as List
See Also:
Type

getObject

public java.lang.Object getObject(java.lang.Object o)
Return NULL, since there is no implementation for this

Specified by:
getObject in interface ItemTable<java.lang.String,java.lang.Short,Type>
Parameters:
o - key object
Returns:
NULL

hasType

public boolean hasType(java.lang.String name)
Returns true if type present in the table

Parameters:
name - type name
Returns:
true if type present

put

public void put(java.lang.String name,
                java.lang.Short id,
                Type type)
Puts the given Type into the Type table with type name and type id as key.
Since both super and sub key are maintained at same level, it is enough if one is provided.

Specified by:
put in interface ItemTable<java.lang.String,java.lang.Short,Type>
Parameters:
name - type name
id - type id
type - Type
See Also:
Type

put

public void put(java.lang.String name,
                Type type)
Puts the given Type into the Type table with type name as key

Specified by:
put in interface ItemTable<java.lang.String,java.lang.Short,Type>
Parameters:
name - type name
type - Type
See Also:
Type

put

public void put(Type type)
Puts the given Type into the Type table

Specified by:
put in interface ItemTable<java.lang.String,java.lang.Short,Type>
Parameters:
type - Type
See Also:
Type

remove

public boolean remove(java.lang.Short id)
Removes the Type with specified type id

Specified by:
remove in interface ItemTable<java.lang.String,java.lang.Short,Type>
Parameters:
id - type id
Returns:
true on success

remove

public boolean remove(java.lang.String name,
                      java.lang.Short id)
Removes the Type with specified type name or type id

Specified by:
remove in interface ItemTable<java.lang.String,java.lang.Short,Type>
Parameters:
name - type name
id - type id
Returns:
true on success

size

public int size()
Returns the size of the table i.e. the no. of types

Specified by:
size in interface ItemTable<java.lang.String,java.lang.Short,Type>
Returns:
table size