+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.annotation;\r
-\r
-import java.lang.annotation.ElementType;\r
-import java.lang.annotation.Inherited;\r
-import java.lang.annotation.Retention;\r
-import java.lang.annotation.RetentionPolicy;\r
-import java.lang.annotation.Target;\r
-\r
-@Inherited\r
-@Retention(RetentionPolicy.RUNTIME)\r
-@Target(ElementType.METHOD)\r
-public @interface OutsideSql {\r
- boolean dynamicBinding() default false;\r
- boolean offsetByCursor() default false;\r
- boolean limitByCursor() default false;\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.bhv.batch;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.helper.token.file.FileMakingOption;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class TokenFileOutputOption {\r
-\r
- // =====================================================================================\r
- // Attribute\r
- // =========\r
- protected FileMakingOption _fileMakingOption = new FileMakingOption();\r
-\r
- // =====================================================================================\r
- // Easy-to-Use\r
- // ===========\r
- public TokenFileOutputOption delimitateByComma() {\r
- _fileMakingOption.delimitateByComma();\r
- return this;\r
- }\r
-\r
- public TokenFileOutputOption delimitateByTab() {\r
- _fileMakingOption.delimitateByTab();\r
- return this;\r
- }\r
-\r
- public TokenFileOutputOption encodeAsUTF8() {\r
- _fileMakingOption.encodeAsUTF8();\r
- return this;\r
- }\r
-\r
- public TokenFileOutputOption encodeAsWindows31J() {\r
- _fileMakingOption.encodeAsWindows31J();\r
- return this;\r
- }\r
-\r
- public TokenFileOutputOption separateCrLf() {\r
- _fileMakingOption.separateCrLf();\r
- return this;\r
- }\r
-\r
- public TokenFileOutputOption separateLf() {\r
- _fileMakingOption.separateLf();\r
- return this;\r
- }\r
-\r
- public TokenFileOutputOption goodByeDoubleQuotation() {\r
- _fileMakingOption.goodByeDoubleQuotation();\r
- return this;\r
- }\r
-\r
- // =====================================================================================\r
- // Accessor\r
- // ========\r
- public String getEncoding() {\r
- return _fileMakingOption.getEncoding();\r
- }\r
-\r
- public void setEncoding(String encoding) {\r
- _fileMakingOption.setDelimiter(encoding);\r
- }\r
-\r
- public String getDelimiter() {\r
- return _fileMakingOption.getDelimiter();\r
- }\r
-\r
- public void setDelimiter(String delimiter) {\r
- _fileMakingOption.setDelimiter(delimiter);\r
- }\r
-\r
- public String getLineSeparator() {\r
- return _fileMakingOption.getLineSeparator();\r
- }\r
-\r
- public void setLineSeparator(String lineSeparator) {\r
- _fileMakingOption.setLineSeparator(lineSeparator);\r
- }\r
-\r
- public boolean isGoodByeDoubleQuotation() {\r
- return _fileMakingOption.isGoodByeDoubleQuotation();\r
- }\r
-\r
- public FileMakingOption getFileMakingOption() {\r
- return _fileMakingOption;\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.bhv.batch;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.Entity;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class TokenFileOutputResult {\r
-\r
- // =====================================================================================\r
- // Attribute\r
- // =========\r
- protected java.util.List<Entity> _selectedList;\r
-\r
- // =====================================================================================\r
- // Accessor\r
- // ========\r
- public java.util.List<Entity> getSelectedList() {\r
- return _selectedList;\r
- }\r
-\r
- public void setSelectedList(java.util.List<Entity> selectedList) {\r
- _selectedList = selectedList;\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.bhv.batch;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.Entity;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class TokenFileReflectionFailure {\r
-\r
- // =====================================================================================\r
- // Attribute\r
- // =========\r
- protected java.util.List<String> _columnNameList;\r
- protected java.util.List<String> _valueList;\r
-\r
- protected String rowString;\r
-\r
- /** The row number. */\r
- protected int _rowNumber;\r
-\r
- /** The line number. */\r
- protected int _lineNumber;\r
-\r
- protected Entity _entity;\r
- protected Exception _exception;\r
-\r
- // =====================================================================================\r
- // Accessor\r
- // ========\r
- public java.util.List<String> getColumnNameList() {\r
- return _columnNameList;\r
- }\r
-\r
- public void setColumnNameList(java.util.List<String> columnNameList) {\r
- this._columnNameList = columnNameList;\r
- }\r
-\r
- public java.util.List<String> getValueList() {\r
- return _valueList;\r
- }\r
-\r
- public void setValueList(java.util.List<String> valueList) {\r
- this._valueList = valueList;\r
- }\r
-\r
- public String getRowString() {\r
- return rowString;\r
- }\r
-\r
- public void setRowString(String rowString) {\r
- this.rowString = rowString;\r
- }\r
-\r
- public int getRowNumber() {\r
- return _rowNumber;\r
- }\r
-\r
- public void setRowNumber(int rowNumber) {\r
- _rowNumber = rowNumber;\r
- }\r
-\r
- public int getLineNumber() {\r
- return _lineNumber;\r
- }\r
-\r
- public void setLineNumber(int lineNumber) {\r
- _lineNumber = lineNumber;\r
- }\r
-\r
- public Entity getEntity() {\r
- return _entity;\r
- }\r
-\r
- public void setEntity(Entity value) {\r
- _entity = value;\r
- }\r
-\r
- public Exception getException() {\r
- return _exception;\r
- }\r
-\r
- public void setException(Exception value) {\r
- _exception = value;\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.bhv.batch;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.helper.token.file.FileTokenizingOption;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class TokenFileReflectionOption {\r
-\r
- // =====================================================================================\r
- // Attribute\r
- // =========\r
- protected boolean _interruptIfError;\r
-\r
- protected FileTokenizingOption _fileTokenizingOption = new FileTokenizingOption();\r
-\r
- // =====================================================================================\r
- // Easy-to-Use\r
- // ===========\r
- public TokenFileReflectionOption delimitateByComma() {\r
- _fileTokenizingOption.delimitateByComma();\r
- return this;\r
- }\r
-\r
- public TokenFileReflectionOption delimitateByTab() {\r
- _fileTokenizingOption.delimitateByTab();\r
- return this;\r
- }\r
-\r
- public TokenFileReflectionOption encodeAsUTF8() {\r
- _fileTokenizingOption.encodeAsUTF8();\r
- return this;\r
- }\r
-\r
- public TokenFileReflectionOption encodeAsWindows31J() {\r
- _fileTokenizingOption.encodeAsWindows31J();\r
- return this;\r
- }\r
-\r
- public TokenFileReflectionOption handleEmptyAsNull() {\r
- _fileTokenizingOption.handleEmptyAsNull();\r
- return this;\r
- }\r
-\r
- public TokenFileReflectionOption interruptIfError() {\r
- _interruptIfError = true;\r
- return this;\r
- }\r
-\r
- // =====================================================================================\r
- // Accessor\r
- // ========\r
- public String getDelimiter() {\r
- return _fileTokenizingOption.getDelimiter();\r
- }\r
-\r
- public void setDelimiter(String delimiter) {\r
- _fileTokenizingOption.setDelimiter(delimiter);\r
- }\r
-\r
- public String getEncoding() {\r
- return _fileTokenizingOption.getEncoding();\r
- }\r
-\r
- public void setEncoding(String encoding) {\r
- _fileTokenizingOption.setDelimiter(encoding);\r
- }\r
-\r
- public boolean isHandleEmptyAsNull() {\r
- return _fileTokenizingOption.isHandleEmptyAsNull();\r
- }\r
-\r
- public boolean isInterruptIfError() {\r
- return _interruptIfError;\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.bhv.batch;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class TokenFileReflectionResult {\r
-\r
- // =====================================================================================\r
- // Attribute\r
- // =========\r
- protected java.util.List<String> _columnNameList;\r
- protected int _successCount;\r
- protected java.util.List<TokenFileReflectionFailure> _failureList;\r
-\r
- // =====================================================================================\r
- // Easy-to-Use\r
- // ===========\r
- public void incrementSuccessCount() {\r
- ++_successCount;\r
- }\r
-\r
- // =====================================================================================\r
- // Accessor\r
- // ========\r
- public java.util.List<String> getColumnNameList() {\r
- return _columnNameList;\r
- }\r
-\r
- public void setColumnNameList(java.util.List<String> columnNameList) {\r
- this._columnNameList = columnNameList;\r
- }\r
-\r
- public int getSuccessCount() {\r
- return _successCount;\r
- }\r
-\r
- public void setSuccessCount(int successCount) {\r
- _successCount = successCount;\r
- }\r
-\r
- public java.util.List<TokenFileReflectionFailure> getFailureList() {\r
- return _failureList;\r
- }\r
-\r
- public void setFailureList(java.util.List<TokenFileReflectionFailure> failureList) {\r
- this._failureList = failureList;\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.bhv.load;\r
-\r
-import java.util.List;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.Entity;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.bhv.setup.ConditionBeanSetupper;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.bhv.setup.EntityListSetupper;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.ConditionBean;\r
-\r
-/**\r
- * The class of load referrer option.\r
- * @param <REFERRER_CONDITION_BEAN> The type of referrer condition-bean.\r
- * @param <REFERRER_ENTITY> The type of referrer entity.\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class LoadReferrerOption<REFERRER_CONDITION_BEAN extends ConditionBean, REFERRER_ENTITY extends Entity> {\r
-\r
- // ===================================================================================\r
- // Attribute\r
- // =========\r
- protected ConditionBeanSetupper<REFERRER_CONDITION_BEAN> _conditionBeanSetupper;\r
-\r
- protected EntityListSetupper<REFERRER_ENTITY> _entityListSetupper;\r
-\r
- protected REFERRER_CONDITION_BEAN _referrerConditionBean;\r
-\r
- protected boolean _toLastKeyCondition;\r
-\r
- protected boolean _stopOrderByKey;\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- public LoadReferrerOption() {\r
- }\r
-\r
- public LoadReferrerOption(ConditionBeanSetupper<REFERRER_CONDITION_BEAN> conditionBeanSetupper) {\r
- this._conditionBeanSetupper = conditionBeanSetupper;\r
- }\r
-\r
- public LoadReferrerOption(ConditionBeanSetupper<REFERRER_CONDITION_BEAN> conditionBeanSetupper, EntityListSetupper<REFERRER_ENTITY> entityListSetupper) {\r
- this._conditionBeanSetupper = conditionBeanSetupper;\r
- this._entityListSetupper = entityListSetupper;\r
- }\r
-\r
- public LoadReferrerOption(LoadReferrerOption<REFERRER_CONDITION_BEAN, REFERRER_ENTITY> option) {\r
- this._conditionBeanSetupper = option._conditionBeanSetupper;\r
- this._entityListSetupper = option._entityListSetupper;\r
- this._referrerConditionBean = option._referrerConditionBean;\r
- this._toLastKeyCondition = option._toLastKeyCondition;\r
- this._stopOrderByKey = option._stopOrderByKey;\r
- }\r
-\r
- // ===================================================================================\r
- // Easy-to-Use\r
- // ===========\r
- /**\r
- * Specify that the key condition is added as last condition. <br />\r
- * This method is valid only after you use reffererConditionBean and add your original condition to it.\r
- * @return this. (NotNull)\r
- */\r
- public LoadReferrerOption<REFERRER_CONDITION_BEAN, REFERRER_ENTITY> toLastKeyCondition() {\r
- _toLastKeyCondition = true;\r
- return this;\r
- }\r
-\r
- /**\r
- * Specify that it stops adding order-by of the key. <br />\r
- * This method is valid only after you use reffererConditionBean and add your original order-by to it.\r
- * @return this. (NotNull)\r
- */\r
- public LoadReferrerOption<REFERRER_CONDITION_BEAN, REFERRER_ENTITY> stopOrderByKey() {\r
- _stopOrderByKey = true;\r
- return this;\r
- }\r
-\r
- public void delegateKeyConditionExchangingFirstWhereClauseForLastOne(REFERRER_CONDITION_BEAN cb) {// Internal\r
- if (!_toLastKeyCondition) {\r
- cb.getSqlClause().exchangeFirstWhereClauseForLastOne();\r
- }\r
- }\r
-\r
- public void delegateConditionBeanSettingUp(REFERRER_CONDITION_BEAN cb) {// Internal\r
- if (_conditionBeanSetupper != null) {\r
- _conditionBeanSetupper.setup(cb);\r
- }\r
- }\r
-\r
- public void delegateEntitySettingUp(List<REFERRER_ENTITY> entityList) {// Internal\r
- if (_entityListSetupper != null) {\r
- _entityListSetupper.setup(entityList);\r
- }\r
- }\r
-\r
- // ===================================================================================\r
- // Accessor\r
- // ========\r
- public ConditionBeanSetupper<REFERRER_CONDITION_BEAN> getConditionBeanSetupper() {\r
- return _conditionBeanSetupper;\r
- }\r
-\r
- public void setConditionBeanSetupper(ConditionBeanSetupper<REFERRER_CONDITION_BEAN> conditionBeanSetupper) {\r
- this._conditionBeanSetupper = conditionBeanSetupper;\r
- }\r
-\r
- public EntityListSetupper<REFERRER_ENTITY> getEntityListSetupper() {\r
- return _entityListSetupper;\r
- }\r
-\r
- public void setEntityListSetupper(EntityListSetupper<REFERRER_ENTITY> entityListSetupper) {\r
- this._entityListSetupper = entityListSetupper;\r
- }\r
-\r
- public REFERRER_CONDITION_BEAN getReferrerConditionBean() {\r
- return _referrerConditionBean;\r
- }\r
-\r
- public void setReferrerConditionBean(REFERRER_CONDITION_BEAN referrerConditionBean) {\r
- this._referrerConditionBean = referrerConditionBean;\r
- }\r
-\r
- public boolean isToLastKeyCondition() {\r
- return _toLastKeyCondition;\r
- }\r
-\r
- public boolean isStopOrderByKey() {\r
- return _stopOrderByKey;\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.bhv.setup;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.ConditionBean;\r
-\r
-/**\r
- * The interface of condition-bean setupper.\r
- * @param <CONDITION_BEAN> The type of condition-bean.\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public interface ConditionBeanSetupper<CONDITION_BEAN extends ConditionBean> {\r
-\r
- /**\r
- * Set up condition.\r
- * @param cb Condition-bean. (NotNull)\r
- */\r
- public void setup(CONDITION_BEAN cb);\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.bhv.setup;\r
-\r
-import java.util.List;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.Entity;\r
-\r
-/**\r
- * The interface of entity list setupper.\r
- * @param <ENTITY> The type of entity.\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public interface EntityListSetupper<ENTITY extends Entity> {\r
-\r
- /**\r
- * Set up the list of entity.\r
- * @param entityList The list of entity. (NotNull)\r
- */\r
- public void setup(List<ENTITY> entityList);\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.bhv.setup;\r
-\r
-/**\r
- * The class of Value-Label Box.\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class ValueLabelBox {\r
-\r
- protected Object _value;\r
-\r
- protected String _label;\r
-\r
- public void setValueLabel(Object value, String label) {\r
- this._value = value;\r
- this._label = label;\r
- }\r
-\r
- public Object getValue() {\r
- return _value;\r
- }\r
-\r
- public String getLabel() {\r
- return _label;\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.bhv.setup;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.Entity;\r
-\r
-/**\r
- * The interface of Value-Label Setupper.\r
- * @param <ENTITY> The type of entity.\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public interface ValueLabelSetupper<ENTITY extends Entity> {\r
-\r
- /**\r
- * Set up value-label.\r
- * @param box Value-label box. (NotNull)\r
- * @param entity Entity. (NotNull)\r
- */\r
- public void setup(ValueLabelBox box, ENTITY entity);\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.cbean.ckey;\r
-\r
-import java.util.List;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.coption.ConditionOption;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.cvalue.ConditionValue;\r
-\r
-/**\r
- * The abstract class of condition-key.\r
- * \r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public abstract class ConditionKey {\r
-\r
- /** Mark of replaced value. */\r
- public static final String MARK_OF_REPLACED_VALUE = "ReplacedValue";\r
-\r
- /** The condition key of equal. */\r
- public static final ConditionKey CK_EQUAL = new ConditionKeyEqual();\r
-\r
- /** The condition key of notEqual. */\r
- public static final ConditionKey CK_NOT_EQUAL = new ConditionKeyNotEqual();\r
-\r
- /** The condition key of greaterThan. */\r
- public static final ConditionKey CK_GREATER_THAN = new ConditionKeyGreaterThan();\r
-\r
- /** The condition key of lessrThan. */\r
- public static final ConditionKey CK_LESS_THAN = new ConditionKeyLessThan();\r
-\r
- /** The condition key of greaterEqual. */\r
- public static final ConditionKey CK_GREATER_EQUAL = new ConditionKeyGreaterEqual();\r
-\r
- /** The condition key of lessEqual. */\r
- public static final ConditionKey CK_LESS_EQUAL = new ConditionKeyLessEqual();\r
-\r
- /** The condition key of prefixSearch. */\r
- public static final ConditionKey CK_PREFIX_SEARCH = new ConditionKeyPrefixSearch();\r
-\r
- /** The condition key of likeSearch. */\r
- public static final ConditionKey CK_LIKE_SEARCH = new ConditionKeyLikeSearch();\r
-\r
- /** The condition key of inScope. */\r
- public static final ConditionKey CK_IN_SCOPE = new ConditionKeyInScope();\r
-\r
- /** The condition key of notInScope. */\r
- public static final ConditionKey CK_NOT_IN_SCOPE = new ConditionKeyNotInScope();\r
-\r
- /** The condition key of isNull. */\r
- public static final ConditionKey CK_IS_NULL = new ConditionKeyIsNull();\r
-\r
- /** The condition key of isNotNull. */\r
- public static final ConditionKey CK_IS_NOT_NULL = new ConditionKeyIsNotNull();\r
-\r
- /** Dummy-object for IsNull and IsNotNull and so on... */\r
- protected static final Object DUMMY_OBJECT = new Object();\r
-\r
- /** Condition-key. */\r
- protected String _conditionKey;\r
-\r
- /** Operand. */\r
- protected String _operand;\r
-\r
- /**\r
- * Get condition-key.\r
- * @return Condition-key.\r
- */\r
- public String getConditionKey() {\r
- return _conditionKey;\r
- }\r
-\r
- /**\r
- * Get operand.\r
- * @return Operand.\r
- */\r
- public String getOperand() {\r
- return _operand;\r
- }\r
-\r
- /**\r
- * Is valid registration?\r
- * @param conditionValue Condition value. (NotNull)\r
- * @param value Value. (NotNull)\r
- * @param callerName Caller name. (NotNull)\r
- * @return Determination.\r
- */\r
- abstract public boolean isValidRegistration(ConditionValue conditionValue, Object value, String callerName);\r
-\r
- /**\r
- * Add where clause.\r
- * @param conditionList Condition list. (NotNull)\r
- * @param columnName Column name. (NotNull)\r
- * @param value Condition value. (NotNull)\r
- * @return this.\r
- */\r
- public ConditionKey addWhereClause(java.util.List<String> conditionList, String columnName, ConditionValue value) {\r
- if (value == null) {\r
- String msg = "Argument[value] must not be null:";\r
- throw new IllegalArgumentException(msg + " value=" + value + " this.toString()=" + toString());\r
- }\r
- doAddWhereClause(conditionList, columnName, value);\r
- return this;\r
- }\r
-\r
- /**\r
- * Add where clause.\r
- * @param conditionList Condition list. (NotNull)\r
- * @param columnName Column name. (NotNull)\r
- * @param value Condition value. (NotNull)\r
- * @param option Condition option. (NotNull)\r
- * @return this.\r
- */\r
- public ConditionKey addWhereClause(java.util.List<String> conditionList, String columnName, ConditionValue value, ConditionOption option) {\r
- if (value == null) {\r
- String msg = "Argument[value] must not be null:";\r
- throw new IllegalArgumentException(msg + " value=" + value + " this.toString()=" + toString());\r
- }\r
- doAddWhereClause(conditionList, columnName, value, option);\r
- return this;\r
- }\r
-\r
- /**\r
- * Do add where clause.\r
- * @param conditionList Condition list. (NotNull)\r
- * @param columnName Column name. (NotNull)\r
- * @param value Condition value. (NotNull)\r
- */\r
- abstract protected void doAddWhereClause(List<String> conditionList, String columnName, ConditionValue value);\r
-\r
- /**\r
- * Do add where clause.\r
- * @param conditionList Condition list. (NotNull)\r
- * @param columnName Column name. (NotNull)\r
- * @param value Condition value. (NotNull)\r
- * @param option Condition option. (NotNull)\r
- */\r
- abstract protected void doAddWhereClause(List<String> conditionList, String columnName, ConditionValue value, ConditionOption option);\r
-\r
- /**\r
- * Setup condition value.\r
- * @param conditionValue Condition value. (NotNull)\r
- * @param value Value. (Nullable)\r
- * @param location Location. (Nullable)\r
- * @return Condition value. (The same as argument[conditionValue]) (NotNull)\r
- */\r
- public ConditionValue setupConditionValue(ConditionValue conditionValue, Object value, String location) {\r
- if (conditionValue == null) {\r
- String msg = "Argument[conditionValue] must not be null:";\r
- throw new IllegalArgumentException(msg + " value=" + value + " this.toString()=" + toString());\r
- }\r
- doSetupConditionValue(conditionValue, value, location);\r
- return conditionValue;\r
- }\r
-\r
- /**\r
- * Setup condition value.\r
- * @param conditionValue Condition value. (NotNull)\r
- * @param value Value. (Nullable)\r
- * @param location Location. (Nullable)\r
- * @param option Condition option. (NotNull)\r
- * @return Condition value. (The same as argument[conditionValue]) (NotNull)\r
- */\r
- public ConditionValue setupConditionValue(ConditionValue conditionValue, Object value, String location, ConditionOption option) {\r
- if (conditionValue == null) {\r
- String msg = "Argument[conditionValue] must not be null:";\r
- throw new IllegalArgumentException(msg + " value=" + value + " this.toString()=" + toString());\r
- }\r
- doSetupConditionValue(conditionValue, value, location, option);\r
- return conditionValue;\r
- }\r
-\r
- /**\r
- * Do setup condition value.\r
- * @param conditionValue Condition value. (NotNull)\r
- * @param value Value. (NotNull)\r
- * @param location Location. (NotNull)\r
- */\r
- abstract protected void doSetupConditionValue(ConditionValue conditionValue, Object value, String location);\r
-\r
- /**\r
- * Do setup condition value.\r
- * @param conditionValue Condition value. (NotNull)\r
- * @param value Value. (NotNull)\r
- * @param location Location. (NotNull)\r
- * @param option Condition option. (NotNull)\r
- */\r
- abstract protected void doSetupConditionValue(ConditionValue conditionValue, Object value, String location, ConditionOption option);\r
-\r
- /**\r
- * Build bind clause. (for s2dao)\r
- * @param columnName Column name. (NotNull)\r
- * @param location Location. (NotNull)\r
- * @return Bind clause. (NotNull)\r
- */\r
- protected String buildBindClause(String columnName, String location) {\r
- return columnName + " " + getOperand() + " " + "/*dto." + location + "*/null";\r
- }\r
-\r
- /**\r
- * Build bind clause. (for s2dao)\r
- * @param columnName Column name. (NotNull)\r
- * @param location Location. (NotNull)\r
- * @param rearOption Rear option. (NotNull)\r
- * @return Bind clause. (NotNull)\r
- */\r
- protected String buildBindClauseWithRearOption(String columnName, String location, String rearOption) {\r
- return columnName + " " + getOperand() + " " + "/*dto." + location + "*/null" + rearOption;\r
- }\r
-\r
- /**\r
- * Build bind clause. (for s2dao)\r
- * @param columnName Column name. (NotNull)\r
- * @param location Location. (NotNull)\r
- * @param dummyValue Dummy value. (NotNull)\r
- * @return Bind clause. (NotNull)\r
- */\r
- protected String buildBindClause(String columnName, String location, String dummyValue) {\r
- return columnName + " " + getOperand() + " " + "/*dto." + location + "*/" + dummyValue;\r
- }\r
-\r
- /**\r
- * Build clause without value.\r
- * @param columnName Column name. (NotNull)\r
- * @return Clause without value. (NotNull)\r
- */\r
- protected String buildClauseWithoutValue(String columnName) {\r
- return columnName + " " + getOperand();\r
- }\r
-\r
- /**\r
- * Get wild-card.\r
- * @return Wild-card.\r
- */\r
- protected String getWildCard() {\r
- return "%";\r
- }\r
-\r
- /**\r
- * The override.\r
- * Returns hash-code of this condition-key string.\r
- * \r
- * @return HashCode.\r
- */\r
- public int hashCode() {\r
- return getConditionKey().hashCode();\r
- }\r
-\r
- /**\r
- * The override.\r
- * If the condition-key of the other is same as this one, returns true.\r
- * \r
- * @param other Other entity. (Nullable)\r
- * @return Comparing result. If other is null, returns false.\r
- */\r
- public boolean equals(Object other) {\r
- if (other instanceof ConditionKey) {\r
- if (this.getConditionKey().equals(((ConditionKey)other).getConditionKey())) {\r
- return true;\r
- }\r
- }\r
- return false;\r
- }\r
-\r
- /**\r
- * The override.\r
- * \r
- * @return View-string of condition key information.\r
- */\r
- public String toString() {\r
- return "ConditionKey: " + getConditionKey() + " " + getOperand() + " wild-card=[" + getWildCard() + "]";\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.cbean.ckey;\r
-\r
-\r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.coption.ConditionOption;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.cvalue.ConditionValue;\r
-\r
-/**\r
- * The condition-key of equal.\r
- * \r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class ConditionKeyEqual extends ConditionKey {\r
-\r
- /** Log-instance. */\r
- private static final Log _log = LogFactory.getLog(ConditionKeyEqual.class);\r
-\r
- /**\r
- * Constructor.\r
- */\r
- protected ConditionKeyEqual() {\r
- _conditionKey = "equal";\r
- _operand = "=";\r
- }\r
-\r
- /**\r
- * Is valid registration?\r
- * \r
- * @param conditionValue Condition value. (NotNull)\r
- * @param value Value. (NotNull)\r
- * @param callerName Caller name. (NotNull)\r
- * @return Determination.\r
- */\r
- public boolean isValidRegistration(ConditionValue conditionValue, Object value, String callerName) {\r
- if (value == null) {\r
- return false;\r
- }\r
- if (conditionValue.hasEqual()) {\r
- if (conditionValue.equalEqual(value)) {\r
- _log.debug("The value has already registered at " + callerName + ": value=" + value);\r
- return false;\r
- } else {\r
- conditionValue.overrideEqual(value);\r
- return false;\r
- }\r
- }\r
- return true;\r
- }\r
-\r
- /**\r
- * This method implements super#doAddWhereClause().\r
- * \r
- * @param conditionList Condition list. (NotNull)\r
- * @param columnName Column name. (NotNull)\r
- * @param value Condition value. (NotNull)\r
- */\r
- protected void doAddWhereClause(java.util.List<String> conditionList, String columnName, ConditionValue value) {\r
- if (value.getEqual() == null) {\r
- return;\r
- }\r
- conditionList.add(buildBindClause(columnName, value.getEqualLocation()));\r
- }\r
-\r
- /**\r
- * This method implements super#doAddWhereClause().\r
- * \r
- * @param conditionList Condition list. (NotNull)\r
- * @param columnName Column name. (NotNull)\r
- * @param value Condition value. (NotNull)\r
- * @param option Condition option. (NotNull)\r
- */\r
- protected void doAddWhereClause(java.util.List<String> conditionList, String columnName, ConditionValue value, ConditionOption option) {\r
- throw new UnsupportedOperationException("doAddWhereClause with condition-option is unsupported!!!");\r
- }\r
-\r
- /**\r
- * This method implements super#doSetupConditionValue().\r
- * \r
- * @param conditionValue Condition value. (NotNull)\r
- * @param value Value. (NotNull)\r
- * @param location Location. (NotNull)\r
- */\r
- protected void doSetupConditionValue(ConditionValue conditionValue, Object value, String location) {\r
- conditionValue.setEqual(value).setEqualLocation(location);\r
- }\r
-\r
- /**\r
- * This method implements super#doSetupConditionValue().\r
- * \r
- * @param conditionValue Condition value. (NotNull)\r
- * @param value Value. (NotNull)\r
- * @param location Location. (NotNull)\r
- * @param option Condition option. (NotNull)\r
- */\r
- protected void doSetupConditionValue(ConditionValue conditionValue, Object value, String location, ConditionOption option) {\r
- throw new UnsupportedOperationException("doSetupConditionValue with condition-option is unsupported!!!");\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.cbean.ckey;\r
-\r
-\r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.coption.ConditionOption;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.cvalue.ConditionValue;\r
-\r
-/**\r
- * The condition-key of greaterEqual.\r
- * \r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class ConditionKeyGreaterEqual extends ConditionKey {\r
-\r
- /** Log-instance. */\r
- private static final Log _log = LogFactory.getLog(ConditionKeyGreaterEqual.class);\r
-\r
- /**\r
- * Constructor.\r
- */\r
- protected ConditionKeyGreaterEqual() {\r
- _conditionKey = "greaterEqual";\r
- _operand = ">=";\r
- }\r
-\r
- /**\r
- * Is valid registration?\r
- * \r
- * @param conditionValue Condition value. (NotNull)\r
- * @param value Value. (NotNull)\r
- * @param callerName Caller name. (NotNull)\r
- * @return Determination.\r
- */\r
- public boolean isValidRegistration(ConditionValue conditionValue, Object value, String callerName) {\r
- if (value == null) {\r
- return false;\r
- }\r
- if (conditionValue.hasGreaterEqual()) {\r
- if (conditionValue.equalGreaterEqual(value)) {\r
- _log.debug("The value has already registered at " + callerName + ": value=" + value);\r
- return false;\r
- } else {\r
- conditionValue.overrideGreaterEqual(value);\r
- return false;\r
- }\r
- }\r
- return true;\r
- }\r
-\r
- /**\r
- * This method implements super#doAddWhereClause().\r
- * \r
- * @param conditionList Condition list. (NotNull)\r
- * @param columnName Column name. (NotNull)\r
- * @param value Condition value. (NotNull)\r
- */\r
- protected void doAddWhereClause(java.util.List<String> conditionList, String columnName, ConditionValue value) {\r
- if (value.getGreaterEqual() == null) {\r
- return;\r
- }\r
- conditionList.add(buildBindClause(columnName, value.getGreaterEqualLocation()));\r
- }\r
-\r
- /**\r
- * This method implements super#doAddWhereClause().\r
- * \r
- * @param conditionList Condition list. (NotNull)\r
- * @param columnName Column name. (NotNull)\r
- * @param value Condition value. (NotNull)\r
- * @param option Condition option. (NotNull)\r
- */\r
- protected void doAddWhereClause(java.util.List<String> conditionList, String columnName, ConditionValue value, ConditionOption option) {\r
- throw new UnsupportedOperationException("doAddWhereClause that has ConditionOption is unsupported!!!");\r
- }\r
-\r
- /**\r
- * This method implements super#doSetupConditionValue().\r
- * \r
- * @param conditionValue Condition value. (NotNull)\r
- * @param value Value. (NotNull)\r
- * @param location Location. (NotNull)\r
- */\r
- protected void doSetupConditionValue(ConditionValue conditionValue, Object value, String location) {\r
- conditionValue.setGreaterEqual(value).setGreaterEqualLocation(location);\r
- }\r
-\r
- /**\r
- * This method implements super#doSetupConditionValue().\r
- * \r
- * @param conditionValue Condition value. (NotNull)\r
- * @param value Value. (NotNull)\r
- * @param location Location. (NotNull)\r
- * @param option Condition option. (NotNull)\r
- */\r
- protected void doSetupConditionValue(ConditionValue conditionValue, Object value, String location, ConditionOption option) {\r
- throw new UnsupportedOperationException("doSetupConditionValue with condition-option is unsupported!!!");\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.cbean.ckey;\r
-\r
-\r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.coption.ConditionOption;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.cvalue.ConditionValue;\r
-\r
-/**\r
- * The condition-key of greaterThan.\r
- * \r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class ConditionKeyGreaterThan extends ConditionKey {\r
-\r
- /** Log-instance. */\r
- private static final Log _log = LogFactory.getLog(ConditionKeyGreaterThan.class);\r
-\r
- /**\r
- * Constructor.\r
- */\r
- protected ConditionKeyGreaterThan() {\r
- _conditionKey = "greaterThan";\r
- _operand = ">";\r
- }\r
-\r
- /**\r
- * Is valid registration?\r
- * \r
- * @param conditionValue Condition value. (NotNull)\r
- * @param value Value. (NotNull)\r
- * @param callerName Caller name. (NotNull)\r
- * @return Determination.\r
- */\r
- public boolean isValidRegistration(ConditionValue conditionValue, Object value, String callerName) {\r
- if (value == null) {\r
- return false;\r
- }\r
- if (conditionValue.hasGreaterThan()) {\r
- if (conditionValue.equalGreaterThan(value)) {\r
- _log.debug("The value has already registered at " + callerName + ": value=" + value);\r
- return false;\r
- } else {\r
- conditionValue.overrideGreaterThan(value);\r
- return false;\r
- }\r
- }\r
- return true;\r
- }\r
-\r
- /**\r
- * This method implements super#doAddWhereClause().\r
- * \r
- * @param conditionList Condition list. (NotNull)\r
- * @param columnName Column name. (NotNull)\r
- * @param value Condition value. (NotNull)\r
- */\r
- protected void doAddWhereClause(java.util.List<String> conditionList, String columnName, ConditionValue value) {\r
- if (value.getGreaterThan() == null) {\r
- return;\r
- }\r
- conditionList.add(buildBindClause(columnName, value.getGreaterThanLocation()));\r
- }\r
-\r
- /**\r
- * This method implements super#doAddWhereClause().\r
- * \r
- * @param conditionList Condition list. (NotNull)\r
- * @param columnName Column name. (NotNull)\r
- * @param value Condition value. (NotNull)\r
- * @param option Condition option. (NotNull)\r
- */\r
- protected void doAddWhereClause(java.util.List<String> conditionList, String columnName, ConditionValue value, ConditionOption option) {\r
- throw new UnsupportedOperationException("doAddWhereClause that has ConditionOption is unsupported!!!");\r
- }\r
-\r
- /**\r
- * This method implements super#doSetupConditionValue().\r
- * \r
- * @param conditionValue Condition value. (NotNull)\r
- * @param value Value. (NotNull)\r
- * @param location Location. (NotNull)\r
- */\r
- protected void doSetupConditionValue(ConditionValue conditionValue, Object value, String location) {\r
- conditionValue.setGreaterThan(value).setGreaterThanLocation(location);\r
- }\r
-\r
- /**\r
- * This method implements super#doSetupConditionValue().\r
- * \r
- * @param conditionValue Condition value. (NotNull)\r
- * @param value Value. (NotNull)\r
- * @param location Location. (NotNull)\r
- * @param option Condition option. (NotNull)\r
- */\r
- protected void doSetupConditionValue(ConditionValue conditionValue, Object value, String location, ConditionOption option) {\r
- throw new UnsupportedOperationException("doSetupConditionValue with condition-option is unsupported!!!");\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.cbean.ckey;\r
-\r
-\r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.coption.ConditionOption;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.coption.InScopeOption;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.cvalue.ConditionValue;\r
-\r
-/**\r
- * The condition-key of inScope.\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class ConditionKeyInScope extends ConditionKey {\r
-\r
- /** Log-instance. */\r
- private static final Log _log = LogFactory.getLog(ConditionKeyInScope.class);\r
-\r
- /**\r
- * Constructor.\r
- */\r
- protected ConditionKeyInScope() {\r
- _conditionKey = "inScope";\r
- _operand = "in";\r
- }\r
-\r
- /**\r
- * Is valid registration?\r
- * @param conditionValue Condition value. (NotNull)\r
- * @param value Value. (NotNull)\r
- * @param callerName Caller name. (NotNull)\r
- * @return Determination.\r
- */\r
- public boolean isValidRegistration(ConditionValue conditionValue, Object value, String callerName) {\r
- if (value == null) {\r
- return false;\r
- }\r
- if (value instanceof java.util.List && ((java.util.List<?>)value).isEmpty()) {\r
- return false;\r
- }\r
- if (value instanceof java.util.List) {\r
- if (conditionValue.hasInScope()) {\r
- if (conditionValue.equalInScope(((java.util.List<?>)value))) {\r
- _log.debug("The value has already registered at " + callerName + ": value=" + value);\r
- return false;\r
- } else {\r
- conditionValue.overrideInScope(((java.util.List<?>)value));\r
- return false;\r
- }\r
- }\r
- }\r
- return true;\r
- }\r
-\r
- /**\r
- * This method implements super#doAddWhereClause().\r
- * @param conditionList Condition list. (NotNull)\r
- * @param columnName Column name. (NotNull)\r
- * @param value Condition value. (NotNull)\r
- */\r
- protected void doAddWhereClause(java.util.List<String> conditionList, String columnName, ConditionValue value) {\r
- if (value.getInScope() == null) {\r
- return;\r
- }\r
- conditionList.add(buildBindClause(columnName, value.getInScopeLocation(), "('a1', 'a2')"));\r
- }\r
-\r
- /**\r
- * This method implements super#doAddWhereClause().\r
- * @param conditionList Condition list. (NotNull)\r
- * @param columnName Column name. (NotNull)\r
- * @param value Condition value. (NotNull)\r
- * @param option Condition option. (NotNull)\r
- */\r
- protected void doAddWhereClause(java.util.List<String> conditionList, String columnName, ConditionValue value, ConditionOption option) {\r
- if (option == null) {\r
- String msg = "The argument[option] should not be null: columnName=" + columnName + " value=" + value;\r
- throw new IllegalArgumentException(msg);\r
- }\r
- if (!(option instanceof InScopeOption)) {\r
- String msg = "The argument[option] should be InScopeOption: columnName=" + columnName + " value=" + value;\r
- throw new IllegalArgumentException(msg);\r
- }\r
- conditionList.add(buildBindClause(columnName, value.getInScopeLocation(), "('a1', 'a2')"));\r
- }\r
-\r
- /**\r
- * This method implements super#doSetupConditionValue().\r
- * @param conditionValue Condition value. (NotNull)\r
- * @param value Value. (NotNull)\r
- * @param location Location. (NotNull)\r
- */\r
- protected void doSetupConditionValue(ConditionValue conditionValue, Object value, String location) {\r
- conditionValue.setInScope((java.util.List<?>)value).setInScopeLocation(location);\r
- }\r
-\r
- /**\r
- * This method implements super#doSetupConditionValue().\r
- * @param conditionValue Condition value. (NotNull)\r
- * @param value Value. (NotNull)\r
- * @param location Location. (NotNull)\r
- * @param option Condition option. (NotNull)\r
- */\r
- protected void doSetupConditionValue(ConditionValue conditionValue, Object value, String location, ConditionOption option) {\r
- conditionValue.setInScope((java.util.List<?>)value, (InScopeOption)option).setInScopeLocation(location);\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.cbean.ckey;\r
-\r
-\r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.coption.ConditionOption;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.cvalue.ConditionValue;\r
-\r
-/**\r
- * The condition-key of isNotNull.\r
- * \r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class ConditionKeyIsNotNull extends ConditionKey {\r
-\r
- /** Log-instance. */\r
- private static final Log _log = LogFactory.getLog(ConditionKeyIsNotNull.class);\r
-\r
- /**\r
- * Constructor.\r
- */\r
- protected ConditionKeyIsNotNull() {\r
- _conditionKey = "isNotNull";\r
- _operand = "is not null";\r
- }\r
-\r
- /**\r
- * Is valid registration?\r
- * \r
- * @param conditionValue Condition value. (NotNull)\r
- * @param value Value. (NotNull)\r
- * @param callerName Caller name. (NotNull)\r
- * @return Determination.\r
- */\r
- public boolean isValidRegistration(ConditionValue conditionValue, Object value, String callerName) {\r
- if (conditionValue.hasIsNotNull()) {\r
- _log.debug("The value has already registered at " + callerName);\r
- return false;\r
- }\r
- return true;\r
- }\r
-\r
- /**\r
- * This method implements super#doAddWhereClause().\r
- * \r
- * @param conditionList Condition list. (NotNull)\r
- * @param columnName Column name. (NotNull)\r
- * @param value Condition value. (NotNull)\r
- */\r
- protected void doAddWhereClause(java.util.List<String> conditionList, String columnName, ConditionValue value) {\r
- if (value.getIsNotNull() == null) {\r
- return;\r
- }\r
- conditionList.add(buildClauseWithoutValue(columnName));\r
- }\r
-\r
- /**\r
- * This method implements super#doAddWhereClause().\r
- * \r
- * @param conditionList Condition list. (NotNull)\r
- * @param columnName Column name. (NotNull)\r
- * @param value Condition value. (NotNull)\r
- * @param option Condition option. (NotNull)\r
- */\r
- protected void doAddWhereClause(java.util.List<String> conditionList, String columnName, ConditionValue value, ConditionOption option) {\r
- throw new UnsupportedOperationException("doAddWhereClause that has ConditionOption is unsupported!!!");\r
- }\r
-\r
- /**\r
- * This method implements super#doSetupConditionValue().\r
- * \r
- * @param conditionValue Condition value. (NotNull)\r
- * @param value Value. (NotNull)\r
- * @param location Location. (NotNull)\r
- */\r
- protected void doSetupConditionValue(ConditionValue conditionValue, Object value, String location) {\r
- conditionValue.setIsNotNull(DUMMY_OBJECT).setIsNotNullLocation(location);\r
- }\r
-\r
- /**\r
- * This method implements super#doSetupConditionValue().\r
- * \r
- * @param conditionValue Condition value. (NotNull)\r
- * @param value Value. (NotNull)\r
- * @param location Location. (NotNull)\r
- * @param option Condition option. (NotNull)\r
- */\r
- protected void doSetupConditionValue(ConditionValue conditionValue, Object value, String location, ConditionOption option) {\r
- throw new UnsupportedOperationException("doSetupConditionValue with condition-option is unsupported!!!");\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.cbean.ckey;\r
-\r
-\r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.coption.ConditionOption;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.cvalue.ConditionValue;\r
-\r
-/**\r
- * The condition-key of isNull.\r
- * \r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class ConditionKeyIsNull extends ConditionKey {\r
-\r
- /** Log-instance. */\r
- private static final Log _log = LogFactory.getLog(ConditionKeyIsNull.class);\r
-\r
- /**\r
- * Constructor.\r
- */\r
- protected ConditionKeyIsNull() {\r
- _conditionKey = "isNull";\r
- _operand = "is null";\r
- }\r
-\r
- /**\r
- * Is valid registration?\r
- * \r
- * @param conditionValue Condition value. (NotNull)\r
- * @param value Value. (NotNull)\r
- * @param callerName Caller name. (NotNull)\r
- * @return Determination.\r
- */\r
- public boolean isValidRegistration(ConditionValue conditionValue, Object value, String callerName) {\r
- if (conditionValue.hasIsNull()) {\r
- _log.debug("The value has already registered at " + callerName);\r
- return false;\r
- }\r
- return true;\r
- }\r
-\r
- /**\r
- * This method implements super#doAddWhereClause().\r
- * \r
- * @param conditionList Condition list. (NotNull)\r
- * @param columnName Column name. (NotNull)\r
- * @param value Condition value. (NotNull)\r
- */\r
- protected void doAddWhereClause(java.util.List<String> conditionList, String columnName, ConditionValue value) {\r
- if (value.getIsNull() == null) {\r
- return;\r
- }\r
- conditionList.add(buildClauseWithoutValue(columnName));\r
- }\r
-\r
- /**\r
- * This method implements super#doAddWhereClause().\r
- * \r
- * @param conditionList Condition list. (NotNull)\r
- * @param columnName Column name. (NotNull)\r
- * @param value Condition value. (NotNull)\r
- * @param option Condition option. (NotNull)\r
- */\r
- protected void doAddWhereClause(java.util.List<String> conditionList, String columnName, ConditionValue value, ConditionOption option) {\r
- throw new UnsupportedOperationException("doAddWhereClause that has ConditionOption is unsupported!!!");\r
- }\r
-\r
- /**\r
- * This method implements super#doSetupConditionValue().\r
- * \r
- * @param conditionValue Condition value. (NotNull)\r
- * @param value Value. (NotNull)\r
- * @param location Location. (NotNull)\r
- */\r
- protected void doSetupConditionValue(ConditionValue conditionValue, Object value, String location) {\r
- conditionValue.setIsNull(DUMMY_OBJECT).setIsNullLocation(location);\r
- }\r
-\r
- /**\r
- * This method implements super#doSetupConditionValue().\r
- * \r
- * @param conditionValue Condition value. (NotNull)\r
- * @param value Value. (NotNull)\r
- * @param location Location. (NotNull)\r
- * @param option Condition option. (NotNull)\r
- */\r
- protected void doSetupConditionValue(ConditionValue conditionValue, Object value, String location, ConditionOption option) {\r
- throw new UnsupportedOperationException("doSetupConditionValue with condition-option is unsupported!!!");\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.cbean.ckey;\r
-\r
-\r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.coption.ConditionOption;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.cvalue.ConditionValue;\r
-\r
-/**\r
- * The condition-key of lessEqual.\r
- * \r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class ConditionKeyLessEqual extends ConditionKey {\r
-\r
- /** Log-instance. */\r
- private static final Log _log = LogFactory.getLog(ConditionKeyLessEqual.class);\r
-\r
- /**\r
- * Constructor.\r
- */\r
- protected ConditionKeyLessEqual() {\r
- _conditionKey = "lessEqual";\r
- _operand = "<=";\r
- }\r
-\r
- /**\r
- * Is valid registration?\r
- * \r
- * @param conditionValue Condition value. (NotNull)\r
- * @param value Value. (NotNull)\r
- * @param callerName Caller name. (NotNull)\r
- * @return Determination.\r
- */\r
- public boolean isValidRegistration(ConditionValue conditionValue, Object value, String callerName) {\r
- if (value == null) {\r
- return false;\r
- }\r
- if (conditionValue.hasLessEqual()) {\r
- if (conditionValue.equalLessEqual(value)) {\r
- _log.debug("The value has already registered at " + callerName + ": value=" + value);\r
- return false;\r
- } else {\r
- conditionValue.overrideLessEqual(value);\r
- return false;\r
- }\r
- }\r
- return true;\r
- }\r
-\r
- /**\r
- * This method implements super#doAddWhereClause().\r
- * \r
- * @param conditionList Condition list. (NotNull)\r
- * @param columnName Column name. (NotNull)\r
- * @param value Condition value. (NotNull)\r
- */\r
- protected void doAddWhereClause(java.util.List<String> conditionList, String columnName, ConditionValue value) {\r
- if (value.getLessEqual() == null) {\r
- return;\r
- }\r
- conditionList.add(buildBindClause(columnName, value.getLessEqualLocation()));\r
- }\r
-\r
- /**\r
- * This method implements super#doAddWhereClause().\r
- * \r
- * @param conditionList Condition list. (NotNull)\r
- * @param columnName Column name. (NotNull)\r
- * @param value Condition value. (NotNull)\r
- * @param option Condition option. (NotNull)\r
- */\r
- protected void doAddWhereClause(java.util.List<String> conditionList, String columnName, ConditionValue value, ConditionOption option) {\r
- throw new UnsupportedOperationException("doAddWhereClause that has ConditionOption is unsupported!!!");\r
- }\r
-\r
- /**\r
- * This method implements super#doSetupConditionValue().\r
- * \r
- * @param conditionValue Condition value. (NotNull)\r
- * @param value Value. (NotNull)\r
- * @param location Location. (NotNull)\r
- */\r
- protected void doSetupConditionValue(ConditionValue conditionValue, Object value, String location) {\r
- conditionValue.setLessEqual(value).setLessEqualLocation(location);\r
- }\r
-\r
- /**\r
- * This method implements super#doSetupConditionValue().\r
- * \r
- * @param conditionValue Condition value. (NotNull)\r
- * @param value Value. (NotNull)\r
- * @param location Location. (NotNull)\r
- * @param option Condition option. (NotNull)\r
- */\r
- protected void doSetupConditionValue(ConditionValue conditionValue, Object value, String location, ConditionOption option) {\r
- throw new UnsupportedOperationException("doSetupConditionValue with condition-option is unsupported!!!");\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.cbean.ckey;\r
-\r
-\r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.coption.ConditionOption;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.cvalue.ConditionValue;\r
-\r
-/**\r
- * The condition-key of lessThan.\r
- * \r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class ConditionKeyLessThan extends ConditionKey {\r
-\r
- /** Log-instance. */\r
- private static final Log _log = LogFactory.getLog(ConditionKeyLessThan.class);\r
-\r
- /**\r
- * Constructor.\r
- */\r
- protected ConditionKeyLessThan() {\r
- _conditionKey = "lessThan";\r
- _operand = "<";\r
- }\r
-\r
- /**\r
- * Is valid registration?\r
- * \r
- * @param conditionValue Condition value. (NotNull)\r
- * @param value Value. (NotNull)\r
- * @param callerName Caller name. (NotNull)\r
- * @return Determination.\r
- */\r
- public boolean isValidRegistration(ConditionValue conditionValue, Object value, String callerName) {\r
- if (value == null) {\r
- return false;\r
- }\r
- if (conditionValue.hasLessThan()) {\r
- if (conditionValue.equalLessThan(value)) {\r
- _log.debug("The value has already registered at " + callerName + ": value=" + value);\r
- return false;\r
- } else {\r
- conditionValue.overrideLessThan(value);\r
- return false;\r
- }\r
- }\r
- return true;\r
- }\r
-\r
- /**\r
- * This method implements super#doAddWhereClause().\r
- * \r
- * @param conditionList Condition list. (NotNull)\r
- * @param columnName Column name. (NotNull)\r
- * @param value Condition value. (NotNull)\r
- */\r
- protected void doAddWhereClause(java.util.List<String> conditionList, String columnName, ConditionValue value) {\r
- if (value.getLessThan() == null) {\r
- return;\r
- }\r
- conditionList.add(buildBindClause(columnName, value.getLessThanLocation()));\r
- }\r
-\r
- /**\r
- * This method implements super#doAddWhereClause().\r
- * \r
- * @param conditionList Condition list. (NotNull)\r
- * @param columnName Column name. (NotNull)\r
- * @param value Condition value. (NotNull)\r
- * @param option Condition option. (NotNull)\r
- */\r
- protected void doAddWhereClause(java.util.List<String> conditionList, String columnName, ConditionValue value, ConditionOption option) {\r
- throw new UnsupportedOperationException("doAddWhereClause that has ConditionOption is unsupported!!!");\r
- }\r
-\r
- /**\r
- * This method implements super#doSetupConditionValue().\r
- * \r
- * @param conditionValue Condition value. (NotNull)\r
- * @param value Value. (NotNull)\r
- * @param location Location. (NotNull)\r
- */\r
- protected void doSetupConditionValue(ConditionValue conditionValue, Object value, String location) {\r
- conditionValue.setLessThan(value).setLessThanLocation(location);\r
- }\r
-\r
- /**\r
- * This method implements super#doSetupConditionValue().\r
- * \r
- * @param conditionValue Condition value. (NotNull)\r
- * @param value Value. (NotNull)\r
- * @param location Location. (NotNull)\r
- * @param option Condition option. (NotNull)\r
- */\r
- protected void doSetupConditionValue(ConditionValue conditionValue, Object value, String location, ConditionOption option) {\r
- throw new UnsupportedOperationException("doSetupConditionValue with condition-option is unsupported!!!");\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.cbean.ckey;\r
-\r
-import java.util.List;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.coption.ConditionOption;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.coption.LikeSearchOption;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.cvalue.ConditionValue;\r
-\r
-/**\r
- * The condition-key of likeSearch.\r
- * \r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class ConditionKeyLikeSearch extends ConditionKey {\r
-\r
- /**\r
- * Constructor.\r
- */\r
- protected ConditionKeyLikeSearch() {\r
- _conditionKey = "likeSearch";\r
- _operand = "like";\r
- }\r
-\r
- /**\r
- * Is valid registration?\r
- * @param conditionValue Condition value. (NotNull)\r
- * @param value Value. (NotNull)\r
- * @param callerName Caller name. (NotNull)\r
- * @return Determination.\r
- */\r
- public boolean isValidRegistration(ConditionValue conditionValue, Object value, String callerName) {\r
- if (value == null) {\r
- return false;\r
- }\r
- return true;\r
- }\r
-\r
- /**\r
- * This method implements super#doAddWhereClause().\r
- * @param conditionList Condition list. (NotNull)\r
- * @param columnName Column name. (NotNull)\r
- * @param value Condition value. (NotNull)\r
- */\r
- protected void doAddWhereClause(List<String> conditionList, String columnName, ConditionValue value) {\r
- throw new UnsupportedOperationException("doAddWhereClause without condition-option is unsupported!!!");\r
- }\r
-\r
- /**\r
- * This method implements super#doAddWhereClause().\r
- * @param conditionList Condition list. (NotNull)\r
- * @param columnName Column name. (NotNull)\r
- * @param value Condition value. (NotNull)\r
- * @param option Condition option. (NotNull)\r
- */\r
- protected void doAddWhereClause(List<String> conditionList, String columnName, ConditionValue value, ConditionOption option) {\r
- if (option == null) {\r
- String msg = "The argument[option] should not be null: columnName=" + columnName + " value=" + value;\r
- throw new IllegalArgumentException(msg);\r
- }\r
- if (!(option instanceof LikeSearchOption)) {\r
- String msg = "The argument[option] should be LikeSearchOption: columnName=" + columnName + " value=" + value;\r
- throw new IllegalArgumentException(msg);\r
- }\r
- final LikeSearchOption myOption = (LikeSearchOption)option;\r
- conditionList.add(buildBindClauseWithRearOption(columnName, value.getLikeSearchLocation(), myOption.getRearOption()));\r
- }\r
-\r
- /**\r
- * This method implements super#doSetupConditionValue().\r
- * @param conditionValue Condition value. (NotNull)\r
- * @param value Value. (NotNull)\r
- * @param location Location. (NotNull)\r
- */\r
- protected void doSetupConditionValue(ConditionValue conditionValue, Object value, String location) {\r
- throw new UnsupportedOperationException("doSetupConditionValue without condition-option is unsupported!!!");\r
- }\r
-\r
- /**\r
- * This method implements super#doSetupConditionValue().\r
- * @param conditionValue Condition value. (NotNull)\r
- * @param value Value. (NotNull)\r
- * @param location Location. (NotNull)\r
- * @param option Condition option. (NotNull)\r
- */\r
- protected void doSetupConditionValue(ConditionValue conditionValue, Object value, String location, ConditionOption option) {\r
- conditionValue.setLikeSearch((String)value, (LikeSearchOption)option).setLikeSearchLocation(location);\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.cbean.ckey;\r
-\r
-\r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.coption.ConditionOption;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.cvalue.ConditionValue;\r
-\r
-/**\r
- * The condition-key of notEqual.\r
- * \r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class ConditionKeyNotEqual extends ConditionKey {\r
-\r
- /** Log-instance. */\r
- private static final Log _log = LogFactory.getLog(ConditionKeyNotEqual.class);\r
-\r
- /**\r
- * Constructor.\r
- */\r
- protected ConditionKeyNotEqual() {\r
- _conditionKey = "notEqual";\r
- _operand = "!=";\r
- }\r
-\r
- /**\r
- * Is valid registration?\r
- * \r
- * @param conditionValue Condition value. (NotNull)\r
- * @param value Value. (NotNull)\r
- * @param callerName Caller name. (NotNull)\r
- * @return Determination.\r
- */\r
- public boolean isValidRegistration(ConditionValue conditionValue, Object value, String callerName) {\r
- if (value == null) {\r
- return false;\r
- }\r
- if (conditionValue.hasNotEqual()) {\r
- if (conditionValue.equalNotEqual(value)) {\r
- _log.debug("The value has already registered at " + callerName + ": value=" + value);\r
- return false;\r
- } else {\r
- conditionValue.overrideNotEqual(value);\r
- return false;\r
- }\r
- }\r
- return true;\r
- }\r
-\r
- /**\r
- * This method implements super#doAddWhereClause().\r
- * \r
- * @param conditionList Condition list. (NotNull)\r
- * @param columnName Column name. (NotNull)\r
- * @param value Condition value. (NotNull)\r
- */\r
- protected void doAddWhereClause(java.util.List<String> conditionList, String columnName, ConditionValue value) {\r
- if (value.getNotEqual() == null) {\r
- return;\r
- }\r
- conditionList.add(buildBindClause(columnName, value.getNotEqualLocation()));\r
- }\r
-\r
- /**\r
- * This method implements super#doAddWhereClause().\r
- * \r
- * @param conditionList Condition list. (NotNull)\r
- * @param columnName Column name. (NotNull)\r
- * @param value Condition value. (NotNull)\r
- * @param option Condition option. (NotNull)\r
- */\r
- protected void doAddWhereClause(java.util.List<String> conditionList, String columnName, ConditionValue value, ConditionOption option) {\r
- throw new UnsupportedOperationException("doAddWhereClause with condition-option is unsupported!!!");\r
- }\r
-\r
- /**\r
- * This method implements super#doSetupConditionValue().\r
- * \r
- * @param conditionValue Condition value. (NotNull)\r
- * @param value Value. (NotNull)\r
- * @param location Location. (NotNull)\r
- */\r
- protected void doSetupConditionValue(ConditionValue conditionValue, Object value, String location) {\r
- conditionValue.setNotEqual(value).setNotEqualLocation(location);\r
- }\r
-\r
- /**\r
- * This method implements super#doSetupConditionValue().\r
- * \r
- * @param conditionValue Condition value. (NotNull)\r
- * @param value Value. (NotNull)\r
- * @param location Location. (NotNull)\r
- * @param option Condition option. (NotNull)\r
- */\r
- protected void doSetupConditionValue(ConditionValue conditionValue, Object value, String location, ConditionOption option) {\r
- throw new UnsupportedOperationException("doSetupConditionValue with condition-option is unsupported!!!");\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.cbean.ckey;\r
-\r
-\r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.coption.ConditionOption;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.cvalue.ConditionValue;\r
-\r
-/**\r
- * The condition-key of notInScope.\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class ConditionKeyNotInScope extends ConditionKey {\r
-\r
- /** Log-instance. */\r
- private static final Log _log = LogFactory.getLog(ConditionKeyNotInScope.class);\r
-\r
- /**\r
- * Constructor.\r
- */\r
- protected ConditionKeyNotInScope() {\r
- _conditionKey = "notInScope";\r
- _operand = "not in";\r
- }\r
-\r
- /**\r
- * Is valid registration?\r
- * @param conditionValue Condition value. (NotNull)\r
- * @param value Value. (NotNull)\r
- * @param callerName Caller name. (NotNull)\r
- * @return Determination.\r
- */\r
- public boolean isValidRegistration(ConditionValue conditionValue, Object value, String callerName) {\r
- if (value == null) {\r
- return false;\r
- }\r
- if (value instanceof java.util.List && ((java.util.List<?>)value).isEmpty()) {\r
- return false;\r
- }\r
- if (value instanceof java.util.List) {\r
- if (conditionValue.hasNotInScope()) {\r
- if (conditionValue.equalNotInScope(((java.util.List<?>)value))) {\r
- _log.debug("The value has already registered at " + callerName + ": value=" + value);\r
- return false;\r
- } else {\r
- conditionValue.overrideNotInScope(((java.util.List<?>)value));\r
- return false;\r
- }\r
- }\r
- }\r
- return true;\r
- }\r
-\r
- /**\r
- * This method implements super#doAddWhereClause().\r
- * \r
- * @param conditionList Condition list. (NotNull)\r
- * @param columnName Column name. (NotNull)\r
- * @param value Condition value. (NotNull)\r
- */\r
- protected void doAddWhereClause(java.util.List<String> conditionList, String columnName, ConditionValue value) {\r
- if (value.getNotInScope() == null) {\r
- return;\r
- }\r
- conditionList.add(buildBindClause(columnName, value.getNotInScopeLocation(), "('a1', 'a2')"));\r
- }\r
-\r
- /**\r
- * This method implements super#doAddWhereClause().\r
- * @param conditionList Condition list. (NotNull)\r
- * @param columnName Column name. (NotNull)\r
- * @param value Condition value. (NotNull)\r
- * @param option Condition option. (NotNull)\r
- */\r
- protected void doAddWhereClause(java.util.List<String> conditionList, String columnName, ConditionValue value, ConditionOption option) {\r
- throw new UnsupportedOperationException("doAddWhereClause that has ConditionOption is unsupported!!!");\r
- }\r
-\r
- /**\r
- * This method implements super#doSetupConditionValue().\r
- * @param conditionValue Condition value. (NotNull)\r
- * @param value Value. (NotNull)\r
- * @param location Location. (NotNull)\r
- */\r
- protected void doSetupConditionValue(ConditionValue conditionValue, Object value, String location) {\r
- conditionValue.setNotInScope((java.util.List<?>)value).setNotInScopeLocation(location);\r
- }\r
-\r
- /**\r
- * This method implements super#doSetupConditionValue().\r
- * @param conditionValue Condition value. (NotNull)\r
- * @param value Value. (NotNull)\r
- * @param location Location. (NotNull)\r
- * @param option Condition option. (NotNull)\r
- */\r
- protected void doSetupConditionValue(ConditionValue conditionValue, Object value, String location, ConditionOption option) {\r
- throw new UnsupportedOperationException("doSetupConditionValue with condition-option is unsupported!!!");\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.cbean.ckey;\r
-\r
-\r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.coption.ConditionOption;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.cvalue.ConditionValue;\r
-\r
-/**\r
- * The condition-key of prefixSearch.\r
- * \r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class ConditionKeyPrefixSearch extends ConditionKey {\r
-\r
- /** Log-instance. */\r
- private static final Log _log = LogFactory.getLog(ConditionKeyPrefixSearch.class);\r
-\r
- /**\r
- * Constructor.\r
- */\r
- protected ConditionKeyPrefixSearch() {\r
- _conditionKey = "prefixSearch";\r
- _operand = "like";\r
- }\r
-\r
- /**\r
- * Is valid registration?\r
- * @param conditionValue Condition value. (NotNull)\r
- * @param value Value. (NotNull)\r
- * @param callerName Caller name. (NotNull)\r
- * @return Determination.\r
- */\r
- public boolean isValidRegistration(ConditionValue conditionValue, Object value, String callerName) {\r
- if (value == null) {\r
- return false;\r
- }\r
- if (conditionValue.hasPrefixSearch()) {\r
- if (conditionValue.equalPrefixSearch(value + getWildCard())) {\r
- _log.debug("The value has already registered at " + callerName + ": value=" + value);\r
- return false;\r
- } else {\r
- conditionValue.overridePrefixSearch(value);\r
- return false;\r
- }\r
- }\r
- return true;\r
- }\r
-\r
- /**\r
- * This method implements super#doAddWhereClause().\r
- * @param conditionList Condition list. (NotNull)\r
- * @param columnName Column name. (NotNull)\r
- * @param value Condition value. (NotNull)\r
- */\r
- protected void doAddWhereClause(java.util.List<String> conditionList, String columnName, ConditionValue value) {\r
- if (value.getPrefixSearch() == null) {\r
- return;\r
- }\r
- conditionList.add(buildBindClause(columnName, value.getPrefixSearchLocation()));\r
- }\r
-\r
- /**\r
- * This method implements super#doAddWhereClause().\r
- * @param conditionList Condition list. (NotNull)\r
- * @param columnName Column name. (NotNull)\r
- * @param value Condition value. (NotNull)\r
- * @param option Condition option. (NotNull)\r
- */\r
- protected void doAddWhereClause(java.util.List<String> conditionList, String columnName, ConditionValue value, ConditionOption option) {\r
- throw new UnsupportedOperationException("doAddWhereClause that has ConditionOption is unsupported!!!");\r
- }\r
-\r
- /**\r
- * This method implements super#doSetupConditionValue().\r
- * @param conditionValue Condition value. (NotNull)\r
- * @param value Value. (NotNull)\r
- * @param location Location. (NotNull)\r
- */\r
- protected void doSetupConditionValue(ConditionValue conditionValue, Object value, String location) {\r
- conditionValue.setPrefixSearch((value != null ? value + getWildCard() : null)).setPrefixSearchLocation(location);\r
- }\r
-\r
- /**\r
- * This method implements super#doSetupConditionValue().\r
- * @param conditionValue Condition value. (NotNull)\r
- * @param value Value. (NotNull)\r
- * @param location Location. (NotNull)\r
- * @param option Condition option. (NotNull)\r
- */\r
- protected void doSetupConditionValue(ConditionValue conditionValue, Object value, String location, ConditionOption option) {\r
- throw new UnsupportedOperationException("doSetupConditionValue with condition-option is unsupported!!!");\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.cbean.coption.parts.local;\r
-\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.helper.character.JapaneseCharacter;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.helper.character.impl.JapaneseCharacterImpl;\r
-\r
-/**\r
- * The class of condition-option-parts-agent.\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class JapaneseOptionPartsAgent {\r
-\r
- // =====================================================================================\r
- // Attribute\r
- // =========\r
- protected boolean _toDoubleByteKatakana;\r
- protected boolean _removeLastLongVowel;\r
- private JapaneseCharacter _japaneseCharacter;\r
-\r
- // =====================================================================================\r
- // Main\r
- // ====\r
- public boolean isToDoubleByteKatakana() {\r
- return _toDoubleByteKatakana;\r
- }\r
-\r
- public void toDoubleByteKatakana() {\r
- _toDoubleByteKatakana = true;\r
- }\r
-\r
- public boolean isRemoveLastLongVowel() {\r
- return _removeLastLongVowel;\r
- }\r
- public void removeLastLongVowel() {\r
- _removeLastLongVowel = true;\r
- }\r
-\r
- // =====================================================================================\r
- // Real Value\r
- // ==========\r
- public String generateRealValue(String value) {\r
- if (value == null) {\r
- return value;\r
- }\r
-\r
- // To Double Byte\r
- if (_toDoubleByteKatakana) {\r
- value = getJapaneseCharacter().toDoubleByteKatakana(value);\r
- }\r
-\r
- // Remove\r
- if (_removeLastLongVowel) {\r
- if (value != null && value.endsWith("\u30fc")) {\r
- value = value.substring(0, value.length() - "\u30fc".length());\r
- }\r
- }\r
- return value;\r
- }\r
-\r
- // =====================================================================================\r
- // Helper\r
- // ======\r
- protected JapaneseCharacter getJapaneseCharacter() {\r
- if (_japaneseCharacter == null) {\r
- _japaneseCharacter = new JapaneseCharacterImpl();\r
- }\r
- return _japaneseCharacter;\r
- }\r
-\r
- // =====================================================================================\r
- // DeepCopy\r
- // ========\r
- public Object createDeepCopy() {\r
- final JapaneseOptionPartsAgent deepCopy = new JapaneseOptionPartsAgent();\r
- deepCopy._toDoubleByteKatakana = _toDoubleByteKatakana;\r
- deepCopy._removeLastLongVowel = _removeLastLongVowel;\r
- return deepCopy;\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.cbean.cvalue;\r
-\r
-\r
-import java.util.List;\r
-import java.util.ArrayList;\r
-import java.util.Iterator;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.coption.LikeSearchOption;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.coption.InScopeOption;\r
-\r
-/**\r
- * Condition value.\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class ConditionValue {\r
-\r
- // ===================================================================================\r
- // Equal\r
- // =====\r
- /** Value of equal. */\r
- protected Object _equalValue;\r
-\r
- /**\r
- * Get the value of equal.\r
- * @return The value of equal. (Nullable)\r
- */\r
- public Object getEqual() {\r
- return filterValue(_equalValue);\r
- }\r
-\r
- /**\r
- * Set the value of equal.\r
- * @param value The value of equal. (Nullable)\r
- * @return this. (NotNull)\r
- */\r
- public ConditionValue setEqual(Object value) {\r
- _equalValue = value;\r
- return this;\r
- }\r
-\r
- /**\r
- * Does it has the value of equal?\r
- * @return Determination. (NotNull)\r
- */\r
- public boolean hasEqual() {\r
- return _equalValue != null;\r
- }\r
-\r
- /**\r
- * Does the value equal the value of equal?\r
- * @param value The value of equal. (Nullable)\r
- * @return Determination. (NotNull)\r
- */\r
- public boolean equalEqual(Object value) {\r
- return hasEqual() ? _equalValue.equals(value) : value == null;\r
- }\r
-\r
- /**\r
- * Override the value of equal.\r
- * @param value The value of equal. (Nullable)\r
- * @return this. (NotNull)\r
- */\r
- public ConditionValue overrideEqual(Object value) {\r
- _equalValue = value;\r
- return this;\r
- }\r
-\r
- /** Location of equal. */\r
- protected String _equalLocation;\r
-\r
- /**\r
- * Get the location of equal.\r
- * @return The location of equal. (Nullable)\r
- */\r
- public String getEqualLocation() {\r
- return _equalLocation;\r
- }\r
-\r
- /**\r
- * Set the location of equal.\r
- * @param location The location of equal. (Nullable)\r
- * @return this. (NotNull)\r
- */\r
- public ConditionValue setEqualLocation(String location) {\r
- _equalLocation = location;\r
- return this;\r
- }\r
-\r
- // ===================================================================================\r
- // Not Equal\r
- // =========\r
- /** Value of notEqual. */\r
- protected Object _notEqualValue;\r
-\r
- /**\r
- * Get the value of notEqual.\r
- * @return The value of notEqual. (Nullable)\r
- */\r
- public Object getNotEqual() {\r
- return filterValue(_notEqualValue);\r
- }\r
-\r
- /**\r
- * Set the value of notEqual.\r
- * @param value The value of notEqual. (Nullable)\r
- * @return this. (NotNull)\r
- */\r
- public ConditionValue setNotEqual(Object value) {\r
- _notEqualValue = value;\r
- return this;\r
- }\r
-\r
- /**\r
- * Does it has the value of notEqual?\r
- * @return Determination. (NotNull)\r
- */\r
- public boolean hasNotEqual() {\r
- return _notEqualValue != null;\r
- }\r
-\r
- /**\r
- * Does the value equal the value of notEqual?\r
- * @param value The value of notEqual. (Nullable)\r
- * @return Determination. (NotNull)\r
- */\r
- public boolean equalNotEqual(Object value) {\r
- return hasNotEqual() ? _notEqualValue.equals(value) : value == null;\r
- }\r
-\r
- /**\r
- * Override the value of notEqual.\r
- * @param value The value of notEqual. (Nullable)\r
- * @return this. (NotNull)\r
- */\r
- public ConditionValue overrideNotEqual(Object value) {\r
- _notEqualValue = value;\r
- return this;\r
- }\r
-\r
- /** Location of notEqual. */\r
- protected String _notEqualLocation;\r
-\r
- /**\r
- * Get the location of notEqual.\r
- * @return The location of notEqual. (Nullable)\r
- */\r
- public String getNotEqualLocation() {\r
- return _notEqualLocation;\r
- }\r
-\r
- /**\r
- * Set the location of notEqual.\r
- * \r
- * @param location The location of notEqual. (Nullable)\r
- * @return this. (NotNull)\r
- */\r
- public ConditionValue setNotEqualLocation(String location) {\r
- _notEqualLocation = location;\r
- return this;\r
- }\r
-\r
- // ===================================================================================\r
- // Greater Than\r
- // ============\r
- /** Value of greaterThan. */\r
- protected Object _greaterThanValue;\r
-\r
- /**\r
- * Get the value of greaterThan.\r
- * @return The value of greaterThan. (Nullable)\r
- */\r
- public Object getGreaterThan() {\r
- return filterValue(_greaterThanValue);\r
- }\r
-\r
- /**\r
- * Set the value of greaterThan.\r
- * @param value The value of greaterThan. (Nullable)\r
- * @return this. (NotNull)\r
- */\r
- public ConditionValue setGreaterThan(Object value) {\r
- _greaterThanValue = value;\r
- return this;\r
- }\r
-\r
- /**\r
- * Does it has the value of greaterThan?\r
- * @return Determination. (NotNull)\r
- */\r
- public boolean hasGreaterThan() {\r
- return _greaterThanValue != null;\r
- }\r
-\r
- /**\r
- * Does the value equal the value of greaterThan?\r
- * @param value The value of greaterThan. (Nullable)\r
- * @return Determination. (NotNull)\r
- */\r
- public boolean equalGreaterThan(Object value) {\r
- return hasGreaterThan() ? _greaterThanValue.equals(value) : value == null;\r
- }\r
-\r
- /**\r
- * Override the value of greaterThan.\r
- * @param value The value of greaterThan. (Nullable)\r
- * @return this. (NotNull)\r
- */\r
- public ConditionValue overrideGreaterThan(Object value) {\r
- _greaterThanValue = value;\r
- return this;\r
- }\r
-\r
- /** Location of GreaterThan. */\r
- protected String _greaterThanLocation;\r
-\r
- /**\r
- * Get the location of greaterThan.\r
- * @return The location of greaterThan. (Nullable)\r
- */\r
- public String getGreaterThanLocation() {\r
- return _greaterThanLocation;\r
- }\r
-\r
- /**\r
- * Set the location of greaterThan.\r
- * @param location The location of greaterThan. (Nullable)\r
- * @return this. (NotNull)\r
- */\r
- public ConditionValue setGreaterThanLocation(String location) {\r
- _greaterThanLocation = location;\r
- return this;\r
- }\r
-\r
- // ===================================================================================\r
- // Less Than\r
- // =========\r
- /** Value of lessThan. */\r
- protected Object _lessThanValue;\r
-\r
- /**\r
- * Get the value of lessThan.\r
- * @return The value of lessThan. (Nullable)\r
- */\r
- public Object getLessThan() {\r
- return filterValue(_lessThanValue);\r
- }\r
-\r
- /**\r
- * Set the value of lessThan.\r
- * @param value The value of lessThan. (Nullable)\r
- * @return this. (NotNull)\r
- */\r
- public ConditionValue setLessThan(Object value) {\r
- _lessThanValue = value;\r
- return this;\r
- }\r
-\r
- /**\r
- * Does it has the value of lessThan?\r
- * @return Determination. (NotNull)\r
- */\r
- public boolean hasLessThan() {\r
- return _lessThanValue != null;\r
- }\r
-\r
- /**\r
- * Does the value equal the value of lessThan?\r
- * @param value The value of lessThan. (Nullable)\r
- * @return Determination. (NotNull)\r
- */\r
- public boolean equalLessThan(Object value) {\r
- return hasLessThan() ? _lessThanValue.equals(value) : value == null;\r
- }\r
-\r
- /**\r
- * Override the value of lessThan.\r
- * @param value The value of lessThan. (Nullable)\r
- * @return this. (NotNull)\r
- */\r
- public ConditionValue overrideLessThan(Object value) {\r
- _lessThanValue = value;\r
- return this;\r
- }\r
-\r
- /** Location of lessThan. */\r
- protected String _lessThanLocation;\r
-\r
- /**\r
- * Get the location of lessThan.\r
- * @return The location of lessThan. (Nullable)\r
- */\r
- public String getLessThanLocation() {\r
- return _lessThanLocation;\r
- }\r
-\r
- /**\r
- * Set the location of lessThan.\r
- * @param location The location of lessThan. (Nullable)\r
- * @return this. (NotNull)\r
- */\r
- public ConditionValue setLessThanLocation(String location) {\r
- _lessThanLocation = location;\r
- return this;\r
- }\r
-\r
- // ===================================================================================\r
- // Greater Equal\r
- // =============\r
- /** Value of greaterEqual. */\r
- protected Object _greaterEqualValue;\r
-\r
- /**\r
- * Get the value of greaterEqual.\r
- * @return The value of greaterEqual. (Nullable)\r
- */\r
- public Object getGreaterEqual() {\r
- return filterValue(_greaterEqualValue);\r
- }\r
-\r
- /**\r
- * Set the value of greaterEqual.\r
- * @param value The value of greaterEqual. (Nullable)\r
- * @return this. (NotNull)\r
- */\r
- public ConditionValue setGreaterEqual(Object value) {\r
- _greaterEqualValue = value;\r
- return this;\r
- }\r
-\r
- /**\r
- * Does it has the value of greaterEqual?\r
- * @return Determination. (NotNull)\r
- */\r
- public boolean hasGreaterEqual() {\r
- return _greaterEqualValue != null;\r
- }\r
-\r
- /**\r
- * Does the value equal the value of greaterEqual?\r
- * @param value The value of greaterEqual. (Nullable)\r
- * @return Determination. (NotNull)\r
- */\r
- public boolean equalGreaterEqual(Object value) {\r
- return hasGreaterEqual() ? _greaterEqualValue.equals(value) : value == null;\r
- }\r
-\r
- /**\r
- * Override the value of greaterEqual.\r
- * @param value The value of greaterEqual. (Nullable)\r
- * @return this. (NotNull)\r
- */\r
- public ConditionValue overrideGreaterEqual(Object value) {\r
- _greaterEqualValue = value;\r
- return this;\r
- }\r
-\r
- /** Location of greaterEqual. */\r
- protected String _greaterEqualLocation;\r
-\r
- /**\r
- * Get the location of greaterEqual.\r
- * @return The location of greaterEqual. (Nullable)\r
- */\r
- public String getGreaterEqualLocation() {\r
- return _greaterEqualLocation;\r
- }\r
-\r
- /**\r
- * Set the location of greaterEqual.\r
- * @param location The location of greaterEqual. (Nullable)\r
- * @return this. (NotNull)\r
- */\r
- public ConditionValue setGreaterEqualLocation(String location) {\r
- _greaterEqualLocation = location;\r
- return this;\r
- }\r
-\r
- // ===================================================================================\r
- // Less Equal\r
- // ==========\r
- /** Value of lessEqual. */\r
- protected Object _lessEqualValue;\r
-\r
- /**\r
- * Get the value of lessEqual.\r
- * @return The value of lessEqual. (Nullable)\r
- */\r
- public Object getLessEqual() {\r
- return filterValue(_lessEqualValue);\r
- }\r
-\r
- /**\r
- * Set the value of lessEqual.\r
- * @param value The value of lessEqual. (Nullable)\r
- * @return this. (NotNull)\r
- */\r
- public ConditionValue setLessEqual(Object value) {\r
- _lessEqualValue = value;\r
- return this;\r
- }\r
-\r
- /**\r
- * Does it has the value of lessEqual?\r
- * @return Determination. (NotNull)\r
- */\r
- public boolean hasLessEqual() {\r
- return _lessEqualValue != null;\r
- }\r
-\r
- /**\r
- * Does the value equal the value of lessEqual?\r
- * @param value The value of lessEqual. (Nullable)\r
- * @return Determination. (NotNull)\r
- */\r
- public boolean equalLessEqual(Object value) {\r
- return hasLessEqual() ? _lessEqualValue.equals(value) : value == null;\r
- }\r
-\r
- /**\r
- * Override the value of lessEqual.\r
- * @param value The value of lessEqual. (Nullable)\r
- * @return this. (NotNull)\r
- */\r
- public ConditionValue overrideLessEqual(Object value) {\r
- _lessEqualValue = value;\r
- return this;\r
- }\r
-\r
- /** Location of lessEqual. */\r
- protected String _lessEqualLocation;\r
-\r
- /**\r
- * Get the location of lessEqual.\r
- * @return The location of lessEqual. (Nullable)\r
- */\r
- public String getLessEqualLocation() {\r
- return _lessEqualLocation;\r
- }\r
-\r
- /**\r
- * Set the location of lessEqual.\r
- * @param location The location of lessEqual. (Nullable)\r
- * @return this. (NotNull)\r
- */\r
- public ConditionValue setLessEqualLocation(String location) {\r
- _lessEqualLocation = location;\r
- return this;\r
- }\r
-\r
- // ===================================================================================\r
- // Prefix Search\r
- // =============\r
- /** Value of prefixSearch. */\r
- protected Object _prefixSearch;\r
-\r
- /**\r
- * Get the value of prefixSearch.\r
- * @return The value of prefixSearch. (Nullable)\r
- */\r
- public Object getPrefixSearch() {\r
- return filterValue(_prefixSearch);\r
- }\r
-\r
- /**\r
- * Set the value of prefixSearch.\r
- * @param value The value of prefixSearch. (Nullable)\r
- * @return this. (NotNull)\r
- */\r
- public ConditionValue setPrefixSearch(Object value) {\r
- _prefixSearch = value;\r
- return this;\r
- }\r
-\r
- /**\r
- * Does it has the value of prefixSearch?\r
- * @return Determination. (NotNull)\r
- */\r
- public boolean hasPrefixSearch() {\r
- return _prefixSearch != null;\r
- }\r
-\r
- /**\r
- * Does the value equal the value of prefixSearch?\r
- * @param value The value of prefixSearch. (Nullable)\r
- * @return Determination. (NotNull)\r
- */\r
- public boolean equalPrefixSearch(Object value) {\r
- return hasPrefixSearch() ? _prefixSearch.equals(value) : value == null;\r
- }\r
-\r
- /**\r
- * Override the value of prefixSearch.\r
- * @param value The value of prefixSearch. (Nullable)\r
- * @return this. (NotNull)\r
- */\r
- public ConditionValue overridePrefixSearch(Object value) {\r
- _prefixSearch = value;\r
- return this;\r
- }\r
-\r
- /** Location of prefixSearch. */\r
- protected String _prefixSearchLocation;\r
-\r
- /**\r
- * Get the location of prefixSearch.\r
- * @return The location of prefixSearch. (Nullable)\r
- */\r
- public String getPrefixSearchLocation() {\r
- return _prefixSearchLocation;\r
- }\r
-\r
- /**\r
- * Set the location of prefixSearch.\r
- * @param location The location of prefixSearch. (Nullable)\r
- * @return this. (NotNull)\r
- */\r
- public ConditionValue setPrefixSearchLocation(String location) {\r
- _prefixSearchLocation = location;\r
- return this;\r
- }\r
-\r
- // ===================================================================================\r
- // Like Search\r
- // ===========\r
- /** Value of likeSearch. */\r
- protected List<LikeSearchValue> _likeSearch;\r
-\r
- /** Value of likeSearch for spare. */\r
- protected List<LikeSearchValue> _likeSearch4Spare;\r
-\r
- /**\r
- * Get the value of likeSearch.\r
- * @return The value of likeSearch. (Nullable)\r
- */\r
- public String getLikeSearch() {\r
- if (_likeSearch == null) {\r
- return null;\r
- }\r
- if (_likeSearch.isEmpty() && !_likeSearch4Spare.isEmpty()) {\r
- for (int index=0; index < _likeSearch4Spare.size(); index++) {\r
- _likeSearch.add(_likeSearch4Spare.get(index));\r
- }\r
- }\r
- final LikeSearchValue likeSearchValue = (LikeSearchValue)_likeSearch.remove(0);\r
- return (String)filterValue(likeSearchValue.generateRealValue());\r
- }\r
-\r
- /**\r
- * Set the value of likeSearch.\r
- * @param value The value of likeSearch. (Nullable)\r
- * @param option The option of likeSearch. (Nullable)\r
- * @return this. (NotNull)\r
- */\r
- public ConditionValue setLikeSearch(String value, LikeSearchOption option) {\r
- if (_likeSearch == null) {\r
- _likeSearch = new ArrayList<LikeSearchValue>();\r
- _likeSearch4Spare= new ArrayList<LikeSearchValue>();\r
- }\r
- if (_likeSearch.isEmpty() && !_likeSearch4Spare.isEmpty()) {\r
- for (int index=0; index < _likeSearch4Spare.size(); index++) {\r
- _likeSearch.add(_likeSearch4Spare.get(index));\r
- }\r
- }\r
- LikeSearchValue likeSearchValue = new LikeSearchValue(value, option);\r
- _likeSearch.add(likeSearchValue);\r
- _likeSearch4Spare.add(likeSearchValue);\r
- return this;\r
- }\r
-\r
- /** Location of likeSearch. */\r
- protected String _likeSearchLocation;\r
-\r
- /**\r
- * Get the location of likeSearch.\r
- * @return The location of likeSearch. (Nullable)\r
- */\r
- public String getLikeSearchLocation() {\r
- return _likeSearchLocation;\r
- }\r
-\r
- /**\r
- * Set the location of likeSearch.\r
- * @param location The location of likeSearch. (Nullable)\r
- * @return this. (NotNull)\r
- */\r
- public ConditionValue setLikeSearchLocation(String location) {\r
- _likeSearchLocation = location;\r
- return this;\r
- }\r
-\r
- protected static class LikeSearchValue {\r
- protected String _value;\r
- protected LikeSearchOption _option;\r
- public LikeSearchValue(String value, LikeSearchOption option) {\r
- _value = value;\r
- _option = option;\r
- }\r
- public String getValue() {\r
- return _value;\r
- }\r
- public LikeSearchOption getOption() {\r
- return _option;\r
- }\r
- public String generateRealValue() {\r
- if (_option == null) {\r
- return _value;\r
- }\r
- return _option.generateRealValue(_value);\r
- }\r
- }\r
-\r
- // ===================================================================================\r
- // In Scope\r
- // ========\r
- /** Value of inScope. */\r
- protected List<?> _inScope;\r
-\r
- protected InScopeOption _inScopeOption;\r
-\r
- /**\r
- * Get the value of inScope.\r
- * @return The value of inScope. (Nullable)\r
- */\r
- @SuppressWarnings("unchecked")\r
- public List<?> getInScope() {\r
- if (_inScopeOption != null) {\r
- return filterValue(_inScopeOption.generateRealValueList((List<String>)_inScope));\r
- }\r
- return filterValue(_inScope);\r
- }\r
-\r
- /**\r
- * Set the value of inScope.\r
- * @param value The value of inScope. (Nullable)\r
- * @return this. (NotNull)\r
- */\r
- public ConditionValue setInScope(List<?> value) {\r
- _inScope = value;\r
- return this;\r
- }\r
-\r
- public ConditionValue setInScope(List<?> value, InScopeOption option) {\r
- _inScope = value;\r
- _inScopeOption = option;\r
- return this;\r
- }\r
-\r
- /**\r
- * Does it has the value of inScope?\r
- * @return Determination. (NotNull)\r
- */\r
- public boolean hasInScope() {\r
- return _inScope != null;\r
- }\r
-\r
- /**\r
- * Does the value equal the value of inScope?\r
- * @param value The value of inScope. (Nullable)\r
- * @return Determination. (NotNull)\r
- */\r
- public boolean equalInScope(List<?> value) {\r
- return hasInScope() ? _inScope.equals(value) : value == null;\r
- }\r
-\r
- /**\r
- * Override the value of inScope.\r
- * @param value The value of inScope. (Nullable)\r
- * @return this. (NotNull)\r
- */\r
- public ConditionValue overrideInScope(List<?> value) {\r
- _inScope = value;\r
- return this;\r
- }\r
-\r
- /** Location of InScope. */\r
- protected String _inScopeLocation;\r
-\r
- /**\r
- * Get the location of inScope.\r
- * @return The location of inScope. (Nullable)\r
- */\r
- public String getInScopeLocation() {\r
- return _inScopeLocation;\r
- }\r
-\r
- /**\r
- * Set the location of inScope.\r
- * @param location The location of inScope. (Nullable)\r
- * @return this. (NotNull)\r
- */\r
- public ConditionValue setInScopeLocation(String location) {\r
- _inScopeLocation = location;\r
- return this;\r
- }\r
-\r
- // ===================================================================================\r
- // Not In Scope\r
- // ============\r
- /** Value of notInScope. */\r
- protected List<?> _notInScope;\r
-\r
- /**\r
- * Get the value of notInScope.\r
- * @return The value of notInScope. (Nullable)\r
- */\r
- public List<?> getNotInScope() {\r
- return filterValue(_notInScope);\r
- }\r
-\r
- /**\r
- * Set the value of notInScope.\r
- * @param value The value of notInScope. (Nullable)\r
- * @return this. (NotNull)\r
- */\r
- public ConditionValue setNotInScope(List<?> value) {\r
- _notInScope = value;\r
- return this;\r
- }\r
-\r
- /**\r
- * Does it has the value of inNotScope?\r
- * @return Determination. (NotNull)\r
- */\r
- public boolean hasNotInScope() {\r
- return _notInScope != null;\r
- }\r
-\r
- /**\r
- * Does the value equal the value of inNotScope?\r
- * @param value The value of inNotScope. (Nullable)\r
- * @return Determination. (NotNull)\r
- */\r
- public boolean equalNotInScope(List<?> value) {\r
- return hasNotInScope() ? _notInScope.equals(value) : value == null;\r
- }\r
-\r
- /**\r
- * Override the value of inNotScope.\r
- * @param value The value of inNotScope. (Nullable)\r
- * @return this. (NotNull)\r
- */\r
- public ConditionValue overrideNotInScope(List<?> value) {\r
- _notInScope = value;\r
- return this;\r
- }\r
-\r
- /** Location of notInScope. */\r
- protected String _notInScopeLocation;\r
-\r
- /**\r
- * Get the location of notInScope.\r
- * @return The location of notInScope. (Nullable)\r
- */\r
- public String getNotInScopeLocation() {\r
- return _notInScopeLocation;\r
- }\r
-\r
- /**\r
- * Set the location of notInScope.\r
- * @param location The location of notInScope. (Nullable)\r
- * @return this. (NotNull)\r
- */\r
- public ConditionValue setNotInScopeLocation(String location) {\r
- _notInScopeLocation = location;\r
- return this;\r
- }\r
-\r
- // ===================================================================================\r
- // Is Null\r
- // =======\r
- /** Value of isNull. */\r
- protected Object _isNullValue;\r
-\r
- /**\r
- * Get the value of isNull.\r
- * @return The value of isNull. (Nullable)\r
- */\r
- public Object getIsNull() {\r
- return _isNullValue;\r
- }\r
-\r
- /**\r
- * Set the value of isNull.\r
- * @param value The value of isNull. (Nullable)\r
- * @return this. (NotNull)\r
- */\r
- public ConditionValue setIsNull(Object value) {\r
- _isNullValue = value;\r
- return this;\r
- }\r
-\r
- /**\r
- * Does it has the value of isNull?\r
- * @return Determination. (NotNull)\r
- */\r
- public boolean hasIsNull() {\r
- return _isNullValue != null;\r
- }\r
-\r
- /** Location of isNull. */\r
- protected String _isNullLocation;\r
-\r
- /**\r
- * Get the location of isNull.\r
- * @return The location of isNull. (Nullable)\r
- */\r
- public String getIsNullLocation() {\r
- return _isNullLocation;\r
- }\r
-\r
- /**\r
- * Set the location of isNull.\r
- * @param location The location of isNull. (Nullable)\r
- * @return this. (NotNull)\r
- */\r
- public ConditionValue setIsNullLocation(String location) {\r
- _isNullLocation = location;\r
- return this;\r
- }\r
-\r
- // ===================================================================================\r
- // Is Not Null\r
- // ===========\r
- /** Value of isNotNull. */\r
- protected Object _isNotNullValue;\r
-\r
- /**\r
- * Get the value of isNotNull.\r
- * @return The value of isNotNull. (Nullable)\r
- */\r
- public Object getIsNotNull() {\r
- return _isNotNullValue;\r
- }\r
-\r
- /**\r
- * Set the value of isNotNull.\r
- * @param value The value of isNotNull. (Nullable)\r
- * @return this. (NotNull)\r
- */\r
- public ConditionValue setIsNotNull(Object value) {\r
- _isNotNullValue = value;\r
- return this;\r
- }\r
-\r
- /**\r
- * Does it has the value of isNotNull?\r
- * @return Determination. (NotNull)\r
- */\r
- public boolean hasIsNotNull() {\r
- return _isNotNullValue != null;\r
- }\r
-\r
- /** Location of isNotNull. */\r
- protected String _isNotNullLocation;\r
-\r
- /**\r
- * Get the location of isNotNull.\r
- * @return The location of isNotNull. (Nullable)\r
- */\r
- public String getIsNotNullLocation() {\r
- return _isNotNullLocation;\r
- }\r
-\r
- /**\r
- * Set the location of isNotNull.\r
- * @param location The location of isNotNull. (Nullable)\r
- * @return this. (NotNull)\r
- */\r
- public ConditionValue setIsNotNullLocation(String location) {\r
- _isNotNullLocation = location;\r
- return this;\r
- }\r
-\r
- // =====================================================================================\r
- // Filter\r
- // ======\r
- /**\r
- * Filter value.\r
- * If the value is instance of java.util.Date or java.util.Calendar, returns value as java.sql.Date.\r
- * @param value Value. (Nullable)\r
- * @return Filtered value. (Nullable)\r
- */\r
- protected Object filterValue(Object value) {\r
- if (value == null) {\r
- return value;\r
- }\r
- if (value instanceof java.sql.Time) {\r
- return value;\r
- }\r
- if (value instanceof java.sql.Timestamp) {\r
- return value;\r
- }\r
- if (value instanceof java.util.Date || value instanceof java.util.Calendar) {\r
- return SqlDateConversionUtil.toDate(value);\r
- } else {\r
- return value;\r
- }\r
- }\r
-\r
- /**\r
- * Filter value.\r
- * If the value is instance of java.util.Date or java.util.Calendar, returns value as java.sql.Date.\r
- * @param valueList Value-list. (Nullable)\r
- * @return Filtered value-list. (Nullable)\r
- */\r
- protected List<?> filterValue(List<?> valueList) {\r
- if (valueList == null || valueList.isEmpty()) {\r
- return valueList;\r
- }\r
- final List<Object> resultList = new ArrayList<Object>();\r
- for (Iterator<?> ite = valueList.iterator(); ite.hasNext(); ) {\r
- Object value = ite.next();\r
- resultList.add(filterValue(value));\r
- }\r
- return resultList;\r
- }\r
-\r
- protected static class SqlDateConversionUtil {\r
-\r
- private SqlDateConversionUtil() {\r
- }\r
-\r
- public static java.sql.Date toDate(Object o) {\r
- return toDate(o, null);\r
- }\r
-\r
- public static java.sql.Date toDate(Object o, String pattern) {\r
- if (o instanceof java.sql.Date) {\r
- return (java.sql.Date) o;\r
- }\r
- java.util.Date date = DateConversionUtil.toDate(o, pattern);\r
- if (date != null) {\r
- return new java.sql.Date(date.getTime());\r
- }\r
- return null;\r
- }\r
- }\r
-\r
- protected static class DateConversionUtil {\r
-\r
- private DateConversionUtil() {\r
- }\r
-\r
- public static java.util.Date toDate(Object o) {\r
- return toDate(o, null);\r
- }\r
-\r
- public static java.util.Date toDate(Object o, String pattern) {\r
- if (o == null) {\r
- return null;\r
- } else if (o instanceof String) {\r
- return toDate((String) o, pattern);\r
- } else if (o instanceof java.util.Date) {\r
- return (java.util.Date) o;\r
- } else if (o instanceof java.util.Calendar) {\r
- return ((java.util.Calendar) o).getTime();\r
- } else {\r
- return toDate(o.toString(), pattern);\r
- }\r
- }\r
-\r
- public static java.util.Date toDate(String s, String pattern) {\r
- return toDate(s, pattern, java.util.Locale.getDefault());\r
- }\r
-\r
- public static java.util.Date toDate(String s, String pattern, java.util.Locale locale) {\r
- java.text.SimpleDateFormat sdf = getDateFormat(s, pattern, locale);\r
- try {\r
- return sdf.parse(s);\r
- } catch (java.text.ParseException ex) {\r
- throw new RuntimeException(ex);\r
- }\r
- }\r
-\r
- public static java.text.SimpleDateFormat getDateFormat(String s, String pattern,\r
- java.util.Locale locale) {\r
- if (pattern != null) {\r
- return new java.text.SimpleDateFormat(pattern);\r
- }\r
- return getDateFormat(s, locale);\r
- }\r
-\r
- public static java.text.SimpleDateFormat getDateFormat(String s, java.util.Locale locale) {\r
- String pattern = getPattern(locale);\r
- String shortPattern = removeDelimiter(pattern);\r
- String delimitor = findDelimiter(s);\r
- if (delimitor == null) {\r
- if (s.length() == shortPattern.length()) {\r
- return new java.text.SimpleDateFormat(shortPattern);\r
- }\r
- if (s.length() == shortPattern.length() + 2) {\r
- return new java.text.SimpleDateFormat(InternalStringUtil.replace(shortPattern,\r
- "yy", "yyyy"));\r
- }\r
- } else {\r
- String[] array = InternalStringUtil.split(s, delimitor);\r
- for (int i = 0; i < array.length; ++i) {\r
- if (array[i].length() == 4) {\r
- pattern = InternalStringUtil.replace(pattern, "yy", "yyyy");\r
- break;\r
- }\r
- }\r
- return new java.text.SimpleDateFormat(pattern);\r
- }\r
- return new java.text.SimpleDateFormat();\r
- }\r
-\r
- public static java.text.SimpleDateFormat getDateFormat(java.util.Locale locale) {\r
- return new java.text.SimpleDateFormat(getPattern(locale));\r
- }\r
-\r
- public static java.text.SimpleDateFormat getY4DateFormat(java.util.Locale locale) {\r
- return new java.text.SimpleDateFormat(getY4Pattern(locale));\r
- }\r
-\r
- public static String getY4Pattern(java.util.Locale locale) {\r
- String pattern = getPattern(locale);\r
- if (pattern.indexOf("yyyy") < 0) {\r
- pattern = InternalStringUtil.replace(pattern, "yy", "yyyy");\r
- }\r
- return pattern;\r
- }\r
-\r
- public static String getPattern(java.util.Locale locale) {\r
- java.text.SimpleDateFormat df = (java.text.SimpleDateFormat) java.text.DateFormat.getDateInstance(\r
- java.text.DateFormat.SHORT, locale);\r
- String pattern = df.toPattern();\r
- int index = pattern.indexOf(' ');\r
- if (index > 0) {\r
- pattern = pattern.substring(0, index);\r
- }\r
- if (pattern.indexOf("MM") < 0) {\r
- pattern = InternalStringUtil.replace(pattern, "M", "MM");\r
- }\r
- if (pattern.indexOf("dd") < 0) {\r
- pattern = InternalStringUtil.replace(pattern, "d", "dd");\r
- }\r
- return pattern;\r
- }\r
-\r
- public static String findDelimiter(String value) {\r
- for (int i = 0; i < value.length(); ++i) {\r
- char c = value.charAt(i);\r
- if (Character.isDigit(c)) {\r
- continue;\r
- }\r
- return Character.toString(c);\r
- }\r
- return null;\r
- }\r
-\r
- public static String removeDelimiter(String pattern) {\r
- StringBuffer buf = new StringBuffer();\r
- for (int i = 0; i < pattern.length(); ++i) {\r
- char c = pattern.charAt(i);\r
- if (c == 'y' || c == 'M' || c == 'd') {\r
- buf.append(c);\r
- }\r
- }\r
- return buf.toString();\r
- }\r
- }\r
-\r
- protected static class InternalStringUtil {\r
- public static final String[] EMPTY_STRINGS = new String[0];\r
- private InternalStringUtil() {\r
- }\r
- public static final boolean isEmpty(String text) {\r
- return text == null || text.length() == 0;\r
- }\r
- public static final String replace(String text, String fromText, String toText) {\r
- if (text == null || fromText == null || toText == null) {\r
- return null;\r
- }\r
- StringBuffer buf = new StringBuffer(100);\r
- int pos = 0;\r
- int pos2 = 0;\r
- while (true) {\r
- pos = text.indexOf(fromText, pos2);\r
- if (pos == 0) {\r
- buf.append(toText);\r
- pos2 = fromText.length();\r
- } else if (pos > 0) {\r
- buf.append(text.substring(pos2, pos));\r
- buf.append(toText);\r
- pos2 = pos + fromText.length();\r
- } else {\r
- buf.append(text.substring(pos2));\r
- break;\r
- }\r
- }\r
- return buf.toString();\r
- }\r
-\r
- public static String[] split(String str, String delim) {\r
- if (str == null) {\r
- return EMPTY_STRINGS;\r
- }\r
- List<String> list = new java.util.ArrayList<String>();\r
- java.util.StringTokenizer st = new java.util.StringTokenizer(str, delim);\r
- while (st.hasMoreElements()) {\r
- list.add(st.nextToken());\r
- }\r
- return (String[]) list.toArray(new String[list.size()]);\r
- }\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.cbean.grouping;\r
-\r
-/**\r
- * The class of option for grouping.\r
- * @param <ENTITY> The type of entity.\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class GroupingOption<ENTITY> {\r
-\r
- // =====================================================================================\r
- // Attribute\r
- // =========\r
- protected int _elementCount;\r
-\r
- protected GroupingRowEndDeterminer<ENTITY> _groupingRowEndDeterminer;\r
-\r
- // =====================================================================================\r
- // Constructor\r
- // ===========\r
- /**\r
- * Constructor. You should set the determiner of grouping row end after you create the instance.\r
- */\r
- public GroupingOption() {\r
- }\r
-\r
- /**\r
- * Constructor.\r
- * @param elementCount The count of row element in a group.\r
- */\r
- public GroupingOption(int elementCount) {\r
- _elementCount = elementCount;\r
- }\r
-\r
- // =====================================================================================\r
- // Accessor\r
- // ========\r
- public int getElementCount() {\r
- return this._elementCount;\r
- }\r
-\r
- public GroupingRowEndDeterminer<ENTITY> getGroupingRowEndDeterminer() {\r
- return this._groupingRowEndDeterminer;\r
- }\r
-\r
- public void setGroupingRowEndDeterminer(GroupingRowEndDeterminer<ENTITY> groupingRowEndDeterminer) {\r
- this._groupingRowEndDeterminer = groupingRowEndDeterminer;\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.cbean.grouping;\r
-\r
-/**\r
- * The interface of grouping end(switch point) determiner.\r
- * @param <ENTITY> The type of entity.\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public interface GroupingRowEndDeterminer<ENTITY> {\r
-\r
- /**\r
- * Determine whether the grouping row is end.\r
- * @param rowResource The resource of grouping row. (NotNull and the property 'groupingRowList' is not empty and the property 'currentEntity' is not null)\r
- * @param nextEntity The entity of next element. (NotNull and the rowResource does not contain yet)\r
- * @return Whether the grouping row is end. (If the value is true, break grouping row and the nextEntity is registered to next row)\r
- */\r
- public boolean determine(GroupingRowResource<ENTITY> rowResource, ENTITY nextEntity);\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.cbean.grouping;\r
-\r
-import java.util.List;\r
-import java.util.ArrayList;\r
-\r
-/**\r
- * The class of row resource for grouping making.\r
- * @param <ENTITY> The type of entity.\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class GroupingRowResource<ENTITY> {\r
-\r
- // =====================================================================================\r
- // Attribute\r
- // =========\r
- protected List<ENTITY> _groupingRowList = new ArrayList<ENTITY>();\r
- protected int _elementCurrentIndex;\r
- protected int _breakCount;\r
-\r
- // =====================================================================================\r
- // Easy-to-Use\r
- // ===========\r
- /**\r
- * @return Does the list of grouping row size up the break count?\r
- */\r
- public boolean isSizeUpBreakCount() {\r
- return _elementCurrentIndex == (_breakCount-1);\r
- }\r
-\r
- // =====================================================================================\r
- // Accessor\r
- // ========\r
- /**\r
- * @return The list of grouping row. (NotNull and NotEmpty)\r
- */\r
- public List<ENTITY> getGroupingRowList() {\r
- return this._groupingRowList;\r
- }\r
-\r
- /**\r
- * Add the element entity to the list of grouping row. {INTERNAL METHOD}\r
- * @param groupingRow The element entity to the list of grouping row.\r
- */\r
- public void addGroupingRowList(ENTITY groupingRow) {\r
- this._groupingRowList.add(groupingRow);\r
- }\r
-\r
- /**\r
- * @return The entity of element current index. (NotNull)\r
- */\r
- public ENTITY getCurrentEntity() {\r
- return _groupingRowList.get(_elementCurrentIndex);\r
- }\r
-\r
- /**\r
- * @return The index of current element.\r
- */\r
- public int getElementCurrentIndex() {\r
- return this._elementCurrentIndex;\r
- }\r
-\r
- /**\r
- * Set the index of current element. {INTERNAL METHOD}\r
- * @param elementCurrentIndex The index of current element.\r
- */\r
- public void setElementCurrentIndex(int elementCurrentIndex) {\r
- this._elementCurrentIndex = elementCurrentIndex;\r
- }\r
-\r
- /**\r
- * @return The count of break loop.\r
- */\r
- public int getBreakCount() {\r
- return this._breakCount;\r
- }\r
-\r
- /**\r
- * Set the count of break loop. {INTERNAL METHOD}\r
- * @param breakCount The count of break loop.\r
- */\r
- public void setBreakCount(int breakCount) {\r
- this._breakCount = breakCount;\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.cbean.grouping;\r
-\r
-/**\r
- * The setupper of grouping row.\r
- * @param <ROW> The type of row.\r
- * @param <ENTITY> The type of entity.\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public interface GroupingRowSetupper<ROW, ENTITY> {\r
-\r
- /**\r
- * Set up the instance of grouping row.\r
- * @param groupingRowResource Grouping row resource. (NotNull)\r
- * @return The instance of grouping row. (NotNull)\r
- */\r
- public ROW setup(GroupingRowResource<ENTITY> groupingRowResource);\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.cbean.mapping;\r
-\r
-/**\r
- * The mapper of entity-to-dto.\r
- * @param <ENTITY> The type of entity.\r
- * @param <DTO> The type of dto.\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public interface EntityDtoMapper<ENTITY, DTO> {\r
-\r
- /**\r
- * Map entity to data transfer object.\r
- * @param entity Entity. (NotNull)\r
- * @return Data transfer object. (NotNull)\r
- */\r
- public DTO map(ENTITY entity);\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.cbean.outsidesql.executor;\r
-\r
-import java.util.List;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.ListResultBean;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.ResultBeanBuilder;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.outsidesql.OutsideSqlDao;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.outsidesql.OutsideSqlOption;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.outsidesql.ProcedurePmb;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.jdbc.StatementConfig;\r
-\r
-/**\r
- * The executor of outside-sql. <br />\r
- * <pre>\r
- * {Basic}\r
- * o selectList()\r
- * o execute()\r
- * o call()\r
- * \r
- * {Entity}\r
- * o entityHandling().selectEntity()\r
- * o entityHandling().selectEntityWithDeletedCheck()\r
- * \r
- * {Cursor}\r
- * o cursorHandling().selectCursor()\r
- * \r
- * {Paging}\r
- * o autoPaging().selectList()\r
- * o autoPaging().selectPage()\r
- * o manualPaging().selectList()\r
- * o manualPaging().selectPage()\r
- * \r
- * {Option -- Dynamic}\r
- * o dynamicBinding().selectList()\r
- * \r
- * </pre>\r
- * \r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class OutsideSqlBasicExecutor {\r
-\r
- // ===================================================================================\r
- // Attribute\r
- // =========\r
- /** The DAO of outside-sql. (NotNull) */\r
- protected final OutsideSqlDao _outsideSqlDao;\r
-\r
- /** Table DB name. (NotNull) */\r
- protected final String _tableDbName;\r
-\r
- /** Is it dynamic binding? */\r
- protected boolean _dynamicBinding;\r
- \r
- /** The config of statement. (Nullable) */\r
- protected StatementConfig _statementConfig;\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- public OutsideSqlBasicExecutor(OutsideSqlDao outsideSqlDao, String tableDbName) {\r
- this._outsideSqlDao = outsideSqlDao;\r
- this._tableDbName = tableDbName;\r
- }\r
-\r
- // ===================================================================================\r
- // Select\r
- // ======\r
- /**\r
- * Select the list of the entity.\r
- * @param <ENTITY> The type of entity for element.\r
- * @param path The path of SQL file. (NotNull)\r
- * @param pmb The parameter-bean. Allowed types are Bean object and Map object. (Nullable)\r
- * @param entityType The element type of entity. (NotNull)\r
- * @return The result bean of selected list. (NotNull)\r
- * @exception jp.sourceforge.ea2ddl.dao.allcommon.exception.OutsideSqlNotFoundException When the outside-sql is not found.\r
- */\r
- public <ENTITY> ListResultBean<ENTITY> selectList(String path, Object pmb, Class<ENTITY> entityType) {\r
- List<ENTITY> resultList = _outsideSqlDao.selectList(path, pmb, createOutsideSqlOption(), entityType);\r
- return new ResultBeanBuilder<ENTITY>(_tableDbName).buildListResultBean(resultList);\r
- }\r
-\r
- // ===================================================================================\r
- // Execute\r
- // =======\r
- /**\r
- * Execute. {Insert/Update/Delete/Etc...}\r
- * @param path The path of SQL file. (NotNull)\r
- * @param pmb The parameter-bean. Allowed types are Bean object and Map object. (Nullable)\r
- * @return The count of execution.\r
- * @exception jp.sourceforge.ea2ddl.dao.allcommon.exception.OutsideSqlNotFoundException When the outside-sql is not found.\r
- */\r
- public int execute(String path, Object pmb) {\r
- return _outsideSqlDao.execute(path, pmb, createOutsideSqlOption());\r
- }\r
-\r
- // [DBFlute-0.7.5]\r
- // ===================================================================================\r
- // Procedure Call\r
- // ==============\r
- /**\r
- * Call stored procedure.\r
- * @param pmb The parameter-bean for procedure. (NotNull)\r
- */\r
- public void call(ProcedurePmb pmb) {\r
- if (pmb == null) { throw new IllegalArgumentException("The argument of call() 'pmb' should not be null!"); }\r
- _outsideSqlDao.call(pmb.getProcedureName(), pmb, createOutsideSqlOption());\r
- }\r
-\r
- // ===================================================================================\r
- // Option\r
- // ======\r
- // -----------------------------------------------------\r
- // Result Handling\r
- // ---------------\r
- /**\r
- * Specify cursor handling. <br />\r
- * <pre>\r
- * # ex) Your Program\r
- * #\r
- * # executor.cursorHandling().selectCursor(path, pmb, handler);\r
- * #\r
- * </pre>\r
- * @return The cursor executor of outside-sql. (NotNull)\r
- */\r
- public OutsideSqlCursorExecutor<Object> cursorHandling() {\r
- return new OutsideSqlCursorExecutor<Object>(_outsideSqlDao, createOutsideSqlOption());\r
- }\r
-\r
- /**\r
- * Specify entity handling. <br />\r
- * <pre>\r
- * # ex) Your Program\r
- * #\r
- * # executor.entityHandling().selectEntityWithDeletedCheck(path, pmb, Xxx.class);\r
- * #\r
- * </pre>\r
- * @return The cursor executor of outside-sql. (NotNull)\r
- */\r
- public OutsideSqlEntityExecutor<Object> entityHandling() {\r
- return new OutsideSqlEntityExecutor<Object>(_outsideSqlDao, createOutsideSqlOption());\r
- }\r
-\r
- // -----------------------------------------------------\r
- // Paging\r
- // ------\r
- /**\r
- * Option of autoPaging. <br />\r
- * If you invoke this, you don't need to write paging condition on your SQL. <br />\r
- * <pre>\r
- * # ex) Your SQL {MySQL}\r
- * #\r
- * # select member.MEMBER_ID, member...\r
- * # from Member member\r
- * # where ...\r
- * # order by ...\r
- * # -- limit 40, 20 *Here is unnecessary!\r
- * #\r
- * </pre>\r
- * @return The executor of paging that the paging mode is auto. (NotNull)\r
- */\r
- public OutsideSqlPagingExecutor autoPaging() {\r
- final OutsideSqlOption option = createOutsideSqlOption();\r
- option.autoPaging();\r
- return new OutsideSqlPagingExecutor(_outsideSqlDao, option, _tableDbName);\r
- }\r
-\r
- /**\r
- * Option of manualPaging. <br />\r
- * If you invoke this, you need to write paging condition on your SQL. <br />\r
- * <pre>\r
- * # ex) Your SQL {MySQL}\r
- * #\r
- * # select member.MEMBER_ID, member...\r
- * # from Member member\r
- * # where ...\r
- * # order by ...\r
- * # limit 40, 20 *Here is necessary!\r
- * #\r
- * </pre>\r
- * @return The executor of paging that the paging mode is manual. (NotNull)\r
- */\r
- public OutsideSqlPagingExecutor manualPaging() {\r
- final OutsideSqlOption option = createOutsideSqlOption();\r
- option.manualPaging();\r
- return new OutsideSqlPagingExecutor(_outsideSqlDao, option, _tableDbName);\r
- }\r
-\r
- // -----------------------------------------------------\r
- // Dynamic Binding\r
- // ---------------\r
- public OutsideSqlBasicExecutor dynamicBinding() {\r
- _dynamicBinding = true;\r
- return this;\r
- }\r
-\r
- // -----------------------------------------------------\r
- // Statement Config\r
- // ----------------\r
- public OutsideSqlBasicExecutor configure(StatementConfig statementConfig) {\r
- _statementConfig = statementConfig;\r
- return this;\r
- }\r
- \r
- // ===================================================================================\r
- // Assist Helper\r
- // =============\r
- protected OutsideSqlOption createOutsideSqlOption() {\r
- final OutsideSqlOption option = new OutsideSqlOption();\r
- option.setStatementConfig(_statementConfig);\r
- if (_dynamicBinding) {\r
- option.dynamicBinding();\r
- }\r
- option.setTableDbName(_tableDbName);// as information\r
- return option;\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.cbean.outsidesql.executor;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.jdbc.CursorHandler;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.outsidesql.OutsideSqlDao;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.outsidesql.OutsideSqlOption;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.jdbc.StatementConfig;\r
-\r
-/**\r
- * The cursor executor of outside-sql.\r
- * @param <PARAMETER_BEAN> The type of parameter-bean.\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class OutsideSqlCursorExecutor<PARAMETER_BEAN> {\r
-\r
- // ===================================================================================\r
- // Attribute\r
- // =========\r
- protected final OutsideSqlDao _outsideSqlDao;\r
-\r
- protected final OutsideSqlOption _outsideSqlOption;\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- public OutsideSqlCursorExecutor(OutsideSqlDao outsideSqlDao, OutsideSqlOption outsideSqlOption) {\r
- this._outsideSqlDao = outsideSqlDao;\r
- this._outsideSqlOption = outsideSqlOption;\r
- }\r
-\r
- // ===================================================================================\r
- // Select\r
- // ======\r
- /**\r
- * Select the cursor of the entity.\r
- * @param path The path of SQL file. (NotNull)\r
- * @param pmb The parameter-bean. Allowed types are Bean object and Map object. (Nullable)\r
- * @param handler The handler of cursor. (NotNull)\r
- * @return The result object that the cursor handler returns. (Nullable)\r
- * @exception jp.sourceforge.ea2ddl.dao.allcommon.exception.OutsideSqlNotFoundException When the outside-sql is not found.\r
- */\r
- public Object selectCursor(String path, PARAMETER_BEAN pmb, CursorHandler handler) {\r
- return _outsideSqlDao.selectCursor(path, pmb, _outsideSqlOption, handler);\r
- }\r
-\r
- // ===================================================================================\r
- // Option\r
- // ======\r
- public OutsideSqlCursorExecutor<PARAMETER_BEAN> dynamicBinding() {\r
- _outsideSqlOption.dynamicBinding();\r
- return this;\r
- }\r
-\r
- public OutsideSqlCursorExecutor<PARAMETER_BEAN> configure(StatementConfig statementConfig) {\r
- _outsideSqlOption.setStatementConfig(statementConfig);\r
- return this;\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.cbean.outsidesql.executor;\r
-\r
-import java.util.List;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.ConditionBeanContext;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.outsidesql.OutsideSqlDao;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.outsidesql.OutsideSqlOption;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.jdbc.StatementConfig;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.util.SimpleSystemUtil;\r
-\r
-/**\r
- * The cursor executor of outside-sql.\r
- * @param <PARAMETER_BEAN> The type of parameter-bean.\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class OutsideSqlEntityExecutor<PARAMETER_BEAN> {\r
-\r
- // ===================================================================================\r
- // Attribute\r
- // =========\r
- protected final OutsideSqlDao _outsideSqlDao;\r
-\r
- protected final OutsideSqlOption _outsideSqlOption;\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- public OutsideSqlEntityExecutor(OutsideSqlDao outsideSqlDao, OutsideSqlOption outsideSqlOption) {\r
- this._outsideSqlDao = outsideSqlDao;\r
- this._outsideSqlOption = outsideSqlOption;\r
- }\r
-\r
- // ===================================================================================\r
- // Select\r
- // ======\r
- /**\r
- * Select entity.\r
- * @param <ENTITY> The type of entity.\r
- * @param path The path of SQL file. (NotNull)\r
- * @param pmb The parameter-bean. Allowed types are Bean object and Map object. (Nullable)\r
- * @param entityType The type of entity. (NotNull)\r
- * @return The selected entity. (Nullable)\r
- * @exception jp.sourceforge.ea2ddl.dao.allcommon.exception.OutsideSqlNotFoundException When the outside-sql is not found.\r
- * @exception jp.sourceforge.ea2ddl.dao.allcommon.exception.EntityDuplicatedException When the entity is duplicated.\r
- */\r
- public <ENTITY> ENTITY selectEntity(String path, PARAMETER_BEAN pmb, Class<ENTITY> entityType) {\r
- final List<ENTITY> ls = _outsideSqlDao.selectList(path, pmb, _outsideSqlOption, entityType);\r
- if (ls.isEmpty()) {\r
- return null;\r
- }\r
- if (ls.size() > 1) {\r
- throwEntityDuplicatedException(ls.size() + "", buildSearch4LogString(path, pmb, entityType), null);\r
- }\r
- return ls.get(0);\r
- }\r
-\r
- /**\r
- * Select entity with deleted check.\r
- * @param <ENTITY> The type of entity.\r
- * @param path The path of SQL file. (NotNull)\r
- * @param pmb The parameter-bean. Allowed types are Bean object and Map object. (Nullable)\r
- * @param entityType The type of entity. (NotNull)\r
- * @return The selected entity. (Nullable)\r
- * @exception jp.sourceforge.ea2ddl.dao.allcommon.exception.OutsideSqlNotFoundException When the outside-sql is not found.\r
- * @exception jp.sourceforge.ea2ddl.dao.allcommon.exception.EntityAlreadyDeletedException When the entity has already been deleted(not found).\r
- * @exception jp.sourceforge.ea2ddl.dao.allcommon.exception.EntityDuplicatedException When the entity is duplicated.\r
- */\r
- public <ENTITY> ENTITY selectEntityWithDeletedCheck(String path, PARAMETER_BEAN pmb, Class<ENTITY> entityType) {\r
- final List<ENTITY> ls = _outsideSqlDao.selectList(path, pmb, _outsideSqlOption, entityType);\r
- if (ls == null || ls.isEmpty()) {\r
- throwEntityAlreadyDeletedException(buildSearch4LogString(path, pmb, entityType));\r
- }\r
- if (ls.size() > 1) {\r
- throwEntityDuplicatedException(ls.size() + "", buildSearch4LogString(path, pmb, entityType), null);\r
- }\r
- return ls.get(0);\r
- }\r
-\r
- protected <ENTITY> String buildSearch4LogString(String path, PARAMETER_BEAN pmb, Class<ENTITY> entityType) {\r
- String tmp = "Table = " + _outsideSqlOption.getTableDbName() + getLineSeparator();\r
- tmp = tmp + "Path = " + path + getLineSeparator();\r
- tmp = tmp + "Pmb = " + (pmb != null ? pmb.getClass().getSimpleName() : "null") + ":" + pmb + getLineSeparator();\r
- tmp = tmp + "Entity = " + (entityType != null ? entityType.getSimpleName() : "null") + getLineSeparator();\r
- tmp = tmp + "Option = " + _outsideSqlOption;\r
- return tmp;\r
- }\r
-\r
- // -----------------------------------------------------\r
- // Helper\r
- // ------\r
- protected void throwEntityAlreadyDeletedException(Object searchKey4Log) {\r
- ConditionBeanContext.throwEntityAlreadyDeletedException(searchKey4Log);\r
- }\r
-\r
- protected void throwEntityDuplicatedException(String resultCountString, Object searchKey4Log, Throwable cause) {\r
- ConditionBeanContext.throwEntityDuplicatedException(resultCountString, searchKey4Log, cause);\r
- }\r
-\r
- // ===================================================================================\r
- // Option\r
- // ======\r
- public OutsideSqlEntityExecutor<PARAMETER_BEAN> configure(StatementConfig statementConfig) {\r
- _outsideSqlOption.setStatementConfig(statementConfig);\r
- return this;\r
- }\r
- \r
- public OutsideSqlEntityExecutor<PARAMETER_BEAN> dynamicBinding() {\r
- _outsideSqlOption.dynamicBinding();\r
- return this;\r
- }\r
-\r
- // ===================================================================================\r
- // Helper\r
- // ======\r
- /**\r
- * Get the value of line separator.\r
- * @return The value of line separator. (NotNull)\r
- */\r
- protected static String getLineSeparator() {\r
- return SimpleSystemUtil.getLineSeparator();\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.cbean.outsidesql.executor;\r
-\r
-import java.util.List;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.DBFluteConfig;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.ListResultBean;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.ResultBeanBuilder;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.PagingBean;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.PagingHandler;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.PagingInvoker;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.PagingResultBean;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.outsidesql.OutsideSqlDao;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.outsidesql.OutsideSqlOption;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.jdbc.StatementConfig;\r
-\r
-/**\r
- * The paging executor of outsideSql.\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class OutsideSqlPagingExecutor {\r
-\r
- // ===================================================================================\r
- // Attribute\r
- // =========\r
- /** The DAO of outsideSql. (NotNull) */\r
- protected final OutsideSqlDao _outsideSqlDao;\r
-\r
- /** The option of outsideSql. (NotNull) */\r
- protected final OutsideSqlOption _outsideSqlOption;\r
-\r
- /** The DB name of table. (NotNull) */\r
- protected final String _tableDbName;\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- public OutsideSqlPagingExecutor(OutsideSqlDao outsideSqlDao, OutsideSqlOption outsideSqlOption, String tableDbName) {\r
- this._outsideSqlDao = outsideSqlDao;\r
- this._outsideSqlOption = outsideSqlOption;\r
- this._tableDbName = tableDbName;\r
- }\r
-\r
- // ===================================================================================\r
- // Select\r
- // ======\r
- public <ENTITY> ListResultBean<ENTITY> selectList(String path, PagingBean pmb, Class<ENTITY> entityType) {\r
- setupScrollableCursorIfNeeds();\r
- List<ENTITY> resultList = _outsideSqlDao.selectList(path, pmb, _outsideSqlOption, entityType);\r
- return new ResultBeanBuilder<ENTITY>(_tableDbName).buildListResultBean(resultList);\r
- }\r
-\r
- /**\r
- * Select page.\r
- * <p>\r
- * The SQL should have Count and Paging. <br />\r
- * You can realize by pagingBean's isPaging() method on your 'SQL Comment'. For example, 'IF Comment'. <br />\r
- * It returns false when it executes Count. And it returns true when it executes Paging. <br />\r
- * <pre>\r
- * - - - - - - - - - - - - - - - - - - - - - - -\r
- * ex) Your Correct SQL {MySQL and manualPaging}\r
- * - - - - - - - - - - - - - - - - - - - - - - -\r
- * # /[*]IF pmb.isPaging()[*]/\r
- * # select member.MEMBER_ID\r
- * # , member.MEMBER_NAME\r
- * # , memberStatus.MEMBER_STATUS_NAME\r
- * # -- ELSE select count(*)\r
- * # /[*]END[*]/\r
- * # from MEMBER member\r
- * # /[*]IF pmb.isPaging()[*]/\r
- * # left outer join MEMBER_STATUS memberStatus\r
- * # on member.MEMBER_STATUS_CODE = memberStatus.MEMBER_STATUS_CODE\r
- * # /[*]END[*]/\r
- * # /[*]BEGIN[*]/where\r
- * # /[*]IF pmb.memberId != null[*]/member.MEMBER_ID = /[*]pmb.memberId[*]/'123'/[*]END[*]/\r
- * # /[*]IF pmb.memberName != null[*]/and member.MEMBER_NAME like /[*]pmb.memberName[*]/'Billy' || '%'/[*]END[*]/\r
- * # /[*]END[*]/\r
- * # /[*]IF pmb.isPaging()[*]/\r
- * # order by member.UPDATE_DATETIME desc\r
- * # /[*]END[*]/\r
- * # /[*]IF pmb.isPaging()[*]/\r
- * # limit /[*]$pmb.pageStartIndex[*]/80, /[*]$pmb.fetchSize[*]/20\r
- * # /[*]END[*]/\r
- * # \r
- * o [*] is easy escape to Java Doc Comment.\r
- * o If it's autoPaging, the line of 'limit 80, 20' is unnecessary!\r
- * \r
- * - - - - - - - - - - - - - - - - - - - - - - - - -\r
- * ex) Wrong SQL {part 1}\r
- * -- Line comment before ELSE comment --\r
- * - - - - - - - - - - - - - - - - - - - - - - - - -\r
- * # /[*]IF pmb.isPaging()[*]/\r
- * # select member.MEMBER_ID\r
- * # , member.MEMBER_NAME -- The name of member... *NG\r
- * # -- The status name of member... *NG\r
- * # , memberStatus.MEMBER_STATUS_NAME\r
- * # -- ELSE select count(*)\r
- * # /[*]END[*]/\r
- * # ...\r
- * o It's S2Dao's restriction...Sorry\r
- * </pre>\r
- * @param <ENTITY> The type of entity.\r
- * @param path The path of SQL that executes count and paging. (NotNull)\r
- * @param pagingPath The path of paging SQL. (NotNull)\r
- * @param pmb The bean of paging parameter. (NotNull)\r
- * @param entityType The type of result entity. (NotNull)\r
- * @return The result bean of paging. (NotNull)\r
- * @exception jp.sourceforge.ea2ddl.dao.allcommon.exception.OutsideSqlNotFoundException When the outside-sql is not found.\r
- */\r
- public <ENTITY> PagingResultBean<ENTITY> selectPage(final String path\r
- , final PagingBean pmb\r
- , final Class<ENTITY> entityType) {\r
- final OutsideSqlOption countOption = _outsideSqlOption.copyOptionWithoutPaging();\r
- final OutsideSqlEntityExecutor<PagingBean> countExecutor = new OutsideSqlEntityExecutor<PagingBean>(_outsideSqlDao, countOption);\r
- final PagingHandler<ENTITY> handler = new PagingHandler<ENTITY>() {\r
- public PagingBean getPagingBean() {\r
- return pmb;\r
- }\r
- public int count() {\r
- pmb.xsetPaging(false);\r
- return countExecutor.selectEntityWithDeletedCheck(path, pmb, Integer.class);\r
- }\r
- public List<ENTITY> paging() {\r
- pmb.xsetPaging(true);\r
- return selectList(path, pmb, entityType);\r
- }\r
- };\r
- final PagingInvoker<ENTITY> invoker = new PagingInvoker<ENTITY>(_tableDbName);\r
- if (pmb.isCountLater()) {\r
- invoker.countLater();\r
- }\r
- return invoker.invokePaging(handler);\r
- }\r
-\r
- protected void setupScrollableCursorIfNeeds() {\r
- if (!_outsideSqlOption.isAutoPaging()) {\r
- return;\r
- }\r
- StatementConfig statementConfig = _outsideSqlOption.getStatementConfig();\r
- if (statementConfig != null && statementConfig.getResultSetType() != null) {\r
- return;\r
- }\r
- StatementConfig defaultStatementConfig = DBFluteConfig.getInstance().getDefaultStatementConfig();\r
- if (defaultStatementConfig != null && defaultStatementConfig.hasResultSetType()) {\r
- return;\r
- }\r
- if (statementConfig == null) {\r
- statementConfig = new StatementConfig();\r
- configure(statementConfig);\r
- }\r
- statementConfig.typeScrollInsensitive();\r
- }\r
- \r
- // ===================================================================================\r
- // Option\r
- // ======\r
- public OutsideSqlPagingExecutor configure(StatementConfig statementConfig) {\r
- _outsideSqlOption.setStatementConfig(statementConfig);\r
- return this;\r
- }\r
-\r
- public OutsideSqlPagingExecutor dynamicBinding() {\r
- _outsideSqlOption.dynamicBinding();\r
- return this;\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.cbean.pagenavi.group;\r
-\r
-import java.util.List;\r
-import java.util.ArrayList;\r
-import java.util.Iterator;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.pagenavi.PageNumberLink;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.pagenavi.PageNumberLinkSetupper;\r
-\r
-/**\r
- * The bean of page group.\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class PageGroupBean implements java.io.Serializable {\r
-\r
- // ===================================================================================\r
- // Definition\r
- // ==========\r
- /** Serial version UID. (Default) */\r
- private static final long serialVersionUID = 1L;\r
-\r
- // ===================================================================================\r
- // Attribute\r
- // =========\r
- protected int _currentPageNumber;\r
- protected int _allPageCount;\r
- protected PageGroupOption _pageGroupOption;\r
-\r
- // ===================================================================================\r
- // Main\r
- // ====\r
- /**\r
- * Build the list of page number link.\r
- * @param <LINK> The type of link.\r
- * @param pageNumberLinkSetupper Page number link setupper. (NotNull and Required LINK)\r
- * @return The list of Page number link. (NotNull)\r
- */\r
- public <LINK extends PageNumberLink> List<LINK> buildPageNumberLinkList(PageNumberLinkSetupper<LINK> pageNumberLinkSetupper) {\r
- final List<Integer> pageNumberList = createPageNumberList();\r
- final List<LINK> pageNumberLinkList = new ArrayList<LINK>();\r
- for (Integer pageNumber: pageNumberList) {\r
- pageNumberLinkList.add(pageNumberLinkSetupper.setup(pageNumber, pageNumber.equals(_currentPageNumber)));\r
- }\r
- return pageNumberLinkList;\r
- }\r
-\r
- /**\r
- * Calculate start page number.\r
- * @return Start page number.\r
- */\r
- public int calculateStartPageNumber() {\r
- assertPageGroupValid();\r
- final int pageGroupSize = _pageGroupOption.getPageGroupSize();\r
- final int currentPageNumber = _currentPageNumber;\r
-\r
- int currentPageGroupNumber = (currentPageNumber / pageGroupSize);\r
- if ((currentPageNumber % pageGroupSize) == 0)\r
- {\r
- currentPageGroupNumber--;\r
- }\r
- final int currentPageGroupStartPageNumber = (pageGroupSize * currentPageGroupNumber) + 1;\r
- if (!(currentPageNumber >= currentPageGroupStartPageNumber)) {\r
- String msg = "currentPageNumber should be greater equal currentPageGroupStartPageNumber. But:";\r
- msg = msg + " currentPageNumber=" + currentPageNumber;\r
- msg = msg + " currentPageGroupStartPageNumber=" + currentPageGroupStartPageNumber;\r
- throw new IllegalStateException(msg);\r
- }\r
- return currentPageGroupStartPageNumber;\r
- }\r
-\r
- /**\r
- * Create the list of page number.\r
- * @return The list of page number. (NotNull)\r
- */\r
- public List<Integer> createPageNumberList() {\r
- assertPageGroupValid();\r
- final int pageGroupSize = _pageGroupOption.getPageGroupSize();\r
- final int allPageCount = _allPageCount;\r
- final int currentPageGroupStartPageNumber = calculateStartPageNumber();\r
- if (!(currentPageGroupStartPageNumber > 0)) {\r
- String msg = "currentPageGroupStartPageNumber should be greater than 0. {> 0} But:";\r
- msg = msg + " currentPageGroupStartPageNumber=" + currentPageGroupStartPageNumber;\r
- throw new IllegalStateException(msg);\r
- }\r
- final int nextPageGroupStartPageNumber = currentPageGroupStartPageNumber + pageGroupSize;\r
-\r
- final List<Integer> resultList = new ArrayList<Integer>();\r
- for (int i=currentPageGroupStartPageNumber; i < nextPageGroupStartPageNumber && i <= allPageCount; i++) {\r
- resultList.add(new Integer(i));\r
- }\r
- return resultList;\r
- }\r
-\r
- /**\r
- * Create the array of page number.\r
- * @return The array of page number. (NotNUll)\r
- */\r
- public int[] createPageNumberArray() {\r
- assertPageGroupValid();\r
- return convertListToIntArray(createPageNumberList());\r
- }\r
-\r
- /**\r
- * Is existing previous page-group?\r
- * Using values are currentPageNumber and pageGroupSize.\r
- * \r
- * @return Determination.\r
- */\r
- public boolean isExistPrePageGroup() {\r
- assertPageGroupValid();\r
- return (_currentPageNumber > _pageGroupOption.getPageGroupSize());\r
- }\r
-\r
- /**\r
- * Is existing next page-group?\r
- * Using values are currentPageNumber and pageGroupSize and allPageCount.\r
- * \r
- * @return Determination.\r
- */\r
- public boolean isExistNextPageGroup() {\r
- assertPageGroupValid();\r
- int currentPageGroupStartPageNumber = calculateStartPageNumber();\r
- if (!(currentPageGroupStartPageNumber > 0)) {\r
- String msg = "currentPageGroupStartPageNumber should be greater than 0. {> 0} But:";\r
- msg = msg + " currentPageGroupStartPageNumber=" + currentPageGroupStartPageNumber;\r
- throw new IllegalStateException(msg);\r
- }\r
- int nextPageGroupStartPageNumber = currentPageGroupStartPageNumber + _pageGroupOption.getPageGroupSize();\r
- return (nextPageGroupStartPageNumber <= _allPageCount);\r
- }\r
-\r
- // ===================================================================================\r
- // Assist Helper\r
- // =============\r
- protected int[] convertListToIntArray(List<Integer> ls) {\r
- final int[] resultArray = new int[ls.size()];\r
- int arrayIndex = 0;\r
- for (Iterator<Integer> ite = ls.iterator(); ite.hasNext(); ) {\r
- final Integer tmpPageNumber = (Integer)ite.next();\r
- resultArray[arrayIndex] = tmpPageNumber.intValue();\r
- arrayIndex++;\r
- }\r
- return resultArray;\r
- }\r
-\r
- protected void assertPageGroupValid() {\r
- if (_pageGroupOption == null) {\r
- String msg = "The pageGroupOption should not be null. Please invoke setPageGroupOption().";\r
- throw new IllegalStateException(msg);\r
- }\r
- if (_pageGroupOption.getPageGroupSize() == 0) {\r
- String msg = "The pageGroupSize should be greater than 1. But the value is zero.";\r
- msg = msg + " pageGroupSize=" + _pageGroupOption.getPageGroupSize();\r
- throw new IllegalStateException(msg);\r
- }\r
- if (_pageGroupOption.getPageGroupSize() == 1) {\r
- String msg = "The pageGroupSize should be greater than 1. But the value is one.";\r
- msg = msg + " pageGroupSize=" + _pageGroupOption.getPageGroupSize();\r
- throw new IllegalStateException(msg);\r
- }\r
- }\r
-\r
- // ===================================================================================\r
- // Basic Override\r
- // ==============\r
- /**\r
- * @return The view string of all attribute values. (NotNull)\r
- */\r
- @Override\r
- public String toString() {\r
- final StringBuilder sb = new StringBuilder();\r
-\r
- sb.append(" currentPageNumber=").append(_currentPageNumber);\r
- sb.append(" allPageCount=").append(_allPageCount);\r
- sb.append(" pageGroupOption=").append(_pageGroupOption);\r
-\r
- return sb.toString();\r
- }\r
-\r
- // ===================================================================================\r
- // Accessor\r
- // ========\r
- public void setCurrentPageNumber(int currentPageNumber) {\r
- this._currentPageNumber = currentPageNumber;\r
- }\r
- public void setAllPageCount(int allPageCount) {\r
- this._allPageCount = allPageCount;\r
- }\r
- public void setPageGroupOption(PageGroupOption pageGroupOption) {\r
- this._pageGroupOption = pageGroupOption;\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.cbean.pagenavi.group;\r
-\r
-/**\r
- * The option of page group.\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class PageGroupOption implements java.io.Serializable {\r
-\r
- // ===================================================================================\r
- // Definition\r
- // ==========\r
- /** Serial version UID. (Default) */\r
- private static final long serialVersionUID = 1L;\r
-\r
- // ===================================================================================\r
- // Attribute\r
- // =========\r
- protected int _pageGroupSize;\r
-\r
- // ===================================================================================\r
- // Basic Override\r
- // ==============\r
- /**\r
- * @return The view string of all attribute values. (NotNull)\r
- */\r
- @Override\r
- public String toString() {\r
- final StringBuilder sb = new StringBuilder();\r
-\r
- sb.append(" pageGroupSize=").append(_pageGroupSize);\r
-\r
- return sb.toString();\r
- }\r
- \r
- // ===================================================================================\r
- // Accessor\r
- // ========\r
- public int getPageGroupSize() {\r
- return _pageGroupSize;\r
- }\r
-\r
- public void setPageGroupSize(int pageGroupSize) {\r
- this._pageGroupSize = pageGroupSize;\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.cbean.pagenavi.range;\r
-\r
-import java.util.List;\r
-import java.util.ArrayList;\r
-import java.util.Iterator;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.pagenavi.PageNumberLink;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.pagenavi.PageNumberLinkSetupper;\r
-\r
-/**\r
- * The bean of page range.\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class PageRangeBean implements java.io.Serializable {\r
-\r
- // ===================================================================================\r
- // Definition\r
- // ==========\r
- /** Serial version UID. (Default) */\r
- private static final long serialVersionUID = 1L;\r
-\r
- // ===================================================================================\r
- // Attribute\r
- // =========\r
- protected int _currentPageNumber;\r
- protected int _allPageCount;\r
- protected PageRangeOption _pageRangeOption;\r
-\r
- // ===================================================================================\r
- // Main\r
- // ====\r
- /**\r
- * Build the list of page number link.\r
- * @param <LINK> The type of link.\r
- * @param pageNumberLinkSetupper Page number link setupper. (NotNull and Required LINK)\r
- * @return The list of Page number link. (NotNull)\r
- */\r
- public <LINK extends PageNumberLink> List<LINK> buildPageNumberLinkList(PageNumberLinkSetupper<LINK> pageNumberLinkSetupper) {\r
- final List<Integer> pageNumberList = createPageNumberList();\r
- final List<LINK> pageNumberLinkList = new ArrayList<LINK>();\r
- for (Integer pageNumber: pageNumberList) {\r
- pageNumberLinkList.add(pageNumberLinkSetupper.setup(pageNumber, pageNumber.equals(_currentPageNumber)));\r
- }\r
- return pageNumberLinkList;\r
- }\r
-\r
- /**\r
- * Create the list of page number.\r
- * @return The list of page number. (NotNull)\r
- */\r
- public List<Integer> createPageNumberList() {\r
- assertPageRangeValid();\r
- final int pageRangeSize = _pageRangeOption.getPageRangeSize();\r
- final int allPageCount = _allPageCount;\r
- final int currentPageNumber = _currentPageNumber;\r
-\r
- final List<Integer> resultList = new ArrayList<Integer>();\r
- for (int i = currentPageNumber - pageRangeSize; i < currentPageNumber; i++) {\r
- if (i < 1) {\r
- continue;\r
- }\r
- resultList.add(new Integer(i));\r
- }\r
-\r
- resultList.add(new Integer(currentPageNumber));\r
-\r
- final int endPageNumber = (currentPageNumber + pageRangeSize);\r
- for (int i = currentPageNumber + 1 ; i <= endPageNumber && i <= allPageCount; i++) {\r
- resultList.add(new Integer(i));\r
- }\r
-\r
- final boolean fillLimit = _pageRangeOption.isFillLimit();\r
- final int limitSize = (pageRangeSize * 2) + 1;\r
- if (fillLimit && !resultList.isEmpty() && resultList.size() < limitSize) {\r
- final Integer firstElements = (Integer)resultList.get(0);\r
- final Integer lastElements = (Integer)resultList.get(resultList.size() - 1);\r
- if (firstElements.intValue() > 1) {\r
- for (int i = firstElements.intValue() - 1 ; resultList.size() < limitSize && i > 0; i--) {\r
- resultList.add(0, new Integer(i));\r
- }\r
- }\r
- for (int i = lastElements.intValue() + 1 ; resultList.size() < limitSize && i <= allPageCount; i++) {\r
- resultList.add(new Integer(i));\r
- }\r
- }\r
- return resultList;\r
- }\r
-\r
- /**\r
- * Get the array of page number.\r
- * @return The array of page number. (NotNull)\r
- */\r
- public int[] createPageNumberArray() {\r
- assertPageRangeValid();\r
- return convertListToIntArray(createPageNumberList());\r
- }\r
-\r
- /**\r
- * Is existing previous page range?\r
- * @return Determination.\r
- */\r
- public boolean isExistPrePageRange() {\r
- assertPageRangeValid();\r
- final int[] array = createPageNumberArray();\r
- if (array.length == 0) {\r
- return false;\r
- }\r
- return array[0] > 1;\r
- }\r
-\r
- /**\r
- * Is existing next page range?\r
- * @return Determination.\r
- */\r
- public boolean isExistNextPageRange() {\r
- assertPageRangeValid();\r
- final int[] array = createPageNumberArray();\r
- if (array.length == 0) {\r
- return false;\r
- }\r
- return array[array.length-1] < _allPageCount;\r
- }\r
-\r
- // ===================================================================================\r
- // Assist Helper\r
- // =============\r
- protected int[] convertListToIntArray(List<Integer> ls) {\r
- final int[] resultArray = new int[ls.size()];\r
- int arrayIndex = 0;\r
- for (Iterator<Integer> ite = ls.iterator(); ite.hasNext(); ) {\r
- final Integer tmpPageNumber = (Integer)ite.next();\r
- resultArray[arrayIndex] = tmpPageNumber.intValue();\r
- arrayIndex++;\r
- }\r
- return resultArray;\r
- }\r
-\r
- protected void assertPageRangeValid() {\r
- if (_pageRangeOption == null) {\r
- String msg = "The pageRangeOption should not be null. Please invoke setPageRangeOption().";\r
- throw new IllegalStateException(msg);\r
- }\r
- final int pageRangeSize = _pageRangeOption.getPageRangeSize();\r
- if (pageRangeSize == 0) {\r
- String msg = "The pageRangeSize should be greater than 1. But the value is zero.";\r
- throw new IllegalStateException(msg);\r
- }\r
- }\r
-\r
- // ===================================================================================\r
- // Accessor\r
- // ========\r
- public void setCurrentPageNumber(int currentPageNumber) {\r
- this._currentPageNumber = currentPageNumber;\r
- }\r
- public void setAllPageCount(int allPageCount) {\r
- this._allPageCount = allPageCount;\r
- }\r
- public void setPageRangeOption(PageRangeOption pageRangeOption) {\r
- this._pageRangeOption = pageRangeOption;\r
- }\r
-\r
- // ===================================================================================\r
- // Basic Override\r
- // ==============\r
- /**\r
- * @return The view string of all attribute values. (NotNull)\r
- */\r
- @Override\r
- public String toString() {\r
- final StringBuilder sb = new StringBuilder();\r
-\r
- sb.append(" currentPageNumber=").append(_currentPageNumber);\r
- sb.append(" allPageCount=").append(_allPageCount);\r
- sb.append(" pageRangeOption=").append(_pageRangeOption);\r
-\r
- return sb.toString();\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.cbean.pagenavi.range;\r
-\r
-/**\r
- * The option of page range.\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class PageRangeOption implements java.io.Serializable {\r
-\r
- // ===================================================================================\r
- // Definition\r
- // ==========\r
- /** Serial version UID. (Default) */\r
- private static final long serialVersionUID = 1L;\r
-\r
- // ===================================================================================\r
- // Attribute\r
- // =========\r
- protected int _pageRangeSize;\r
- protected boolean _fillLimit;\r
-\r
- // ===================================================================================\r
- // Basic Override\r
- // ==============\r
- /**\r
- * @return The view string of all attribute values. (NotNull)\r
- */\r
- @Override\r
- public String toString() {\r
- final StringBuilder sb = new StringBuilder();\r
-\r
- sb.append(" pageRangeSize=").append(_pageRangeSize);\r
- sb.append(" fillLimit=").append(_fillLimit);\r
-\r
- return sb.toString();\r
- }\r
- \r
- // ===================================================================================\r
- // Accessor\r
- // ========\r
- public int getPageRangeSize() {\r
- return _pageRangeSize;\r
- }\r
-\r
- public void setPageRangeSize(int pageRangeSize) {\r
- this._pageRangeSize = pageRangeSize;\r
- }\r
-\r
- public boolean isFillLimit() {\r
- return _fillLimit;\r
- }\r
-\r
- public void setFillLimit(boolean fillLimit) {\r
- this._fillLimit = fillLimit;\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.cbean.sqlclause;\r
-\r
-\r
-import java.util.Collection;\r
-import java.util.List;\r
-import java.util.ArrayList;\r
-import java.util.Map;\r
-import java.util.HashMap;\r
-import java.util.LinkedHashMap;\r
-import java.util.Set;\r
-import java.util.Iterator;\r
-import java.util.StringTokenizer;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.ckey.*;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.coption.ConditionOption;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.cvalue.ConditionValue;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.dbmeta.DBMeta;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.dbmeta.DBMetaInstanceHandler;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.dbmeta.info.ColumnInfo;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.dbmeta.info.ForeignInfo;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.dbmeta.info.UniqueInfo;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.util.SimpleAssertUtil;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.util.SimpleStringUtil;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.util.SimpleSystemUtil;\r
-\r
-/**\r
- * The abstract class of SqlClause.\r
- * @author DBFlute(AutoGenerator)\r
- */
-@SuppressWarnings("unchecked")\r
-public abstract class AbstractSqlClause implements SqlClause {\r
-\r
- // ===================================================================================\r
- // Definition\r
- // ==========\r
- protected static final String SELECT_HINT = "/*$dto.selectHint*/";\r
- \r
- // ===================================================================================\r
- // Attribute\r
- // =========\r
- // -----------------------------------------------------\r
- // Basic\r
- // -----\r
- /** Target table name. */\r
- protected final String _tableName;\r
-\r
- // -----------------------------------------------------\r
- // Clause Resource\r
- // ---------------\r
- /** Selected select column map. map:{tableAliasName : map:{columnName : selectColumnInfo}}*/\r
- protected Map<String, Map<String, SelectedSelectColumnInfo>> _selectedSelectColumnMap = new LinkedHashMap<String, Map<String, SelectedSelectColumnInfo>>();\r
- \r
- /** Specified select column map. map:{ tableAliasName = map:{ columnName : null } } */\r
- protected Map<String, Map<String, String>> _specifiedSelectColumnMap;// [DBFlute-0.7.4]\r
- \r
- /** Specified derive sub-query map. */\r
- protected Map<String, String> _specifiedDeriveSubQueryMap;// [DBFlute-0.7.4]\r
-\r
- /** Included select column map. */\r
- protected Map<String, String> _includedSelectColumnMap = new LinkedHashMap<String, String>();\r
-\r
- /** The map of real column and alias of select clause. map:{realColumnName : aliasName} */\r
- protected Map<String, String> _selectClauseRealColumnAliasMap = new HashMap<String, String>();// Without linked!\r
- \r
- /** Outer join map. */\r
- protected Map<String, LeftOuterJoinInfo> _outerJoinMap = new LinkedHashMap<String, LeftOuterJoinInfo>();\r
-\r
- /** Where list. */\r
- protected List<String> _whereList = new ArrayList<String>();\r
-\r
- /** Inline where list for BaseTable. */\r
- protected List<String> _baseTableInlineWhereList = new ArrayList<String>();\r
-\r
- /** Order-by clause. */\r
- protected final OrderByClause _orderByClause = new OrderByClause();\r
-\r
- /** Union clause list. */\r
- protected List<UnionQueryInfo> _unionQueryInfoList = new ArrayList<UnionQueryInfo>();\r
-\r
- /** Is included-select-column effective? Default value is false. */\r
- protected boolean _isIncludedSelectColumnEffective = false;\r
-\r
- /** Is order-by effective? Default value is false. */\r
- protected boolean _isOrderByEffective = false;\r
-\r
- // -----------------------------------------------------\r
- // Fetch Property\r
- // --------------\r
- /** Fetch start index. (for fetchXxx()) */\r
- protected int _fetchStartIndex = 0;\r
-\r
- /** Fetch size. (for fetchXxx()) */\r
- protected int _fetchSize = 0;\r
-\r
- /** Fetch page number. (for fetchXxx()) This value should be plus. */\r
- protected int _fetchPageNumber = 1;\r
-\r
- /** Is fetch-narrowing effective? Default value is false. */\r
- protected boolean _isFetchScopeEffective = false;\r
-\r
- // -----------------------------------------------------\r
- // AdditionalConditionAsOr\r
- // -----------------------\r
- /** Is additional condition as or effective?*/\r
- protected boolean _isAdditionalConditionAsOrEffective = false;\r
-\r
- // -----------------------------------------------------\r
- // WhereClauseSimpleFilter\r
- // -----------------------\r
- /** The filter for where clause. */\r
- protected List<WhereClauseSimpleFilter> _whereClauseSimpleFilterList;\r
-\r
- // -----------------------------------------------------\r
- // Selected Foreign Info\r
- // ---------------------\r
- /** The information of selected foreign table. */\r
- protected Map<String, String> _selectedForeignInfo;\r
- \r
- // -----------------------------------------------------\r
- // Optional Info\r
- // -------------\r
- protected boolean _formatClause;\r
- \r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- public AbstractSqlClause(String tableName) {\r
- if (tableName == null) {\r
- String msg = "Argument[tableName] must not be null.";\r
- throw new IllegalArgumentException(msg);\r
- }\r
- _tableName = tableName;\r
- }\r
-\r
- // ===================================================================================\r
- // Clause\r
- // ======\r
- // -----------------------------------------------------\r
- // Complete Clause\r
- // ---------------\r
- public String getClause() {\r
- StringBuilder sb = new StringBuilder(512);\r
- sb.append(getSelectClause());\r
- sb.append(" ");\r
- sb.append(buildClauseWithoutMainSelect(false));\r
- String sql = sb.toString();\r
- return filterSubQueryIndent(sql);\r
- }\r
- \r
- public String getClausePKOnly() {\r
- StringBuilder sb = new StringBuilder(512);\r
- sb.append(getSelectClausePKOnly());\r
- sb.append(" ");\r
- sb.append(buildClauseWithoutMainSelect(true));\r
- String sql = sb.toString();\r
- return filterSubQueryIndent(sql);\r
- }\r
- \r
- protected String buildClauseWithoutMainSelect(boolean pkonly) {\r
- StringBuilder sb = new StringBuilder(512);\r
- sb.append(getFromClause());\r
- sb.append(getFromHint());\r
- sb.append(" ");\r
- sb.append(getWhereClause());\r
- String unionClause = buildUnionClause(pkonly ? getSelectClausePKOnly() : getSelectClause());\r
- \r
- // Delete template mark! (At the future this will be unnecessary.)\r
- unionClause = replaceString(unionClause, getUnionWhereClauseMark(), "");// Required!\r
- unionClause = replaceString(unionClause, getUnionWhereFirstConditionMark(), "");// Required!\r
- \r
- sb.append(unionClause);\r
- if (_isOrderByEffective && !_orderByClause.isEmpty()) {\r
- sb.append(" ");\r
- sb.append(getOrderByClause());\r
- }\r
- sb.append(" ");\r
- sb.append(getSqlSuffix());\r
- return sb.toString();\r
- }\r
- \r
- // -----------------------------------------------------\r
- // Fragment Clause\r
- // ---------------\r
- public String getClauseFromWhereWithUnionTemplate() {\r
- return buildClauseFromWhereAsTemplate(false);\r
- }\r
- \r
- public String getClauseFromWhereWithWhereUnionTemplate() {\r
- return buildClauseFromWhereAsTemplate(true);\r
- }\r
- \r
- protected String buildClauseFromWhereAsTemplate(boolean template) {\r
- StringBuilder sb = new StringBuilder(512);\r
- sb.append(getFromClause());\r
- sb.append(getFromHint());\r
- sb.append(" ");\r
- sb.append(buildWhereClause(template));\r
- sb.append(buildUnionClause(getUnionSelectClauseMark()));\r
- return sb.toString();\r
- }\r
-\r
- protected String buildUnionClause(String selectClause) {\r
- StringBuilder sb = new StringBuilder();\r
- for (final Iterator<UnionQueryInfo> ite = _unionQueryInfoList.iterator(); ite.hasNext(); ) {\r
- final UnionQueryInfo unionQueryInfo = (UnionQueryInfo)ite.next();\r
- final String unionQueryClause = unionQueryInfo.getUnionQueryClause();\r
- final boolean unionAll = unionQueryInfo.isUnionAll();\r
- if (isFormatClauseEffective()) {\r
- sb.append(getLineSeparator());\r
- }\r
- sb.append(unionAll ? " union all " : " union ");\r
- if (isFormatClauseEffective()) {\r
- sb.append(getLineSeparator());\r
- }\r
- sb.append(selectClause).append(" ").append(unionQueryClause);\r
- }\r
- return sb.toString();\r
- }\r
-\r
- // ===================================================================================\r
- // Clause Parts\r
- // ============\r
- public String getSelectClause() {\r
- StringBuilder sb = new StringBuilder();\r
- DBMeta dbmeta = DBMetaInstanceHandler.findDBMeta(_tableName);\r
- List<ColumnInfo> columnInfoList = dbmeta.getColumnInfoList();\r
-\r
- // [DBFlute-0.7.4]\r
- Map<String, String> localSpecifiedMap = _specifiedSelectColumnMap != null ? _specifiedSelectColumnMap.get(getLocalTableAliasName()) : null;\r
- boolean existsSpecifiedLocal = localSpecifiedMap != null && !localSpecifiedMap.isEmpty();\r
-\r
- for (ColumnInfo columnInfo : columnInfoList) {\r
- String columnName = columnInfo.getColumnDbName();\r
- \r
- // [DBFlute-0.7.4]\r
- if (existsSpecifiedLocal && !localSpecifiedMap.containsKey(columnName)) {\r
- continue;\r
- }\r
-\r
- if (sb.length() > 0) {\r
- sb.append(", ");\r
- } else {\r
- sb.append("select").append(SELECT_HINT).append(" ");\r
- }\r
- String realColumnName = getLocalTableAliasName() + "." + columnName;\r
- sb.append(realColumnName).append(" as ").append(columnName);\r
- _selectClauseRealColumnAliasMap.put(realColumnName, columnName);\r
- }\r
- Set<String> tableAliasNameSet = _selectedSelectColumnMap.keySet();\r
- for (String tableAliasName : tableAliasNameSet) {\r
- Map<String, SelectedSelectColumnInfo> map = _selectedSelectColumnMap.get(tableAliasName);\r
- Collection<SelectedSelectColumnInfo> selectColumnInfoList = map.values();\r
-\r
- // [DBFlute-0.7.4]\r
- Map<String, String> foreginSpecifiedMap = _specifiedSelectColumnMap != null ? _specifiedSelectColumnMap.get(tableAliasName) : null;\r
- boolean existsSpecifiedForeign = foreginSpecifiedMap != null && !foreginSpecifiedMap.isEmpty();\r
-\r
- for (SelectedSelectColumnInfo selectColumnInfo : selectColumnInfoList) {\r
- String realColumnName = selectColumnInfo.buildRealColumnName();\r
-\r
- // [DBFlute-0.7.4]\r
- if (existsSpecifiedForeign && !foreginSpecifiedMap.containsKey(selectColumnInfo.getColumnName())) {\r
- continue;\r
- }\r
-\r
- sb.append(", ").append(realColumnName).append(" as ").append(selectColumnInfo.getColumnAliasName());\r
- _selectClauseRealColumnAliasMap.put(realColumnName, selectColumnInfo.getColumnAliasName());\r
- }\r
- }\r
- if (_isIncludedSelectColumnEffective && !_includedSelectColumnMap.isEmpty()) {\r
- sb.append(getIncludedSelectColumnClause());\r
- }\r
- \r
- // [DBFlute-0.7.4]\r
- if (_specifiedDeriveSubQueryMap != null && !_specifiedDeriveSubQueryMap.isEmpty()) {\r
- Collection<String> deriveSubQuerySet = _specifiedDeriveSubQueryMap.values();\r
- for (String deriveSubQuery : deriveSubQuerySet) {\r
- if (isFormatClauseEffective()) {\r
- sb.append(getLineSeparator()).append(" ");\r
- }\r
- sb.append(", ").append(deriveSubQuery);\r
- }\r
- }\r
-\r
- return sb.toString();\r
- }\r
- \r
- public String getSelectClausePKOnly() {\r
- StringBuilder sb = new StringBuilder();\r
- DBMeta dbmeta = DBMetaInstanceHandler.findDBMeta(_tableName);\r
- UniqueInfo uniqueInfo = dbmeta.getPrimaryUniqueInfo();\r
- List<ColumnInfo> columnInfoList = uniqueInfo.getUniqueColumnList();\r
- for (ColumnInfo columnInfo : columnInfoList) {\r
- String columnName = columnInfo.getColumnDbName();\r
- if (sb.length() > 0) {\r
- sb.append(", ");\r
- } else {\r
- sb.append("select").append(SELECT_HINT).append(" ");\r
- }\r
- String realColumnName = getLocalTableAliasName() + "." + columnName;\r
- sb.append(realColumnName).append(" as ").append(columnName);\r
- _selectClauseRealColumnAliasMap.put(realColumnName, columnName);\r
- }\r
- if (_isIncludedSelectColumnEffective && !_includedSelectColumnMap.isEmpty()) {\r
- sb.append(getIncludedSelectColumnClause());\r
- }\r
-\r
- // [DBFlute-0.7.4]\r
- if (_specifiedDeriveSubQueryMap != null && !_specifiedDeriveSubQueryMap.isEmpty()) {\r
- Collection<String> deriveSubQuerySet = _specifiedDeriveSubQueryMap.values();\r
- for (String deriveSubQuery : deriveSubQuerySet) {\r
- if (isFormatClauseEffective()) {\r
- sb.append(getLineSeparator()).append(" ");\r
- }\r
- sb.append(", ").append(deriveSubQuery);\r
- }\r
- }\r
-\r
- return sb.toString();\r
- }\r
- \r
- public String getSelectHint() {\r
- return createSelectHint();\r
- }\r
-\r
- public String getIncludedSelectColumnClause() {\r
- StringBuilder sb = new StringBuilder();\r
- int count = 0;\r
- for (Iterator<String> ite = _includedSelectColumnMap.keySet().iterator(); ite.hasNext(); count++) {\r
- String aliasName = ite.next();\r
- String realColumnName = (String)_includedSelectColumnMap.get(aliasName);\r
- sb.append(", ").append(realColumnName).append(" as ").append(aliasName);\r
- _selectClauseRealColumnAliasMap.put(realColumnName, aliasName);\r
- }\r
- return sb.toString();\r
- }\r
-\r
- public String getFromClause() {\r
- StringBuilder sb = new StringBuilder();\r
- if (isFormatClauseEffective()) {\r
- sb.append(getLineSeparator()).append(" ");\r
- }\r
- sb.append("from ");\r
- if (_baseTableInlineWhereList.isEmpty()) {\r
- sb.append(_tableName).append(" dflocal");\r
- } else {\r
- sb.append(getInlineViewClause(_tableName, _baseTableInlineWhereList)).append(" dflocal");\r
- }\r
- sb.append(getFromBaseTableHint());\r
- sb.append(getLeftOuterJoinClause());\r
- return sb.toString();\r
- }\r
-\r
- protected String getLeftOuterJoinClause() {\r
- StringBuilder sb = new StringBuilder();\r
- for (Iterator<String> ite = _outerJoinMap.keySet().iterator(); ite.hasNext(); ) {\r
- String aliasName = ite.next();\r
- LeftOuterJoinInfo joinInfo = (LeftOuterJoinInfo)_outerJoinMap.get(aliasName);\r
- String joinTableName = joinInfo.getJoinTableName();\r
- List<String> inlineWhereClauseList = joinInfo.getInlineWhereClauseList();\r
- List<String> additionalOnClauseList = joinInfo.getAdditionalOnClauseList();\r
- Map<String, String> joinOnMap = joinInfo.getJoinOnMap();\r
- assertJoinOnMapNotEmpty(joinOnMap, aliasName);\r
-\r
- if (isFormatClauseEffective()) {\r
- sb.append(getLineSeparator()).append(" ");\r
- }\r
- sb.append(" left outer join ");\r
- if (inlineWhereClauseList.isEmpty()) {\r
- sb.append(joinTableName);\r
- } else {\r
- sb.append(getInlineViewClause(joinTableName, inlineWhereClauseList));\r
- }\r
- sb.append(" ").append(aliasName).append(" on ");\r
- int count = 0;\r
- Set<String> localColumnNameSet = joinOnMap.keySet();\r
- for (String localColumnName : localColumnNameSet) {\r
- String foreignColumnName = (String)joinOnMap.get(localColumnName);\r
- if (count > 0) {\r
- sb.append(" and ");\r
- }\r
- if (localColumnName.equals("$$fixedCondition$$")) {\r
- sb.append(foreignColumnName);\r
- } else {\r
- sb.append(localColumnName).append(" = ").append(foreignColumnName);\r
- }\r
- ++count;\r
- }\r
- for (String additionalOnClause : additionalOnClauseList) {\r
- sb.append(" and ").append(additionalOnClause);\r
- }\r
- }\r
- return sb.toString();\r
- }\r
-\r
- protected String getInlineViewClause(String joinTableName, List<String> inlineWhereClauseList) {\r
- StringBuilder sb = new StringBuilder();\r
- sb.append("(select * from ").append(joinTableName).append(" where ");\r
- int count = 0;\r
- for (final Iterator<String> ite = inlineWhereClauseList.iterator(); ite.hasNext(); ) {\r
- String clauseElement = ite.next();\r
- clauseElement = filterWhereClauseSimply(clauseElement);\r
- if (count > 0) {\r
- sb.append(" and ");\r
- }\r
- sb.append(clauseElement);\r
- ++count;\r
- }\r
- sb.append(")");\r
- return sb.toString();\r
- }\r
-\r
- public String getFromBaseTableHint() {\r
- return createFromBaseTableHint();\r
- }\r
-\r
- public String getFromHint() {\r
- return createFromHint();\r
- }\r
-\r
- public String getWhereClause() {\r
- return buildWhereClause(false);\r
- }\r
- \r
- protected String buildWhereClause(boolean template) {\r
- StringBuilder sb = new StringBuilder();\r
- int count = 0;\r
- for (Iterator<String> ite = _whereList.iterator(); ite.hasNext(); count++) {\r
- String clauseElement = (String)ite.next();\r
- clauseElement = filterWhereClauseSimply(clauseElement);\r
- if (count == 0) {\r
- if (isFormatClauseEffective()) {\r
- sb.append(getLineSeparator()).append(" ");\r
- }\r
- sb.append("where ").append(template ? getWhereFirstConditionMark() : "").append(clauseElement);\r
- } else {\r
- if (isFormatClauseEffective()) {\r
- sb.append(getLineSeparator()).append(" ");\r
- }\r
- sb.append(" and ").append(clauseElement);\r
- }\r
- }\r
- if (template && sb.length() == 0) {\r
- sb.append(getWhereClauseMark());\r
- }\r
- return sb.toString();\r
- }\r
- \r
- public String getOrderByClause() {\r
- String orderByClause = null;\r
- if (!_unionQueryInfoList.isEmpty()) {\r
- if (_selectClauseRealColumnAliasMap == null || _selectClauseRealColumnAliasMap.isEmpty()) {\r
- String msg = "The selectClauseColumnAliasMap should not be null or empty when union query exists: " + toString();\r
- throw new IllegalStateException(msg);\r
- }\r
- orderByClause = _orderByClause.getOrderByClause(_selectClauseRealColumnAliasMap);\r
- } else {\r
- orderByClause = _orderByClause.getOrderByClause();\r
- }\r
- if (isFormatClauseEffective() && orderByClause != null && orderByClause.trim().length() > 0) {\r
- return getLineSeparator() + " " + orderByClause;\r
- } else {\r
- return orderByClause;\r
- }\r
- }\r
-\r
- public String getSqlSuffix() {\r
- String sqlSuffix = createSqlSuffix();\r
- if (isFormatClauseEffective() && sqlSuffix != null && sqlSuffix.trim().length() > 0) {\r
- return getLineSeparator() + sqlSuffix;\r
- } else {\r
- return sqlSuffix;\r
- }\r
- }\r
-\r
- // ===================================================================================\r
- // Copy Parts\r
- // ==========\r
- public void copyIncludedSelectColumn(SqlClause sqlClause) {\r
- Set<String> keySet = _includedSelectColumnMap.keySet();\r
- for (Iterator<String> ite = keySet.iterator(); ite.hasNext(); ) {\r
- String aliasName = ite.next();\r
- String realColumnName = (String)_includedSelectColumnMap.get(aliasName);\r
- sqlClause.registerIncludedSelectColumn(aliasName, realColumnName);\r
- }\r
- }\r
-\r
- // ===================================================================================\r
- // SelectedSelectColumn\r
- // ====================\r
- /**\r
- * Register selected select column.\r
- * \r
- * @param foreignTableAliasName The alias name of foreign table. (NotNull)\r
- * @param localTableName The table name of local. (NotNull)\r
- * @param foreignPropertyName The property name of foreign table. (NotNull)\r
- * @param localRelationPath The path of local relation. (Nullable)\r
- */\r
- public void registerSelectedSelectColumn(String foreignTableAliasName\r
- , String localTableName\r
- , String foreignPropertyName\r
- , String localRelationPath) {\r
- _selectedSelectColumnMap.put(foreignTableAliasName, createSelectedSelectColumnInfo(foreignTableAliasName, localTableName, foreignPropertyName, localRelationPath));\r
- }\r
- \r
- protected Map<String, SelectedSelectColumnInfo> createSelectedSelectColumnInfo(String foreignTableAliasName\r
- , String localTableName\r
- , String foreignPropertyName\r
- , String localRelationPath) {\r
- final DBMeta dbmeta = DBMetaInstanceHandler.findDBMeta(localTableName);\r
- final ForeignInfo foreignInfo = dbmeta.findForeignInfo(foreignPropertyName);\r
- final int relationNo = foreignInfo.getRelationNo();\r
- String nextRelationPath = "_" + relationNo;\r
- if (localRelationPath != null) {\r
- nextRelationPath = localRelationPath + nextRelationPath;\r
- }\r
- final Map<String, SelectedSelectColumnInfo> resultMap = new LinkedHashMap<String, SelectedSelectColumnInfo>();\r
- final DBMeta foreignDBMeta = foreignInfo.getForeignDBMeta();\r
- final List<ColumnInfo> columnInfoList = foreignDBMeta.getColumnInfoList();\r
- for (ColumnInfo columnInfo : columnInfoList) {\r
- final String columnDbName = columnInfo.getColumnDbName();\r
- final SelectedSelectColumnInfo selectColumnInfo = new SelectedSelectColumnInfo();\r
- selectColumnInfo.setTableAliasName(foreignTableAliasName);\r
- selectColumnInfo.setColumnName(columnDbName);\r
- selectColumnInfo.setColumnAliasName(columnDbName + nextRelationPath);\r
- resultMap.put(columnDbName, selectColumnInfo);\r
- }\r
- return resultMap;\r
- }\r
-\r
- public static class SelectedSelectColumnInfo {\r
- protected String tableAliasName;\r
- protected String columnName;\r
- protected String columnAliasName;\r
- public String buildRealColumnName() {\r
- if (tableAliasName != null) {\r
- return tableAliasName + "." + columnName;\r
- } else {\r
- return columnName;\r
- }\r
- }\r
- public String getTableAliasName() {\r
- return tableAliasName;\r
- }\r
- public void setTableAliasName(String tableAliasName) {\r
- this.tableAliasName = tableAliasName;\r
- }\r
- public String getColumnName() {\r
- return columnName;\r
- }\r
- public void setColumnName(String columnName) {\r
- this.columnName = columnName;\r
- }\r
- public String getColumnAliasName() {\r
- return columnAliasName;\r
- }\r
- public void setColumnAliasName(String columnAliasName) {\r
- this.columnAliasName = columnAliasName;\r
- }\r
- }\r
- \r
- // ===================================================================================\r
- // IncludedSelectColumn\r
- // ====================\r
- public void ignoreIncludedSelectColumn() {\r
- _isIncludedSelectColumnEffective = false;\r
- }\r
-\r
- public void makeIncludedSelectColumnEffective() {\r
- if (!_includedSelectColumnMap.isEmpty()) {\r
- _isIncludedSelectColumnEffective = true;\r
- }\r
- }\r
-\r
- public void registerIncludedSelectColumn(String aliasName, String realColumnName) {\r
- _isIncludedSelectColumnEffective = true;\r
- _includedSelectColumnMap.put(aliasName, realColumnName);\r
- }\r
-\r
- // ===================================================================================\r
- // OuterJoin\r
- // =========\r
- public void registerOuterJoin(String joinTableName, String aliasName, Map<String, String> joinOnMap) {\r
- assertAlreadyOuterJoin(aliasName);\r
- assertJoinOnMapNotEmpty(joinOnMap, aliasName);\r
- final LeftOuterJoinInfo joinInfo = new LeftOuterJoinInfo();\r
- joinInfo.setAliasName(aliasName);\r
- joinInfo.setJoinTableName(joinTableName);\r
- joinInfo.setJoinOnMap(joinOnMap);\r
- _outerJoinMap.put(aliasName, joinInfo);\r
- }\r
-\r
- protected static class LeftOuterJoinInfo {\r
- protected String _aliasName;\r
- protected String _joinTableName;\r
- protected List<String> _inlineWhereClauseList = new ArrayList<String>();\r
- protected List<String> _additionalOnClauseList = new ArrayList<String>();\r
- protected Map<String, String> _joinOnMap;\r
- protected boolean _onClauseInline;\r
- public String getAliasName() {\r
- return _aliasName;\r
- }\r
- public void setAliasName(String value) {\r
- _aliasName = value;\r
- }\r
- public String getJoinTableName() {\r
- return _joinTableName;\r
- }\r
- public void setJoinTableName(String value) {\r
- _joinTableName = value;\r
- }\r
- public List<String> getInlineWhereClauseList() {\r
- return _inlineWhereClauseList;\r
- }\r
- public void addInlineWhereClause(String value) {\r
- _inlineWhereClauseList.add(value);\r
- }\r
- public List<String> getAdditionalOnClauseList() {\r
- return _additionalOnClauseList;\r
- }\r
- public void addAdditionalOnClause(String value) {\r
- _additionalOnClauseList.add(value);\r
- }\r
- public Map<String, String> getJoinOnMap() {\r
- return _joinOnMap;\r
- }\r
- public void setJoinOnMap(Map<String, String> value) {\r
- _joinOnMap = value;\r
- }\r
- public boolean isOnClauseInline() {\r
- return _onClauseInline;\r
- }\r
- public void setOnClauseInline(boolean value) {\r
- _onClauseInline = value;\r
- }\r
- }\r
-\r
- protected void assertAlreadyOuterJoin(String aliasName) {\r
- if (_outerJoinMap.containsKey(aliasName)) {\r
- String msg = "The alias name have already registered in outer join: " + aliasName;\r
- throw new IllegalStateException(msg);\r
- }\r
- }\r
-\r
- protected void assertJoinOnMapNotEmpty(Map<String, String> joinOnMap, String aliasName) {\r
- if (joinOnMap.isEmpty()) {\r
- String msg = "The joinOnMap should not be empty: aliasName=" + aliasName;\r
- throw new IllegalStateException(msg);\r
- }\r
- }\r
-\r
- // ===================================================================================\r
- // Where\r
- // =====\r
- public void registerWhereClause(String columnFullName, ConditionKey key, ConditionValue value) {\r
- assertStringNotNullAndNotTrimmedEmpty("columnFullName", columnFullName);\r
- key.addWhereClause(_whereList, columnFullName, value);\r
- arrangeWhereListAdditionalConditionAsOr(_whereList);\r
- }\r
-\r
- public void registerWhereClause(String columnFullName, ConditionKey key, ConditionValue value, ConditionOption option) {\r
- assertStringNotNullAndNotTrimmedEmpty("columnFullName", columnFullName);\r
- assertObjectNotNull("option of " + columnFullName, option);\r
- key.addWhereClause(_whereList, columnFullName, value, option);\r
- arrangeWhereListAdditionalConditionAsOr(_whereList);\r
- }\r
-\r
- public void registerWhereClause(String clause) {\r
- assertStringNotNullAndNotTrimmedEmpty("clause", clause);\r
- _whereList.add(clause);\r
- arrangeWhereListAdditionalConditionAsOr(_whereList);\r
- }\r
-\r
- public void exchangeFirstWhereClauseForLastOne() {\r
- if (_whereList.size() > 1) {\r
- final String first = (String)_whereList.get(0);\r
- final String last = (String)_whereList.get(_whereList.size() - 1);\r
- _whereList.set(0, last);\r
- _whereList.set(_whereList.size() - 1, first);\r
- }\r
- }\r
-\r
- // ===================================================================================\r
- // InlineWhere\r
- // ===========\r
- public void registerBaseTableInlineWhereClause(String columnName, ConditionKey key, ConditionValue value) {\r
- assertStringNotNullAndNotTrimmedEmpty("columnName", columnName);\r
- key.addWhereClause(_baseTableInlineWhereList, columnName, value);\r
- arrangeWhereListAdditionalConditionAsOr(_baseTableInlineWhereList);\r
- }\r
-\r
- public void registerBaseTableInlineWhereClause(String columnName, ConditionKey key, ConditionValue value, ConditionOption option) {\r
- assertStringNotNullAndNotTrimmedEmpty("columnName", columnName);\r
- assertObjectNotNull("option of " + columnName, option);\r
- key.addWhereClause(_baseTableInlineWhereList, columnName, value, option);\r
- arrangeWhereListAdditionalConditionAsOr(_baseTableInlineWhereList);\r
- }\r
-\r
- public void registerBaseTableInlineWhereClause(String value) {\r
- _baseTableInlineWhereList.add(value);\r
- }\r
-\r
- public void registerOuterJoinInlineWhereClause(String aliasName, String columnName, ConditionKey key, ConditionValue value, boolean onClauseInline) {\r
- assertNotYetOuterJoin(aliasName);\r
- assertStringNotNullAndNotTrimmedEmpty("columnName", columnName);\r
- final LeftOuterJoinInfo joinInfo = (LeftOuterJoinInfo)_outerJoinMap.get(aliasName);\r
- if (onClauseInline) {\r
- key.addWhereClause(joinInfo.getAdditionalOnClauseList(), aliasName + "." + columnName, value);\r
- } else {\r
- key.addWhereClause(joinInfo.getInlineWhereClauseList(), columnName, value);\r
- }\r
- arrangeWhereListAdditionalConditionAsOr(joinInfo.getInlineWhereClauseList());\r
- }\r
-\r
- public void registerOuterJoinInlineWhereClause(String aliasName, String columnName, ConditionKey key, ConditionValue value, ConditionOption option, boolean onClauseInline) {\r
- assertNotYetOuterJoin(aliasName);\r
- assertStringNotNullAndNotTrimmedEmpty("columnName", columnName);\r
- final LeftOuterJoinInfo joinInfo = (LeftOuterJoinInfo)_outerJoinMap.get(aliasName);\r
- if (onClauseInline) {\r
- key.addWhereClause(joinInfo.getAdditionalOnClauseList(), aliasName + "." + columnName, value, option);\r
- arrangeWhereListAdditionalConditionAsOr(joinInfo.getAdditionalOnClauseList());\r
- } else {\r
- key.addWhereClause(joinInfo.getInlineWhereClauseList(), columnName, value, option);\r
- arrangeWhereListAdditionalConditionAsOr(joinInfo.getInlineWhereClauseList());\r
- }\r
- }\r
-\r
- public void registerOuterJoinInlineWhereClause(String aliasName, String value, boolean onClauseInline) {\r
- assertNotYetOuterJoin(aliasName);\r
- final LeftOuterJoinInfo joinInfo = (LeftOuterJoinInfo)_outerJoinMap.get(aliasName);\r
- if (onClauseInline) {\r
- joinInfo.addAdditionalOnClause(value);\r
- arrangeWhereListAdditionalConditionAsOr(joinInfo.getAdditionalOnClauseList());\r
- } else {\r
- joinInfo.addInlineWhereClause(value);\r
- arrangeWhereListAdditionalConditionAsOr(joinInfo.getInlineWhereClauseList());\r
- }\r
- }\r
-\r
- protected void assertNotYetOuterJoin(String aliasName) {\r
- if (!_outerJoinMap.containsKey(aliasName)) {\r
- String msg = "The alias name have not registered in outer join yet: " + aliasName;\r
- throw new IllegalStateException(msg);\r
- }\r
- }\r
-\r
- // ===================================================================================\r
- // AdditionalConditionAsOr\r
- // =======================\r
- public void makeAdditionalConditionAsOrEffective() {\r
- _isAdditionalConditionAsOrEffective = true;\r
- }\r
-\r
- public void ignoreAdditionalConditionAsOr() {\r
- _isAdditionalConditionAsOrEffective = false;\r
- }\r
-\r
- protected void arrangeWhereListAdditionalConditionAsOr(List<String> whereList) {\r
- if (_isAdditionalConditionAsOrEffective) {\r
- if (whereList.size() < 2) {\r
- String msg = "The whereList should have two more elements when the isAdditionalConditionAsOrEffective is true: " + toString();\r
- throw new IllegalStateException(msg);\r
- }\r
- final String lastWhereClause = (String)whereList.remove(whereList.size() - 1);\r
- final String preWhereClause = (String)whereList.remove(whereList.size() - 1);\r
- if (preWhereClause.startsWith("(") && preWhereClause.endsWith(")")) {\r
- final String plainClause = preWhereClause.substring("(".length(), preWhereClause.length() - ")".length());\r
- whereList.add("(" + plainClause + " or " + lastWhereClause + ")");\r
- } else {\r
- whereList.add("(" + preWhereClause + " or " + lastWhereClause + ")");\r
- }\r
- }\r
- }\r
-\r
- // ===================================================================================\r
- // OrderBy\r
- // =======\r
- public OrderByClause getSqlComponentOfOrderByClause() {\r
- return _orderByClause;\r
- }\r
-\r
- public SqlClause clearOrderBy() {\r
- _isOrderByEffective = false;\r
- _orderByClause.clear();\r
- return this;\r
- }\r
-\r
- public SqlClause ignoreOrderBy() {\r
- _isOrderByEffective = false;\r
- return this;\r
- }\r
-\r
- public SqlClause makeOrderByEffective() {\r
- if (!_orderByClause.isEmpty()) {\r
- _isOrderByEffective = true;\r
- }\r
- return this;\r
- }\r
-\r
- public void reverseOrderBy_Or_OverrideOrderBy(String orderByProperty, String registeredOrderByProperty, boolean ascOrDesc) {\r
- _isOrderByEffective = true;\r
- if (!_orderByClause.isSameOrderByColumn(orderByProperty)) {\r
- clearOrderBy();\r
- registerOrderBy(orderByProperty, registeredOrderByProperty, ascOrDesc);\r
- } else {\r
- _orderByClause.reverseAll();\r
- }\r
- }\r
-\r
- public void registerOrderBy(String orderByProperty, String registeredOrderByProperty, boolean ascOrDesc) {\r
- try {\r
- _isOrderByEffective = true;\r
- final List<String> orderByList = new ArrayList<String>();\r
- {\r
- final StringTokenizer st = new StringTokenizer(orderByProperty, "/");\r
- while (st.hasMoreElements()) {\r
- orderByList.add(st.nextToken());\r
- }\r
- }\r
-\r
- if (registeredOrderByProperty == null || registeredOrderByProperty.trim().length() ==0) {\r
- registeredOrderByProperty = orderByProperty;\r
- }\r
-\r
- final List<String> registeredOrderByList = new ArrayList<String>();\r
- {\r
- final StringTokenizer st = new StringTokenizer(registeredOrderByProperty, "/");\r
- while (st.hasMoreElements()) {\r
- registeredOrderByList.add(st.nextToken());\r
- }\r
- }\r
-\r
- int count = 0;\r
- for (final Iterator<String> ite = orderByList.iterator(); ite.hasNext(); ) {\r
- String orderBy = ite.next();\r
- String registeredOrderBy = (String)registeredOrderByList.get(count);\r
-\r
- _isOrderByEffective = true;\r
- String aliasName = null;\r
- String columnName = null;\r
- String registeredAliasName = null;\r
- String registeredColumnName = null;\r
-\r
- if (orderBy.indexOf(".") < 0) {\r
- columnName = orderBy;\r
- } else {\r
- aliasName = orderBy.substring(0, orderBy.lastIndexOf("."));\r
- columnName = orderBy.substring(orderBy.lastIndexOf(".") + 1);\r
- }\r
-\r
- if (registeredOrderBy.indexOf(".") < 0) {\r
- registeredColumnName = registeredOrderBy;\r
- } else {\r
- registeredAliasName = registeredOrderBy.substring(0, registeredOrderBy.lastIndexOf("."));\r
- registeredColumnName = registeredOrderBy.substring(registeredOrderBy.lastIndexOf(".") + 1);\r
- }\r
-\r
- OrderByElement element = new OrderByElement();\r
- element.setAliasName(aliasName);\r
- element.setColumnName(columnName);\r
- element.setRegisteredAliasName(registeredAliasName);\r
- element.setRegisteredColumnName(registeredColumnName);\r
- if (ascOrDesc) {\r
- element.setupAsc();\r
- } else {\r
- element.setupDesc();\r
- }\r
- _orderByClause.addOrderByElement(element);\r
-\r
- count++;\r
- }\r
- } catch (RuntimeException e) {\r
- String msg = "registerOrderBy() threw the exception: orderByProperty=" + orderByProperty;\r
- msg = msg + " registeredColumnFullName=" + registeredOrderByProperty;\r
- msg = msg + " ascOrDesc=" + ascOrDesc;\r
- msg = msg + " sqlClause=" + this.toString();\r
- throw new RuntimeException(msg, e);\r
- }\r
- }\r
- \r
- public void addNullsFirstToPreviousOrderBy() {\r
- _orderByClause.addNullsFirstToPreviousOrderByElement(createOrderByNullsSetupper());\r
- }\r
- \r
- public void addNullsLastToPreviousOrderBy() {\r
- _orderByClause.addNullsLastToPreviousOrderByElement(createOrderByNullsSetupper());\r
- }\r
- \r
- protected OrderByClause.OrderByNullsSetupper createOrderByNullsSetupper() {// As Default\r
- return new OrderByClause.OrderByNullsSetupper() {\r
- public String setup(String columnName, String orderByElementClause, boolean nullsFirst) {\r
- return orderByElementClause + " nulls " + (nullsFirst ? "first" : "last");\r
- }\r
- };\r
- }\r
- \r
- protected OrderByClause.OrderByNullsSetupper createOrderByNullsSetupperByCaseWhen() {// Helper For Nulls Unsupported Database\r
- return new OrderByClause.OrderByNullsSetupper() {\r
- public String setup(String columnName, String orderByElementClause, boolean nullsFirst) {\r
- final String thenNumber = nullsFirst ? "1" : "0";\r
- final String elseNumber = nullsFirst ? "0" : "1";\r
- final String caseWhen = "case when " + columnName + " is not null then " + thenNumber + " else " + elseNumber + " end asc";\r
- return caseWhen + ", " + orderByElementClause;\r
- }\r
- };\r
- }\r
- \r
- // ===================================================================================\r
- // UnionQuery\r
- // ==========\r
- public void registerUnionQuery(String unionQueryClause, boolean unionAll) {\r
- assertStringNotNullAndNotTrimmedEmpty("unionQueryClause", unionQueryClause);\r
- final UnionQueryInfo unionQueryInfo = new UnionQueryInfo();\r
- unionQueryInfo.setUnionQueryClause(unionQueryClause);\r
- unionQueryInfo.setUnionAll(unionAll);\r
- _unionQueryInfoList.add(unionQueryInfo);\r
- }\r
-\r
- protected static class UnionQueryInfo {\r
- protected String _unionQueryClause;\r
- protected boolean _unionAll;\r
- public String getUnionQueryClause() {\r
- return _unionQueryClause;\r
- }\r
- public void setUnionQueryClause(String unionQueryClause) {\r
- _unionQueryClause = unionQueryClause;\r
- }\r
- public boolean isUnionAll() {\r
- return _unionAll;\r
- }\r
- public void setUnionAll(boolean unionAll) {\r
- _unionAll = unionAll;\r
- }\r
- }\r
-\r
- // ===================================================================================\r
- // FetchScope\r
- // ==========\r
- /**\r
- * @param fetchSize Fetch-size. (NotMinus & NotZero)\r
- * @return this. (NotNull)\r
- */\r
- public SqlClause fetchFirst(int fetchSize) {\r
- _isFetchScopeEffective = true;\r
- if (fetchSize <= 0) {\r
- String msg = "Argument[fetchSize] should be plus: " + fetchSize;\r
- throw new IllegalArgumentException(msg);\r
- }\r
- _fetchStartIndex = 0;\r
- _fetchSize = fetchSize;\r
- _fetchPageNumber = 1;\r
- doClearFetchPageClause();\r
- doFetchFirst();\r
- return this;\r
- }\r
-\r
- /**\r
- * @param fetchStartIndex Fetch-start-index. 0 origin. (NotMinus)\r
- * @param fetchSize Fetch size. (NotMinus)\r
- * @return this. (NotNull)\r
- */\r
- public SqlClause fetchScope(int fetchStartIndex, int fetchSize) {\r
- _isFetchScopeEffective = true;\r
- if (fetchStartIndex < 0) {\r
- String msg = "Argument[fetchStartIndex] must be plus or zero: " + fetchStartIndex;\r
- throw new IllegalArgumentException(msg);\r
- }\r
- if (fetchSize <= 0) {\r
- String msg = "Argument[fetchSize] should be plus: " + fetchSize;\r
- throw new IllegalArgumentException(msg);\r
- }\r
- _fetchStartIndex = fetchStartIndex;\r
- _fetchSize = fetchSize;\r
- return fetchPage(1);\r
- }\r
-\r
- /**\r
- * @param fetchPageNumber Page-number. 1 origin. (NotMinus & NotZero: If minus or zero, set one.)\r
- * @return this. (NotNull)\r
- */\r
- public SqlClause fetchPage(int fetchPageNumber) {\r
- _isFetchScopeEffective = true;\r
- if (fetchPageNumber <= 0) {\r
- fetchPageNumber = 1;\r
- }\r
- if (_fetchSize <= 0) {\r
- String msg = "Look! Read the message below." + getLineSeparator();\r
- msg = msg + "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *" + getLineSeparator();\r
- msg = msg + "Fetch size should not be minus or zero!" + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Advice]" + getLineSeparator();\r
- msg = msg + "When you invoke this method, it is necessary to invoke 'fetchFirst()' or 'fetchScope()' ahead of that. " + getLineSeparator();\r
- msg = msg + "Please confirm your program. Does it really invoke 'fetchPage()' with 'fetchFirst()' or 'fetchScope()'?" + getLineSeparator();\r
- msg = msg + " For example:" + getLineSeparator();\r
- msg = msg + " before (x):" + getLineSeparator();\r
- msg = msg + " XxxCB cb = new XxxCB();" + getLineSeparator();\r
- msg = msg + " cb.fetchPage(3);" + getLineSeparator();\r
- msg = msg + " after (o):" + getLineSeparator();\r
- msg = msg + " XxxCB cb = new XxxCB();" + getLineSeparator();\r
- msg = msg + " cb.fetchFirst(20); // The size of page" + getLineSeparator();\r
- msg = msg + " cb.fetchPage(3); // The number of target page" + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Actual Parameter Value]" + getLineSeparator();\r
- msg = msg + "fetchSize=" + _fetchSize + getLineSeparator();\r
- msg = msg + "fetchPageNumber=" + fetchPageNumber + getLineSeparator();\r
- msg = msg + "* * * * * * * * * */" + getLineSeparator();\r
- throw new IllegalStateException(msg);\r
- }\r
- _fetchPageNumber = fetchPageNumber;\r
- if (_fetchPageNumber == 1 && _fetchStartIndex == 0) {\r
- return fetchFirst(_fetchSize);\r
- }\r
- doClearFetchPageClause();\r
- doFetchPage();\r
- return this;\r
- }\r
-\r
- abstract protected void doFetchFirst();\r
- abstract protected void doFetchPage();\r
- abstract protected void doClearFetchPageClause();\r
-\r
- public int getFetchStartIndex() {\r
- return _fetchStartIndex;\r
- }\r
-\r
- public int getFetchSize() {\r
- return _fetchSize;\r
- }\r
-\r
- public int getFetchPageNumber() {\r
- return _fetchPageNumber;\r
- }\r
-\r
- /**\r
- * @return Page start index. 0 origin. (NotMinus)\r
- */\r
- public int getPageStartIndex() {\r
- if (_fetchPageNumber <= 0) {\r
- String msg = "_fetchPageNumber must be plus: " + _fetchPageNumber;\r
- throw new IllegalStateException(msg);\r
- }\r
- return _fetchStartIndex + (_fetchSize * (_fetchPageNumber - 1));\r
- }\r
-\r
- /**\r
- * @return Page end index. 0 origin. (NotMinus)\r
- */\r
- public int getPageEndIndex() {\r
- if (_fetchPageNumber <= 0) {\r
- String msg = "_fetchPageNumber must be plus: " + _fetchPageNumber;\r
- throw new IllegalStateException(msg);\r
- }\r
- return _fetchStartIndex + (_fetchSize * _fetchPageNumber);\r
- }\r
-\r
- public boolean isFetchScopeEffective() {\r
- return _isFetchScopeEffective;\r
- }\r
-\r
- public SqlClause ignoreFetchScope() {\r
- _isFetchScopeEffective = false;\r
- doClearFetchPageClause();\r
- return this;\r
- }\r
-\r
- public SqlClause makeFetchScopeEffective() {\r
- if (getFetchSize() > 0 && getFetchPageNumber() > 0) {\r
- fetchPage(getFetchPageNumber());\r
- }\r
- return this;\r
- }\r
- \r
- public boolean isFetchStartIndexSupported() {\r
- return true; // Default\r
- }\r
-\r
- public boolean isFetchSizeSupported() {\r
- return true; // Default\r
- }\r
-\r
- abstract protected String createSelectHint();\r
- abstract protected String createFromBaseTableHint();\r
- abstract protected String createFromHint();\r
- abstract protected String createSqlSuffix();\r
-\r
- // ===================================================================================\r
- // Fetch Narrowing\r
- // ===============\r
- /**\r
- * The implementation.\r
- * @return Fetch-narrowing start-index.\r
- */\r
- public int getFetchNarrowingSkipStartIndex() {\r
- return getPageStartIndex();\r
- }\r
-\r
- /**\r
- * The implementation.\r
- * @return Fetch-narrowing size.\r
- */\r
- public int getFetchNarrowingLoopCount() {\r
- return getFetchSize();\r
- }\r
-\r
- /**\r
- * The implementation.\r
- * @return Determination.\r
- */\r
- public boolean isFetchNarrowingEffective() {\r
- return _isFetchScopeEffective;\r
- }\r
-\r
- // ===================================================================================\r
- // Resolver\r
- // ========\r
- public String resolveJoinAliasName(String relationPath, int cqNestNo) {\r
- return resolveNestLevelExpression("dfrelation" + relationPath, cqNestNo);\r
- }\r
-\r
- public String resolveNestLevelExpression(String name, int cqNestNo) {\r
- // if (cqNestNo > 1) {\r
- // return name + "_n" + cqNestNo;\r
- // } else {\r
- // return name;\r
- // }\r
- return name;\r
- }\r
-\r
- public int resolveRelationNo(String localTableName, String foreignPropertyName) {\r
- final DBMeta dbmeta = DBMetaInstanceHandler.findDBMeta(localTableName);\r
- final ForeignInfo foreignInfo = dbmeta.findForeignInfo(foreignPropertyName);\r
- return foreignInfo.getRelationNo();\r
- }\r
-\r
- // ===================================================================================\r
- // Table Alias Info\r
- // ================\r
- public String getLocalTableAliasName() {\r
- return "dflocal";\r
- }\r
- \r
- public String getForeignTableAliasPrefix() {\r
- return "dfrelation";\r
- }\r
-\r
- // ===================================================================================\r
- // Template Mark\r
- // =============\r
- public String getWhereClauseMark() {\r
- return "#df:whereClause#";\r
- }\r
- \r
- public String getWhereFirstConditionMark() {\r
- return "#df:whereFirstCondition#";\r
- }\r
- \r
- public String getUnionSelectClauseMark() {\r
- return "#df:unionSelectClause#";\r
- }\r
- \r
- public String getUnionWhereClauseMark() {\r
- return "#df:unionWhereClause#";\r
- }\r
- \r
- public String getUnionWhereFirstConditionMark() {\r
- return "#df:unionWhereFirstCondition#";\r
- }\r
- \r
- // =====================================================================================\r
- // Where Clause Simple Filter\r
- // ==========================\r
- public void addWhereClauseSimpleFilter(WhereClauseSimpleFilter whereClauseSimpleFilter) {\r
- if (_whereClauseSimpleFilterList == null) {\r
- _whereClauseSimpleFilterList = new ArrayList<WhereClauseSimpleFilter>();\r
- }\r
- _whereClauseSimpleFilterList.add(whereClauseSimpleFilter);\r
- }\r
-\r
- protected String filterWhereClauseSimply(String clauseElement) {\r
- if (_whereClauseSimpleFilterList == null || _whereClauseSimpleFilterList.isEmpty()) {\r
- return clauseElement;\r
- }\r
- for (final Iterator<WhereClauseSimpleFilter> ite = _whereClauseSimpleFilterList.iterator(); ite.hasNext(); ) {\r
- final WhereClauseSimpleFilter filter = ite.next();\r
- if (filter == null) {\r
- String msg = "The list of filter should not have null: _whereClauseSimpleFilterList=" + _whereClauseSimpleFilterList;\r
- throw new IllegalStateException(msg);\r
- }\r
- clauseElement = filter.filterClauseElement(clauseElement);\r
- }\r
- return clauseElement;\r
- }\r
- \r
- // =====================================================================================\r
- // Selected Foreign Info\r
- // =====================\r
- public boolean isSelectedForeignInfoEmpty() {\r
- if (_selectedForeignInfo == null) {\r
- return true;\r
- }\r
- return _selectedForeignInfo.isEmpty();\r
- }\r
-\r
- public boolean hasSelectedForeignInfo(String relationPath) {\r
- if (_selectedForeignInfo == null) {\r
- return false;\r
- }\r
- return _selectedForeignInfo.containsKey(relationPath);\r
- }\r
-\r
- public void registerSelectedForeignInfo(String relationPath, String foreignPropertyName) {\r
- if (_selectedForeignInfo == null) {\r
- _selectedForeignInfo = new HashMap<String, String>();\r
- }\r
- _selectedForeignInfo.put(relationPath, foreignPropertyName);\r
- }\r
- \r
- // ===================================================================================\r
- // Format Clause\r
- // =============\r
- public boolean isFormatClauseEffective() {\r
- return _formatClause;\r
- }\r
- \r
- public void makeFormatClauseEffective() {\r
- _formatClause = true;\r
- }\r
-\r
- // ===================================================================================\r
- // Sub Query Indent\r
- // ================\r
- public String resolveSubQueryBeginMark(String subQueryIdentity) {\r
- return getSubQueryBeginMarkPrefix() + subQueryIdentity + getSubQueryIdentityTerminal();\r
- }\r
-\r
- public String resolveSubQueryEndMark(String subQueryIdentity) {\r
- return getSubQueryEndMarkPrefix() + subQueryIdentity + getSubQueryIdentityTerminal();\r
- }\r
-\r
- protected String getSubQueryBeginMarkPrefix() {\r
- return "--df:SubQueryBegin#";\r
- }\r
-\r
- protected String getSubQueryEndMarkPrefix() {\r
- return "--df:SubQueryEnd#";\r
- }\r
- \r
- protected String getSubQueryIdentityTerminal() {\r
- return "#IdentityTerminal#";\r
- }\r
-\r
- public String filterSubQueryIndent(String sql) {\r
- return isFormatClauseEffective() ? filterSubQueryIndent(sql, "") : sql;\r
- }\r
-\r
- protected String filterSubQueryIndent(String sql, String preIndent) {\r
- if (!isFormatClauseEffective()) {\r
- return sql;\r
- }\r
- final String lineSeparator = getLineSeparator();\r
- if (!sql.contains(getSubQueryBeginMarkPrefix())) {\r
- return sql;\r
- }\r
- final String[] lines = sql.split(lineSeparator);\r
- final String beginMarkPrefix = getSubQueryBeginMarkPrefix();\r
- final String endMarkPrefix = getSubQueryEndMarkPrefix();\r
- final String identityTerminal = getSubQueryIdentityTerminal();\r
- final int terminalLength = identityTerminal.length();\r
- StringBuilder mainSb = new StringBuilder();\r
- StringBuilder subSb = null;\r
- boolean throughBegin = false;\r
- boolean throughBeginFirst = false;\r
- String subQueryIdentity = null;\r
- String indent = null;\r
- for (String line : lines) {\r
- if (!throughBegin) {\r
- if (line.contains(beginMarkPrefix)) {\r
- throughBegin = true;\r
- subSb = new StringBuilder();\r
- final int markIndex = line.indexOf(beginMarkPrefix);\r
- final int terminalIndex = line.indexOf(identityTerminal);\r
- if (terminalIndex < 0) {\r
- String msg = "Identity terminal was Not Found at the begin line: [" + line + "]";\r
- throw new SubQueryIndentFailureException(msg);\r
- }\r
- final String clause = line.substring(0, markIndex) + line.substring(terminalIndex + terminalLength);\r
- subQueryIdentity = line.substring(markIndex + beginMarkPrefix.length(), terminalIndex);\r
- subSb.append(clause);\r
- indent = buildSpaceBar(markIndex - preIndent.length());\r
- } else {\r
- mainSb.append(line).append(getLineSeparator());\r
- }\r
- } else {\r
- // - - - - - - - -\r
- // In begin to end\r
- // - - - - - - - -\r
- if (line.contains(endMarkPrefix + subQueryIdentity)) {// The end\r
- final int markIndex = line.indexOf(endMarkPrefix);\r
- final int terminalIndex = line.indexOf(identityTerminal);\r
- if (terminalIndex < 0) {\r
- String msg = "Identity terminal was Not Found at the begin line: [" + line + "]";\r
- throw new SubQueryIndentFailureException(msg);\r
- }\r
- final String clause = line.substring(0, markIndex) + line.substring(terminalIndex + terminalLength);\r
- subSb.append(clause).append(getLineSeparator());\r
- final String currentSql = filterSubQueryIndent(subSb.toString(), preIndent + indent);\r
- mainSb.append(currentSql);\r
- throughBegin = false;\r
- throughBeginFirst = false;\r
- } else {\r
- if (!throughBeginFirst) {\r
- subSb.append(line.trim()).append(getLineSeparator());\r
- throughBeginFirst = true;\r
- } else {\r
- subSb.append(indent).append(line).append(getLineSeparator());\r
- }\r
- }\r
- }\r
- }\r
- final String filteredSql = mainSb.toString();\r
- \r
- if (throughBegin) {\r
- String msg = "End Mark Not Found!";\r
- msg = msg + getLineSeparator() + "[Current SubQueryIdentity]" + getLineSeparator();\r
- msg = msg + subQueryIdentity + getLineSeparator();\r
- msg = msg + getLineSeparator() + "[Before Filter]" + getLineSeparator();\r
- msg = msg + sql + getLineSeparator();\r
- msg = msg + getLineSeparator() + "[After Filter]" + getLineSeparator() + filteredSql;\r
- throw new SubQueryIndentFailureException(msg);\r
- }\r
- if (filteredSql.contains(beginMarkPrefix)) {\r
- String msg = "Any begin marks are not filtered!";\r
- msg = msg + getLineSeparator() + "[Current SubQueryIdentity]" + getLineSeparator();\r
- msg = msg + subQueryIdentity + getLineSeparator();\r
- msg = msg + getLineSeparator() + "[Before Filter]" + getLineSeparator();\r
- msg = msg + sql + getLineSeparator();\r
- msg = msg + getLineSeparator() + "[After Filter]" + getLineSeparator() + filteredSql;\r
- throw new SubQueryIndentFailureException(msg);\r
- }\r
- return filteredSql;\r
- }\r
- \r
- protected String buildSpaceBar(int size) {\r
- final StringBuilder sb = new StringBuilder();\r
- for (int i = 0; i < size; i++) {\r
- sb.append(" ");\r
- }\r
- return sb.toString();\r
- }\r
- \r
- public static class SubQueryIndentFailureException extends RuntimeException {\r
- private static final long serialVersionUID = 1L;\r
- public SubQueryIndentFailureException(String msg) {\r
- super(msg);\r
- }\r
- }\r
-\r
- // [DBFlute-0.7.4]\r
- // ===================================================================================\r
- // Specification\r
- // =============\r
- public void specifySelectColumn(String tableAliasName, String columnName) {\r
- if (_specifiedSelectColumnMap == null) {\r
- _specifiedSelectColumnMap = new HashMap<String, Map<String, String>>();\r
- }\r
- if (!_specifiedSelectColumnMap.containsKey(tableAliasName)) {\r
- _specifiedSelectColumnMap.put(tableAliasName, new HashMap<String, String>());\r
- }\r
- Map<String, String> elementMap = _specifiedSelectColumnMap.get(tableAliasName);\r
- elementMap.put(columnName, null); // The value is dummy for extension at the future.\r
- _specifiedSelectColumnMap.put(tableAliasName, elementMap);\r
- }\r
-\r
- public void specifyDeriveSubQuery(String aliasName, String deriveSubQuery) {\r
- if (_specifiedDeriveSubQueryMap == null) {\r
- _specifiedDeriveSubQueryMap = new LinkedHashMap<String, String>();\r
- }\r
- _specifiedDeriveSubQueryMap.put(aliasName, deriveSubQuery);\r
- }\r
-\r
- public boolean hasSpecifiedDeriveSubQuery(String aliasName) {\r
- if (_specifiedDeriveSubQueryMap == null) { return false; }\r
- return _specifiedDeriveSubQueryMap.containsKey(aliasName);\r
- }\r
-\r
- public String getSpecifiedColumnNameAsOne() {\r
- if (_specifiedSelectColumnMap != null && _specifiedSelectColumnMap.size() == 1) {\r
- Map<String, String> elementMap = _specifiedSelectColumnMap.get(_specifiedSelectColumnMap.keySet().iterator().next());\r
- if (elementMap != null && elementMap.size() == 1) {\r
- return elementMap.keySet().iterator().next();\r
- }\r
- }\r
- return null;\r
- }\r
-\r
- public void clearSpecifiedSelectColumn() {\r
- if (_specifiedSelectColumnMap != null) { _specifiedSelectColumnMap.clear(); _specifiedSelectColumnMap = null; }\r
- }\r
-\r
- // [DBFlute-0.7.5]\r
- // ===================================================================================\r
- // Query Update\r
- // ============\r
- public String getClauseQueryUpdate(Map<String, String> columnParameterMap) {\r
- if (columnParameterMap.isEmpty()) {\r
- return null;\r
- }\r
- final String aliasName = getLocalTableAliasName();\r
- final DBMeta dbmeta = findDBMeta();\r
- if (dbmeta.hasTwoOrMorePrimaryKeys()) {\r
- String msg = "The target table of queryUpdate() should have only one primary key:";\r
- msg = msg + " primaryKeys=" + dbmeta.getPrimaryUniqueInfo().getUniqueColumnList();\r
- throw new IllegalStateException(msg);\r
- }\r
- final String primaryKeyName = dbmeta.getPrimaryUniqueInfo().getFirstColumn().getColumnDbName();\r
- final String selectClause = "select " + aliasName + "." + primaryKeyName;\r
- String fromWhereClause = getClauseFromWhereWithUnionTemplate();\r
-\r
- // Replace template marks. These are very important!\r
- fromWhereClause = replaceString(fromWhereClause, getUnionSelectClauseMark(), selectClause);\r
- fromWhereClause = replaceString(fromWhereClause, getUnionWhereClauseMark(), "");\r
- fromWhereClause = replaceString(fromWhereClause, getUnionWhereFirstConditionMark(), "");\r
-\r
- final StringBuilder sb = new StringBuilder();\r
- String ln = "";\r
- if (isFormatClauseEffective()) {\r
- ln = getLineSeparator();\r
- }\r
- sb.append("update ").append(_tableName).append(ln);\r
- int index = 0;\r
- // It is guaranteed that the map has one or more elements.\r
- for (String columnName : columnParameterMap.keySet()) {\r
- final String parameter = columnParameterMap.get(columnName); \r
- if (index == 0) {\r
- sb.append(" set ").append(columnName).append(" = ").append(parameter).append(ln);\r
- } else {\r
- sb.append(" , ").append(columnName).append(" = ").append(parameter).append(ln);\r
- }\r
- ++index;\r
- }\r
- if (isUpdateSubQueryUseLocalTableSupported()) {\r
- final String subQuery = filterSubQueryIndent(selectClause + " " + fromWhereClause);\r
- sb.append(" where ").append(primaryKeyName);\r
- sb.append(" in (").append(ln).append(subQuery).append(ln).append(")");\r
- return sb.toString();\r
- } else {\r
- String subQuery = filterSubQueryIndent(fromWhereClause);\r
- subQuery = replaceString(subQuery, aliasName + ".", "");\r
- subQuery = replaceString(subQuery, " " + aliasName + " ", " ");\r
- subQuery = subQuery.substring(subQuery.indexOf("where "));\r
- sb.append(" ").append(subQuery);\r
- return sb.toString();\r
- }\r
- }\r
-\r
- public String getClauseQueryDelete() {\r
- final String aliasName = getLocalTableAliasName();\r
- final DBMeta dbmeta = findDBMeta();\r
- if (dbmeta.hasTwoOrMorePrimaryKeys()) {\r
- String msg = "The target table of queryDelete() should have only one primary key:";\r
- msg = msg + " primaryKeys=" + dbmeta.getPrimaryUniqueInfo().getUniqueColumnList();\r
- throw new IllegalStateException(msg);\r
- }\r
- final String primaryKeyName = dbmeta.getPrimaryUniqueInfo().getFirstColumn().getColumnDbName();\r
- final String selectClause = "select " + aliasName + "." + primaryKeyName;\r
- String fromWhereClause = getClauseFromWhereWithUnionTemplate();\r
- \r
- // Replace template marks. These are very important!\r
- fromWhereClause = replaceString(fromWhereClause, getUnionSelectClauseMark(), selectClause);\r
- fromWhereClause = replaceString(fromWhereClause, getUnionWhereClauseMark(), "");\r
- fromWhereClause = replaceString(fromWhereClause, getUnionWhereFirstConditionMark(), "");\r
- \r
- if (isUpdateSubQueryUseLocalTableSupported()) {\r
- final String subQuery = filterSubQueryIndent(selectClause + " " + fromWhereClause);\r
- final StringBuilder sb = new StringBuilder();\r
- String ln = "";\r
- if (isFormatClauseEffective()) {\r
- ln = getLineSeparator();\r
- }\r
- sb.append("delete from ").append(_tableName).append(ln);\r
- sb.append(" where ").append(primaryKeyName);\r
- sb.append(" in (").append(ln).append(subQuery).append(ln).append(")");\r
- return sb.toString();\r
- } else {\r
- String subQuery = filterSubQueryIndent(fromWhereClause);\r
- subQuery = replaceString(subQuery, aliasName + ".", "");\r
- subQuery = replaceString(subQuery, " " + aliasName + " ", " ");\r
- subQuery = subQuery.substring(subQuery.indexOf("from "));\r
- return "delete " + subQuery;\r
- }\r
- }\r
-\r
- protected boolean isUpdateSubQueryUseLocalTableSupported() {\r
- return true;\r
- }\r
-\r
- // [DBFlute-0.7.7]\r
- // ===================================================================================\r
- // Unique Constraint\r
- // =================\r
- public boolean isUniqueConstraintException(String sqlState, Integer errorCode) {\r
- return false;\r
- }\r
- \r
- // [DBFlute-0.7.5]\r
- // ===================================================================================\r
- // Assist Helper\r
- // =============\r
- protected DBMeta findDBMeta() {\r
- return DBMetaInstanceHandler.findDBMeta(_tableName); \r
- }\r
- \r
- // ===================================================================================\r
- // General Helper\r
- // ==============\r
- protected String replaceString(String text, String fromText, String toText) {\r
- return SimpleStringUtil.replace(text, fromText, toText);\r
- }\r
- \r
- protected String getLineSeparator() {\r
- return SimpleSystemUtil.getLineSeparator();\r
- }\r
-\r
- // -----------------------------------------------------\r
- // Assert Object\r
- // -------------\r
- protected void assertObjectNotNull(String variableName, Object value) {\r
- SimpleAssertUtil.assertObjectNotNull(variableName, value);\r
- }\r
-\r
- // -----------------------------------------------------\r
- // Assert String\r
- // -------------\r
- protected void assertStringNotNullAndNotTrimmedEmpty(String variableName, String value) {\r
- SimpleAssertUtil.assertStringNotNullAndNotTrimmedEmpty(variableName, value);\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.cbean.sqlclause;\r
-\r
-import java.io.Serializable;\r
-import java.util.Map;\r
-import java.util.List;\r
-import java.util.ArrayList;\r
-import java.util.Iterator;\r
-import java.util.StringTokenizer;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class OrderByClause implements Serializable {\r
-\r
- /** Serial version UID. (Default) */\r
- private static final long serialVersionUID = 1L;\r
-\r
- // =====================================================================================\r
- // Attribute\r
- // =========\r
- protected List<OrderByElement> _orderByList = new ArrayList<OrderByElement>();\r
-\r
- // =====================================================================================\r
- // Constructor\r
- // ===========\r
- /**\r
- * Constructor.\r
- */\r
- public OrderByClause() {\r
- }\r
-\r
- // =====================================================================================\r
- // Manipulation\r
- // ============\r
- /**\r
- * Add order-by element.\r
- * @param orderByElement Order-by element. (NotNull)\r
- */\r
- public void addOrderByElement(OrderByElement orderByElement) {\r
- _orderByList.add(orderByElement);\r
- }\r
-\r
- /**\r
- * Insert first order-by element .\r
- * @param orderByElement Order-by element. (NotNull)\r
- */\r
- public void insertFirstOrderByElement(OrderByElement orderByElement) {\r
- _orderByList.add(0, orderByElement);\r
- }\r
-\r
- public void reverseAll() {\r
- for (Iterator<OrderByElement> ite = _orderByList.iterator(); ite.hasNext(); ) {\r
- ite.next().reverse();\r
- }\r
- }\r
-\r
- public void exchangeFirstOrderByElementForLastOne() {\r
- if (_orderByList.size() > 1) {\r
- final OrderByElement first = _orderByList.get(0);\r
- final OrderByElement last = _orderByList.get(_orderByList.size() - 1);\r
- _orderByList.set(0, last);\r
- _orderByList.set(_orderByList.size() - 1, first);\r
- }\r
- }\r
- \r
- public void addNullsFirstToPreviousOrderByElement(OrderByNullsSetupper filter) {\r
- if (_orderByList.isEmpty()) {\r
- return;\r
- }\r
- final OrderByElement last = _orderByList.get(_orderByList.size() - 1);\r
- last.setOrderByNullsSetupper(filter, true);\r
- }\r
- \r
- public void addNullsLastToPreviousOrderByElement(OrderByNullsSetupper filter) {\r
- if (_orderByList.isEmpty()) {\r
- return;\r
- }\r
- final OrderByElement last = _orderByList.get(_orderByList.size() - 1);\r
- last.setOrderByNullsSetupper(filter, false);\r
- }\r
- \r
- public static interface OrderByNullsSetupper {\r
- public String setup(String columnName, String orderByElementClause, boolean nullsFirst);\r
- }\r
-\r
- // =====================================================================================\r
- // Order-By Expression\r
- // ===================\r
- public List<OrderByElement> getOrderByList() {\r
- return _orderByList;\r
- }\r
-\r
- public String getOrderByClause() {\r
- return getOrderByClause(null);\r
- }\r
-\r
- public String getOrderByClause(Map<String, String> selectClauseRealColumnAliasMap) {\r
- if (_orderByList.isEmpty()) {\r
- return "";\r
- }\r
- final StringBuffer sb = new StringBuffer();\r
- final String delimiter = ", ";\r
- for (final Iterator<OrderByElement> ite = _orderByList.iterator(); ite.hasNext(); ) {\r
- final OrderByElement element = ite.next();\r
- sb.append(delimiter);\r
- if (selectClauseRealColumnAliasMap != null) {\r
- sb.append(element.getElementClause(selectClauseRealColumnAliasMap));\r
- } else {\r
- sb.append(element.getElementClause());\r
- }\r
- }\r
- sb.delete(0, delimiter.length()).insert(0, "order by ");\r
- return sb.toString();\r
- }\r
-\r
- public boolean isSameOrderByColumn(String orderByProperty) {\r
- final List<String> orderByList = new ArrayList<String>();\r
- {\r
- final StringTokenizer st = new StringTokenizer(orderByProperty, "/");\r
- while (st.hasMoreElements()) {\r
- orderByList.add(st.nextToken());\r
- }\r
- }\r
- if (_orderByList.size() != orderByList.size()) {\r
- return false;\r
- }\r
- int count = 0;\r
- for (final Iterator<String> ite = orderByList.iterator(); ite.hasNext(); ) {\r
- final String columnFullName = ite.next();\r
- final OrderByElement element = (OrderByElement)_orderByList.get(count);\r
- if (!element.getColumnFullName().equals(columnFullName)) {\r
- return false;\r
- }\r
- count++;\r
- }\r
- return true;\r
- }\r
-\r
- // =====================================================================================\r
- // First Element\r
- // =============\r
- public boolean isFirstElementAsc() {\r
- if (isEmpty()) {\r
- String msg = "This order-by clause is empty: " + toString();\r
- throw new IllegalStateException(msg);\r
- }\r
- final OrderByElement element = (OrderByElement)_orderByList.get(0);\r
- return element.isAsc();\r
- }\r
-\r
- public boolean isFirstElementDesc() {\r
- return !isFirstElementAsc();\r
- }\r
-\r
- public boolean isSameAsFirstElementAliasName(String expectedAliasName) {\r
- if (isEmpty()) {\r
- String msg = "This order-by clause is empty: " + toString();\r
- throw new RuntimeException(msg);\r
- }\r
- OrderByElement element = (OrderByElement)_orderByList.get(0);\r
- String actualAliasName = element.getAliasName();\r
- if (actualAliasName != null && expectedAliasName != null) {\r
- return actualAliasName.equalsIgnoreCase(expectedAliasName);\r
- } else {\r
- return false;\r
- }\r
- }\r
-\r
- /**\r
- * @param expectedColumnName Expected column-name. (Nullable)\r
- * @return Determination.\r
- */\r
- public boolean isSameAsFirstElementColumnName(String expectedColumnName) {\r
- if (isEmpty()) {\r
- String msg = "This order-by clause is empty: " + toString();\r
- throw new RuntimeException(msg);\r
- }\r
- OrderByElement element = (OrderByElement)_orderByList.get(0);\r
- String actualColumnName = element.getColumnName();\r
- if (actualColumnName != null && expectedColumnName != null) {\r
- return actualColumnName.equalsIgnoreCase(expectedColumnName);\r
- } else {\r
- return false;\r
- }\r
- }\r
-\r
- /**\r
- * @param expectedAliasName Expected alias-name. (Nullable)\r
- * @return Determination.\r
- */\r
- public boolean isSameAsFirstElementRegisteredAliasName(String expectedAliasName) {\r
- if (isEmpty()) {\r
- String msg = "This order-by clause is empty: " + toString();\r
- throw new RuntimeException(msg);\r
- }\r
- OrderByElement element = (OrderByElement)_orderByList.get(0);\r
- String actualAliasName = element.getRegisteredAliasName();\r
- if (actualAliasName != null && expectedAliasName != null) {\r
- return actualAliasName.equalsIgnoreCase(expectedAliasName);\r
- } else {\r
- return false;\r
- }\r
- }\r
-\r
- /**\r
- * @param expectedColumnName Expected column-name. (Nullable)\r
- * @return Determination.\r
- */\r
- public boolean isSameAsFirstElementRegisteredColumnName(String expectedColumnName) {\r
- if (isEmpty()) {\r
- String msg = "This order-by clause is empty: " + toString();\r
- throw new RuntimeException(msg);\r
- }\r
- OrderByElement element = (OrderByElement)_orderByList.get(0);\r
- String actualColumnName = element.getRegisteredColumnName();\r
- if (actualColumnName != null && expectedColumnName != null) {\r
- return actualColumnName.equalsIgnoreCase(expectedColumnName);\r
- } else {\r
- return false;\r
- }\r
- }\r
-\r
- // =====================================================================================\r
- // Delegate of List\r
- // ================\r
- /**\r
- * Is empty?\r
- * @return Determination.\r
- */\r
- public boolean isEmpty() {\r
- return _orderByList.isEmpty();\r
- }\r
-\r
- /**\r
- * Get iterator of order-by list.\r
- * @return Determination.\r
- */\r
- public Iterator<OrderByElement> iterator() {\r
- return _orderByList.iterator();\r
- }\r
-\r
- /**\r
- * Clear order-by list.\r
- */\r
- public void clear() {\r
- _orderByList.clear();\r
- }\r
-\r
- // =====================================================================================\r
- // Basic Override\r
- // ==============\r
- /**\r
- * This method overrides the method that is declared at super.\r
- * @return The view string of all-columns value. (NotNUll)\r
- */\r
- public String toString() {\r
- return _orderByList.toString();\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.cbean.sqlclause;\r
-\r
-import java.io.Serializable;\r
-import java.util.Map;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.util.SimpleSystemUtil;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class OrderByElement implements Serializable {\r
-\r
- /** Serial version UID. (Default) */\r
- private static final long serialVersionUID = 1L;\r
-\r
- // =====================================================================================\r
- // Attribute\r
- // =========\r
- /** The value of alias name. */\r
- protected String _aliasName;\r
-\r
- /** The value of column name. */\r
- protected String _columnName;\r
-\r
- /** The value of registered alias name. */\r
- protected String _registeredAliasName;\r
-\r
- /** The value of registered column name. */\r
- protected String _registeredColumnName;\r
-\r
- /** The value of ascDesc. */\r
- protected String _ascDesc = "asc";\r
- \r
- /** The setupper of order-by nulls. */\r
- protected OrderByClause.OrderByNullsSetupper _orderByNullsSetupper;\r
- \r
- /** Is nulls ordered first? */\r
- protected boolean _nullsFirst;\r
-\r
- // =====================================================================================\r
- // Manipulation\r
- // ============\r
- public void setupAsc() {\r
- _ascDesc = "asc";\r
- }\r
-\r
- public void setupDesc() {\r
- _ascDesc = "desc";\r
- }\r
-\r
- public void reverse() {\r
- if (_ascDesc == null) {\r
- String msg = "The attribute[ascDesc] should not be null.";\r
- throw new IllegalStateException(msg);\r
- }\r
- if (_ascDesc.equals("asc")) {\r
- _ascDesc = "desc";\r
- } else if (_ascDesc.equals("desc")) {\r
- _ascDesc = "asc";\r
- } else {\r
- String msg = "The attribute[ascDesc] should be asc or desc: but ascDesc=" + _ascDesc;\r
- throw new IllegalStateException(msg);\r
- }\r
- }\r
-\r
- // =====================================================================================\r
- // Order-By Expression\r
- // ===================\r
- public boolean isAsc() {\r
- if (_ascDesc == null) {\r
- String msg = "The attribute[ascDesc] should not be null.";\r
- throw new IllegalStateException(msg);\r
- }\r
- if (_ascDesc.equals("asc")) {\r
- return true;\r
- } else if (_ascDesc.equals("desc")) {\r
- return false;\r
- } else {\r
- String msg = "The attribute[ascDesc] should be asc or desc: but ascDesc=" + _ascDesc;\r
- throw new IllegalStateException(msg);\r
- }\r
- }\r
-\r
- public String getColumnFullName() {\r
- final StringBuilder sb = new StringBuilder();\r
- if (_aliasName != null) {\r
- sb.append(_aliasName).append(".");\r
- }\r
- if (_columnName == null) {\r
- String msg = "The attribute[columnName] should not be null.";\r
- throw new IllegalStateException(msg);\r
- }\r
- sb.append(_columnName);\r
- return sb.toString();\r
- }\r
-\r
- public String getElementClause() {\r
- if (_ascDesc == null) {\r
- String msg = "The attribute[ascDesc] should not be null.";\r
- throw new IllegalStateException(msg);\r
- }\r
- final StringBuilder sb = new StringBuilder();\r
- sb.append(getColumnFullName()).append(" ").append(_ascDesc);\r
- if (_orderByNullsSetupper != null) {\r
- return _orderByNullsSetupper.setup(getColumnFullName(), sb.toString(), _nullsFirst);\r
- } else {\r
- return sb.toString();\r
- }\r
- }\r
-\r
- public String getElementClause(Map<String, String> selectClauseRealColumnAliasMap) {\r
- if (selectClauseRealColumnAliasMap == null) {\r
- String msg = "The argument[selectClauseRealColumnAliasMap] should not be null.";\r
- throw new IllegalArgumentException(msg);\r
- }\r
- if (_ascDesc == null) {\r
- String msg = "The attribute[ascDesc] should not be null.";\r
- throw new IllegalStateException(msg);\r
- }\r
- final StringBuilder sb = new StringBuilder();\r
- final String columnAlias = selectClauseRealColumnAliasMap.get(getColumnFullName());\r
- if (columnAlias == null || columnAlias.trim().length() == 0) {\r
- throwOrderByColumnNotFoundException(getColumnFullName(), selectClauseRealColumnAliasMap);\r
- }\r
- sb.append(columnAlias).append(" ").append(_ascDesc);\r
- if (_orderByNullsSetupper != null) {\r
- return _orderByNullsSetupper.setup(columnAlias, sb.toString(), _nullsFirst);\r
- } else {\r
- return sb.toString();\r
- }\r
- }\r
-\r
- protected void throwOrderByColumnNotFoundException(String columnName, Map<String, String> selectClauseRealColumnAliasMap) {\r
- String msg = "Look! Read the message below." + getLineSeparator();\r
- msg = msg + "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *" + getLineSeparator();\r
- msg = msg + "The column for order-by was Not Found in select-clause!" + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Advice]" + getLineSeparator();\r
- msg = msg + "If you use 'union()' or 'unionAll()', Check your condition-bean!" + getLineSeparator();\r
- msg = msg + "Order-by for union can use only columns on select-clause." + getLineSeparator();\r
- msg = msg + "So the rule when using union is little difference from the one when NOT using." + getLineSeparator();\r
- msg = msg + " For example:" + getLineSeparator();\r
- msg = msg + " [before (x)]" + getLineSeparator();\r
- msg = msg + " AaaCB cb = new AaaCB();" + getLineSeparator();\r
- msg = msg + " cb.query().setXxx...();" + getLineSeparator();\r
- msg = msg + " {" + getLineSeparator();\r
- msg = msg + " AaaCB unionCB = new AaaCB();" + getLineSeparator();\r
- msg = msg + " unionCB.query().setXxx...();" + getLineSeparator();\r
- msg = msg + " cb.union(unionCB.query());" + getLineSeparator();\r
- msg = msg + " }" + getLineSeparator();\r
- msg = msg + " cb.query().queryBbb().addOrderBy_BbbName_Asc();// *NG!" + getLineSeparator();\r
- msg = msg + " " + getLineSeparator();\r
- msg = msg + " [after (o)]" + getLineSeparator();\r
- msg = msg + " AaaCB cb = new AaaCB();" + getLineSeparator();\r
- msg = msg + " cb.setupSelect_Bbb();// *Point!" + getLineSeparator();\r
- msg = msg + " cb.query().setXxx...();" + getLineSeparator();\r
- msg = msg + " {" + getLineSeparator();\r
- msg = msg + " AaaCB unionCB = new AaaCB();" + getLineSeparator();\r
- msg = msg + " unionCB.query().setXxx...();" + getLineSeparator();\r
- msg = msg + " cb.union(unionCB.query());" + getLineSeparator();\r
- msg = msg + " }" + getLineSeparator();\r
- msg = msg + " cb.query().queryBbb().addOrderBy_BbbName_Asc();// *OK!" + getLineSeparator();\r
- msg = msg + " " + getLineSeparator();\r
- msg = msg + "Or else if you DON'T use 'union()' or 'unionAll()', This is the Framework Exception!" + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Target Column]" + getLineSeparator();\r
- msg = msg + columnName + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Internal Object]" + getLineSeparator();\r
- msg = msg + "selectClauseRealColumnAliasMap=" + selectClauseRealColumnAliasMap + getLineSeparator();\r
- msg = msg + "* * * * * * * * * */" + getLineSeparator();\r
- throw new IllegalStateException(msg);\r
- }\r
-\r
- protected String getLineSeparator() {\r
- return SimpleSystemUtil.getLineSeparator();\r
- }\r
-\r
- // =====================================================================================\r
- // Basic Override\r
- // ==============\r
- /**\r
- * This method overrides the method that is declared at super.\r
- * @return The view-string of all-columns value. (NotNull)\r
- */\r
- public String toString() {\r
- final StringBuilder sb = new StringBuilder();\r
- sb.append("{aliasName=").append(_aliasName);\r
- sb.append(" columnName=").append(_columnName);\r
- sb.append(" registeredAliasName=").append(_registeredAliasName);\r
- sb.append(" registeredColumnName=").append(_registeredColumnName);\r
- sb.append(" ascDesc=").append(_ascDesc).append("}");\r
- return sb.toString();\r
- }\r
-\r
- // =====================================================================================\r
- // Accessor\r
- // ========\r
- public String getAliasName() {\r
- return _aliasName;\r
- }\r
- public String getColumnName() {\r
- return _columnName;\r
- }\r
- public String getRegisteredAliasName() {\r
- return _registeredAliasName;\r
- }\r
- public String getRegisteredColumnName() {\r
- return _registeredColumnName;\r
- }\r
- public String getAscDesc() {\r
- return _ascDesc;\r
- }\r
- public void setAliasName(String value) {\r
- _aliasName = value;\r
- }\r
- public void setColumnName(String value) {\r
- _columnName = value;\r
- }\r
- public void setRegisteredAliasName(String value) {\r
- _registeredAliasName = value;\r
- }\r
- public void setRegisteredColumnName(String value) {\r
- _registeredColumnName = value;\r
- }\r
- public void setAscDesc(String value) {\r
- _ascDesc = value;\r
- }\r
- public void setOrderByNullsSetupper(OrderByClause.OrderByNullsSetupper value, boolean nullsFirst) {\r
- _orderByNullsSetupper = value;\r
- _nullsFirst = nullsFirst;\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.cbean.sqlclause;\r
-\r
-import java.util.Map;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.ckey.ConditionKey;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.coption.ConditionOption;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.cvalue.ConditionValue;\r
-\r
-/**\r
- * The interface of SQL-clause.\r
- * \r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public interface SqlClause {\r
-\r
- // =====================================================================================\r
- // Clause\r
- // ======\r
- // -----------------------------------------------------\r
- // Complete Clause\r
- // ---------------\r
- /**\r
- * Get the clause of all parts.\r
- * <pre>\r
- * # select [base-table-columns], [join-table-columns]\r
- * # from [base-table] left outer join [join-table] [join-alias] on [join-condition]\r
- * # where [base-table].[column] = [value] and [join-alias].[column] is null\r
- * # order by [base-table].[column] asc, [join-alias].[column] desc\r
- * # for update\r
- * </pre>\r
- * @return The clause of all parts. (NotNull)\r
- */\r
- public String getClause();\r
-\r
- /**\r
- * Get clause of all parts as PK-only.\r
- * <pre>\r
- * # select [base-table-columns], [join-table-columns]\r
- * # from [base-table] left outer join [join-table] [join-alias] on [join-condition]\r
- * # where [base-table].[column] = [value] and [join-alias].[column] is null\r
- * # order by [base-table].[column] asc, [join-alias].[column] desc\r
- * # for update\r
- * </pre>\r
- * @return The clause of all parts as PK-Only. (NotNull)\r
- */\r
- public String getClausePKOnly();\r
-\r
- // -----------------------------------------------------\r
- // Fragment Clause\r
- // ---------------\r
- /**\r
- * Get from-where clause without select and orderBy and sqlSuffix. \r
- * For subQuery and selectCount.\r
- * <p>\r
- * You should handle UnionSelectClauseMark and UnionWhereClauseMark and UnionWhereFirstConditionMark in clause.\r
- * </p>\r
- * @return The 'from-where' clause(contains union) without 'select' and 'orderBy' and 'sqlSuffix'. (NotNull)\r
- */\r
- public String getClauseFromWhereWithUnionTemplate();\r
- \r
- /**\r
- * Get from-where clause without select and orderBy and sqlSuffix as template. \r
- * For subQuery and selectCount.\r
- * <p>\r
- * You should handle UnionSelectClauseMark and UnionWhereClauseMark and UnionWhereFirstConditionMark\r
- * and WhereClauseMark and WhereFirstConditionMark in clause.\r
- * </p>\r
- * @return The 'from-where' clause(contains union) without 'select' and 'orderBy' and 'sqlSuffix'. (NotNull)\r
- */\r
- public String getClauseFromWhereWithWhereUnionTemplate();\r
-\r
- // =====================================================================================\r
- // Clause Parts\r
- // ============\r
- /**\r
- * Get the clause of 'select'. This is an internal method.\r
- * @return The clause of select. {[select ...] from table...} (NotNull)\r
- */\r
- public String getSelectClause();\r
- \r
- /**\r
- * Get The clause of 'select' as PK-only. This is an internal method.\r
- * @return The clause of select PK-only. {[select ...] from table...} (NotNull)\r
- */\r
- public String getSelectClausePKOnly();\r
- \r
- /**\r
- * Get the hint of 'select'. This is an internal method.\r
- * @return The hint of 'select'. {select [select-hint] * from table...} (NotNull)\r
- */\r
- public String getSelectHint();\r
-\r
- /**\r
- * Get the clause of included-select-column. This is an internal method.\r
- * @return The clause of included-select-column. {select ... , [included-select-column clause] from table...} (NotNull)\r
- */\r
- public String getIncludedSelectColumnClause();\r
-\r
- /**\r
- * Get the clause of 'from'. This is an internal method.\r
- * @return The clause of 'from'. (NotNull)\r
- */\r
- public String getFromClause();\r
-\r
- /**\r
- * Get the clause of from-base-table. This is an internal method.\r
- * @return The hint of from-base-table. {select * from table [from-base-table-hint] where ...} (NotNull)\r
- */\r
- public String getFromBaseTableHint();\r
-\r
- /**\r
- * Get the hint of 'from'. This is an internal method.\r
- * @return The hint of 'from'. {select * from table left outer join ... on ... [from-hint] where ...} (NotNull)\r
- */\r
- public String getFromHint();\r
-\r
- /**\r
- * Get the clause of 'where'. This is an internal method.\r
- * @return The clause of 'where'. (NotNull)\r
- */\r
- public String getWhereClause();\r
-\r
- /**\r
- * Get the clause of 'order-by'. This is an internal method.\r
- * @return The clause of 'order-by'. (NotNull)\r
- */\r
- public String getOrderByClause();\r
-\r
- /**\r
- * Get the suffix of SQL. This is an internal method.\r
- * @return The suffix of SQL. {select * from table where ... order by ... [sql-suffix]} (NotNull)\r
- */\r
- public String getSqlSuffix();\r
-\r
- // ===================================================================================\r
- // Copy Parts\r
- // ==========\r
- /**\r
- * Copy included-select-column.\r
- * @param sqlClause SQL-clause. (NotNull)\r
- */\r
- public void copyIncludedSelectColumn(SqlClause sqlClause);\r
-\r
- // ===================================================================================\r
- // SelectedSelectColumn\r
- // ====================\r
- /**\r
- * Register selected-select-column.\r
- * @param foreignTableAliasName The alias name of foreign table. (NotNull)\r
- * @param localTableName The table name of local. (NotNull)\r
- * @param foreignPropertyName The property name of foreign table. (NotNull)\r
- * @param localRelationPath The path of local relation. (Nullable)\r
- */\r
- public void registerSelectedSelectColumn(String foreignTableAliasName\r
- , String localTableName\r
- , String foreignPropertyName\r
- , String localRelationPath);\r
- \r
- // ===================================================================================\r
- // IncludedSelectColumn\r
- // ====================\r
- /**\r
- * Ignore included-select-column.\r
- */\r
- public void ignoreIncludedSelectColumn();\r
-\r
- /**\r
- * Make included-select-column effective.\r
- */\r
- public void makeIncludedSelectColumnEffective();\r
-\r
- /**\r
- * Register included-select-column.\r
- * @param aliasName The alias name of the included-select-column. (NotNull)\r
- * @param realColumnName The real column name of the included-select-column. (NotNull)\r
- */\r
- public void registerIncludedSelectColumn(String aliasName, String realColumnName);\r
-\r
- // ===================================================================================\r
- // OuterJoin\r
- // =========\r
- /**\r
- * Register outer-join.\r
- * @param joinTableName The name of join table. {left outer join [joinTableName]} (NotNull)\r
- * @param aliasName The alias name of join table. {left outer join joinTableName [aliasName]} (NotNull and Unique per invoking method)\r
- * @param joinOnMap Map that has conditions of on-clause. (NotNull)\r
- */\r
- public void registerOuterJoin(String joinTableName, String aliasName, Map<String, String> joinOnMap);\r
-\r
- // ===================================================================================\r
- // Where\r
- // =====\r
- /**\r
- * Register 'where' clause.\r
- * @param columnFullName The full name of column. {[table-name].[column-name]}. (NotNull)\r
- * @param key Condition-key. (NotNull)\r
- * @param value Condition-value. (NotNull)\r
- */\r
- public void registerWhereClause(String columnFullName, ConditionKey key, ConditionValue value);\r
-\r
- /**\r
- * Register 'where' clause.\r
- * @param columnFullName The full name of column. {[table-name].[column-name]}. (NotNull)\r
- * @param key Condition-key. (NotNull)\r
- * @param value Condition-value. (NotNull)\r
- * @param option Condition-option. (NotNull)\r
- */\r
- public void registerWhereClause(String columnFullName, ConditionKey key, ConditionValue value, ConditionOption option);\r
-\r
- /**\r
- * Register 'where' clause.\r
- * @param clause The clause of 'where'. (NotNull)\r
- */\r
- public void registerWhereClause(String clause);\r
-\r
- /**\r
- * Exchange first The clause of 'where' for last one.\r
- */\r
- public void exchangeFirstWhereClauseForLastOne();\r
-\r
- // ===================================================================================\r
- // InlineWhere\r
- // ===========\r
- public void registerBaseTableInlineWhereClause(String columnName, ConditionKey key, ConditionValue value);\r
- public void registerBaseTableInlineWhereClause(String columnName, ConditionKey key, ConditionValue value, ConditionOption option);\r
- public void registerBaseTableInlineWhereClause(String value);\r
- public void registerOuterJoinInlineWhereClause(String aliasName, String columnName, ConditionKey key, ConditionValue value, boolean onClauseInline);\r
- public void registerOuterJoinInlineWhereClause(String aliasName, String columnName, ConditionKey key, ConditionValue value, ConditionOption option, boolean onClauseInline);\r
- public void registerOuterJoinInlineWhereClause(String aliasName, String value, boolean onClauseInline);\r
-\r
- // ===================================================================================\r
- // AdditionalConditionAsOr\r
- // =======================\r
- public void makeAdditionalConditionAsOrEffective();\r
- public void ignoreAdditionalConditionAsOr();\r
-\r
- // ===================================================================================\r
- // OrderBy\r
- // =======\r
- public OrderByClause getSqlComponentOfOrderByClause();\r
- public SqlClause clearOrderBy();\r
- public SqlClause ignoreOrderBy();\r
- public SqlClause makeOrderByEffective();\r
- \r
- /**\r
- * @param orderByProperty Order-by-property. 'aliasName.columnName/aliasName.columnName/...' (NotNull)\r
- * @param registeredOrderByProperty Registered-order-by-property. ([table-name].[column-name]) (Nullable)\r
- * @param ascOrDesc Is it ascend or descend?\r
- */\r
- public void registerOrderBy(String orderByProperty, String registeredOrderByProperty, boolean ascOrDesc);\r
- \r
- /**\r
- * @param orderByProperty Order-by-property. 'aliasName.columnName/aliasName.columnName/...' (NotNull)\r
- * @param registeredOrderByProperty Registered-order-by-property. ([table-name].[column-name]) (Nullable)\r
- * @param ascOrDesc Is it ascend or descend?\r
- */\r
- public void reverseOrderBy_Or_OverrideOrderBy(String orderByProperty, String registeredOrderByProperty, boolean ascOrDesc);\r
-\r
- public void addNullsFirstToPreviousOrderBy();\r
- public void addNullsLastToPreviousOrderBy();\r
- \r
- // ===================================================================================\r
- // Union\r
- // =====\r
- public void registerUnionQuery(String unionClause, boolean unionAll);\r
-\r
- // ===================================================================================\r
- // FetchScope\r
- // ==========\r
- /**\r
- * Fetch first.\r
- * @param fetchSize Fetch-size. (NotMinus)\r
- * @return this. (NotNull)\r
- */\r
- public SqlClause fetchFirst(int fetchSize);\r
-\r
- /**\r
- * Fetch scope.\r
- * @param fetchStartIndex Fetch-start-index. 0 origin. (NotMinus)\r
- * @param fetchSize Fetch-size. (NotMinus)\r
- * @return this. (NotNull)\r
- */\r
- public SqlClause fetchScope(int fetchStartIndex, int fetchSize);\r
-\r
- /**\r
- * Fetch page.\r
- * <p>\r
- * When you invoke this, it is normally necessary to invoke 'fetchFirst()' or 'fetchScope()' ahead of that.\r
- * But you also can use default-fetch-size without invoking 'fetchFirst()' or 'fetchScope()'.\r
- * If you invoke this, your SQL returns [fetch-size] records from [fetch-start-index] calculated by [fetch-page-number].\r
- * </p>\r
- * @param fetchPageNumber Fetch-page-number. 1 origin. (NotMinus & NotZero: If minus or zero, set one.)\r
- * @return this. (NotNull)\r
- */\r
- public SqlClause fetchPage(int fetchPageNumber);\r
-\r
- /**\r
- * Get fetch start index.\r
- * @return Fetch start index.\r
- */\r
- public int getFetchStartIndex();\r
-\r
- /**\r
- * Get fetch size.\r
- * @return Fetch size.\r
- */\r
- public int getFetchSize();\r
-\r
- /**\r
- * Get fetch page number.\r
- * @return Fetch page number.\r
- */\r
- public int getFetchPageNumber();\r
-\r
- /**\r
- * Get page start index.\r
- * @return Page start index. 0 origin. (NotMinus)\r
- */\r
- public int getPageStartIndex();\r
-\r
- /**\r
- * Get page end index.\r
- * @return Page end index. 0 origin. (NotMinus)\r
- */\r
- public int getPageEndIndex();\r
-\r
- /**\r
- * Is fetch scope effective?\r
- * @return Determiantion.\r
- */\r
- public boolean isFetchScopeEffective();\r
-\r
- /**\r
- * Ignore fetch-scope.\r
- * @return this. (NotNull)\r
- */\r
- public SqlClause ignoreFetchScope();\r
-\r
- /**\r
- * Make fetch-scope effective.\r
- * @return this. (NotNull)\r
- */\r
- public SqlClause makeFetchScopeEffective();\r
-\r
- /**\r
- * Is fetch start index supported?\r
- * @return Determination.\r
- */\r
- public boolean isFetchStartIndexSupported();\r
-\r
- /**\r
- * Is fetch size supported?\r
- * @return Determination.\r
- */\r
- public boolean isFetchSizeSupported();\r
-\r
- // ===================================================================================\r
- // Fetch Narrowing\r
- // ===============\r
- /**\r
- * Is fetch-narrowing effective?\r
- * @return Determiantion.\r
- */\r
- public boolean isFetchNarrowingEffective();\r
-\r
- /**\r
- * Get fetch-narrowing skip-start-index.\r
- * @return Skip-start-index.\r
- */\r
- public int getFetchNarrowingSkipStartIndex();\r
-\r
- /**\r
- * Get fetch-narrowing loop-count.\r
- * @return Loop-count.\r
- */\r
- public int getFetchNarrowingLoopCount();\r
-\r
- // ===================================================================================\r
- // Lock\r
- // ====\r
- /**\r
- * Lock for update.\r
- * <p>\r
- * If you invoke this, your SQL lock target records for update.\r
- * It depends whether this method supports this on the database type.\r
- * </p>\r
- * @return this. (NotNull)\r
- */\r
- public SqlClause lockForUpdate();\r
-\r
- // ===================================================================================\r
- // Resolver\r
- // ========\r
- /**\r
- * Resolve join alias name.\r
- * @param relationPath Relation path. (NotNull)\r
- * @param cqNestNo The nest no of condition query.\r
- * @return Resolved join alias name. (NotNull)\r
- */\r
- public String resolveJoinAliasName(String relationPath, int cqNestNo);\r
-\r
- /**\r
- * Resolve nest level expression.\r
- * @param name Name. (NotNull)\r
- * @param cqNestNo The nest no of condition query.\r
- * @return Resolved name about nest level. (NotNull)\r
- */\r
- public String resolveNestLevelExpression(String name, int cqNestNo);\r
-\r
- /**\r
- * Resolve relation no.\r
- * @param baseTableName The table name of base. (NotNull)\r
- * @param foreignPropertyName The property name of foreign. (NotNull)\r
- * @return Resolved relation no.\r
- */\r
- public int resolveRelationNo(String baseTableName, String foreignPropertyName);\r
-\r
- // ===================================================================================\r
- // Table Alias Info\r
- // ================\r
- public String getLocalTableAliasName();\r
- public String getForeignTableAliasPrefix();\r
-\r
- // ===================================================================================\r
- // Template Mark\r
- // =============\r
- public String getWhereClauseMark();\r
- public String getWhereFirstConditionMark();\r
- public String getUnionSelectClauseMark();\r
- public String getUnionWhereClauseMark();\r
- public String getUnionWhereFirstConditionMark();\r
- \r
- // ===================================================================================\r
- // Where Clause Simple Filter\r
- // ==========================\r
- public void addWhereClauseSimpleFilter(WhereClauseSimpleFilter whereClauseSimpleFilter);\r
- \r
- // ===================================================================================\r
- // Selected Foreign Info\r
- // =====================\r
- public boolean isSelectedForeignInfoEmpty();\r
- public boolean hasSelectedForeignInfo(String relationPath);\r
- public void registerSelectedForeignInfo(String relationPath, String foreignPropertyName);\r
- \r
- // ===================================================================================\r
- // Format Clause\r
- // =============\r
- public boolean isFormatClauseEffective();\r
- public void makeFormatClauseEffective();\r
- \r
- // ===================================================================================\r
- // Sub Query Indent\r
- // ================\r
- public String resolveSubQueryBeginMark(String subQueryIdentity);\r
- public String resolveSubQueryEndMark(String subQueryIdentity);\r
- public String filterSubQueryIndent(String sql);\r
- \r
- // [DBFlute-0.7.4]\r
- // ===================================================================================\r
- // Specification\r
- // =============\r
- public void specifySelectColumn(String tableAliasName, String columnName);\r
- public void specifyDeriveSubQuery(String aliasName, String deriveSubQuery);\r
- public boolean hasSpecifiedDeriveSubQuery(String aliasName);\r
- public String getSpecifiedColumnNameAsOne();\r
- public void clearSpecifiedSelectColumn();\r
- \r
- // [DBFlute-0.7.5]\r
- // ===================================================================================\r
- // Query Update\r
- // ============\r
- /**\r
- * @param columnParameterMap The map of column parameters. (NotNull)\r
- * @return The clause of query update. (Nullable: If columnParameterMap is empty, return null)\r
- */\r
- public String getClauseQueryUpdate(Map<String, String> columnParameterMap);\r
- public String getClauseQueryDelete();\r
-\r
- // [DBFlute-0.7.7]\r
- // ===================================================================================\r
- // Unique Constraint\r
- // =================\r
- /**\r
- * Is the SQLException from unique constraint? {Use both SQLState and ErrorCode}\r
- * @param sqlState SQLState of the SQLException. (Nullable)\r
- * @param errorCode ErrorCode of the SQLException. (Nullable)\r
- * @return Is the SQLException from unique constraint?\r
- */ \r
- public boolean isUniqueConstraintException(String sqlState, Integer errorCode);\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.cbean.sqlclause;\r
-\r
-\r
-/**\r
- * SqlClause for DB2.\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class SqlClauseDb2 extends AbstractSqlClause {\r
-\r
- // ===================================================================================\r
- // Attribute\r
- // =========\r
- /** String of fetch-first as sql-suffix. */\r
- protected String _fetchFirstSqlSuffix = "";\r
-\r
- /** String of lock as from-hint. */\r
- protected String _lockSqlSuffix = "";\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- /**\r
- * Constructor.\r
- * @param tableName Table name. (NotNull)\r
- **/\r
- public SqlClauseDb2(String tableName) {\r
- super(tableName);\r
- }\r
-\r
- // ===================================================================================\r
- // OrderBy Override\r
- // ================\r
- @Override\r
- protected OrderByClause.OrderByNullsSetupper createOrderByNullsSetupper() {\r
- return createOrderByNullsSetupperByCaseWhen();\r
- }\r
-\r
- // ===================================================================================\r
- // FetchScope Override\r
- // ===================\r
- /**\r
- * The implementation.\r
- */\r
- protected void doFetchFirst() {\r
- if (isFetchSizeSupported()) {\r
- _fetchFirstSqlSuffix = " fetch first " + getFetchSize() + " rows only";\r
- }\r
- }\r
-\r
- /**\r
- * The implementation. {Unsupported!}\r
- */\r
- protected void doFetchPage() {\r
- if (isFetchSizeSupported()) {\r
- if (isFetchStartIndexSupported()) {\r
- _fetchFirstSqlSuffix = " fetch first " + getFetchSize() + " rows only";\r
- } else {\r
- _fetchFirstSqlSuffix = " fetch first " + getPageEndIndex() + " rows only";\r
- }\r
- }\r
- }\r
-\r
- /**\r
- * The implementation. {Unsupported!}\r
- */\r
- protected void doClearFetchPageClause() {\r
- _fetchFirstSqlSuffix = "";\r
- }\r
-\r
- /**\r
- * The override.\r
- * @return Determination.\r
- */\r
- public boolean isFetchStartIndexSupported() {\r
- return false;\r
- }\r
-\r
- /**\r
- * The implementation.\r
- * @return this. (NotNull)\r
- */\r
- public SqlClause lockForUpdate() {\r
- _lockSqlSuffix = " for update with RS";\r
- return this;\r
- }\r
-\r
- /**\r
- * The implementation.\r
- * @return Select-hint. (NotNull)\r
- */\r
- protected String createSelectHint() {\r
- return "";\r
- }\r
-\r
- /**\r
- * The implementation.\r
- * @return From-base-table-hint. {select * from table [from-base-table-hint] where ...} (NotNull)\r
- */\r
- protected String createFromBaseTableHint() {\r
- return "";\r
- }\r
-\r
- /**\r
- * The implementation.\r
- * @return From-hint. (NotNull)\r
- */\r
- protected String createFromHint() {\r
- return "";\r
- }\r
-\r
- /**\r
- * The implementation.\r
- * @return Sql-suffix. (NotNull)\r
- */\r
- protected String createSqlSuffix() {\r
- return _fetchFirstSqlSuffix + _lockSqlSuffix;\r
- }\r
-\r
- // [DBFlute-0.7.7]\r
- // ===================================================================================\r
- // Unique Constraint Override\r
- // ==========================\r
- @Override\r
- public boolean isUniqueConstraintException(String sqlState, Integer errorCode) {\r
- return "23505".equals(sqlState);\r
- }\r
-\r
- // [DBFlute-0.7.9]\r
- // ===================================================================================\r
- // DB2 Dependency\r
- // ==============\r
- public void lockWithRR() {\r
- _lockSqlSuffix = " with RR";\r
- }\r
-\r
- public void lockWithRS() {\r
- _lockSqlSuffix = " with RS";\r
- }\r
-\r
- public void lockWithCS() {\r
- _lockSqlSuffix = " with CS";\r
- }\r
-\r
- public void lockWithUR() {\r
- _lockSqlSuffix = " with UR";\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.cbean.sqlclause;\r
-\r
-\r
-/**\r
- * SqlClause for Default.\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class SqlClauseDefault extends AbstractSqlClause {\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- /**\r
- * @param tableName Table name. (NotNull)\r
- **/\r
- public SqlClauseDefault(String tableName) {\r
- super(tableName);\r
- }\r
-\r
- // ===================================================================================\r
- // OrderBy Override\r
- // ================\r
- @Override\r
- protected OrderByClause.OrderByNullsSetupper createOrderByNullsSetupper() {\r
- return createOrderByNullsSetupperByCaseWhen();\r
- }\r
-\r
- /**\r
- * The implementation.\r
- */\r
- protected void doFetchFirst() {\r
- }\r
-\r
- /**\r
- * The implementation.\r
- */\r
- protected void doFetchPage() {\r
- }\r
-\r
- /**\r
- * The implementation.\r
- */\r
- protected void doClearFetchPageClause() {\r
- }\r
-\r
- /**\r
- * The override.\r
- * \r
- * @return Determination.\r
- */\r
- public boolean isFetchStartIndexSupported() {\r
- return false; // Default\r
- }\r
-\r
- /**\r
- * The override.\r
- * \r
- * @return Determination.\r
- */\r
- public boolean isFetchSizeSupported() {\r
- return false; // Default\r
- }\r
-\r
- /**\r
- * The implementation.\r
- * \r
- * @return this. (NotNull)\r
- */\r
- public SqlClause lockForUpdate() {\r
- String msg = "LockForUpdate-SQL is unsupported in the database. Sorry...: " + toString();\r
- throw new UnsupportedOperationException(msg);\r
- }\r
-\r
- /**\r
- * The implementation.\r
- * \r
- * @return Select-hint. (NotNull)\r
- */\r
- protected String createSelectHint() {\r
- return "";\r
- }\r
-\r
- /**\r
- * The implementation.\r
- * \r
- * @return From-base-table-hint. {select * from table [from-base-table-hint] where ...} (NotNull)\r
- */\r
- protected String createFromBaseTableHint() {\r
- return "";\r
- }\r
-\r
- /**\r
- * The implementation.\r
- * \r
- * @return From-hint. (NotNull)\r
- */\r
- protected String createFromHint() {\r
- return "";\r
- }\r
-\r
- /**\r
- * The implementation.\r
- * \r
- * @return Sql-suffix. (NotNull)\r
- */\r
- protected String createSqlSuffix() {\r
- return "";\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.cbean.sqlclause;\r
-\r
-\r
-/**\r
- * SqlClause for Default.\r
- * \r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class SqlClauseDerby extends AbstractSqlClause {\r
-\r
- // ===================================================================================\r
- // Attribute\r
- // =========\r
- /** String of lock as sql-suffix. */\r
- protected String _lockSqlSuffix = "";\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- /**\r
- * Constructor.\r
- * @param tableName Table name. (NotNull)\r
- **/\r
- public SqlClauseDerby(String tableName) {\r
- super(tableName);\r
- }\r
-\r
- // ===================================================================================\r
- // OrderBy Override\r
- // ================\r
- @Override\r
- protected OrderByClause.OrderByNullsSetupper createOrderByNullsSetupper() {\r
- return createOrderByNullsSetupperByCaseWhen();\r
- }\r
-\r
- // ===================================================================================\r
- // FetchScope Override\r
- // ===================\r
- /**\r
- * The implementation.\r
- */\r
- protected void doFetchFirst() {\r
- }\r
-\r
- /**\r
- * The implementation.\r
- */\r
- protected void doFetchPage() {\r
- }\r
-\r
- /**\r
- * The implementation.\r
- */\r
- protected void doClearFetchPageClause() {\r
- }\r
-\r
- /**\r
- * The override.\r
- * \r
- * @return Determination.\r
- */\r
- public boolean isFetchStartIndexSupported() {\r
- return false; // Default\r
- }\r
-\r
- /**\r
- * The override.\r
- * \r
- * @return Determination.\r
- */\r
- public boolean isFetchSizeSupported() {\r
- return false; // Default\r
- }\r
-\r
- /**\r
- * The implementation.\r
- * \r
- * @return this. (NotNull)\r
- */\r
- public SqlClause lockForUpdate() {\r
- _lockSqlSuffix = " for update";\r
- return this;\r
- }\r
-\r
- /**\r
- * The implementation.\r
- * \r
- * @return Select-hint. (NotNull)\r
- */\r
- protected String createSelectHint() {\r
- return "";\r
- }\r
-\r
- /**\r
- * The implementation.\r
- * \r
- * @return From-base-table-hint. {select * from table [from-base-table-hint] where ...} (NotNull)\r
- */\r
- protected String createFromBaseTableHint() {\r
- return "";\r
- }\r
-\r
- /**\r
- * The implementation.\r
- * \r
- * @return From-hint. (NotNull)\r
- */\r
- protected String createFromHint() {\r
- return "";\r
- }\r
-\r
- /**\r
- * The implementation.\r
- * \r
- * @return Sql-suffix. (NotNull)\r
- */\r
- protected String createSqlSuffix() {\r
- return _lockSqlSuffix;\r
- }\r
-\r
- // [DBFlute-0.7.7]\r
- // ===================================================================================\r
- // Unique Constraint Override\r
- // ==========================\r
- @Override\r
- public boolean isUniqueConstraintException(String sqlState, Integer errorCode) {\r
- return "23505".equals(sqlState);\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.cbean.sqlclause;\r
-\r
-\r
-/**\r
- * SqlClause for Firebird.\r
- * \r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class SqlClauseFirebird extends AbstractSqlClause {\r
-\r
- /** String of fetch-scope as select-hint. */\r
- protected String _fetchScopeSelectHint = "";\r
-\r
- /** String of lock as sql-suffix. */\r
- protected String _lockSqlSuffix = "";\r
-\r
- /**\r
- * Constructor.\r
- * \r
- * @param tableName Table name. (NotNull)\r
- **/\r
- public SqlClauseFirebird(String tableName) {\r
- super(tableName);\r
- }\r
-\r
- /**\r
- * The implementation.\r
- */\r
- protected void doFetchFirst() {\r
- if (isFetchSizeSupported()) {\r
- _fetchScopeSelectHint = " first " + getFetchSize();\r
- }\r
- }\r
-\r
- /**\r
- * The implementation.\r
- */\r
- protected void doFetchPage() {\r
- if (isFetchStartIndexSupported() && isFetchSizeSupported()) {\r
- _fetchScopeSelectHint = " first " + getFetchSize() + " skip " + getPageStartIndex();\r
- }\r
- if (isFetchStartIndexSupported() && !isFetchSizeSupported()) {\r
- _fetchScopeSelectHint = " skip " + getPageStartIndex();\r
- }\r
- if (!isFetchStartIndexSupported() && isFetchSizeSupported()) {\r
- _fetchScopeSelectHint = " first " + getPageEndIndex();\r
- }\r
- }\r
-\r
- /**\r
- * The implementation.\r
- */\r
- protected void doClearFetchPageClause() {\r
- _fetchScopeSelectHint = "";\r
- }\r
-\r
- /**\r
- * The implementation.\r
- * \r
- * @return this. (NotNull)\r
- */\r
- public SqlClause lockForUpdate() {\r
- _lockSqlSuffix = " for update with lock";\r
- return this;\r
- }\r
-\r
- /**\r
- * The implementation.\r
- * \r
- * @return Select-hint. (NotNull)\r
- */\r
- protected String createSelectHint() {\r
- return _fetchScopeSelectHint;\r
- }\r
-\r
- /**\r
- * The implementation.\r
- * \r
- * @return From-base-table-hint. {select * from table [from-base-table-hint] where ...} (NotNull)\r
- */\r
- protected String createFromBaseTableHint() {\r
- return "";\r
- }\r
-\r
- /**\r
- * The implementation.\r
- * \r
- * @return From-hint. (NotNull)\r
- */\r
- protected String createFromHint() {\r
- return "";\r
- }\r
-\r
- /**\r
- * The implementation.\r
- * \r
- * @return Sql-suffix. (NotNull)\r
- */\r
- protected String createSqlSuffix() {\r
- return _lockSqlSuffix;\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.cbean.sqlclause;\r
-\r
-\r
-/**\r
- * SqlClause for H2.\r
- * \r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class SqlClauseH2 extends AbstractSqlClause {\r
-\r
- /** String of fetch-scope as sql-suffix. */\r
- protected String _fetchScopeSqlSuffix = "";\r
-\r
- /** String of lock as sql-suffix. */\r
- protected String _lockSqlSuffix = "";\r
-\r
- /**\r
- * Constructor.\r
- * @param tableName Table name. (NotNull)\r
- **/\r
- public SqlClauseH2(String tableName) {\r
- super(tableName);\r
- }\r
-\r
- /**\r
- * The implementation.\r
- */\r
- protected void doFetchFirst() {\r
- doFetchPage();\r
- }\r
-\r
- /**\r
- * The implementation.\r
- */\r
- protected void doFetchPage() {\r
- _fetchScopeSqlSuffix = " limit " + getFetchSize() + " offset " + getPageStartIndex();\r
- }\r
-\r
- /**\r
- * The implementation.\r
- */\r
- protected void doClearFetchPageClause() {\r
- _fetchScopeSqlSuffix = "";\r
- }\r
-\r
- /**\r
- * The implementation.\r
- * @return this. (NotNull)\r
- */\r
- public SqlClause lockForUpdate() {\r
- _lockSqlSuffix = " for update";\r
- return this;\r
- }\r
-\r
- /**\r
- * The implementation.\r
- * @return Select-hint. (NotNull)\r
- */\r
- protected String createSelectHint() {\r
- return "";\r
- }\r
-\r
- /**\r
- * The implementation.\r
- * @return From-base-table-hint. {select * from table [from-base-table-hint] where ...} (NotNull)\r
- */\r
- protected String createFromBaseTableHint() {\r
- return "";\r
- }\r
-\r
- /**\r
- * The implementation.\r
- * @return From-hint. (NotNull)\r
- */\r
- protected String createFromHint() {\r
- return "";\r
- }\r
-\r
- /**\r
- * The implementation.\r
- * @return Sql-suffix. (NotNull)\r
- */\r
- protected String createSqlSuffix() {\r
- return _fetchScopeSqlSuffix + _lockSqlSuffix;\r
- }\r
-\r
- // [DBFlute-0.7.7]\r
- // ===================================================================================\r
- // Unique Constraint Override\r
- // ==========================\r
- @Override\r
- public boolean isUniqueConstraintException(String sqlState, Integer errorCode) {\r
- return "23001".equals(sqlState);\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.cbean.sqlclause;\r
-\r
-\r
-/**\r
- * SqlClause for Interbase.\r
- * \r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class SqlClauseInterbase extends AbstractSqlClause {\r
-\r
- // ===================================================================================\r
- // Attribute\r
- // =========\r
- /** String of fetch-scope as select-hint. */\r
- protected String _fetchScopeSelectHint = "";\r
-\r
- /** String of lock as sql-suffix. */\r
- protected String _lockSqlSuffix = "";\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- /**\r
- * Constructor.\r
- * @param tableName Table name. (NotNull)\r
- **/\r
- public SqlClauseInterbase(String tableName) {\r
- super(tableName);\r
- }\r
-\r
- /**\r
- * The implementation.\r
- */\r
- protected void doFetchFirst() {\r
- if (isFetchSizeSupported()) {\r
- _fetchScopeSelectHint = " first " + getFetchSize();\r
- }\r
- }\r
-\r
- /**\r
- * The implementation.\r
- */\r
- protected void doFetchPage() {\r
- if (isFetchStartIndexSupported() && isFetchSizeSupported()) {\r
- _fetchScopeSelectHint = " first " + getFetchSize() + " skip " + getPageStartIndex();\r
- }\r
- if (isFetchStartIndexSupported() && !isFetchSizeSupported()) {\r
- _fetchScopeSelectHint = " skip " + getPageStartIndex();\r
- }\r
- if (!isFetchStartIndexSupported() && isFetchSizeSupported()) {\r
- _fetchScopeSelectHint = " first " + getPageEndIndex();\r
- }\r
- }\r
-\r
- /**\r
- * The implementation.\r
- */\r
- protected void doClearFetchPageClause() {\r
- _fetchScopeSelectHint = "";\r
- }\r
-\r
- /**\r
- * The implementation.\r
- * \r
- * @return this. (NotNull)\r
- */\r
- public SqlClause lockForUpdate() {\r
- _lockSqlSuffix = " for update with lock";\r
- return this;\r
- }\r
-\r
- /**\r
- * The implementation.\r
- * \r
- * @return Select-hint. (NotNull)\r
- */\r
- protected String createSelectHint() {\r
- return _fetchScopeSelectHint;\r
- }\r
-\r
- /**\r
- * The implementation.\r
- * \r
- * @return From-base-table-hint. {select * from table [from-base-table-hint] where ...} (NotNull)\r
- */\r
- protected String createFromBaseTableHint() {\r
- return "";\r
- }\r
-\r
- /**\r
- * The implementation.\r
- * \r
- * @return From-hint. (NotNull)\r
- */\r
- protected String createFromHint() {\r
- return "";\r
- }\r
-\r
- /**\r
- * The implementation.\r
- * \r
- * @return Sql-suffix. (NotNull)\r
- */\r
- protected String createSqlSuffix() {\r
- return _lockSqlSuffix;\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.cbean.sqlclause;\r
-\r
-\r
-/**\r
- * SqlClause for MySQL.\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class SqlClauseMySql extends AbstractSqlClause {\r
-\r
- // ===================================================================================\r
- // Attribute\r
- // =========\r
- /** String of fetch-scope as sql-suffix. */\r
- protected String _fetchScopeSqlSuffix = "";\r
-\r
- /** String of lock as sql-suffix. */\r
- protected String _lockSqlSuffix = "";\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- /**\r
- * Constructor.\r
- * @param tableName Table name. (NotNull)\r
- **/\r
- public SqlClauseMySql(String tableName) {\r
- super(tableName);\r
- }\r
-\r
- // ===================================================================================\r
- // OrderBy Override\r
- // ================\r
- @Override\r
- protected OrderByClause.OrderByNullsSetupper createOrderByNullsSetupper() {\r
- return createOrderByNullsSetupperByCaseWhen();\r
- }\r
-\r
- // ===================================================================================\r
- // FetchScope Override\r
- // ===================\r
- /**\r
- * The implementation.\r
- */\r
- protected void doFetchFirst() {\r
- doFetchPage();\r
- }\r
-\r
- /**\r
- * The implementation.\r
- */\r
- protected void doFetchPage() {\r
- _fetchScopeSqlSuffix = " limit " + getPageStartIndex() + ", " + getFetchSize();\r
- }\r
-\r
- /**\r
- * The implementation.\r
- */\r
- protected void doClearFetchPageClause() {\r
- _fetchScopeSqlSuffix = "";\r
- }\r
-\r
- /**\r
- * The implementation.\r
- * @return this. (NotNull)\r
- */\r
- public SqlClause lockForUpdate() {\r
- _lockSqlSuffix = " for update";\r
- return this;\r
- }\r
-\r
- /**\r
- * The implementation.\r
- * @return Select-hint. (NotNull)\r
- */\r
- protected String createSelectHint() {\r
- return "";\r
- }\r
-\r
- /**\r
- * The implementation.\r
- * @return From-base-table-hint. {select * from table [from-base-table-hint] where ...} (NotNull)\r
- */\r
- protected String createFromBaseTableHint() {\r
- return "";\r
- }\r
-\r
- /**\r
- * The implementation.\r
- * @return From-hint. (NotNull)\r
- */\r
- protected String createFromHint() {\r
- return "";\r
- }\r
-\r
- /**\r
- * The implementation.\r
- * @return Sql-suffix. (NotNull)\r
- */\r
- protected String createSqlSuffix() {\r
- return _fetchScopeSqlSuffix + _lockSqlSuffix;\r
- }\r
- \r
- // [DBFlute-0.7.5]\r
- // ===================================================================================\r
- // Query Update Override\r
- // =====================\r
- @Override\r
- protected boolean isUpdateSubQueryUseLocalTableSupported() {\r
- return false;\r
- }\r
-\r
- // [DBFlute-0.7.7]\r
- // ===================================================================================\r
- // Unique Constraint Override\r
- // ==========================\r
- @Override\r
- public boolean isUniqueConstraintException(String sqlState, Integer errorCode) {\r
- return errorCode != null && errorCode == 1062;\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.cbean.sqlclause;\r
-\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.dbmeta.DBMeta;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.dbmeta.DBMetaInstanceHandler;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.dbmeta.info.ColumnInfo;\r
-\r
-/**\r
- * SqlClause for Oracle.\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class SqlClauseOracle extends AbstractSqlClause {\r
-\r
- // ===================================================================================\r
- // Attribute\r
- // =========\r
- /** String of fetch-scope as select-hint. */\r
- protected String _fetchScopeSelectHint = "";\r
-\r
- /** String of fetch-scope as sql-suffix. */\r
- protected String _fetchScopeSqlSuffix = "";\r
-\r
- /** String of lock as sql-suffix. */\r
- protected String _lockSqlSuffix = "";\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- /**\r
- * Constructor.\r
- * @param tableName Table name. (NotNull)\r
- **/\r
- public SqlClauseOracle(String tableName) {\r
- super(tableName);\r
- }\r
-\r
- // ===================================================================================\r
- // Database Original Override\r
- // ==========================\r
- @Override\r
- protected String buildUnionClause(String selectClause) {\r
- \r
- // - - - - - - - - - - - - - - - - - - - - - - - - - - - -\r
- // Remove select-hint comment from select clause of union\r
- // for fetch-scope with union().\r
- // - - - - - - - - - - - - - - - - - - - - - - - - - - - -\r
-\r
- selectClause = replaceString(selectClause, SELECT_HINT, "");\r
- return super.buildUnionClause(selectClause);\r
- }\r
- \r
- // ===================================================================================\r
- // FetchScope Override\r
- // ===================\r
- /**\r
- * The implementation.\r
- */\r
- protected void doFetchFirst() {\r
- doFetchPage();\r
- }\r
-\r
- /**\r
- * The implementation.\r
- */\r
- protected void doFetchPage() {\r
- if (!isFetchStartIndexSupported() && !isFetchSizeSupported()) {\r
- return;\r
- }\r
- String ln = null;\r
- if (isFormatClauseEffective()) {\r
- ln = getLineSeparator();\r
- } else {\r
- ln = "";\r
- }\r
- _fetchScopeSelectHint = " * from (select base.*, rownum as rn from (" + ln + "select";\r
- _fetchScopeSqlSuffix = "";\r
- if (isFetchStartIndexSupported()) {\r
- _fetchScopeSqlSuffix = ") base )" + ln + " where rn > " + getPageStartIndex();\r
- }\r
- if (isFetchSizeSupported()) {\r
- if (isFetchStartIndexSupported()) {\r
- _fetchScopeSqlSuffix = _fetchScopeSqlSuffix + " and rn <= " + getPageEndIndex();\r
- } else {\r
- _fetchScopeSqlSuffix = ") base )" + ln + " where rn <= " + getPageEndIndex();\r
- }\r
- }\r
- }\r
-\r
- /**\r
- * The implementation.\r
- */\r
- protected void doClearFetchPageClause() {\r
- _fetchScopeSelectHint = "";\r
- _fetchScopeSqlSuffix = "";\r
- }\r
-\r
- // ===================================================================================\r
- // Lock Override\r
- // =============\r
- /**\r
- * The implementation.\r
- * @return this. (NotNull)\r
- */\r
- public SqlClause lockForUpdate() {\r
- final DBMeta dbmeta = DBMetaInstanceHandler.findDBMeta(_tableName);\r
- if (dbmeta.hasPrimaryKey()) {\r
- final String primaryKeyColumnName = dbmeta.getPrimaryUniqueInfo().getFirstColumn().getColumnDbName();\r
- _lockSqlSuffix = " for update of " + getLocalTableAliasName() + "." + primaryKeyColumnName;\r
- } else {\r
- final String randomColumnName = ((ColumnInfo)dbmeta.getColumnInfoList().get(0)).getColumnDbName();\r
- _lockSqlSuffix = " for update of " + getLocalTableAliasName() + "." + randomColumnName;\r
- }\r
- return this;\r
- }\r
-\r
- // ===================================================================================\r
- // Hint Override\r
- // =============\r
- /**\r
- * The implementation.\r
- * @return Select-hint. (NotNull)\r
- */\r
- protected String createSelectHint() {\r
- return _fetchScopeSelectHint;\r
- }\r
-\r
- /**\r
- * The implementation.\r
- * @return From-base-table-hint. {select * from table [from-base-table-hint] where ...} (NotNull)\r
- */\r
- protected String createFromBaseTableHint() {\r
- return "";\r
- }\r
-\r
- /**\r
- * The implementation.\r
- * @return From-hint. (NotNull)\r
- */\r
- protected String createFromHint() {\r
- return "";\r
- }\r
-\r
- /**\r
- * The implementation.\r
- * @return Sql-suffix. (NotNull)\r
- */\r
- protected String createSqlSuffix() {\r
- return _fetchScopeSqlSuffix + _lockSqlSuffix;\r
- }\r
-\r
- // [DBFlute-0.7.7]\r
- // ===================================================================================\r
- // Unique Constraint Override\r
- // ==========================\r
- @Override\r
- public boolean isUniqueConstraintException(String sqlState, Integer errorCode) {\r
- return errorCode != null && errorCode == 1;\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.cbean.sqlclause;\r
-\r
-\r
-/**\r
- * SqlClause for PostreSQL.\r
- * \r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class SqlClausePostgreSql extends AbstractSqlClause {\r
-\r
- /** String of fetch-scope as sql-suffix. */\r
- protected String _fetchScopeSqlSuffix = "";\r
-\r
- /** String of lock as sql-suffix. */\r
- protected String _lockSqlSuffix = "";\r
-\r
- /**\r
- * Constructor.\r
- * @param tableName Table name. (NotNull)\r
- **/\r
- public SqlClausePostgreSql(String tableName) {\r
- super(tableName);\r
- }\r
-\r
- /**\r
- * The implementation.\r
- */\r
- protected void doFetchFirst() {\r
- doFetchPage();\r
- }\r
-\r
- /**\r
- * The implementation.\r
- */\r
- protected void doFetchPage() {\r
- _fetchScopeSqlSuffix = " offset " + getPageStartIndex() + " limit " + getFetchSize();\r
- }\r
-\r
- /**\r
- * The implementation.\r
- */\r
- protected void doClearFetchPageClause() {\r
- _fetchScopeSqlSuffix = "";\r
- }\r
-\r
- /**\r
- * The implementation.\r
- * \r
- * @return this. (NotNull)\r
- */\r
- public SqlClause lockForUpdate() {\r
- _lockSqlSuffix = " for update";\r
- return this;\r
- }\r
-\r
- /**\r
- * The implementation.\r
- * @return Select-hint. (NotNull)\r
- */\r
- protected String createSelectHint() {\r
- return "";\r
- }\r
-\r
- /**\r
- * The implementation.\r
- * @return From-base-table-hint. {select * from table [from-base-table-hint] where ...} (NotNull)\r
- */\r
- protected String createFromBaseTableHint() {\r
- return "";\r
- }\r
-\r
- /**\r
- * The implementation.\r
- * @return From-hint. (NotNull)\r
- */\r
- protected String createFromHint() {\r
- return "";\r
- }\r
-\r
- /**\r
- * The implementation.\r
- * @return Sql-suffix. (NotNull)\r
- */\r
- protected String createSqlSuffix() {\r
- return _fetchScopeSqlSuffix + _lockSqlSuffix;\r
- }\r
-\r
- // [DBFlute-0.7.7]\r
- // ===================================================================================\r
- // Unique Constraint Override\r
- // ==========================\r
- @Override\r
- public boolean isUniqueConstraintException(String sqlState, Integer errorCode) {\r
- return "23505".equals(sqlState);\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.cbean.sqlclause;\r
-\r
-\r
-/**\r
- * SqlClause for MSSQL.\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class SqlClauseSqlServer extends AbstractSqlClause {\r
-\r
- // ===================================================================================\r
- // Attribute\r
- // =========\r
- /** String of fetch-first as select-hint. */\r
- protected String _fetchFirstSelectHint = "";\r
-\r
- /** String of lock as from-hint. */\r
- protected String _lockFromHint = "";\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- /**\r
- * Constructor.\r
- * @param tableName Table name. (NotNull)\r
- **/\r
- public SqlClauseSqlServer(String tableName) {\r
- super(tableName);\r
- }\r
-\r
- // ===================================================================================\r
- // OrderBy Override\r
- // ================\r
- @Override\r
- protected OrderByClause.OrderByNullsSetupper createOrderByNullsSetupper() {\r
- return createOrderByNullsSetupperByCaseWhen();\r
- }\r
-\r
- // ===================================================================================\r
- // FetchScope Override\r
- // ===================\r
- /**\r
- * The implementation.\r
- */\r
- protected void doFetchFirst() {\r
- if (isFetchSizeSupported()) {\r
- _fetchFirstSelectHint = " top " + getFetchSize();\r
- }\r
- }\r
-\r
- /**\r
- * The implementation.\r
- */\r
- protected void doFetchPage() {\r
- if (isFetchSizeSupported()) {\r
- if (isFetchStartIndexSupported()) {\r
- _fetchFirstSelectHint = " top " + getFetchSize();\r
- } else {\r
- _fetchFirstSelectHint = " top " + getPageEndIndex();\r
- }\r
- }\r
- }\r
-\r
- /**\r
- * The implementation.\r
- */\r
- protected void doClearFetchPageClause() {\r
- _fetchFirstSelectHint = "";\r
- }\r
-\r
- /**\r
- * @return Determination.\r
- */\r
- public boolean isFetchStartIndexSupported() {\r
- return false;\r
- }\r
-\r
- // ===================================================================================\r
- // Lock Override\r
- // =============\r
- /**\r
- * The implementation. {Implement}\r
- * @return this. (NotNull)\r
- */\r
- public SqlClause lockForUpdate() {\r
- _lockFromHint = " with (updlock)";\r
- return this;\r
- }\r
-\r
- // ===================================================================================\r
- // Hint Override\r
- // =============\r
- /**\r
- * The implementation.\r
- * @return Select-hint. (NotNull)\r
- */\r
- protected String createSelectHint() {\r
- return _fetchFirstSelectHint;\r
- }\r
-\r
- /**\r
- * The implementation.\r
- * @return From-base-table-hint. {select * from table [from-base-table-hint] where ...} (NotNull)\r
- */\r
- protected String createFromBaseTableHint() {\r
- return _lockFromHint;\r
- }\r
-\r
- /**\r
- * The implementation.\r
- * @return From-hint. (NotNull)\r
- */\r
- protected String createFromHint() {\r
- return "";\r
- }\r
-\r
- /**\r
- * The implementation.\r
- * @return Sql-suffix. (NotNull)\r
- */\r
- protected String createSqlSuffix() {\r
- return "";\r
- }\r
- \r
- // [DBFlute-0.7.7]\r
- // ===================================================================================\r
- // Unique Constraint Override\r
- // ==========================\r
- @Override\r
- public boolean isUniqueConstraintException(String sqlState, Integer errorCode) {\r
- return errorCode != null && errorCode == 2627;\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.cbean.sqlclause;\r
-\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.dbmeta.info.ColumnInfo;\r
-\r
-/**\r
- * The interface of simple filter for where clause.\r
- * \r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public interface WhereClauseSimpleFilter {\r
-\r
- public static final String BIND_COMMENT_BEGIN_PART = "/*dto";\r
- public static final String BIND_COMMENT_END_PART = "*/null";\r
-\r
- public static final String EMBEDDED_COMMENT_BEGIN_PART = "/*$dto";\r
- public static final String EMBEDDED_COMMENT_END_PART = "*/null";\r
-\r
- public static final String EMBEDDED_COMMENT_QUOTED_BEGIN_PART = "'/*$dto";\r
- public static final String EMBEDDED_COMMENT_QUOTED_END_PART = "*/'dummy''";\r
-\r
- /**\r
- * Filter clause element.\r
- * \r
- * @param clauseElement Clause element of where. (NotNull and NotEmpty)\r
- * @return Filtered where clause. (NotNull and NotEmpty)\r
- */\r
- public String filterClauseElement(String clauseElement);\r
-\r
- /**\r
- * The simple filter for where clause to embedded. <br />\r
- * *Attension -- Target column is not perfect. This class determines by column name only!\r
- * So when the column name of base table is same as the column name of join table, both are target!\r
- * \r
- * @author DBFlute(AutoGenerator)\r
- */\r
- public static class WhereClauseToEmbeddedSimpleFilter implements WhereClauseSimpleFilter {\r
-\r
- protected java.util.Set<ColumnInfo> _filterTargetColumnInfoSet;\r
-\r
- public WhereClauseToEmbeddedSimpleFilter(ColumnInfo filterTargetColumnInfo) {\r
- this._filterTargetColumnInfoSet = new java.util.HashSet<ColumnInfo>();\r
- this._filterTargetColumnInfoSet.add(filterTargetColumnInfo);\r
- }\r
-\r
- public WhereClauseToEmbeddedSimpleFilter(java.util.Set<ColumnInfo> filterTargetColumnInfoSet) {\r
- this._filterTargetColumnInfoSet = filterTargetColumnInfoSet;\r
- }\r
-\r
- /**\r
- * Filter clause element.\r
- * \r
- * @param clauseElement Clause element of where. (NotNull and NotEmpty)\r
- * @return Filtered where clause. (NotNull and NotEmpty)\r
- */\r
- public String filterClauseElement(String clauseElement) {\r
- if (_filterTargetColumnInfoSet == null || _filterTargetColumnInfoSet.isEmpty()) {\r
- return toEmbedded(clauseElement);\r
- }\r
- for (final java.util.Iterator<ColumnInfo> ite = _filterTargetColumnInfoSet.iterator(); ite.hasNext(); ) {\r
- final ColumnInfo columnInfo = (ColumnInfo)ite.next();\r
- if (isTargetClause(clauseElement, columnInfo.getColumnDbName())) {\r
- return toEmbedded(clauseElement);\r
- }\r
- }\r
- return clauseElement;\r
- }\r
-\r
- protected boolean isTargetClause(String clauseElement, final String columnDbName) {\r
- return clauseElement.indexOf("." + columnDbName + " ") >= 0;\r
- }\r
-\r
- protected String toEmbedded(String clauseElement) {\r
- clauseElement = replace(clauseElement, BIND_COMMENT_BEGIN_PART, EMBEDDED_COMMENT_BEGIN_PART);\r
- clauseElement = replace(clauseElement, BIND_COMMENT_END_PART, EMBEDDED_COMMENT_END_PART);\r
- return clauseElement;\r
- }\r
-\r
- protected final String replace(String text, String fromText,\r
- String toText) {\r
-\r
- if (text == null || fromText == null || toText == null) {\r
- return null;\r
- }\r
- StringBuffer buf = new StringBuffer(100);\r
- int pos = 0;\r
- int pos2 = 0;\r
- while (true) {\r
- pos = text.indexOf(fromText, pos2);\r
- if (pos == 0) {\r
- buf.append(toText);\r
- pos2 = fromText.length();\r
- } else if (pos > 0) {\r
- buf.append(text.substring(pos2, pos));\r
- buf.append(toText);\r
- pos2 = pos + fromText.length();\r
- } else {\r
- buf.append(text.substring(pos2));\r
- break;\r
- }\r
- }\r
- return buf.toString();\r
- }\r
- }\r
-\r
- /**\r
- * The simple filter for where clause to embedded and quoted. <br />\r
- * *Attension -- Target column is not perfect. This class determines by column name only!\r
- * So when the column name of base table is same as the column name of join table, both are target!\r
- * \r
- * @author DBFlute(AutoGenerator)\r
- */\r
- public static class WhereClauseToEmbeddedQuotedSimpleFilter extends WhereClauseToEmbeddedSimpleFilter {\r
-\r
- public WhereClauseToEmbeddedQuotedSimpleFilter(ColumnInfo filterTargetColumnInfo) {\r
- super(filterTargetColumnInfo);\r
- }\r
-\r
- public WhereClauseToEmbeddedQuotedSimpleFilter(java.util.Set<ColumnInfo> filterTargetColumnInfoSet) {\r
- super(filterTargetColumnInfoSet);\r
- }\r
-\r
- protected String toEmbedded(String clauseElement) {\r
- clauseElement = replace(clauseElement, BIND_COMMENT_BEGIN_PART, EMBEDDED_COMMENT_QUOTED_BEGIN_PART);\r
- clauseElement = replace(clauseElement, BIND_COMMENT_END_PART, EMBEDDED_COMMENT_QUOTED_END_PART);\r
- return clauseElement;\r
- }\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.dbmeta.hierarchy.basic;\r
-\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.dbmeta.hierarchy.HierarchySourceColumn;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.dbmeta.info.ColumnInfo;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class HierarchySourceEntityColumn implements HierarchySourceColumn {\r
-\r
- protected ColumnInfo columnInfo;\r
-\r
- public HierarchySourceEntityColumn(ColumnInfo columnInfo) {\r
- this.columnInfo = columnInfo;\r
- }\r
-\r
- public String getColumnName() {\r
- return columnInfo.getColumnDbName();\r
- }\r
-\r
- public java.lang.reflect.Method findGetter() {\r
- return columnInfo.findGetter();\r
- }\r
-}
\ No newline at end of file
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.dbmeta.hierarchy.basic;\r
-\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- * @param <SOURCE_ROW> The type of source.\r
- */\r
-public class HierarchySourceEntityListIterator<SOURCE_ROW> extends HierarchySourceListIterator<SOURCE_ROW> {\r
-\r
- /**\r
- * Constructor.\r
- * \r
- * @param sourceRowList The list of source row. (NotNull)\r
- */\r
- public HierarchySourceEntityListIterator(java.util.List<SOURCE_ROW> sourceRowList) {\r
- super(sourceRowList, new HierarchySourceRowSetupper<SOURCE_ROW>() {\r
- public jp.sourceforge.ea2ddl.dao.allcommon.dbmeta.hierarchy.HierarchySourceRow setup(SOURCE_ROW source) {\r
- return new HierarchySourceEntityRow(source);\r
- }\r
- });\r
- }\r
-}
\ No newline at end of file
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.dbmeta.hierarchy.basic;\r
-\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class HierarchySourceEntityRow implements jp.sourceforge.ea2ddl.dao.allcommon.dbmeta.hierarchy.HierarchySourceRow {\r
-\r
- protected Object sourceBean;\r
-\r
- public HierarchySourceEntityRow(Object sourceBean) {\r
- this.sourceBean = sourceBean;\r
- }\r
-\r
- public Object extractColumnValue(jp.sourceforge.ea2ddl.dao.allcommon.dbmeta.hierarchy.HierarchySourceColumn columnInfo) {\r
- if (!(columnInfo instanceof HierarchySourceEntityColumn)) {\r
- String msg = "The column info should be HierarchySourceEntityColumn! but: " + columnInfo;\r
- throw new IllegalStateException(msg);\r
- }\r
- final HierarchySourceEntityColumn sourceEntityColumn = (HierarchySourceEntityColumn) columnInfo;\r
- return invoke(sourceEntityColumn.findGetter(), sourceBean, new Object[] {});\r
- }\r
-\r
- private Object invoke(java.lang.reflect.Method method, Object target, Object[] args) {\r
- try {\r
- return method.invoke(target, args);\r
- } catch (java.lang.reflect.InvocationTargetException ex) {\r
- Throwable t = ex.getCause();\r
- if (t instanceof RuntimeException) {\r
- throw (RuntimeException) t;\r
- }\r
- if (t instanceof Error) {\r
- throw (Error) t;\r
- }\r
- String msg = "target=" + target + " method=" + method + "-" + java.util.Arrays.asList(args);\r
- throw new RuntimeException(msg, ex);\r
- } catch (IllegalAccessException ex) {\r
- String msg = "target=" + target + " method=" + method + "-" + java.util.Arrays.asList(args);\r
- throw new RuntimeException(msg, ex);\r
- }\r
- }\r
-}
\ No newline at end of file
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.dbmeta.hierarchy.basic;\r
-\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- * @param <SOURCE_ROW> The type of source.\r
- */\r
-public class HierarchySourceListIterator<SOURCE_ROW> implements jp.sourceforge.ea2ddl.dao.allcommon.dbmeta.hierarchy.HierarchySourceIterator {\r
-\r
- protected java.util.List<? extends Object> sourceRowList;\r
-\r
- protected HierarchySourceRowSetupper<SOURCE_ROW> sourceRowSetupper;\r
-\r
- protected java.util.Iterator<SOURCE_ROW> sourceBeanListIterator;\r
-\r
- protected jp.sourceforge.ea2ddl.dao.allcommon.dbmeta.hierarchy.HierarchySourceRow currentSourceEntity;\r
-\r
- public HierarchySourceListIterator(java.util.List<SOURCE_ROW> sourceRowList,\r
- HierarchySourceRowSetupper<SOURCE_ROW> sourceRowSetupper) {\r
- this.sourceRowList = sourceRowList;\r
- this.sourceRowSetupper = sourceRowSetupper;\r
- this.sourceBeanListIterator = sourceRowList.iterator();\r
- }\r
-\r
- public boolean hasNext() {\r
- return this.sourceBeanListIterator.hasNext();\r
- }\r
-\r
- public jp.sourceforge.ea2ddl.dao.allcommon.dbmeta.hierarchy.HierarchySourceRow next() {\r
- this.currentSourceEntity = this.sourceRowSetupper.setup(this.sourceBeanListIterator.next());\r
- return this.currentSourceEntity;\r
- }\r
-\r
- public jp.sourceforge.ea2ddl.dao.allcommon.dbmeta.hierarchy.HierarchySourceRow current() {\r
- return this.currentSourceEntity;\r
- }\r
-}
\ No newline at end of file
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.dbmeta.hierarchy.basic;\r
-\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- * @param <SOURCE_ROW> The type of source.\r
- */\r
-public interface HierarchySourceRowSetupper<SOURCE_ROW> {\r
-\r
- public jp.sourceforge.ea2ddl.dao.allcommon.dbmeta.hierarchy.HierarchySourceRow setup(SOURCE_ROW source);\r
-}
\ No newline at end of file
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.dbmeta.info;\r
-\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.dbmeta.DBMeta;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.dbmeta.DBMeta.OptimisticLockType;\r
-\r
-/**\r
- * The information of column.\r
- * @author DBFlute(AutoGenerator)\r
- */
-@SuppressWarnings("unchecked")\r
-public class ColumnInfo {\r
-\r
- // ===================================================================================\r
- // Attribute\r
- // =========\r
- protected DBMeta dbmeta;\r
- protected String columnDbName;\r
- protected String propertyName;\r
- protected Class<?> propertyType;\r
- protected boolean primary;\r
- protected Integer columnSize;\r
- protected Integer columnDecimalDigits;\r
- protected OptimisticLockType optimisticLockType;\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- public ColumnInfo(DBMeta dbmeta, String columnDbName) {\r
- this(dbmeta, columnDbName, null, null, false, null, null);\r
- }\r
-\r
- public ColumnInfo(DBMeta dbmeta, String columnDbName, String propertyName\r
- , Class<?> propertyType, boolean primary, Integer columnSize) {\r
- this(dbmeta, columnDbName, propertyName, propertyType, primary, columnSize, null);\r
- }\r
-\r
- public ColumnInfo(DBMeta dbmeta, String columnDbName, String propertyName\r
- , Class<?> propertyType, boolean primary, Integer columnSize, Integer columnDecimalDigits) {\r
- this(dbmeta, columnDbName, propertyName, propertyType, primary, columnSize, columnDecimalDigits, OptimisticLockType.NONE);\r
- }\r
-\r
- public ColumnInfo(DBMeta dbmeta, String columnDbName, String propertyName\r
- , Class<?> propertyType, boolean primary, Integer columnSize\r
- , Integer columnDecimalDigits, OptimisticLockType optimisticLockType) {\r
- this.dbmeta = dbmeta;\r
- this.columnDbName = columnDbName;\r
- this.propertyName = propertyName;\r
- this.propertyType = propertyType;\r
- this.primary = primary;\r
- this.columnSize = columnSize;\r
- this.columnDecimalDigits = columnDecimalDigits;\r
- this.optimisticLockType = optimisticLockType;\r
- }\r
-\r
- // ===================================================================================\r
- // Builder\r
- // =======\r
- public String buildInitCapPropertyName() {\r
- return initCap(this.propertyName);\r
- }\r
-\r
- // ===================================================================================\r
- // Finder\r
- // ======\r
- public java.lang.reflect.Method findSetter() {\r
- return findMethod(dbmeta.getEntityType(), "set" + buildInitCapPropertyName(), new Class<?>[] { this.propertyType });\r
- }\r
-\r
- public java.lang.reflect.Method findGetter() {\r
- return findMethod(dbmeta.getEntityType(), "get" + buildInitCapPropertyName(), new Class<?>[] {});\r
- }\r
-\r
- // ===================================================================================\r
- // Optimistic Lock Type\r
- // ====================\r
- public boolean isOptimisticLock() {\r
- return isVersionNo() || isUpdateDate();\r
- }\r
-\r
- public boolean isVersionNo() {\r
- return OptimisticLockType.VERSION_NO == optimisticLockType;\r
- }\r
-\r
- public boolean isUpdateDate() {\r
- return OptimisticLockType.UPDATE_DATE == optimisticLockType;\r
- }\r
-\r
- // ===================================================================================\r
- // Internal Helper\r
- // ===============\r
- protected String initCap(final String name) {\r
- return name.substring(0, 1).toUpperCase() + name.substring(1);\r
- }\r
-\r
- protected java.lang.reflect.Method findMethod(Class<?> clazz, String methodName, Class<?>[] argTypes) {\r
- try {\r
- return clazz.getMethod(methodName, argTypes);\r
- } catch (NoSuchMethodException ex) {\r
- String msg = "class=" + clazz + " method=" + methodName + "-" + java.util.Arrays.asList(argTypes);\r
- throw new RuntimeException(msg, ex);\r
- }\r
- }\r
-\r
- // ===================================================================================\r
- // Basic Override\r
- // ==============\r
- public int hashCode() {\r
- return dbmeta.hashCode() + columnDbName.hashCode();\r
- }\r
-\r
- public boolean equals(Object obj) {\r
- if (!(obj instanceof ColumnInfo)) {\r
- return false;\r
- }\r
- final ColumnInfo target = (ColumnInfo)obj;\r
- if (this.dbmeta == null || target.getDBMeta() == null) {\r
- return false;\r
- }\r
- if (!this.dbmeta.equals(target.getDBMeta())) {\r
- return false;\r
- }\r
- if (this.columnDbName == null || target.getColumnDbName() == null) {\r
- return false;\r
- }\r
- if (!this.columnDbName.equals(target.getColumnDbName())) {\r
- return false;\r
- }\r
- return true;\r
- }\r
-\r
- public String toString() {\r
- return dbmeta.getTableDbName() + "." + columnDbName;\r
- }\r
-\r
- // ===================================================================================\r
- // Accessor\r
- // ========\r
- public DBMeta getDBMeta() {\r
- return dbmeta;\r
- }\r
-\r
- public void setDBMeta(DBMeta dbmeta) {\r
- this.dbmeta = dbmeta;\r
- }\r
-\r
- public String getColumnDbName() {\r
- return this.columnDbName;\r
- }\r
-\r
- public void setColumnDbName(String columnDbName) {\r
- this.columnDbName = columnDbName;\r
- }\r
-\r
- public String getPropertyName() {\r
- return this.propertyName;\r
- }\r
-\r
- public void setPropertyName(String propertyName) {\r
- this.propertyName = propertyName;\r
- }\r
- \r
- public Class<?> getPropertyType() {\r
- return this.propertyType;\r
- }\r
-\r
- public void setPropertyType(Class<?> propertyType) {\r
- this.propertyType = propertyType;\r
- }\r
-\r
- public boolean isPrimary() {\r
- return this.primary;\r
- }\r
-\r
- public void setPrimary(boolean primary) {\r
- this.primary = primary;\r
- }\r
-\r
- public Integer getColumnSize() {\r
- return this.columnSize;\r
- }\r
-\r
- public void setColumnSize(Integer columnSize) {\r
- this.columnSize = columnSize;\r
- }\r
-\r
- public Integer getColumnDecimalDigits() {\r
- return this.columnDecimalDigits;\r
- }\r
-\r
- public void setColumnDecimalDigits(Integer columnDecimalDigits) {\r
- this.columnDecimalDigits = columnDecimalDigits;\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.dbmeta.info;\r
-\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.dbmeta.DBMeta;\r
-\r
-/**\r
- * The class of foreign information.\r
- * \r
- * @author DBFlute(AutoGenerator)\r
- */
-@SuppressWarnings("unchecked")\r
-public class ForeignInfo implements RelationInfo {\r
-\r
- // ===================================================================================\r
- // Attribute\r
- // =========\r
- protected String foreignPropertyName;\r
- protected DBMeta localDBMeta;\r
- protected DBMeta foreignDBMeta;\r
- protected java.util.Map<ColumnInfo, ColumnInfo> localForeignColumnInfoMap;\r
- protected java.util.Map<ColumnInfo, ColumnInfo> foreignLocalColumnInfoMap;\r
- protected int relationNo;\r
- protected boolean oneToOne;\r
-\r
- // ===================================================================================\r
- // Finder\r
- // ======\r
- public ColumnInfo findLocalByForeign(String foreignColumnDbName) {\r
- final ColumnInfo keyColumnInfo = new ColumnInfo(foreignDBMeta, foreignColumnDbName);\r
- final ColumnInfo resultColumnInfo = (ColumnInfo)foreignLocalColumnInfoMap.get(keyColumnInfo);\r
- if (resultColumnInfo == null) {\r
- String msg = "Not found by foreignColumnDbName in foreignLocalColumnInfoMap:";\r
- msg = msg + " foreignColumnDbName=" + foreignColumnDbName + " foreignLocalColumnInfoMap=" + foreignLocalColumnInfoMap;\r
- throw new IllegalArgumentException(msg);\r
- }\r
- return resultColumnInfo;\r
- }\r
-\r
- // ===================================================================================\r
- // Builder\r
- // =======\r
- public String buildInitCapPropertyName() {\r
- return initCap(this.foreignPropertyName);\r
- }\r
-\r
- // ===================================================================================\r
- // Finder\r
- // ======\r
- public java.lang.reflect.Method findSetter() {\r
- return findMethod(localDBMeta.getEntityType(), "set" + buildInitCapPropertyName(), new Class[] { java.util.List.class });\r
- }\r
-\r
- public java.lang.reflect.Method findGetter() {\r
- return findMethod(localDBMeta.getEntityType(), "get" + buildInitCapPropertyName(), new Class[] {});\r
- }\r
-\r
- // ===================================================================================\r
- // Implement\r
- // =========\r
- public String getRelationPropertyName() {\r
- return getForeignPropertyName();\r
- }\r
-\r
- public DBMeta getTargetDBMeta() {\r
- return getForeignDBMeta();\r
- }\r
-\r
- public java.util.Map<ColumnInfo, ColumnInfo> getLocalTargetColumnInfoMap() {\r
- return getLocalForeignColumnInfoMap();\r
- }\r
-\r
- public boolean isReferrer() {\r
- return false;\r
- }\r
-\r
- // ===================================================================================\r
- // Accessor\r
- // ========\r
- public String getForeignPropertyName() {\r
- return foreignPropertyName;\r
- }\r
-\r
- public void setForeignPropertyName(String foreignPropertyName) {\r
- this.foreignPropertyName = foreignPropertyName;\r
- }\r
-\r
- public DBMeta getLocalDBMeta() {\r
- return localDBMeta;\r
- }\r
-\r
- public void setLocalDBMeta(DBMeta localDBMeta) {\r
- this.localDBMeta = localDBMeta;\r
- }\r
-\r
- public DBMeta getForeignDBMeta() {\r
- return foreignDBMeta;\r
- }\r
-\r
- public void setForeignDBMeta(DBMeta foreignDBMeta) {\r
- this.foreignDBMeta = foreignDBMeta;\r
- }\r
-\r
- public java.util.Map<ColumnInfo, ColumnInfo> getLocalForeignColumnInfoMap() {\r
- return localForeignColumnInfoMap;\r
- }\r
-\r
- public void setLocalForeignColumnInfoMap(java.util.Map<ColumnInfo, ColumnInfo> localForeignColumnInfoMap) {\r
- this.localForeignColumnInfoMap = localForeignColumnInfoMap;\r
- final java.util.Set keySet = localForeignColumnInfoMap.keySet();\r
- foreignLocalColumnInfoMap = new java.util.LinkedHashMap<ColumnInfo, ColumnInfo>();\r
- for (final java.util.Iterator ite = keySet.iterator(); ite.hasNext(); ) {\r
- final ColumnInfo key = (ColumnInfo)ite.next();\r
- final ColumnInfo value = (ColumnInfo)localForeignColumnInfoMap.get(key);\r
- foreignLocalColumnInfoMap.put(value, key);\r
- }\r
- }\r
-\r
- public java.util.Map<ColumnInfo, ColumnInfo> getForeignLocalColumnInfoMap() {\r
- return foreignLocalColumnInfoMap;\r
- }\r
-\r
- public int getRelationNo() {\r
- return relationNo;\r
- }\r
-\r
- public void setRelationNo(int relationNo) {\r
- this.relationNo = relationNo;\r
- }\r
-\r
- public boolean isOneToOne() {\r
- return oneToOne;\r
- }\r
-\r
- public void setOneToOne(boolean oneToOne) {\r
- this.oneToOne = oneToOne;\r
- }\r
-\r
- // ===================================================================================\r
- // General Helper\r
- // ==============\r
- protected java.lang.reflect.Method findMethod(Class clazz, String methodName, Class[] argTypes) {\r
- try {\r
- return clazz.getMethod(methodName, argTypes);\r
- } catch (NoSuchMethodException ex) {\r
- String msg = "class=" + clazz + " method=" + methodName + "-" + java.util.Arrays.asList(argTypes);\r
- throw new RuntimeException(msg, ex);\r
- }\r
- }\r
- \r
- protected String initCap(final String name) {\r
- return name.substring(0, 1).toUpperCase() + name.substring(1);\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.dbmeta.info;\r
-\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.dbmeta.DBMeta;\r
-\r
-/**\r
- * The class of referrer information.\r
- * \r
- * @author DBFlute(AutoGenerator)\r
- */
-@SuppressWarnings("unchecked")\r
-public class ReferrerInfo implements RelationInfo {\r
-\r
- // ===================================================================================\r
- // Attribute\r
- // =========\r
- protected String referrerPropertyName;\r
- protected DBMeta localDBMeta;\r
- protected DBMeta referrerDBMeta;\r
- protected java.util.Map<ColumnInfo, ColumnInfo> localReferrerColumnInfoMap;\r
- protected java.util.Map<ColumnInfo, ColumnInfo> referrerLocalColumnInfoMap;\r
- protected boolean oneToOne;\r
-\r
- // ===================================================================================\r
- // Finder\r
- // ======\r
- public ColumnInfo findLocalByReferrer(String referrerColumnDbName) {\r
- final ColumnInfo keyColumnInfo = new ColumnInfo(referrerDBMeta, referrerColumnDbName);\r
- final ColumnInfo resultColumnInfo = (ColumnInfo)referrerLocalColumnInfoMap.get(keyColumnInfo);\r
- if (resultColumnInfo == null) {\r
- String msg = "Not found by referrerColumnDbName in referrerLocalColumnInfoMap:";\r
- msg = msg + " referrerColumnDbName=" + referrerColumnDbName + " referrerLocalColumnInfoMap=" + referrerLocalColumnInfoMap;\r
- throw new IllegalArgumentException(msg);\r
- }\r
- return resultColumnInfo;\r
- }\r
-\r
- public ColumnInfo findReferrerByLocal(String localColumnDbName) {\r
- final ColumnInfo keyColumnInfo = new ColumnInfo(localDBMeta, localColumnDbName);\r
- final ColumnInfo resultColumnInfo = (ColumnInfo)localReferrerColumnInfoMap.get(keyColumnInfo);\r
- if (resultColumnInfo == null) {\r
- String msg = "Not found by localColumnDbName in localReferrerColumnInfoMap:";\r
- msg = msg + " localColumnDbName=" + localColumnDbName + " localReferrerColumnInfoMap=" + localReferrerColumnInfoMap;\r
- throw new IllegalArgumentException(msg);\r
- }\r
- return resultColumnInfo;\r
- }\r
-\r
- // ===================================================================================\r
- // Builder\r
- // =======\r
- public String buildInitCapPropertyName() {\r
- return initCap(this.referrerPropertyName);\r
- }\r
-\r
- // ===================================================================================\r
- // Finder\r
- // ======\r
- public java.lang.reflect.Method findSetter() {\r
- return findMethod(localDBMeta.getEntityType(), "set" + buildInitCapPropertyName(), new Class[] { java.util.List.class });\r
- }\r
-\r
- public java.lang.reflect.Method findGetter() {\r
- return findMethod(localDBMeta.getEntityType(), "get" + buildInitCapPropertyName(), new Class[] {});\r
- }\r
-\r
- // ===================================================================================\r
- // Implement\r
- // =========\r
- public String getRelationPropertyName() {\r
- return getReferrerPropertyName();\r
- }\r
-\r
- public DBMeta getTargetDBMeta() {\r
- return getReferrerDBMeta();\r
- }\r
-\r
- public java.util.Map<ColumnInfo, ColumnInfo> getLocalTargetColumnInfoMap() {\r
- return getLocalReferrerColumnInfoMap();\r
- }\r
-\r
- public boolean isReferrer() {\r
- return true;\r
- }\r
-\r
- // ===================================================================================\r
- // Accessor\r
- // ========\r
- public String getReferrerPropertyName() {\r
- return referrerPropertyName;\r
- }\r
-\r
- public void setReferrerPropertyName(String referrerPropertyName) {\r
- this.referrerPropertyName = referrerPropertyName;\r
- }\r
-\r
- public DBMeta getLocalDBMeta() {\r
- return localDBMeta;\r
- }\r
-\r
- public void setLocalDBMeta(DBMeta localDBMeta) {\r
- this.localDBMeta = localDBMeta;\r
- }\r
-\r
- public DBMeta getReferrerDBMeta() {\r
- return referrerDBMeta;\r
- }\r
-\r
- public void setReferrerDBMeta(DBMeta referrerDBMeta) {\r
- this.referrerDBMeta = referrerDBMeta;\r
- }\r
-\r
- public java.util.Map<ColumnInfo, ColumnInfo> getLocalReferrerColumnInfoMap() {\r
- return localReferrerColumnInfoMap;\r
- }\r
-\r
- public void setLocalReferrerColumnInfoMap(java.util.Map<ColumnInfo, ColumnInfo> localReferrerColumnInfoMap) {\r
- this.localReferrerColumnInfoMap = localReferrerColumnInfoMap;\r
- final java.util.Set keySet = localReferrerColumnInfoMap.keySet();\r
- referrerLocalColumnInfoMap = new java.util.LinkedHashMap<ColumnInfo, ColumnInfo>();\r
- for (final java.util.Iterator ite = keySet.iterator(); ite.hasNext(); ) {\r
- final ColumnInfo key = (ColumnInfo)ite.next();\r
- final ColumnInfo value = (ColumnInfo)localReferrerColumnInfoMap.get(key);\r
- referrerLocalColumnInfoMap.put(value, key);\r
- }\r
- }\r
-\r
- public java.util.Map<ColumnInfo, ColumnInfo> getReferrerLocalColumnInfoMap() {\r
- return referrerLocalColumnInfoMap;\r
- }\r
-\r
- public boolean isOneToOne() {\r
- return oneToOne;\r
- }\r
-\r
- public void setOneToOne(boolean oneToOne) {\r
- this.oneToOne = oneToOne;\r
- }\r
-\r
- // ===================================================================================\r
- // Internal Helper\r
- // ===============\r
- protected String initCap(final String name) {\r
- return name.substring(0, 1).toUpperCase() + name.substring(1);\r
- }\r
-\r
- protected java.lang.reflect.Method findMethod(Class clazz, String methodName, Class[] argTypes) {\r
- try {\r
- return clazz.getMethod(methodName, argTypes);\r
- } catch (NoSuchMethodException ex) {\r
- String msg = "class=" + clazz + " method=" + methodName + "-" + java.util.Arrays.asList(argTypes);\r
- throw new RuntimeException(msg, ex);\r
- }\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.dbmeta.info;\r
-\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.dbmeta.DBMeta;\r
-\r
-/**\r
- * The class of referer information.\r
- * \r
- * @author DBFlute(AutoGenerator)\r
- */
-@SuppressWarnings("unchecked")\r
-public interface RelationInfo {\r
-\r
- public String getRelationPropertyName();\r
-\r
- public DBMeta getLocalDBMeta();\r
-\r
- public DBMeta getTargetDBMeta();\r
-\r
- public java.util.Map<ColumnInfo, ColumnInfo> getLocalTargetColumnInfoMap();\r
-\r
- public boolean isOneToOne();\r
-\r
- public boolean isReferrer();\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.dbmeta.info;\r
-\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.dbmeta.DBMeta;\r
-\r
-/**\r
- * The class of unique info.\r
- * \r
- * @author DBFlute(AutoGenerator)\r
- */
-@SuppressWarnings("unchecked")\r
-public class UniqueInfo {\r
-\r
- // ===================================================================================\r
- // Attribute\r
- // =========\r
- protected DBMeta dbmeta;\r
- protected java.util.List<ColumnInfo> uniqueColumnList = new java.util.ArrayList<ColumnInfo>();\r
- protected boolean primary;\r
-\r
- // ===================================================================================\r
- // Easy-to-Use\r
- // ===========\r
- public boolean containsColumn(String columnName) {\r
- for (final java.util.Iterator ite = uniqueColumnList.iterator(); ite.hasNext(); ) {\r
- final ColumnInfo columnInfo = (ColumnInfo)ite.next();\r
- if (columnInfo.getColumnDbName().equals(columnName)) {\r
- return true;\r
- }\r
- }\r
- return false;\r
- }\r
-\r
- public boolean containsColumn(ColumnInfo column) {\r
- return containsColumn(column.getColumnDbName());\r
- }\r
-\r
- // ===================================================================================\r
- // Accessor\r
- // ========\r
- public DBMeta getDBMeta() {\r
- return dbmeta;\r
- }\r
-\r
- public void setDBMeta(DBMeta dbmeta) {\r
- this.dbmeta = dbmeta;\r
- }\r
-\r
- public java.util.List<ColumnInfo> getUniqueColumnList() {\r
- return uniqueColumnList;\r
- }\r
-\r
- public void addUniqueColumnList(ColumnInfo uniqueColumn) {\r
- this.uniqueColumnList.add(uniqueColumn);\r
- }\r
-\r
- public ColumnInfo getFirstColumn() {\r
- return (ColumnInfo)this.uniqueColumnList.get(0);\r
- }\r
-\r
- public boolean isTwoOrMore() {\r
- return this.uniqueColumnList.size() > 1;\r
- }\r
-\r
- public boolean isPrimary() {\r
- return this.primary;\r
- }\r
-\r
- public void setPrimary(boolean primary) {\r
- this.primary = primary;\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.exception;\r
-\r
-/**\r
- * The exception of when the entity has already been updated by other thread in batch update.\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class BatchEntityAlreadyUpdatedException extends EntityAlreadyUpdatedException {\r
-\r
- /** Serial version UID. (Default) */\r
- private static final long serialVersionUID = 1L;\r
- \r
- // ===================================================================================\r
- // Attribute\r
- // =========\r
- protected Integer _batchUpdateCount;\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- /**\r
- * Constructor.\r
- * @param bean Bean. (NotNull)\r
- * @param rows Rows(Update count per One entity).\r
- * @param batchUpdateCount Batch update count(Total).\r
- */\r
- public BatchEntityAlreadyUpdatedException(Object bean, int rows, Integer batchUpdateCount) {\r
- super(bean, rows);\r
- _batchUpdateCount = batchUpdateCount;\r
- }\r
-\r
- // ===================================================================================\r
- // Accessor\r
- // ========\r
- public Integer getBatchUpdateCount() {\r
- return _batchUpdateCount;\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.exception;\r
-\r
-/**\r
- * The exception of when the property on bind variable comment is not found about outsideSql.\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class BindVariableCommentNotFoundPropertyException extends RuntimeException {\r
-\r
- /** Serial version UID. (Default) */\r
- private static final long serialVersionUID = 1L;\r
-\r
- /**\r
- * Constructor.\r
- * @param msg Exception message. (NotNull)\r
- */\r
- public BindVariableCommentNotFoundPropertyException(String msg) {\r
- super(msg);\r
- }\r
-\r
- /**\r
- * Constructor.\r
- * @param msg Exception message. (NotNull)\r
- * @param cause Throwable.\r
- */\r
- public BindVariableCommentNotFoundPropertyException(String msg, Throwable cause) {\r
- super(msg, cause);\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.exception;\r
-\r
-/**\r
- * The exception of when the value of bind variable is null about outsideSql.\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class BindVariableParameterNullValueException extends RuntimeException {\r
-\r
- /** Serial version UID. (Default) */\r
- private static final long serialVersionUID = 1L;\r
-\r
- /**\r
- * Constructor.\r
- * @param msg Exception message. (NotNull)\r
- */\r
- public BindVariableParameterNullValueException(String msg) {\r
- super(msg);\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.exception;\r
-\r
-/**\r
- * The exception of when the result size is dangerous.\r
- * \r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class DangerousResultSizeException extends RuntimeException {\r
-\r
- /** Serial version UID. (Default) */\r
- private static final long serialVersionUID = 1L;\r
-\r
- /** Safety max result size. */\r
- protected int _safetyMaxResultSize;\r
-\r
- /**\r
- * Constructor.\r
- * \r
- * @param msg Exception message.\r
- * @param safetyMaxResultSize Safety max result size.\r
- * @param selectedCount Selected count.\r
- */\r
- public DangerousResultSizeException(String msg, int safetyMaxResultSize) {\r
- super(msg);\r
- this._safetyMaxResultSize = safetyMaxResultSize;\r
- }\r
-\r
- /**\r
- * Get safety max result size.\r
- * \r
- * @return Safety max result size.\r
- */\r
- public int getSafetyMaxResultSize() {\r
- return _safetyMaxResultSize;\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.exception;\r
-\r
-/**\r
- * The exception of when the property on embedded value comment is not found about outsideSql.\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class EmbeddedValueCommentNotFoundPropertyException extends RuntimeException {\r
-\r
- /** Serial version UID. (Default) */\r
- private static final long serialVersionUID = 1L;\r
-\r
- /**\r
- * Constructor.\r
- * @param msg Exception message. (NotNull)\r
- */\r
- public EmbeddedValueCommentNotFoundPropertyException(String msg) {\r
- super(msg);\r
- }\r
-\r
- /**\r
- * Constructor.\r
- * @param msg Exception message. (NotNull)\r
- * @param cause Throwable.\r
- */\r
- public EmbeddedValueCommentNotFoundPropertyException(String msg, Throwable cause) {\r
- super(msg, cause);\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.exception;\r
-\r
-/**\r
- * The exception of when the value of embedded value is null about outsideSql.\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class EmbeddedValueParameterNullValueException extends RuntimeException {\r
-\r
- /** Serial version UID. (Default) */\r
- private static final long serialVersionUID = 1L;\r
-\r
- /**\r
- * Constructor.\r
- * @param msg Exception message. (NotNull)\r
- */\r
- public EmbeddedValueParameterNullValueException(String msg) {\r
- super(msg);\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.exception;\r
-\r
-/**\r
- * The exception of when the end comment is not found about outsideSql.\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class EndCommentNotFoundException extends RuntimeException {\r
-\r
- /** Serial version UID. (Default) */\r
- private static final long serialVersionUID = 1L;\r
-\r
- /**\r
- * Constructor.\r
- * @param msg Exception message. (NotNull)\r
- */\r
- public EndCommentNotFoundException(String msg) {\r
- super(msg);\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.exception;\r
-\r
-/**\r
- * The exception of when the entity has already been deleted by other thread.\r
- * \r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class EntityAlreadyDeletedException extends RecordHasAlreadyBeenDeletedException {\r
-\r
- /** Serial version UID. (Default) */\r
- private static final long serialVersionUID = 1L;\r
-\r
- /**\r
- * Constructor.\r
- * \r
- * @param msg Exception message.\r
- */\r
- public EntityAlreadyDeletedException(String msg) {\r
- super(msg);\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.exception;\r
-\r
-import java.sql.SQLException;\r
-\r
-/**\r
- * The exception of when the entity already exists on the database.\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class EntityAlreadyExistsException extends SQLFailureException {\r
-\r
- /** Serial version UID. (Default) */\r
- private static final long serialVersionUID = 1L;\r
-\r
- /**\r
- * Constructor.\r
- * @param msg Exception message. (NotNull)\r
- * @param cause SQLException. (NotNull)\r
- */\r
- public EntityAlreadyExistsException(String msg, SQLException cause) {\r
- super(msg, cause);\r
- sqlEx = cause;\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.exception;\r
-\r
-import org.seasar.dao.NotSingleRowUpdatedRuntimeException;\r
-\r
-/**\r
- * The exception of when the entity has already been updated by other thread.\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class EntityAlreadyUpdatedException extends NotSingleRowUpdatedRuntimeException {\r
-\r
- /** Serial version UID. (Default) */\r
- private static final long serialVersionUID = 1L;\r
- \r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- /**\r
- * Constructor.\r
- * @param bean Bean. (NotNull)\r
- * @param rows Rows.\r
- */\r
- public EntityAlreadyUpdatedException(Object bean, int rows) {\r
- super(bean, rows);\r
- }\r
-\r
- /**\r
- * Constructor.\r
- * @param e NotSingleRowUpdatedRuntimeException. (NotNull)\r
- */\r
- public EntityAlreadyUpdatedException(NotSingleRowUpdatedRuntimeException e) {\r
- super(e.getBean(), e.getRows());\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.exception;\r
-\r
-/**\r
- * The exception of when the entity has been duplicated.\r
- * \r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class EntityDuplicatedException extends RecordHasOverlappedException {\r
-\r
- /** Serial version UID. (Default) */\r
- private static final long serialVersionUID = 1L;\r
-\r
- /**\r
- * Constructor.\r
- * @param msg Exception message.\r
- */\r
- public EntityDuplicatedException(String msg) {\r
- super(msg);\r
- }\r
-\r
- /**\r
- * Constructor.\r
- * @param msg Exception message.\r
- * @param cause Throwable.\r
- */\r
- public EntityDuplicatedException(String msg, Throwable cause) {\r
- super(msg, cause);\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.exception;\r
-\r
-/**\r
- * The exception of when the condition of IF comment is not found about outsideSql.\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class IfCommentConditionNotFoundException extends IfCommentWrongExpressionException {\r
-\r
- /** Serial version UID. (Default) */\r
- private static final long serialVersionUID = 1L;\r
-\r
- /**\r
- * Constructor.\r
- * @param msg Exception message. (NotNull)\r
- */\r
- public IfCommentConditionNotFoundException(String msg) {\r
- super(msg);\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.exception;\r
-\r
-/**\r
- * The exception of when the result of IF comment is not boolean about outsideSql.\r
- * \r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class IfCommentNotBooleanResultException extends IfCommentWrongExpressionException {\r
-\r
- /** Serial version UID. (Default) */\r
- private static final long serialVersionUID = 1L;\r
-\r
- /**\r
- * Constructor.\r
- * \r
- * @param msg Exception message. (NotNull)\r
- */\r
- public IfCommentNotBooleanResultException(String msg) {\r
- super(msg);\r
- }\r
-\r
- /**\r
- * Constructor.\r
- * \r
- * @param msg Exception message. (NotNull)\r
- * @param cause Throwable.\r
- */\r
- public IfCommentNotBooleanResultException(String msg, Throwable cause) {\r
- super(msg, cause);\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.exception;\r
-\r
-/**\r
- * The exception of when the IF comment has a wrong expression about outsideSql.\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class IfCommentWrongExpressionException extends RuntimeException {\r
-\r
- /** Serial version UID. (Default) */\r
- private static final long serialVersionUID = 1L;\r
-\r
- /**\r
- * Constructor.\r
- * @param msg Exception message. (NotNull)\r
- */\r
- public IfCommentWrongExpressionException(String msg) {\r
- super(msg);\r
- }\r
-\r
- /**\r
- * Constructor.\r
- * @param msg Exception message. (NotNull)\r
- * @param cause Throwable.\r
- */\r
- public IfCommentWrongExpressionException(String msg, Throwable cause) {\r
- super(msg, cause);\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.exception;\r
-\r
-/**\r
- * The exception of when the outside-sql is not found.\r
- * \r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class OutsideSqlNotFoundException extends RuntimeException {\r
-\r
- /** Serial version UID. (Default) */\r
- private static final long serialVersionUID = 1L;\r
-\r
- /**\r
- * Constructor.\r
- * \r
- * @param msg Exception message.\r
- */\r
- public OutsideSqlNotFoundException(String msg) {\r
- super(msg);\r
- }\r
-\r
- /**\r
- * Constructor.\r
- * \r
- * @param msg Exception message.\r
- * @param cause Throwable.\r
- */\r
- public OutsideSqlNotFoundException(String msg, Throwable cause) {\r
- super(msg, cause);\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.exception;\r
-\r
-/**\r
- * The exception when the record has already been deleted (by other thread). <br />\r
- * This class is old.\r
- * \r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class RecordHasAlreadyBeenDeletedException extends RuntimeException {\r
-\r
- /** Serial version UID. (Default) */\r
- private static final long serialVersionUID = 1L;\r
-\r
- /**\r
- * Constructor.\r
- * \r
- * @param msg Exception message.\r
- */\r
- public RecordHasAlreadyBeenDeletedException(String msg) {\r
- super(msg);\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.exception;\r
-\r
-/**\r
- * The exception when the record has overlapped.\r
- * This class is old.\r
- * \r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class RecordHasOverlappedException extends RuntimeException {\r
-\r
- /** Serial version UID. (Default) */\r
- private static final long serialVersionUID = 1L;\r
-\r
- /**\r
- * Constructor.\r
- * \r
- * @param msg Exception message.\r
- */\r
- public RecordHasOverlappedException(String msg) {\r
- super(msg);\r
- }\r
-\r
- /**\r
- * Constructor.\r
- * \r
- * @param msg Exception message.\r
- * @param cause Throwable.\r
- */\r
- public RecordHasOverlappedException(String msg, Throwable cause) {\r
- super(msg, cause);\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.exception;\r
-\r
-/**\r
- * The exception of when the required option is not found.\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class RequiredOptionNotFoundException extends RuntimeException {\r
-\r
- /** Serial version UID. (Default) */\r
- private static final long serialVersionUID = 1L;\r
-\r
- /**\r
- * Constructor.\r
- * @param msg Exception message.\r
- */\r
- public RequiredOptionNotFoundException(String msg) {\r
- super(msg);\r
- }\r
-\r
- /**\r
- * Constructor.\r
- * @param msg Exception message.\r
- * @param cause Throwable.\r
- */\r
- public RequiredOptionNotFoundException(String msg, Throwable cause) {\r
- super(msg, cause);\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.exception;\r
-\r
-import java.sql.SQLException;\r
-\r
-/**\r
- * The exception of when the SQL failed to execute.\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class SQLFailureException extends RuntimeException {\r
-\r
- /** Serial version UID. (Default) */\r
- private static final long serialVersionUID = 1L;\r
-\r
- protected SQLException sqlEx;\r
-\r
- /**\r
- * Constructor.\r
- * @param msg Exception message. (NotNull)\r
- * @param cause SQLException. (NotNull)\r
- */\r
- public SQLFailureException(String msg, SQLException cause) {\r
- super(msg, cause);\r
- sqlEx = cause;\r
- }\r
- \r
- public SQLException getSQLException() {\r
- return sqlEx;\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.helper.character.impl;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.helper.character.GeneralCharacter;\r
-\r
-/**\r
- * The implementation of general character.\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class GeneralCharacterImpl implements GeneralCharacter {\r
-\r
- public String toSingleByteAlphabet(String target) {\r
- if (target == null) {\r
- return target;\r
- }\r
- final StringBuffer sb = new StringBuffer();\r
- for (int i = 0; i < target.length(); i++) {\r
- final char currentChar = target.charAt(i);\r
-\r
- if (currentChar >= 0xff21 && currentChar <= 0xff3a) {\r
- sb.append(toSingleByteCharacter(currentChar));\r
- } else if (currentChar >= 0xff41 && currentChar <= 0xff5a) {\r
- sb.append(toSingleByteCharacter(currentChar));\r
- } else {\r
- sb.append(currentChar);\r
- }\r
- }\r
- return sb.toString();\r
- }\r
-\r
- public String toSingleByteNumber(String target) {\r
- if (target == null) {\r
- return target;\r
- }\r
- final StringBuffer sb = new StringBuffer();\r
- for (int i = 0; i < target.length(); i++) {\r
- final char currentChar = target.charAt(i);\r
- if (currentChar >= 0xff10 && currentChar <= 0xff19) {\r
- sb.append(toSingleByteCharacter(currentChar));\r
- } else {\r
- sb.append(currentChar);\r
- }\r
- }\r
- return sb.toString();\r
- }\r
-\r
- public String toSingleByteAlphabetNumber(String target) {\r
- if (target == null) {\r
- return target;\r
- }\r
- final StringBuffer sb = new StringBuffer();\r
- for (int i = 0; i < target.length(); i++) {\r
- final char currentChar = target.charAt(i);\r
-\r
- if (currentChar >= 0xff10 && currentChar <= 0xff19) {\r
- sb.append(toSingleByteCharacter(currentChar));\r
- } else if (currentChar >= 0xff21 && currentChar <= 0xff3a) {\r
- sb.append(toSingleByteCharacter(currentChar));\r
- } else if (currentChar >= 0xff41 && currentChar <= 0xff5a) {\r
- sb.append(toSingleByteCharacter(currentChar));\r
- } else {\r
- sb.append(currentChar);\r
- }\r
- }\r
- return sb.toString();\r
- }\r
-\r
- public String toSingleByteAlphabetNumberMark(String target) {\r
- if (target == null) {\r
- return target;\r
- }\r
- final StringBuffer sb = new StringBuffer(target.length());\r
- for (int i = 0; i < target.length(); i++) {\r
- final char currentChar = target.charAt(i);\r
- if (currentChar >= 0xff01 && currentChar <= 0xff5e) {\r
- sb.append(toSingleByteCharacter(currentChar));\r
-\r
- // It needs to append more mark...\r
- } else if (currentChar == '\u2019' || currentChar == '\u2018' || currentChar == '\u2032') {\r
- sb.append('\'');\r
- } else if (currentChar == '\u201d' || currentChar == '\u201c' || currentChar == '\u2033') {\r
- sb.append('\"');\r
- } else if (currentChar == '\uffe5') {\r
- sb.append('\\');\r
- } else if (currentChar == '\u2010') {\r
- sb.append('-');\r
- } else if (currentChar == '\uff5e') {\r
- sb.append('~');\r
- } else {\r
- sb.append(currentChar);\r
- }\r
- }\r
- return sb.toString();\r
- }\r
-\r
- protected char toSingleByteCharacter(final char currentChar) {\r
- return (char) (currentChar - 0xfee0);\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.helper.character.impl;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.helper.character.JapaneseCharacter;\r
-\r
-/**\r
- * The implementation of Japanese character.\r
- *\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class JapaneseCharacterImpl implements JapaneseCharacter {\r
-\r
- // Double-byte Katakana\r
- protected static final String TABLE_ZENKANA = \r
- "\u3002\u300c\u300d\u3001\u30fb\u30f2\u30a1\u30a3\u30a5"\r
- + "\u30a7\u30a9\u30e3\u30e5\u30e7\u30c3\u30fc\u30a2\u30a4"\r
- + "\u30a6\u30a8\u30aa\u30ab\u30ad\u30af\u30b1\u30b3\u30b5"\r
- + "\u30b7\u30b9\u30bb\u30bd\u30bf\u30c1\u30c4\u30c6\u30c8"\r
- + "\u30ca\u30cb\u30cc\u30cd\u30ce\u30cf\u30d2\u30d5\u30d8"\r
- + "\u30db\u30de\u30df\u30e0\u30e1\u30e2\u30e4\u30e6\u30e8"\r
- + "\u30e9\u30ea\u30eb\u30ec\u30ed\u30ef\u30f3\u309b\u309c";\r
-\r
- // (uff71 - uff9d)\r
- protected static final String DEF_DOUBLE_BYTE_VOICED_SOUND_NORMAL_KATAKANA = \r
- "\u30a2\u30a4\u30f4\u30a8\u30aa" +\r
- "\u30ac\u30ae\u30b0\u30b2\u30b4" +\r
- "\u30b6\u30b8\u30ba\u30bc\u30be" +\r
- "\u30c0\u30c2\u30c5\u30c7\u30c9" +\r
- "\u30ca\u30cb\u30cc\u30cd\u30ce" +\r
- "\u30d0\u30d3\u30d6\u30d9\u30dc" +\r
- "\u30de\u30df\u30e0\u30e1\u30e2" +\r
- "\u30e4\u30e6\u30e8" +\r
- "\u30e9\u30ea\u30eb\u30ec\u30ed" +\r
- "\u30ef\u30f3";\r
-\r
- // (uff66 - uff6f)\r
- protected static final String DEF_DOUBLE_BYTE_VOICED_SOUND_SPECIAL_KATAKANA = "\u30fa\u30a1\u30a3\u30a5\u30a7\u30a9\u30e3\u30e5\u30e7";\r
-\r
- // (u30cf - u30dd)\r
- protected static final String DEF_DOUBLE_BYTE_SEMI_VOICED_SOUND_KATAKANA = "\u30d1\u30d4\u30d7\u30da\u30dd";\r
-\r
- public String toDoubleByteKatakana(String target) {\r
- if (target == null) {\r
- return target;\r
- }\r
-\r
- final StringBuffer sb = new StringBuffer();\r
- for (int i = 0; i < target.length(); i++) {\r
- final char currentChar = target.charAt(i);\r
- final char nextChar;\r
- if (i < target.length() - 1) {\r
- nextChar = target.charAt(i + 1);\r
- } else {\r
- nextChar = ' ';\r
- }\r
-\r
- if (isVoicedSoundKatakana(currentChar, nextChar)) {\r
- if (currentChar >= 0xff66 && currentChar <= 0xff6f) {// Voiced sound special Katakana\r
- sb.append(DEF_DOUBLE_BYTE_VOICED_SOUND_SPECIAL_KATAKANA.charAt(currentChar - 0xff66));\r
- i++;\r
- } else if (currentChar >= 0xff71 && currentChar <= 0xff9d) {// Voiced sound normal Katakana\r
- sb.append(DEF_DOUBLE_BYTE_VOICED_SOUND_NORMAL_KATAKANA.charAt(currentChar - 0xff71));\r
- i++;\r
- }\r
-\r
- } else if (isSemiVoicedSoundKatakana(currentChar, nextChar)) {\r
- sb.append(DEF_DOUBLE_BYTE_SEMI_VOICED_SOUND_KATAKANA.charAt(currentChar - 0xff8a));\r
- i++;\r
- } else if (currentChar != 0xff9e && currentChar != 0xff9f) {\r
- if (currentChar >= 0xff61 && currentChar <= 0xff9f) {\r
- sb.append(TABLE_ZENKANA.charAt(currentChar - 0xff61));\r
- } else {\r
- sb.append(currentChar);\r
- }\r
- }\r
- }\r
- return sb.toString();\r
- }\r
-\r
- protected boolean isVoicedSoundKatakana(final char currentChar, final char nextChar) {\r
- return ((currentChar >= 0xff66 && currentChar <= 0xff6f) || (currentChar >= 0xff71 && (currentChar <= 0xff9d)))\r
- && (nextChar == 0xff9e);\r
- }\r
-\r
- protected boolean isSemiVoicedSoundKatakana(final char currentChar, final char nextChar) {\r
- return (currentChar >= 0xff8a && currentChar <= 0xff8e) && (nextChar == 0xff9f);\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.helper.collection.order.impl;\r
-\r
-import java.util.Collections;\r
-import java.util.Comparator;\r
-import java.util.LinkedHashMap;\r
-import java.util.List;\r
-import java.util.Map;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.helper.collection.order.AccordingToOrder;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.helper.collection.order.AccordingToOrderIdExtractor;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.helper.collection.order.AccordingToOrderOption;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class AccordingToOrderImpl implements AccordingToOrder {\r
-\r
- // ===================================================================================\r
- // Main\r
- // ====\r
- /**\r
- * The implementation.\r
- * \r
- * @param unorderedList The unordered list. (NotNull)\r
- * @param option The option of according-to-order. (NotNull)\r
- * @param <ELEMENT_TYPE> The type of element.\r
- * @param <ID_TYPE> The type of ID.\r
- */\r
- public <ELEMENT_TYPE, ID_TYPE> void order(final List<ELEMENT_TYPE> unorderedList, final AccordingToOrderOption<ELEMENT_TYPE, ID_TYPE> option) {\r
- assertObjectNotNull("unorderedList", unorderedList);\r
- if (unorderedList.isEmpty()) {\r
- return;\r
- }\r
- assertObjectNotNull("option", option);\r
- final List<ID_TYPE> orderedUniqueIdList = option.getOrderedUniqueIdList();\r
- assertObjectNotNull("option.getOrderedUniqueIdList()", orderedUniqueIdList);\r
- if (orderedUniqueIdList.isEmpty()) {\r
- return;\r
- }\r
- final AccordingToOrderIdExtractor<ELEMENT_TYPE, ID_TYPE> idExtractor = option.getIdExtractor();\r
- assertObjectNotNull("option.getIdExtractor()", idExtractor);\r
-\r
- final Map<ID_TYPE, Integer> idIndexMap = new LinkedHashMap<ID_TYPE, Integer>();\r
- int index = 0;\r
- for (ID_TYPE id : orderedUniqueIdList) {\r
- if (idIndexMap.containsKey(id)) {\r
- String msg = "The id was duplicated: id=" + id + " orderedUniqueIdList=" + orderedUniqueIdList;\r
- throw new IllegalStateException(msg);\r
- }\r
- idIndexMap.put(id, index);\r
- ++index;\r
- }\r
- final Comparator<ELEMENT_TYPE> comp = new Comparator<ELEMENT_TYPE>() {\r
- public int compare(ELEMENT_TYPE o1, ELEMENT_TYPE o2) {\r
- final ID_TYPE id1 = idExtractor.extractId(o1);\r
- final ID_TYPE id2 = idExtractor.extractId(o2);\r
- assertObjectNotNull("id1 of " + o1, id1);\r
- assertObjectNotNull("id2 of " + o2, id2);\r
- final Integer index1 = idIndexMap.get(id1);\r
- final Integer index2 = idIndexMap.get(id2);\r
- if (index1 != null && index2 != null) {\r
- return index1.compareTo(index2);\r
- }\r
- if (index1 == null && index2 == null) {\r
- return 0;\r
- }\r
- return index1 == null ? 1 : -1;\r
- }\r
- };\r
- Collections.sort(unorderedList, comp);\r
- }\r
-\r
- // ===================================================================================\r
- // Assert Helper\r
- // =============\r
- /**\r
- * Assert that the object is not null.\r
- * \r
- * @param variableName Variable name. (NotNull)\r
- * @param value Value. (NotNull)\r
- * @exception IllegalArgumentException\r
- */\r
- protected void assertObjectNotNull(String variableName, Object value) {\r
- if (variableName == null) {\r
- String msg = "The value should not be null: variableName=" + variableName + " value=" + value;\r
- throw new IllegalArgumentException(msg);\r
- }\r
- if (value == null) {\r
- String msg = "The value should not be null: variableName=" + variableName;\r
- throw new IllegalArgumentException(msg);\r
- }\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.helper.stacktrace.impl;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.helper.stacktrace.InvokeNameResult;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.helper.stacktrace.InvokeNameExtractingResource;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.helper.stacktrace.InvokeNameExtractor;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class InvokeNameExtractorImpl implements InvokeNameExtractor {\r
-\r
- // ==========================================================================================\r
- // Attribute\r
- // =========\r
- protected StackTraceElement[] _stackTrace;\r
-\r
- // ==========================================================================================\r
- // Main\r
- // ====\r
- /**\r
- * @param resource the call-back resource for invoke-name-extracting. (NotNull)\r
- * @return Invoke name. (NotNull: If not found, returns empty string.)\r
- */\r
- public InvokeNameResult extractInvokeName(InvokeNameExtractingResource resource) {\r
- if (_stackTrace == null) {\r
- String msg = "The attribute 'stackTrace' should not be null: resource=" + resource;\r
- throw new IllegalStateException(msg);\r
- }\r
- String targetSimpleClassName = null;\r
- String targetMethodName = null;\r
- int lineNumber = 0;\r
- int foundIndex = -1; // The minus one means 'Not Found'.\r
- int foundFirstIndex = -1; // The minus one means 'Not Found'.\r
- boolean onTarget = false;\r
- for (int i=resource.getStartIndex(); i < _stackTrace.length; i++) {\r
- final StackTraceElement element = _stackTrace[i];\r
- if (i > resource.getStartIndex() + resource.getLoopSize()) {\r
- break;\r
- }\r
- final String className = element.getClassName();\r
- if (className.startsWith("sun.") || className.startsWith("java.")) {\r
- if (onTarget) {\r
- break;\r
- }\r
- continue;\r
- }\r
- final String methodName = element.getMethodName();\r
- if (resource.isTargetElement(className, methodName)) {\r
- if (methodName.equals("invoke")) {\r
- continue;\r
- }\r
- targetSimpleClassName = className.substring(className.lastIndexOf(".") + 1);\r
- targetMethodName = methodName;\r
- if (resource.isUseAdditionalInfo()) {\r
- lineNumber = element.getLineNumber();\r
- }\r
- foundIndex = i;\r
- if (foundFirstIndex == -1) {\r
- foundFirstIndex = i;\r
- }\r
- onTarget = true;\r
- continue;\r
- }\r
- if (onTarget) {\r
- break;\r
- }\r
- }\r
- final InvokeNameResult result = new InvokeNameResult();\r
- if (targetSimpleClassName == null) {\r
- result.beEmptyResult(); // Not Found! It sets empty result.\r
- return result;\r
- }\r
- final String filteredClassName = resource.filterSimpleClassName(targetSimpleClassName);\r
- result.setSimpleClassName(resource.filterSimpleClassName(targetSimpleClassName));\r
- result.setMethodName(targetMethodName);\r
- if (lineNumber > 0) {\r
- result.setInvokeName(filteredClassName + "." + targetMethodName + "():" + lineNumber + " --> ");\r
- } else {\r
- result.setInvokeName(filteredClassName + "." + targetMethodName + "() --> ");\r
- }\r
- result.setFoundIndex(foundIndex);\r
- result.setFoundFirstIndex(foundFirstIndex);\r
- return result;\r
- }\r
-\r
- // ==========================================================================================\r
- // Accessor\r
- // ========\r
- public void setStackTrace(StackTraceElement[] stackTrace) {\r
- _stackTrace = stackTrace;\r
- }\r
-}
\ No newline at end of file
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.helper.token.file.impl;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.helper.token.file.FileToken;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.helper.token.file.FileMakingCallback;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.helper.token.file.FileMakingOption;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.helper.token.file.FileMakingRowResource;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.helper.token.file.FileMakingSimpleFacade;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class FileMakingSimpleFacadeImpl implements FileMakingSimpleFacade {\r
-\r
- protected FileToken _fileToken = new FileTokenImpl();\r
-\r
- public void setFileToken(FileToken fileToken) {\r
- this._fileToken = fileToken;\r
- }\r
-\r
- /**\r
- * Make token-file from row-list.\r
- * \r
- * @param filename Output target file name. (NotNull)\r
- * @param rowList Row-list composed of value-list. (NotNull)\r
- * @param fileMakingOption File-making option. (NotNull and Required{encoding and delimiter})\r
- * @throws java.io.FileNotFoundException\r
- * @throws java.io.IOException\r
- */\r
- public void makeFromRowList(final String filename, final java.util.List<java.util.List<String>> rowList, final FileMakingOption fileMakingOption) throws java.io.FileNotFoundException, java.io.IOException {\r
- final FileMakingCallback fileMakingCallback = new FileMakingCallback() {\r
- protected int rowCount = 0;\r
- public FileMakingRowResource getRowResource() {\r
- ++rowCount;\r
- if (rowList.size() < rowCount) {\r
- return null;// The End!\r
- }\r
- final java.util.List<String> valueList = (java.util.List<String>)rowList.get(rowCount - 1);\r
- final FileMakingRowResource fileMakingRowResource = new FileMakingRowResource();\r
- fileMakingRowResource.setValueList(valueList);\r
- return fileMakingRowResource;\r
- }\r
- };\r
- _fileToken.make(filename, fileMakingCallback, fileMakingOption);\r
- }\r
-\r
- /**\r
- * Make bytes from row-list.\r
- * \r
- * @param rowList Row-list composed of value-list. (NotNull)\r
- * @param fileMakingOption File-making option. (NotNull and Required{encoding and delimiter})\r
- * @return Result byte array. (NotNull)\r
- * @throws java.io.FileNotFoundException\r
- * @throws java.io.IOException\r
- */\r
- public byte[] makeFromRowList(final java.util.List<java.util.List<String>> rowList, final FileMakingOption fileMakingOption) throws java.io.FileNotFoundException, java.io.IOException {\r
- final FileMakingCallback fileMakingCallback = new FileMakingCallback() {\r
- protected int rowCount = 0;\r
- public FileMakingRowResource getRowResource() {\r
- ++rowCount;\r
- if (rowList.size() < rowCount) {\r
- return null;// The End!\r
- }\r
- final java.util.List<String> valueList = (java.util.List<String>)rowList.get(rowCount - 1);\r
- final FileMakingRowResource fileMakingRowResource = new FileMakingRowResource();\r
- fileMakingRowResource.setValueList(valueList);\r
- return fileMakingRowResource;\r
- }\r
- };\r
- final java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();\r
- _fileToken.make(baos, fileMakingCallback, fileMakingOption);\r
- return baos.toByteArray();\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.helper.token.file.impl;\r
-\r
-import java.util.List;\r
-import java.util.ArrayList;\r
-import java.util.Iterator;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.helper.token.file.FileToken;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.helper.token.file.FileTokenizingCallback;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.helper.token.file.FileTokenizingOption;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.helper.token.file.FileTokenizingRowResource;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.helper.token.file.FileTokenizingHeaderInfo;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.helper.token.file.FileMakingCallback;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.helper.token.file.FileMakingOption;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.helper.token.file.FileMakingRowResource;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.helper.token.file.FileMakingHeaderInfo;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.helper.token.line.LineToken;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.helper.token.line.LineTokenizingOption;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.helper.token.line.LineMakingOption;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.helper.token.line.impl.LineTokenImpl;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class FileTokenImpl implements FileToken {\r
-\r
- // =====================================================================================\r
- // Attribute\r
- // =========\r
- /** Line-token for help. */\r
- protected final LineToken _lineToken = new LineTokenImpl();\r
-\r
- // =====================================================================================\r
- // Main\r
- // ====\r
- /**\r
- * Tokenize token-file data of a specified file.\r
- * \r
- * @param filename File name. (NotNull)\r
- * @param fileTokenizingCallback File-tokenizing callback. (NotNull)\r
- * @param fileTokenizingOption File-tokenizing option. (NotNull and Required{encoding and delimiter})\r
- * @throws java.io.FileNotFoundException\r
- * @throws java.io.IOException\r
- */\r
- public void tokenize(String filename, FileTokenizingCallback fileTokenizingCallback, FileTokenizingOption fileTokenizingOption) throws java.io.FileNotFoundException, java.io.IOException {\r
- assertStringNotNullAndNotTrimmedEmpty("filename", filename);\r
-\r
- java.io.FileInputStream fis = null;\r
- try {\r
- fis = new java.io.FileInputStream(filename);\r
- tokenize(fis, fileTokenizingCallback, fileTokenizingOption);\r
- } catch (java.io.FileNotFoundException e) {\r
- throw e;\r
- } catch (java.io.IOException e) {\r
- throw e;\r
- } finally {\r
- try {\r
- if (fis != null) {\r
- fis.close();\r
- }\r
- } catch (java.io.IOException ignored) {\r
- }\r
- }\r
- }\r
-\r
-\r
- /**\r
- * Tokenize token-file data of a specified file.\r
- * <pre>\r
- * This method uses java.io.InputStreamReader and java.io.BufferedReader that wrap the argument[inputStream].\r
- * These objects are closed. (Invoking close() at finally)\r
- * </pre>\r
- * @param inputStream Input target stream. (NotNull)\r
- * @param fileTokenizingCallback File-tokenizing callback. (NotNull)\r
- * @param fileTokenizingOption File-tokenizing option. (NotNull and Required{encoding and delimiter})\r
- * @throws java.io.FileNotFoundException\r
- * @throws java.io.IOException\r
- */\r
- public void tokenize(java.io.InputStream inputStream, FileTokenizingCallback fileTokenizingCallback, FileTokenizingOption fileTokenizingOption) throws java.io.FileNotFoundException, java.io.IOException {\r
- assertObjectNotNull("inputStream", inputStream);\r
- assertObjectNotNull("fileTokenizingCallback", fileTokenizingCallback);\r
- assertObjectNotNull("fileTokenizingOption", fileTokenizingOption);\r
- final String delimiter = fileTokenizingOption.getDelimiter();\r
- final String encoding = fileTokenizingOption.getEncoding();\r
- assertStringNotNullAndNotTrimmedEmpty("encoding", encoding);\r
- assertObjectNotNull("delimiter", delimiter);\r
-\r
- java.io.InputStreamReader ir = null;\r
- java.io.BufferedReader br = null;\r
-\r
- String lineString = null;\r
- String preContinueString = "";\r
- final List<String> temporaryValueList = new ArrayList<String>();\r
- final List<String> filteredValueList = new ArrayList<String>();\r
-\r
- try {\r
- ir = new java.io.InputStreamReader(inputStream, encoding);\r
- br = new java.io.BufferedReader(ir);\r
-\r
- FileTokenizingHeaderInfo fileTokenizingHeaderInfo = null;\r
- int count = -1;\r
- int rowNumber = 1;\r
- int lineNumber = 0;\r
- while (true) {\r
- ++count;\r
- if ("".equals(preContinueString)) {\r
- lineNumber = count + 1;\r
- }\r
-\r
- lineString = br.readLine();\r
- if (lineString == null) {\r
- break;\r
- }\r
- if (count == 0) {\r
- if (fileTokenizingOption.isBeginFirstLine()) {\r
- fileTokenizingHeaderInfo = new FileTokenizingHeaderInfo();// As empty\r
- } else {\r
- fileTokenizingHeaderInfo = analyzeHeaderInfo(delimiter, lineString);\r
- continue;\r
- }\r
- }\r
- final String rowString;\r
- if (preContinueString.equals("")) {\r
- rowString = lineString;\r
- } else {\r
- final String lineSeparator = System.getProperty("line.separator");\r
- rowString = preContinueString + lineSeparator + lineString;\r
- }\r
- final ValueLineInfo valueLineInfo = arrangeValueList(rowString, delimiter);\r
- final List<String> ls = valueLineInfo.getValueList();\r
- if (valueLineInfo.isContinueNextLine()) {\r
- preContinueString = (String)ls.remove(ls.size() - 1);\r
- temporaryValueList.addAll(ls);\r
- continue;\r
- }\r
- temporaryValueList.addAll(ls);\r
-\r
- try {\r
- final FileTokenizingRowResource fileTokenizingRowResource = new FileTokenizingRowResource();\r
- fileTokenizingRowResource.setFirstLineInfo(fileTokenizingHeaderInfo);\r
-\r
- if (fileTokenizingOption.isHandleEmptyAsNull()) {\r
- for (final Iterator<String> ite = temporaryValueList.iterator(); ite.hasNext(); ) {\r
- final String value = (String)ite.next();\r
- if ("".equals(value)) {\r
- filteredValueList.add(null);\r
- } else {\r
- filteredValueList.add(value);\r
- }\r
- }\r
- fileTokenizingRowResource.setValueList(filteredValueList);\r
- } else {\r
- fileTokenizingRowResource.setValueList(temporaryValueList);\r
- }\r
-\r
- fileTokenizingRowResource.setRowString(rowString);\r
- fileTokenizingRowResource.setRowNumber(rowNumber);\r
- fileTokenizingRowResource.setLineNumber(lineNumber);\r
- fileTokenizingCallback.handleRowResource(fileTokenizingRowResource);\r
- } finally {\r
- ++rowNumber;\r
- temporaryValueList.clear();\r
- filteredValueList.clear();\r
- preContinueString = "";\r
- }\r
- }\r
- } catch (java.io.FileNotFoundException e) {\r
- throw e;\r
- } catch (java.io.IOException e) {\r
- throw e;\r
- } finally {\r
- try {\r
- if (ir != null) {\r
- ir.close();\r
- }\r
- if (br != null) {\r
- br.close();\r
- }\r
- } catch (java.io.IOException ignored) {\r
- }\r
- }\r
- }\r
-\r
- protected ValueLineInfo arrangeValueList(final String lineString, String delimiter) {\r
- final List<String> valueList = new ArrayList<String>();\r
-\r
- // Don't use split!\r
- // final String[] values = lineString.split(delimiter);\r
- final LineTokenizingOption tokenizingOption = new LineTokenizingOption();\r
- tokenizingOption.setDelimiter(delimiter);\r
- final List<String> list = _lineToken.tokenize(lineString, tokenizingOption);\r
- final String[] values = (String[])list.toArray(new String[list.size()]);\r
- for (int i=0; i < values.length; i++) {\r
- valueList.add(values[i]);\r
- }\r
- return arrangeValueList(valueList, delimiter);\r
- }\r
-\r
- protected ValueLineInfo arrangeValueList(List<String> valueList, String delimiter) {\r
- final ValueLineInfo valueLineInfo = new ValueLineInfo();\r
- final ArrayList<String> resultList = new ArrayList<String>();\r
- String preString = "";\r
- for (int i = 0; i < valueList.size(); i++) {\r
- final String value = (String)valueList.get(i);\r
- if (value == null) {\r
- continue;\r
- }\r
- if (i == valueList.size() - 1) {// The last loop\r
- if (preString.equals("")) {\r
- if (isFrontQOnly(value)) {\r
- valueLineInfo.setContinueNextLine(true);\r
- resultList.add(value);\r
- break;\r
- } else if (isRearQOnly(value)) {\r
- resultList.add(value);\r
- break;\r
- } else if (isNotBothQ(value)) {\r
- resultList.add(value);\r
- break;\r
- } else {\r
- resultList.add(removeDoubleQuotation(value));\r
- break;\r
- }\r
- } else {\r
- if (isFrontQOnly(value)) {\r
- valueLineInfo.setContinueNextLine(true);\r
- resultList.add(connectPreString(preString, delimiter, value));\r
- break;\r
- } else if (isRearQOnly(value)) {\r
- resultList.add(removeDoubleQuotation(connectPreString(preString, delimiter, value)));\r
- break;\r
- } else if (isNotBothQ(value)) {\r
- valueLineInfo.setContinueNextLine(true);\r
- resultList.add(connectPreString(preString, delimiter, value));\r
- break;\r
- } else {\r
- resultList.add(removeDoubleQuotation(connectPreString(preString, delimiter, value)));\r
- break;\r
- }\r
- }\r
- }\r
-\r
- if (preString.equals("")) {\r
- if (isFrontQOnly(value)) {\r
- preString = value;\r
- continue;\r
- } else if (isRearQOnly(value)) {\r
- preString = value;\r
- continue;\r
- } else if (isNotBothQ(value)) {\r
- resultList.add(value);\r
- } else {\r
- resultList.add(removeDoubleQuotation(value));\r
- }\r
- } else {\r
- if (isFrontQOnly(value)) {\r
- preString = connectPreString(preString, delimiter, value);\r
- continue;\r
- } else if (isRearQOnly(value)) {\r
- resultList.add(removeDoubleQuotation(connectPreString(preString, delimiter, value)));\r
- } else if (isNotBothQ(value)) {\r
- preString = connectPreString(preString, delimiter, value);\r
- continue;\r
- } else {\r
- resultList.add(removeDoubleQuotation(connectPreString(preString, delimiter, value)));\r
- }\r
- }\r
- preString = "";\r
- }\r
- valueLineInfo.setValueList(resultList);\r
- return valueLineInfo;\r
- }\r
-\r
- protected String connectPreString(String preString, String delimiter, String value) {\r
- if (preString.equals("")) {\r
- return value;\r
- } else {\r
- return preString + delimiter + value;\r
- }\r
- }\r
-\r
- protected boolean isNotBothQ(final String value) {\r
- return !value.startsWith("\"") && !value.endsWith("\"");\r
- }\r
-\r
- protected boolean isRearQOnly(final String value) {\r
- return !value.startsWith("\"") && value.endsWith("\"");\r
- }\r
-\r
- protected boolean isFrontQOnly(final String value) {\r
- return value.startsWith("\"") && !value.endsWith("\"");\r
- }\r
-\r
- protected String removeDoubleQuotation(String value) {\r
- if (!value.startsWith("\"") && !value.endsWith("\"")) {\r
- return value;\r
- }\r
- if (value.startsWith("\"")) {\r
- value = value.substring(1);\r
- }\r
- if (value.endsWith("\"")) {\r
- value = value.substring(0, value.length() - 1);\r
- }\r
- return value;\r
- }\r
-\r
- protected String removeRightDoubleQuotation(String value) {\r
- if (value.endsWith("\"")) {\r
- value = value.substring(0, value.length() - 1);\r
- }\r
- return value;\r
- }\r
-\r
- protected FileTokenizingHeaderInfo analyzeHeaderInfo(String delimiter, final String lineString) {\r
- final java.util.List<String> columnNameList = new ArrayList<String>();\r
- final String[] values = lineString.split(delimiter);\r
- for (int i=0; i < values.length; i++) {\r
- final String value = values[i].trim();// Trimming is Header Only!;\r
- if (value.startsWith("\"") && value.endsWith("\"")) {\r
- columnNameList.add(value.substring(1, value.length() - 1));\r
- } else {\r
- columnNameList.add(value);\r
- }\r
- }\r
- final FileTokenizingHeaderInfo fileTokenizingHeaderInfo = new FileTokenizingHeaderInfo();\r
- fileTokenizingHeaderInfo.setColumnNameList(columnNameList);\r
- fileTokenizingHeaderInfo.setColumnNameRowString(lineString);\r
- return fileTokenizingHeaderInfo;\r
- }\r
-\r
- public static class ValueLineInfo {\r
- protected java.util.List<String> valueList;\r
-\r
- protected boolean continueNextLine;\r
-\r
- public java.util.List<String> getValueList() {\r
- return valueList;\r
- }\r
-\r
- public void setValueList(List<String> valueList) {\r
- this.valueList = valueList;\r
- }\r
-\r
- public boolean isContinueNextLine() {\r
- return continueNextLine;\r
- }\r
-\r
- public void setContinueNextLine(boolean continueNextLine) {\r
- this.continueNextLine = continueNextLine;\r
- }\r
- }\r
-\r
- /**\r
- * Make token-file from specified row resources.\r
- * \r
- * @param filename File name. (NotNull)\r
- * @param fileMakingCallback File-making callback. (NotNull)\r
- * @param fileMakingOption File-making option. (NotNull and Required{encoding and delimiter})\r
- * @throws java.io.FileNotFoundException\r
- * @throws java.io.IOException\r
- */\r
- public void make(String filename, FileMakingCallback fileMakingCallback, FileMakingOption fileMakingOption) throws java.io.FileNotFoundException, java.io.IOException {\r
- assertStringNotNullAndNotTrimmedEmpty("filename", filename);\r
-\r
- java.io.FileOutputStream fos = null;\r
- try {\r
- fos = new java.io.FileOutputStream(filename);\r
- make(fos, fileMakingCallback, fileMakingOption);\r
- } catch (java.io.FileNotFoundException e) {\r
- throw e;\r
- } catch (java.io.IOException e) {\r
- throw e;\r
- } finally {\r
- if (fos != null) {\r
- fos.close();\r
- }\r
- }\r
- }\r
-\r
- /**\r
- * Make token-file from specified row resources.\r
- * <pre>\r
- * This method uses java.io.BufferedOutputStream and java.io.OutputStreamWriter that wrap the argument[outputStream].\r
- * These objects are closed. (Invoking close() at finally)\r
- * </pre>\r
- * @param outputStream Output target stream. (NotNull)\r
- * @param fileMakingCallback File-making callback. (NotNull)\r
- * @param fileMakingOption File-making option. (NotNull and Required{encoding and delimiter})\r
- * @throws java.io.FileNotFoundException\r
- * @throws java.io.IOException\r
- */\r
- public void make(java.io.OutputStream outputStream, FileMakingCallback fileMakingCallback, FileMakingOption fileMakingOption) throws java.io.FileNotFoundException, java.io.IOException {\r
- assertObjectNotNull("outputStream", outputStream);\r
- assertObjectNotNull("fileMakingCallback", fileMakingCallback);\r
- assertObjectNotNull("fileMakingOption", fileMakingOption);\r
- final String encoding = fileMakingOption.getEncoding();\r
- final String delimiter = fileMakingOption.getDelimiter();\r
- assertStringNotNullAndNotTrimmedEmpty("encoding", encoding);\r
- assertObjectNotNull("delimiter", delimiter);\r
- final String lineSeparator;\r
- if (fileMakingOption.getLineSeparator() != null && !fileMakingOption.getLineSeparator().equals("")) {\r
- lineSeparator = fileMakingOption.getLineSeparator();\r
- } else {\r
- lineSeparator = System.getProperty("line.separator");// Default!\r
- }\r
-\r
- java.io.BufferedOutputStream bos = null;\r
- java.io.Writer writer = null;\r
- try {\r
- bos = new java.io.BufferedOutputStream(outputStream);\r
- writer = new java.io.OutputStreamWriter(bos, encoding);\r
-\r
- boolean headerDone = false;\r
-\r
- // Make header.\r
- final FileMakingHeaderInfo fileMakingHeaderInfo = fileMakingOption.getFileMakingHeaderInfo();\r
- if (fileMakingHeaderInfo != null) {\r
- final List<String> columnNameList = fileMakingHeaderInfo.getColumnNameList();\r
- if (columnNameList != null && !columnNameList.isEmpty()) {\r
- final LineMakingOption lineMakingOption = new LineMakingOption();\r
- lineMakingOption.setDelimiter(delimiter);\r
- lineMakingOption.trimSpace();// Trimming is Header Only!\r
- final String columnHeaderString = _lineToken.make(columnNameList, lineMakingOption);\r
- writer.write(columnHeaderString + lineSeparator);\r
- headerDone = true;\r
- }\r
- }\r
-\r
- // Make row.\r
- FileMakingRowResource rowResource = null;\r
- while (true) {\r
- rowResource = fileMakingCallback.getRowResource();\r
- if (rowResource == null) {\r
- break;// The End!\r
- }\r
- final java.util.List<String> valueList;\r
- if (rowResource.getValueList() != null) {\r
- valueList = rowResource.getValueList();\r
- } else {\r
- final java.util.LinkedHashMap<String, String> nameValueMap = rowResource.getNameValueMap();\r
- if (!headerDone) {\r
- final java.util.List<String> columnNameList = new java.util.ArrayList<String>(nameValueMap.keySet());\r
- final LineMakingOption lineMakingOption = new LineMakingOption();\r
- lineMakingOption.setDelimiter(delimiter);\r
- lineMakingOption.trimSpace();// Trimming is Header Only!\r
- final String columnHeaderString = _lineToken.make(columnNameList, lineMakingOption);\r
- writer.write(columnHeaderString + lineSeparator);\r
- headerDone = true;\r
- }\r
- valueList = new ArrayList<String>(nameValueMap.values());\r
- }\r
- final LineMakingOption lineMakingOption = new LineMakingOption();\r
- lineMakingOption.setDelimiter(delimiter);\r
- if (!fileMakingOption.isGoodByeDoubleQuotation()) {\r
- lineMakingOption.quoteByDoubleQuotation();\r
- }\r
- final String lineString = _lineToken.make(valueList, lineMakingOption);\r
- writer.write(lineString + lineSeparator);\r
- }\r
- writer.flush();\r
- } catch (java.io.FileNotFoundException e) {\r
- throw e;\r
- } catch (java.io.IOException e) {\r
- throw e;\r
- } finally {\r
- if (bos != null) {\r
- bos.close();\r
- }\r
- if (writer != null) {\r
- writer.close();\r
- }\r
- }\r
- }\r
-\r
- // ----------------------------------------------------------------\r
- // Assert Object\r
- // -------------\r
- /**\r
- * Assert that the object is not null.\r
- * \r
- * @param variableName Variable name. (NotNull)\r
- * @param value Value. (NotNull)\r
- * @exception IllegalArgumentException\r
- */\r
- protected void assertObjectNotNull(String variableName, Object value) {\r
- if (variableName == null) {\r
- String msg = "The value should not be null: variableName=" + variableName + " value=" + value;\r
- throw new IllegalArgumentException(msg);\r
- }\r
- if (value == null) {\r
- String msg = "The value should not be null: variableName=" + variableName;\r
- throw new IllegalArgumentException(msg);\r
- }\r
- }\r
-\r
- // ----------------------------------------------------------------\r
- // Assert String\r
- // -------------\r
- /**\r
- * Assert that the entity is not null and not trimmed empty.\r
- * \r
- * @param variableName Variable name. (NotNull)\r
- * @param value Value. (NotNull)\r
- */\r
- protected void assertStringNotNullAndNotTrimmedEmpty(String variableName, String value) {\r
- assertObjectNotNull("variableName", variableName);\r
- assertObjectNotNull(variableName, value);\r
- if (value.trim().length() ==0) {\r
- String msg = "The value should not be empty: variableName=" + variableName + " value=" + value;\r
- throw new IllegalArgumentException(msg);\r
- }\r
- }\r
-}
\ No newline at end of file
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.helper.token.line.impl;\r
-\r
-import java.util.List;\r
-import java.util.ArrayList;\r
-import java.util.Iterator;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.helper.token.line.LineToken;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.helper.token.line.LineTokenizingOption;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.helper.token.line.LineMakingOption;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class LineTokenImpl implements LineToken {\r
-\r
- public List<String> tokenize(String lineString, LineTokenizingOption lineTokenizingOption) {\r
- final String delimiter = lineTokenizingOption.getDelimiter();\r
- final List<String> list = new ArrayList<String>();\r
- int i = 0;\r
- int j = lineString.indexOf(delimiter);\r
- for (int h = 0; j >= 0; h++) {\r
- final String pureValue = lineString.substring(i, j);\r
- if (lineTokenizingOption.isTrimDoubleQuotation()) {\r
- final String before = pureValue;\r
- if (before.length() > 1 && before.startsWith("\"") && before.endsWith("\"")) {\r
- final String after = before.substring(1, before.length() - 1);\r
- list.add(filterHandlingEmptyAsNull(after, lineTokenizingOption));\r
- } else {\r
- list.add(filterHandlingEmptyAsNull(before, lineTokenizingOption));\r
- }\r
- } else {\r
- list.add(filterHandlingEmptyAsNull(pureValue, lineTokenizingOption));\r
- }\r
- i = j + 1;\r
- j = lineString.indexOf(delimiter, i);\r
- }\r
- list.add(filterHandlingEmptyAsNull(lineString.substring(i), lineTokenizingOption));\r
- return list;\r
- }\r
-\r
- protected String filterHandlingEmptyAsNull(String target, LineTokenizingOption lineTokenizingOption) {\r
- if (target == null) {\r
- return null;\r
- }\r
- if (lineTokenizingOption.isHandleEmtpyAsNull() && "".equals(target)) {\r
- return null;\r
- }\r
- return target;\r
- }\r
-\r
- public String make(java.util.List<String> valueList, LineMakingOption lineMakingOption) {\r
- assertObjectNotNull("valueList", valueList);\r
- assertObjectNotNull("lineMakingOption", lineMakingOption);\r
- final String delimiter = lineMakingOption.getDelimiter();\r
- assertObjectNotNull("lineMakingOption.getDelimiter()", delimiter);\r
- return createLineString(valueList, delimiter, lineMakingOption.isQuoteByDoubleQuotation(), lineMakingOption.isTrimSpace());\r
- }\r
-\r
- protected String createLineString(List<String> valueList, String delimiter, boolean quoteByDoubleQuotation, boolean trimSpace) {\r
- final StringBuffer sb = new StringBuffer();\r
- for (final Iterator<String> ite = valueList.iterator(); ite.hasNext(); ) {\r
- String value = (String)ite.next();\r
- value = (value != null ? value : "");\r
- if (trimSpace) {\r
- value = value.trim();\r
- }\r
- if (quoteByDoubleQuotation) {\r
- sb.append(delimiter).append("\"").append(value).append("\"");\r
- } else {\r
- sb.append(delimiter).append(value);\r
- }\r
- }\r
- sb.delete(0, delimiter.length());\r
- return sb.toString();\r
- }\r
-\r
- // ----------------------------------------------------------------\r
- // Assert Object\r
- // -------------\r
- /**\r
- * Assert that the object is not null.\r
- * \r
- * @param variableName Variable name. (NotNull)\r
- * @param value Value. (NotNull)\r
- * @exception IllegalArgumentException\r
- */\r
- protected void assertObjectNotNull(String variableName, Object value) {\r
- if (variableName == null) {\r
- String msg = "The value should not be null: variableName=" + variableName + " value=" + value;\r
- throw new IllegalArgumentException(msg);\r
- }\r
- if (value == null) {\r
- String msg = "The value should not be null: variableName=" + variableName;\r
- throw new IllegalArgumentException(msg);\r
- }\r
- }\r
-\r
- // ----------------------------------------------------------------\r
- // Assert String\r
- // -------------\r
- /**\r
- * Assert that the entity is not null and not trimmed empty.\r
- * \r
- * @param variableName Variable name. (NotNull)\r
- * @param value Value. (NotNull)\r
- */\r
- protected void assertStringNotNullAndNotTrimmedEmpty(String variableName, String value) {\r
- assertObjectNotNull("variableName", variableName);\r
- assertObjectNotNull(variableName, value);\r
- if (value.trim().length() ==0) {\r
- String msg = "The value should not be empty: variableName=" + variableName + " value=" + value;\r
- throw new IllegalArgumentException(msg);\r
- }\r
- }\r
-}
\ No newline at end of file
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.jdbc;\r
-\r
-/**\r
- * The interface of statement history witness.\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public interface CursorHandler {\r
-\r
- /**\r
- * @param resultSet Result set. (NotNull)\r
- * @return Result\r
- * @throws java.sql.SQLException\r
- */\r
- Object handle(java.sql.ResultSet resultSet) throws java.sql.SQLException;\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.jdbc;\r
-\r
-/**\r
- * The provider of latest SQL.\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public interface LatestSqlProvider {\r
-\r
- /**\r
- * Get display SQL.\r
- * @return Display SQL. (Nullable: If it was not found, returns null.)\r
- */\r
- public String getDisplaySql();\r
- \r
- /**\r
- * Clear the cache of SQL.\r
- */\r
- public void clearSqlCache();\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.jdbc;\r
-\r
-import java.sql.ResultSet;\r
-\r
-/**\r
- * The config of statement.\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class StatementConfig {\r
-\r
- // ===================================================================================\r
- // Attribute\r
- // =========\r
- // -----------------------------------------------------\r
- // ResultSet TYPE\r
- // --------------\r
- protected Integer _resultSetType;\r
- \r
- // -----------------------------------------------------\r
- // Statement Option\r
- // ----------------\r
- protected Integer _queryTimeout;\r
- protected Integer _fetchSize;\r
- protected Integer _maxRows;\r
- \r
- // ===================================================================================\r
- // Setting Interface\r
- // =================\r
- // -----------------------------------------------------\r
- // ResultSet TYPE\r
- // --------------\r
- public StatementConfig typeForwardOnly() {\r
- _resultSetType = ResultSet.TYPE_FORWARD_ONLY;\r
- return this;\r
- }\r
- \r
- public StatementConfig typeScrollInsensitive() {\r
- _resultSetType = ResultSet.TYPE_SCROLL_INSENSITIVE;\r
- return this;\r
- }\r
- \r
- public StatementConfig typeScrollSensitive() {\r
- _resultSetType = ResultSet.TYPE_SCROLL_SENSITIVE;\r
- return this;\r
- }\r
- \r
- // -----------------------------------------------------\r
- // Statement Option\r
- // ----------------\r
- public StatementConfig queryTimeout(int queryTimeout) {\r
- this._queryTimeout = queryTimeout;\r
- return this;\r
- }\r
- \r
- public StatementConfig fetchSize(int fetchSize) {\r
- this._fetchSize = fetchSize;\r
- return this;\r
- }\r
- \r
- public StatementConfig maxRows(int maxRows) {\r
- this._maxRows = maxRows;\r
- return this;\r
- }\r
- \r
- // ===================================================================================\r
- // Determination\r
- // =============\r
- // -----------------------------------------------------\r
- // ResultSet TYPE\r
- // --------------\r
- public boolean hasResultSetType() {\r
- return _resultSetType != null;\r
- }\r
- \r
- // -----------------------------------------------------\r
- // Statement Option\r
- // ----------------\r
- public boolean hasStatementOptions() {\r
- return hasQueryTimeout() || hasFetchSize() || hasMaxRows();\r
- }\r
- \r
- public boolean hasQueryTimeout() {\r
- return _queryTimeout != null;\r
- }\r
- \r
- public boolean hasFetchSize() {\r
- return _fetchSize != null;\r
- }\r
- \r
- public boolean hasMaxRows() {\r
- return _maxRows != null;\r
- }\r
- \r
- // ===================================================================================\r
- // Basic Override\r
- // ==============\r
- @Override\r
- public String toString() {\r
- return "{" + _resultSetType + ", " + _queryTimeout + ", " + _fetchSize + ", " + _maxRows + "}";\r
- }\r
- \r
- // ===================================================================================\r
- // Accessor\r
- // ========\r
- // -----------------------------------------------------\r
- // ResultSet TYPE\r
- // --------------\r
- public Integer getResultSetType() {\r
- return _resultSetType;\r
- }\r
- \r
- // -----------------------------------------------------\r
- // Statement Option\r
- // ----------------\r
- public Integer getQueryTimeout() {\r
- return _queryTimeout;\r
- }\r
- \r
- public Integer getFetchSize() {\r
- return _fetchSize;\r
- }\r
- \r
- public Integer getMaxRows() {\r
- return _maxRows;\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.rshandler;\r
-\r
-import java.sql.ResultSet;\r
-import java.sql.SQLException;\r
-import java.util.Map;\r
-import java.util.Set;\r
-\r
-import org.seasar.dao.BeanMetaData;\r
-import org.seasar.dao.RelationPropertyType;\r
-import org.seasar.dao.RelationRowCreator;\r
-import org.seasar.dao.RowCreator;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.Entity;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-@SuppressWarnings("unchecked")\r
-public abstract class InternalAbstractBeanMetaDataResultSetHandler extends InternalAbstractDtoMetaDataResultSetHandler {\r
-\r
- // ===================================================================================\r
- // Attribute\r
- // =========\r
- private BeanMetaData beanMetaData;\r
- protected RelationRowCreator relationRowCreator;\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- /**\r
- * @param beanMetaData Bean meta data. (NotNull)\r
- * @param rowCreator Row creator. (NotNull)\r
- * @param relationRowCreator Relation row creator. (NotNul)\r
- */\r
- public InternalAbstractBeanMetaDataResultSetHandler(BeanMetaData beanMetaData, RowCreator rowCreator, RelationRowCreator relationRowCreator) {\r
- super(beanMetaData, rowCreator);\r
- this.beanMetaData = beanMetaData;\r
- this.relationRowCreator = relationRowCreator;\r
- }\r
-\r
- // ===================================================================================\r
- // Assist Helper\r
- // =============\r
- /**\r
- * @param columnNames The set of column name. (NotNull)\r
- * @return The map of row property cache. Map{String(columnName), PropertyType} (NotNull)\r
- * @throws SQLException\r
- */\r
- protected Map createPropertyCache(Set columnNames) throws SQLException {\r
- // - - - - - - - - -\r
- // Override for Bean\r
- // - - - - - - - - -\r
- return rowCreator.createPropertyCache(columnNames, beanMetaData);\r
- }\r
-\r
- /**\r
- * @param rs Result set. (NotNull)\r
- * @param propertyCache The map of property cache. Map{String(columnName), PropertyType} (NotNull)\r
- * @return Created row. (NotNull)\r
- * @throws SQLException\r
- */\r
- protected Object createRow(ResultSet rs, Map propertyCache) throws SQLException {\r
- // - - - - - - - - -\r
- // Override for Bean\r
- // - - - - - - - - -\r
- final Class beanClass = beanMetaData.getBeanClass();\r
- return rowCreator.createRow(rs, propertyCache, beanClass);\r
- }\r
-\r
- /**\r
- * @param columnNames The set of column name. (NotNull)\r
- * @return The map of relation property cache. Map{String(relationNoSuffix), Map{String(columnName), PropertyType}} (NotNull)\r
- * @throws SQLException\r
- */\r
- protected Map createRelationPropertyCache(Set columnNames) throws SQLException {\r
- return relationRowCreator.createPropertyCache(columnNames, beanMetaData);\r
- }\r
-\r
- /**\r
- * @param rs Result set. (NotNull)\r
- * @param rpt The type of relation property. (NotNull)\r
- * @param columnNames The set of column name. (NotNull)\r
- * @param relKeyValues The map of rel key values. (Nullable)\r
- * @param relationPropertyCache The map of relation property cache. Map{String(relationNoSuffix), Map{String(columnName), PropertyType}} (NotNull)\r
- * @return Created relation row. (Nullable)\r
- * @throws SQLException\r
- */\r
- protected Object createRelationRow(ResultSet rs, RelationPropertyType rpt,\r
- Set columnNames, Map relKeyValues, Map relationPropertyCache) throws SQLException {\r
- return relationRowCreator.createRelationRow(rs, rpt, columnNames, relKeyValues, relationPropertyCache);\r
- }\r
-\r
- /**\r
- * @param row The row of result list. (NotNull)\r
- */\r
- protected void postCreateRow(final Object row) {\r
- if (row instanceof Entity) { // DBFlute Target\r
- ((Entity)row).clearModifiedPropertyNames();\r
- } else { // Basically Unreachable\r
- final BeanMetaData bmd = getBeanMetaData();\r
- final Set names = bmd.getModifiedPropertyNames(row);\r
- names.clear();\r
- }\r
- }\r
-\r
- // ===================================================================================\r
- // Accessor\r
- // ========\r
- public BeanMetaData getBeanMetaData() {\r
- return beanMetaData;\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.rshandler;\r
-\r
-import java.util.Map;\r
-import java.util.Set;\r
-import java.sql.ResultSet;\r
-import java.sql.ResultSetMetaData;\r
-import java.sql.SQLException;\r
-\r
-import org.seasar.framework.util.CaseInsensitiveSet;\r
-import org.seasar.extension.jdbc.ResultSetHandler;\r
-import org.seasar.dao.DtoMetaData;\r
-import org.seasar.dao.RowCreator;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-@SuppressWarnings("unchecked")\r
-public abstract class InternalAbstractDtoMetaDataResultSetHandler implements ResultSetHandler {\r
-\r
- // ===================================================================================\r
- // Attribute\r
- // =========\r
- private DtoMetaData dtoMetaData;\r
- protected RowCreator rowCreator; // [DAO-118] (2007/08/25)\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- /**\r
- * @param dtoMetaData Dto meta data. (NotNull)\r
- * @param rowCreator Row creator. (NotNull)\r
- */\r
- public InternalAbstractDtoMetaDataResultSetHandler(DtoMetaData dtoMetaData, RowCreator rowCreator) {\r
- this.dtoMetaData = dtoMetaData;\r
- this.rowCreator = rowCreator;\r
- }\r
-\r
- // ===================================================================================\r
- // Assist Helper\r
- // =============\r
- /**\r
- * @param columnNames The set of column name. (NotNull)\r
- * @return The map of row property cache. Map{String(columnName), PropertyType} (NotNull)\r
- * @throws SQLException\r
- */\r
- protected Map createPropertyCache(Set columnNames) throws SQLException {\r
- return rowCreator.createPropertyCache(columnNames, dtoMetaData);\r
- }\r
-\r
- /**\r
- * @param rs Result set. (NotNull)\r
- * @param propertyCache The map of property cache. Map{String(columnName), PropertyType} (NotNull)\r
- * @return Created row. (NotNull)\r
- * @throws SQLException\r
- */\r
- protected Object createRow(ResultSet rs, Map propertyCache) throws SQLException {\r
- final Class beanClass = dtoMetaData.getBeanClass();\r
- return rowCreator.createRow(rs, propertyCache, beanClass);\r
- }\r
-\r
- protected Set createColumnNames(final ResultSetMetaData rsmd) throws SQLException {\r
- final int count = rsmd.getColumnCount();\r
- final Set columnNames = new CaseInsensitiveSet();\r
- for (int i = 0; i < count; ++i) {\r
- final String columnName = rsmd.getColumnLabel(i + 1);\r
- final int pos = columnName.lastIndexOf('.'); // [DAO-41]\r
- if (-1 < pos) {\r
- columnNames.add(columnName.substring(pos + 1));\r
- } else {\r
- columnNames.add(columnName);\r
- }\r
- }\r
- return columnNames;\r
- }\r
-\r
- public DtoMetaData getDtoMetaData() {\r
- return dtoMetaData;\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.rshandler;\r
-\r
-import java.lang.reflect.Array;\r
-import java.sql.ResultSet;\r
-import java.sql.SQLException;\r
-import java.util.List;\r
-\r
-import org.seasar.dao.BeanMetaData;\r
-import org.seasar.dao.RelationRowCreator;\r
-import org.seasar.dao.RowCreator;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-@SuppressWarnings("unchecked")\r
-public class InternalBeanArrayMetaDataResultSetHandler extends InternalBeanListMetaDataResultSetHandler {\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- /**\r
- * @param beanMetaData Bean meta data. (NotNull)\r
- * @param rowCreator Row creator. (NotNull)\r
- * @param relationRowCreator Relation row creator. (NotNul)\r
- */\r
- public InternalBeanArrayMetaDataResultSetHandler(BeanMetaData beanMetaData, RowCreator rowCreator, RelationRowCreator relationRowCreator) {\r
- super(beanMetaData, rowCreator, relationRowCreator);\r
- }\r
- \r
- // ===================================================================================\r
- // Handle\r
- // ======\r
- public Object handle(ResultSet rs) throws SQLException {\r
- List list = (List) super.handle(rs);\r
- return list.toArray((Object[]) Array.newInstance(getBeanMetaData().getBeanClass(), list.size()));\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.rshandler;\r
-\r
-import java.util.ArrayList;\r
-import java.util.HashMap;\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.Set;\r
-import java.sql.ResultSet;\r
-import java.sql.SQLException;\r
-\r
-import org.seasar.framework.beans.PropertyDesc;\r
-import org.seasar.extension.jdbc.PropertyType;\r
-import org.seasar.extension.jdbc.ValueType;\r
-import org.seasar.dao.BeanMetaData;\r
-import org.seasar.dao.RelationPropertyType;\r
-import org.seasar.dao.RelationRowCreator;\r
-import org.seasar.dao.RowCreator;\r
-import org.seasar.dao.impl.RelationKey;\r
-import org.seasar.dao.impl.RelationRowCache;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.ConditionBean;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.ConditionBeanContext;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.outsidesql.OutsideSqlContext;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-@SuppressWarnings("unchecked")\r
-public class InternalBeanListMetaDataResultSetHandler extends InternalAbstractBeanMetaDataResultSetHandler {\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- /**\r
- * @param beanMetaData Bean meta data. (NotNull)\r
- * @param rowCreator Row creator. (NotNull)\r
- * @param relationRowCreator Relation row creator. (NotNul)\r
- */\r
- public InternalBeanListMetaDataResultSetHandler(BeanMetaData beanMetaData, RowCreator rowCreator, RelationRowCreator relationRowCreator) {\r
- super(beanMetaData, rowCreator, relationRowCreator);\r
- }\r
- \r
- // ===================================================================================\r
- // Handle\r
- // ======\r
- public Object handle(ResultSet rs) throws SQLException {\r
- // Lazy initialization because if the result is zero, the resources are unused.\r
- Set columnNames = null; // Set<String(columnName)>\r
- Map propertyCache = null; // Map<String(columnName), PropertyType>\r
- Map relationPropertyCache = null; // Map<String(relationNoSuffix), Map<String(columnName), PropertyType>>\r
- RelationRowCache relRowCache = null;\r
-\r
- final List list = new ArrayList();\r
- final int relSize = getBeanMetaData().getRelationPropertyTypeSize();\r
- final boolean hasCB = hasConditionBean();\r
- final boolean skipRelationLoop;\r
- {\r
- final boolean emptyRelation = isSelectedForeignInfoEmpty();\r
- final boolean hasOSC = hasOutsideSqlContext();\r
- final boolean specifiedOutsideSql = isSpecifiedOutsideSql();\r
-\r
- // If it has condition-bean that has no relation to get\r
- // or it has outside-sql context that is specified-outside-sql,\r
- // they are unnecessary to do relation loop!\r
- skipRelationLoop = (hasCB && emptyRelation) || (hasOSC && specifiedOutsideSql);\r
- }\r
-\r
- while (rs.next()) {\r
- if (columnNames == null) {\r
- columnNames = createColumnNames(rs.getMetaData());\r
- }\r
- if (propertyCache == null) {\r
- propertyCache = createPropertyCache(columnNames);\r
- }\r
-\r
- // Create row instance of base table by row property cache.\r
- final Object row = createRow(rs, propertyCache);\r
-\r
- // If it has condition-bean that has no relation to get\r
- // or it has outside-sql context that is specified-outside-sql,\r
- // they are unnecessary to do relation loop!\r
- if (skipRelationLoop) {\r
- postCreateRow(row);\r
- list.add(row);\r
- continue;\r
- }\r
-\r
- if (relationPropertyCache == null) {\r
- relationPropertyCache = createRelationPropertyCache(columnNames);\r
- }\r
- if (relRowCache == null) {\r
- relRowCache = new RelationRowCache(relSize);\r
- }\r
- for (int i = 0; i < relSize; ++i) {\r
- final RelationPropertyType rpt = getBeanMetaData().getRelationPropertyType(i);\r
- if (rpt == null) {\r
- continue;\r
- }\r
-\r
- // Do only selected foreign property for performance if condition-bean exists.\r
- if (hasCB && !hasSelectedForeignInfo(buildRelationNoSuffix(rpt))) {\r
- continue;\r
- }\r
-\r
- final Map relKeyValues = new HashMap();\r
- final RelationKey relKey = createRelationKey(rs, rpt, columnNames, relKeyValues);\r
- Object relationRow = null;\r
- if (relKey != null) {\r
- relationRow = relRowCache.getRelationRow(i, relKey);\r
- if (relationRow == null) { // when no cache\r
- relationRow = createRelationRow(rs, rpt, columnNames, relKeyValues, relationPropertyCache);\r
- if (relationRow != null) {\r
- relRowCache.addRelationRow(i, relKey, relationRow);\r
- postCreateRow(relationRow);\r
- }\r
- }\r
- }\r
- if (relationRow != null) {\r
- final PropertyDesc pd = rpt.getPropertyDesc();\r
- pd.setValue(row, relationRow);\r
- }\r
- }\r
- postCreateRow(row);\r
- list.add(row);\r
- }\r
- return list;\r
- }\r
-\r
- protected RelationKey createRelationKey(ResultSet rs, RelationPropertyType rpt, Set columnNames, Map relKeyValues) throws SQLException {\r
- final List keyList = new ArrayList();\r
- final BeanMetaData bmd = rpt.getBeanMetaData();\r
- for (int i = 0; i < rpt.getKeySize(); ++i) {\r
- final ValueType valueType;\r
- String columnName = rpt.getMyKey(i);\r
- if (columnNames.contains(columnName)) {\r
- final PropertyType pt = getBeanMetaData().getPropertyTypeByColumnName(columnName);\r
- valueType = pt.getValueType();\r
- } else {\r
- final PropertyType pt = bmd.getPropertyTypeByColumnName(rpt.getYourKey(i));\r
- columnName = pt.getColumnName() + buildRelationNoSuffix(rpt);\r
- if (columnNames.contains(columnName)) {\r
- valueType = pt.getValueType();\r
- } else {\r
- return null;\r
- }\r
- }\r
- final Object value = valueType.getValue(rs, columnName);\r
- if (value == null) {\r
- return null;\r
- }\r
- relKeyValues.put(columnName, value);\r
- keyList.add(value);\r
- }\r
- if (keyList.size() > 0) {\r
- Object[] keys = keyList.toArray();\r
- return new RelationKey(keys);\r
- } else {\r
- return null;\r
- }\r
- }\r
- \r
- // ===================================================================================\r
- // Assist Helper\r
- // =============\r
- protected boolean hasConditionBean() {\r
- return ConditionBeanContext.isExistConditionBeanOnThread();\r
- }\r
-\r
- protected boolean isSelectedForeignInfoEmpty() {\r
- if (!hasConditionBean()) {\r
- return true;\r
- }\r
- ConditionBean cb = ConditionBeanContext.getConditionBeanOnThread();\r
- if (cb.getSqlClause().isSelectedForeignInfoEmpty()) {\r
- return true;\r
- }\r
- return false;\r
- }\r
-\r
- /**\r
- * Has it selected foreign information?\r
- * You should call hasConditionBean() before calling this!\r
- * @param relationNoSuffix The suffix of relation NO. (NotNull)\r
- * @return Determination.\r
- */\r
- protected boolean hasSelectedForeignInfo(String relationNoSuffix) {\r
- final ConditionBean cb = ConditionBeanContext.getConditionBeanOnThread();\r
- if (cb.getSqlClause().hasSelectedForeignInfo(relationNoSuffix)) {\r
- return true;\r
- }\r
- return false;\r
- }\r
-\r
- /**\r
- * Build the string of relation No suffix.\r
- * @param rpt The property type of relation. (NotNull)\r
- * @return The string of relation No suffix. (NotNull)\r
- */\r
- protected String buildRelationNoSuffix(RelationPropertyType rpt) {\r
- return "_" + rpt.getRelationNo();\r
- }\r
-\r
- protected boolean hasOutsideSqlContext() {\r
- return OutsideSqlContext.isExistOutsideSqlContextOnThread();\r
- }\r
-\r
- protected boolean isSpecifiedOutsideSql() {\r
- if (!hasOutsideSqlContext()) {\r
- return false;\r
- }\r
- final OutsideSqlContext context = OutsideSqlContext.getOutsideSqlContextOnThread();\r
- return context.isSpecifiedOutsideSql();\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlcommand;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import javax.sql.DataSource;\r
-\r
-import org.seasar.dao.BeanMetaData;\r
-import org.seasar.dao.IdentifierGenerator;\r
-import org.seasar.dao.NotSingleRowUpdatedRuntimeException;\r
-import org.seasar.dao.PrimaryKeyNotFoundRuntimeException;\r
-import org.seasar.extension.jdbc.PropertyType;\r
-import org.seasar.extension.jdbc.StatementFactory;\r
-import org.seasar.framework.exception.SRuntimeException;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.exception.EntityAlreadyUpdatedException;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlhandler.InternalAbstractAutoHandler;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public abstract class InternalAbstractAutoStaticCommand extends InternalAbstractStaticCommand {\r
-\r
- // ===================================================================================\r
- // Definition\r
- // ==========\r
- protected static final boolean DEFAULT_VERSION_NO_AUTO_INCREMENT_ON_MEMORY = true;\r
-\r
- // ===================================================================================\r
- // Attribute\r
- // =========\r
- private PropertyType[] propertyTypes;\r
- private boolean checkSingleRowUpdate = true;\r
- protected boolean versionNoAutoIncrementOnMemory = DEFAULT_VERSION_NO_AUTO_INCREMENT_ON_MEMORY;\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- public InternalAbstractAutoStaticCommand(DataSource dataSource,\r
- StatementFactory statementFactory, BeanMetaData beanMetaData,\r
- String[] propertyNames) {\r
- this(dataSource, statementFactory, beanMetaData, propertyNames, DEFAULT_VERSION_NO_AUTO_INCREMENT_ON_MEMORY);\r
- }\r
-\r
- public InternalAbstractAutoStaticCommand(DataSource dataSource,\r
- StatementFactory statementFactory, BeanMetaData beanMetaData,\r
- String[] propertyNames, boolean versionNoAutoIncrementOnMemory) {\r
- super(dataSource, statementFactory, beanMetaData);\r
- this.versionNoAutoIncrementOnMemory = versionNoAutoIncrementOnMemory;\r
- setupPropertyTypes(propertyNames);\r
- setupSql();\r
- }\r
-\r
- // ===================================================================================\r
- // Execute\r
- // =======\r
- public Object execute(Object[] args) {\r
- InternalAbstractAutoHandler handler = createAutoHandler();\r
- handler.setSql(getSql());\r
- handler.setLoggingMessageSqlArgs(args);\r
- int rows = handler.execute(args);\r
- if (isCheckSingleRowUpdate() && rows != 1) {\r
- throw createNotSingleRowUpdatedRuntimeException(args[0], rows);\r
- }\r
- return new Integer(rows);\r
- }\r
-\r
- public boolean isCheckSingleRowUpdate() {\r
- return checkSingleRowUpdate;\r
- }\r
-\r
- public void setCheckSingleRowUpdate(boolean checkSingleRowUpdate) {\r
- this.checkSingleRowUpdate = checkSingleRowUpdate;\r
- }\r
-\r
- protected NotSingleRowUpdatedRuntimeException createNotSingleRowUpdatedRuntimeException(Object bean, int rows) {\r
- return new EntityAlreadyUpdatedException(bean, rows);\r
- }\r
-\r
- protected PropertyType[] getPropertyTypes() {\r
- return propertyTypes;\r
- }\r
-\r
- protected void setPropertyTypes(PropertyType[] propertyTypes) {\r
- this.propertyTypes = propertyTypes;\r
- }\r
-\r
- protected abstract InternalAbstractAutoHandler createAutoHandler();\r
-\r
- protected abstract void setupPropertyTypes(String[] propertyNames);\r
-\r
- protected void setupInsertPropertyTypes(String[] propertyNames) {\r
- List<PropertyType> types = new ArrayList<PropertyType>();\r
- for (int i = 0; i < propertyNames.length; ++i) {\r
- PropertyType pt = getBeanMetaData().getPropertyType(propertyNames[i]);\r
- if (isInsertTarget(pt)) {\r
- types.add(pt);\r
- }\r
- }\r
- propertyTypes = (PropertyType[]) types.toArray(new PropertyType[types.size()]);\r
- }\r
-\r
- protected boolean isInsertTarget(PropertyType propertyType) {\r
- if (propertyType.isPrimaryKey()) {\r
- String name = propertyType.getPropertyName();\r
- final IdentifierGenerator generator = getBeanMetaData().getIdentifierGenerator(name);\r
- return generator.isSelfGenerate();\r
- }\r
- return true;\r
- }\r
-\r
- protected void setupUpdatePropertyTypes(String[] propertyNames) {\r
- List<PropertyType> types = new ArrayList<PropertyType>();\r
- for (int i = 0; i < propertyNames.length; ++i) {\r
- PropertyType pt = getBeanMetaData().getPropertyType(propertyNames[i]);\r
- if (pt.isPrimaryKey()) {\r
- continue;\r
- }\r
- types.add(pt);\r
- }\r
- if (types.size() == 0) {\r
- throw new SRuntimeException("EDAO0020");\r
- }\r
- propertyTypes = (PropertyType[]) types.toArray(new PropertyType[types.size()]);\r
- }\r
-\r
- protected void setupDeletePropertyTypes(String[] propertyNames) {\r
- }\r
-\r
- protected abstract void setupSql();\r
-\r
- protected void setupInsertSql() {\r
- BeanMetaData bmd = getBeanMetaData();\r
- StringBuilder sb = new StringBuilder(100);\r
- sb.append("insert into ");\r
- sb.append(bmd.getTableName());\r
- sb.append(" (");\r
- for (int i = 0; i < propertyTypes.length; ++i) {\r
- PropertyType pt = propertyTypes[i];\r
- if (isInsertTarget(pt)) {\r
- sb.append(pt.getColumnName());\r
- sb.append(", ");\r
- }\r
- }\r
- sb.setLength(sb.length() - 2);\r
- sb.append(") values (");\r
- for (int i = 0; i < propertyTypes.length; ++i) {\r
- PropertyType pt = propertyTypes[i];\r
- if (isInsertTarget(pt)) {\r
- sb.append("?, ");\r
- }\r
- }\r
- sb.setLength(sb.length() - 2);\r
- sb.append(")");\r
- setSql(sb.toString());\r
- }\r
-\r
- protected void setupUpdateSql() {\r
- checkPrimaryKey();\r
- StringBuilder sb = new StringBuilder(100);\r
- sb.append("update ");\r
- sb.append(getBeanMetaData().getTableName());\r
- sb.append(" set ");\r
- String versionNoPropertyName = getBeanMetaData().getVersionNoPropertyName();\r
- for (int i = 0; i < propertyTypes.length; ++i) {\r
- PropertyType pt = propertyTypes[i];\r
- if (pt.getPropertyName().equalsIgnoreCase(versionNoPropertyName) && !versionNoAutoIncrementOnMemory) {\r
- sb.append(pt.getColumnName()).append(" = ").append(pt.getColumnName()).append(" + 1, ");\r
- continue;\r
- }\r
- sb.append(pt.getColumnName()).append(" = ?, ");\r
- }\r
- sb.setLength(sb.length() - 2);\r
- setupUpdateWhere(sb);\r
- setSql(sb.toString());\r
- }\r
-\r
- protected void setupDeleteSql() {\r
- checkPrimaryKey();\r
- StringBuilder sb = new StringBuilder(100);\r
- sb.append("delete from ");\r
- sb.append(getBeanMetaData().getTableName());\r
- setupUpdateWhere(sb);\r
- setSql(sb.toString());\r
- }\r
-\r
- protected void checkPrimaryKey() {\r
- BeanMetaData bmd = getBeanMetaData();\r
- if (bmd.getPrimaryKeySize() == 0) {\r
- throw new PrimaryKeyNotFoundRuntimeException(bmd.getBeanClass());\r
- }\r
- }\r
-\r
- protected void setupUpdateWhere(StringBuilder sb) {\r
- BeanMetaData bmd = getBeanMetaData();\r
- sb.append(" where ");\r
- for (int i = 0; i < bmd.getPrimaryKeySize(); ++i) {\r
- sb.append(bmd.getPrimaryKey(i)).append(" = ? and ");\r
- }\r
- sb.setLength(sb.length() - 5);\r
- if (bmd.hasVersionNoPropertyType()) {\r
- PropertyType pt = bmd.getVersionNoPropertyType();\r
- sb.append(" and ").append(pt.getColumnName()).append(" = ?");\r
- }\r
- if (bmd.hasTimestampPropertyType()) {\r
- PropertyType pt = bmd.getTimestampPropertyType();\r
- sb.append(" and ").append(pt.getColumnName()).append(" = ?");\r
- }\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlcommand;\r
-\r
-import javax.sql.DataSource;\r
-\r
-import org.seasar.extension.jdbc.StatementFactory;\r
-import org.seasar.dao.BeanMetaData;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlhandler.InternalAbstractBatchAutoHandler;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public abstract class InternalAbstractBatchAutoStaticCommand extends InternalAbstractAutoStaticCommand {\r
-\r
- // ===================================================================================\r
- // Attribute\r
- // =========\r
- protected final boolean returningRows;\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- public InternalAbstractBatchAutoStaticCommand(DataSource dataSource,\r
- StatementFactory statementFactory, BeanMetaData beanMetaData,\r
- String[] propertyNames, boolean returningRows) {\r
- this(dataSource, statementFactory, beanMetaData, propertyNames, returningRows, DEFAULT_VERSION_NO_AUTO_INCREMENT_ON_MEMORY);\r
- }\r
-\r
- public InternalAbstractBatchAutoStaticCommand(DataSource dataSource,\r
- StatementFactory statementFactory, BeanMetaData beanMetaData,\r
- String[] propertyNames, boolean returningRows, boolean versionNoAutoIncrementOnMemory) {\r
- super(dataSource, statementFactory, beanMetaData, propertyNames, versionNoAutoIncrementOnMemory);\r
- this.returningRows = returningRows;\r
- }\r
-\r
- // ===================================================================================\r
- // Execute\r
- // =======\r
- public Object execute(Object[] args) {\r
- final InternalAbstractBatchAutoHandler handler = createBatchAutoHandler();\r
- \r
- // It is unnecessary!\r
- // injectDaoClass(handler);\r
- \r
- handler.setSql(getSql());\r
- // The logging message SQL of procedure is unnecessary.\r
- // handler.setLoggingMessageSqlArgs(args);\r
- if (this.returningRows) {\r
- return handler.executeBatch(args);\r
- } else {\r
- final int updatedRows = handler.execute(args);\r
- return new Integer(updatedRows);\r
- }\r
- }\r
- \r
- protected abstract InternalAbstractBatchAutoHandler createBatchAutoHandler();\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlcommand;\r
-\r
-import javax.sql.DataSource;\r
-\r
-import org.seasar.dao.CommandContext;\r
-import org.seasar.dao.Node;\r
-import org.seasar.extension.jdbc.StatementFactory;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlparser.InternalCommandContextCreator;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlparser.InternalSqlParser;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public abstract class InternalAbstractDynamicCommand extends InternalAbstractSqlCommand {\r
-\r
- // ===================================================================================\r
- // Attribute\r
- // =========\r
- protected Node rootNode;\r
- protected String[] argNames = new String[0];\r
- protected Class<?>[] argTypes = new Class[0];\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- public InternalAbstractDynamicCommand(DataSource dataSource, StatementFactory statementFactory) {\r
- super(dataSource, statementFactory);\r
- }\r
-\r
- // ===================================================================================\r
- // Sql Handling\r
- // ============\r
- public void setSql(String sql) {\r
- super.setSql(sql);\r
- this.rootNode = createInternalSqlParser(sql).parse();\r
- }\r
- \r
- protected InternalSqlParser createInternalSqlParser(String sql) {\r
- return new InternalSqlParser(sql);\r
- }\r
-\r
- public CommandContext apply(Object[] args) {// It is necessary to be public!\r
- final CommandContext ctx = createCommandContext(args);\r
- rootNode.accept(ctx);\r
- return ctx;\r
- }\r
-\r
- protected CommandContext createCommandContext(Object[] args) {\r
- return createCommandContextCreator().createCommandContext(args);\r
- }\r
-\r
- protected InternalCommandContextCreator createCommandContextCreator() {\r
- return new InternalCommandContextCreator(argNames, argTypes);\r
- }\r
- \r
- // ===================================================================================\r
- // Accessor\r
- // ========\r
- public String[] getArgNames() {\r
- return argNames;\r
- }\r
-\r
- public void setArgNames(String[] argNames) {\r
- this.argNames = argNames;\r
- }\r
-\r
- public Class<?>[] getArgTypes() {\r
- return argTypes;\r
- }\r
-\r
- public void setArgTypes(Class<?>[] argTypes) {\r
- this.argTypes = argTypes;\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlcommand;\r
-\r
-import javax.sql.DataSource;\r
-\r
-import org.seasar.dao.SqlCommand;\r
-import org.seasar.extension.jdbc.StatementFactory;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public abstract class InternalAbstractSqlCommand implements SqlCommand {\r
-\r
- // ===================================================================================\r
- // Attribute\r
- // =========\r
- private DataSource dataSource;\r
- private StatementFactory statementFactory;\r
- private String sql;\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- public InternalAbstractSqlCommand(DataSource dataSource, StatementFactory statementFactory) {\r
- this.dataSource = dataSource;\r
- this.statementFactory = statementFactory;\r
- }\r
-\r
- // ===================================================================================\r
- // Accessor\r
- // ========\r
- public DataSource getDataSource() {\r
- return dataSource;\r
- }\r
-\r
- public StatementFactory getStatementFactory() {\r
- return statementFactory;\r
- }\r
-\r
- public String getSql() {\r
- return sql;\r
- }\r
-\r
- public void setSql(String sql) {\r
- this.sql = sql;\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlcommand;\r
-\r
-import javax.sql.DataSource;\r
-\r
-import org.seasar.dao.BeanMetaData;\r
-import org.seasar.extension.jdbc.StatementFactory;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public abstract class InternalAbstractStaticCommand extends InternalAbstractSqlCommand {\r
-\r
- // ===================================================================================\r
- // Attribute\r
- // =========\r
- private BeanMetaData beanMetaData;\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- public InternalAbstractStaticCommand(DataSource dataSource, StatementFactory statementFactory, BeanMetaData beanMetaData) {\r
- super(dataSource, statementFactory);\r
- this.beanMetaData = beanMetaData;\r
- }\r
-\r
- // ===================================================================================\r
- // Accessor\r
- // ========\r
- public BeanMetaData getBeanMetaData() {\r
- return beanMetaData;\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlcommand;\r
-\r
-import javax.sql.DataSource;\r
-\r
-import org.seasar.extension.jdbc.StatementFactory;\r
-import org.seasar.dao.BeanMetaData;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlhandler.InternalAbstractAutoHandler;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlhandler.InternalDeleteAutoHandler;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class InternalDeleteAutoStaticCommand extends InternalAbstractAutoStaticCommand {\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- public InternalDeleteAutoStaticCommand(DataSource dataSource,\r
- StatementFactory statementFactory, BeanMetaData beanMetaData,\r
- String[] propertyNames) {\r
- super(dataSource, statementFactory, beanMetaData, propertyNames);\r
- }\r
-\r
- // ===================================================================================\r
- // Override\r
- // ========\r
- @Override\r
- protected InternalAbstractAutoHandler createAutoHandler() {\r
- return new InternalDeleteAutoHandler(getDataSource(), getStatementFactory(), getBeanMetaData(), getPropertyTypes());\r
- }\r
- \r
- @Override\r
- protected void setupSql() {\r
- setupDeleteSql();\r
- }\r
-\r
- @Override\r
- protected void setupPropertyTypes(String[] propertyNames) {\r
- setupDeletePropertyTypes(propertyNames);\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlcommand;\r
-\r
-import javax.sql.DataSource;\r
-\r
-import org.seasar.extension.jdbc.StatementFactory;\r
-import org.seasar.dao.BeanMetaData;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlhandler.InternalAbstractAutoHandler;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlhandler.InternalAbstractBatchAutoHandler;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlhandler.InternalDeleteBatchAutoHandler;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class InternalDeleteBatchAutoStaticCommand extends InternalAbstractBatchAutoStaticCommand {\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- public InternalDeleteBatchAutoStaticCommand(DataSource dataSource,\r
- StatementFactory statementFactory, BeanMetaData beanMetaData,\r
- String[] propertyNames, boolean returningRows) {\r
- super(dataSource, statementFactory, beanMetaData, propertyNames, returningRows);\r
- }\r
-\r
- // ===================================================================================\r
- // Override\r
- // ========\r
- @Override\r
- protected InternalAbstractAutoHandler createAutoHandler() {\r
- return createBatchAutoHandler();\r
- }\r
-\r
- @Override\r
- protected InternalAbstractBatchAutoHandler createBatchAutoHandler() {\r
- return newInternalBatchAutoHandler();\r
- }\r
-\r
- protected InternalDeleteBatchAutoHandler newInternalBatchAutoHandler() {\r
- return new InternalDeleteBatchAutoHandler(getDataSource(), getStatementFactory(), getBeanMetaData(), getPropertyTypes());\r
- }\r
-\r
- @Override\r
- protected void setupSql() {\r
- setupDeleteSql();\r
- }\r
-\r
- @Override\r
- protected void setupPropertyTypes(String[] propertyNames) {\r
- setupDeletePropertyTypes(propertyNames);\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlcommand;\r
-\r
-import javax.sql.DataSource;\r
-\r
-import org.seasar.extension.jdbc.StatementFactory;\r
-import org.seasar.dao.CommandContext;\r
-import org.seasar.dao.Node;\r
-import org.seasar.dao.SqlCommand;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.ConditionBean;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlhandler.InternalCommandContextHandler;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlparser.InternalCommandContextCreator;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlparser.InternalSqlParser;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.util.SimpleSystemUtil;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class InternalDeleteQueryAutoDynamicCommand implements SqlCommand {\r
-\r
- // ===================================================================================\r
- // Attribute\r
- // =========\r
- protected DataSource dataSource;\r
- protected StatementFactory statementFactory;\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- public InternalDeleteQueryAutoDynamicCommand(DataSource dataSource, StatementFactory statementFactory) {\r
- this.dataSource = dataSource;\r
- this.statementFactory = statementFactory;\r
- }\r
-\r
- // ===================================================================================\r
- // Execute\r
- // =======\r
- public Object execute(Object[] args) {\r
- ConditionBean cb = extractConditionBeanWithCheck(args);\r
- String[] argNames = new String[]{"dto"};\r
- Class<?>[] argTypes = new Class<?>[]{cb.getClass()};\r
- String twoWaySql = buildQueryDeleteTwoWaySql(cb);\r
- CommandContext context = createCommandContext(twoWaySql, argNames, argTypes, args);\r
- InternalCommandContextHandler handler = createCommandContextHandler(context);\r
- handler.setLoggingMessageSqlArgs(context.getBindVariables());\r
- int rows = handler.execute(args);\r
- return new Integer(rows);\r
- }\r
- \r
- protected ConditionBean extractConditionBeanWithCheck(Object[] args) {\r
- if (args == null || args.length == 0) {\r
- String msg = "The arguments should have one argument! But:";\r
- msg = msg + " args=" + (args != null ? args.length : null);\r
- throw new IllegalArgumentException(msg);\r
- }\r
- Object fisrtArg = args[0];\r
- if (!(fisrtArg instanceof ConditionBean)) {\r
- String msg = "The type of argument should be " + ConditionBean.class + "! But:";\r
- msg = msg + " type=" + fisrtArg.getClass();\r
- throw new IllegalArgumentException(msg);\r
- }\r
- return (ConditionBean) fisrtArg;\r
- }\r
- \r
- protected InternalCommandContextHandler createCommandContextHandler(CommandContext context) {\r
- return new InternalCommandContextHandler(dataSource, statementFactory, context);\r
- }\r
-\r
- protected String buildQueryDeleteTwoWaySql(ConditionBean cb) {\r
- return cb.getSqlClause().getClauseQueryDelete();\r
- }\r
- \r
- protected CommandContext createCommandContext(String twoWaySql, String[] argNames, Class<?>[] argTypes, Object[] args) {\r
- CommandContext context;\r
- {\r
- InternalSqlParser parser = new InternalSqlParser(twoWaySql);\r
- Node node = parser.parse();\r
- InternalCommandContextCreator creator = new InternalCommandContextCreator(argNames, argTypes);\r
- context = creator.createCommandContext(args);\r
- node.accept(context);\r
- }\r
- return context;\r
- }\r
- \r
- // ===================================================================================\r
- // General Helper\r
- // ==============\r
- protected String getLineSeparator() {\r
- return SimpleSystemUtil.getLineSeparator();\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlcommand;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import javax.sql.DataSource;\r
-\r
-import org.seasar.dao.BeanMetaData;\r
-import org.seasar.dao.IdentifierGenerator;\r
-import org.seasar.dao.NotSingleRowUpdatedRuntimeException;\r
-import org.seasar.dao.SqlCommand;\r
-import org.seasar.extension.jdbc.PropertyType;\r
-import org.seasar.extension.jdbc.StatementFactory;\r
-import org.seasar.framework.exception.SRuntimeException;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlhandler.InternalInsertAutoHandler;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class InternalInsertAutoDynamicCommand implements SqlCommand {\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- protected DataSource dataSource;\r
- protected StatementFactory statementFactory;\r
- protected BeanMetaData beanMetaData;\r
- protected String[] propertyNames;\r
- protected boolean checkSingleRowUpdate = true;\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- public InternalInsertAutoDynamicCommand() {\r
- }\r
-\r
- // ===================================================================================\r
- // Execute\r
- // =======\r
- public Object execute(Object[] args) {\r
- final Object bean = args[0];\r
- final BeanMetaData bmd = getBeanMetaData();\r
- final PropertyType[] propertyTypes = createInsertPropertyTypes(bmd, bean, getPropertyNames());\r
- final String sql = createInsertSql(bmd, propertyTypes);\r
- final InternalInsertAutoHandler handler = new InternalInsertAutoHandler(getDataSource(), getStatementFactory(), bmd, propertyTypes);\r
- handler.setSql(sql);\r
- handler.setLoggingMessageSqlArgs(args);\r
- final int rows = handler.execute(args);\r
- if (isCheckSingleRowUpdate() && rows != 1) {\r
- throw new NotSingleRowUpdatedRuntimeException(args[0], rows);\r
- }\r
- return new Integer(rows);\r
- }\r
-\r
- protected String createInsertSql(BeanMetaData bmd,\r
- PropertyType[] propertyTypes) {\r
- StringBuffer buf = new StringBuffer(100);\r
- buf.append("insert into ");\r
- buf.append(bmd.getTableName());\r
- buf.append(" (");\r
- for (int i = 0; i < propertyTypes.length; ++i) {\r
- PropertyType pt = propertyTypes[i];\r
- final String columnName = pt.getColumnName();\r
- if (i > 0) {\r
- buf.append(", ");\r
- }\r
- buf.append(columnName);\r
- }\r
- buf.append(") values (");\r
- for (int i = 0; i < propertyTypes.length; ++i) {\r
- if (i > 0) {\r
- buf.append(", ");\r
- }\r
- buf.append("?");\r
- }\r
- buf.append(")");\r
- return buf.toString();\r
- }\r
-\r
- protected PropertyType[] createInsertPropertyTypes(BeanMetaData bmd, Object bean, String[] propertyNames) {\r
-\r
- if (0 == propertyNames.length) {\r
- throw new SRuntimeException("EDAO0024", new Object[] { bean.getClass().getName() });\r
- }\r
- List<PropertyType> types = new ArrayList<PropertyType>();\r
- final String timestampPropertyName = bmd.getTimestampPropertyName();\r
- final String versionNoPropertyName = bmd.getVersionNoPropertyName();\r
-\r
- for (int i = 0; i < propertyNames.length; ++i) {\r
- PropertyType pt = bmd.getPropertyType(propertyNames[i]);\r
- if (pt.isPrimaryKey()) {\r
- final IdentifierGenerator generator = bmd.getIdentifierGenerator(pt.getPropertyName());\r
- if (!generator.isSelfGenerate()) {\r
- continue;\r
- }\r
- } else {\r
- if (pt.getPropertyDesc().getValue(bean) == null) {\r
- final String propertyName = pt.getPropertyName();\r
- if (!propertyName.equalsIgnoreCase(timestampPropertyName)\r
- && !propertyName.equalsIgnoreCase(versionNoPropertyName)) {\r
- continue;\r
- }\r
- }\r
- }\r
- types.add(pt);\r
- }\r
- if (types.isEmpty()) {\r
- throw new SRuntimeException("EDAO0014");\r
- }\r
- PropertyType[] propertyTypes = (PropertyType[]) types.toArray(new PropertyType[types.size()]);\r
- return propertyTypes;\r
- }\r
-\r
- // ===================================================================================\r
- // Accessor\r
- // ========\r
- protected DataSource getDataSource() {\r
- return dataSource;\r
- }\r
-\r
- public void setDataSource(DataSource dataSource) {\r
- this.dataSource = dataSource;\r
- }\r
-\r
- protected StatementFactory getStatementFactory() {\r
- return statementFactory;\r
- }\r
-\r
- public void setStatementFactory(StatementFactory statementFactory) {\r
- this.statementFactory = statementFactory;\r
- }\r
-\r
- protected BeanMetaData getBeanMetaData() {\r
- return beanMetaData;\r
- }\r
-\r
- public void setBeanMetaData(BeanMetaData beanMetaData) {\r
- this.beanMetaData = beanMetaData;\r
- }\r
-\r
- protected String[] getPropertyNames() {\r
- return propertyNames;\r
- }\r
-\r
- public void setPropertyNames(String[] propertyNames) {\r
- this.propertyNames = propertyNames;\r
- }\r
-\r
- public boolean isCheckSingleRowUpdate() {\r
- return checkSingleRowUpdate;\r
- }\r
-\r
- public void setCheckSingleRowUpdate(boolean checkSingleRowUpdate) {\r
- this.checkSingleRowUpdate = checkSingleRowUpdate;\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlcommand;\r
-\r
-import javax.sql.DataSource;\r
-\r
-import org.seasar.extension.jdbc.StatementFactory;\r
-import org.seasar.dao.BeanMetaData;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlhandler.InternalAbstractAutoHandler;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlhandler.InternalAbstractBatchAutoHandler;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlhandler.InternalInsertBatchAutoHandler;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class InternalInsertBatchAutoStaticCommand extends InternalAbstractBatchAutoStaticCommand {\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- public InternalInsertBatchAutoStaticCommand(DataSource dataSource,\r
- StatementFactory statementFactory, BeanMetaData beanMetaData,\r
- String[] propertyNames, boolean returningRows) {\r
- super(dataSource, statementFactory, beanMetaData, propertyNames, returningRows);\r
- }\r
-\r
- // ===================================================================================\r
- // Override\r
- // ========\r
- @Override\r
- protected InternalAbstractAutoHandler createAutoHandler() {\r
- return createBatchAutoHandler();\r
- }\r
-\r
- @Override\r
- protected InternalAbstractBatchAutoHandler createBatchAutoHandler() {\r
- return new InternalInsertBatchAutoHandler(getDataSource(), getStatementFactory(), getBeanMetaData(), getPropertyTypes());\r
- }\r
-\r
- @Override\r
- protected void setupSql() {\r
- setupInsertSql();\r
- }\r
-\r
- @Override\r
- protected void setupPropertyTypes(String[] propertyNames) {\r
- setupInsertPropertyTypes(propertyNames);\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlcommand;\r
-\r
-import javax.sql.DataSource;\r
-\r
-import org.seasar.dao.SqlCommand;\r
-import org.seasar.extension.jdbc.ResultSetHandler;\r
-import org.seasar.extension.jdbc.StatementFactory;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.outsidesql.OutsideSqlContext;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlhandler.InternalProcedureHandler;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.various.InternalProcedureMetaData;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class InternalProcedureCommand implements SqlCommand {\r
-\r
- // ===================================================================================\r
- // Attribute\r
- // =========\r
- protected DataSource dataSource;\r
- protected ResultSetHandler resultSetHandler;\r
- protected StatementFactory statementFactory;\r
- protected InternalProcedureMetaData procedureMetaData;\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- public InternalProcedureCommand(DataSource dataSource, ResultSetHandler resultSetHandler,\r
- StatementFactory statementFactory, InternalProcedureMetaData procedureMetaData) {\r
- this.dataSource = dataSource;\r
- this.resultSetHandler = resultSetHandler;\r
- this.statementFactory = statementFactory;\r
- this.procedureMetaData = procedureMetaData;\r
- }\r
-\r
- // ===================================================================================\r
- // Execute\r
- // =======\r
- public Object execute(final Object[] args) {\r
- final InternalProcedureHandler handler = newArgumentDtoProcedureHandler();\r
- final OutsideSqlContext outsideSqlContext = OutsideSqlContext.getOutsideSqlContextOnThread();\r
- final Object pmb = outsideSqlContext.getParameterBean();\r
- // The logging message SQL of procedure is unnecessary.\r
- // handler.setLoggingMessageSqlArgs(...);\r
- return handler.execute(new Object[]{pmb});\r
- }\r
- protected InternalProcedureHandler newArgumentDtoProcedureHandler() {\r
- return new InternalProcedureHandler(dataSource, createSql(procedureMetaData), resultSetHandler,\r
- statementFactory, procedureMetaData);\r
- }\r
- protected String createSql(final InternalProcedureMetaData procedureMetaData) {\r
- final StringBuilder sb = new StringBuilder();\r
- sb.append("{");\r
- int size = procedureMetaData.parameterTypes().size();\r
- if (procedureMetaData.hasReturnParameterType()) {\r
- sb.append("? = ");\r
- size--;\r
- }\r
- sb.append("call ").append(procedureMetaData.getProcedureName()).append("(");\r
- for (int i = 0; i < size; i++) {\r
- sb.append("?, ");\r
- }\r
- if (size > 0) {\r
- sb.setLength(sb.length() - 2);\r
- }\r
- sb.append(")}");\r
- return sb.toString();\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlcommand;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import javax.sql.DataSource;\r
-\r
-import org.seasar.extension.jdbc.PropertyType;\r
-import org.seasar.extension.jdbc.StatementFactory;\r
-import org.seasar.dao.impl.AbstractSqlCommand;\r
-import org.seasar.dao.BeanMetaData;\r
-import org.seasar.dao.NoUpdatePropertyTypeRuntimeException;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlhandler.InternalUpdateAutoHandler;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class InternalUpdateAutoDynamicCommand extends AbstractSqlCommand {\r
-\r
- // ===================================================================================\r
- // Definition\r
- // ==========\r
- /** Log instance. */\r
- private static final org.apache.commons.logging.Log _log = org.apache.commons.logging.LogFactory.getLog(InternalUpdateAutoDynamicCommand.class);\r
-\r
- private static final Integer NO_UPDATE = new Integer(0);\r
-\r
- // ===================================================================================\r
- // Attribute\r
- // =========\r
- private BeanMetaData beanMetaData;\r
- private String[] propertyNames;\r
- private boolean checkSingleRowUpdate = true;\r
- private boolean versionNoAutoIncrementOnMemory = true;\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- public InternalUpdateAutoDynamicCommand(DataSource dataSource, StatementFactory statementFactory) {\r
- super(dataSource, statementFactory);\r
- }\r
-\r
- // ===================================================================================\r
- // Execute\r
- // =======\r
- public Object execute(Object[] args) {\r
- final Object bean = args[0];\r
- final BeanMetaData bmd = getBeanMetaData();\r
- final PropertyType[] propertyTypes = createUpdatePropertyTypes(bmd, bean, getPropertyNames());\r
- if (propertyTypes.length == 0) {\r
- if (_log.isDebugEnabled()) {\r
- _log.debug(createNoUpdateLogMessage(bean, bmd));\r
- }\r
- return NO_UPDATE;\r
- }\r
- InternalUpdateAutoHandler handler = createInternalUpdateAutoHandler(bmd, propertyTypes);\r
- handler.setSql(createUpdateSql(bmd, propertyTypes, bean));\r
- handler.setLoggingMessageSqlArgs(args);\r
- int i = handler.execute(args);\r
-\r
- // [Comment Out]: This statement moved to the handler at [DBFlute-0.8.0].\r
- // if (isCheckSingleRowUpdate() && i < 1) {\r
- // throw createNotSingleRowUpdatedRuntimeException(args[0], i);\r
- // }\r
-\r
- return new Integer(i);\r
- }\r
-\r
- protected InternalUpdateAutoHandler createInternalUpdateAutoHandler(BeanMetaData bmd, PropertyType[] propertyTypes) {\r
- InternalUpdateAutoHandler handler = new InternalUpdateAutoHandler(getDataSource(), getStatementFactory(), bmd, propertyTypes);\r
- handler.setVersionNoAutoIncrementOnMemory(versionNoAutoIncrementOnMemory);\r
- handler.setCheckSingleRowUpdate(isCheckSingleRowUpdate()); // [DBFlute-0.8.0]\r
- return handler;\r
- }\r
-\r
- protected PropertyType[] createUpdatePropertyTypes(BeanMetaData bmd, Object bean, String[] propertyNames) {\r
- final List<PropertyType> types = new ArrayList<PropertyType>();\r
- final String timestampPropertyName = bmd.getTimestampPropertyName();\r
- final String versionNoPropertyName = bmd.getVersionNoPropertyName();\r
- for (int i = 0; i < propertyNames.length; ++i) {\r
- PropertyType pt = bmd.getPropertyType(propertyNames[i]);\r
- if (pt.isPrimaryKey() == false) {\r
- String propertyName = pt.getPropertyName();\r
- if (propertyName.equalsIgnoreCase(timestampPropertyName)\r
- || propertyName.equalsIgnoreCase(versionNoPropertyName)\r
- || pt.getPropertyDesc().getValue(bean) != null) {\r
- types.add(pt);\r
- }\r
- }\r
- }\r
- if (types.isEmpty()) {\r
- throw new NoUpdatePropertyTypeRuntimeException();\r
- }\r
- PropertyType[] propertyTypes = (PropertyType[]) types.toArray(new PropertyType[types.size()]);\r
- return propertyTypes;\r
- }\r
-\r
- protected String createNoUpdateLogMessage(final Object bean, final BeanMetaData bmd) {\r
- final StringBuffer sb = new StringBuffer();\r
- sb.append("skip UPDATE: table=").append(bmd.getTableName());\r
- final int size = bmd.getPrimaryKeySize();\r
- for (int i = 0; i < size; i++) {\r
- if (i == 0) {\r
- sb.append(", key{");\r
- } else {\r
- sb.append(", ");\r
- }\r
- final String keyName = bmd.getPrimaryKey(i);\r
- sb.append(keyName).append("=");\r
- sb.append(bmd.getPropertyTypeByColumnName(keyName).getPropertyDesc().getValue(bean));\r
- if (i == size - 1) {\r
- sb.append("}");\r
- }\r
- }\r
- final String s = new String(sb);\r
- return s;\r
- }\r
-\r
- /**\r
- * Create update SQL. The update is by the primary keys.\r
- * @param bmd The meta data of bean. (NotNull & RequiredPrimaryKeys)\r
- * @param propertyTypes The types of property for update. (NotNull)\r
- * @param bean A bean for update for handling version no and so on. (NotNull)\r
- * @return The update SQL. (NotNull)\r
- */\r
- protected String createUpdateSql(BeanMetaData bmd, PropertyType[] propertyTypes, Object bean) {\r
- if (bmd.getPrimaryKeySize() == 0) {\r
- String msg = "The table '" + bmd.getTableName() + "' does not have primary keys!";\r
- throw new IllegalStateException(msg);\r
- }\r
- final StringBuilder sb = new StringBuilder(100);\r
- sb.append("update ");\r
- sb.append(bmd.getTableName());\r
- sb.append(" set ");\r
- final String versionNoPropertyName = bmd.getVersionNoPropertyName();\r
- for (int i = 0; i < propertyTypes.length; ++i) {\r
- PropertyType pt = propertyTypes[i];\r
- final String columnName = pt.getColumnName();\r
- if (i > 0) {\r
- sb.append(", ");\r
- }\r
- if (pt.getPropertyName().equalsIgnoreCase(versionNoPropertyName)) {\r
- if (!isVersionNoAutoIncrementOnMemory()) {\r
- setupVersionNoAutoIncrementOnQuery(sb, columnName);\r
- continue;\r
- }\r
- final Object versionNo = pt.getPropertyDesc().getValue(bean);\r
- if (versionNo == null) {\r
- setupVersionNoAutoIncrementOnQuery(sb, columnName);\r
- continue;\r
- }\r
- }\r
- sb.append(columnName).append(" = ?");\r
- }\r
- sb.append(" where ");\r
- for (int i = 0; i < bmd.getPrimaryKeySize(); ++i) {\r
- sb.append(bmd.getPrimaryKey(i)).append(" = ? and ");\r
- }\r
- sb.setLength(sb.length() - 5);\r
- if (bmd.hasVersionNoPropertyType()) {\r
- PropertyType pt = bmd.getVersionNoPropertyType();\r
- sb.append(" and ").append(pt.getColumnName()).append(" = ?");\r
- }\r
- if (bmd.hasTimestampPropertyType()) {\r
- PropertyType pt = bmd.getTimestampPropertyType();\r
- sb.append(" and ").append(pt.getColumnName()).append(" = ?");\r
- }\r
- return sb.toString();\r
- }\r
-\r
- protected boolean isVersionNoAutoIncrementOnMemory() {\r
- return versionNoAutoIncrementOnMemory;\r
- }\r
-\r
- public void setVersionNoAutoIncrementOnMemory(boolean versionNoAutoIncrementOnMemory) {\r
- this.versionNoAutoIncrementOnMemory = versionNoAutoIncrementOnMemory;\r
- }\r
- \r
- protected void setupVersionNoAutoIncrementOnQuery(StringBuilder sb, String columnName) {\r
- sb.append(columnName).append(" = ").append(columnName).append(" + 1");\r
- }\r
-\r
- public BeanMetaData getBeanMetaData() {\r
- return beanMetaData;\r
- }\r
-\r
- public void setBeanMetaData(BeanMetaData beanMetaData) {\r
- this.beanMetaData = beanMetaData;\r
- }\r
-\r
- public String[] getPropertyNames() {\r
- return propertyNames;\r
- }\r
-\r
- public void setPropertyNames(String[] propertyNames) {\r
- this.propertyNames = propertyNames;\r
- }\r
-\r
- public boolean isCheckSingleRowUpdate() {\r
- return checkSingleRowUpdate;\r
- }\r
-\r
- public void setCheckSingleRowUpdate(boolean resultCheck) {\r
- this.checkSingleRowUpdate = resultCheck;\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlcommand;\r
-\r
-import javax.sql.DataSource;\r
-\r
-import org.seasar.extension.jdbc.StatementFactory;\r
-import org.seasar.dao.BeanMetaData;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlhandler.InternalAbstractAutoHandler;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlhandler.InternalAbstractBatchAutoHandler;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlhandler.InternalUpdateBatchAutoHandler;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class InternalUpdateBatchAutoStaticCommand extends InternalAbstractBatchAutoStaticCommand {\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- public InternalUpdateBatchAutoStaticCommand(DataSource dataSource,\r
- StatementFactory statementFactory, BeanMetaData beanMetaData,\r
- String[] propertyNames, boolean returningRows, boolean versionNoAutoIncrementOnMemory) {\r
- super(dataSource, statementFactory, beanMetaData, propertyNames, returningRows, versionNoAutoIncrementOnMemory);\r
- }\r
-\r
- // ===================================================================================\r
- // Override\r
- // ========\r
- @Override\r
- protected InternalAbstractAutoHandler createAutoHandler() {\r
- return createBatchAutoHandler();\r
- }\r
-\r
- @Override\r
- protected InternalAbstractBatchAutoHandler createBatchAutoHandler() {\r
- InternalUpdateBatchAutoHandler handler = newInternalBatchAutoHandler();\r
- handler.setVersionNoAutoIncrementOnMemory(versionNoAutoIncrementOnMemory);\r
- return handler;\r
- }\r
-\r
- protected InternalUpdateBatchAutoHandler newInternalBatchAutoHandler() {\r
- return new InternalUpdateBatchAutoHandler(getDataSource(), getStatementFactory(), getBeanMetaData(), getPropertyTypes());\r
- }\r
-\r
- @Override\r
- protected void setupSql() {\r
- setupUpdateSql();\r
- }\r
-\r
- @Override\r
- protected void setupPropertyTypes(String[] propertyNames) {\r
- setupUpdatePropertyTypes(propertyNames);\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlcommand;\r
-\r
-import javax.sql.DataSource;\r
-import org.seasar.dao.CommandContext;\r
-import org.seasar.extension.jdbc.StatementFactory;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlhandler.InternalBasicUpdateHandler;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class InternalUpdateDynamicCommand extends InternalAbstractDynamicCommand {\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- public InternalUpdateDynamicCommand(DataSource dataSource, StatementFactory statementFactory) {\r
- super(dataSource, statementFactory);\r
- }\r
-\r
- // ===================================================================================\r
- // Execute\r
- // =======\r
- public Object execute(Object args[]) {\r
- final CommandContext ctx = apply(args);\r
- final InternalBasicUpdateHandler updateHandler = new InternalBasicUpdateHandler(getDataSource(), ctx.getSql(), getStatementFactory());\r
- Object[] bindVariables = ctx.getBindVariables();\r
- updateHandler.setLoggingMessageSqlArgs(bindVariables);\r
- return new Integer(updateHandler.execute(bindVariables, ctx.getBindVariableTypes()));\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlcommand;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-import java.util.Set;\r
-\r
-import javax.sql.DataSource;\r
-\r
-import org.seasar.dao.BeanMetaData;\r
-import org.seasar.extension.jdbc.PropertyType;\r
-import org.seasar.extension.jdbc.StatementFactory;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class InternalUpdateModifiedOnlyCommand extends InternalUpdateAutoDynamicCommand {\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- public InternalUpdateModifiedOnlyCommand(DataSource dataSource, StatementFactory statementFactory) {\r
- super(dataSource, statementFactory);\r
- }\r
-\r
- // ===================================================================================\r
- // No.1 Point Override\r
- // ===================\r
- @Override\r
- protected PropertyType[] createUpdatePropertyTypes(final BeanMetaData bmd, final Object bean, final String[] propertyNames) {\r
- final Set<?> modifiedPropertyNames = getBeanMetaData().getModifiedPropertyNames(bean);\r
- final List<PropertyType> types = new ArrayList<PropertyType>();\r
- final String timestampPropertyName = bmd.getTimestampPropertyName();\r
- final String versionNoPropertyName = bmd.getVersionNoPropertyName();\r
- for (int i = 0; i < propertyNames.length; ++i) {\r
- final PropertyType pt = bmd.getPropertyType(propertyNames[i]);\r
- if (pt.isPrimaryKey() == false) {\r
- final String propertyName = pt.getPropertyName();\r
- if (propertyName.equalsIgnoreCase(timestampPropertyName)\r
- || propertyName.equalsIgnoreCase(versionNoPropertyName)\r
- || modifiedPropertyNames.contains(propertyName)) {\r
- types.add(pt);\r
- }\r
- }\r
- }\r
- final PropertyType[] propertyTypes = (PropertyType[]) types.toArray(new PropertyType[types.size()]);\r
- return propertyTypes;\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlcommand;\r
-\r
-import java.util.Map;\r
-import java.util.LinkedHashMap;\r
-import java.util.Set;\r
-import java.util.Date;\r
-import java.sql.Timestamp;\r
-import java.lang.reflect.Method;\r
-import javax.sql.DataSource;\r
-\r
-import org.seasar.extension.jdbc.StatementFactory;\r
-import org.seasar.dao.CommandContext;\r
-import org.seasar.dao.Node;\r
-import org.seasar.dao.SqlCommand;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.Entity;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.ConditionBean;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.dbmeta.DBMeta;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.dbmeta.DBMetaInstanceHandler;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.dbmeta.info.ColumnInfo;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlhandler.InternalCommandContextHandler;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlparser.InternalCommandContextCreator;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlparser.InternalSqlParser;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.util.SimpleSystemUtil;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class InternalUpdateQueryAutoDynamicCommand implements SqlCommand {\r
-\r
- // ===================================================================================\r
- // Attribute\r
- // =========\r
- protected DataSource dataSource;\r
- protected StatementFactory statementFactory;\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- public InternalUpdateQueryAutoDynamicCommand(DataSource dataSource, StatementFactory statementFactory) {\r
- this.dataSource = dataSource;\r
- this.statementFactory = statementFactory;\r
- }\r
-\r
- // ===================================================================================\r
- // Execute\r
- // =======\r
- public Object execute(Object[] args) {\r
- ConditionBean cb = extractConditionBeanWithCheck(args);\r
- Entity entity = extractEntityWithCheck(args);\r
- String[] argNames = new String[]{"dto", "entity"};\r
- Class<?>[] argTypes = new Class<?>[]{cb.getClass(), entity.getClass()};\r
- String twoWaySql = buildQueryUpdateTwoWaySql(cb, entity);\r
- if (twoWaySql == null) {\r
- return 0;// No execute!\r
- }\r
- CommandContext context = createCommandContext(twoWaySql, argNames, argTypes, args);\r
- InternalCommandContextHandler handler = createCommandContextHandler(context);\r
- handler.setLoggingMessageSqlArgs(context.getBindVariables());\r
- int rows = handler.execute(args);\r
- return new Integer(rows);\r
- }\r
- \r
- protected ConditionBean extractConditionBeanWithCheck(Object[] args) {\r
- assertArgument(args);\r
- Object fisrtArg = args[0];\r
- if (!(fisrtArg instanceof ConditionBean)) {\r
- String msg = "The type of first argument should be " + ConditionBean.class + "! But:";\r
- msg = msg + " type=" + fisrtArg.getClass();\r
- throw new IllegalArgumentException(msg);\r
- }\r
- return (ConditionBean) fisrtArg;\r
- }\r
- \r
- protected Entity extractEntityWithCheck(Object[] args) {\r
- assertArgument(args);\r
- Object secondArg = args[1];\r
- if (!(secondArg instanceof Entity)) {\r
- String msg = "The type of second argument should be " + Entity.class + "! But:";\r
- msg = msg + " type=" + secondArg.getClass();\r
- throw new IllegalArgumentException(msg);\r
- }\r
- return (Entity) secondArg;\r
- }\r
- \r
- protected void assertArgument(Object[] args) {\r
- if (args == null || args.length <= 1) {\r
- String msg = "The arguments should have two argument! But:";\r
- msg = msg + " args=" + (args != null ? args.length : null);\r
- throw new IllegalArgumentException(msg);\r
- }\r
- }\r
- \r
- protected InternalCommandContextHandler createCommandContextHandler(CommandContext context) {\r
- return new InternalCommandContextHandler(dataSource, statementFactory, context);\r
- }\r
-\r
- /**\r
- * @param cb Condition-bean. (NotNull)\r
- * @param entity Entity. (NotNull)\r
- * @return The two-way SQL of query update. (Nullable: If the set of modified properties is empty, return null.)\r
- */\r
- protected String buildQueryUpdateTwoWaySql(ConditionBean cb, Entity entity) {\r
- Map<String, String> columnParameterMap = new LinkedHashMap<String, String>();\r
- DBMeta dbmeta = DBMetaInstanceHandler.findDBMeta(entity.getTableDbName());\r
- Set<String> modifiedPropertyNames = entity.getModifiedPropertyNames();\r
- if (modifiedPropertyNames.isEmpty()) {\r
- return null;\r
- }\r
- String currentPropertyName = null;\r
- try {\r
- for (String propertyName : modifiedPropertyNames) {\r
- currentPropertyName = propertyName;\r
- ColumnInfo columnInfo = dbmeta.findColumnInfo(propertyName);\r
- String columnName = columnInfo.getColumnDbName();\r
- Method getter = columnInfo.findGetter();\r
- Object value = getter.invoke(entity, (Object[])null);\r
- if (value != null) {\r
- columnParameterMap.put(columnName, "/*entity." + propertyName + "*/null");\r
- } else {\r
- columnParameterMap.put(columnName, "null");\r
- }\r
- }\r
- if (dbmeta.hasVersionNo()) {\r
- ColumnInfo columnInfo = dbmeta.getVersionNoColumnInfo();\r
- String columnName = columnInfo.getColumnDbName();\r
- columnParameterMap.put(columnName, columnName + " + 1");\r
- }\r
- if (dbmeta.hasUpdateDate()) {\r
- ColumnInfo columnInfo = dbmeta.getUpdateDateColumnInfo();\r
- Method setter = columnInfo.findSetter();\r
- if (Timestamp.class.isAssignableFrom(columnInfo.getPropertyType())) {\r
- setter.invoke(entity, new Timestamp(System.currentTimeMillis()));\r
- } else {\r
- setter.invoke(entity, new Date());\r
- }\r
- String columnName = columnInfo.getColumnDbName();\r
- columnParameterMap.put(columnName, "/*entity." + columnInfo.getPropertyName() + "*/null");\r
- }\r
- } catch (Exception e) {\r
- throwQueryUpdateFailureException(cb, entity, currentPropertyName, e);\r
- }\r
- return cb.getSqlClause().getClauseQueryUpdate(columnParameterMap);\r
- }\r
- \r
- protected void throwQueryUpdateFailureException(ConditionBean cb, Entity entity, String propertyName, Exception e) {\r
- String msg = "Look! Read the message below." + getLineSeparator();\r
- msg = msg + "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *" + getLineSeparator();\r
- msg = msg + "queryUpdate() failed to execute!" + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Advice]" + getLineSeparator();\r
- msg = msg + "Please confirm the parameter comment logic." + getLineSeparator();\r
- msg = msg + "It may exist the parameter comment that DOESN'T have an end comment." + getLineSeparator();\r
- msg = msg + " For example:" + getLineSeparator();\r
- msg = msg + " before (x) -- /*IF pmb.xxxId != null*/XXX_ID = /*pmb.xxxId*/3" + getLineSeparator();\r
- msg = msg + " after (o) -- /*IF pmb.xxxId != null*/XXX_ID = /*pmb.xxxId*/3/*END*/" + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Doubtful Property Name]" + getLineSeparator() + propertyName + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[ConditionBean]" + getLineSeparator() + cb + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Entity]" + getLineSeparator() + entity + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Exception Message]" + getLineSeparator() + e.getMessage() + getLineSeparator();\r
- msg = msg + "* * * * * * * * * */";\r
- throw new QueryUpdateFailureException(msg, e);\r
- }\r
- \r
- public static class QueryUpdateFailureException extends RuntimeException {\r
- private static final long serialVersionUID = 1L;\r
- public QueryUpdateFailureException(String msg, Exception e) {\r
- super(msg, e);\r
- }\r
- }\r
-\r
- protected CommandContext createCommandContext(String twoWaySql, String[] argNames, Class<?>[] argTypes, Object[] args) {\r
- CommandContext context;\r
- {\r
- InternalSqlParser parser = new InternalSqlParser(twoWaySql);\r
- Node node = parser.parse();\r
- InternalCommandContextCreator creator = new InternalCommandContextCreator(argNames, argTypes);\r
- context = creator.createCommandContext(args);\r
- node.accept(context);\r
- }\r
- return context;\r
- }\r
- \r
- // ===================================================================================\r
- // General Helper\r
- // ==============\r
- protected String getLineSeparator() {\r
- return SimpleSystemUtil.getLineSeparator();\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlhandler;\r
-\r
-import java.sql.Connection;\r
-import java.sql.PreparedStatement;\r
-import java.sql.SQLException;\r
-import java.sql.Timestamp;\r
-import java.util.ArrayList;\r
-import java.util.Date;\r
-import java.util.List;\r
-\r
-import javax.sql.DataSource;\r
-\r
-import org.seasar.dao.BeanMetaData;\r
-import org.seasar.extension.jdbc.PropertyType;\r
-import org.seasar.extension.jdbc.StatementFactory;\r
-import org.seasar.extension.jdbc.ValueType;\r
-import org.seasar.framework.beans.PropertyDesc;\r
-import org.seasar.framework.util.IntegerConversionUtil;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public abstract class InternalAbstractAutoHandler extends InternalBasicHandler {\r
-\r
- // ===================================================================================\r
- // Attribute\r
- // =========\r
- protected BeanMetaData beanMetaData;\r
- protected Object[] bindVariables;\r
- protected ValueType[] bindVariableValueTypes;\r
- protected Timestamp timestamp;\r
- protected Integer versionNo;\r
- protected PropertyType[] propertyTypes;\r
- protected boolean versionNoAutoIncrementOnMemory = true;\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- public InternalAbstractAutoHandler(DataSource dataSource,\r
- StatementFactory statementFactory, BeanMetaData beanMetaData,\r
- PropertyType[] propertyTypes) {\r
- super(dataSource, statementFactory);\r
- this.beanMetaData = beanMetaData;\r
- this.propertyTypes = propertyTypes;\r
- }\r
-\r
- public int execute(Object[] args) {\r
- Connection connection = getConnection();\r
- try {\r
- return execute(connection, args[0]);\r
- } finally {\r
- close(connection);\r
- }\r
- }\r
-\r
- public int execute(Object[] args, Class<?>[] argTypes) {\r
- return execute(args);\r
- }\r
-\r
- protected int execute(Connection connection, Object bean) {\r
- preUpdateBean(bean);\r
- setupBindVariables(bean);\r
- logSql(bindVariables, getArgTypes(bindVariables));\r
- PreparedStatement ps = prepareStatement(connection);\r
- int ret = -1;\r
- try {\r
- bindArgs(ps, bindVariables, bindVariableValueTypes);\r
- ret = executeUpdate(ps);\r
- } finally {\r
- close(ps);\r
- }\r
- postUpdateBean(bean, ret);\r
- return ret;\r
- }\r
-\r
- protected void bindArgs(PreparedStatement ps, Object[] args, ValueType[] valueTypes) {\r
- if (args == null) {\r
- return;\r
- }\r
- for (int i = 0; i < args.length; ++i) {\r
- ValueType valueType = valueTypes[i];\r
- try {\r
- valueType.bindValue(ps, i + 1, args[i]);\r
- } catch (SQLException e) {\r
- handleSQLException(e, ps);\r
- }\r
- }\r
- }\r
-\r
- protected void preUpdateBean(Object bean) {\r
- }\r
-\r
- protected void postUpdateBean(Object bean, int ret) {\r
- }\r
-\r
- protected abstract void setupBindVariables(Object bean);\r
-\r
- protected void setupInsertBindVariables(Object bean) {\r
- final List<Object> varList = new ArrayList<Object>();\r
- final List<ValueType> varValueTypeList = new ArrayList<ValueType>();\r
- final BeanMetaData bmd = getBeanMetaData();\r
- final String timestampPropertyName = bmd.getTimestampPropertyName();\r
- final String versionNoPropertyName = bmd.getVersionNoPropertyName();\r
- for (int i = 0; i < propertyTypes.length; ++i) {\r
- PropertyType pt = propertyTypes[i];\r
- if (pt.getPropertyName().equalsIgnoreCase(timestampPropertyName)) {\r
- setTimestamp(new Timestamp(new Date().getTime()));\r
- varList.add(getTimestamp());\r
- } else if (pt.getPropertyName().equalsIgnoreCase(versionNoPropertyName)) {\r
- setVersionNo(new Integer(0));\r
- varList.add(getVersionNo());\r
- } else {\r
- varList.add(pt.getPropertyDesc().getValue(bean));\r
- }\r
- varValueTypeList.add(pt.getValueType());\r
- }\r
- setBindVariables(varList.toArray());\r
- setBindVariableValueTypes((ValueType[])varValueTypeList.toArray(new ValueType[varValueTypeList.size()]));\r
- }\r
-\r
- protected void setupUpdateBindVariables(Object bean) {\r
- final List<Object> varList = new ArrayList<Object>();\r
- final List<ValueType> varValueTypeList = new ArrayList<ValueType>();\r
- final BeanMetaData bmd = getBeanMetaData();\r
- final String timestampPropertyName = bmd.getTimestampPropertyName();\r
- final String versionNoPropertyName = bmd.getVersionNoPropertyName();\r
- for (int i = 0; i < propertyTypes.length; ++i) {\r
- PropertyType pt = propertyTypes[i];\r
- if (pt.getPropertyName().equalsIgnoreCase(timestampPropertyName)) {\r
- setTimestamp(new Timestamp(new Date().getTime()));\r
- varList.add(getTimestamp());\r
- } else if (pt.getPropertyName().equalsIgnoreCase(versionNoPropertyName)) {\r
- if (!isVersionNoAutoIncrementOnMemory()) {\r
- continue;// because of always 'VERSION_NO = VERSION_NO + 1'\r
- }\r
- Object value = pt.getPropertyDesc().getValue(bean);\r
- if (value == null) {\r
- continue;// because of 'VERSION_NO = VERSION_NO + 1'\r
- }\r
- int intValue = IntegerConversionUtil.toPrimitiveInt(value) + 1;\r
- setVersionNo(new Integer(intValue));\r
- varList.add(getVersionNo());\r
- } else {\r
- varList.add(pt.getPropertyDesc().getValue(bean));\r
- }\r
- varValueTypeList.add(pt.getValueType());\r
- }\r
- addAutoUpdateWhereBindVariables(varList, varValueTypeList, bean);\r
- setBindVariables(varList.toArray());\r
- setBindVariableValueTypes((ValueType[]) varValueTypeList.toArray(new ValueType[varValueTypeList.size()]));\r
- }\r
-\r
- protected void setupDeleteBindVariables(Object bean) {\r
- final List<Object> varList = new ArrayList<Object>();\r
- final List<ValueType> varValueTypeList = new ArrayList<ValueType>();\r
- addAutoUpdateWhereBindVariables(varList, varValueTypeList, bean);\r
- setBindVariables(varList.toArray());\r
- setBindVariableValueTypes((ValueType[])varValueTypeList.toArray(new ValueType[varValueTypeList.size()]));\r
- }\r
-\r
- protected void addAutoUpdateWhereBindVariables(List<Object> varList, List<ValueType> varValueTypeList, Object bean) {\r
- BeanMetaData bmd = getBeanMetaData();\r
- for (int i = 0; i < bmd.getPrimaryKeySize(); ++i) {\r
- PropertyType pt = bmd.getPropertyTypeByColumnName(bmd.getPrimaryKey(i));\r
- PropertyDesc pd = pt.getPropertyDesc();\r
- varList.add(pd.getValue(bean));\r
- varValueTypeList.add(pt.getValueType());\r
- }\r
- if (bmd.hasVersionNoPropertyType()) {\r
- PropertyType pt = bmd.getVersionNoPropertyType();\r
- PropertyDesc pd = pt.getPropertyDesc();\r
- varList.add(pd.getValue(bean));\r
- varValueTypeList.add(pt.getValueType());\r
- }\r
- if (bmd.hasTimestampPropertyType()) {\r
- PropertyType pt = bmd.getTimestampPropertyType();\r
- PropertyDesc pd = pt.getPropertyDesc();\r
- varList.add(pd.getValue(bean));\r
- varValueTypeList.add(pt.getValueType());\r
- }\r
- }\r
-\r
- protected void updateTimestampIfNeed(Object bean) {\r
- if (getTimestamp() != null) {\r
- PropertyDesc pd = getBeanMetaData().getTimestampPropertyType().getPropertyDesc();\r
- pd.setValue(bean, getTimestamp());\r
- }\r
- }\r
-\r
- protected void updateVersionNoIfNeed(Object bean) {\r
- if (getVersionNo() != null) {\r
- PropertyDesc pd = getBeanMetaData().getVersionNoPropertyType().getPropertyDesc();\r
- pd.setValue(bean, getVersionNo());\r
- }\r
- }\r
-\r
- // ===================================================================================\r
- // Accessor\r
- // ========\r
- public BeanMetaData getBeanMetaData() {\r
- return beanMetaData;\r
- }\r
-\r
- protected Object[] getBindVariables() {\r
- return bindVariables;\r
- }\r
-\r
- protected void setBindVariables(Object[] bindVariables) {\r
- this.bindVariables = bindVariables;\r
- }\r
-\r
- protected ValueType[] getBindVariableValueTypes() {\r
- return bindVariableValueTypes;\r
- }\r
-\r
- protected void setBindVariableValueTypes(ValueType[] bindVariableValueTypes) {\r
- this.bindVariableValueTypes = bindVariableValueTypes;\r
- }\r
-\r
- protected Timestamp getTimestamp() {\r
- return timestamp;\r
- }\r
-\r
- protected void setTimestamp(Timestamp timestamp) {\r
- this.timestamp = timestamp;\r
- }\r
-\r
- protected Integer getVersionNo() {\r
- return versionNo;\r
- }\r
-\r
- protected void setVersionNo(Integer versionNo) {\r
- this.versionNo = versionNo;\r
- }\r
-\r
- protected PropertyType[] getPropertyTypes() {\r
- return propertyTypes;\r
- }\r
-\r
- protected void setPropertyTypes(PropertyType[] propertyTypes) {\r
- this.propertyTypes = propertyTypes;\r
- }\r
-\r
- protected boolean isVersionNoAutoIncrementOnMemory() {\r
- return versionNoAutoIncrementOnMemory;\r
- }\r
-\r
- public void setVersionNoAutoIncrementOnMemory(boolean versionNoAutoIncrementOnMemory) {\r
- this.versionNoAutoIncrementOnMemory = versionNoAutoIncrementOnMemory;\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlhandler;\r
-\r
-import java.sql.Connection;\r
-import java.sql.PreparedStatement;\r
-import java.sql.SQLException;\r
-import java.util.Arrays;\r
-import java.util.Iterator;\r
-import java.util.List;\r
-\r
-import javax.sql.DataSource;\r
-\r
-import org.seasar.dao.BeanMetaData;\r
-import org.seasar.extension.jdbc.PropertyType;\r
-import org.seasar.extension.jdbc.StatementFactory;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public abstract class InternalAbstractBatchAutoHandler extends InternalAbstractAutoHandler {\r
-\r
- // ===================================================================================\r
- // Definition\r
- // ==========\r
- /** Log instance. */\r
- private static final org.apache.commons.logging.Log _log = org.apache.commons.logging.LogFactory.getLog(InternalAbstractBatchAutoHandler.class);\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- public InternalAbstractBatchAutoHandler(DataSource dataSource,\r
- StatementFactory statementFactory, BeanMetaData beanMetaData,\r
- PropertyType[] propertyTypes) {\r
- super(dataSource, statementFactory, beanMetaData, propertyTypes);\r
- }\r
-\r
- // ===================================================================================\r
- // Execute\r
- // =======\r
- public int[] execute(List<?> list, Class<?>[] argTypes) {\r
- return execute(list);\r
- }\r
-\r
- public int[] execute(List<?> list) {\r
- if (list == null) {\r
- throw new IllegalArgumentException("list");\r
- }\r
- if (list.isEmpty()) {\r
- if (_log.isDebugEnabled()) {\r
- _log.debug("Skip executeBatch() bacause of the empty list.");\r
- }\r
- return new int[0];\r
- }\r
- final Connection connection = getConnection();\r
- try {\r
- final PreparedStatement ps = prepareStatement(connection);\r
- try {\r
- for (Iterator<?> iter = list.iterator(); iter.hasNext();) {\r
- final Object bean = (Object) iter.next();\r
- prepareBatchElement(ps, bean);\r
- }\r
- return executeBatch(ps, list);\r
- } finally {\r
- close(ps);\r
- }\r
- } finally {\r
- close(connection);\r
- }\r
- // Reflection to bean is unsupported at batch update.\r
- // postBatchUpdateBean(...);\r
- }\r
- \r
- public int execute(Object[] args) {\r
- List<?> list = null;\r
- if (args[0] instanceof Object[]) {\r
- list = Arrays.asList((Object[]) args[0]);\r
- } else if (args[0] instanceof List) {\r
- list = (List<?>) args[0];\r
- }\r
- if (list == null) {\r
- throw new IllegalArgumentException("args[0]");\r
- }\r
- int[] ret = execute(list);\r
- int updatedRow = 0;\r
- for (int i = 0; i < ret.length; i++) {\r
- if (ret[i] > 0) {\r
- updatedRow += ret[i];\r
- }\r
- }\r
- return updatedRow;\r
- }\r
-\r
- public int[] executeBatch(Object[] args) {\r
- List<?> list = null;\r
- if (args[0] instanceof Object[]) {\r
- list = Arrays.asList((Object[]) args[0]);\r
- } else if (args[0] instanceof List) {\r
- list = (List<?>) args[0];\r
- }\r
- if (list == null) {\r
- throw new IllegalArgumentException("args[0]");\r
- }\r
- return execute(list);\r
- }\r
-\r
- protected void prepareBatchElement(PreparedStatement ps, Object bean) {\r
- setupBindVariables(bean);\r
- logSql(getBindVariables(), getArgTypes(getBindVariables()));\r
- bindArgs(ps, getBindVariables(), getBindVariableValueTypes());\r
- addBatch(ps);\r
- }\r
-\r
- // ===================================================================================\r
- // JDBC Delegator\r
- // ==============\r
- protected int[] executeBatch(PreparedStatement ps, List<?> list) {\r
- try {\r
- return ps.executeBatch();\r
- } catch (SQLException e) {\r
- handleSQLException(e, ps, true);\r
- return null; // Unreachable!\r
- }\r
- }\r
- \r
- protected void addBatch(PreparedStatement ps) {\r
- try {\r
- ps.addBatch();\r
- } catch (SQLException e) {\r
- handleSQLException(e, ps);\r
- }\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlhandler;\r
-\r
-import java.sql.Connection;\r
-import java.sql.Statement;\r
-import java.sql.PreparedStatement;\r
-import java.sql.ResultSet;\r
-import java.sql.SQLException;\r
-\r
-import javax.sql.DataSource;\r
-\r
-import org.seasar.extension.jdbc.StatementFactory;\r
-import org.seasar.extension.jdbc.ValueType;\r
-import org.seasar.extension.jdbc.types.ValueTypes;\r
-import org.seasar.framework.exception.SQLRuntimeException;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.QLog;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.DBFluteConfig;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.InternalMapContext;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.ConditionBeanContext;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.ConditionBean;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.outsidesql.OutsideSqlContext;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.exception.EntityAlreadyExistsException;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.exception.SQLFailureException;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqllog.InternalSqlLogRegistry;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.util.InternalBindVariableUtil;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.util.SimpleSystemUtil;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class InternalBasicHandler {\r
-\r
- // ===================================================================================\r
- // Attribute\r
- // =========\r
- private DataSource dataSource;\r
- private String sql;\r
- private StatementFactory statementFactory;\r
- private Object[] loggingMessageSqlArgs;\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- public InternalBasicHandler(DataSource ds, StatementFactory statementFactory) {\r
- setDataSource(ds);\r
- setStatementFactory(statementFactory);\r
- }\r
-\r
- public InternalBasicHandler(DataSource ds, String sql, StatementFactory statementFactory) {\r
- setDataSource(ds);\r
- setSql(sql);\r
- setStatementFactory(statementFactory);\r
- }\r
-\r
- // ===================================================================================\r
- // Basic Method for SubClass\r
- // =========================\r
- protected void bindArgs(PreparedStatement ps, Object[] args, Class<?>[] argTypes) {\r
- if (args == null) {\r
- return;\r
- }\r
- for (int i = 0; i < args.length; ++i) {\r
- ValueType valueType = getValueType(argTypes[i]);\r
- try {\r
- valueType.bindValue(ps, i + 1, args[i]);\r
- } catch (SQLException e) {\r
- handleSQLException(e, ps);\r
- }\r
- }\r
- }\r
-\r
- protected Class<?>[] getArgTypes(Object[] args) {\r
- if (args == null) {\r
- return null;\r
- }\r
- Class<?>[] argTypes = new Class[args.length];\r
- for (int i = 0; i < args.length; ++i) {\r
- Object arg = args[i];\r
- if (arg != null) {\r
- argTypes[i] = arg.getClass();\r
- }\r
- }\r
- return argTypes;\r
- }\r
-\r
- protected String getCompleteSql(Object[] args) {\r
- return InternalBindVariableUtil.getCompleteSql(sql, args);\r
- }\r
-\r
- protected String getBindVariableText(Object bindVariable) {\r
- return InternalBindVariableUtil.getBindVariableText(bindVariable);\r
- }\r
-\r
- protected ValueType getValueType(Class<?> clazz) {\r
- return ValueTypes.getValueType(clazz);\r
- }\r
-\r
- protected void logSql(Object[] args, Class<?>[] argTypes) {\r
- if (QLog.isLogEnabled() || InternalSqlLogRegistry.existsSqlLogRegistry()) {\r
- final String completeSql = getCompleteSql(args);\r
- if (isContainsLineSeparatorInSql()) {\r
- QLog.log(getLineSeparator() + completeSql);\r
- } else {\r
- QLog.log(completeSql);\r
- }\r
- if (InternalSqlLogRegistry.existsSqlLogRegistry()) {\r
- final Object sqlLogRegistry = InternalSqlLogRegistry.findContainerSqlLogRegistry();\r
- if (sqlLogRegistry != null) {\r
- InternalSqlLogRegistry.push(getSql(), completeSql, args, argTypes, sqlLogRegistry);\r
- }\r
- }\r
- }\r
- }\r
- \r
- protected boolean isContainsLineSeparatorInSql() {\r
- return sql != null ? sql.contains(getLineSeparator()) : false;\r
- }\r
-\r
- // ===================================================================================\r
- // Exception Handler\r
- // =================\r
- protected void handleSQLException(SQLException e, Statement statement) {\r
- handleSQLException(e, statement, false);\r
- }\r
-\r
- protected void handleSQLException(SQLException e, Statement statement, boolean uniqueConstraintValid) {\r
- String completeSql = buildLoggingMessageSql();\r
- new SQLExceptionHandler().handleSQLException(e, statement, uniqueConstraintValid, completeSql);\r
- }\r
-\r
- protected String buildLoggingMessageSql() {\r
- String completeSql = null;\r
- if (sql != null && loggingMessageSqlArgs != null) {\r
- try {\r
- completeSql = getCompleteSql(loggingMessageSqlArgs);\r
- } catch (RuntimeException ignored) {\r
- }\r
- }\r
- return completeSql;\r
- }\r
-\r
- public static class SQLExceptionHandler {\r
-\r
- public void handleSQLException(SQLException e, Statement statement) {\r
- handleSQLException(e, statement, false);\r
- }\r
- \r
- public void handleSQLException(SQLException e, Statement statement, boolean uniqueConstraintValid) {\r
- handleSQLException(e, statement, uniqueConstraintValid, null);\r
- }\r
- \r
- public void handleSQLException(SQLException e, Statement statement, boolean uniqueConstraintValid, String completeSql) {\r
- if (isSqlExceptionOldStyleHandling()) {\r
- throw new SQLRuntimeException(e);\r
- }\r
- if (uniqueConstraintValid && isUniqueConstraintException(e)) {\r
- throwEntityAlreadyExistsException(e, statement, completeSql);\r
- }\r
- throwSQLFailureException(e, statement, completeSql);\r
- }\r
- \r
- protected boolean isUniqueConstraintException(SQLException e) {\r
- DBFluteConfig.UniqueConstraintDeterminator determinator = getUniqueConstraintDeterminator();\r
- if (determinator != null) {\r
- return determinator.isUniqueConstraintException(e);\r
- }\r
- return ConditionBeanContext.isUniqueConstraintException(extractSQLState(e), e.getErrorCode());\r
- }\r
- \r
- protected DBFluteConfig.UniqueConstraintDeterminator getUniqueConstraintDeterminator() {\r
- return DBFluteConfig.getInstance().getUniqueConstraintDeterminator();\r
- }\r
- \r
- protected boolean isSqlExceptionOldStyleHandling() {\r
- return DBFluteConfig.getInstance().isSqlExceptionOldStyleHandling();\r
- }\r
- \r
- protected void throwEntityAlreadyExistsException(SQLException e, Statement statement, String completeSql) {\r
- String msg = "Look! Read the message below." + getLineSeparator();\r
- msg = msg + "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *" + getLineSeparator();\r
- msg = msg + "The entity already exists on the database!" + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Advice]" + getLineSeparator();\r
- msg = msg + "Please confirm the primary key whether it already exists on the database." + getLineSeparator();\r
- msg = msg + "And confirm the unique constraint for other columns." + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[SQLState]" + getLineSeparator() + extractSQLState(e) + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[ErrorCode]" + getLineSeparator() + e.getErrorCode() + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[SQLException]" + getLineSeparator() + e.getClass().getName() + getLineSeparator();\r
- msg = msg + e.getMessage() + getLineSeparator();\r
- SQLException nextEx = e.getNextException();\r
- if (nextEx != null) {\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[NextException]" + getLineSeparator();\r
- msg = msg + nextEx.getClass().getName() + getLineSeparator();\r
- msg = msg + nextEx.getMessage() + getLineSeparator();\r
- SQLException nextNextEx = nextEx.getNextException();\r
- if (nextNextEx != null) {\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[NextNextException]" + getLineSeparator();\r
- msg = msg + nextNextEx.getClass().getName() + getLineSeparator();\r
- msg = msg + nextNextEx.getMessage() + getLineSeparator();\r
- }\r
- }\r
- Object invokeName = extractBehaviorInvokeName();\r
- if (invokeName != null) {\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Behavior]" + getLineSeparator();\r
- msg = msg + invokeName + getLineSeparator();\r
- }\r
- if (hasConditionBean()) {\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[ConditionBean]" + getLineSeparator();\r
- msg = msg + getConditionBean().getClass().getName() + getLineSeparator();\r
- }\r
- if (hasOutsideSqlContext()) {\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[OutsideSql]" + getLineSeparator();\r
- msg = msg + getOutsideSqlContext().getOutsideSqlPath() + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[ParameterBean]" + getLineSeparator();\r
- Object pmb = getOutsideSqlContext().getParameterBean();\r
- if (pmb != null) {\r
- msg = msg + pmb.getClass().getName() + getLineSeparator();\r
- msg = msg + pmb + getLineSeparator();\r
- } else {\r
- msg = msg + pmb + getLineSeparator();\r
- }\r
- }\r
- if (statement != null) {\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Statement]" + getLineSeparator();\r
- msg = msg + statement.getClass().getName() + getLineSeparator();\r
- }\r
- if (completeSql != null) {\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Display SQL]" + getLineSeparator();\r
- msg = msg + completeSql + getLineSeparator();\r
- }\r
- msg = msg + "* * * * * * * * * */";\r
- throw new EntityAlreadyExistsException(msg, e);\r
- }\r
- \r
- protected void throwSQLFailureException(SQLException e, Statement statement, String completeSql) {\r
- String msg = "Look! Read the message below." + getLineSeparator();\r
- msg = msg + "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *" + getLineSeparator();\r
- msg = msg + "The SQL failed to execute!" + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Advice]" + getLineSeparator();\r
- msg = msg + "Please confirm the SQLException message." + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[SQLState]" + getLineSeparator() + extractSQLState(e) + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[ErrorCode]" + getLineSeparator() + e.getErrorCode() + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[SQLException]" + getLineSeparator() + e.getClass().getName() + getLineSeparator();\r
- msg = msg + e.getMessage() + getLineSeparator();\r
- SQLException nextEx = e.getNextException();\r
- if (nextEx != null) {\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[NextException]" + getLineSeparator();\r
- msg = msg + nextEx.getClass().getName() + getLineSeparator();\r
- msg = msg + nextEx.getMessage() + getLineSeparator();\r
- SQLException nextNextEx = nextEx.getNextException();\r
- if (nextNextEx != null) {\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[NextNextException]" + getLineSeparator();\r
- msg = msg + nextNextEx.getClass().getName() + getLineSeparator();\r
- msg = msg + nextNextEx.getMessage() + getLineSeparator();\r
- }\r
- }\r
- Object invokeName = extractBehaviorInvokeName();\r
- if (invokeName != null) {\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Behavior]" + getLineSeparator();\r
- msg = msg + invokeName + getLineSeparator();\r
- }\r
- if (hasConditionBean()) {\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[ConditionBean]" + getLineSeparator();\r
- msg = msg + getConditionBean().getClass().getName() + getLineSeparator();\r
- }\r
- if (hasOutsideSqlContext()) {\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[OutsideSql]" + getLineSeparator();\r
- msg = msg + getOutsideSqlContext().getOutsideSqlPath() + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[ParameterBean]" + getLineSeparator();\r
- Object pmb = getOutsideSqlContext().getParameterBean();\r
- if (pmb != null) {\r
- msg = msg + pmb.getClass().getName() + getLineSeparator();\r
- msg = msg + pmb + getLineSeparator();\r
- } else {\r
- msg = msg + pmb + getLineSeparator();\r
- }\r
- }\r
- if (statement != null) {\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Statement]" + getLineSeparator();\r
- msg = msg + statement.getClass().getName() + getLineSeparator();\r
- }\r
- if (completeSql != null) {\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Display SQL]" + getLineSeparator();\r
- msg = msg + completeSql + getLineSeparator();\r
- }\r
- msg = msg + "* * * * * * * * * */";\r
- throw new SQLFailureException(msg, e);\r
- }\r
-\r
- protected String extractSQLState(SQLException e) {\r
- String sqlState = e.getSQLState();\r
- if (sqlState != null) {\r
- return sqlState;\r
- }\r
-\r
- // Next\r
- SQLException nextEx = e.getNextException();\r
- if (nextEx == null) {\r
- return null;\r
- }\r
- sqlState = nextEx.getSQLState();\r
- if (sqlState != null) {\r
- return sqlState;\r
- }\r
-\r
- // Next Next\r
- SQLException nextNextEx = nextEx.getNextException();\r
- if (nextNextEx == null) {\r
- return null;\r
- }\r
- sqlState = nextNextEx.getSQLState();\r
- if (sqlState != null) {\r
- return sqlState;\r
- }\r
-\r
- // Next Next Next\r
- SQLException nextNextNextEx = nextNextEx.getNextException();\r
- if (nextNextNextEx == null) {\r
- return null;\r
- }\r
- sqlState = nextNextNextEx.getSQLState();\r
- if (sqlState != null) {\r
- return sqlState;\r
- }\r
-\r
- // It doesn't use recursive call by design because JDBC is unpredictable fellow.\r
- return null;\r
- }\r
-\r
- protected String extractBehaviorInvokeName() {\r
- final Object behaviorInvokeName = InternalMapContext.getObject("df:BehaviorInvokeName");\r
- if (behaviorInvokeName == null) {\r
- return null;\r
- }\r
- final Object clientInvokeName = InternalMapContext.getObject("df:ClientInvokeName");\r
- final Object byPassInvokeName = InternalMapContext.getObject("df:ByPassInvokeName");\r
- final StringBuilder sb = new StringBuilder();\r
- boolean existsPath = false;\r
- if (clientInvokeName != null) {\r
- existsPath = true;\r
- sb.append(clientInvokeName);\r
- }\r
- if (byPassInvokeName != null) {\r
- existsPath = true;\r
- sb.append(byPassInvokeName);\r
- }\r
- sb.append(behaviorInvokeName);\r
- if (existsPath) {\r
- sb.append("...");\r
- }\r
- return sb.toString();\r
- }\r
-\r
- protected boolean hasConditionBean() {\r
- return ConditionBeanContext.isExistConditionBeanOnThread();\r
- }\r
-\r
- protected ConditionBean getConditionBean() {\r
- return ConditionBeanContext.getConditionBeanOnThread();\r
- }\r
-\r
- protected boolean hasOutsideSqlContext() {\r
- return OutsideSqlContext.isExistOutsideSqlContextOnThread();\r
- }\r
-\r
- protected OutsideSqlContext getOutsideSqlContext() {\r
- return OutsideSqlContext.getOutsideSqlContextOnThread();\r
- }\r
-\r
- protected String getLineSeparator() {\r
- return SimpleSystemUtil.getLineSeparator();\r
- }\r
- }\r
-\r
- // ===================================================================================\r
- // JDBC Delegator\r
- // ==============\r
- protected Connection getConnection() {\r
- if (dataSource == null) {\r
- throw new IllegalStateException("The dataSource should not be null!");\r
- }\r
- try {\r
- return dataSource.getConnection();\r
- } catch (SQLException e) {\r
- handleSQLException(e, null);\r
- return null;// Unreachable!\r
- }\r
- }\r
-\r
- protected PreparedStatement prepareStatement(Connection conn) {\r
- if (sql == null) {\r
- throw new IllegalStateException("The sql should not be null!");\r
- }\r
- return statementFactory.createPreparedStatement(conn, sql);\r
- }\r
-\r
- protected int executeUpdate(PreparedStatement ps) {\r
- try {\r
- return ps.executeUpdate();\r
- } catch (SQLException e) {\r
- handleSQLException(e, ps, true);\r
- return 0;// Unreachable!\r
- }\r
- }\r
-\r
- protected void setFetchSize(Statement statement, int fetchSize) {\r
- if (statement == null) {\r
- return;\r
- }\r
- try {\r
- statement.setFetchSize(fetchSize);\r
- } catch (SQLException e) {\r
- handleSQLException(e, statement);\r
- }\r
- }\r
-\r
- protected void setMaxRows(Statement statement, int maxRows) {\r
- if (statement == null) {\r
- return;\r
- }\r
- try {\r
- statement.setMaxRows(maxRows);\r
- } catch (SQLException e) {\r
- handleSQLException(e, statement);\r
- }\r
- }\r
-\r
- protected void close(Statement statement) {\r
- if (statement == null) {\r
- return;\r
- }\r
- try {\r
- statement.close();\r
- } catch (SQLException e) {\r
- handleSQLException(e, statement);\r
- }\r
- }\r
-\r
- protected void close(ResultSet resultSet) {\r
- if (resultSet == null) {\r
- return;\r
- }\r
- try {\r
- resultSet.close();\r
- } catch (SQLException e) {\r
- handleSQLException(e, null);\r
- }\r
- }\r
-\r
- protected void close(Connection conn) {\r
- if (conn == null) {\r
- return;\r
- }\r
- try {\r
- conn.close();\r
- } catch (SQLException e) {\r
- handleSQLException(e, null);\r
- }\r
- }\r
-\r
- // ===================================================================================\r
- // Assist Helper\r
- // =============\r
- // It needs this method if the target database doest not support line comment.\r
- protected String removeLineComment(final String sql) { // With removing CR!\r
- if (sql == null || sql.trim().length() == 0) {\r
- return sql;\r
- }\r
- final StringBuilder sb = new StringBuilder();\r
- final String[] lines = sql.split("\n");\r
- for (String line : lines) {\r
- if (line == null) {\r
- continue;\r
- }\r
- line = line.replaceAll("\r", ""); // Remove CR!\r
- if (line.startsWith("--")) {\r
- continue;\r
- }\r
- sb.append(line).append("\n");\r
- }\r
- return sb.toString();\r
- }\r
-\r
- // ===================================================================================\r
- // General Helper\r
- // ==============\r
- protected String getLineSeparator() {\r
- return SimpleSystemUtil.getLineSeparator();\r
- }\r
-\r
- // ===================================================================================\r
- // Accessor\r
- // ========\r
- public DataSource getDataSource() {\r
- return dataSource;\r
- }\r
-\r
- public void setDataSource(DataSource dataSource) {\r
- this.dataSource = dataSource;\r
- }\r
-\r
- public String getSql() {\r
- return sql;\r
- }\r
-\r
- public void setSql(String sql) {\r
- sql = removeLineComment(sql);\r
- this.sql = sql;\r
- }\r
-\r
- public StatementFactory getStatementFactory() {\r
- return statementFactory;\r
- }\r
-\r
- public void setStatementFactory(StatementFactory statementFactory) {\r
- this.statementFactory = statementFactory;\r
- }\r
-\r
- public void setLoggingMessageSqlArgs(Object[] loggingMessageSqlArgs) {\r
- this.loggingMessageSqlArgs = loggingMessageSqlArgs;\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlhandler;\r
-\r
-import java.sql.Connection;\r
-import java.sql.PreparedStatement;\r
-import java.sql.ResultSet;\r
-import java.sql.SQLException;\r
-\r
-import javax.sql.DataSource;\r
-\r
-import org.seasar.extension.jdbc.ResultSetHandler;\r
-import org.seasar.extension.jdbc.StatementFactory;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.FetchNarrowingBean;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.FetchNarrowingBeanContext;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.outsidesql.OutsideSqlContext;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.s2dao.FetchNarrowingResultSetWrapper;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class InternalBasicSelectHandler extends InternalBasicHandler {\r
-\r
- // ===================================================================================\r
- // Attribute\r
- // =========\r
- private ResultSetHandler resultSetHandler;\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- public InternalBasicSelectHandler(DataSource dataSource, String sql,\r
- ResultSetHandler resultSetHandler, StatementFactory statementFactory) {\r
- super(dataSource, statementFactory);\r
- setSql(sql);\r
- setResultSetHandler(resultSetHandler);\r
- }\r
-\r
- // ===================================================================================\r
- // Execute\r
- // =======\r
- public Object execute(Object[] args) {\r
- return execute(args, getArgTypes(args));\r
- }\r
-\r
- @SuppressWarnings("unchecked")\r
- public Object execute(Object[] args, Class[] argTypes) {\r
- Connection conn = getConnection();\r
- try {\r
- return execute(conn, args, argTypes);\r
- } finally {\r
- close(conn);\r
- }\r
- }\r
-\r
- @SuppressWarnings("unchecked")\r
- public Object execute(Connection conn, Object[] args, Class[] argTypes) {\r
- logSql(args, argTypes);\r
- PreparedStatement ps = null;\r
- try {\r
- ps = prepareStatement(conn);\r
- bindArgs(ps, args, argTypes);\r
- return execute(ps);\r
- } catch (SQLException e) {\r
- handleSQLException(e, ps);\r
- return null; // Unreachable!\r
- } finally {\r
- close(ps);\r
- }\r
- }\r
-\r
- protected Object execute(PreparedStatement ps) throws SQLException {\r
- if (resultSetHandler == null) {\r
- throw new IllegalStateException("The resultSetHandler should not be null!");\r
- }\r
- ResultSet resultSet = null;\r
- try {\r
- resultSet = createResultSet(ps);\r
- return resultSetHandler.handle(resultSet);\r
- } finally {\r
- close(resultSet);\r
- }\r
- }\r
-\r
- protected ResultSet createResultSet(PreparedStatement ps) throws SQLException {\r
- final ResultSet resultSet = ps.executeQuery();\r
- if (!FetchNarrowingBeanContext.isExistFetchNarrowingBeanOnThread()) {\r
- return resultSet;\r
- }\r
- final FetchNarrowingBean cb = FetchNarrowingBeanContext.getFetchNarrowingBeanOnThread();\r
- if (!isUseFetchNarrowingResultSetWrapper(cb)) {\r
- return resultSet;\r
- }\r
- final FetchNarrowingResultSetWrapper wrapper;\r
- if (OutsideSqlContext.isExistOutsideSqlContextOnThread()) {\r
- final OutsideSqlContext outsideSqlContext = OutsideSqlContext.getOutsideSqlContextOnThread();\r
- wrapper = new FetchNarrowingResultSetWrapper(resultSet, cb, outsideSqlContext.isOffsetByCursorForcedly(), outsideSqlContext.isLimitByCursorForcedly());\r
- } else {\r
- wrapper = new FetchNarrowingResultSetWrapper(resultSet, cb, false, false);\r
- }\r
- return wrapper;\r
- }\r
-\r
- protected boolean isUseFetchNarrowingResultSetWrapper(FetchNarrowingBean cb) {\r
- if (cb.getSafetyMaxResultSize() > 0) {\r
- return true;\r
- }\r
- if (!cb.isFetchNarrowingEffective()) {\r
- return false; // It is not necessary to control.\r
- }\r
- if (OutsideSqlContext.isExistOutsideSqlContextOnThread()) {\r
- final OutsideSqlContext outsideSqlContext = OutsideSqlContext.getOutsideSqlContextOnThread();\r
- if (outsideSqlContext.isOffsetByCursorForcedly() || outsideSqlContext.isLimitByCursorForcedly()) {\r
- return true;\r
- }\r
- }\r
- if (cb.isFetchNarrowingSkipStartIndexEffective() || cb.isFetchNarrowingLoopCountEffective()) {\r
- return true;\r
- }\r
- return false;\r
- }\r
-\r
- // ===================================================================================\r
- // Accessor\r
- // ========\r
- public ResultSetHandler getResultSetHandler() {\r
- return resultSetHandler;\r
- }\r
-\r
- public void setResultSetHandler(ResultSetHandler resultSetHandler) {\r
- this.resultSetHandler = resultSetHandler;\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlhandler;\r
-\r
-import java.sql.Connection;\r
-import java.sql.PreparedStatement;\r
-\r
-import javax.sql.DataSource;\r
-\r
-import org.seasar.extension.jdbc.StatementFactory;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class InternalBasicUpdateHandler extends InternalBasicHandler {\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- public InternalBasicUpdateHandler(DataSource dataSource, String sql, StatementFactory statementFactory) {\r
- super(dataSource, sql, statementFactory);\r
- }\r
-\r
- // ===================================================================================\r
- // Execute\r
- // =======\r
- public int execute(Object[] args) {\r
- return execute(args, getArgTypes(args));\r
- }\r
-\r
- @SuppressWarnings("unchecked")\r
- public int execute(Object[] args, Class[] argTypes) {\r
- Connection connection = getConnection();\r
- try {\r
- return execute(connection, args, argTypes);\r
- } finally {\r
- close(connection);\r
- }\r
- }\r
-\r
- @SuppressWarnings("unchecked")\r
- public int execute(Connection connection, Object[] args, Class[] argTypes) {\r
- logSql(args, argTypes);\r
- PreparedStatement ps = prepareStatement(connection);\r
- try {\r
- bindArgs(ps, args, argTypes);\r
- return executeUpdate(ps);\r
- } finally {\r
- close(ps);\r
- }\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlhandler;\r
-\r
-import java.sql.Connection;\r
-import java.sql.PreparedStatement;\r
-\r
-import javax.sql.DataSource;\r
-\r
-import org.seasar.dao.CommandContext;\r
-import org.seasar.extension.jdbc.StatementFactory;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class InternalCommandContextHandler extends InternalBasicHandler {\r
-\r
- // ===================================================================================\r
- // Attribute\r
- // =========\r
- protected CommandContext commandContext;\r
- \r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- public InternalCommandContextHandler(DataSource dataSource, StatementFactory statementFactory, CommandContext commandContext) {\r
- super(dataSource, statementFactory);\r
- this.commandContext = commandContext;\r
- setSql(commandContext.getSql());\r
- }\r
-\r
- // ===================================================================================\r
- // Execute\r
- // =======\r
- public int execute(Object[] args) {\r
- final Connection connection = getConnection();\r
- try {\r
- return execute(connection, commandContext);\r
- } finally {\r
- close(connection);\r
- }\r
- }\r
-\r
- protected int execute(Connection connection, CommandContext context) {\r
- logSql(context.getBindVariables(), getArgTypes(context.getBindVariables()));\r
- PreparedStatement ps = prepareStatement(connection);\r
- int ret = -1;\r
- try {\r
- bindArgs(ps, context.getBindVariables(), context.getBindVariableTypes());\r
- ret = executeUpdate(ps);\r
- } finally {\r
- close(ps);\r
- }\r
- return ret;\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlhandler;\r
-\r
-import javax.sql.DataSource;\r
-\r
-import org.seasar.dao.BeanMetaData;\r
-import org.seasar.extension.jdbc.PropertyType;\r
-import org.seasar.extension.jdbc.StatementFactory;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class InternalDeleteAutoHandler extends InternalAbstractAutoHandler {\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- public InternalDeleteAutoHandler(DataSource dataSource,\r
- StatementFactory statementFactory, BeanMetaData beanMetaData,\r
- PropertyType[] propertyTypes) {\r
- super(dataSource, statementFactory, beanMetaData, propertyTypes);\r
- }\r
-\r
- // ===================================================================================\r
- // Override\r
- // ========\r
- @Override\r
- protected void setupBindVariables(Object bean) {\r
- setupDeleteBindVariables(bean);\r
- setLoggingMessageSqlArgs(bindVariables);\r
- }\r
-}
\ No newline at end of file
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlhandler;\r
-\r
-import javax.sql.DataSource;\r
-\r
-import org.seasar.extension.jdbc.PropertyType;\r
-import org.seasar.extension.jdbc.StatementFactory;\r
-import org.seasar.dao.BeanMetaData;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class InternalDeleteBatchAutoHandler extends InternalAbstractBatchAutoHandler {\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- public InternalDeleteBatchAutoHandler(DataSource dataSource,\r
- StatementFactory statementFactory, BeanMetaData beanMetaData,\r
- PropertyType[] propertyTypes) {\r
-\r
- super(dataSource, statementFactory, beanMetaData, propertyTypes);\r
- }\r
-\r
- // ===================================================================================\r
- // Override\r
- // ========\r
- @Override\r
- protected void setupBindVariables(Object bean) {\r
- setupDeleteBindVariables(bean);\r
- }\r
-}
\ No newline at end of file
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlhandler;\r
-\r
-import javax.sql.DataSource;\r
-\r
-import org.seasar.dao.BeanMetaData;\r
-import org.seasar.dao.IdentifierGenerator;\r
-import org.seasar.extension.jdbc.PropertyType;\r
-import org.seasar.extension.jdbc.StatementFactory;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class InternalInsertAutoHandler extends InternalAbstractAutoHandler {\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- public InternalInsertAutoHandler(DataSource dataSource,\r
- StatementFactory statementFactory, BeanMetaData beanMetaData,\r
- PropertyType[] propertyTypes) {\r
- super(dataSource, statementFactory, beanMetaData, propertyTypes);\r
- }\r
-\r
- // ===================================================================================\r
- // Override\r
- // ========\r
- @Override\r
- protected void setupBindVariables(Object bean) {\r
- setupInsertBindVariables(bean);\r
- setLoggingMessageSqlArgs(bindVariables);\r
- }\r
-\r
- @Override\r
- protected void preUpdateBean(Object bean) {\r
- BeanMetaData bmd = getBeanMetaData();\r
- for (int i = 0; i < bmd.getIdentifierGeneratorSize(); i++) {\r
- IdentifierGenerator generator = bmd.getIdentifierGenerator(i);\r
- if (generator.isSelfGenerate()) {\r
- generator.setIdentifier(bean, getDataSource());\r
- }\r
- }\r
- }\r
- \r
- @Override\r
- protected void postUpdateBean(Object bean, int ret) {\r
- BeanMetaData bmd = getBeanMetaData();\r
- for (int i = 0; i < bmd.getIdentifierGeneratorSize(); i++) {\r
- IdentifierGenerator generator = bmd.getIdentifierGenerator(i);\r
- if (!generator.isSelfGenerate()) {\r
- generator.setIdentifier(bean, getDataSource());\r
- }\r
- }\r
- updateVersionNoIfNeed(bean);\r
- updateTimestampIfNeed(bean);\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlhandler;\r
-\r
-import javax.sql.DataSource;\r
-\r
-import org.seasar.extension.jdbc.PropertyType;\r
-import org.seasar.extension.jdbc.StatementFactory;\r
-import org.seasar.dao.BeanMetaData;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class InternalInsertBatchAutoHandler extends InternalAbstractBatchAutoHandler {\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- public InternalInsertBatchAutoHandler(DataSource dataSource,\r
- StatementFactory statementFactory, BeanMetaData beanMetaData,\r
- PropertyType[] propertyTypes) {\r
-\r
- super(dataSource, statementFactory, beanMetaData, propertyTypes);\r
- }\r
-\r
- // ===================================================================================\r
- // Override\r
- // ========\r
- @Override\r
- protected void setupBindVariables(Object bean) {\r
- setupInsertBindVariables(bean);\r
- }\r
-}
\ No newline at end of file
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlhandler;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.sql.CallableStatement;\r
-import java.sql.Connection;\r
-import java.sql.ResultSet;\r
-import java.sql.ResultSetMetaData;\r
-import java.sql.Statement;\r
-import java.sql.SQLException;\r
-import javax.sql.DataSource;\r
-\r
-import org.seasar.framework.util.CaseInsensitiveMap;\r
-import org.seasar.extension.jdbc.PropertyType;\r
-import org.seasar.extension.jdbc.ResultSetHandler;\r
-import org.seasar.extension.jdbc.StatementFactory;\r
-import org.seasar.extension.jdbc.ValueType;\r
-import org.seasar.extension.jdbc.impl.PropertyTypeImpl;\r
-import org.seasar.extension.jdbc.types.ValueTypes;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.various.InternalProcedureMetaData;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.various.InternalProcedureParameterType;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class InternalProcedureHandler extends InternalBasicSelectHandler {\r
-\r
- // ===================================================================================\r
- // Attribute\r
- // =========\r
- private InternalProcedureMetaData procedureMetaData;\r
- \r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- public InternalProcedureHandler(final DataSource dataSource, final String sql,\r
- final ResultSetHandler resultSetHandler, final StatementFactory statementFactory,\r
- final InternalProcedureMetaData procedureMetaData) {\r
- super(dataSource, sql, resultSetHandler, statementFactory);\r
- this.procedureMetaData = procedureMetaData;\r
- }\r
- \r
- // ===================================================================================\r
- // Execute\r
- // =======\r
- @SuppressWarnings("unchecked")\r
- public Object execute(final Connection connection, final Object[] args, final Class[] argTypes) {\r
- final Object dto = getArgumentDto(args);\r
- logSql(args, argTypes);\r
- CallableStatement cs = null;\r
- try {\r
- cs = prepareCallableStatement(connection);\r
- bindArgs(cs, dto);\r
- Object returnValue = null; \r
- if (cs.execute()) {\r
- final ResultSet resultSet = cs.getResultSet();\r
- if (resultSet != null) {\r
- final ResultSetHandler handler = createReturnResultSetHandler(resultSet);\r
- try {\r
- returnValue = handler.handle(resultSet);\r
- } finally {\r
- if (resultSet != null) {\r
- resultSet.close();\r
- }\r
- }\r
- }\r
- }\r
- return handleOutParameters(cs, dto, returnValue);\r
- } catch (SQLException e) {\r
- handleSQLException(e, cs);\r
- return null;// Unreachable!\r
- } finally {\r
- close(cs);\r
- }\r
- }\r
-\r
- protected ResultSetHandler createReturnResultSetHandler(ResultSet resultSet) {\r
- return new InternalMapListResultSetHandler();\r
- }\r
-\r
- @Override\r
- protected String getCompleteSql(final Object[] args) {// for Procedure Call\r
- String sql = getSql();\r
- Object dto = getArgumentDto(args);\r
- if (args == null || dto == null) {\r
- return sql;\r
- }\r
- StringBuilder sb = new StringBuilder(100);\r
- int pos = 0;\r
- int pos2 = 0;\r
- for (InternalProcedureParameterType ppt : procedureMetaData.parameterTypes()) {\r
- if ((pos2 = sql.indexOf('?', pos)) < 0) {\r
- break;\r
- }\r
- sb.append(sql.substring(pos, pos2));\r
- pos = pos2 + 1;\r
- if (ppt.isInType()) {\r
- sb.append(getBindVariableText(ppt.getValue(dto)));\r
- } else {\r
- sb.append(sql.substring(pos2, pos));\r
- }\r
- }\r
- sb.append(sql.substring(pos));\r
- return sb.toString();\r
- }\r
-\r
- protected CallableStatement prepareCallableStatement(final Connection connection) {\r
- if (getSql() == null) { throw new IllegalStateException("The SQL should not be null!"); }\r
- return getStatementFactory().createCallableStatement(connection, getSql());\r
- }\r
-\r
- protected void bindArgs(final CallableStatement cs, final Object dto) throws SQLException {\r
- if (dto == null) { return; }\r
- int i = 0;\r
- for (InternalProcedureParameterType ppt : procedureMetaData.parameterTypes()) {\r
- final ValueType valueType = ppt.getValueType();\r
- if (ppt.isOutType()) {\r
- valueType.registerOutParameter(cs, i + 1);\r
- }\r
- if (ppt.isInType()) {\r
- final Object value = ppt.getValue(dto);\r
- valueType.bindValue(cs, i + 1, value);\r
- }\r
- ++i;\r
- }\r
- }\r
-\r
- protected Object handleResultSet(final CallableStatement cs) throws SQLException {\r
- ResultSet rs = null;\r
- try {\r
- rs = getResultSet(cs);\r
- return getResultSetHandler().handle(rs);\r
- } finally {\r
- close(rs);\r
- }\r
- }\r
-\r
- protected ResultSet getResultSet(Statement statement) {\r
- try {\r
- return statement.getResultSet();\r
- } catch (SQLException e) {\r
- handleSQLException(e, statement);\r
- return null;// Unreachable!\r
- }\r
- }\r
-\r
- protected Object handleOutParameters(final CallableStatement cs, final Object dto, Object returnValue) throws SQLException {\r
- if (dto == null) {\r
- return null;\r
- }\r
- int i = 0;\r
- for (InternalProcedureParameterType ppt : procedureMetaData.parameterTypes()) {\r
- final ValueType valueType = ppt.getValueType();\r
- if (ppt.isOutType()) {\r
- Object value = valueType.getValue(cs, i + 1);\r
- if (value instanceof ResultSet) {\r
- final ResultSet resultSet = (ResultSet) value;\r
- final ResultSetHandler handler = createOutParameterResultSetHandler(ppt, resultSet);\r
- try {\r
- value = handler.handle(resultSet);\r
- } finally {\r
- if (resultSet != null) {\r
- resultSet.close();\r
- }\r
- }\r
- }\r
- ppt.setValue(dto, value);\r
- } else if (ppt.isReturnType()) {\r
- ppt.setValue(dto, returnValue);\r
- }\r
- ++i;\r
- }\r
- return dto;\r
- }\r
-\r
- protected Object getArgumentDto(Object[] args) {\r
- if (args.length == 0) {\r
- return null;\r
- }\r
- if (args.length == 1) {\r
- if (args[0] == null) {\r
- throw new IllegalArgumentException("args[0] should not be null!");\r
- }\r
- return args[0];\r
- }\r
- throw new IllegalArgumentException("args");\r
- }\r
-\r
- protected ResultSetHandler createOutParameterResultSetHandler(InternalProcedureParameterType ppt, ResultSet resultSet) {\r
- return new InternalMapListResultSetHandler();\r
- }\r
-\r
- // ===================================================================================\r
- // Map Result Set Handler\r
- // ======================\r
- protected static abstract class InternalAbstractMapResultSetHandler implements ResultSetHandler {\r
-\r
- @SuppressWarnings("unchecked")\r
- protected Map<String, Object> createRow(ResultSet rs, PropertyType[] propertyTypes) throws SQLException {\r
- Map<String, Object> row = new CaseInsensitiveMap();\r
- for (int i = 0; i < propertyTypes.length; ++i) {\r
- Object value = propertyTypes[i].getValueType().getValue(rs, i + 1);\r
- row.put(propertyTypes[i].getPropertyName(), value);\r
- }\r
- return row;\r
- }\r
-\r
- protected PropertyType[] createPropertyTypes(ResultSetMetaData rsmd) throws SQLException {\r
- int count = rsmd.getColumnCount();\r
- PropertyType[] propertyTypes = new PropertyType[count];\r
- for (int i = 0; i < count; ++i) {\r
- String propertyName = rsmd.getColumnLabel(i + 1);\r
- ValueType valueType = ValueTypes.getValueType(rsmd.getColumnType(i + 1));\r
- propertyTypes[i] = new PropertyTypeImpl(propertyName, valueType);\r
- }\r
- return propertyTypes;\r
- }\r
- }\r
-\r
- protected static class InternalMapListResultSetHandler extends InternalAbstractMapResultSetHandler {\r
-\r
- public Object handle(ResultSet resultSet) throws SQLException {\r
- PropertyType[] propertyTypes = createPropertyTypes(resultSet.getMetaData());\r
- List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();\r
- while (resultSet.next()) {\r
- list.add(createRow(resultSet, propertyTypes));\r
- }\r
- return list;\r
- }\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlhandler;\r
-\r
-import javax.sql.DataSource;\r
-\r
-import org.seasar.dao.BeanMetaData;\r
-import org.seasar.extension.jdbc.PropertyType;\r
-import org.seasar.extension.jdbc.StatementFactory;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.exception.EntityAlreadyUpdatedException;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class InternalUpdateAutoHandler extends InternalAbstractAutoHandler {\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- private boolean checkSingleRowUpdate = true;\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- public InternalUpdateAutoHandler(DataSource dataSource,\r
- StatementFactory statementFactory, BeanMetaData beanMetaData,\r
- PropertyType[] propertyTypes) {\r
- super(dataSource, statementFactory, beanMetaData, propertyTypes);\r
- }\r
-\r
- // ===================================================================================\r
- // Override\r
- // ========\r
- @Override\r
- protected void setupBindVariables(Object bean) {\r
- setupUpdateBindVariables(bean);\r
- setLoggingMessageSqlArgs(bindVariables);\r
- }\r
-\r
- @Override\r
- protected void postUpdateBean(Object bean, int ret) {\r
- if (isCheckSingleRowUpdate() && ret < 1) {\r
- throw createEntityAlreadyUpdatedException(bean, ret);\r
- }\r
- updateVersionNoIfNeed(bean);\r
- updateTimestampIfNeed(bean);\r
- }\r
-\r
- protected EntityAlreadyUpdatedException createEntityAlreadyUpdatedException(Object bean, int rows) {\r
- return new EntityAlreadyUpdatedException(bean, rows);\r
- }\r
-\r
- // ===================================================================================\r
- // Accessor\r
- // ========\r
- public boolean isCheckSingleRowUpdate() {\r
- return checkSingleRowUpdate;\r
- }\r
-\r
- public void setCheckSingleRowUpdate(boolean resultCheck) {\r
- this.checkSingleRowUpdate = resultCheck;\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlhandler;\r
-\r
-import javax.sql.DataSource;\r
-\r
-import org.seasar.extension.jdbc.PropertyType;\r
-import org.seasar.extension.jdbc.StatementFactory;\r
-import org.seasar.dao.BeanMetaData;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class InternalUpdateBatchAutoHandler extends InternalAbstractBatchAutoHandler {\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- public InternalUpdateBatchAutoHandler(DataSource dataSource,\r
- StatementFactory statementFactory, BeanMetaData beanMetaData,\r
- PropertyType[] propertyTypes) {\r
-\r
- super(dataSource, statementFactory, beanMetaData, propertyTypes);\r
- }\r
-\r
- // ===================================================================================\r
- // Override\r
- // ========\r
- @Override\r
- protected void setupBindVariables(Object bean) {\r
- setupUpdateBindVariables(bean);\r
- }\r
-}
\ No newline at end of file
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqllog;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class InternalSqlLog {\r
-\r
- // ===================================================================================\r
- // Attribute\r
- // =========\r
- private String rawSql;\r
- private String completeSql;\r
- private Object[] bindArgs;\r
- private Class<?>[] bindArgTypes;\r
- \r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- public InternalSqlLog(String rawSql, String completeSql, Object[] bindArgs, Class<?>[] bindArgTypes) {\r
- this.rawSql = rawSql;\r
- this.completeSql = completeSql;\r
- this.bindArgs = bindArgs;\r
- this.bindArgTypes = bindArgTypes;\r
- }\r
-\r
- // ===================================================================================\r
- // Accessor\r
- // ========\r
- public Object[] getBindArgs() {\r
- return bindArgs;\r
- }\r
-\r
- public Class<?>[] getBindArgTypes() {\r
- return bindArgTypes;\r
- }\r
-\r
- public String getCompleteSql() {\r
- return completeSql;\r
- }\r
-\r
- public String getRawSql() {\r
- return rawSql;\r
- }\r
-\r
- public String toString() {\r
- return rawSql;\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqllog;\r
-\r
-import java.lang.reflect.Method;\r
-import java.lang.reflect.Constructor;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class InternalSqlLogRegistry {\r
-\r
- // ===================================================================================\r
- // Definition\r
- // ==========\r
- /** Log instance. */\r
- private static final org.apache.commons.logging.Log _log = org.apache.commons.logging.LogFactory.getLog(InternalSqlLogRegistry.class);\r
-\r
- // ===================================================================================\r
- // Definition\r
- // ==========\r
- protected static final String NAME_SqlLogRegistryLocator = "org.seasar.extension.jdbc.SqlLogRegistryLocator";\r
- protected static final String NAME_getInstance = "getInstance";\r
- protected static final String NAME_setInstance = "setInstance";\r
- protected static final String NAME_SqlLogRegistry = "org.seasar.extension.jdbc.SqlLogRegistry";\r
- protected static final String NAME_SqlLog = "org.seasar.extension.jdbc.SqlLog";\r
- protected static final String NAME_SqlLogImpl = "org.seasar.extension.jdbc.impl.SqlLogImpl";\r
- protected static boolean STATUS_SqlLogExists = false;\r
- static {\r
- forNameContainerSqlLogRegistryLocator();\r
- }\r
- \r
- // ===================================================================================\r
- // Public Entry\r
- // ============\r
- public static boolean existsSqlLogRegistry() {\r
- return STATUS_SqlLogExists;\r
- }\r
- \r
- public static Object findContainerSqlLogRegistry() {\r
- final Class<?> sqlLogRegistryLocatorType = forNameContainerSqlLogRegistryLocator();\r
- if (sqlLogRegistryLocatorType == null) {\r
- return null;\r
- }\r
- try {\r
- final Method method = sqlLogRegistryLocatorType.getMethod(NAME_getInstance, (Class[])null);\r
- return method.invoke(null, (Object[])null);\r
- } catch (Exception e) {\r
- String msg = "InternalSqlLogRegistry.findContainerSqlLogRegistry() threw the exception:";\r
- msg = msg + " sqlLogRegistryLocatorType=" + sqlLogRegistryLocatorType;\r
- msg = msg + " NAME_getInstance=" + NAME_getInstance;\r
- throw new IllegalStateException(msg, e);\r
- }\r
- }\r
- \r
- public static void closeRegistration() {\r
- final Class<?> sqlLogRegistryLocatorType = forNameContainerSqlLogRegistryLocator();\r
- if (sqlLogRegistryLocatorType == null) {\r
- return;\r
- }\r
- final Class<?> sqlLogRegistryType = forNameContainerSqlLogRegistry();\r
- if (sqlLogRegistryType == null) {\r
- return;\r
- }\r
- try {\r
- final Method method = sqlLogRegistryLocatorType.getMethod(NAME_setInstance, new Class[]{sqlLogRegistryType});\r
- _log.info("...Closing the registration of sqlLog.");\r
- method.invoke(null, new Object[]{null});\r
- } catch (Exception e) {\r
- String msg = "InternalSqlLogRegistry.closeRegistration() threw the exception:";\r
- msg = msg + " sqlLogRegistryLocatorType=" + sqlLogRegistryLocatorType;\r
- msg = msg + " NAME_setInstance=" + NAME_setInstance;\r
- throw new IllegalStateException(msg, e);\r
- }\r
- }\r
- \r
- public static void push(String rawSql, String completeSql, Object[] bindArgs, Class<?>[] bindArgTypes, Object sqlLogRegistry) {\r
- if (sqlLogRegistry == null) {\r
- throw new IllegalArgumentException("sqlLogRegistry should not be null!");\r
- }\r
- final Object sqlLogImpl = createContainerSqlLogImpl(rawSql, completeSql, bindArgs, bindArgTypes);\r
- reflectSqlLogToContainerSqlLogRegistry(sqlLogImpl, sqlLogRegistry);\r
- }\r
- \r
- public static String peekCompleteSql() {\r
- final Object sqlLogRegistry = findContainerSqlLogRegistry();\r
- if (sqlLogRegistry == null) {\r
- return null;\r
- }\r
- final Object sqlLog = findLastContainerSqlLog(sqlLogRegistry);\r
- if (sqlLog == null) {\r
- return null;\r
- }\r
- return extractCompleteSqlFromContainerSqlLog(sqlLog);\r
- }\r
-\r
- // ===================================================================================\r
- // Container Reflection\r
- // ====================\r
- protected static Object createContainerSqlLogImpl(String rawSql, String completeSql, Object[] bindArgs, Class<?>[] bindArgTypes) {\r
- try {\r
- final Class<?> sqlLogImplType = Class.forName(NAME_SqlLogImpl);\r
- final Class<?>[] argTypes = new Class[]{String.class, String.class, Object[].class, Class[].class};\r
- final Constructor<?> constructor = sqlLogImplType.getConstructor(argTypes);\r
- return constructor.newInstance(new Object[]{rawSql, completeSql, bindArgs, bindArgTypes});\r
- } catch (Exception e) {\r
- String msg = "InternalSqlLogRegistry.createContainerSqlLogImpl() threw the exception:";\r
- msg = msg + " completeSql=" + completeSql;\r
- msg = msg + " NAME_SqlLogImpl=" + NAME_SqlLogImpl;\r
- throw new IllegalStateException(msg, e);\r
- }\r
- }\r
- \r
- protected static void reflectSqlLogToContainerSqlLogRegistry(Object sqlLog, Object sqlLogRegistry) {\r
- if (sqlLog == null || sqlLogRegistry == null) {\r
- return;\r
- }\r
- try {\r
- final Class<?> sqlLogRegistryType = sqlLogRegistry.getClass();\r
- final Class<?> sqlLogType = Class.forName(NAME_SqlLog);\r
- final Method method = sqlLogRegistryType.getMethod("add", new Class[]{sqlLogType});\r
- method.invoke(sqlLogRegistry, new Object[]{sqlLog});\r
- } catch (Exception e) {\r
- String msg = "InternalSqlLogRegistry.reflectToContainerSqlLogRegistry() threw the exception:";\r
- msg = msg + " sqlLog=" + sqlLog + " sqlLogRegistry=" + sqlLogRegistry;\r
- msg = msg + " NAME_SqlLog=" + NAME_SqlLog;\r
- throw new IllegalStateException(msg, e);\r
- }\r
- }\r
-\r
- protected static Object findLastContainerSqlLog(Object sqlLogRegistry) {\r
- if (sqlLogRegistry == null) {\r
- return null;\r
- }\r
- try {\r
- final Class<?> sqlLogRegistryType = sqlLogRegistry.getClass();\r
- final Method method = sqlLogRegistryType.getMethod("getLast", (Class[])null);\r
- return method.invoke(sqlLogRegistry, (Object[])null);\r
- } catch (Exception e) {\r
- String msg = "InternalSqlLogRegistry.findLastContainerSqlLog() threw the exception:";\r
- msg = msg + " sqlLogRegistry=" + sqlLogRegistry;\r
- throw new IllegalStateException(msg, e);\r
- }\r
- }\r
- \r
- protected static String extractCompleteSqlFromContainerSqlLog(Object sqlLog) {\r
- if (sqlLog == null) {\r
- return null;\r
- }\r
- try {\r
- final Class<?> sqlLogType = sqlLog.getClass();\r
- final Method method = sqlLogType.getMethod("getCompleteSql", (Class[])null);\r
- return (String)method.invoke(sqlLog, (Object[])null);\r
- } catch (Exception e) {\r
- String msg = "InternalSqlLogRegistry.extractCompleteSqlFromContainerSqlLog() threw the exception:";\r
- msg = msg + " sqlLog=" + sqlLog;\r
- throw new IllegalStateException(msg, e);\r
- }\r
- }\r
- \r
- protected static Class<?> forNameContainerSqlLogRegistryLocator() {\r
- Class<?> clazz = null;\r
- try {\r
- clazz = Class.forName(NAME_SqlLogRegistryLocator);\r
- STATUS_SqlLogExists = true;\r
- } catch (Exception ignored) {\r
- STATUS_SqlLogExists = false;\r
- return null;\r
- }\r
- return clazz;\r
- }\r
- \r
- protected static Class<?> forNameContainerSqlLogRegistry() {\r
- Class<?> clazz = null;\r
- try {\r
- clazz = Class.forName(NAME_SqlLogRegistry);\r
- } catch (Exception ignored) {\r
- return null;\r
- }\r
- return clazz;\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlparser;\r
-\r
-import org.seasar.dao.CommandContext;\r
-import org.seasar.dao.context.CommandContextImpl;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class InternalCommandContextCreator {\r
-\r
- // ===================================================================================\r
- // Attribute\r
- // =========\r
- protected String[] argNames;\r
- protected Class<?>[] argTypes;\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- public InternalCommandContextCreator(String[] argNames, Class<?>[] argTypes) {\r
- this.argNames = (argNames != null ? argNames : new String[0]);\r
- this.argTypes = (argTypes != null ? argTypes : new Class[0]);\r
- }\r
- \r
- // ===================================================================================\r
- // Create\r
- // ======\r
- public CommandContext createCommandContext(Object[] args) {\r
- final CommandContext ctx = new CommandContextImpl();\r
- if (args != null) {\r
- for (int i = 0; i < args.length; ++i) {\r
- Class<?> argType = null;\r
- if (args[i] != null) {\r
- if (i < argTypes.length) {\r
- argType = argTypes[i];\r
- } else if (args[i] != null) {\r
- argType = args[i].getClass();\r
- }\r
- }\r
- if (i < argNames.length) {\r
- ctx.addArg(argNames[i], args[i], argType);\r
- } else {\r
- ctx.addArg("$" + (i + 1), args[i], argType);\r
- }\r
- }\r
- }\r
- return ctx;\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlparser;\r
-\r
-import java.lang.reflect.Array;\r
-import java.lang.reflect.Method;\r
-import java.util.Map;\r
-import java.util.List;\r
-import java.util.ArrayList;\r
-import java.util.Stack;\r
-import java.util.StringTokenizer;\r
-\r
-import org.seasar.dao.CommandContext;\r
-import org.seasar.dao.Node;\r
-import org.seasar.dao.node.AbstractNode;\r
-import org.seasar.dao.node.BeginNode;\r
-import org.seasar.dao.node.ContainerNode;\r
-import org.seasar.dao.node.ElseNode;\r
-import org.seasar.dao.node.PrefixSqlNode;\r
-import org.seasar.dao.node.SqlNode;\r
-import org.seasar.framework.beans.BeanDesc;\r
-import org.seasar.framework.beans.PropertyDesc;\r
-import org.seasar.framework.beans.factory.BeanDescFactory;\r
-import org.seasar.framework.util.OgnlUtil;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.MapParameterBean;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.coption.LikeSearchOption;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.exception.BindVariableCommentNotFoundPropertyException;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.exception.BindVariableParameterNullValueException;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.exception.EmbeddedValueCommentNotFoundPropertyException;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.exception.EmbeddedValueParameterNullValueException;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.exception.EndCommentNotFoundException;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.exception.IfCommentConditionNotFoundException;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.exception.IfCommentNotBooleanResultException;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.exception.IfCommentWrongExpressionException;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.exception.RequiredOptionNotFoundException;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.util.InternalBindVariableUtil;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.util.SimpleStringUtil;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.util.SimpleSystemUtil;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class InternalSqlParser {\r
-\r
- // ===================================================================================\r
- // Attribute\r
- // =========\r
- protected InternalSqlTokenizer tokenizer;\r
- protected Stack<Node> nodeStack = new Stack<Node>();\r
- protected String specifiedSql;// Extension!\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- public InternalSqlParser(String sql) {\r
- sql = sql.trim();\r
- if (sql.endsWith(";")) {\r
- sql = sql.substring(0, sql.length() - 1);\r
- }\r
- specifiedSql = sql;// Extension!\r
- tokenizer = new InternalSqlTokenizer(sql);\r
- }\r
-\r
- // ===================================================================================\r
- // Parse\r
- // =====\r
- public Node parse() {\r
- push(new ContainerNode());\r
- while (InternalSqlTokenizer.EOF != tokenizer.next()) {\r
- parseToken();\r
- }\r
- return pop();\r
- }\r
-\r
- protected void parseToken() {\r
- switch (tokenizer.getTokenType()) {\r
- case InternalSqlTokenizer.SQL:\r
- parseSql();\r
- break;\r
- case InternalSqlTokenizer.COMMENT:\r
- parseComment();\r
- break;\r
- case InternalSqlTokenizer.ELSE:\r
- parseElse();\r
- break;\r
- case InternalSqlTokenizer.BIND_VARIABLE:\r
- parseBindVariable();\r
- break;\r
- }\r
- }\r
-\r
- protected void parseSql() {\r
- String sql = tokenizer.getToken();\r
- if (isElseMode()) {\r
- sql = InternalStringUtil.replace(sql, "--", "");\r
- }\r
- Node node = peek();\r
- if ((node instanceof InternalIfNode || node instanceof ElseNode) && node.getChildSize() == 0) {\r
-\r
- InternalSqlTokenizer st = new InternalSqlTokenizer(sql);\r
- st.skipWhitespace();\r
- String token = st.skipToken();\r
- st.skipWhitespace();\r
- if (sql.startsWith(",")) {\r
- if (sql.startsWith(", ")) {\r
- node.addChild(new PrefixSqlNode(", ", sql.substring(2)));\r
- } else {\r
- node.addChild(new PrefixSqlNode(",", sql.substring(1)));\r
- }\r
- } else if ("AND".equalsIgnoreCase(token) || "OR".equalsIgnoreCase(token)) {\r
- node.addChild(new PrefixSqlNode(st.getBefore(), st.getAfter()));\r
- } else {\r
- node.addChild(new SqlNode(sql));\r
- }\r
- } else {\r
- node.addChild(new SqlNode(sql));\r
- }\r
- }\r
-\r
- protected void parseComment() {\r
- final String comment = tokenizer.getToken();\r
- if (isTargetComment(comment)) {\r
- if (isIfComment(comment)) {\r
- parseIf();\r
- } else if (isBeginComment(comment)) {\r
- parseBegin();\r
- } else if (isEndComment(comment)) {\r
- return;\r
- } else {\r
- parseCommentBindVariable();\r
- }\r
- } else if (comment != null && 0 < comment.length()) {\r
- // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\r
- // [UnderReview]: Should I resolve bind character on scope comment(normal comment)?\r
- // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\r
- String before = tokenizer.getBefore();\r
- peek().addChild(new SqlNode(before.substring(before.lastIndexOf("/*"))));\r
- }\r
- }\r
-\r
- protected void parseIf() {\r
- final String condition = tokenizer.getToken().substring(2).trim();\r
- if (InternalStringUtil.isEmpty(condition)) {\r
- throwIfCommentConditionNotFoundException();\r
- }\r
- final ContainerNode ifNode = createIfNode(condition);\r
- peek().addChild(ifNode);\r
- push(ifNode);\r
- parseEnd();\r
- }\r
- \r
- protected void throwIfCommentConditionNotFoundException() {\r
- String msg = "Look! Read the message below." + getLineSeparator();\r
- msg = msg + "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *" + getLineSeparator();\r
- msg = msg + "The condition of IF comment was Not Found!" + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Advice]" + getLineSeparator();\r
- msg = msg + "Please confirm the IF comment expression." + getLineSeparator();\r
- msg = msg + "It may exist the IF comment that DOESN'T have a condition." + getLineSeparator();\r
- msg = msg + " For example:" + getLineSeparator();\r
- msg = msg + " before (x) -- /*IF*/XXX_ID = /*pmb.xxxId*/3/*END*/" + getLineSeparator();\r
- msg = msg + " after (o) -- /*IF pmb.xxxId != null*/XXX_ID = /*pmb.xxxId*/3/*END*/" + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[IF Comment Expression]" + getLineSeparator() + tokenizer.getToken() + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Specified SQL]" + getLineSeparator() + specifiedSql + getLineSeparator();\r
- msg = msg + "* * * * * * * * * */";\r
- throw new IfCommentConditionNotFoundException(msg);\r
- }\r
-\r
- protected void parseBegin() {\r
- BeginNode beginNode = new BeginNode();\r
- peek().addChild(beginNode);\r
- push(beginNode);\r
- parseEnd();\r
- }\r
-\r
- protected void parseEnd() {\r
- while (InternalSqlTokenizer.EOF != tokenizer.next()) {\r
- if (tokenizer.getTokenType() == InternalSqlTokenizer.COMMENT && isEndComment(tokenizer.getToken())) {\r
- pop();\r
- return;\r
- }\r
- parseToken();\r
- }\r
- throwEndCommentNotFoundException();\r
- }\r
-\r
- protected void throwEndCommentNotFoundException() {\r
- String msg = "Look! Read the message below." + getLineSeparator();\r
- msg = msg + "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *" + getLineSeparator();\r
- msg = msg + "The end comment was Not Found!" + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Advice]" + getLineSeparator();\r
- msg = msg + "Please confirm the parameter comment logic." + getLineSeparator();\r
- msg = msg + "It may exist the parameter comment that DOESN'T have an end comment." + getLineSeparator();\r
- msg = msg + " For example:" + getLineSeparator();\r
- msg = msg + " before (x) -- /*IF pmb.xxxId != null*/XXX_ID = /*pmb.xxxId*/3" + getLineSeparator();\r
- msg = msg + " after (o) -- /*IF pmb.xxxId != null*/XXX_ID = /*pmb.xxxId*/3/*END*/" + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Specified SQL]" + getLineSeparator() + specifiedSql + getLineSeparator();\r
- msg = msg + "* * * * * * * * * */";\r
- throw new EndCommentNotFoundException(msg);\r
- }\r
- \r
- protected void parseElse() {\r
- final Node parent = peek();\r
- if (!(parent instanceof InternalIfNode)) {\r
- return;\r
- }\r
- final InternalIfNode ifNode = (InternalIfNode) pop();\r
- final InternalElseNode elseNode = new InternalElseNode();\r
- ifNode.setElseNode(elseNode);\r
- push(elseNode);\r
- tokenizer.skipWhitespace();\r
- }\r
-\r
- protected void parseCommentBindVariable() {\r
- final String expr = tokenizer.getToken();\r
- final String s = tokenizer.skipToken();\r
- if (expr.startsWith("$")) {\r
- peek().addChild(createEmbeddedValueNode(expr.substring(1), s));// Extension!\r
- } else {\r
- peek().addChild(createBindVariableNode(expr, s));// Extension!\r
- }\r
- }\r
-\r
- protected void parseBindVariable() {\r
- final String expr = tokenizer.getToken();\r
- peek().addChild(createBindVariableNode(expr, null));// Extension!\r
- }\r
-\r
- protected Node pop() {\r
- return (Node) nodeStack.pop();\r
- }\r
-\r
- protected Node peek() {\r
- return (Node) nodeStack.peek();\r
- }\r
-\r
- protected void push(Node node) {\r
- nodeStack.push(node);\r
- }\r
-\r
- protected boolean isElseMode() {\r
- for (int i = 0; i < nodeStack.size(); ++i) {\r
- if (nodeStack.get(i) instanceof InternalElseNode) {\r
- return true;\r
- }\r
- }\r
- return false;\r
- }\r
-\r
- private static boolean isTargetComment(String comment) {\r
- return comment != null && comment.length() > 0 && Character.isJavaIdentifierStart(comment.charAt(0));\r
- }\r
-\r
- private static boolean isIfComment(String comment) {\r
- return comment.startsWith("IF");\r
- }\r
-\r
- private static boolean isBeginComment(String content) {\r
- return content != null && "BEGIN".equals(content);\r
- }\r
-\r
- private static boolean isEndComment(String content) {\r
- return content != null && "END".equals(content);\r
- }\r
-\r
- protected AbstractNode createBindVariableNode(String expr, String testValue) {// Extension!\r
- return new InternalBindVariableNode(expr, testValue, specifiedSql);\r
- }\r
-\r
- protected AbstractNode createEmbeddedValueNode(String expr, String testValue) {// Extension!\r
- return new InternalEmbeddedValueNode(expr, testValue, specifiedSql);\r
- }\r
-\r
- protected ContainerNode createIfNode(String expr) {// Extension!\r
- return new InternalIfNode(expr, specifiedSql);\r
- }\r
-\r
- // ===================================================================================\r
- // General Helper\r
- // ==============\r
- protected String getLineSeparator() {\r
- return SimpleSystemUtil.getLineSeparator();\r
- }\r
- \r
- protected final String replaceString(String text, String fromText, String toText) {\r
- return SimpleStringUtil.replace(text, fromText, toText);\r
- }\r
- \r
- // ===================================================================================\r
- // Extension\r
- // =========\r
- // -----------------------------------------------------\r
- // BindVariableNode\r
- // ----------------\r
- protected static class InternalBindVariableNode extends AbstractNode {\r
- protected String _expression;\r
- protected String _testValue;\r
- protected String[] _names;\r
- protected String _specifiedSql;\r
-\r
- public InternalBindVariableNode(String expression, String testValue, String specifiedSql) {\r
- this._expression = expression;\r
- this._testValue = testValue;\r
- this._names = InternalStringUtil.split(expression, ".");\r
- this._specifiedSql = specifiedSql;\r
- }\r
-\r
- public void accept(CommandContext ctx) {\r
- final Object value = ctx.getArg(_names[0]);\r
- final Class<?> clazz = ctx.getArgType(_names[0]);\r
- final InternalValueAndType valueAndType = new InternalValueAndType();\r
- valueAndType.setTargetValue(value);\r
- valueAndType.setTargetType(clazz);\r
- setupValueAndType(valueAndType);\r
- \r
- if (valueAndType.getTargetValue() == null) {\r
- throwBindOrEmbeddedParameterNullValueException(valueAndType);\r
- }\r
- if (!isInScope()) {\r
- // Main Root\r
- ctx.addSql("?", valueAndType.getTargetValue(), valueAndType.getTargetType());\r
- } else {\r
- if (List.class.isAssignableFrom(valueAndType.getTargetType())) {\r
- bindArray(ctx, ((List<?>)valueAndType.getTargetValue()).toArray());\r
- } else if (valueAndType.getTargetType().isArray()) {\r
- bindArray(ctx, valueAndType.getTargetValue());\r
- } else {\r
- ctx.addSql("?", valueAndType.getTargetValue(), valueAndType.getTargetType());\r
- }\r
- }\r
- if (valueAndType.isValidRearOption()) {\r
- ctx.addSql(valueAndType.buildRearOptionOnSql());\r
- }\r
- }\r
-\r
- protected void setupValueAndType(InternalValueAndType valueAndType) {\r
- final InternalValueAndTypeSetuper valueAndTypeSetuper = new InternalValueAndTypeSetuper(_expression, _names, _specifiedSql, true);\r
- valueAndTypeSetuper.setupValueAndType(valueAndType);\r
- }\r
- \r
- protected void throwBindOrEmbeddedParameterNullValueException(InternalValueAndType valueAndType) {\r
- ParameterCommentExceptionProvider.throwBindOrEmbeddedParameterNullValueException(_expression, valueAndType.getTargetType(), _specifiedSql, true);\r
- }\r
- \r
- protected boolean isInScope() {\r
- return _testValue != null && _testValue.startsWith("(") && _testValue.endsWith(")");\r
- }\r
- \r
- protected void bindArray(CommandContext ctx, Object array) {\r
- if (array == null) {\r
- return;\r
- }\r
- final int length = Array.getLength(array);\r
- if (length == 0) {\r
- throwBindOrEmbeddedParameterEmptyListException();\r
- }\r
- Class<?> clazz = null;\r
- for (int i = 0; i < length; ++i) {\r
- final Object currentElement = Array.get(array, i);\r
- if (currentElement != null) {\r
- clazz = currentElement.getClass();\r
- break;\r
- }\r
- }\r
- if (clazz == null) {\r
- throwBindOrEmbeddedParameterNullOnlyListException();\r
- }\r
- boolean existsValidElements = false;\r
- ctx.addSql("(");\r
- for (int i = 0; i < length; ++i) {\r
- final Object currentElement = Array.get(array, i);\r
- if (currentElement != null) {\r
- if (!existsValidElements) {\r
- ctx.addSql("?", currentElement, clazz);\r
- existsValidElements = true;\r
- } else {\r
- ctx.addSql(", ?", currentElement, clazz);\r
- }\r
- }\r
- }\r
- ctx.addSql(")");\r
- }\r
-\r
- protected void throwBindOrEmbeddedParameterEmptyListException() {\r
- ParameterCommentExceptionProvider.throwBindOrEmbeddedParameterEmptyListException(_expression, _specifiedSql, false);\r
- }\r
- \r
- protected void throwBindOrEmbeddedParameterNullOnlyListException() {\r
- ParameterCommentExceptionProvider.throwBindOrEmbeddedParameterNullOnlyListException(_expression, _specifiedSql, true);\r
- }\r
- }\r
-\r
- // -----------------------------------------------------\r
- // EmbeddedValueNode\r
- // -----------------\r
- protected static class InternalEmbeddedValueNode extends AbstractNode {\r
- protected String _expression;\r
- protected String _testValue;\r
- protected String[] _names;\r
- protected String _specifiedSql;\r
-\r
- public InternalEmbeddedValueNode(String expression, String testValue, String specifiedSql) {\r
- this._expression = expression;\r
- this._testValue = testValue;\r
- this._names = InternalStringUtil.split(expression, ".");\r
- this._specifiedSql = specifiedSql;\r
- }\r
-\r
- public void accept(CommandContext ctx) {\r
- final Object value = ctx.getArg(_names[0]);\r
- final Class<?> clazz = ctx.getArgType(_names[0]);\r
- final InternalValueAndType valueAndType = new InternalValueAndType();\r
- valueAndType.setTargetValue(value);\r
- valueAndType.setTargetType(clazz);\r
- setupValueAndType(valueAndType);\r
- \r
- if (valueAndType.getTargetValue() == null) {\r
- throwBindOrEmbeddedParameterNullValueException(valueAndType);\r
- }\r
- if (!isInScope()) {\r
- // Main Root\r
- // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\r
- // [UnderReview]: Should I make an original exception instead of this exception?\r
- // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\r
- if (valueAndType.getTargetValue() != null && valueAndType.getTargetValue().toString().indexOf("?") > -1) {\r
- throw new org.seasar.framework.exception.SRuntimeException("EDAO0023");\r
- }\r
- ctx.addSql(valueAndType.getTargetValue().toString());\r
- } else {\r
- if (List.class.isAssignableFrom(valueAndType.getTargetType())) {\r
- embedArray(ctx, ((List<?>)valueAndType.getTargetValue()).toArray());\r
- } else if (valueAndType.getTargetType().isArray()) {\r
- embedArray(ctx, valueAndType.getTargetValue());\r
- } else {\r
- // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\r
- // [UnderReview]: Should I make an original exception instead of this exception?\r
- // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\r
- if (valueAndType.getTargetValue() != null && valueAndType.getTargetValue().toString().indexOf("?") > -1) {\r
- throw new org.seasar.framework.exception.SRuntimeException("EDAO0023");\r
- }\r
- ctx.addSql(valueAndType.getTargetValue().toString());\r
- }\r
- }\r
- if (valueAndType.isValidRearOption()) {\r
- ctx.addSql(valueAndType.buildRearOptionOnSql());\r
- }\r
- }\r
-\r
- protected void setupValueAndType(InternalValueAndType valueAndType) {\r
- final InternalValueAndTypeSetuper valueAndTypeSetuper = new InternalValueAndTypeSetuper(_expression, _names, _specifiedSql, false);\r
- valueAndTypeSetuper.setupValueAndType(valueAndType);\r
- }\r
- \r
- protected void throwBindOrEmbeddedParameterNullValueException(InternalValueAndType valueAndType) {\r
- ParameterCommentExceptionProvider.throwBindOrEmbeddedParameterNullValueException(_expression, valueAndType.getTargetType(), _specifiedSql, false);\r
- }\r
- \r
- protected boolean isInScope() {\r
- return _testValue != null && _testValue.startsWith("(") && _testValue.endsWith(")");\r
- }\r
- \r
- protected void embedArray(CommandContext ctx, Object array) {\r
- if (array == null) {\r
- return;\r
- }\r
- final int length = Array.getLength(array);\r
- if (length == 0) {\r
- throwBindOrEmbeddedParameterEmptyListException();\r
- }\r
- String quote = null;\r
- for (int i = 0; i < length; ++i) {\r
- final Object currentElement = Array.get(array, i);\r
- if (currentElement != null) {\r
- quote = !(currentElement instanceof Number) ? "'" : "";\r
- break;\r
- }\r
- }\r
- if (quote == null) {\r
- throwBindOrEmbeddedParameterNullOnlyListException();\r
- }\r
- boolean existsValidElements = false;\r
- ctx.addSql("(");\r
- for (int i = 0; i < length; ++i) {\r
- final Object currentElement = Array.get(array, i);\r
- if (currentElement != null) {\r
- if (!existsValidElements) {\r
- ctx.addSql(quote + currentElement + quote);\r
- existsValidElements = true;\r
- } else {\r
- ctx.addSql(", " + quote + currentElement + quote);\r
- }\r
- }\r
- }\r
- ctx.addSql(")");\r
- }\r
- \r
- protected void throwBindOrEmbeddedParameterEmptyListException() {\r
- ParameterCommentExceptionProvider.throwBindOrEmbeddedParameterEmptyListException(_expression, _specifiedSql, false);\r
- }\r
- \r
- protected void throwBindOrEmbeddedParameterNullOnlyListException() {\r
- ParameterCommentExceptionProvider.throwBindOrEmbeddedParameterNullOnlyListException(_expression, _specifiedSql, false);\r
- }\r
- }\r
-\r
- // -----------------------------------------------------\r
- // Value and Type\r
- // --------------\r
- protected static class InternalValueAndType {\r
- public Object _targetValue;\r
- public Class<?> _targetType;\r
- protected String _rearOption;\r
-\r
- public boolean isValidRearOption() {\r
- return _targetValue != null && _rearOption != null && _rearOption.trim().length() > 0;\r
- }\r
-\r
- public String buildRearOptionOnSql() {\r
- return " " + _rearOption.trim() + " ";\r
- }\r
-\r
- public Object getTargetValue() {\r
- return _targetValue;\r
- }\r
- public void setTargetValue(Object targetValue) {\r
- this._targetValue = targetValue;\r
- }\r
- public Class<?> getTargetType() {\r
- return _targetType;\r
- }\r
- public void setTargetType(Class<?> targetType) {\r
- this._targetType = targetType;\r
- }\r
- public String getRearOption() {\r
- return _rearOption;\r
- }\r
- public void setRearOption(String rearOption) {\r
- this._rearOption = rearOption;\r
- }\r
- }\r
-\r
- protected static class InternalValueAndTypeSetuper {\r
- protected String _expression;\r
- protected String[] _names;\r
- protected String _specifiedSql;\r
- protected boolean _bind;\r
-\r
- public InternalValueAndTypeSetuper(String expression, String[] names, String specifiedSql, boolean bind) {\r
- this._expression = expression;\r
- this._names = names;\r
- this._specifiedSql = specifiedSql;\r
- this._bind = bind;\r
- }\r
-\r
- protected void setupValueAndType(InternalValueAndType valueAndType) {\r
- Object value = valueAndType.getTargetValue();\r
- Class<?> clazz = valueAndType.getTargetType();\r
-\r
- // LikeSearchOption handling here is for OutsideSql.\r
- LikeSearchOption likeSearchOption = null;\r
- String rearOption = null;\r
-\r
- for (int pos = 1; pos < _names.length; ++pos) {\r
- if (value == null) {\r
- break;\r
- }\r
- final String currentName = _names[pos];\r
- if (pos == 1) {// at the First Loop\r
- final BeanDesc beanDesc = BeanDescFactory.getBeanDesc(clazz);\r
- if (hasLikeSearchOption(beanDesc, currentName)) {\r
- likeSearchOption = getLikeSearchOption(beanDesc, currentName, value);\r
- }\r
- }\r
- if (Map.class.isInstance(value)) {\r
- final Map<?, ?> map = (Map<?, ?>) value;\r
- value = map.get(_names[pos]);\r
- if (isLastLoop4LikeSearch(pos, likeSearchOption) && isValidStringValue(value)) {// at the Last Loop\r
- value = likeSearchOption.generateRealValue((String) value);\r
- rearOption = likeSearchOption.getRearOption();\r
- }\r
- clazz = (value != null ? value.getClass() : clazz);\r
- continue;\r
- }\r
- final BeanDesc beanDesc = BeanDescFactory.getBeanDesc(clazz);\r
- if (beanDesc.hasPropertyDesc(currentName)) {\r
- final PropertyDesc pd = beanDesc.getPropertyDesc(currentName);\r
- value = getPropertyValue(clazz, value, currentName, pd);\r
- if (isLastLoop4LikeSearch(pos, likeSearchOption) && isValidStringValue(value)) {// at the Last Loop\r
- value = likeSearchOption.generateRealValue((String) value);\r
- rearOption = likeSearchOption.getRearOption();\r
- }\r
- clazz = (value != null ? value.getClass() : pd.getPropertyType());\r
- continue;\r
- }\r
- final String methodName = "get" + initCap(currentName);\r
- if (beanDesc.hasMethod(methodName)) {// Is this unused???\r
- final Method method = beanDesc.getMethod(methodName);\r
- value = invokeGetter(method, value);\r
- clazz = method.getReturnType();\r
- continue;\r
- }\r
- if (pos == 1 && MapParameterBean.class.isAssignableFrom(clazz)) {\r
- final MapParameterBean pmb = (MapParameterBean)value;\r
- final Map<String, Object> map = pmb.getParameterMap();\r
- final Object elementValue = (map != null ? map.get(_names[pos]) : null);\r
- if (elementValue != null) {\r
- value = elementValue;\r
- clazz = value.getClass();\r
- continue;\r
- }\r
- }\r
- throwBindOrEmbeddedCommentNotFoundPropertyException(_expression, clazz, currentName, _specifiedSql, _bind);\r
- }\r
- valueAndType.setTargetValue(value);\r
- valueAndType.setTargetType(clazz);\r
- valueAndType.setRearOption(rearOption);\r
- }\r
-\r
- // for OutsideSql\r
- protected boolean isLastLoop4LikeSearch(int pos, LikeSearchOption likeSearchOption) {\r
- return _names.length == (pos + 1) && likeSearchOption != null;\r
- }\r
-\r
- protected boolean isValidStringValue(Object value) {\r
- return value != null && value instanceof String && ((String) value).length() > 0;\r
- }\r
-\r
- // for OutsideSql\r
- protected boolean hasLikeSearchOption(BeanDesc beanDesc, String currentName) {\r
- return beanDesc.hasPropertyDesc(currentName + "InternalLikeSearchOption");\r
- }\r
-\r
- // for OutsideSql\r
- protected LikeSearchOption getLikeSearchOption(BeanDesc beanDesc, String currentName, Object resourceBean) {\r
- final PropertyDesc pb = beanDesc.getPropertyDesc(currentName + "InternalLikeSearchOption");\r
- final LikeSearchOption option = (LikeSearchOption) pb.getValue(resourceBean);\r
- if (option == null) {\r
- throwLikeSearchOptionNotFoundException(resourceBean, currentName);\r
- }\r
- if (option.isSplit()) {\r
- throwOutsideSqlLikeSearchOptionSplitUnsupportedException(option, resourceBean, currentName);\r
- }\r
- return option;\r
- }\r
-\r
- // for OutsideSql\r
- protected void throwLikeSearchOptionNotFoundException(Object resourceBean, String currentName) {\r
- String msg = "Look! Read the message below." + getLineSeparator();\r
- msg = msg + "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *" + getLineSeparator();\r
- msg = msg + "The likeSearchOption was Not Found! (Should not be null!)" + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Advice]" + getLineSeparator();\r
- msg = msg + "Please confirm your method call:" + getLineSeparator();\r
- final String beanName = resourceBean.getClass().getSimpleName();\r
- final String methodName = "set" + initCap(currentName) + "_LikeSearch(value, likeSearchOption);";\r
- msg = msg + " " + beanName + "." + methodName + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Target ParameterBean]" + getLineSeparator() + resourceBean + getLineSeparator();\r
- msg = msg + "* * * * * * * * * */";\r
- throw new RequiredOptionNotFoundException(msg);\r
- }\r
- \r
- // for OutsideSql\r
- protected void throwOutsideSqlLikeSearchOptionSplitUnsupportedException(LikeSearchOption option, Object resourceBean, String currentName) {\r
- String msg = "Look! Read the message below." + getLineSeparator();\r
- msg = msg + "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *" + getLineSeparator();\r
- msg = msg + "The splitByXxx() of LikeSearchOption is unsupported at OutsideSql!" + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Advice]" + getLineSeparator();\r
- msg = msg + "Please confirm your method call:" + getLineSeparator();\r
- msg = msg + " For example:" + getLineSeparator();\r
- msg = msg + " before (x):" + getLineSeparator();\r
- final String beanName = resourceBean.getClass().getSimpleName();\r
- final String methodName = "set" + initCap(currentName) + "_LikeSearch(value, likeSearchOption);";\r
- msg = msg + " " + beanName + " pmb = new " + beanName + "();" + getLineSeparator();\r
- msg = msg + " LikeSearchOption likeSearchOption = new LikeSearchOption().likeContain();" + getLineSeparator();\r
- msg = msg + " likeSearchOption.splitBySpace(); // *No! Don't invoke this!" + getLineSeparator();\r
- msg = msg + " pmb." + methodName + getLineSeparator();\r
- msg = msg + " after (o):" + getLineSeparator();\r
- msg = msg + " " + beanName + " pmb = new " + beanName + "();" + getLineSeparator();\r
- msg = msg + " LikeSearchOption likeSearchOption = new LikeSearchOption().likeContain();" + getLineSeparator();\r
- msg = msg + " pmb." + methodName + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Target LikeSearchOption]" + getLineSeparator() + option + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Target ParameterBean]" + getLineSeparator() + resourceBean + getLineSeparator();\r
- msg = msg + "* * * * * * * * * */";\r
- throw new UnsupportedOperationException(msg);\r
- }\r
-\r
- protected Object getPropertyValue(Class<?> beanType, Object beanValue, String currentName, PropertyDesc pd) {\r
- try {\r
- return pd.getValue(beanValue);\r
- } catch (RuntimeException e) {\r
- throwPropertyHandlingFailureException(beanType, beanValue, currentName, _expression, _specifiedSql, _bind, e);\r
- return null;// Unreachable!\r
- }\r
- }\r
- \r
- protected void throwPropertyHandlingFailureException(Class<?> beanType, Object beanValue, String currentName,\r
- String expression, String specifiedSql, boolean bind, Exception e) {\r
- String msg = "Look! Read the message below." + getLineSeparator();\r
- msg = msg + "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *" + getLineSeparator();\r
- msg = msg + "The handlig of the property was failed!" + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Advice]" + getLineSeparator();\r
- msg = msg + "This is the Framework Exception!" + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[" + (bind ? "Bind Variable" : "Embedded Value") + " Comment Expression]" + getLineSeparator()\r
- + expression + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Bean Type]" + getLineSeparator() + beanType + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Bean Value]" + getLineSeparator() + beanValue + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Property Name]" + getLineSeparator() + currentName + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Specified SQL]" + getLineSeparator() + specifiedSql + getLineSeparator();\r
- msg = msg + "* * * * * * * * * */";\r
- throw new IllegalStateException(msg, e);\r
- }\r
-\r
- protected String initCap(String name) {\r
- return SimpleStringUtil.initCap(name);\r
- }\r
-\r
- protected Object invokeGetter(Method method, Object target) {\r
- try {\r
- return method.invoke(target, (Object[]) null);\r
- } catch (IllegalArgumentException e) {\r
- throw new RuntimeException(e);\r
- } catch (IllegalAccessException e) {\r
- throw new RuntimeException(e);\r
- } catch (java.lang.reflect.InvocationTargetException e) {\r
- throw new RuntimeException(e);\r
- }\r
- }\r
-\r
- protected void throwBindOrEmbeddedCommentNotFoundPropertyException(String expression, Class<?> targetType, String notFoundProperty, String specifiedSql, boolean bind) {\r
- String msg = "Look! Read the message below." + getLineSeparator();\r
- msg = msg + "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *" + getLineSeparator();\r
- msg = msg + "The property on the " + (bind ? "bind variable" : "embedded value") + " comment was Not Found!" + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Advice]" + getLineSeparator();\r
- msg = msg + "Please confirm the existence of your property on your arguments." + getLineSeparator();\r
- msg = msg + "Abd has the property had misspelling?" + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[" + (bind ? "Bind Variable" : "Embedded Value") + " Comment Expression]" + getLineSeparator() + expression + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[NotFound Property]" + getLineSeparator() + (targetType != null ? targetType.getName() + "#" : "") + notFoundProperty + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Specified SQL]" + getLineSeparator() + specifiedSql + getLineSeparator();\r
- msg = msg + "* * * * * * * * * */";\r
- if (bind) {\r
- throw new BindVariableCommentNotFoundPropertyException(msg);\r
- } else {\r
- throw new EmbeddedValueCommentNotFoundPropertyException(msg);\r
- }\r
- }\r
-\r
- protected String getLineSeparator() {\r
- return SimpleSystemUtil.getLineSeparator();\r
- }\r
- }\r
- \r
- // -----------------------------------------------------\r
- // Exception Provider\r
- // ------------------\r
- protected static class ParameterCommentExceptionProvider {\r
- public static void throwBindOrEmbeddedParameterNullValueException(String expression, Class<?> targetType, String specifiedSql, boolean bind) {\r
- String msg = "Look! Read the message below." + getLineSeparator();\r
- msg = msg + "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *" + getLineSeparator();\r
- msg = msg + "The value of " + (bind ? "bind variable" : "embedded value") + " was Null!" + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Advice]" + getLineSeparator();\r
- msg = msg + "Is it within the scope of your assumption?" + getLineSeparator();\r
- msg = msg + "If the answer is YES, please confirm your application logic about the parameter." + getLineSeparator();\r
- msg = msg + "If the answer is NO, please confirm the logic of parameter comment(especially IF comment)." + getLineSeparator();\r
- msg = msg + " --> For example:" + getLineSeparator();\r
- msg = msg + " before (x) -- XXX_ID = /*pmb.xxxId*/3" + getLineSeparator();\r
- msg = msg + " after (o) -- /*IF pmb.xxxId != null*/XXX_ID = /*pmb.xxxId*/3/*END*/" + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[" + (bind ? "Bind Variable" : "Embedded Value") + " Comment Expression]" + getLineSeparator() + expression + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Parameter Property Type]" + getLineSeparator() + targetType + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Specified SQL]" + getLineSeparator() + specifiedSql + getLineSeparator();\r
- msg = msg + "* * * * * * * * * */";\r
- if (bind) {\r
- throw new BindVariableParameterNullValueException(msg);\r
- } else {\r
- throw new EmbeddedValueParameterNullValueException(msg);\r
- }\r
- }\r
- \r
- public static void throwBindOrEmbeddedParameterEmptyListException(String expression, String specifiedSql, boolean bind) {\r
- String msg = "Look! Read the message below." + getLineSeparator();\r
- msg = msg + "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *" + getLineSeparator();\r
- msg = msg + "The list of " + (bind ? "bind variable" : "embedded value") + " was empty!" + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Advice]" + getLineSeparator();\r
- msg = msg + "Please confirm your application logic." + getLineSeparator();\r
- msg = msg + " For example:" + getLineSeparator();\r
- msg = msg + " before (x):" + getLineSeparator();\r
- msg = msg + " List<Integer> xxxIdList = new ArrayList<Integer>();" + getLineSeparator();\r
- msg = msg + " cb.query().setXxxId_InScope(xxxIdList);// Or pmb.setXxxIdList(xxxIdList);" + getLineSeparator();\r
- msg = msg + " after (o):" + getLineSeparator();\r
- msg = msg + " List<Integer> xxxIdList = new ArrayList<Integer>();" + getLineSeparator();\r
- msg = msg + " xxxIdList.add(3);" + getLineSeparator();\r
- msg = msg + " xxxIdList.add(7);" + getLineSeparator();\r
- msg = msg + " cb.query().setXxxId_InScope(xxxIdList);// Or pmb.setXxxIdList(xxxIdList);" + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[" + (bind ? "Bind Variable" : "Embedded Value") + " Comment Expression]" + getLineSeparator() + expression + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Specified SQL]" + getLineSeparator() + specifiedSql + getLineSeparator();\r
- msg = msg + "* * * * * * * * * */";\r
- throw new IllegalArgumentException(msg);\r
- }\r
- \r
- public static void throwBindOrEmbeddedParameterNullOnlyListException(String expression, String specifiedSql, boolean bind) {\r
- String msg = "Look! Read the message below." + getLineSeparator();\r
- msg = msg + "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *" + getLineSeparator();\r
- msg = msg + "The list of " + (bind ? "bind variable" : "embedded value") + " was 'Null Only List'!" + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Advice]" + getLineSeparator();\r
- msg = msg + "Please confirm your application logic." + getLineSeparator();\r
- msg = msg + " For example:" + getLineSeparator();\r
- msg = msg + " before (x):" + getLineSeparator();\r
- msg = msg + " List<Integer> xxxIdList = new ArrayList<Integer>();" + getLineSeparator();\r
- msg = msg + " xxxIdList.add(null);" + getLineSeparator();\r
- msg = msg + " xxxIdList.add(null);" + getLineSeparator();\r
- msg = msg + " cb.query().setXxxId_InScope(xxxIdList);// Or pmb.setXxxIdList(xxxIdList);" + getLineSeparator();\r
- msg = msg + " after (o):" + getLineSeparator();\r
- msg = msg + " List<Integer> xxxIdList = new ArrayList<Integer>();" + getLineSeparator();\r
- msg = msg + " xxxIdList.add(3);" + getLineSeparator();\r
- msg = msg + " xxxIdList.add(7);" + getLineSeparator();\r
- msg = msg + " cb.query().setXxxId_InScope(xxxIdList);// Or pmb.setXxxIdList(xxxIdList);" + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[" + (bind ? "Bind Variable" : "Embedded Value") + " Comment Expression]" + getLineSeparator() + expression + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Specified SQL]" + getLineSeparator() + specifiedSql + getLineSeparator();\r
- msg = msg + "* * * * * * * * * */";\r
- throw new IllegalArgumentException(msg);\r
- }\r
- \r
- protected static String getLineSeparator() {\r
- return SimpleSystemUtil.getLineSeparator();\r
- }\r
- }\r
- \r
- // -----------------------------------------------------\r
- // IfNode\r
- // ------\r
- protected static class InternalIfNode extends ContainerNode {\r
- private String _expression;\r
- private Object _parsedExpression;\r
- private InternalElseNode _elseNode;\r
- private String _specifiedSql;\r
-\r
- public InternalIfNode(String expression, String specifiedSql) {\r
- this._expression = expression;\r
- this._parsedExpression = OgnlUtil.parseExpression(expression);\r
- this._specifiedSql = specifiedSql;\r
- }\r
-\r
- public String getExpression() {\r
- return _expression;\r
- }\r
-\r
- public InternalElseNode getElseNode() {\r
- return _elseNode;\r
- }\r
-\r
- public void setElseNode(InternalElseNode elseNode) {\r
- this._elseNode = elseNode;\r
- }\r
-\r
- public void accept(CommandContext ctx) {\r
- Object result = null;\r
- try {\r
- result = OgnlUtil.getValue(_parsedExpression, ctx);\r
- } catch (RuntimeException e) {\r
- if (!_expression.contains("pmb.")) {\r
- throwIfCommentWrongExpressionException(_expression, e, _specifiedSql);\r
- }\r
- final String replaced = InternalStringUtil.replace(_expression, "pmb.", "pmb.parameterMap.");\r
- final Object secondParsedExpression = OgnlUtil.parseExpression(replaced);\r
- try {\r
- result = OgnlUtil.getValue(secondParsedExpression, ctx);\r
- } catch (RuntimeException ignored) {\r
- throwIfCommentWrongExpressionException(_expression, e, _specifiedSql);\r
- }\r
- if (result == null) {\r
- throwIfCommentWrongExpressionException(_expression, e, _specifiedSql);\r
- }\r
- _parsedExpression = secondParsedExpression;\r
- }\r
- if (result != null && result instanceof Boolean) {\r
- if (((Boolean) result).booleanValue()) {\r
- super.accept(ctx);\r
- ctx.setEnabled(true);\r
- } else if (_elseNode != null) {\r
- _elseNode.accept(ctx);\r
- ctx.setEnabled(true);\r
- }\r
- } else {\r
- throwIfCommentNotBooleanResultException(_expression, result, _specifiedSql);\r
- }\r
- }\r
-\r
- protected void throwIfCommentWrongExpressionException(String expression, RuntimeException cause, String specifiedSql) {\r
- String msg = "Look! Read the message below." + getLineSeparator();\r
- msg = msg + "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *" + getLineSeparator();\r
- msg = msg + "The IF comment of your specified SQL was Wrong!" + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Advice]" + getLineSeparator();\r
- msg = msg + "Please confirm the existence of your property on your arguments." + getLineSeparator();\r
- msg = msg + "And confirm the IF comment of your specified SQL." + getLineSeparator();\r
- msg = msg + " For example, correct IF comment is as below:" + getLineSeparator();\r
- msg = msg + " /*IF pmb.xxxId != null*/XXX_ID = .../*END*/" + getLineSeparator();\r
- msg = msg + " /*IF pmb.isPaging()*/.../*END*/" + getLineSeparator();\r
- msg = msg + " /*IF pmb.xxxId == null && pmb.xxxName != null*/.../*END*/" + getLineSeparator();\r
- msg = msg + " /*IF pmb.xxxId == null || pmb.xxxName != null*/.../*END*/" + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[IF Comment Expression]" + getLineSeparator() + expression + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Cause Message]" + getLineSeparator();\r
- msg = msg + cause.getClass() + ":" + getLineSeparator();\r
- msg = msg + " --> " + cause.getMessage() + getLineSeparator();\r
- final Throwable nestedCause = cause.getCause();\r
- if (nestedCause != null) {\r
- msg = msg + nestedCause.getClass() + ":" + getLineSeparator();\r
- msg = msg + " --> " + nestedCause.getMessage() + getLineSeparator();\r
- }\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Specified SQL]" + getLineSeparator() + specifiedSql + getLineSeparator();\r
- msg = msg + "* * * * * * * * * */";\r
- throw new IfCommentWrongExpressionException(msg, cause);\r
- }\r
-\r
- protected void throwIfCommentNotBooleanResultException(String expression, Object result, String specifiedSql) {\r
- String msg = "Look! Read the message below." + getLineSeparator();\r
- msg = msg + "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *" + getLineSeparator();\r
- msg = msg + "The boolean expression on IF comment of your specified SQL was Wrong!" + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Advice]" + getLineSeparator();\r
- msg = msg + "Please confirm the grammar of your IF comment. Does it really express boolean?" + getLineSeparator();\r
- msg = msg + "And confirm the existence of your property on your arguments if you use parameterMap." + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[IF Comment Expression]" + getLineSeparator() + expression + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[IF Comment Result Value]" + getLineSeparator() + result + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Specified SQL]" + getLineSeparator() + specifiedSql + getLineSeparator();\r
- msg = msg + "* * * * * * * * * */";\r
- throw new IfCommentNotBooleanResultException(msg);\r
- }\r
-\r
- protected String getLineSeparator() {\r
- return SimpleSystemUtil.getLineSeparator();\r
- }\r
- }\r
-\r
- // -----------------------------------------------------\r
- // ElseNode\r
- // --------\r
- protected static class InternalElseNode extends ContainerNode {\r
- public void accept(CommandContext ctx) {\r
- super.accept(ctx);\r
- ctx.setEnabled(true);\r
- }\r
- }\r
-\r
- // -----------------------------------------------------\r
- // StringUtil\r
- // ----------\r
- protected static class InternalStringUtil {\r
-\r
- public static final String[] EMPTY_STRINGS = new String[0];\r
- private InternalStringUtil() {\r
- }\r
-\r
- public static final boolean isEmpty(String text) {\r
- return text == null || text.length() == 0;\r
- }\r
-\r
- public static final String replace(String text, String fromText, String toText) {\r
- return SimpleStringUtil.replace(text, fromText, toText);\r
- }\r
-\r
- public static String[] split(String str, String delim) {\r
- if (str == null) {\r
- return EMPTY_STRINGS;\r
- }\r
- List<String> list = new ArrayList<String>();\r
- StringTokenizer st = new StringTokenizer(str, delim);\r
- while (st.hasMoreElements()) {\r
- list.add(st.nextToken());\r
- }\r
- return (String[]) list.toArray(new String[list.size()]);\r
- }\r
- }\r
- \r
- // ===================================================================================\r
- // Convert\r
- // =======\r
- public static String convertTwoWaySql2DisplaySql(String twoWaySql, Object arg) {\r
- final String[] argNames = new String[]{"dto"};\r
- final Class<?>[] argTypes = new Class<?>[]{arg.getClass()};\r
- final Object[] args = new Object[]{arg};\r
- return convertTwoWaySql2DisplaySql(twoWaySql, argNames, argTypes, args);\r
- }\r
- \r
- public static String convertTwoWaySql2DisplaySql(String twoWaySql, String[] argNames, Class<?>[] argTypes, Object[] args) {\r
- final CommandContext context;\r
- {\r
- final InternalSqlParser parser = new InternalSqlParser(twoWaySql);\r
- final Node node = parser.parse();\r
- final InternalCommandContextCreator creator = new InternalCommandContextCreator(argNames, argTypes);\r
- context = creator.createCommandContext(args);\r
- node.accept(context);\r
- }\r
- final String preparedSql = context.getSql();\r
- return InternalBindVariableUtil.getCompleteSql(preparedSql, context.getBindVariables());\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.sqlparser;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.exception.EndCommentNotFoundException;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.util.SimpleSystemUtil;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class InternalSqlTokenizer {\r
-\r
- // ===================================================================================\r
- // Definition\r
- // ==========\r
- public static final int SQL = 1;\r
- public static final int COMMENT = 2;\r
- public static final int ELSE = 3;\r
- public static final int BIND_VARIABLE = 4;\r
- public static final int EOF = 99;\r
- \r
- // ===================================================================================\r
- // Attribute\r
- // =========\r
- protected String sql;\r
- protected int position = 0;\r
- protected String token;\r
- protected int tokenType = SQL;\r
- protected int nextTokenType = SQL;\r
- protected int bindVariableNum = 0;\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- public InternalSqlTokenizer(String sql) {\r
- this.sql = sql;\r
- }\r
-\r
- // ===================================================================================\r
- // Tokenize\r
- // ========\r
- public int next() {\r
- if (position >= sql.length()) {\r
- token = null;\r
- tokenType = EOF;\r
- nextTokenType = EOF;\r
- return tokenType;\r
- }\r
- switch (nextTokenType) {\r
- case SQL:\r
- parseSql();\r
- break;\r
- case COMMENT:\r
- parseComment();\r
- break;\r
- case ELSE:\r
- parseElse();\r
- break;\r
- case BIND_VARIABLE:\r
- parseBindVariable();\r
- break;\r
- default:\r
- parseEof();\r
- break;\r
- }\r
- return tokenType;\r
- }\r
-\r
- protected void parseSql() {\r
- int commentStartPos = sql.indexOf("/*", position);\r
- int commentStartPos2 = sql.indexOf("#*", position);\r
- if (0 < commentStartPos2 && commentStartPos2 < commentStartPos) {\r
- commentStartPos = commentStartPos2;\r
- }\r
- int lineCommentStartPos = sql.indexOf("--", position);\r
- int bindVariableStartPos = sql.indexOf("?", position);\r
- int elseCommentStartPos = -1;\r
- int elseCommentLength = -1;\r
- if (lineCommentStartPos >= 0) {\r
- int skipPos = skipWhitespace(lineCommentStartPos + 2);\r
- if (skipPos + 4 < sql.length()\r
- && "ELSE".equals(sql.substring(skipPos, skipPos + 4))) {\r
- elseCommentStartPos = lineCommentStartPos;\r
- elseCommentLength = skipPos + 4 - lineCommentStartPos;\r
- }\r
- }\r
- int nextStartPos = getNextStartPos(commentStartPos, elseCommentStartPos, bindVariableStartPos);\r
- if (nextStartPos < 0) {\r
- token = sql.substring(position);\r
- nextTokenType = EOF;\r
- position = sql.length();\r
- tokenType = SQL;\r
- } else {\r
- token = sql.substring(position, nextStartPos);\r
- tokenType = SQL;\r
- boolean needNext = nextStartPos == position;\r
- if (nextStartPos == commentStartPos) {\r
- nextTokenType = COMMENT;\r
- position = commentStartPos + 2;\r
- } else if (nextStartPos == elseCommentStartPos) {\r
- nextTokenType = ELSE;\r
- position = elseCommentStartPos + elseCommentLength;\r
- } else if (nextStartPos == bindVariableStartPos) {\r
- nextTokenType = BIND_VARIABLE;\r
- position = bindVariableStartPos;\r
- }\r
- if (needNext) {\r
- next();\r
- }\r
- }\r
- }\r
-\r
- protected int getNextStartPos(int commentStartPos, int elseCommentStartPos, int bindVariableStartPos) {\r
- int nextStartPos = -1;\r
- if (commentStartPos >= 0) {\r
- nextStartPos = commentStartPos;\r
- }\r
- if (elseCommentStartPos >= 0\r
- && (nextStartPos < 0 || elseCommentStartPos < nextStartPos)) {\r
- nextStartPos = elseCommentStartPos;\r
- }\r
- if (bindVariableStartPos >= 0\r
- && (nextStartPos < 0 || bindVariableStartPos < nextStartPos)) {\r
- nextStartPos = bindVariableStartPos;\r
- }\r
- return nextStartPos;\r
- }\r
-\r
- protected String nextBindVariableName() {\r
- return "$" + ++bindVariableNum;\r
- }\r
-\r
- protected void parseComment() {\r
- int commentEndPos = sql.indexOf("*/", position);\r
- int commentEndPos2 = sql.indexOf("*#", position);\r
- if (0 < commentEndPos2 && commentEndPos2 < commentEndPos) {\r
- commentEndPos = commentEndPos2;\r
- }\r
- if (commentEndPos < 0) {\r
- throwEndCommentNotFoundException(sql.substring(position));\r
- }\r
- token = sql.substring(position, commentEndPos);\r
- nextTokenType = SQL;\r
- position = commentEndPos + 2;\r
- tokenType = COMMENT;\r
- }\r
-\r
- protected void throwEndCommentNotFoundException(String expression) {\r
- String msg = "Look! Read the message below." + getLineSeparator();\r
- msg = msg + "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *" + getLineSeparator();\r
- msg = msg + "The end comment was Not Found!" + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Advice]" + getLineSeparator();\r
- msg = msg + "Please confirm the parameter comment logic." + getLineSeparator();\r
- msg = msg + "It may exist the parameter comment that DOESN'T have an end comment." + getLineSeparator();\r
- msg = msg + " For example:" + getLineSeparator();\r
- msg = msg + " before (x) -- /*IF pmb.xxxId != null*/XXX_ID = /*pmb.xxxId*/3" + getLineSeparator();\r
- msg = msg + " after (o) -- /*IF pmb.xxxId != null*/XXX_ID = /*pmb.xxxId*/3/*END*/" + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[End Comment Expected Place]" + getLineSeparator() + expression + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Specified SQL]" + getLineSeparator() + sql + getLineSeparator();\r
- msg = msg + "* * * * * * * * * */" + getLineSeparator();\r
- throw new EndCommentNotFoundException(msg);\r
- }\r
-\r
- protected void parseBindVariable() {\r
- token = nextBindVariableName();\r
- nextTokenType = SQL;\r
- position += 1;\r
- tokenType = BIND_VARIABLE;\r
- }\r
-\r
- protected void parseElse() {\r
- token = null;\r
- nextTokenType = SQL;\r
- tokenType = ELSE;\r
- }\r
-\r
- protected void parseEof() {\r
- token = null;\r
- tokenType = EOF;\r
- nextTokenType = EOF;\r
- }\r
-\r
- public String skipToken() {\r
- int index = sql.length();\r
- char quote = position < sql.length() ? sql.charAt(position) : '\0';\r
- boolean quoting = quote == '\'' || quote == '(';\r
- if (quote == '(') {\r
- quote = ')';\r
- }\r
- for (int i = quoting ? position + 1 : position; i < sql.length(); ++i) {\r
- char c = sql.charAt(i);\r
- if ((Character.isWhitespace(c) || c == ',' || c == ')' || c == '(')\r
- && !quoting) {\r
- index = i;\r
- break;\r
- } else if (c == '/' && i + 1 < sql.length()\r
- && sql.charAt(i + 1) == '*') {\r
- index = i;\r
- break;\r
- } else if (c == '-' && i + 1 < sql.length()\r
- && sql.charAt(i + 1) == '-') {\r
- index = i;\r
- break;\r
- } else if (quoting && quote == '\'' && c == '\''\r
- && (i + 1 >= sql.length() || sql.charAt(i + 1) != '\'')) {\r
- index = i + 1;\r
- break;\r
- } else if (quoting && c == quote) {\r
- index = i + 1;\r
- break;\r
- }\r
- }\r
- token = sql.substring(position, index);\r
- tokenType = SQL;\r
- nextTokenType = SQL;\r
- position = index;\r
- return token;\r
- }\r
-\r
- public String skipWhitespace() {\r
- int index = skipWhitespace(position);\r
- token = sql.substring(position, index);\r
- position = index;\r
- return token;\r
- }\r
-\r
- protected int skipWhitespace(int position) {\r
- int index = sql.length();\r
- for (int i = position; i < sql.length(); ++i) {\r
- char c = sql.charAt(i);\r
- if (!Character.isWhitespace(c)) {\r
- index = i;\r
- break;\r
- }\r
- }\r
- return index;\r
- }\r
-\r
- // ===================================================================================\r
- // General Helper\r
- // ==============\r
- protected String getLineSeparator() {\r
- return SimpleSystemUtil.getLineSeparator();\r
- }\r
-\r
- // ===================================================================================\r
- // Accessor\r
- // ========\r
- public int getPosition() {\r
- return position;\r
- }\r
-\r
- public String getToken() {\r
- return token;\r
- }\r
-\r
- public String getBefore() {\r
- return sql.substring(0, position);\r
- }\r
-\r
- public String getAfter() {\r
- return sql.substring(position);\r
- }\r
-\r
- public int getTokenType() {\r
- return tokenType;\r
- }\r
-\r
- public int getNextTokenType() {\r
- return nextTokenType;\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.util;\r
-\r
-import java.lang.reflect.Method;\r
-import java.lang.reflect.InvocationTargetException;\r
-import java.sql.Date;\r
-import java.sql.Time;\r
-import java.sql.Timestamp;\r
-import java.text.SimpleDateFormat;\r
-import java.util.Calendar;\r
-\r
-import org.seasar.extension.jdbc.ValueType;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.DBFluteConfig;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class InternalBindVariableUtil {\r
-\r
- // ===================================================================================\r
- // Definition\r
- // ==========\r
- private static final String NULL = "null";\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- private InternalBindVariableUtil() {\r
- }\r
-\r
- public static String getCompleteSql(String sql, Object[] args) {\r
- if (args == null || args.length == 0) {\r
- return sql;\r
- }\r
- return getCompleteSql(sql, args, new ValueType[args.length]);\r
- }\r
-\r
- public static String getCompleteSql(String sql, Object[] args,\r
- ValueType[] valueTypes) {\r
- if (args == null || args.length == 0) {\r
- return sql;\r
- }\r
- StringBuffer buf = new StringBuffer(sql.length() + args.length * 15);\r
- int pos = 0;\r
- int pos2 = 0;\r
- int pos3 = 0;\r
- int pos4 = 0;\r
- int pos5 = 0;\r
- int pos6 = 0;\r
- int index = 0;\r
- while (true) {\r
- pos = sql.indexOf('?', pos2);\r
- pos3 = sql.indexOf('\'', pos2);\r
- pos4 = sql.indexOf('\'', pos3 + 1);\r
- pos5 = sql.indexOf("/*", pos2);\r
- pos6 = sql.indexOf("*/", pos5 + 1);\r
- if (pos > 0) {\r
- if (pos3 >= 0 && pos3 < pos && pos < pos4) {\r
- buf.append(sql.substring(pos2, pos4 + 1));\r
- pos2 = pos4 + 1;\r
- } else if (pos5 >= 0 && pos5 < pos && pos < pos6) {\r
- buf.append(sql.substring(pos2, pos6 + 1));\r
- pos2 = pos6 + 1;\r
- } else {\r
- if (args.length <= index) {\r
- String msg = "The size of bind arguments is illegal:";\r
- msg = msg + " size=" + args.length + " sql=" + sql;\r
- throw new IllegalStateException(msg);\r
- }\r
- buf.append(sql.substring(pos2, pos));\r
- buf.append(getBindVariableText(args[index],\r
- valueTypes[index]));\r
- pos2 = pos + 1;\r
- index++;\r
- }\r
- } else {\r
- buf.append(sql.substring(pos2));\r
- break;\r
- }\r
- }\r
- return buf.toString();\r
- }\r
-\r
- public static String getBindVariableText(Object bindVariable) {\r
- if (bindVariable instanceof String) {\r
- return quote(bindVariable.toString());\r
- } else if (bindVariable instanceof Number) {\r
- return bindVariable.toString();\r
- } else if (bindVariable instanceof Time) {\r
- SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");\r
- return quote(sdf.format((java.util.Date) bindVariable));\r
- } else if (bindVariable instanceof Timestamp) {\r
- SimpleDateFormat sdf = new SimpleDateFormat(getLogTimestampFormat());\r
- return quote(sdf.format((java.util.Date) bindVariable));\r
- } else if (bindVariable instanceof java.util.Date) {\r
- SimpleDateFormat sdf = new SimpleDateFormat(getLogDateFormat());\r
- return quote(sdf.format((java.util.Date) bindVariable));\r
- } else if (bindVariable instanceof Boolean) {\r
- return bindVariable.toString();\r
- } else if (bindVariable == null) {\r
- return NULL;\r
- } else {\r
- return quote(bindVariable.toString());\r
- }\r
- }\r
-\r
- protected static String getLogDateFormat() {\r
- String logDateFormat = DBFluteConfig.getInstance().getLogDateFormat();\r
- return logDateFormat != null ? logDateFormat : "yyyy-MM-dd";\r
- }\r
-\r
- protected static String getLogTimestampFormat() {\r
- String logTimestampFormat = DBFluteConfig.getInstance().getLogTimestampFormat();\r
- return logTimestampFormat != null ? logTimestampFormat : "yyyy-MM-dd HH:mm:ss";\r
- }\r
- \r
- // For various seasar's version.\r
- protected static final Class<?>[] TOTEXT_ARGUMENT_TYPES = new Class<?>[]{Object.class};\r
- protected static final Method TOTEXT_METHOD;\r
- static {\r
- Method method = null;\r
- try {\r
- method = ValueType.class.getMethod("toText", TOTEXT_ARGUMENT_TYPES);\r
- } catch (SecurityException e) {\r
- } catch (NoSuchMethodException e) {\r
- }\r
- TOTEXT_METHOD = method;\r
- }\r
- public static String getBindVariableText(Object bindVariable, ValueType valueType) {\r
- if (valueType != null && TOTEXT_METHOD != null ) {\r
- try {\r
- return (String)TOTEXT_METHOD.invoke(valueType, new Object[]{bindVariable});\r
- } catch (IllegalArgumentException e) {\r
- String msg = "ValueType.toText() threw the IllegalArgumentException:";\r
- msg = msg + " valueType=" + valueType + " bindVariable=" + bindVariable;\r
- throw new IllegalStateException(msg, e);\r
- } catch (IllegalAccessException e) {\r
- String msg = "ValueType.toText() threw the IllegalAccessException:";\r
- msg = msg + " valueType=" + valueType + " bindVariable=" + bindVariable;\r
- throw new IllegalStateException(msg, e);\r
- } catch (InvocationTargetException e) {\r
- if (e.getTargetException() instanceof RuntimeException) {\r
- throw (RuntimeException)e.getTargetException();\r
- } else {\r
- String msg = "ValueType.toText() threw the exception:";\r
- msg = msg + " valueType=" + valueType + " bindVariable=" + bindVariable;\r
- throw new IllegalStateException(msg, e.getTargetException());\r
- }\r
- }\r
- }\r
- return getBindVariableText(bindVariable);\r
- }\r
- \r
- public static String nullText() {\r
- return NULL;\r
- }\r
-\r
- public static String toText(Number value) {\r
- if (value == null) {\r
- return NULL;\r
- }\r
- return value.toString();\r
- }\r
-\r
- public static String toText(Boolean value) {\r
- if (value == null) {\r
- return NULL;\r
- }\r
- return quote(value.toString());\r
- }\r
-\r
- public static String toText(String value) {\r
- if (value == null) {\r
- return NULL;\r
- }\r
- return quote(value);\r
- }\r
-\r
- public static String toText(Date value) {\r
- if (value == null) {\r
- return NULL;\r
- }\r
- Calendar calendar = Calendar.getInstance();\r
- calendar.setTime(value);\r
- StringBuilder buf = new StringBuilder();\r
- addDate(buf, calendar);\r
- return quote(buf.toString());\r
- }\r
-\r
- public static String toText(Time value) {\r
- if (value == null) {\r
- return NULL;\r
- }\r
- Calendar calendar = Calendar.getInstance();\r
- calendar.setTime(value);\r
- StringBuilder buf = new StringBuilder();\r
- addTime(buf, calendar);\r
- addTimeDecimalPart(buf, calendar.get(Calendar.MILLISECOND));\r
- return quote(buf.toString());\r
- }\r
-\r
- public static String toText(Timestamp value) {\r
- if (value == null) {\r
- return NULL;\r
- }\r
- Calendar calendar = Calendar.getInstance();\r
- calendar.setTime(value);\r
- StringBuilder buf = new StringBuilder(30);\r
- addDate(buf, calendar);\r
- addTime(buf, calendar);\r
- addTimeDecimalPart(buf, value.getNanos());\r
- return quote(buf.toString());\r
- }\r
-\r
- public static String toText(byte[] value) {\r
- if (value == null) {\r
- return NULL;\r
- }\r
- return quote(value.toString() + "(byteLength=" + Integer.toString(value.length) + ")");\r
- }\r
-\r
- /**\r
- * {@link Object}の文字列表現を返します。\r
- * \r
- * @param value\r
- * 値\r
- * @return 文字列表現\r
- */\r
- public static String toText(Object value) {\r
- if (value == null) {\r
- return NULL;\r
- }\r
- return quote(value.toString());\r
- }\r
-\r
- // yyyy-mm-dd\r
- protected static void addDate(StringBuilder buf, Calendar calendar) {\r
- int year = calendar.get(Calendar.YEAR);\r
- buf.append(year);\r
- buf.append('-');\r
- int month = calendar.get(Calendar.MONTH) + 1;\r
- if (month < 10) {\r
- buf.append('0');\r
- }\r
- buf.append(month);\r
- buf.append('-');\r
- int date = calendar.get(Calendar.DATE);\r
- if (date < 10) {\r
- buf.append('0');\r
- }\r
- buf.append(date);\r
- }\r
-\r
- // hh:mm:ss\r
- protected static void addTime(StringBuilder buf, Calendar calendar) {\r
- if (buf.length() > 0) {\r
- buf.append(' ');\r
- }\r
- int hour = calendar.get(Calendar.HOUR_OF_DAY);\r
- if (hour < 10) {\r
- buf.append('0');\r
- }\r
- buf.append(hour);\r
- buf.append(':');\r
- int minute = calendar.get(Calendar.MINUTE);\r
- if (minute < 10) {\r
- buf.append('0');\r
- }\r
- buf.append(minute);\r
- buf.append(':');\r
- int second = calendar.get(Calendar.SECOND);\r
- if (second < 10) {\r
- buf.append('0');\r
- }\r
- buf.append(second);\r
- }\r
-\r
- // .000\r
- protected static void addTimeDecimalPart(StringBuilder buf, int decimalPart) {\r
- if (decimalPart == 0) {\r
- return;\r
- }\r
- if (buf.length() > 0) {\r
- buf.append('.');\r
- }\r
- buf.append(decimalPart);\r
- }\r
-\r
- // 'text'\r
- protected static String quote(String text) {\r
- return "'" + text + "'";\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.various;\r
-\r
-import java.util.Collection;\r
-import java.util.Comparator;\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-import java.util.TreeMap;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class InternalProcedureMetaData {\r
-\r
- // ===================================================================================\r
- // Attribute\r
- // =========\r
- private String procedureName;\r
- private Map<String, InternalProcedureParameterType> unorderedMap = createUnorderedMap();\r
- private Map<String, InternalProcedureParameterType> parameterTypes = createParameterTypes();\r
- private boolean returnType;\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- public InternalProcedureMetaData(final String procedureName) {\r
- this.procedureName = procedureName;\r
- }\r
-\r
- // ===================================================================================\r
- // Factory\r
- // =======\r
- protected Map<String, InternalProcedureParameterType> createUnorderedMap() {\r
- return new HashMap<String, InternalProcedureParameterType>();\r
- }\r
-\r
- protected Map<String, InternalProcedureParameterType> createParameterTypes() {\r
- return new TreeMap<String, InternalProcedureParameterType>(new ParameterComparator());\r
- }\r
-\r
- protected class ParameterComparator implements Comparator<String> {\r
- public int compare(String o1, String o2) {\r
- final int oneGreaterThanTwo = 1;\r
- final int twoGreaterThanOne = -1;\r
- final InternalProcedureParameterType parameterType1 = unorderedMap.get(o1);\r
- final InternalProcedureParameterType parameterType2 = unorderedMap.get(o2);\r
- if (parameterType1.isReturnType()) {\r
- return twoGreaterThanOne; // Return type is prior\r
- }\r
- if (parameterType2.isReturnType()) {\r
- return oneGreaterThanTwo; // Return type is prior\r
- }\r
- final Integer parameterIndex1 = parameterType1.getParameterIndex();\r
- final Integer parameterIndex2 = parameterType2.getParameterIndex();\r
- if (parameterIndex1 == null && parameterIndex2 == null) {\r
- return oneGreaterThanTwo; // No changes\r
- }\r
- if (parameterIndex1 != null && parameterIndex2 == null) {\r
- return twoGreaterThanOne; // Not null is prior\r
- }\r
- if (parameterIndex1 == null && parameterIndex2 != null) {\r
- return oneGreaterThanTwo; // Not null is prior\r
- }\r
- return parameterIndex1.compareTo(parameterIndex2);\r
- }\r
- }\r
-\r
- // ===================================================================================\r
- // Accessor\r
- // ========\r
- public String getProcedureName() {\r
- return procedureName;\r
- }\r
-\r
- public Collection<InternalProcedureParameterType> parameterTypes() {\r
- return parameterTypes.values();\r
- }\r
-\r
- public void addParameterType(final InternalProcedureParameterType parameterType) {\r
- final String name = parameterType.getParameterName();\r
- unorderedMap.put(name, parameterType);\r
- parameterTypes.put(name, parameterType);\r
- if (parameterType.isReturnType()) {\r
- returnType = true;\r
- }\r
- }\r
-\r
- public boolean hasReturnParameterType() {\r
- return returnType;\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.various;\r
-\r
-import java.lang.reflect.Field;\r
-import java.lang.reflect.Modifier;\r
-import java.util.Collection;\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.Stack;\r
-\r
-import org.seasar.framework.beans.BeanDesc;\r
-import org.seasar.framework.beans.factory.BeanDescFactory;\r
-import org.seasar.extension.jdbc.ValueType;\r
-import org.seasar.extension.jdbc.types.ValueTypes;\r
-import org.seasar.dao.ValueTypeFactory;\r
-import org.seasar.dao.util.TypeUtil;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.ConditionBeanContext;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class InternalProcedureMetaDataFactory {\r
-\r
- // ===================================================================================\r
- // Attribute\r
- // =========\r
- protected ValueTypeFactory valueTypeFactory;\r
- protected InternalFieldProcedureAnnotationReader annotationReader = new InternalFieldProcedureAnnotationReader();\r
- \r
- // ===================================================================================\r
- // Main\r
- // ====\r
- public InternalProcedureMetaData createProcedureMetaData(final String procedureName, final Class<?> pmbType) {\r
- final InternalProcedureMetaData metaData = new InternalProcedureMetaData(procedureName);\r
- if (pmbType == null) {\r
- return metaData;\r
- } else {\r
- if (!isDtoType(pmbType)) {\r
- throw new IllegalStateException("The pmb type was Not DTO type: " + pmbType.getName());\r
- }\r
- }\r
- final BeanDesc pmbDesc = BeanDescFactory.getBeanDesc(pmbType);\r
-\r
- // *Point\r
- final Stack<Class<?>> stack = new Stack<Class<?>>();\r
- for (Class<?> clazz = pmbType; clazz != null && clazz != Object.class; clazz = clazz.getSuperclass()) {\r
- stack.push(clazz);\r
- }\r
- for ( ; !stack.isEmpty() ;) {\r
- final Class<?> clazz = stack.pop();\r
- registerParameterType(metaData, pmbDesc, clazz.getDeclaredFields());\r
- }\r
-\r
- return metaData;\r
- }\r
- protected void registerParameterType(InternalProcedureMetaData metaData, BeanDesc pmbDesc, Field[] fields) {\r
- for (Field field : fields) {\r
- if (!isInstanceField(field)) {\r
- continue;\r
- }\r
- final InternalProcedureParameterType ppt = getProcedureParameterType(pmbDesc, field);\r
- if (ppt == null) {\r
- continue;\r
- }\r
- metaData.addParameterType(ppt);\r
- }\r
- }\r
- protected InternalProcedureParameterType getProcedureParameterType(final BeanDesc dtoDesc, final Field field) {\r
- final String procedureParameter = annotationReader.getProcedureParameter(dtoDesc, field);\r
- if (procedureParameter == null) {\r
- return null;\r
- }\r
- final String type = extractParameterType(procedureParameter);\r
- field.setAccessible(true);\r
- final InternalProcedureParameterType ppt = new InternalProcedureParameterType(field);\r
- if (type.equalsIgnoreCase("in")) {\r
- ppt.setInType(true);\r
- } else if (type.equalsIgnoreCase("out")) {\r
- ppt.setOutType(true);\r
- } else if (type.equalsIgnoreCase("inout")) {\r
- ppt.setInType(true);\r
- ppt.setOutType(true);\r
- } else if (type.equalsIgnoreCase("return")) {\r
- ppt.setOutType(true);\r
- ppt.setReturnType(true);\r
- } else {\r
- String msg = "The parameter type should be 'in' or 'out' or 'inout' or 'return':";\r
- msg = msg + " class=" + field.getDeclaringClass().getSimpleName();\r
- msg = msg + " field=" + field.getName();\r
- msg = msg + " parameterType=" + type;\r
- throw new IllegalStateException(msg);\r
- }\r
- final Integer index = extractParameterIndex(procedureParameter, field);\r
- ppt.setParameterIndex(index);\r
- final ValueType valueType = getValueType(dtoDesc, field);\r
- ppt.setValueType(valueType);\r
- return ppt;\r
- }\r
- protected String extractParameterType(String procedureParameter) {\r
- if (procedureParameter.contains(",")) {\r
- return procedureParameter.substring(0, procedureParameter.indexOf(",")).trim();\r
- }\r
- return procedureParameter.trim();\r
- }\r
- protected Integer extractParameterIndex(String procedureParameter, Field field) {\r
- if (procedureParameter.contains(",")) {\r
- String tmp = procedureParameter.substring(procedureParameter.indexOf(",") + ",".length()).trim();\r
- try {\r
- return Integer.valueOf(tmp);\r
- } catch (NumberFormatException e) {\r
- String msg = "The parameter index should be number:";\r
- msg = msg + " class=" + field.getDeclaringClass().getSimpleName();\r
- msg = msg + " field=" + field.getName();\r
- msg = msg + " parameterIndex=" + tmp + " procedureParameter=" + procedureParameter;\r
- throw new IllegalStateException(msg, e);\r
- }\r
- }\r
- return null;\r
- }\r
- protected ValueType getValueType(final BeanDesc dtoDesc, final Field field) {\r
- final String name = annotationReader.getValueType(dtoDesc, field);\r
- if (name != null) {\r
- return valueTypeFactory.getValueTypeByName(name);\r
- }\r
- final Class<?> type = field.getType();\r
- if (List.class.isAssignableFrom(type)) {// is for out parameter cursor.\r
- if (ConditionBeanContext.isOracle()) {\r
- return ValueTypes.ORACLE_RESULT_SET;\r
- } else if (ConditionBeanContext.isPostgreSql()) {\r
- return ValueTypes.POSTGRE_RESULT_SET;\r
- } else {\r
- return ValueTypes.SERIALIZABLE_BYTE_ARRAY;\r
- }\r
- }\r
- return valueTypeFactory.getValueTypeByClass(type);\r
- }\r
- protected boolean isInstanceField(final Field field) {\r
- final int mod = field.getModifiers();\r
- return !Modifier.isStatic(mod) && !Modifier.isFinal(mod);\r
- }\r
- protected boolean isDtoType(final Class<?> clazz) {\r
- return !TypeUtil.isSimpleType(clazz) && !isContainerType(clazz);\r
- }\r
- protected boolean isContainerType(final Class<?> clazz) {\r
- if (clazz == null) { throw new NullPointerException("clazz"); }\r
- return Collection.class.isAssignableFrom(clazz) || Map.class.isAssignableFrom(clazz) || clazz.isArray();\r
- }\r
- public void setValueTypeFactory(final ValueTypeFactory valueTypeFactory) {\r
- this.valueTypeFactory = valueTypeFactory;\r
- }\r
- \r
- protected static class InternalFieldProcedureAnnotationReader {\r
- protected String PROCEDURE_PARAMETER_SUFFIX;\r
- protected String VALUE_TYPE_SUFFIX;\r
- public InternalFieldProcedureAnnotationReader() {\r
- PROCEDURE_PARAMETER_SUFFIX = "_PROCEDURE_PARAMETER";\r
- VALUE_TYPE_SUFFIX = "_VALUE_TYPE";\r
- }\r
- public String getProcedureParameter(BeanDesc dtoDesc, Field field) {\r
- String fieldName = removeInstanceVariablePrefix(field.getName());// *Point\r
- String annotationName = fieldName + PROCEDURE_PARAMETER_SUFFIX;\r
- if (dtoDesc.hasField(annotationName)) {\r
- Field f = dtoDesc.getField(annotationName);\r
- return (String) getValue(f, null);\r
- } else {\r
- return null;\r
- }\r
- }\r
- public String getValueType(BeanDesc dtoDesc, Field field) {\r
- String fieldName = removeInstanceVariablePrefix(field.getName());// *Point\r
- String annotationName = fieldName + VALUE_TYPE_SUFFIX;\r
- if (dtoDesc.hasField(annotationName)) {\r
- Field f = dtoDesc.getField(annotationName);\r
- return (String) getValue(f, null);\r
- } else {\r
- return null;\r
- }\r
- }\r
- protected String removeInstanceVariablePrefix(String fieldName) {\r
- return fieldName.startsWith("_") ? fieldName.substring("_".length()) : fieldName;\r
- }\r
- protected Object getValue(Field field, Object target) {\r
- try {\r
- return field.get(target);\r
- } catch (IllegalAccessException e) {\r
- String msg = "The getting of the field threw the exception:";\r
- msg = msg + " class=" + field.getDeclaringClass().getSimpleName();\r
- msg = msg + " field=" + field.getName();\r
- throw new IllegalStateException(msg, e);\r
- }\r
- }\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.various;\r
-\r
-import java.lang.reflect.Field;\r
-\r
-import org.seasar.extension.jdbc.ValueType;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class InternalProcedureParameterType {\r
-\r
- // ===================================================================================\r
- // Attribute\r
- // =========\r
- private String parameterName;\r
- private Integer parameterIndex;\r
- private Field field;\r
- private ValueType valueType;\r
- private boolean inType;\r
- private boolean outType;\r
- private boolean returnType;\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- public InternalProcedureParameterType(Field field) {\r
- this.field = field;\r
- this.parameterName = field.getName();\r
- }\r
-\r
- // ===================================================================================\r
- // Field Value\r
- // ===========\r
- public Object getValue(Object target) {\r
- try {\r
- return field.get(target);\r
- } catch (IllegalAccessException e) {\r
- String msg = "The getting of the field threw the exception:";\r
- msg = msg + " class=" + field.getDeclaringClass().getSimpleName();\r
- msg = msg + " field=" + field.getName();\r
- throw new IllegalStateException(msg, e);\r
- }\r
- }\r
-\r
- public void setValue(Object target, Object value) {\r
- try {\r
- field.set(target, value);\r
- } catch (IllegalAccessException e) {\r
- String msg = "The setting of the field threw the exception:";\r
- msg = msg + " class=" + field.getDeclaringClass().getSimpleName();\r
- msg = msg + " field=" + field.getName();\r
- throw new IllegalStateException(msg, e);\r
- }\r
- }\r
-\r
- // ===================================================================================\r
- // Accessor\r
- // ========\r
- public String getParameterName() {\r
- return parameterName;\r
- }\r
- \r
- public Integer getParameterIndex() {\r
- return parameterIndex;\r
- }\r
- \r
- public void setParameterIndex(Integer parameterIndex) {\r
- this.parameterIndex = parameterIndex;\r
- }\r
-\r
- public ValueType getValueType() {\r
- return valueType;\r
- }\r
-\r
- public void setValueType(final ValueType valueType) {\r
- this.valueType = valueType;\r
- }\r
-\r
- public boolean isInType() {\r
- return inType;\r
- }\r
-\r
- public void setInType(final boolean inType) {\r
- this.inType = inType;\r
- }\r
-\r
- public boolean isOutType() {\r
- return outType;\r
- }\r
-\r
- public void setOutType(final boolean outType) {\r
- this.outType = outType;\r
- }\r
-\r
- public boolean isReturnType() {\r
- return returnType;\r
- }\r
-\r
- public void setReturnType(final boolean returnType) {\r
- this.returnType = returnType;\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.various;\r
-\r
-import java.util.Iterator;\r
-import java.util.Map;\r
-import java.util.Set;\r
-import java.util.Stack;\r
-import java.sql.ResultSet;\r
-import java.sql.SQLException;\r
-\r
-import org.seasar.framework.beans.PropertyDesc;\r
-import org.seasar.extension.jdbc.PropertyType;\r
-import org.seasar.extension.jdbc.ValueType;\r
-import org.seasar.dao.BeanMetaData;\r
-import org.seasar.dao.RelationPropertyType;\r
-import org.seasar.dao.impl.RelationRowCreationResource;\r
-import org.seasar.dao.impl.RelationRowCreatorImpl;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.ConditionBean;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.cbean.ConditionBeanContext;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.dbmeta.DBMeta;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class InternalRelationRowCreator extends RelationRowCreatorImpl {\r
-\r
- @Override\r
- protected Object createRelationRow(RelationRowCreationResource res)\r
- throws SQLException {\r
- // - - - - - - - - - - - \r
- // Recursive Call Point!\r
- // - - - - - - - - - - -\r
- if (!res.hasPropertyCacheElement()) {\r
- return null;\r
- }\r
- setupRelationKeyValue(res);\r
- setupRelationAllValue(res);\r
- return res.getRow();\r
- }\r
-\r
- @Override\r
- protected void setupRelationKeyValue(RelationRowCreationResource res) {\r
- final RelationPropertyType rpt = res.getRelationPropertyType();\r
- final BeanMetaData bmd = rpt.getBeanMetaData();\r
- final DBMeta dbmeta = findDBMeta(bmd.getBeanClass(), bmd.getTableName());\r
- for (int i = 0; i < rpt.getKeySize(); ++i) {\r
- final String columnName = rpt.getMyKey(i) + res.getBaseSuffix();\r
-\r
- if (!res.containsColumnName(columnName)) {\r
- continue;\r
- }\r
- if (!res.hasRowInstance()) {\r
- final Object row;\r
- if (dbmeta != null) {\r
- row = dbmeta.newEntity();\r
- } else {\r
- row = newRelationRow(rpt);\r
- }\r
- res.setRow(row);\r
- }\r
- if (!res.containsRelKeyValueIfExists(columnName)) {\r
- continue;\r
- }\r
- final Object value = res.extractRelKeyValue(columnName);\r
- if (value == null) {\r
- continue;\r
- }\r
-\r
- final String yourKey = rpt.getYourKey(i);\r
- final PropertyType pt = bmd.getPropertyTypeByColumnName(yourKey);\r
- final PropertyDesc pd = pt.getPropertyDesc();\r
- pd.setValue(res.getRow(), value);\r
- continue;\r
- }\r
- }\r
-\r
- protected Object createRelationRowInstance(DBMeta dbmeta) {\r
- if (dbmeta != null) {\r
- return dbmeta.newEntity();\r
- }\r
- return null;\r
- }\r
-\r
- protected DBMeta findDBMeta(Class<?> rowType, String tableName) {\r
- return InternalRowCreator.findDBMeta(rowType, tableName);\r
- }\r
-\r
- @SuppressWarnings("unchecked")\r
- @Override\r
- protected void setupRelationAllValue(RelationRowCreationResource res) throws SQLException {\r
- final Map propertyCacheElement = res.extractPropertyCacheElement();\r
- final Set columnNameCacheElementKeySet = propertyCacheElement.keySet();\r
- for (final Iterator ite = columnNameCacheElementKeySet.iterator(); ite.hasNext();) {\r
- final String columnName = (String) ite.next();\r
- final PropertyType pt = (PropertyType) propertyCacheElement.get(columnName);\r
- res.setCurrentPropertyType(pt);\r
- if (!isValidRelationPerPropertyLoop(res)) {\r
- res.clearRowInstance();\r
- return;\r
- }\r
- setupRelationProperty(res);\r
- }\r
- if (!isValidRelationAfterPropertyLoop(res)) {\r
- res.clearRowInstance();\r
- return;\r
- }\r
- res.clearValidValueCount();\r
- if (res.hasNextRelationProperty() && (hasConditionBean(res) || res.hasNextRelationLevel())) {\r
- setupNextRelationRow(res);\r
- }\r
- }\r
- \r
- @Override\r
- protected void registerRelationValue(RelationRowCreationResource res, String columnName) throws SQLException {\r
- final PropertyType pt = res.getCurrentPropertyType();\r
- Object value = null;\r
- if (res.containsRelKeyValueIfExists(columnName)) {\r
- value = res.extractRelKeyValue(columnName);\r
- } else {\r
- final ValueType valueType = pt.getValueType();\r
- value = valueType.getValue(res.getResultSet(), columnName);\r
- }\r
- \r
- if (value != null) {\r
- res.incrementValidValueCount();\r
- final DBMeta dbmeta = findDBMeta(res.getRow());\r
- final String propertyName = pt.getPropertyName();\r
- if (dbmeta != null && dbmeta.hasEntityPropertySetupper(propertyName)) {\r
- dbmeta.setupEntityProperty(propertyName, res.getRow(), value);\r
- } else {\r
- final PropertyDesc pd = pt.getPropertyDesc();\r
- pd.setValue(res.getRow(), value);\r
- }\r
- }\r
- }\r
- \r
- /**\r
- * @param row The instance of row. (NotNull)\r
- * @return The interface of DBMeta. (Nullable: If it's null, it means NotFound.)\r
- */\r
- protected DBMeta findDBMeta(Object row) {\r
- return InternalRowCreator.findDBMeta(row);\r
- }\r
-\r
- @Override\r
- protected void setupPropertyCache(RelationRowCreationResource res) throws SQLException {\r
- // - - - - - - - - - - - \r
- // Recursive Call Point!\r
- // - - - - - - - - - - -\r
- res.initializePropertyCacheElement();\r
-\r
- // Do only selected foreign property for performance if condition-bean exists.\r
- if (hasConditionBean(res) && !hasSelectedForeignInfo(res)) {\r
- return;\r
- }\r
-\r
- // Set up property cache about current beanMetaData.\r
- final BeanMetaData nextBmd = res.getRelationBeanMetaData();\r
- for (int i = 0; i < nextBmd.getPropertyTypeSize(); ++i) {\r
- final PropertyType pt = nextBmd.getPropertyType(i);\r
- res.setCurrentPropertyType(pt);\r
- if (!isTargetProperty(res)) {\r
- continue;\r
- }\r
- setupPropertyCacheElement(res);\r
- }\r
- \r
- // Set up next relation.\r
- if (res.hasNextRelationProperty() && (hasConditionBean(res) || res.hasNextRelationLevel())) {\r
- res.backupRelationPropertyType();\r
- res.incrementCurrentRelationNestLevel();\r
- try {\r
- setupNextPropertyCache(res, nextBmd);\r
- } finally {\r
- res.restoreRelationPropertyType();\r
- res.decrementCurrentRelationNestLevel();\r
- }\r
- }\r
- }\r
-\r
- @Override\r
- protected boolean isTargetProperty(RelationRowCreationResource res) throws SQLException {\r
- final PropertyType pt = res.getCurrentPropertyType();\r
- if (!pt.getPropertyDesc().hasWriteMethod()) {\r
- return false;\r
- }\r
- if (java.util.List.class.isAssignableFrom(pt.getPropertyDesc().getPropertyType())) {\r
- return false;\r
- }\r
- return true;\r
- }\r
-\r
- @Override\r
- protected boolean isCreateDeadLink() {\r
- return false;\r
- }\r
- \r
- @Override\r
- protected int getLimitRelationNestLevel() {\r
- return 2;// for Compatible\r
- }\r
-\r
- @SuppressWarnings("unchecked")\r
- @Override\r
- protected RelationRowCreationResource createResourceForRow(ResultSet rs,\r
- RelationPropertyType rpt, Set columnNames, Map relKeyValues,\r
- Map relationPropertyCache) throws SQLException {\r
- final RelationRowCreationResource res = new RelationRowCreationResourceExtension();\r
- res.setResultSet(rs);\r
- res.setRelationPropertyType(rpt);\r
- res.setColumnNames(columnNames);\r
- res.setRelKeyValues(relKeyValues);\r
- res.setRelationPropertyCache(relationPropertyCache);\r
- res.setBaseSuffix("");// as Default\r
- res.setRelationNoSuffix(buildRelationNoSuffix(rpt));\r
- res.setLimitRelationNestLevel(getLimitRelationNestLevel());\r
- res.setCurrentRelationNestLevel(1);// as Default\r
- res.setCreateDeadLink(isCreateDeadLink());\r
- return res;\r
- }\r
-\r
- @SuppressWarnings("unchecked")\r
- @Override\r
- protected RelationRowCreationResource createResourceForPropertyCache(RelationPropertyType rpt, Set columnNames,\r
- Map relationPropertyCache, String baseSuffix, String relationNoSuffix, int limitRelationNestLevel)\r
- throws SQLException {\r
- final RelationRowCreationResource res = new RelationRowCreationResourceExtension();\r
- res.setRelationPropertyType(rpt);\r
- res.setColumnNames(columnNames);\r
- res.setRelationPropertyCache(relationPropertyCache);\r
- res.setBaseSuffix(baseSuffix);\r
- res.setRelationNoSuffix(relationNoSuffix);\r
- res.setLimitRelationNestLevel(limitRelationNestLevel);\r
- res.setCurrentRelationNestLevel(1);// as Default\r
- return res;\r
- }\r
- \r
- protected boolean isConditionBeanSelectedRelation(RelationRowCreationResource res) {\r
- if (hasConditionBean(res)) {\r
- final ConditionBean cb = ConditionBeanContext.getConditionBeanOnThread();\r
- if (cb.getSqlClause().hasSelectedForeignInfo(res.getRelationNoSuffix())) {\r
- return true;\r
- }\r
- }\r
- return false;\r
- }\r
- \r
- protected boolean hasConditionBean(RelationRowCreationResource res) {\r
- return ConditionBeanContext.isExistConditionBeanOnThread();\r
- }\r
- \r
- protected boolean hasSelectedForeignInfo(RelationRowCreationResource res) {\r
- final ConditionBean cb = ConditionBeanContext.getConditionBeanOnThread();\r
- if (cb.getSqlClause().hasSelectedForeignInfo(res.getRelationNoSuffix())) {\r
- return true;\r
- }\r
- return false;\r
- }\r
- \r
- protected static class RelationRowCreationResourceExtension extends RelationRowCreationResource {\r
- protected Stack<RelationPropertyType> backupRelationPropertyType = new Stack<RelationPropertyType>();\r
- protected Stack<String> backupBaseSuffix = new Stack<String>();\r
- protected Stack<String> backupRelationSuffix = new Stack<String>();\r
- \r
- @Override\r
- public void backupRelationPropertyType() {\r
- backupRelationPropertyType.push(getRelationPropertyType());\r
- }\r
- \r
- @Override\r
- public void restoreRelationPropertyType() {\r
- setRelationPropertyType(backupRelationPropertyType.pop());\r
- }\r
- \r
- @Override\r
- public void backupSuffixAndPrepare(String baseSuffix, String additionalRelationNoSuffix) {\r
- backupBaseSuffixExtension();\r
- backupRelationNoSuffixExtension();\r
- setBaseSuffix(baseSuffix);\r
- addRelationNoSuffix(additionalRelationNoSuffix);\r
- }\r
- \r
- @Override\r
- public void restoreSuffix() {\r
- restoreBaseSuffixExtension();\r
- restoreRelationNoSuffixExtension();\r
- }\r
- \r
- protected void backupBaseSuffixExtension() {\r
- backupBaseSuffix.push(getBaseSuffix());\r
- }\r
-\r
- protected void restoreBaseSuffixExtension() {\r
- setBaseSuffix(backupBaseSuffix.pop());\r
- }\r
- \r
- protected void backupRelationNoSuffixExtension() {\r
- backupRelationSuffix.push(getRelationNoSuffix());\r
- }\r
- \r
- protected void restoreRelationNoSuffixExtension() {\r
- setRelationNoSuffix(backupRelationSuffix.pop());\r
- }\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.s2dao.internal.various;\r
-\r
-import java.util.HashMap;\r
-import java.util.Iterator;\r
-import java.util.Map;\r
-import java.util.Set;\r
-import java.sql.ResultSet;\r
-import java.sql.SQLException;\r
-\r
-import org.seasar.extension.jdbc.PropertyType;\r
-import org.seasar.extension.jdbc.ValueType;\r
-import org.seasar.dao.impl.RowCreatorImpl;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.Entity;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.InternalMapContext;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.dbmeta.DBMeta;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.dbmeta.DBMetaInstanceHandler;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.util.SimpleSystemUtil;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class InternalRowCreator extends RowCreatorImpl {\r
-\r
- // ===================================================================================\r
- // Definition\r
- // ==========\r
- /** Log instance. */\r
- private static final org.apache.commons.logging.Log _log = org.apache.commons.logging.LogFactory.getLog(InternalRowCreator.class);\r
-\r
- /** The key of DBMeta cache. */\r
- protected static final String DBMETA_CACHE_KEY = "df:DBMetaCache";\r
-\r
- // ===================================================================================\r
- // Attribute\r
- // =========\r
- protected DBMeta _dbmeta;\r
- \r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- protected InternalRowCreator() {}\r
-\r
- /**\r
- * @param beanClass The class of target bean to find DB-meta. (Nullable)\r
- * @return The instance of internal row creator. (NotNull)\r
- */\r
- public static InternalRowCreator createInternalRowCreator(Class<?> beanClass) {\r
- final InternalRowCreator rowCreator = new InternalRowCreator();\r
- if (beanClass != null) {\r
- rowCreator.setDBMeta(findDBMetaByClass(beanClass));\r
- }\r
- return rowCreator;\r
- }\r
-\r
- // ===================================================================================\r
- // Main\r
- // ====\r
- @SuppressWarnings("unchecked")\r
- @Override\r
- public Object createRow(ResultSet rs, Map propertyCache, Class beanClass) throws SQLException {\r
- final Set columnNameSet = propertyCache.keySet();\r
- String columnName = null;\r
- PropertyType pt = null;\r
- String propertyName = null;\r
- final Object row;\r
- final DBMeta dbmeta;\r
- if (_dbmeta != null) {\r
- dbmeta = _dbmeta;\r
- row = dbmeta.newEntity();\r
- } else {\r
- row = newBean(beanClass);\r
- dbmeta = findDBMeta(row);\r
- }\r
- try {\r
- if (dbmeta != null) {\r
- for (final Iterator ite = columnNameSet.iterator(); ite.hasNext();) {\r
- columnName = (String) ite.next();\r
- pt = (PropertyType) propertyCache.get(columnName);\r
- propertyName = pt.getPropertyName();\r
- if (dbmeta.hasEntityPropertySetupper(propertyName)) {\r
- final ValueType valueType = pt.getValueType();\r
- final Object value = valueType.getValue(rs, columnName);\r
- dbmeta.setupEntityProperty(propertyName, row, value);\r
- } else {\r
- registerValue(rs, row, pt, columnName);\r
- }\r
- }\r
- } else {\r
- for (final Iterator ite = columnNameSet.iterator(); ite.hasNext();) {\r
- columnName = (String) ite.next();\r
- pt = (PropertyType) propertyCache.get(columnName);\r
- propertyName = pt.getPropertyName();\r
- registerValue(rs, row, pt, columnName);\r
- }\r
- }\r
- return row;\r
- } catch (ClassCastException e) {\r
- if (_log.isWarnEnabled()) {\r
- String msg = ClassCastException.class.getSimpleName() + " occurred while ResultSet Handling:";\r
- _log.warn(msg + " target=" + beanClass.getSimpleName() + "." + propertyName + " dbmeta");\r
- }\r
- throwNonsenseClassCastException(row, dbmeta, e);\r
- return null; // Unreachable!\r
- } catch (SQLException e) {\r
- if (_log.isWarnEnabled()) {\r
- String msg = SQLException.class.getSimpleName() + " occurred while ResultSet Handling:";\r
- _log.warn(msg + " target=" + beanClass.getSimpleName() + "." + propertyName);\r
- }\r
- throw e;\r
- }\r
- }\r
- \r
- protected void throwNonsenseClassCastException(Object entity, DBMeta dbmeta, ClassCastException e) {\r
- String msg = "Look! Read the message below." + getLineSeparator();\r
- msg = msg + "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *" + getLineSeparator();\r
- msg = msg + "Nonsense ClassCastException occured!" + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Advice]" + getLineSeparator();\r
- msg = msg + "This exception may be from ClassLoader Headache about HotDeploy." + getLineSeparator();\r
- msg = msg + "Please add the ignore-package setting to convention.dicon like as follows:" + getLineSeparator();\r
- msg = msg + " For example:" + getLineSeparator();\r
- msg = msg + " <initMethod name=”addIgnorePackageName”>" + getLineSeparator();\r
- msg = msg + " <arg>”com.example.xxx.dbflute”</arg>" + getLineSeparator();\r
- msg = msg + " </initMethod>" + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Exception Message]" + getLineSeparator() + e.getMessage() + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Target Entity]" + getLineSeparator() + entity + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Target Entity Class Loader]" + getLineSeparator() + entity.getClass().getClassLoader() + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Target DBMeta]" + getLineSeparator() + dbmeta + getLineSeparator();\r
- msg = msg + getLineSeparator();\r
- msg = msg + "[Target DBMeta Class Loader]" + getLineSeparator() + dbmeta.getClass().getClassLoader() + getLineSeparator();\r
- msg = msg + "* * * * * * * * * */";\r
- throw new NonsenseClassCastException(msg, e);\r
- }\r
-\r
- public static class NonsenseClassCastException extends RuntimeException {\r
- private static final long serialVersionUID = 1L;\r
- public NonsenseClassCastException(String msg, ClassCastException e) {\r
- super(msg, e);\r
- }\r
- }\r
-\r
- // ===================================================================================\r
- // Assist Helper\r
- // =============\r
- /**\r
- * @param row The instance of row. (NotNull)\r
- * @return The interface of DBMeta. (Nullable: If it's null, it means NotFound.)\r
- */\r
- public static DBMeta findDBMeta(Object row) {\r
- return DBMetaCacheHandler.findDBMeta(row);\r
- }\r
-\r
- /**\r
- * @param rowType The type of row. (NotNull)\r
- * @param tableName The name of table. (NotNull)\r
- * @return The interface of DBMeta. (Nullable: If it's null, it means NotFound.)\r
- */\r
- public static DBMeta findDBMeta(Class<?> rowType, String tableName) {\r
- return DBMetaCacheHandler.findDBMeta(rowType, tableName);\r
- }\r
-\r
- protected static class DBMetaCacheHandler {\r
- \r
- /** The key of DBMeta cache. */\r
- protected static final String DBMETA_CACHE_KEY = "df:DBMetaCache";\r
-\r
- public static DBMeta findDBMeta(Object row) {\r
- if (!(row instanceof Entity)) {\r
- return null;\r
- }\r
- final Entity entity = (Entity) row;\r
- DBMeta dbmeta = findCachedDBMeta(entity.getClass());\r
- if (dbmeta != null) {\r
- return dbmeta;\r
- }\r
- dbmeta = entity.getDBMeta();\r
- cacheDBMeta(entity, dbmeta);\r
- return dbmeta;\r
- }\r
- \r
- public static DBMeta findDBMeta(Class<?> rowType, String tableName) {\r
- DBMeta dbmeta = findCachedDBMeta(rowType);\r
- if (dbmeta != null) {\r
- return dbmeta;\r
- }\r
- try {\r
- dbmeta = DBMetaInstanceHandler.findDBMeta(tableName);\r
- } catch (DBMetaInstanceHandler.DBMetaNotFoundException ignored) {\r
- return null;\r
- }\r
- cacheDBMeta(rowType, dbmeta);\r
- return dbmeta;\r
- }\r
-\r
- protected static DBMeta findCachedDBMeta(Class<?> rowType) {\r
- Map<Class<?>, DBMeta> dbmetaCache = findDBMetaCache();\r
- if (dbmetaCache == null) {\r
- dbmetaCache = new HashMap<Class<?>, DBMeta>();\r
- InternalMapContext.setObject(DBMETA_CACHE_KEY, dbmetaCache);\r
- }\r
- return dbmetaCache.get(rowType);\r
- }\r
- \r
- protected static void cacheDBMeta(Entity entity, DBMeta dbmeta) {\r
- cacheDBMeta(entity.getClass(), dbmeta);\r
- }\r
- \r
- protected static void cacheDBMeta(Class<?> type, DBMeta dbmeta) {\r
- final Map<Class<?>, DBMeta> dbmetaCache = findDBMetaCache();\r
- dbmetaCache.put(type, dbmeta);\r
- }\r
- \r
- @SuppressWarnings("unchecked")\r
- protected static Map<Class<?>, DBMeta> findDBMetaCache() {\r
- return (Map<Class<?>, DBMeta>)InternalMapContext.getObject(DBMETA_CACHE_KEY);\r
- }\r
- }\r
-\r
- protected static DBMeta findDBMetaByClass(Class<?> beanClass) {\r
- final Object instance = newInstance(beanClass);\r
- if (!(instance instanceof Entity)) {\r
- return null;\r
- }\r
- return ((Entity)instance).getDBMeta();\r
- }\r
-\r
- protected static Object newInstance(Class<?> clazz) {\r
- try {\r
- return clazz.newInstance();\r
- } catch (InstantiationException e) {\r
- throw new IllegalStateException(e);\r
- } catch (IllegalAccessException e) {\r
- throw new IllegalStateException(e);\r
- }\r
- }\r
-\r
- // ===================================================================================\r
- // General Helper\r
- // ==============\r
- protected String getLineSeparator() {\r
- return SimpleSystemUtil.getLineSeparator();\r
- }\r
-\r
- // ===================================================================================\r
- // Accessor\r
- // ========\r
- public void setDBMeta(DBMeta dbmeta) {\r
- this._dbmeta = dbmeta;\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.util;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class SimpleAssertUtil {\r
-\r
- // ===================================================================================\r
- // Assert\r
- // ======\r
- // -----------------------------------------------------\r
- // Assert Object\r
- // -------------\r
- /**\r
- * Assert that the object is not null.\r
- * \r
- * @param variableName Variable name. (NotNull)\r
- * @param value Value. (NotNull)\r
- * @exception IllegalArgumentException\r
- */\r
- public static void assertObjectNotNull(String variableName, Object value) {\r
- if (variableName == null) {\r
- String msg = "The value should not be null: variableName=" + variableName + " value=" + value;\r
- throw new IllegalArgumentException(msg);\r
- }\r
- if (value == null) {\r
- String msg = "The value should not be null: variableName=" + variableName;\r
- throw new IllegalArgumentException(msg);\r
- }\r
- }\r
-\r
- // -----------------------------------------------------\r
- // Assert String\r
- // -------------\r
- /**\r
- * Assert that the entity is not null and not trimmed empty.\r
- * \r
- * @param variableName Variable name. (NotNull)\r
- * @param value Value. (NotNull)\r
- */\r
- public static void assertStringNotNullAndNotTrimmedEmpty(String variableName, String value) {\r
- assertObjectNotNull("variableName", variableName);\r
- assertObjectNotNull("value", value);\r
- if (value.trim().length() ==0) {\r
- String msg = "The value should not be empty: variableName=" + variableName + " value=" + value;\r
- throw new IllegalArgumentException(msg);\r
- }\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.util;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class SimpleStringUtil {\r
-\r
- // ===================================================================================\r
- // String\r
- // ======\r
- public static String replace(String text, String fromText, String toText) {\r
- if(text == null || fromText == null || toText == null) {\r
- return null;\r
- }\r
- StringBuilder sb = new StringBuilder();\r
- int pos = 0;\r
- int pos2 = 0;\r
- do {\r
- pos = text.indexOf(fromText, pos2);\r
- if(pos == 0) {\r
- sb.append(toText);\r
- pos2 = fromText.length();\r
- } else\r
- if(pos > 0) {\r
- sb.append(text.substring(pos2, pos));\r
- sb.append(toText);\r
- pos2 = pos + fromText.length();\r
- } else {\r
- sb.append(text.substring(pos2));\r
- return sb.toString();\r
- }\r
- } while(true);\r
- }\r
- \r
- public static String initCap(String str) {\r
- assertObjectNotNull("str", str);\r
- return str.substring(0, 1).toUpperCase() + str.substring(1);\r
- }\r
- \r
- public static String initUncap(String str) {\r
- assertObjectNotNull("str", str);\r
- return str.substring(0, 1).toLowerCase() + str.substring(1);\r
- }\r
- \r
- // -----------------------------------------------------\r
- // Assert Object\r
- // -------------\r
- /**\r
- * Assert that the object is not null.\r
- * @param variableName Variable name. (NotNull)\r
- * @param value Value. (NotNull)\r
- * @exception IllegalArgumentException\r
- */\r
- protected static void assertObjectNotNull(String variableName, Object value) {\r
- if (variableName == null) {\r
- String msg = "The value should not be null: variableName=" + variableName + " value=" + value;\r
- throw new IllegalArgumentException(msg);\r
- }\r
- if (value == null) {\r
- String msg = "The value should not be null: variableName=" + variableName;\r
- throw new IllegalArgumentException(msg);\r
- }\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.util;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class SimpleSystemUtil {\r
-\r
- // ===================================================================================\r
- // System\r
- // ======\r
- public static String getLineSeparator() {\r
- // /- - - - - - - - - - - - - - - - - - - - - -\r
- // Because 'CR + LF' caused many trouble!\r
- // And Now 'LF' have little trouble. \r
- // \r
- // return System.getProperty("line.separator");\r
- // - - - - - - - - - -/\r
- return "\n";\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.util;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class TraceViewUtil {\r
-\r
- /**\r
- * Convert to performance view.\r
- * @param afterMinusBefore The value of after-minus-before millisecond.\r
- * @return Performance view. (ex. 1m23s456ms) (NotNull)\r
- */\r
- public static String convertToPerformanceView(long afterMinusBefore) {\r
- if (afterMinusBefore < 0) {\r
- return String.valueOf(afterMinusBefore);\r
- }\r
-\r
- long sec = afterMinusBefore / 1000;\r
- final long min = sec / 60;\r
- sec = sec % 60;\r
- final long mil = afterMinusBefore % 1000;\r
-\r
- final StringBuffer sb = new StringBuffer();\r
- if (min >= 10) { // Minute\r
- sb.append(min).append("m");\r
- } else if (min < 10 && min >= 0) {\r
- sb.append("0").append(min).append("m");\r
- }\r
- if (sec >= 10) { // Second\r
- sb.append(sec).append("s");\r
- } else if (sec < 10 && sec >= 0) {\r
- sb.append("0").append(sec).append("s");\r
- }\r
- if (mil >= 100) { // Millisecond\r
- sb.append(mil).append("ms");\r
- } else if (mil < 100 && mil >= 10) {\r
- sb.append("0").append(mil).append("ms");\r
- } else if (mil < 10 && mil >= 0) {\r
- sb.append("00").append(mil).append("ms");\r
- }\r
-\r
- return sb.toString();\r
- }\r
-\r
- /**\r
- * Convert object array to string view.\r
- * @param objArray The array of object. (Nullable)\r
- * @return The string divided with comma. (NotNull: If the argument is null, returns empty string.)\r
- */\r
- public static String convertObjectArrayToStringView(Object[] objArray) {\r
- if (objArray == null) {\r
- return "";\r
- }\r
- final StringBuffer sb = new StringBuffer();\r
- for (int i = 0; i < objArray.length; i++) {\r
- if (i == 0) {\r
- sb.append(objArray[i]);\r
- } else {\r
- sb.append(", ").append(objArray[i]);\r
- }\r
- }\r
- return sb.toString();\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.allcommon.util;\r
-\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.LinkedHashMap;\r
-\r
-/**\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class ValueLabelUtil {\r
-\r
- /**\r
- * Find the label by the value from the list of value label.\r
- * @param valueLabelList The list of value label. (NotNull and NotEmpty)\r
- * @param value Value. (NotNull)\r
- * @return Label. (NotNull)\r
- */\r
- public static String findLabel(List<Map<String, Object>> valueLabelList, Object value) {\r
- if (valueLabelList == null) {\r
- String msg = "The arguement[valueLabelList] should not be null.";\r
- throw new IllegalArgumentException(msg);\r
- }\r
- if (valueLabelList.isEmpty()) {\r
- String msg = "The arguement[valueLabelList] should not be empty.";\r
- throw new IllegalArgumentException(msg);\r
- }\r
- if (value == null) {\r
- String msg = "The arguement[value] should not be null.";\r
- throw new IllegalArgumentException(msg);\r
- }\r
- for (Map<String, Object> elementMap : valueLabelList) {\r
- final Object currentValue = elementMap.get("value");\r
- if (value.equals(currentValue)) {\r
- return (String) elementMap.get("label");\r
- }\r
- }\r
- String msg = "Not found label by the value: value=" + value + " valueLabelList=" + valueLabelList;\r
- throw new IllegalStateException(msg);\r
- }\r
- \r
- public static Map<Object, String> createValueLabelMap(List<Map<String, Object>> valueLabelList) {\r
- final Map<Object, String> resultMap = new LinkedHashMap<Object, String>();\r
- for (Map<String, Object> elementMap : valueLabelList) {\r
- final Object currentValue = elementMap.get("value");\r
- final String currentLabel = (String) elementMap.get("label");\r
- resultMap.put(currentValue, currentLabel);\r
- }\r
- return resultMap;\r
- }\r
- \r
- public static Map<String, Object> createLabelValueMap(List<Map<String, Object>> valueLabelList) {\r
- final Map<String, Object> resultMap = new LinkedHashMap<String, Object>();\r
- for (Map<String, Object> elementMap : valueLabelList) {\r
- final Object currentValue = elementMap.get("value");\r
- final String currentLabel = (String) elementMap.get("label");\r
- resultMap.put(currentLabel, currentValue);\r
- }\r
- return resultMap;\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.bsdao.pmbean;\r
-\r
-\r
-/**\r
- * The parameter-bean of SelectTablesInPackagePmb.\r
- * @author DBFlute(AutoGenerator)\r
- */\r
-public class BsSelectTablesInPackagePmb {\r
-\r
- // ===================================================================================\r
- // Attribute\r
- // =========\r
- /** The value of packageId. */\r
- protected java.lang.Integer _packageId;\r
-\r
- /** The value of stereotype. */\r
- protected java.lang.String _stereotype;\r
-\r
- /** The value of objectType. */\r
- protected java.lang.String _objectType;\r
-\r
- // ===================================================================================\r
- // Constructor\r
- // ===========\r
- public BsSelectTablesInPackagePmb() {\r
- }\r
- \r
- // ===================================================================================\r
- // Helper\r
- // ======\r
- /**\r
- * @param value Query value. (Nullable)\r
- * @return Converted value. (Nullable)\r
- */\r
- protected String convertEmptyToNullIfString(String value) {\r
- return filterRemoveEmptyString(value);\r
- }\r
-\r
- /**\r
- * @param value Query value string. (Nullable)\r
- * @return Removed-empty value. (Nullable)\r
- */\r
- protected String filterRemoveEmptyString(String value) {\r
- return ((value != null && !"".equals(value)) ? value : null);\r
- }\r
-\r
- // ===================================================================================\r
- // Basic Override\r
- // ==============\r
- /**\r
- * The override.\r
- * @return The view of properties. (NotNull)\r
- */\r
- @Override\r
- public String toString() {\r
- final String delimiter = ",";\r
- final StringBuffer sb = new StringBuffer();\r
- sb.append(delimiter).append(_packageId);\r
- sb.append(delimiter).append(_stereotype);\r
- sb.append(delimiter).append(_objectType);\r
- if (sb.length() > 0) { sb.delete(0, delimiter.length()); }\r
- sb.insert(0, "{").append("}");\r
- return sb.toString();\r
- }\r
-\r
- // ===================================================================================\r
- // Accessor\r
- // ========\r
- /**\r
- * Get the value of packageId. (Converted empty to null)\r
- * @return The value of packageId. (Nullable & NotEmptyString: if the value is empty string, returns null)\r
- */\r
- public java.lang.Integer getPackageId() {\r
- return _packageId;\r
- }\r
-\r
- /**\r
- * Set the value of packageId.\r
- * @param packageId The value of packageId. (Nullable)\r
- */\r
- public void setPackageId(java.lang.Integer packageId) {\r
- _packageId = packageId;\r
- }\r
-\r
- /**\r
- * Get the value of stereotype. (Converted empty to null)\r
- * @return The value of stereotype. (Nullable & NotEmptyString: if the value is empty string, returns null)\r
- */\r
- public java.lang.String getStereotype() {\r
- return (java.lang.String)convertEmptyToNullIfString(_stereotype);\r
- }\r
-\r
- /**\r
- * Set the value of stereotype.\r
- * @param stereotype The value of stereotype. (Nullable)\r
- */\r
- public void setStereotype(java.lang.String stereotype) {\r
- _stereotype = stereotype;\r
- }\r
-\r
- /**\r
- * Get the value of objectType. (Converted empty to null)\r
- * @return The value of objectType. (Nullable & NotEmptyString: if the value is empty string, returns null)\r
- */\r
- public java.lang.String getObjectType() {\r
- return (java.lang.String)convertEmptyToNullIfString(_objectType);\r
- }\r
-\r
- /**\r
- * Set the value of objectType.\r
- * @param objectType The value of objectType. (Nullable)\r
- */\r
- public void setObjectType(java.lang.String objectType) {\r
- _objectType = objectType;\r
- }\r
-\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.bsentity.customize.dbmeta;\r
-\r
-import java.util.List;\r
-import java.util.Map;\r
-\r
-import jp.sourceforge.ea2ddl.dao.allcommon.Entity;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.dbmeta.AbstractDBMeta;\r
-import jp.sourceforge.ea2ddl.dao.exentity.customize.ForeignKey;\r
-import jp.sourceforge.ea2ddl.dao.allcommon.dbmeta.info.*;\r
-\r
-/**\r
- * The DB meta of ForeignKey. (Singleton)\r
- * @author DBFlute(AutoGenerator)\r
- */
-@SuppressWarnings("unchecked")\r
-public class ForeignKeyDbm extends AbstractDBMeta {\r
-\r
- private static final ForeignKeyDbm _instance = new ForeignKeyDbm();\r
- private ForeignKeyDbm() {}\r
- public static ForeignKeyDbm getInstance() { return _instance; }\r
-\r
- // ===================================================================================\r
- // Table Info\r
- // ==========\r
- public String getTableDbName() { return "ForeignKey"; }\r
- public String getTablePropertyName() { return "foreignKey"; }\r
- public String getTableSqlName() { return "ForeignKey"; }\r
-\r
- // ===================================================================================\r
- // Column Info\r
- // ===========\r
- protected ColumnInfo _columnConnectorId = cci("Connector_ID", "connectorId", java.lang.Integer.class, false, 10, 0);\r
- protected ColumnInfo _columnStartObjectId = cci("Start_Object_ID", "startObjectId", java.lang.Integer.class, false, 10, 0);\r
- protected ColumnInfo _columnName = cci("Name", "name", String.class, false, 255, 0);\r
- protected ColumnInfo _columnEndObjectId = cci("End_Object_ID", "endObjectId", java.lang.Integer.class, false, 10, 0);\r
-\r
- public ColumnInfo columnConnectorId() { return _columnConnectorId; }\r
- public ColumnInfo columnStartObjectId() { return _columnStartObjectId; }\r
- public ColumnInfo columnName() { return _columnName; }\r
- public ColumnInfo columnEndObjectId() { return _columnEndObjectId; }\r
- { initializeColumnInfoList(); }\r
-\r
- // ===================================================================================\r
- // Name Map\r
- // ========\r
- public Map<String, String> getDbNamePropertyNameKeyToLowerMap() { return createDbNamePropertyNameKeyToLowerMap(); }\r
- public Map<String, String> getPropertyNameDbNameKeyToLowerMap() { return createPropertyNameDbNameKeyToLowerMap(); }\r
- protected static Map<String, String> _dbNamePropertyNameKeyToLowerMap;\r
- protected Map<String, String> createDbNamePropertyNameKeyToLowerMap() {\r
- if (_dbNamePropertyNameKeyToLowerMap == null) { _dbNamePropertyNameKeyToLowerMap = setupKeyToLowerMap(true); }\r
- return _dbNamePropertyNameKeyToLowerMap;\r
- }\r
- protected static Map<String, String> _propertyNameDbNameKeyToLowerMap;\r
- protected Map<String, String> createPropertyNameDbNameKeyToLowerMap() {\r
- if (_propertyNameDbNameKeyToLowerMap == null) { _propertyNameDbNameKeyToLowerMap = setupKeyToLowerMap(false); }\r
- return _propertyNameDbNameKeyToLowerMap;\r
- }\r
-\r
- // ===================================================================================\r
- // Type Name\r
- // =========\r
- public String getEntityTypeName() { return "jp.sourceforge.ea2ddl.dao.exentity.customize.ForeignKey"; }\r
- public String getConditionBeanTypeName() { return null; }\r
- public String getDaoTypeName() { return null; }\r
- public String getBehaviorTypeName() { return null; }\r
-\r
- // ===================================================================================\r
- // Object Type\r
- // ===========\r
- public Class<ForeignKey> getEntityType() { return ForeignKey.class; }\r
-\r
- // ===================================================================================\r
- // Object Instance\r
- // ===============\r
- public Entity newEntity() { return newMyEntity(); }\r
- public ForeignKey newMyEntity() { return new ForeignKey(); }\r
-\r
- // ===================================================================================\r
- // Unique Info\r
- // ===========\r
- // -----------------------------------------------------\r
- // Primary Element\r
- // ---------------\r
- public UniqueInfo getPrimaryUniqueInfo() {\r
- throw new UnsupportedOperationException("The table doen not have primary key: " + getTableDbName());\r
- }\r
- public boolean hasPrimaryKey() { return false; }\r
- public boolean hasTwoOrMorePrimaryKeys() { return false; }\r
-\r
- // ===================================================================================\r
- // Relation Info\r
- // =============\r
- // -----------------------------------------------------\r
- // Foreign Property\r
- // ----------------\r
-\r
- // -----------------------------------------------------\r
- // Referrer Property\r
- // -----------------\r
-\r
- // ===================================================================================\r
- // Various Info\r
- // ============\r
-\r
- // ===================================================================================\r
- // Entity Handling\r
- // =============== \r
- // -----------------------------------------------------\r
- // Accept\r
- // ------\r
- public void acceptPrimaryKeyMap(Entity entity, Map<String, ? extends Object> primaryKeyMap) {\r
- doAcceptPrimaryKeyMap((ForeignKey)entity, primaryKeyMap, _epsMap);\r
- }\r
-\r
- public void acceptPrimaryKeyMapString(Entity entity, String primaryKeyMapString) {\r
- MapStringUtil.acceptPrimaryKeyMapString(primaryKeyMapString, entity);\r
- }\r
-\r
- public void acceptColumnValueMap(Entity entity, Map<String, ? extends Object> columnValueMap) {\r
- doAcceptColumnValueMap((ForeignKey)entity, columnValueMap, _epsMap);\r
- }\r
-\r
- public void acceptColumnValueMapString(Entity entity, String columnValueMapString) {\r
- MapStringUtil.acceptColumnValueMapString(columnValueMapString, entity);\r
- }\r
-\r
- // -----------------------------------------------------\r
- // Extract\r
- // -------\r
- public String extractPrimaryKeyMapString(Entity entity) { return MapStringUtil.extractPrimaryKeyMapString(entity); }\r
- public String extractPrimaryKeyMapString(Entity entity, String startBrace, String endBrace, String delimiter, String equal) {\r
- return doExtractPrimaryKeyMapString(entity, startBrace, endBrace, delimiter, equal);\r
- }\r
- public String extractColumnValueMapString(Entity entity) { return MapStringUtil.extractColumnValueMapString(entity); }\r
- public String extractColumnValueMapString(Entity entity, String startBrace, String endBrace, String delimiter, String equal) {\r
- return doExtractColumnValueMapString(entity, startBrace, endBrace, delimiter, equal);\r
- }\r
-\r
- // -----------------------------------------------------\r
- // Convert\r
- // -------\r
- public List<Object> convertToColumnValueList(Entity entity) { return newArrayList(convertToColumnValueMap(entity).values()); }\r
- public Map<String, Object> convertToColumnValueMap(Entity entity) { return doConvertToColumnValueMap(entity); }\r
- public List<String> convertToColumnStringValueList(Entity entity) { return newArrayList(convertToColumnStringValueMap(entity).values()); }\r
- public Map<String, String> convertToColumnStringValueMap(Entity entity) { return doConvertToColumnStringValueMap(entity); }\r
-\r
- // ===================================================================================\r
- // Entity Property Setup\r
- // =====================\r
- // It's very INTERNAL!\r
- protected Map<String, Eps<ForeignKey>> _epsMap = newHashMap();\r
- {\r
- setupEps(_epsMap, new EpsConnectorId(), columnConnectorId());\r
- setupEps(_epsMap, new EpsStartObjectId(), columnStartObjectId());\r
- setupEps(_epsMap, new EpsName(), columnName());\r
- setupEps(_epsMap, new EpsEndObjectId(), columnEndObjectId());\r
- }\r
- \r
- public boolean hasEntityPropertySetupper(String propertyName) {\r
- return _epsMap.containsKey(propertyName);\r
- }\r
-\r
- public void setupEntityProperty(String propertyName, Object entity, Object value) {\r
- findEps(_epsMap, propertyName).setup((ForeignKey)entity, value);\r
- }\r
- \r
- public static class EpsConnectorId implements Eps<ForeignKey> {\r
- public void setup(ForeignKey e, Object v) { e.setConnectorId((java.lang.Integer)v); }\r
- }\r
- public static class EpsStartObjectId implements Eps<ForeignKey> {\r
- public void setup(ForeignKey e, Object v) { e.setStartObjectId((java.lang.Integer)v); }\r
- }\r
- public static class EpsName implements Eps<ForeignKey> {\r
- public void setup(ForeignKey e, Object v) { e.setName((String)v); }\r
- }\r
- public static class EpsEndObjectId implements Eps<ForeignKey> {\r
- public void setup(ForeignKey e, Object v) { e.setEndObjectId((java.lang.Integer)v); }\r
- }\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.exdao.pmbean;\r
-\r
-/**\r
- * The parameter-bean of SelectTablesInPackagePmb.\r
- * <p>\r
- * You can implement your original methods here.\r
- * This class is NOT overrided when re-generating.\r
- * </p>\r
- * @author DBFlute(AutoGenerator)\r
- */
-@SuppressWarnings("unchecked")\r
-public class SelectTablesInPackagePmb extends jp.sourceforge.ea2ddl.dao.bsdao.pmbean.BsSelectTablesInPackagePmb {\r
-}\r
+++ /dev/null
-package jp.sourceforge.ea2ddl.dao.exentity.customize;\r
-\r
-/**\r
- * The entity of ForeignKey.\r
- * <p>\r
- * You can implement your original methods here.\r
- * This class is NOT overrided when re-generating.\r
- * </p>\r
- * @author DBFlute(AutoGenerator)\r
- */
-@SuppressWarnings("unchecked")\r
-public class ForeignKey extends jp.sourceforge.ea2ddl.dao.bsentity.customize.BsForeignKey {\r
-\r
- /** Serial version UID. (Default) */\r
- private static final long serialVersionUID = 1L;\r
-}\r