Example usage for java.lang.reflect Modifier PUBLIC

List of usage examples for java.lang.reflect Modifier PUBLIC

Introduction

In this page you can find the example usage for java.lang.reflect Modifier PUBLIC.

Prototype

int PUBLIC

To view the source code for java.lang.reflect Modifier PUBLIC.

Click Source Link

Document

The int value representing the public modifier.

Usage

From source file:org.netxilia.spi.impl.formula.function.FunctionRegistry.java

/**
 * register all the public methods of the given instance
 * /*from ww  w  .  j a  v  a  2 s.c  o m*/
 * @param instance
 */
public void registerMethods(Object instance) {
    for (Method m : instance.getClass().getDeclaredMethods())
        if ((m.getModifiers() & Modifier.PUBLIC) != 0
                && AnnotationUtils.findAnnotation(m, SkipFunction.class) == null)
            registerFunction(new MethodWrapper(instance, m));
}

From source file:com.tmall.wireless.tangram3.support.ExposureSupport.java

private void findTraceMethods(Method[] methods) {
    for (Method method : methods) {
        String methodName = method.getName();
        if (isValidTraceMethodName(methodName)) {
            int modifiers = method.getModifiers();
            if ((modifiers & Modifier.PUBLIC) != 0 && (modifiers & MODIFIERS_IGNORE) == 0) {
                Class<?>[] parameterTypes = method.getParameterTypes();
                if (parameterTypes.length == 3) {
                    Class<?> viewType = parameterTypes[0];
                    Class<?> cellType = parameterTypes[1];
                    Class<?> clickIntType = parameterTypes[2];
                    if (View.class.isAssignableFrom(viewType) && BaseCell.class.isAssignableFrom(cellType)
                            && (clickIntType.equals(int.class) || clickIntType.equals(Integer.class))) {
                        mOnTraceMethods.put(viewType, new OnTraceMethod(3, method));
                    }/*from  w  w w.j ava2 s .  co m*/
                }
            }
        }
    }
}

From source file:com.tmall.wireless.tangram.support.SimpleClickSupport.java

private void findClickMethods(Method[] methods) {
    for (Method method : methods) {
        String methodName = method.getName();
        if (!methodName.equals(ON_CLICK_METHOD_NAME) && methodName.startsWith(ON_CLICK_METHOD_NAME)
                || (methodName.startsWith(ON_CLICK_METHOD_PREFIX)
                        && methodName.endsWith(ON_CLICK_METHOD_POSTFIX))) {
            int modifiers = method.getModifiers();
            if ((modifiers & Modifier.PUBLIC) != 0 && (modifiers & MODIFIERS_IGNORE) == 0) {
                Class<?>[] parameterTypes = method.getParameterTypes();
                if (parameterTypes.length == 3 || parameterTypes.length == 4) {
                    Class<?> viewType = parameterTypes[0];
                    Class<?> cellType = parameterTypes[1];
                    Class<?> clickIntType = parameterTypes[2];
                    if (View.class.isAssignableFrom(viewType) && BaseCell.class.isAssignableFrom(cellType)
                            && (clickIntType.equals(int.class) || clickIntType.equals(Integer.class))) {
                        if (parameterTypes.length == 4) {
                            Class<?> clickParamsType = parameterTypes[3];
                            if (Map.class.isAssignableFrom(clickParamsType)) {
                                mOnClickMethods.put(viewType, new OnClickMethod(4, method));
                            }/*  w ww  .  j a v  a  2 s  . c  om*/
                        } else {
                            mOnClickMethods.put(viewType, new OnClickMethod(3, method));
                        }
                    }
                }
            }
        }
    }
}

From source file:org.tinygroup.template.rumtime.TemplateUtil.java

/**
 * ?/*  w  w w  . ja  v a 2 s  .com*/
 *
 * @param object
 * @param name
 * @return
 * @throws TemplateException
 */
public static Object getAttribute(Object object, Object name) throws TemplateException {
    try {
        if (object instanceof Map) {
            Object value = ((Map) object).get(name);
            if (value != null) {
                return value;
            }
        }
        String fieldName = name.toString();
        Map<String, Method> stringMethodMap = methodCache.get(object.getClass());
        Method method = null;
        if (stringMethodMap != null) {
            method = stringMethodMap.get(fieldName);
        }
        if (method == null) {
            PropertyDescriptor descriptor = propertyUtilsBean.getPropertyDescriptor(object, fieldName);
            if (descriptor != null && descriptor.getReadMethod() != null) {
                method = object.getClass().getMethod(descriptor.getReadMethod().getName());
                method.setAccessible(true);
                if (stringMethodMap == null) {
                    stringMethodMap = new HashMap<String, Method>();
                    methodCache.put(object.getClass(), stringMethodMap);
                }
                stringMethodMap.put(fieldName, method);
            }
        }
        if (method != null) {
            return method.invoke(object);
        }
        Map<String, Field> stringFieldMap = fieldCache.get(fieldName);
        Field field = null;
        if (stringFieldMap != null) {
            field = stringFieldMap.get(fieldName);
        }
        if (field == null) {
            field = object.getClass().getField(fieldName);
            if (field != null) {
                if ((field.getModifiers() & Modifier.PUBLIC) == Modifier.PUBLIC) {
                    field.setAccessible(true);
                    if (stringFieldMap == null) {
                        stringFieldMap = new HashMap<String, Field>();
                        fieldCache.put(object.getClass(), stringFieldMap);
                    }
                    stringFieldMap.put(fieldName, field);
                } else {
                    field = null;
                }
            }
        }
        if (field != null) {
            return field.get(object);
        }
        throw new TemplateException(
                object.getClass().getName() + "?" + fieldName + "?");
    } catch (Exception e) {
        throw new TemplateException(e);
    }
}

