com.languagecomputer.api.query
Class DefaultQuery

java.lang.Object
  extended by com.languagecomputer.api.query.DefaultQuery
All Implemented Interfaces:
Query

public class DefaultQuery
extends Object
implements Query

Default implementation of a Query. Alternatively, the Query interface may be implemented in order to be backed by a different mechanism (i.e., for speed and/or memory performance based on the individual system).

Since:
1.0
Author:
Kirk Roberts

Constructor Summary
DefaultQuery()
           
 
Method Summary
 void addKeyword(Keyword keyword)
          Adds a Keyword to the keyword representation of the DefaultQuery.
 void addRequiredEntityType(String entityType)
          Adds an entity type to the required entity type representation of the DefaultQuery.
 Set<Keyword> getKeywords()
          Returns the keywords for this Query.
 String getNaturalLanguage()
          Returns the natural language representation for this Query.
 Set<String> getRequiredEntityTypes()
          Returns the required entity types for this Query.
 String getStructuredQuery()
          Returns the structured data query for this Query.
 void setNaturalLanguage(String naturalLanguage)
          Sets the natural language representation for the DefaultQuery.
 void setStructuredQuery(String structuredQuery)
          Sets the structured query representation for the DefaultQuery.
 String toString()
          Returns a String representation of a DefaultQuery.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultQuery

public DefaultQuery()
Method Detail

setNaturalLanguage

public void setNaturalLanguage(String naturalLanguage)
Sets the natural language representation for the DefaultQuery. Does not need to be called if there is no such representation.

Parameters:
naturalLanguage - Natural language query, or null to indicate none exists.
See Also:
getNaturalLanguage()

getNaturalLanguage

public String getNaturalLanguage()
Returns the natural language representation for this Query. This could be a question, a command, or just traditional keywords.

Specified by:
getNaturalLanguage in interface Query
Returns:
A String representation of this Query, or null if it has no natural language representation.

addKeyword

public void addKeyword(Keyword keyword)
Adds a Keyword to the keyword representation of the DefaultQuery. Does not need to be called if there is no such representation.

Parameters:
keyword - non-null Keyword to add.
Throws:
IllegalArgumentException - If the keyword is null.
See Also:
getKeywords()

getKeywords

public Set<Keyword> getKeywords()
Returns the keywords for this Query.

Specified by:
getKeywords in interface Query
Returns:
A Set of Keywords representing this Query, or null if it has no keyword representation.

addRequiredEntityType

public void addRequiredEntityType(String entityType)
Adds an entity type to the required entity type representation of the DefaultQuery. Does not need to be called if there is no such representation.

Parameters:
entityType - non-null entity type String.
Throws:
IllegalArgumentException - If the entityType is null.
See Also:
getRequiredEntityTypes()

getRequiredEntityTypes

public Set<String> getRequiredEntityTypes()
Returns the required entity types for this Query.

Specified by:
getRequiredEntityTypes in interface Query
Returns:
A Set of mandatory entity types representing this Query, or null if it has no required entity types representation.

setStructuredQuery

public void setStructuredQuery(String structuredQuery)
Sets the structured query representation for the DefaultQuery. Does not need to be called if there is no such representation.

Parameters:
structuredQuery - Structured query, or null to indicate none exists.
See Also:
getStructuredQuery()

getStructuredQuery

public String getStructuredQuery()
Returns the structured data query for this Query.

Specified by:
getStructuredQuery in interface Query
Returns:
A String-based structured query representing this Query, or null if it has no structured query representation.

toString

public String toString()
Returns a String representation of a DefaultQuery.

Overrides:
toString in class Object


Copyright © 2009. All Rights Reserved.