Example usage for org.apache.commons.attributes Attributes getAttribute

List of usage examples for org.apache.commons.attributes Attributes getAttribute

Introduction

In this page you can find the example usage for org.apache.commons.attributes Attributes getAttribute.

Prototype

public static Object getAttribute(Method method, Class attributeClass)
        throws RepositoryError, MultipleAttributesError 

Source Link

Document

Get one attributes of a given type from a method.

Usage

From source file:net.sf.sojo.optional.filter.attributes.ClassPropertyFilterHanlderForAttributes.java

private ClassPropertyFilter createClassPropertyFilter(Class<?> pvClass) {
    ClassPropertyFilter lvFilter = null;
    ClassAttribute lvClassAttribute = (ClassAttribute) Attributes.getAttribute(pvClass, ClassAttribute.class);
    if (lvClassAttribute != null) {
        lvFilter = new ClassPropertyFilter(pvClass);
        if (lvClassAttribute.getFilterUniqueId() == true) {
            lvFilter.addProperty(UniqueIdGenerator.UNIQUE_ID_PROPERTY);
        }// www  .  ja  v a  2  s  .  co  m
        lvFilter.setSupport4AddClassProperty(lvClassAttribute.getFilter4ClassProperty());

        createPropertyFilterForFieldAnnotation(lvFilter, pvClass);
        createPropertyFilterForPropertyAnnotation(lvFilter, pvClass);
    }
    classCache.put(pvClass, lvFilter);
    return lvFilter;
}

From source file:net.sf.sojo.optional.filter.attributes.ClassPropertyFilterHanlderForAttributes.java

private void createPropertyFilterForFieldAnnotation(final ClassPropertyFilter pvFilter, Class<?> pvClass) {
    Field lvFields[] = ReflectionFieldHelper.getAllFieldsByClass(pvClass);
    for (int i = 0; i < lvFields.length; i++) {
        Object lvPropertyAttribute = Attributes.getAttribute(lvFields[i], PropertyAttribute.class);
        if (lvPropertyAttribute != null) {
            pvFilter.addProperty(lvFields[i].getName());
        }/*from ww w . j  ava2  s.  c o m*/
    }
}

From source file:net.sf.sojo.optional.filter.attributes.ClassPropertyFilterHanlderForAttributes.java

private void createPropertyFilterForPropertyAnnotation(final ClassPropertyFilter pvFilter, Class<?> pvClass) {
    Map<?, ?> lvMethodMap = ReflectionMethodHelper.getAllGetterMethodWithCache(pvClass, null);
    for (Map.Entry<?, ?> lvEntry : lvMethodMap.entrySet()) {
        String lvPropertyName = (String) lvEntry.getKey();
        if (Util.getKeyWordClass().equals(lvPropertyName) == false) {
            Method lvMethod = (Method) lvEntry.getValue();
            Object lvPropertyAttribute = Attributes.getAttribute(lvMethod, PropertyAttribute.class);
            if (lvPropertyAttribute != null) {
                pvFilter.addProperty(lvPropertyName);
            }//from w ww .j a  va2  s .com
        } else if (pvFilter.getSupport4AddClassProperty()) {
            pvFilter.addProperty(lvPropertyName);
        }

    }
}