📄 arguments.java
字号:
Object result = null; try { Class[] mTypes = method.getParameterTypes(); Class[] aTypes = getArgumentsTypes(); if (aTypes == null) { aTypes = new Class[0]; } if (mTypes.length == aTypes.length) { for (int i = 0; i < aTypes.length; i++) { if (!mTypes[i].equals(aTypes[i])) { methodError = true; return null; } } Object[] args = getArguments(); boolean ia = method.isAccessible(); if (!ia) { method.setAccessible(true); } result = method.invoke(obj, args); method.setAccessible(ia); } else { methodError = true; } } catch (NullPointerException npe) { methodError = true; } catch (Exception ex) { ex.printStackTrace(); } finally { return result; } } private boolean translateBoolean(String value) { for (int i = 0; i < booleanStrings.length; i++) { if (booleanStrings[i][0].equalsIgnoreCase(value)) { return true; } else if (booleanStrings[i][1].equalsIgnoreCase(value)) { return false; } } return false; } public void addElement(Object value, Class caster) { if (caster == Date.class) { try { super.addElement(sdfTranslator.parse(value.toString())); } catch (ParseException ex) { } } else if ((caster == boolean.class) || (caster == Boolean.class)) { addElement(translateBoolean(value.toString())); } else if ((caster == byte.class) || (caster == Byte.class)) { addElement(Byte.parseByte(value.toString())); } else if ((caster == double.class) || (caster == Double.class)) { addElement(Double.parseDouble(value.toString())); } else if ((caster == float.class) || (caster == Float.class)) { addElement(Float.parseFloat(value.toString())); } else if ((caster == int.class) || (caster == Integer.class)) { addElement(Integer.parseInt(value.toString())); } else if ((caster == long.class) || (caster == Long.class)) { addElement(Long.parseLong(value.toString())); } else if ((caster == short.class) || (caster == Short.class)) { addElement(Short.parseShort(value.toString())); } else { addElement(value); } } public void addElement(Object data) { Class caster = data.getClass(); String value = String.valueOf(data); if ((caster == boolean.class) || (caster == Boolean.class)) { addElement(translateBoolean(value)); } else if ((caster == byte.class) || (caster == Byte.class)) { addElement(Byte.parseByte(value)); } else if ((caster == double.class) || (caster == Double.class)) { addElement(Double.parseDouble(value)); } else if ((caster == float.class) || (caster == Float.class)) { addElement(Float.parseFloat(value)); } else if ((caster == int.class) || (caster == Integer.class)) { addElement(Integer.parseInt(value)); } else if ((caster == long.class) || (caster == Long.class)) { addElement(Long.parseLong(value)); } else if ((caster == short.class) || (caster == Short.class)) { addElement(Short.parseShort(value)); } else { super.addElement(data); } } public static char unWrapChar(Object obj) { return ((Character)unWrap(obj)).charValue(); } public static boolean unWrapBoolean(Object obj) { return ((Boolean)unWrap(obj)).booleanValue(); } public static byte unWrapByte(Object obj) { return ((Byte)unWrap(obj)).byteValue(); } public static double unWrapDouble(Object obj) { return ((Double)unWrap(obj)).doubleValue(); } public static float unWrapFloat(Object obj) { return ((Float)unWrap(obj)).floatValue(); } public static int unWrapInteger(Object obj) { return ((Integer)unWrap(obj)).intValue(); } public static long unWrapLong(Object obj) { return ((Long)unWrap(obj)).longValue(); } public static short unWrapShort(Object obj) { return ((Short)unWrap(obj)).shortValue(); } public static Object unWrap(Object obj) { return (obj instanceof Argument) ? ((Argument)obj).getData(false) : obj; } private Object unWrapObject(Object obj) { return (obj instanceof Argument) ? ((Argument)obj).getData(nullAsClass) : obj; } public void addElement(boolean value) { Argument o = createArrayObject(boolean.class); Array.setBoolean(o.array, 0, value); addElement(o); } public void addElement(byte value) { Argument o = createArrayObject(byte.class); Array.setByte(o.array, 0, value); addElement(o); } public void addElement(char value) { Argument o = createArrayObject(char.class); Array.setChar(o.array, 0, value); addElement(o); } public void addElement(double value) { Argument o = createArrayObject(double.class); Array.setDouble(o.array, 0, value); addElement(o); } public void addElement(float value) { Argument o = createArrayObject(float.class); Array.setFloat(o.array, 0, value); addElement(o); } public void addElement(int value) { Argument o = createArrayObject(int.class); Array.setInt(o.array, 0, value); addElement(o); } public void addElement(long value) { Argument o = createArrayObject(long.class); Array.setLong(o.array, 0, value); addElement(o); } public void addElement(short value) { Argument o = createArrayObject(short.class); Array.setShort(o.array, 0, value); addElement(o); } public void setElementAt(boolean value, int index) { Argument o = createArrayObject(boolean.class, this, index); Array.setBoolean(o.array, 0, value); setElementAt(o, index); } public void setElementAt(byte value, int index) { Argument o = createArrayObject(byte.class, this, index); Array.setByte(o.array, 0, value); setElementAt(o, index); } public void setElementAt(char value, int index) { Argument o = createArrayObject(char.class, this, index); Array.setChar(o.array, 0, value); setElementAt(o, index); } public void setElementAt(double value, int index) { Argument o = createArrayObject(double.class, this, index); Array.setDouble(o.array, 0, value); setElementAt(o, index); } public void setElementAt(float value, int index) { Argument o = createArrayObject(float.class, this, index); Array.setFloat(o.array, 0, value); setElementAt(o, index); } public void setElementAt(int value, int index) { Argument o = createArrayObject(int.class, this, index); Array.setInt(o.array, 0, value); setElementAt(o, index); } public void setElementAt(long value, int index) { Argument o = createArrayObject(long.class, this, index); Array.setLong(o.array, 0, value); setElementAt(o, index); } public void setElementAt(short value, int index) { Argument o = createArrayObject(short.class, this, index); Array.setShort(o.array, 0, value); setElementAt(o, index); } public void insertElementAt(boolean value, int index) { Argument o = createArrayObject(boolean.class); Array.setBoolean(o.array, 0, value); insertElementAt(o, index); } public void insertElementAt(byte value, int index) { Argument o = createArrayObject(byte.class); Array.setByte(o.array, 0, value); insertElementAt(o, index); } public void insertElementAt(char value, int index) { Argument o = createArrayObject(char.class); Array.setChar(o.array, 0, value); insertElementAt(o, index); } public void insertElementAt(double value, int index) { Argument o = createArrayObject(double.class); Array.setDouble(o.array, 0, value); insertElementAt(o, index); } public void insertElementAt(float value, int index) { Argument o = createArrayObject(float.class); Array.setFloat(o.array, 0, value); insertElementAt(o, index); } public void insertElementAt(int value, int index) { Argument o = createArrayObject(int.class); Array.setInt(o.array, 0, value); insertElementAt(o, index); } public void insertElementAt(long value, int index) { Argument o = createArrayObject(long.class); Array.setLong(o.array, 0, value); insertElementAt(o, index); } public void insertElementAt(short value, int index) { Argument o = createArrayObject(short.class); Array.setShort(o.array, 0, value); insertElementAt(o, index); } public void addNull(Class classType) { Argument o = createArrayObject(Class.class); Array.set(o.array, 0, classType); addElement(o); } public void setNullAt(Class classType, int index) { Argument o = createArrayObject(Class.class); Array.set(o.array, 0, classType); setElementAt(o, index); } public void insertNullAt(Class classType, int index) { Argument o = createArrayObject(Class.class); Array.set(o.array, 0, classType); insertElementAt(o, index); } private static Argument createArrayObject(Class objClass, Arguments args, int index) { Argument result = null; Object x = args.elementAt(index); if (x instanceof Argument) { result = (Argument)x; result.verifyClass(objClass); } else { result = createArrayObject(objClass); } return result; } private static Argument createArrayObject(Class objClass) { return new Argument(objClass); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -