Java SQL Type getFormatTypeAsString(int fieldType)

Here you can find the source of getFormatTypeAsString(int fieldType)

Description

Get the String representing the format-type associated with the value in fieldType.

License

Open Source License

Parameter

Parameter Description
fieldType int one of the values in java.sql.Types. Currently the only values that return non-null are Types.DATE and Types.NUMERIC

Exception

Parameter Description
RuntimeException if fieldType is not recognized. Currently the onlyrecognized types are Types.DATE, Types.NUMBER, Types.VARCHAR.

Return

String null if fieldType is a value that does not support formatting, otherwise a String specifying the type of the field.

Declaration

private static String getFormatTypeAsString(int fieldType) 

Method Source Code

//package com.java2s;
/*// w  ww.  j  ava2 s . c  o m
* Copyright 2002 - 2013 Pentaho Corporation.  All rights reserved.
* 
* This software was developed by Pentaho Corporation and is provided under the terms
* of the Mozilla Public License, Version 1.1, or any later version. You may not use
* this file except in compliance with the license. If you need a copy of the license,
* please go to http://www.mozilla.org/MPL/MPL-1.1.txt. TThe Initial Developer is Pentaho Corporation.
*
* Software distributed under the Mozilla Public License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or  implied. Please refer to
* the license for the specific language governing your rights and limitations.
*/

import java.sql.Types;

public class Main {
    /**
     * Get the String representing the format-type associated with the value in <param>fieldType</param>.
     * This method will return the appropriate type String based in the input <param>fieldType</param>.
     * See the documentation for getGroupMessageFieldFormatText() for more information.
     * 
     * @param fieldType int one of the values in java.sql.Types. Currently the only values
     * that return non-null are Types.DATE and Types.NUMERIC
     * 
     * @return String null if fieldType is a value that does not support formatting,
     * otherwise a String specifying the type of the field.
     * 
     * @throws RuntimeException if fieldType is not recognized. Currently the only
     * recognized types are Types.DATE, Types.NUMBER, Types.VARCHAR.
     */
    private static String getFormatTypeAsString(int fieldType) {
        switch (fieldType) {
        case Types.DATE:
            return "date"; //$NON-NLS-1$
        case Types.NUMERIC:
            return "number"; //$NON-NLS-1$
        case Types.VARCHAR:
            return null;
        default:
            // TODO sbarkdull, should be internationalized
            throw new RuntimeException("Invalid field type: " + "(" + String.valueOf(fieldType) + ")");
        }
    }
}

Related

  1. getDefaultScale(int sqlType)
  2. getDefaultValue(Class type)
  3. getDoubleTypeString(Connection conn)
  4. getDoubleTypeString(Connection conn)
  5. getExpressionChoices(int type)
  6. getInsertarEmpresa()
  7. getIntTypeString(Connection conn)
  8. getIntValue(String typeName)
  9. getJavaType(int dataType, int columnSize, int decimalDegit)