iitb.con.query
Class ItemQuery

java.lang.Object
  extended by iitb.con.query.ItemQuery
All Implemented Interfaces:
Query

public class ItemQuery
extends java.lang.Object
implements Query


Constructor Summary
ItemQuery(java.lang.String cnetDirName, ItemTable<java.lang.String,java.lang.Short,Type> typeTable, ItemTable<java.lang.Short,java.lang.Integer,InstanceMetaItem> instanceTable, RelationTable relationTable)
          Constructs the ItemQuery object and initializes with meta-information of concept-net
 
Method Summary
 void close()
          Closes the files that associated with the query object
 java.util.List<java.lang.Integer> getAllEntityInstanceIds()
          Returns all the Entity Instances Id
 java.util.List<EntityInstance> getAllEntityInstances()
          Returns all the EntitiyInstances in the concept-net
 java.util.List<java.lang.Short> getAllEntityTypeIds()
          Returns all entity type ids
 java.util.List<java.lang.Integer> getAllInstanceIds()
          Returns all the Entity and Relation Instances Id
 java.util.List<java.lang.Integer> getAllRelationInstanceIds()
          Returns all the Relation Instances Id
 java.util.List<RelationInstance> getAllRelationInstances()
          Returns all the RelationInstances in the concept-net
 java.util.List<java.lang.Short> getAllRelationTypeIds()
          Returns all relation type ids
 java.util.List<java.lang.Short> getAllTypeIds()
          Returns all type ids
 java.util.List<EntityInstance> getEntityInstances(java.lang.Short typeId)
          Returns all the entity instances of specified Type
 java.util.List<EntityInstance> getEntityInstances(java.lang.String typeName)
          Returns all the entity instances of specified Type
 Instance getInstance(int instanceId)
          Returns the instance for the specified instance id
 java.util.List<java.lang.Integer> getInstanceIds(short typeId)
          Returns the instance ids for the specified Type id
 java.util.List<java.lang.Integer> getInstanceIds(java.lang.String typeName)
          Returns the instance ids for the specified Type name
<K extends java.lang.Comparable<K>>
java.util.List<java.lang.Integer>
getInstanceIds(java.lang.String typeName, java.lang.String attributeName, K value)
          Returns the existing Instance ids from the concept-nets.
The instance id is retrieved based on the type with the specified attribute name and its value.
 InstanceMetaItem getInstanceMetaItem(int instanceId)
          Returns the instance meta item of specified instance id
 java.util.List<Instance> getInstances(java.util.List<java.lang.Integer> idList)
          Returns the instances for the specified instance id
 java.util.List<Instance> getInstances(java.lang.Short typeId)
          Returns all the instances for the specified Type
 java.util.List<Instance> getInstances(java.lang.String typeName)
          Returns all the instances for the specified Type
<K extends java.lang.Comparable<K>>
java.util.List<Instance>
getInstances(java.lang.String typeName, java.lang.String attributeName, K value)
          Returns the existing Instance from the concept-nets.
The instance is retrieved based on the type with the specified attribute name and its value.
 int getLeftEntityId(int relationInstanceId)
          Returns the left associated entity id of the given relation id
 java.util.List<java.lang.Integer> getRelatedInstanceIds(int instanceId)
          Returns the instance ids based on the relation association of the specified instance
 java.util.List<java.lang.Integer> getRelatedInstanceIds(int instanceId, java.lang.String relationTypeName)
          Returns the related Instance ids for the specified entity instance id and filtered by relation type name
 java.util.List<java.lang.Integer> getRelationIds(int instanceId)
          Returns the associated relations Ids of an entity instance id
 java.util.List<java.lang.Integer> getRelationIds(int instanceId, java.lang.String relationTypeName)
          Returns the associated relations Ids of an entity instance id and filtered by relation type name
 java.util.List<RelationInstance> getRelationInstances(java.lang.Short typeId)
          Returns all the relation instances of specified Type
 java.util.List<RelationInstance> getRelationInstances(java.lang.String typeName)
          Returns all the relation instances of specified Type
 int getRightEntityId(int relationInstanceId)
          Returns the right associated entity id of the given relation id
 Type getType(java.lang.String typeName)
          Returns Type for the specified type name
 short getTypeId(int instanceId)
          Returns the type id of the specified instance
 short getTypeId(java.lang.String typeName)
          Returns the type id of the specified type name
 java.lang.String getTypeName(short typeId)
          Returns the type name for the specified type id
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ItemQuery

