Class AbstractSqlTag
- java.lang.Object
-
- net.sf.jkniv.sqlegance.builder.xml.AbstractSqlTag
-
- Direct Known Subclasses:
IncludeTag,ProcedureTag
public abstract class AbstractSqlTag extends Object implements SqlTag
Generic tag to support the common functions from other tags.- Since:
- 0.0.2
- Author:
- Alisson Gomes
-
-
Field Summary
Fields Modifier and Type Field Description static StringATTRIBUTE_BATCHstatic StringATTRIBUTE_CACHEstatic StringATTRIBUTE_GROUP_BYstatic StringATTRIBUTE_HINTstatic StringATTRIBUTE_ISOLATIONstatic StringATTRIBUTE_NAMEstatic StringATTRIBUTE_RESULTSET_CONCURRENCYstatic StringATTRIBUTE_RESULTSET_HOLDABILITYstatic StringATTRIBUTE_RESULTSET_TYPEstatic StringATTRIBUTE_RETURN_TYPEstatic StringATTRIBUTE_TIMEOUTstatic StringATTRIBUTE_TYPEstatic StringATTRIBUTE_VALIDATIONprotected Stringidprotected LanguageTypelanguageTypeprotected static net.sf.jkniv.asserts.AssertableNOT_NULL
-
Constructor Summary
Constructors Constructor Description AbstractSqlTag(String id, LanguageType languageType)Build a new SQL tag from XML file.AbstractSqlTag(String id, LanguageType languageType, SqlDialect sqlDialect)AbstractSqlTag(String id, LanguageType languageType, Isolation isolation, int timeout, ResultSetType resultSetType, ResultSetConcurrency resultSetConcurrency, ResultSetHoldability resultSetHoldability, String returnType, ValidateType validateType, Statistical stats)Build a new SQL tag from XML file.AbstractSqlTag(String id, LanguageType languageType, Isolation isolation, int timeout, ValidateType validateType, Statistical stats)Build a new SQL tag from XML file.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddTag(String text)add a set of static text from tag elements.voidaddTag(List<ITextTag> tags)add a set of text tags (static or dynamic).voidaddTag(ITextTag tag)add a new text tag.DeletableasDeletable()DeletableinstanceInsertableasInsertable()InsertableinstanceSelectableasSelectable()SelectableinstanceStorableasStorable()StorableinstanceUpdateableasUpdateable()Updateableinstancevoidbind(SqlDialect sqlDialect)booleanequals(Object obj)String[]extractNames(Object params)Extract the name parameters from dynamic queryString[]extractNames(String sql)Extract the name parameters from SQLIsolationgetIsolation()Retrieves the current transaction isolation level for the query.LanguageTypegetLanguageType()language from SQL sentence.StringgetName()Retrieve the identifier name from tag.StringgetPackage()name of package that this SQL belongsParamParsergetParamParser()strategy to parser the parameters from SQL.StringgetResourceName()The filename that SQL belong toResultSetConcurrencygetResultSetConcurrency()ResultSetHoldabilitygetResultSetHoldability()ResultSetTypegetResultSetType()StringgetReturnType()Class<?>getReturnTypeAsClass()StringgetSql()Retrieve static sql from a node, the dynamic parts is skipped.StringgetSql(Object params)Retrieve dynamic sql from a node, the dynamic parts is evaluated at time to create the sql.SqlDialectgetSqlDialect()dialect for a specific databaseStatisticalgetStats()get statistical data from query executionintgetTimeout()Retrieves the number of seconds the repository will wait for a Query object to execute.DategetTimestamp()Timestamp when sql was read from xmlValidateTypegetValidateType()StringgetXPath()Expression XPATH to read SQLinthashCode()booleanhasReturnType()booleanisDeletable()Verify if command is a DELETEbooleanisInsertable()Verify if command is a INSERTbooleanisSelectable()Verify if command is a SELECTbooleanisStorable()Verify if command is a STORED PROCEDUREbooleanisUpdateable()Verify if command is a UPDATEvoidsetIsolation(Isolation isolation)voidsetPackage(String name)name of package this sql belongvoidsetResourceName(String resourceName)File name from SqlvoidsetResultSetConcurrency(ResultSetConcurrency resultSetConcurrency)voidsetResultSetHoldability(ResultSetHoldability resultSetHoldability)voidsetResultSetType(ResultSetType resultSetType)voidsetResultType(String returnType)protected voidsetStats(Statistical stats)voidsetTimeout(int timeout)voidsetValidateType(ValidateType validateType)voidsetXpath(String xpath)set the XPATH expression to retrieve the query at xml file.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.sf.jkniv.sqlegance.Sql
getSqlType
-
Methods inherited from interface net.sf.jkniv.sqlegance.builder.xml.SqlTag
getTagName
-
-
-
-
Field Detail
-
NOT_NULL
protected static final net.sf.jkniv.asserts.Assertable NOT_NULL
-
ATTRIBUTE_NAME
public static final String ATTRIBUTE_NAME
- See Also:
- Constant Field Values
-
ATTRIBUTE_TYPE
public static final String ATTRIBUTE_TYPE
- See Also:
- Constant Field Values
-
ATTRIBUTE_ISOLATION
public static final String ATTRIBUTE_ISOLATION
- See Also:
- Constant Field Values
-
ATTRIBUTE_TIMEOUT
public static final String ATTRIBUTE_TIMEOUT
- See Also:
- Constant Field Values
-
ATTRIBUTE_HINT
public static final String ATTRIBUTE_HINT
- See Also:
- Constant Field Values
-
ATTRIBUTE_BATCH
public static final String ATTRIBUTE_BATCH
- See Also:
- Constant Field Values
-
ATTRIBUTE_CACHE
public static final String ATTRIBUTE_CACHE
- See Also:
- Constant Field Values
-
ATTRIBUTE_RETURN_TYPE
public static final String ATTRIBUTE_RETURN_TYPE
- See Also:
- Constant Field Values
-
ATTRIBUTE_GROUP_BY
public static final String ATTRIBUTE_GROUP_BY
- See Also:
- Constant Field Values
-
ATTRIBUTE_RESULTSET_TYPE
public static final String ATTRIBUTE_RESULTSET_TYPE
- See Also:
- Constant Field Values
-
ATTRIBUTE_RESULTSET_CONCURRENCY
public static final String ATTRIBUTE_RESULTSET_CONCURRENCY
- See Also:
- Constant Field Values
-
ATTRIBUTE_RESULTSET_HOLDABILITY
public static final String ATTRIBUTE_RESULTSET_HOLDABILITY
- See Also:
- Constant Field Values
-
ATTRIBUTE_VALIDATION
public static final String ATTRIBUTE_VALIDATION
- See Also:
- Constant Field Values
-
id
protected String id
-
languageType
protected LanguageType languageType
-
-
Constructor Detail
-
AbstractSqlTag
public AbstractSqlTag(String id, LanguageType languageType)
Build a new SQL tag from XML file.- Parameters:
id- Name/Identify from tag.languageType- type of language from tag.
-
AbstractSqlTag
public AbstractSqlTag(String id, LanguageType languageType, SqlDialect sqlDialect)
-
AbstractSqlTag
public AbstractSqlTag(String id, LanguageType languageType, Isolation isolation, int timeout, ValidateType validateType, Statistical stats)
Build a new SQL tag from XML file.- Parameters:
id- Name/Identify from tag.languageType- type of language from tag.isolation- Retrieves the current transaction isolation level for the query.timeout- Retrieves the number of seconds the repository will wait for a Query object to execute.validateType- validation to apply before execute SQL.stats- SQL statistical
-
AbstractSqlTag
public AbstractSqlTag(String id, LanguageType languageType, Isolation isolation, int timeout, ResultSetType resultSetType, ResultSetConcurrency resultSetConcurrency, ResultSetHoldability resultSetHoldability, String returnType, ValidateType validateType, Statistical stats)
Build a new SQL tag from XML file.- Parameters:
id- Name/Identify from tag.languageType- type of language from tag.isolation- Retrieves the current transaction isolation level for the query.timeout- Retrieves the number of seconds the repository will wait for a Query object to execute.resultSetType- TODO javadocresultSetConcurrency- TODO javadocresultSetHoldability- TODO javadocreturnType- vvalidateType- TODO javadocstats- statistical for procedures
-
-
Method Detail
-
getSql
public String getSql()
Retrieve static sql from a node, the dynamic parts is skipped.
-
getSql
public String getSql(Object params)
Retrieve dynamic sql from a node, the dynamic parts is evaluated at time to create the sql.
-
getLanguageType
public LanguageType getLanguageType()
language from SQL sentence.- Specified by:
getLanguageTypein interfaceSql- Returns:
- the type of language used to SQL sentence.
-
getName
public String getName()
Retrieve the identifier name from tag.
-
addTag
public void addTag(ITextTag tag)
add a new text tag.
-
addTag
public void addTag(String text)
add a set of static text from tag elements.
-
getIsolation
public Isolation getIsolation()
Description copied from interface:SqlRetrieves the current transaction isolation level for the query.- Specified by:
getIsolationin interfaceSql- Returns:
- the current transaction isolation level.
-
setIsolation
public void setIsolation(Isolation isolation)
-
getTimeout
public int getTimeout()
Description copied from interface:SqlRetrieves the number of seconds the repository will wait for a Query object to execute. If the limit is exceeded, a RepositoryException is thrown.- Specified by:
getTimeoutin interfaceSql- Returns:
- the current query timeout limit in seconds; zero means there is no limit
-
setTimeout
public void setTimeout(int timeout)
-
isSelectable
public boolean isSelectable()
Description copied from interface:SqlVerify if command is a SELECT- Specified by:
isSelectablein interfaceSql- Returns:
truewhen is SELECT,falseotherwise
-
isInsertable
public boolean isInsertable()
Description copied from interface:SqlVerify if command is a INSERT- Specified by:
isInsertablein interfaceSql- Returns:
truewhen is INSERT,falseotherwise
-
isUpdateable
public boolean isUpdateable()
Description copied from interface:SqlVerify if command is a UPDATE- Specified by:
isUpdateablein interfaceSql- Returns:
truewhen is UPDATE,falseotherwise
-
isDeletable
public boolean isDeletable()
Description copied from interface:SqlVerify if command is a DELETE- Specified by:
isDeletablein interfaceSql- Returns:
truewhen is DELETE,falseotherwise
-
asSelectable
public Selectable asSelectable()
Description copied from interface:SqlSelectableinstance- Specified by:
asSelectablein interfaceSql- Returns:
- this instance
-
asInsertable
public Insertable asInsertable()
Description copied from interface:SqlInsertableinstance- Specified by:
asInsertablein interfaceSql- Returns:
- this instance
-
asUpdateable
public Updateable asUpdateable()
Description copied from interface:SqlUpdateableinstance- Specified by:
asUpdateablein interfaceSql- Returns:
- this instance
-
asDeletable
public Deletable asDeletable()
Description copied from interface:SqlDeletableinstance- Specified by:
asDeletablein interfaceSql- Returns:
- this instance
-
isStorable
public boolean isStorable()
Description copied from interface:SqlVerify if command is a STORED PROCEDURE- Specified by:
isStorablein interfaceSql- Returns:
truewhen is STORED PROCEDURE,falseotherwise
-
asStorable
public Storable asStorable()
Description copied from interface:SqlStorableinstance- Specified by:
asStorablein interfaceSql- Returns:
- this instance
-
getResultSetType
public ResultSetType getResultSetType()
- Specified by:
getResultSetTypein interfaceSql
-
setResultSetType
public void setResultSetType(ResultSetType resultSetType)
-
getResultSetConcurrency
public ResultSetConcurrency getResultSetConcurrency()
- Specified by:
getResultSetConcurrencyin interfaceSql
-
setResultSetConcurrency
public void setResultSetConcurrency(ResultSetConcurrency resultSetConcurrency)
-
getResultSetHoldability
public ResultSetHoldability getResultSetHoldability()
- Specified by:
getResultSetHoldabilityin interfaceSql
-
setResultSetHoldability
public void setResultSetHoldability(ResultSetHoldability resultSetHoldability)
-
setResultType
public void setResultType(String returnType)
-
getReturnType
public String getReturnType()
- Specified by:
getReturnTypein interfaceSql
-
hasReturnType
public boolean hasReturnType()
- Specified by:
hasReturnTypein interfaceSql
-
getReturnTypeAsClass
public Class<?> getReturnTypeAsClass()
- Specified by:
getReturnTypeAsClassin interfaceSql
-
setValidateType
public void setValidateType(ValidateType validateType)
- Specified by:
setValidateTypein interfaceSql
-
getValidateType
public ValidateType getValidateType()
- Specified by:
getValidateTypein interfaceSql
-
setXpath
public void setXpath(String xpath)
Description copied from interface:SqlTagset the XPATH expression to retrieve the query at xml file.
-
getXPath
public String getXPath()
Description copied from interface:SqlExpression XPATH to read SQL
-
setResourceName
public void setResourceName(String resourceName)
Description copied from interface:SqlTagFile name from Sql- Specified by:
setResourceNamein interfaceSqlTag- Parameters:
resourceName- filename from sql as resource
-
getResourceName
public String getResourceName()
Description copied from interface:SqlThe filename that SQL belong to- Specified by:
getResourceNamein interfaceSql- Returns:
- return the filename, relative to absolute classpath, where the SQL was read.
-
getTimestamp
public Date getTimestamp()
Description copied from interface:SqlTimestamp when sql was read from xml- Specified by:
getTimestampin interfaceSql- Returns:
- when SQL was read from XML file
-
getParamParser
public ParamParser getParamParser()
Description copied from interface:Sqlstrategy to parser the parameters from SQL.- Specified by:
getParamParserin interfaceSql- Returns:
- return the implementation of parser (colon, hash or question mark)
-
extractNames
public String[] extractNames(Object params)
Description copied from interface:SqlExtract the name parameters from dynamic query- Specified by:
extractNamesin interfaceSql- Parameters:
params- parameters from query- Returns:
- array of parameters names from query, array based-zero length when haven't param. Array of questions marks (?) is returned when the isn't name based.
-
extractNames
public String[] extractNames(String sql)
Description copied from interface:SqlExtract the name parameters from SQL- Specified by:
extractNamesin interfaceSql- Parameters:
sql- sentence- Returns:
- array of parameters names from query, array based-zero length when haven't param. Array of questions marks (?) is returned when the isn't name based.
-
bind
public void bind(SqlDialect sqlDialect)
-
getSqlDialect
public SqlDialect getSqlDialect()
Description copied from interface:Sqldialect for a specific database- Specified by:
getSqlDialectin interfaceSql- Returns:
- the dialect
-
getPackage
public String getPackage()
Description copied from interface:Sqlname of package that this SQL belongs- Specified by:
getPackagein interfaceSql- Returns:
- name of package
-
setPackage
public void setPackage(String name)
Description copied from interface:SqlTagname of package this sql belong- Specified by:
setPackagein interfaceSqlTag- Parameters:
name- of package
-
getStats
public Statistical getStats()
Description copied from interface:Sqlget statistical data from query execution
-
setStats
protected void setStats(Statistical stats)
-
-