当前位置: 首页>>代码示例>>Java>>正文


Java CachedClass类代码示例

本文整理汇总了Java中org.codehaus.groovy.reflection.CachedClass的典型用法代码示例。如果您正苦于以下问题:Java CachedClass类的具体用法?Java CachedClass怎么用?Java CachedClass使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CachedClass类属于org.codehaus.groovy.reflection包,在下文中一共展示了CachedClass类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: chooseEmptyMethodParams

import org.codehaus.groovy.reflection.CachedClass; //导入依赖的package包/类
/**
 * @param methods the methods to choose from
 * @return the method with 1 parameter which takes the most general type of
 *         object (e.g. Object)
 */
public static Object chooseEmptyMethodParams(FastArray methods) {
    Object vargsMethod = null;
    final int len = methods.size();
    final Object[] data = methods.getArray();
    for (int i = 0; i != len; ++i) {
        Object method = data[i];
        final ParameterTypes pt = (ParameterTypes) method;
        CachedClass[] paramTypes = pt.getParameterTypes();
        int paramLength = paramTypes.length;
        if (paramLength == 0) {
            return method;
        } else if (paramLength == 1 && pt.isVargsMethod(EMPTY_ARRAY)) {
            vargsMethod = method;
        }
    }
    return vargsMethod;
}
 
开发者ID:yajsw,项目名称:yajsw,代码行数:23,代码来源:MetaClassHelper.java

示例2: containsMatchingMethod

import org.codehaus.groovy.reflection.CachedClass; //导入依赖的package包/类
/**
 * @param list   a list of MetaMethods
 * @param method the MetaMethod of interest
 * @return true if a method of the same matching prototype was found in the
 *         list
 */
