/** * Calls the callback with every parameter of the method, skipping out the offset parameter * introduced by F2J for array arguments. * * @param method * @param callback */ protected void iterateRelevantParameters( Method method, boolean offsets, ParameterCallback callback) { if (method.getParameterTypes().length == 0) return; String[] names = new String[0]; try { names = paranamer.lookupParameterNames(method, true); } catch (ParameterNamesNotFoundException e) { getLog().warn(e); } for (int i = 0; i < method.getParameterTypes().length; i++) { Class<?> param = method.getParameterTypes()[i]; if (i > 0 && !offsets && param == Integer.TYPE && method.getParameterTypes()[i - 1].isArray()) { continue; } String name; if (names.length > 0) name = names[i]; else name = "arg" + i; String offsetName = null; if (i < method.getParameterTypes().length - 1 && param.isArray() && method.getParameterTypes()[i + 1] == Integer.TYPE) offsetName = names[i + 1]; callback.process(i, param, name, offsetName); } }
public boolean hasOffsets(Method method) { Class<?> last = null; for (int i = 0; i < method.getParameterTypes().length; i++) { Class<?> param = method.getParameterTypes()[i]; if (last != null && last.isArray() && param.equals(Integer.TYPE)) return true; last = param; } return false; }
protected Class<?> nioBufferClass(Class<?> clazz) { Class<?> compType = clazz.getComponentType(); if (compType == null) { return null; } else if (compType.equals(Character.TYPE)) { return CharBuffer.class; } else if (compType.equals(Integer.TYPE)) { return IntBuffer.class; } else if (compType.equals(Double.TYPE)) { return DoubleBuffer.class; } else if (compType.equals(Float.TYPE)) { return FloatBuffer.class; } else if (compType.equals(Long.TYPE)) { return LongBuffer.class; } else if (compType.equals(Short.TYPE)) { return ShortBuffer.class; // there's no boolean[]-from-ByteBuffer thing, so we're stuck with // boolean[] // } else if (compType.equals(Boolean.TYPE)) { // return ByteBuffer.class; } else { return null; } }