public ItemQuery(java.lang.String cnetDirName,
                 ItemTable<java.lang.String,java.lang.Short,Type> typeTable,
                 ItemTable<java.lang.Short,java.lang.Integer,InstanceMetaItem> instanceTable,
                 RelationTable relationTable)
          throws java.io.FileNotFoundException,
                 java.io.IOException
Constructs the ItemQuery object and initializes with meta-information of concept-net

Parameters:
cnetDirName - concept-net directory name
typeTable - type table reference
instanceTable - instance table reference
Throws:
java.io.FileNotFoundException - if concept-net file not found
java.io.IOException - if file operation fails
Method Detail

close

public void close()
           throws java.io.IOException
Closes the files that associated with the query object

Specified by:
close in interface Query
Throws:
java.io.IOException - if file operation fails

getAllEntityInstanceIds

public java.util.List<java.lang.Integer> getAllEntityInstanceIds()
Returns all the Entity Instances Id

Specified by:
getAllEntityInstanceIds in interface Query
Returns:
Instance Ids as List

getAllEntityInstances

public java.util.List<EntityInstance> getAllEntityInstances()
Returns all the EntitiyInstances in the concept-net

Specified by:
getAllEntityInstances in interface Query
Returns:
entity instance list
See Also:
EntityInstance

getAllEntityTypeIds

public java.util.List<java.lang.Short> getAllEntityTypeIds()
Returns all entity type ids

Specified by:
getAllEntityTypeIds in interface Query
Returns:
type ids as list

getAllInstanceIds

public java.util.List<java.lang.Integer> getAllInstanceIds()
Returns all the Entity and Relation Instances Id

Specified by:
getAllInstanceIds in interface Query
Returns:
Instance Ids as List

getAllRelationInstanceIds

public java.util.List<java.lang.Integer> getAllRelationInstanceIds()
Returns all the Relation Instances Id

Specified by:
getAllRelationInstanceIds in interface Query
Returns:
Instance Ids as List

getAllRelationInstances

public java.util.List<RelationInstance> getAllRelationInstances()
Returns all the RelationInstances in the concept-net

Specified by:
getAllRelationInstances in interface Query
Returns:
relation instance list
See Also:
RelationInstance

getAllRelationTypeIds

public java.util.List<java.lang.Short> getAllRelationTypeIds()
Returns all relation type ids

Specified by:
getAllRelationTypeIds in interface Query
Returns:
type ids as list

getAllTypeIds

public java.util.List<java.lang.Short> getAllTypeIds()
Returns all type ids

Specified by:
getAllTypeIds in interface Query
Returns:
type ids as list

getEntityInstances

public java.util.List<EntityInstance> getEntityInstances(java.lang.Short typeId)
Returns all the entity instances of specified Type

Specified by:
getEntityInstances in interface Query
Parameters:
typeId - type id
Returns:
Entity instance list of the given type
See Also:
EntityInstance

getEntityInstances

public java.util.List<EntityInstance> getEntityInstances(java.lang.String typeName)
Returns all the entity instances of specified Type

Specified by:
getEntityInstances in interface Query
Parameters:
typeName - type name
Returns:
Entity instance list of the given type
See Also:
EntityInstance

getInstance

public Instance getInstance(int instanceId)
Returns the instance for the specified instance id

Specified by:
getInstance in interface Query
Parameters:
instanceId - instance id
Returns:
@link{Instance}

getInstanceIds

public java.util.List<java.lang.Integer> getInstanceIds(short typeId)
Returns the instance ids for the specified Type id

Specified by:
getInstanceIds in interface Query
Parameters:
typeId - type id
Returns:
instance ids of the relevant type

getInstanceIds

public java.util.List<java.lang.Integer> getInstanceIds(java.lang.String typeName)
Returns the instance ids for the specified Type name

Specified by:
getInstanceIds in interface Query
Parameters:
typeName - type name
Returns:
instance ids of the relevant type

getInstanceIds

public <K extends java.lang.Comparable<K>> java.util.List<java.lang.Integer> getInstanceIds(java.lang.String typeName,
                                                                                            java.lang.String attributeName,
                                                                                            K value)
Returns the existing Instance ids from the concept-nets.
The instance id is retrieved based on the type with the specified attribute name and its value.
Returns NULL, if Instance does not exists.

Specified by:
getInstanceIds in interface Query
Parameters:
typeName - type name
attributeName - instance's attribute name
value - the attribute value
Returns:
instance ids as list

getInstanceMetaItem

public InstanceMetaItem getInstanceMetaItem(int instanceId)
Returns the instance meta item of specified instance id

Specified by:
getInstanceMetaItem in interface Query
Parameters:
instanceId - instance's id
Returns:
InstanceMetaItem

getInstances

