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.s2dao.metadata;

Author(s):
modified by jflute (originated in S2Dao)
    // ===================================================================================
    //                                                                             Provide
    //                                                                             =======
    
Provide value type for procedure from registered types.

Parameters:
pmbType The type of ProcdurePmb for the parameter. (NotNull)
paramName The name of parameter. (NotNull)
paramType The type of parameter. (NotNull)
keyName The key name for plug-in value type. (NullAllowed)
dbdef The current DB definition. (NotNull)
Returns:
The instance of value type. (NotNull: if not found by (not-null) valueTypeName, exception)
    public ValueType provide(Class<?> pmbTypeString paramNameClass<?> paramTypeString keyNameDBDef dbdef) {
        if (keyName != null) {
            return findValueTypeByName(pmbTypeparamNameparamTypekeyName);
        }
        if (List.class.isAssignableFrom(paramType)) { // is for out parameter cursor.
            return findCursorValueType(dbdef);
        }
        return findValueTypeByType(paramType);
    }
    // ===================================================================================
    //                                                                             By Name
    //                                                                             =======
    protected ValueType findValueTypeByName(Class<?> pmbTypeString paramNameClass<?> paramTypeString keyName) {
        final ValueType valueType = TnValueTypes.getPluginValueType(keyName);
        if (valueType != null) {
            return valueType;
        }
        final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
        br.addNotice("Not found a plug-in value type by the name.");
        br.addItem("ProcedurePmb");
        br.addElement(pmbType.getName());
        br.addItem("Parameter");
        br.addElement(paramName);
        br.addElement(paramType.getName());
        br.addItem("Key Name");
        br.addElement(keyName);
        final String msg = br.buildExceptionMessage();
        throw new PluginValueTypeNotFoundException(msg);
    }
    // ===================================================================================
    //                                                                              Cursor
    //                                                                              ======
    protected ValueType findCursorValueType(DBDef dbdef) {
        if (..equals(dbdef)) {
            return .;
        } else if (..equals(dbdef)) {
            return .;
        } else {
            return .;
        }
    }
    // ===================================================================================
    //                                                                             By Type
    //                                                                             =======
    protected ValueType findValueTypeByType(Class<?> paramType) {
        return TnValueTypes.getValueType(paramType);
    }
New to GrepCode? Check out our FAQ X