Java Array Convert to convertArrayType(String type)

Here you can find the source of convertArrayType(String type)

Description

convert Array Type

License

Open Source License

Declaration

public static int convertArrayType(String type) 

Method Source Code

//package com.java2s;
/*//w  w  w  .  j  a  v a2 s .c  o  m
 * JBoss, Home of Professional Open Source.
 * See the COPYRIGHT.txt file distributed with this work for information
 * regarding copyright ownership.  Some portions may be licensed
 * to Red Hat, Inc. under one or more contributor license agreements.
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301 USA.
 */

public class Main {
    public static final int PG_TYPE_TEXTARRAY = 1009;
    public static final int PG_TYPE_BOOLARRAY = 1000;
    public static final int PG_TYPE_INT8ARRAY = 1026;
    public static final int PG_TYPE_INT2ARRAY = 1005;
    public static final int PG_TYPE_INT4ARRAY = 1007;
    public static final int PG_TYPE_FLOAT4ARRAY = 1021;
    public static final int PG_TYPE_FLOAT8ARRAY = 1022;
    public static final int PG_TYPE_DATEARRAY = 1182;
    public static final int PG_TYPE_TIMEARRAY = 1183;
    public static final int PG_TYPE_TIMESTAMP_NO_TMZONEARRAY = 1115;
    public static final int PG_TYPE_NUMERICARRAY = 1031;

    public static int convertArrayType(String type) {
        switch (type) {
        case "boolean[]": //$NON-NLS-1$
            return PG_TYPE_BOOLARRAY;
        case "byte[]": //$NON-NLS-1$
        case "short[]": //$NON-NLS-1$
            return PG_TYPE_INT2ARRAY;
        case "integer[]": //$NON-NLS-1$
            return PG_TYPE_INT4ARRAY;
        case "long[]": //$NON-NLS-1$
            return PG_TYPE_INT8ARRAY;
        case "float[]": //$NON-NLS-1$
            return PG_TYPE_FLOAT4ARRAY;
        case "double[]": //$NON-NLS-1$
            return PG_TYPE_FLOAT8ARRAY;
        case "biginiteger[]": //$NON-NLS-1$
        case "bigdecimal[]": //$NON-NLS-1$
            return PG_TYPE_NUMERICARRAY;
        case "date[]": //$NON-NLS-1$
            return PG_TYPE_DATEARRAY;
        case "time[]": //$NON-NLS-1$
            return PG_TYPE_TIMEARRAY;
        case "timestamp[]": //$NON-NLS-1$
            return PG_TYPE_TIMESTAMP_NO_TMZONEARRAY;
        default:
            return PG_TYPE_TEXTARRAY;
        }
    }
}

Related

  1. convertArray2String(String[] sources)
  2. convertArrayIndexToShipLetter(int i)
  3. convertArrayToCSVString(String[] s)
  4. convertArrayToInteger(String[] input)
  5. convertArrayToLine(String[] cols)
  6. convertArrayTypeName(final String typeName)
  7. convertArrayValue(Object value, Class type)
  8. toDoubleArray(byte[] data)
  9. toDoubleArray(Double[] list)