public java.util.List<Instance> getInstances(java.util.List<java.lang.Integer> idList)
Returns the instances for the specified instance id

Specified by:
getInstances in interface Query
Parameters:
idList - list of instance ids
Returns:
@link{Instance}

getInstances

public java.util.List<Instance> getInstances(java.lang.Short typeId)
Returns all the instances for the specified Type

Specified by:
getInstances in interface Query
Parameters:
typeId - type id
Returns:
instance list of the given type
See Also:
Instance

getInstances

public java.util.List<Instance> getInstances(java.lang.String typeName)
Returns all the instances for the specified Type

Specified by:
getInstances in interface Query
Parameters:
typeName - type name
Returns:
instance list of the given type
See Also:
Instance

getInstances

public <K extends java.lang.Comparable<K>> java.util.List<Instance> getInstances(java.lang.String typeName,
                                                                                 java.lang.String attributeName,
                                                                                 K value)
Returns the existing Instance from the concept-nets.
The instance is retrieved based on the type with the specified attribute name and its value.
Returns NULL, if Instance does not exists.

Specified by:
getInstances in interface Query
Parameters:
typeName - type name
attributeName - instance's attribute name
value - the attribute value
Returns:
Instance list

getLeftEntityId

public int getLeftEntityId(int relationInstanceId)
Returns the left associated entity id of the given relation id

Specified by:
getLeftEntityId in interface Query
Parameters:
relationInstanceId - relation instance id
Returns:
entity instance id if exists, else returns -1

getRelatedInstanceIds

public java.util.List<java.lang.Integer> getRelatedInstanceIds(int instanceId)
Returns the instance ids based on the relation association of the specified instance

Specified by:
getRelatedInstanceIds in interface Query
Parameters:
instanceId - entity instance id
Returns:
entity instance ids which have relations with the specified instance

getRelatedInstanceIds

public java.util.List<java.lang.Integer> getRelatedInstanceIds(int instanceId,
                                                               java.lang.String relationTypeName)
Returns the related Instance ids for the specified entity instance id and filtered by relation type name

Specified by:
getRelatedInstanceIds in interface Query
Parameters:
instanceId - entity instance id whose relations are to be fetched
relationTypeName - relation type name to filter the instance's relations
Returns:
Instance's relations Id as Integer List

getRelationIds

public java.util.List<java.lang.Integer> getRelationIds(int instanceId)
Returns the associated relations Ids of an entity instance id

Specified by:
getRelationIds in interface Query
Parameters:
instanceId - entity instance id whose relations are to be fetched
Returns:
Instance's relations Id as Integer List

getRelationIds

public java.util.List<java.lang.Integer> getRelationIds(int instanceId,
                                                        java.lang.String relationTypeName)
Returns the associated relations Ids of an entity instance id and filtered by relation type name

Specified by:
getRelationIds in interface Query
Parameters:
instanceId - entity instance id whose relations are to be fetched
relationTypeName - relation type name to filter the instance's relations
Returns:
Instance's relations Id as Integer List

getRelationInstances

public java.util.List<RelationInstance> getRelationInstances(java.lang.Short typeId)
Returns all the relation instances of specified Type

Specified by:
getRelationInstances in interface Query
Parameters:
typeId - type id
Returns:
Relation instance list of the given type
See Also:
RelationInstance

getRelationInstances

public java.util.List<RelationInstance> getRelationInstances(java.lang.String typeName)
Returns all the relation instances of specified Type

Specified by:
getRelationInstances in interface Query
Parameters:
typeName - type name
Returns:
Relation instance list of the given type
See Also:
RelationInstance

getRightEntityId

public int getRightEntityId(int relationInstanceId)
Returns the right associated entity id of the given relation id

Specified by:
getRightEntityId in interface Query
Parameters:
relationInstanceId - relation instance id
Returns:
entity instance id if exists, else returns -1

getType

public Type getType(java.lang.String typeName)
Returns Type for the specified type name

Specified by:
getType in interface Query
Returns:
Type if exists, else null

getTypeId

public short getTypeId(int instanceId)
Returns the type id of the specified instance

Specified by:
getTypeId in interface Query
Parameters:
instanceId - instance id
Returns:
type id if exists, else returns -1

getTypeId

public short getTypeId(java.lang.String typeName)
Returns the type id of the specified type name

Specified by:
getTypeId in interface Query
Parameters:
typeName - type name
Returns:
type id if exists, else returns -1

getTypeName

public java.lang.String getTypeName(short typeId)
Returns the type name for the specified type id

Specified by:
getTypeName in interface Query
Parameters:
typeId - Type id
Returns:
type name if exists, else null
See Also:
Type