001/***************************************************************************** 002 * Copyright by The HDF Group. * 003 * Copyright by the Board of Trustees of the University of Illinois. * 004 * All rights reserved. * 005 * * 006 * This file is part of the HDF Java Products distribution. * 007 * The full copyright notice, including terms governing use, modification, * 008 * and redistribution, is contained in the COPYING file, which can be found * 009 * at the root of the source code distribution tree, * 010 * or in https://www.hdfgroup.org/licenses. * 011 * If you do not have access to either file, you may request a copy from * 012 * help@hdfgroup.org. * 013 ****************************************************************************/ 014 015package hdf.object; 016 017/** General utility class */ 018public final class Utils { 019 private Utils() { throw new IllegalStateException("Utility class"); } 020 021 /** 022 * Retrieves the Java Runtime Class of the given Object. B = byte array, S = short array, I = int 023 * array, J = long array, F = float array, D = double array, L = class or interface 024 * 025 * @param o 026 * the Object to determine the Runtime Class of 027 * @return the Java Runtime Class of the given Object. 028 */ 029 public static char getJavaObjectRuntimeClass(Object o) 030 { 031 if (o == null) 032 return ' '; 033 034 String cName = o.getClass().getName(); 035 036 if (cName.equals("java.lang.String") || cName.equals("java.util.Vector") || 037 cName.equals("java.util.Arrays$ArrayList") || cName.equals("java.util.ArrayList")) 038 return 'L'; 039 040 int cIndex = cName.lastIndexOf('['); 041 if (cIndex >= 0) { 042 return cName.charAt(cIndex + 1); 043 } 044 045 return ' '; 046 } 047}