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


Java ClassUtils类代码示例

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


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

示例1: getInterfaces

import org.apache.commons.lang.ClassUtils; //导入依赖的package包/类
/**
 * Get a set of all of the interfaces that the element_class implements
 * 
 * @param element_class
 * @return
 */
@SuppressWarnings("unchecked")
public static Collection<Class<?>> getInterfaces(Class<?> element_class) {
    Set<Class<?>> ret = ClassUtil.CACHE_getInterfaceClasses.get(element_class);
    if (ret == null) {
        // ret = new HashSet<Class<?>>();
        // Queue<Class<?>> queue = new LinkedList<Class<?>>();
        // queue.add(element_class);
        // while (!queue.isEmpty()) {
        // Class<?> current = queue.poll();
        // for (Class<?> i : current.getInterfaces()) {
        // ret.add(i);
        // queue.add(i);
        // } // FOR
        // } // WHILE
        ret = new HashSet<Class<?>>(ClassUtils.getAllInterfaces(element_class));
        if (element_class.isInterface())
            ret.add(element_class);
        ret = Collections.unmodifiableSet(ret);
        ClassUtil.CACHE_getInterfaceClasses.put(element_class, ret);
    }
    return (ret);
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:29,代码来源:ClassUtil.java

示例2: TotoroBootStrap

import org.apache.commons.lang.ClassUtils; //导入依赖的package包/类
public TotoroBootStrap(final Properties conf) throws UnknownHostException {

        CanalConf canalConf = getCanalConf(conf);
        EsConf esConf = getEsConf(conf);
        int transThreadNum = getTransThreadNum(conf);
        //totoroSelector需要提前初始化好
        totoroSelector = new CanalEmbedSelector(canalConf);
        //初始化 Channel
        initChannel();
        //初始化 SelectorTask
        SelectorTask selectorTask = initSelectorTask();
        //初始化 TransFormTask
        TransFormTask transFormTask = initTransFormTask(canalConf, transThreadNum);
        //初始化 ConsumerTask
        ConsumerTask consumerTask = initConsumerTask(esConf);

        taskMap.put(ClassUtils.getShortClassName(SelectorTask.class), selectorTask);
        taskMap.put(ClassUtils.getShortClassName(TransFormTask.class), transFormTask);
        taskMap.put(ClassUtils.getShortClassName(ConsumerTask.class), consumerTask);


        logger.info("Totoro init complete .......");
    }
 
开发者ID:zhongchengxcr,项目名称:canal-elasticsearch,代码行数:24,代码来源:TotoroBootStrap.java

示例3: getPrimitivePromotionCost

import org.apache.commons.lang.ClassUtils; //导入依赖的package包/类
/**
 * Get the number of steps required to promote a primitive number to another
 * type.
 * @param srcClass the (primitive) source class
 * @param destClass the (primitive) destination class
 * @return The cost of promoting the primitive
 */
private static float getPrimitivePromotionCost(final Class srcClass, final Class destClass) {
    float cost = 0.0f;
    Class cls = srcClass;
    if (!cls.isPrimitive()) {
        // slight unwrapping penalty
        cost += 0.1f;
        cls = ClassUtils.wrapperToPrimitive(cls);
    }
    for (int i = 0; cls != destClass && i < ORDERED_PRIMITIVE_TYPES.length; i++) {
        if (cls == ORDERED_PRIMITIVE_TYPES[i]) {
            cost += 0.1f;
            if (i < ORDERED_PRIMITIVE_TYPES.length - 1) {
                cls = ORDERED_PRIMITIVE_TYPES[i + 1];
            }
        }
    }
    return cost;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:MemberUtils.java

示例4: accept

import org.apache.commons.lang.ClassUtils; //导入依赖的package包/类
/**
 * Returns whether or not to append the given <code>Field</code>.
 * <ul>
 * <li>Transient fields are appended only if {@link #isAppendTransients()} returns <code>true</code>.
 * <li>Static fields are appended only if {@link #isAppendStatics()} returns <code>true</code>.
 * <li>Inner class fields are not appened.</li>
 * </ul>
 * 
 * @param field
 *            The Field to test.
 * @return Whether or not to append the given <code>Field</code>.
 */
protected boolean accept(Field field) {
    if (field.getName().indexOf(ClassUtils.INNER_CLASS_SEPARATOR_CHAR) != -1) {
        // Reject field from inner class.
        return false;
    }
    if (Modifier.isTransient(field.getModifiers()) && !this.isAppendTransients()) {
        // Reject transient fields.
        return false;
    }
    if (Modifier.isStatic(field.getModifiers()) && !this.isAppendStatics()) {
        // Reject static fields.
        return false;
    }
    if (this.getExcludeFieldNames() != null
        && Arrays.binarySearch(this.getExcludeFieldNames(), field.getName()) >= 0) {
        // Reject fields from the getExcludeFieldNames list.
        return false;
    }
    return true;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:33,代码来源:ReflectionToStringBuilder.java

示例5: dump

import org.apache.commons.lang.ClassUtils; //导入依赖的package包/类
/**
 * 记录请求信息
 * 
 * @param methodInvocation
 * @param take
 */
private void dump(MethodInvocation methodInvocation, Object result, long take) {
    // 取得日志打印对象
    Logger log = getLogger(methodInvocation.getMethod().getDeclaringClass());
    Object[] args = methodInvocation.getArguments();
    StringBuffer buffer = getArgsString(args);

    if (log.isInfoEnabled()) {
        String className = ClassUtils.getShortClassName(methodInvocation.getMethod().getDeclaringClass());
        String methodName = methodInvocation.getMethod().getName();
        String resultStr = getResultString(result);

        String now = new SimpleDateFormat(DATA_FORMAT).format(new Date());
        log.info(MessageFormat.format(MESSAGE, new Object[] { className, methodName, now, take, buffer.toString(),
                resultStr }));
    }
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:23,代码来源:LogInterceptor.java

示例6: compareReply

import org.apache.commons.lang.ClassUtils; //导入依赖的package包/类
/**
 * 将当前的符合条件的processIds和当前的reply queue进行校对,剔除不在processIds里的内容
 */
private synchronized void compareReply(List<Long> processIds, ReplyProcessQueue replyProcessIds) {
    Object[] replyIds = replyProcessIds.toArray();
    for (Object replyId : replyIds) {
        if (processIds.contains((Long) replyId) == false) { // 判断reply id是否在当前processId列表中
            // 因为存在并发问题,如在执行Listener事件的同时,可能触发了process的创建,这时新建的processId会进入到reply队列中
            // 此时接受到的processIds变量为上一个版本的内容,所以会删除新建的process,导致整个通道被挂住
            if (CollectionUtils.isEmpty(processIds) == false) {
                Long processId = processIds.get(0);
                if (processId > (Long) replyId) { // 如果当前最小的processId都大于replyId, processId都是递增创建的
                    logger.info("## {} remove reply id [{}]", ClassUtils.getShortClassName(this.getClass()),
                                (Long) replyId);
                    replyProcessIds.remove((Long) replyId);
                    progress.remove((Long) replyId);
                }
            }
        }
    }
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:22,代码来源:RpcStageController.java

示例7: compareReply

import org.apache.commons.lang.ClassUtils; //导入依赖的package包/类
/**
 * 将当前的符合条件的processIds和当前的reply queue进行校对,剔除不在processIds里的内容
 */
protected synchronized void compareReply(List<Long> processIds) {
    Object[] replyIds = replyProcessIds.toArray();
    for (Object replyId : replyIds) {
        if (processIds.contains((Long) replyId) == false) { // 判断reply id是否在当前processId列表中
            // 因为存在并发问题,如在执行Listener事件的同时,可能触发了process的创建,这时新建的processId会进入到reply队列中
            // 此时接受到的processIds变量为上一个版本的内容,所以会删除新建的process,导致整个通道被挂住
            if (CollectionUtils.isEmpty(processIds) == false) {
                Long processId = processIds.get(0);
                if (processId > (Long) replyId) { // 如果当前最小的processId都大于replyId, processId都是递增创建的
                    logger.info("## {} remove reply id [{}]", ClassUtils.getShortClassName(this.getClass()),
                                (Long) replyId);
                    replyProcessIds.remove((Long) replyId);
                }
            }
        }
    }
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:21,代码来源:AbstractProcessListener.java

示例8: getInterfaces

import org.apache.commons.lang.ClassUtils; //导入依赖的package包/类
/**
     * Get a set of all of the interfaces that the element_class implements
     * @param element_class
     * @return
     */
    @SuppressWarnings("unchecked")
    public static Collection<Class<?>> getInterfaces(Class<?> element_class) {
        Set<Class<?>> ret = ClassUtil.CACHE_getInterfaceClasses.get(element_class);
        if (ret == null) {
//            ret = new HashSet<Class<?>>();
//            Queue<Class<?>> queue = new LinkedList<Class<?>>();
//            queue.add(element_class);
//            while (!queue.isEmpty()) {
//                Class<?> current = queue.poll();
//                for (Class<?> i : current.getInterfaces()) {
//                    ret.add(i);
//                    queue.add(i);
//                } // FOR
//            } // WHILE
            ret = new HashSet<Class<?>>(ClassUtils.getAllInterfaces(element_class));
            if (element_class.isInterface()) ret.add(element_class);
            ret = Collections.unmodifiableSet(ret);
            ClassUtil.CACHE_getInterfaceClasses.put(element_class, ret);
        }
        return (ret);
    }
 
开发者ID:faclc4,项目名称:HTAPBench,代码行数:27,代码来源:ClassUtil.java

示例9: RegionServerEnvironment

import org.apache.commons.lang.ClassUtils; //导入依赖的package包/类
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value="BC_UNCONFIRMED_CAST",
    justification="Intentional; FB has trouble detecting isAssignableFrom")
public RegionServerEnvironment(final Class<?> implClass,
    final Coprocessor impl, final int priority, final int seq,
    final Configuration conf, final RegionServerServices services) {
  super(impl, priority, seq, conf);
  this.regionServerServices = services;
  for (Object itf : ClassUtils.getAllInterfaces(implClass)) {
    Class<?> c = (Class<?>) itf;
    if (SingletonCoprocessorService.class.isAssignableFrom(c)) {// FindBugs: BC_UNCONFIRMED_CAST
      this.regionServerServices.registerService(
        ((SingletonCoprocessorService) impl).getService());
      break;
    }
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:17,代码来源:RegionServerCoprocessorHost.java

示例10: getTickMethod

import org.apache.commons.lang.ClassUtils; //导入依赖的package包/类
private static TickMethod getTickMethod(Class clazz, Method method) {
    // Order of list is from bottom (subclass) to top (superclass).
    List<Class> superclasses = (List<Class>) ClassUtils.getAllSuperclasses(clazz);
    superclasses.add(0, clazz);
    // Loop over clazz and its superclasses
    for (Class superclass : superclasses) {
        // find and iterate over the current class' tick methods, if it has any.
        for (TickMethod tickMethod : CLASS_TICK_METHODS.get(superclass)) {
            // if the superclass TickMethod has the same method as ours, return it.
            if (ReflectionUtils.sameMethodSignature(method, tickMethod.method)) {
                return tickMethod;
            }
        }
    }
    return null;
}
 
开发者ID:BlurEngine,项目名称:Blur,代码行数:17,代码来源:TickMethodsCache.java

示例11: call

import org.apache.commons.lang.ClassUtils; //导入依赖的package包/类
@Override
public Object call(Context context, List args) throws FunctionCallException {
    try {
        String clazzName = (String) (args.get(0));
        String methodName = (String) (args.get(1));
        LOGGER.info("XEditor extension function calling {} {}", clazzName, methodName);

        Class[] argTypes = new Class[args.size() - 2];
        Object[] params = new Object[args.size() - 2];
        for (int i = 0; i < argTypes.length; i++) {
            argTypes[i] = args.get(i + 2).getClass();
            params[i] = args.get(i + 2);
        }

        Class clazz = ClassUtils.getClass(clazzName);
        Method method = MethodUtils.getMatchingAccessibleMethod(clazz, methodName, argTypes);
        return method.invoke(null, params);
    } catch (Exception ex) {
        LOGGER.warn("Exception in call to external java method", ex);
        return ex.getMessage();
    }
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:23,代码来源:MCRFunctionCallJava.java

示例12: MCRCommand

import org.apache.commons.lang.ClassUtils; //导入依赖的package包/类
public MCRCommand(Method cmd) {
    className = cmd.getDeclaringClass().getName();
    methodName = cmd.getName();
    parameterTypes = cmd.getParameterTypes();
    org.mycore.frontend.cli.annotation.MCRCommand cmdAnnotation = cmd
        .getAnnotation(org.mycore.frontend.cli.annotation.MCRCommand.class);
    help = cmdAnnotation.help();
    messageFormat = new MessageFormat(cmdAnnotation.syntax(), Locale.ROOT);
    setMethod(cmd);

    for (int i = 0; i < parameterTypes.length; i++) {
        Class<?> paramtype = parameterTypes[i];
        if (ClassUtils.isAssignable(paramtype, Integer.class, true)
            || ClassUtils.isAssignable(paramtype, Long.class, true)) {
            messageFormat.setFormat(i, NumberFormat.getIntegerInstance(Locale.ROOT));
        } else if (!String.class.isAssignableFrom(paramtype)) {
            unsupportedArgException(className + "." + methodName, paramtype.getName());
        }
    }

    int pos = cmdAnnotation.syntax().indexOf("{");
    suffix = pos == -1 ? cmdAnnotation.syntax() : cmdAnnotation.syntax().substring(0, pos);
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:24,代码来源:MCRCommand.java

示例13: populateBean

import org.apache.commons.lang.ClassUtils; //导入依赖的package包/类
private <T> T populateBean(final T resultBean, List<Object> processedColumns, BeanCells cells) {
    for (int i = 0; i < processedColumns.size(); i++) {
        final Object fieldValue = processedColumns.get(i);

        BeanCell cell = cells.getCell(i);
        if (cell == null || cell.getType() == null) {
            continue;
        }

        // ClassUtils handles boxed types
        if (fieldValue != null && ClassUtils.isAssignable(fieldValue.getClass(), cell.getType(), true)) {
            cell.setValue(resultBean, fieldValue);
        } else {
            Class<?> fieldValueClass = fieldValue == null ? Object.class : fieldValue.getClass();
            TypeConverter<Object, Object> converter
                    = (TypeConverter<Object, Object>) typeConverterRegistry.getConverter(fieldValueClass, cell.getType());
            if (converter == null) {
                throw new SuperCsvException(Form.at("No converter registered from type {} to type {}. Add one or fix your CellProcessor-annotations to return the field's type",
                        fieldValueClass.getName(), cell.getType().getName()));
            }
            cell.setValue(resultBean, converter.convert(fieldValue));
        }
    }

    return resultBean;
}
 
开发者ID:dmn1k,项目名称:super-csv-declarative,代码行数:27,代码来源:CsvDeclarativeBeanReader.java

示例14: read

import org.apache.commons.lang.ClassUtils; //导入依赖的package包/类
@Override
public Object read(Kryo kryo, Input input, Class type) {
    try {
        ObjectMap graphContext = kryo.getGraphContext();
        ObjectInputStream objectStream = (ObjectInputStream) graphContext.get(this);
        if (objectStream == null) {
            objectStream = new ObjectInputStream(input) {
                @Override
                protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException {
                    return ClassUtils.getClass(KryoSerialization.class.getClassLoader(), desc.getName());
                }
            };
            graphContext.put(this, objectStream);
        }
        return objectStream.readObject();
    } catch (Exception ex) {
        throw new KryoException("Error during Java deserialization.", ex);
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:20,代码来源:KryoSerialization.java

示例15: propertyBelongsTo

import org.apache.commons.lang.ClassUtils; //导入依赖的package包/类
private boolean propertyBelongsTo(Field field, MetaProperty metaProperty, List<Class> systemInterfaces) {
    String getterName = "get" + StringUtils.capitalize(metaProperty.getName());

    Class<?> aClass = field.getDeclaringClass();
    //noinspection unchecked
    List<Class> allInterfaces = ClassUtils.getAllInterfaces(aClass);
    for (Class intf : allInterfaces) {
        Method[] methods = intf.getDeclaredMethods();
        for (Method method : methods) {
            if (method.getName().equals(getterName) && method.getParameterTypes().length == 0) {
                if (systemInterfaces.contains(intf))
                    return true;
            }
        }
    }
    return false;
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:18,代码来源:MetaModelLoader.java


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