Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2014-2015 the original author or authors.
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
  * either express or implied. See the License for the specific language
  * governing permissions and limitations under the License.
  */
 package org.dbflute.cbean.sqlclause.subquery;
 

Author(s):
jflute
Since:
0.9.7.2 (2010/06/20 Sunday)
 
 public class SpecifyDerivedReferrer extends DerivedReferrer {
 
     // ===================================================================================
     //                                                                          Definition
     //                                                                          ==========
     
The prefix mark for derived mapping alias.
 
 
     // ===================================================================================
     //                                                                           Attribute
     //                                                                           =========
     
The alias name for derived column. (NullAllowed: if null, means no alias expression)
 
     protected final String _aliasName;
 
     // ===================================================================================
     //                                                                         Constructor
     //                                                                         ===========
     public SpecifyDerivedReferrer(SubQueryPath subQueryPathColumnRealNameProvider localRealNameProvider,
             ColumnSqlNameProvider subQuerySqlNameProviderint subQueryLevelSqlClause subQuerySqlClauseString subQueryIdentity,
             DBMeta subQueryDBMetaGearedCipherManager cipherManagerString mainSubQueryIdentityString aliasName) {
         super(subQueryPathlocalRealNameProvidersubQuerySqlNameProvidersubQueryLevelsubQuerySqlClausesubQueryIdentity,
                 subQueryDBMetacipherManagermainSubQueryIdentity);
          = aliasName;
     }
 
     // ===================================================================================
     //                                                                        Build Clause
     //                                                                        ============
     @Override
     protected String doBuildDerivedReferrer(String functionColumnRealName correlatedColumnRealNameColumnSqlName relatedColumnSqlName,
             String subQueryClauseString beginMarkString endMarkString endIndent) {
         return buildCompleteClause(subQueryClausebeginMarkendMarkendIndent);
     }
 
     @Override
     protected String doBuildDerivedReferrer(String functionColumnRealName[] correlatedColumnRealNames,
             ColumnSqlName[] relatedColumnSqlNamesString subQueryClauseString beginMarkString endMarkString endIndent) {
         return buildCompleteClause(subQueryClausebeginMarkendMarkendIndent);
     }
 
     protected String buildCompleteClause(String subQueryClauseString beginMarkString endMarkString endIndent) {
         final String aliasExp;
         if ( != null) {
             final String realAlias;
             if (.startsWith()) {
                 realAlias = Srl.substringFirstRear();
             } else {
                 realAlias = ;
             }
             aliasExp = " as " + realAlias;
         } else {
             aliasExp = "";
         }
         return "(" + beginMark + subQueryClause + ln() + endIndent + ")" + aliasExp + endMark;
     }
 
     @Override
     protected void throwDerivedReferrerInvalidColumnSpecificationException(String function) {
     }
 
     @Override
     protected void doAssertDerivedReferrerColumnType(String functionString derivedColumnDbNameClass<?> derivedColumnType) {
         if ("sum".equalsIgnoreCase(function) || "avg".equalsIgnoreCase(function)) {
             if (!Number.class.isAssignableFrom(derivedColumnType)) {
                 throwSpecifyDerivedReferrerUnmatchedColumnTypeException(functionderivedColumnDbNamederivedColumnType);
             }
         }
    }
    protected void throwSpecifyDerivedReferrerUnmatchedColumnTypeException(String functionString derivedColumnDbName,
            Class<?> derivedColumnType) {
        createCBExThrower().throwSpecifyDerivedReferrerUnmatchedColumnTypeException(functionderivedColumnDbNamederivedColumnType);
    }
New to GrepCode? Check out our FAQ X