From source file:com.manydesigns.portofino.reflection.ColumnAccessor.java

public int getModifiers() {
    return Modifier.PUBLIC;
}

From source file:de.micromata.tpsb.doc.parser.japa.ParserUtil.java

public static boolean ignoreClass(FileInfo fi) {
    if (TpsbEnvUtils.getAnnotation(fi, TpsbIgnore.class.getSimpleName()) != null) {
        return true;
    }//from w  w w.  j  a va2 s .  co  m
    if ((fi.getModifier() & Modifier.PUBLIC) != Modifier.PUBLIC) {
        return true;
    }
    return false;
}

From source file:com.tmall.wireless.tangram.support.ExposureSupport.java

private void findTraceMethods(Method[] methods) {
    for (Method method : methods) {
        String methodName = method.getName();
        if (!methodName.equals(ON_TRACE_METHOD_NAME) && methodName.startsWith(ON_TRACE_METHOD_NAME)
                || (methodName.startsWith(ON_TRACE_METHOD_PREFIX)
                        && methodName.endsWith(ON_TRACE_METHOD_POSTFIX))) {
            int modifiers = method.getModifiers();
            if ((modifiers & Modifier.PUBLIC) != 0 && (modifiers & MODIFIERS_IGNORE) == 0) {
                Class<?>[] parameterTypes = method.getParameterTypes();
                if (parameterTypes.length == 3) {
                    Class<?> viewType = parameterTypes[0];
                    Class<?> cellType = parameterTypes[1];
                    Class<?> clickIntType = parameterTypes[2];
                    if (View.class.isAssignableFrom(viewType) && BaseCell.class.isAssignableFrom(cellType)
                            && (clickIntType.equals(int.class) || clickIntType.equals(Integer.class))) {
                        mOnTraceMethods.put(viewType, new OnTraceMethod(3, method));
                    }//from  w w w. j a  v  a2s. co  m
                }
            }
        }
    }
}

From source file:com.hihframework.core.utils.ReflectUtil.java

public static final String[] getPublicMethodsName(Object obj) {
    return getMethodsName(obj, Modifier.PUBLIC, null);
}

From source file:org.gvnix.service.roo.addon.addon.ServiceOperationsImpl.java

/**
 * {@inheritDoc}//from w ww .j ava2 s .co m
 * <p>
 * Creates the body of the new method (the return line), checks the input
 * parameters if they exists and calls the 'createMethod' method from
 * {@link JavaParserService} to add into the class.
 * </p>
 */
public void addServiceOperation(JavaSymbolName operationName, JavaType returnType, JavaType className,
        List<JavaType> paramTypeList, List<String> paramNameList, List<JavaType> exceptionList) {

    InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder();

    // Create some method content to get the user started.
    String todoMessage = "// TODO: You have to place the method logic here.\n";
    bodyBuilder.appendFormalLine(todoMessage);

    // If return type != null we must add method body (return null);
    String returnLine = "return ".concat(returnType == null ? ";" : "null;");
    bodyBuilder.appendFormalLine(returnLine);

    // Parameter names
    List<JavaSymbolName> parameterNameList = new ArrayList<JavaSymbolName>();
    // Parameter types.
    List<AnnotatedJavaType> parameterTypeList = new ArrayList<AnnotatedJavaType>();

    Validate.isTrue(paramTypeList != null && paramTypeList.size() == paramNameList.size(),
            "The method parameter types must have the same number of parameter names to create the method.");

    if (paramNameList.size() > 0) {
        for (String parameterName : paramNameList) {
            parameterNameList.add(new JavaSymbolName(parameterName));
        }
    }

    if (paramTypeList != null && paramTypeList.size() > 0) {
        for (JavaType parameterType : paramTypeList) {
            parameterTypeList.add(new AnnotatedJavaType(parameterType, new ArrayList<AnnotationMetadata>()));
        }
    }

    javaParserService.createMethod(operationName, returnType, className, Modifier.PUBLIC, exceptionList,
            new ArrayList<AnnotationMetadata>(), parameterTypeList, parameterNameList, bodyBuilder.getOutput());
}

From source file:ca.digitalface.jasperoo.JasperooMetadata.java

/**
 * Create metadata for a method definition. 
 *
 * @return a MethodMetadata object/*from w ww.ja  v a  2 s .c  o m*/
 */
private MethodMetadata getReportableMethod() {
    // Specify the desired method name
    JavaSymbolName methodName = new JavaSymbolName("isReportable");

    // Check if a method with the same signature already exists in the target type
    MethodMetadata method = methodExists(methodName, new ArrayList<AnnotatedJavaType>());
    if (method != null) {
        // If it already exists, just return the method and omit its generation via the ITD
        return method;
    }

    // Define method annotations (none in this case)
    List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>();

    // Define method throws types (none in this case)
    List<JavaType> throwsTypes = new ArrayList<JavaType>();

    // Define method parameter types (none in this case)
    List<AnnotatedJavaType> parameterTypes = new ArrayList<AnnotatedJavaType>();

    // Define method parameter names (none in this case)
    List<JavaSymbolName> parameterNames = new ArrayList<JavaSymbolName>();

    // Create the method body
    InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder();
    //      bodyBuilder.appendFormalLine("reportable = true;");
    bodyBuilder.appendFormalLine("return true;");

    // Use the MethodMetadataBuilder for easy creation of MethodMetadata
    MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(getId(), Modifier.PUBLIC, methodName,
            JavaType.BOOLEAN_PRIMITIVE, parameterTypes, parameterNames, bodyBuilder);
    methodBuilder.setAnnotations(annotations);
    methodBuilder.setThrowsTypes(throwsTypes);

    return methodBuilder.build(); // Build and return a MethodMetadata instance
}