public static boolean containsMatchingMethod(List list, MetaMethod method) {
    for (Object aList : list) {
        MetaMethod aMethod = (MetaMethod) aList;
        CachedClass[] params1 = aMethod.getParameterTypes();
        CachedClass[] params2 = method.getParameterTypes();
        if (params1.length == params2.length) {
            boolean matches = true;
            for (int i = 0; i < params1.length; i++) {
                if (params1[i] != params2[i]) {
                    matches = false;
                    break;
                }
            }
            if (matches) {
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:yajsw,项目名称:yajsw,代码行数:27,代码来源:MetaClassHelper.java

示例3: applyUse

import org.codehaus.groovy.reflection.CachedClass; //导入依赖的package包/类
private void applyUse(CachedClass cachedClass) {
    CachedMethod[] methods = cachedClass.getMethods();
    for (CachedMethod cachedMethod : methods) {
        if (cachedMethod.isStatic() && cachedMethod.isPublic()) {
            CachedClass[] paramTypes = cachedMethod.getParameterTypes();
            if (paramTypes.length > 0) {
                CachedClass metaClass = paramTypes[0];
                CategoryMethod mmethod = new CategoryMethod(cachedMethod, metaClass.getTheClass());
                final String name = cachedMethod.getName();
                CategoryMethodList list = get(name);
                if (list == null || list.level != level) {
                    list = new CategoryMethodList(name, level, list);
                    put(name, list);
                }
                list.add(mmethod);
                Collections.sort(list);
                cachePropertyAccessor(mmethod);
            }
        }
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:22,代码来源:GroovyCategorySupport.java

示例4: isMatchingMethod

import org.codehaus.groovy.reflection.CachedClass; //导入依赖的package包/类
private static boolean isMatchingMethod(MetaMethod aMethod, MetaMethod method) {
    if (aMethod==method) return true;
    CachedClass[] params1 = aMethod.getParameterTypes();
    CachedClass[] params2 = method.getParameterTypes();
    if (params1.length != params2.length) {
        return false;
    }

    boolean matches = true;
    for (int i = 0; i < params1.length; i++) {
        if (params1[i] != params2[i]) {
            matches = false;
            break;
        }
    }
    return matches;
}
 
开发者ID:apache,项目名称:groovy,代码行数:18,代码来源:MetaMethodIndex.java

示例5: methodInfo

import org.codehaus.groovy.reflection.CachedClass; //导入依赖的package包/类
protected String[] methodInfo(MetaMethod method) {
    String[] result = new String[MEMBER_EXCEPTIONS_IDX + 1];
    int mod = method.getModifiers();
    result[MEMBER_ORIGIN_IDX] = GROOVY;
    result[MEMBER_MODIFIER_IDX] = Modifier.toString(mod);
    result[MEMBER_DECLARER_IDX] = shortName(method.getDeclaringClass().getTheClass());
    result[MEMBER_TYPE_IDX] = shortName(method.getReturnType());
    result[MEMBER_NAME_IDX] = method.getName();
    CachedClass[] params = method.getParameterTypes();
    StringBuilder sb = new StringBuilder();
    for (int j = 0; j < params.length; j++) {
        sb.append(shortName(params[j].getTheClass()));
        if (j < (params.length - 1)) sb.append(", ");
    }
    result[MEMBER_PARAMS_IDX] = sb.toString();
    result[MEMBER_EXCEPTIONS_IDX] = NOT_APPLICABLE; // no exception info for Groovy MetaMethods
    return withoutNulls(result);
}
 
开发者ID:apache,项目名称:groovy,代码行数:19,代码来源:Inspector.java

示例6: getMetaProperty

import org.codehaus.groovy.reflection.CachedClass; //导入依赖的package包/类
/**
 * @see MetaObjectProtocol#getMetaProperty(String)
 */
public MetaProperty getMetaProperty(String name) {
    SingleKeyHashMap propertyMap = classPropertyIndex.getNotNull(theCachedClass);
    if (propertyMap.containsKey(name)) {
        return (MetaProperty) propertyMap.get(name);
    } else if (staticPropertyIndex.containsKey(name)) {
        return (MetaProperty) staticPropertyIndex.get(name);
    } else {
        propertyMap = classPropertyIndexForSuper.getNotNull(theCachedClass);
        if (propertyMap.containsKey(name))
            return (MetaProperty) propertyMap.get(name);
        else {
            CachedClass superClass = theCachedClass;
            while (superClass != null && superClass != ReflectionCache.OBJECT_CLASS) {
                final MetaBeanProperty property = findPropertyInClassHierarchy(name, superClass);
                if (property != null) {
                    onSuperPropertyFoundInHierarchy(property);
                    return property;
                }
                superClass = superClass.getCachedSuperClass();
            }
            return null;
        }
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:28,代码来源:MetaClassImpl.java

示例7: fillMethodIndex

import org.codehaus.groovy.reflection.CachedClass; //导入依赖的package包/类
/**
 * Fills the method index
 */
private void fillMethodIndex() {
    mainClassMethodHeader = metaMethodIndex.getHeader(theClass);
    LinkedList<CachedClass> superClasses = getSuperClasses();
    CachedClass firstGroovySuper = calcFirstGroovySuperClass(superClasses);

    Set<CachedClass> interfaces = theCachedClass.getInterfaces();
    addInterfaceMethods(interfaces);

    populateMethods(superClasses, firstGroovySuper);

    inheritInterfaceNewMetaMethods(interfaces);
    if (isGroovyObject) {
      metaMethodIndex.copyMethodsToSuper();

      connectMultimethods(superClasses, firstGroovySuper);
      removeMultimethodsOverloadedWithPrivateMethods();

      replaceWithMOPCalls(theCachedClass.mopMethods);
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:24,代码来源:MetaClassImpl.java

示例8: connectMultimethods

import org.codehaus.groovy.reflection.CachedClass; //导入依赖的package包/类
private void connectMultimethods(List<CachedClass> superClasses, CachedClass firstGroovyClass) {
    superClasses = DefaultGroovyMethods.reverse(superClasses);
    MetaMethodIndex.Header last = null;
    for (final CachedClass c : superClasses) {
        MetaMethodIndex.Header methodIndex = metaMethodIndex.getHeader(c.getTheClass());
        // We don't copy DGM methods to superclasses' indexes
        // The reason we can do that is particular set of DGM methods in use,
        // if at some point we will define DGM method for some Groovy class or
        // for a class derived from such, we will need to revise this condition.
        // It saves us a lot of space and some noticeable time
        if (last != null) metaMethodIndex.copyNonPrivateNonNewMetaMethods(last, methodIndex);
        last = methodIndex;

        if (c == firstGroovyClass)
            break;
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:18,代码来源:MetaClassImpl.java

示例9: getCategoryMethodGetter

import org.codehaus.groovy.reflection.CachedClass; //导入依赖的package包/类
private static MetaMethod getCategoryMethodGetter(Class sender, String name, boolean useLongVersion) {
    List possibleGenericMethods = GroovyCategorySupport.getCategoryMethods(name);
    if (possibleGenericMethods != null) {
        for (Iterator iter = possibleGenericMethods.iterator(); iter.hasNext();) {
            MetaMethod mmethod = (MetaMethod) iter.next();
            if (!mmethod.getDeclaringClass().getTheClass().isAssignableFrom(sender))
              continue;

            CachedClass[] paramTypes = mmethod.getParameterTypes();
            if (useLongVersion) {
                if (paramTypes.length == 1 && paramTypes[0].getTheClass() == String.class) {
                    return mmethod;
                }
            } else {
                if (paramTypes.length == 0) return mmethod;
            }
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:groovy,代码行数:21,代码来源:MetaClassImpl.java

示例10: getCategoryMethodSetter

import org.codehaus.groovy.reflection.CachedClass; //导入依赖的package包/类
private static MetaMethod getCategoryMethodSetter(Class sender, String name, boolean useLongVersion) {
    List possibleGenericMethods = GroovyCategorySupport.getCategoryMethods(name);
    if (possibleGenericMethods != null) {
        for (Iterator iter = possibleGenericMethods.iterator(); iter.hasNext();) {
            MetaMethod mmethod = (MetaMethod) iter.next();
            if (!mmethod.getDeclaringClass().getTheClass().isAssignableFrom(sender))
              continue;

            CachedClass[] paramTypes = mmethod.getParameterTypes();
            if (useLongVersion) {
                if (paramTypes.length == 2 && paramTypes[0].getTheClass() == String.class) {
                    return mmethod;
                }
            } else {
                if (paramTypes.length == 1) return mmethod;
            }
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:groovy,代码行数:21,代码来源:MetaClassImpl.java

示例11: getMatchKindForCategory

import org.codehaus.groovy.reflection.CachedClass; //导入依赖的package包/类
/**
 * return false: add method
 *        null:  ignore method
 *        true:  replace
 */
private static Boolean getMatchKindForCategory(MetaMethod aMethod, MetaMethod categoryMethod) {
    CachedClass[] params1 = aMethod.getParameterTypes();
    CachedClass[] params2 = categoryMethod.getParameterTypes();
    if (params1.length != params2.length) return Boolean.FALSE;

    for (int i = 0; i < params1.length; i++) {
        if (params1[i] != params2[i]) return Boolean.FALSE;
    }

    Class aMethodClass = aMethod.getDeclaringClass().getTheClass();
    Class categoryMethodClass = categoryMethod.getDeclaringClass().getTheClass();

    if (aMethodClass==categoryMethodClass) return Boolean.TRUE;
    boolean match = aMethodClass.isAssignableFrom(categoryMethodClass);
    if (match) return Boolean.TRUE;
    return null;
}
 
开发者ID:apache,项目名称:groovy,代码行数:23,代码来源:MetaClassImpl.java

示例12: findMatchingMethod

import org.codehaus.groovy.reflection.CachedClass; //导入依赖的package包/类
private int findMatchingMethod(CachedMethod[] data, int from, int to, MetaMethod method) {
    for (int j = from; j <= to; ++j) {
        CachedMethod aMethod = data[j];
        CachedClass[] params1 = aMethod.getParameterTypes();
        CachedClass[] params2 = method.getParameterTypes();
        if (params1.length == params2.length) {
            boolean matches = true;
            for (int i = 0; i < params1.length; i++) {
                if (params1[i] != params2[i]) {
                    matches = false;
                    break;
                }
            }
            if (matches) {
                return j;
            }
        }
    }
    return -1;
}
 
开发者ID:apache,项目名称:groovy,代码行数:21,代码来源:MetaClassImpl.java

示例13: findPropertyInClassHierarchy

import org.codehaus.groovy.reflection.CachedClass; //导入依赖的package包/类
protected MetaBeanProperty findPropertyInClassHierarchy(String propertyName, CachedClass theClass) {
    MetaBeanProperty property= null;
    if (theClass == null)
        return null;

    final CachedClass superClass = theClass.getCachedSuperClass();
    if (superClass == null)
      return null;

    MetaClass metaClass = this.registry.getMetaClass(superClass.getTheClass());
    if(metaClass instanceof MutableMetaClass) {
        property = getMetaPropertyFromMutableMetaClass(propertyName,metaClass);
        if(property == null) {
            if(superClass != ReflectionCache.OBJECT_CLASS) {
                property = findPropertyInClassHierarchy(propertyName, superClass);
            }
            if(property == null) {
                final Class[] interfaces = theClass.getTheClass().getInterfaces();
                property = searchInterfacesForMetaProperty(propertyName, interfaces);
            }
        }
    }
    return property;

}
 
开发者ID:apache,项目名称:groovy,代码行数:26,代码来源:MetaClassImpl.java

示例14: getSignature

import org.codehaus.groovy.reflection.CachedClass; //导入依赖的package包/类
/**
 * Returns the signature of this method
 *
 * @return The signature of this method
 */
public synchronized String getSignature() {
    if (signature == null) {
        CachedClass [] parameters = getParameterTypes();
        final String name = getName();
        StringBuilder buf = new StringBuilder(name.length()+parameters.length*10);
        buf.append(getReturnType().getName());
        
        buf.append(' ');
        buf.append(name);
        buf.append('(');
        for (int i = 0; i < parameters.length; i++) {
            if (i > 0) {
                buf.append(", ");
            }
            buf.append(parameters[i].getName());
        }
        buf.append(')');
        signature = buf.toString();
    }
    return signature;
}
 
开发者ID:apache,项目名称:groovy,代码行数:27,代码来源:MetaMethod.java

示例15: registerBeanProperty

import org.codehaus.groovy.reflection.CachedClass; //导入依赖的package包/类
/**
 * Registers a new bean property
 *
 * @param property The property name
 * @param newValue The properties initial value
 */
public void registerBeanProperty(final String property, final Object newValue) {
    performOperationOnMetaClass(new Callable() {
        public void call() {
            Class type = newValue == null ? Object.class : newValue.getClass();

            MetaBeanProperty mbp = newValue instanceof MetaBeanProperty ? (MetaBeanProperty) newValue : new ThreadManagedMetaBeanProperty(theClass, property, type, newValue);

            final MetaMethod getter = mbp.getGetter();
            final MethodKey getterKey = new DefaultCachedMethodKey(theClass, getter.getName(), CachedClass.EMPTY_ARRAY, false);
            final MetaMethod setter = mbp.getSetter();
            final MethodKey setterKey = new DefaultCachedMethodKey(theClass, setter.getName(), setter.getParameterTypes(), false);
            addMetaMethod(getter);
            addMetaMethod(setter);

            expandoMethods.put(setterKey, setter);
            expandoMethods.put(getterKey, getter);
            expandoProperties.put(mbp.getName(), mbp);

            addMetaBeanProperty(mbp);
            performRegistryCallbacks();
        }

    });
}
 
开发者ID:apache,项目名称:groovy,代码行数:31,代码来源:ExpandoMetaClass.java


注:本文中的org.codehaus.groovy.reflection.CachedClass类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。