Example usage for java.lang Object getClass

List of usage examples for java.lang Object getClass

Introduction

In this page you can find the example usage for java.lang Object getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:Main.java

public static Object invokeMethod(Object object, String methodName, Class[] cls, Object[] args)
        throws Exception {
    Class clazz = object.getClass();
    return invokeMethod(clazz, object, methodName, cls, args);
}

From source file:Main.java

public static boolean isViewer(Object obj) {
    if (JFACES_VIEWER == null || obj == null)
        return false;
    return JFACES_VIEWER.isAssignableFrom(obj.getClass());
}

From source file:Main.java

public final static int getIntValue(Object owner, String name, int defvalue) {
    int result = defvalue;
    setClass(owner.getClass().getName());
    Field field = getField(name);

    if (field != null) {
        try {//from   w  w w.j a v a2s  . co  m
            result = field.getInt(owner);
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }
    return result;
}

From source file:com.mycompany.client.bank.utils.CryptMessage.java

public static Object toInternal(String SuperSecret, Object criptStrings) {
    Class curClass = criptStrings.getClass();
    byte[] syperSecretBytes = null;
    try {/* www .j  a v a  2s.  c  om*/
        syperSecretBytes = SuperSecret.getBytes("utf-8");
    } catch (UnsupportedEncodingException ex) {
        Logger.getLogger(CryptMessage.class.getName()).log(Level.SEVERE, null, ex);
    }
    for (Field field : curClass.getDeclaredFields()) {
        try {
            String str = null;
            if (field.get(criptStrings) != null)
                str = field.get(criptStrings).toString();
            if (str != null) {
                byte[] mybyte = str.getBytes("utf-8");
                int i = 0;
                ByteTransform(syperSecretBytes, mybyte, i);
                field.set(criptStrings, new String(mybyte, "utf-8"));
            }
        } catch (UnsupportedEncodingException | IllegalArgumentException | IllegalAccessException ex) {
            Logger.getLogger(CryptMessage.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    return criptStrings;
}

From source file:Main.java

public static void inject(PathClassLoader pathClassLoader, DexClassLoader loader) {

    try {/*from  w ww .j  a va2 s .com*/
        Object dexElements = combineArray(getDexElements(getPathList(pathClassLoader)),
                getDexElements(getPathList(loader)));
        Object pathList = getPathList(pathClassLoader);
        setField(pathList, pathList.getClass(), "dexElements", dexElements);
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (NoSuchFieldException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }
}

From source file:io.devcon5.pageobjects.tx.TransactionHelper.java

/**
 * Determines whether an instance is a CGLib Proxy.
 * @param object/*  w  ww.  j  av a 2 s  .c  o m*/
 *  the object to check
 * @return
 *  true if the object is a CGLib proxy
 */
private static boolean isCGLibProxy(Object object) {
    return object != null && object.getClass().getName().contains("$$EnhancerByCGLIB$$");
}

From source file:Main.java

public static Boolean isCollection(Object object) {
    if (object == null)
        return Boolean.FALSE;
    return Collection.class.isAssignableFrom(object.getClass());
}

From source file:org.terasoluna.gfw.web.util.HtmlEscapeUtils.java

/**
 * converts input array object to String
 * @param input//from w w  w.  ja v a  2 s. c  o  m
 * @return converted String value
 */
private static String convertArraysToString(Object input) {
    Class<?> clazz = input.getClass().getComponentType();
    String str;
    if (clazz == String.class) {
        str = Arrays.toString((Object[]) input);
    } else if (clazz == boolean.class) {
        str = Arrays.toString((boolean[]) input);
    } else if (clazz == char.class) {
        str = Arrays.toString((char[]) input);
    } else if (clazz == int.class) {
        str = Arrays.toString((int[]) input);
    } else if (clazz == long.class) {
        str = Arrays.toString((long[]) input);
    } else if (clazz == byte.class) {
        str = Arrays.toString((byte[]) input);
    } else if (clazz == short.class) {
        str = Arrays.toString((short[]) input);
    } else if (clazz == float.class) {
        str = Arrays.toString((float[]) input);
    } else if (clazz == double.class) {
        str = Arrays.toString((double[]) input);
    } else {
        str = Arrays.toString((Object[]) input);
    }
    return str;
}

From source file:Main.java

public static Field findField(Object target, List<String> possible_names) {
    if (target == null)
        return null;
    for (Class<?> clazz = target.getClass(); clazz != null; clazz = clazz.getSuperclass()) {
        for (String name : possible_names) {
            try {
                return clazz.getDeclaredField(name);
            } catch (Exception e) {
            }/*w w w.j a  va  2 s . c  o  m*/
        }
    }
    return null;
}

From source file:Main.java

public static Object expand(Object obj, int i, boolean flag) {
    int j = Array.getLength(obj);
    Object obj1 = Array.newInstance(obj.getClass().getComponentType(), j + i);
    System.arraycopy(obj, 0, obj1, flag ? 0 : i, j);
    return obj1;//  www.  j  av  a2  s.  c om
}