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


Java MethodUtils.invokeExactMethod方法代码示例

本文整理汇总了Java中org.apache.commons.lang3.reflect.MethodUtils.invokeExactMethod方法的典型用法代码示例。如果您正苦于以下问题:Java MethodUtils.invokeExactMethod方法的具体用法?Java MethodUtils.invokeExactMethod怎么用?Java MethodUtils.invokeExactMethod使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.lang3.reflect.MethodUtils的用法示例。


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

示例1: formatObjectGraph

import org.apache.commons.lang3.reflect.MethodUtils; //导入方法依赖的package包/类
@Override
public String formatObjectGraph(Object graph) throws ReflectiveOperationException, ClassCastException {
    StringBuilder out = new StringBuilder();
    Enumeration attrs = (Enumeration) MethodUtils.invokeExactMethod(graph, "getAttributeNames");
    @SuppressWarnings("unchecked")
    ArrayList<String> attrList = Collections.list(attrs);
    Collections.sort(attrList);
    out.append("{");
    int size = attrList.size();
    for (int i = 0; i < size; i++) {
        String attrName = attrList.get(i);
        Object attrValue = MethodUtils.invokeExactMethod(graph, "getAttribute", attrName);
        out.append(attrName);
        out.append('=');
        out.append(attrValue);
        if (i != size - 1) {
            out.append(",\n\n");
        }
    }
    out.append("}");
    return out.toString();
}
 
开发者ID:commercehub-oss,项目名称:clouseau,代码行数:23,代码来源:HttpSessionAttributesToString.java

示例2: addItemToCollection

import org.apache.commons.lang3.reflect.MethodUtils; //导入方法依赖的package包/类
private void addItemToCollection(Object object, String fieldName, Object value)
    throws IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException {
  Object collection = null;
  try {
    collection = FieldUtils.readField(object, fieldName);
    if (!(collection instanceof Collection)) {
      collection = null;
    }
  } catch (Exception e) {
    // Do nothing -> just using this to check if we have to use the field or the addXxxx() method
  }

  if (collection != null) {
    MethodUtils.invokeExactMethod(collection, "add", new Object[]{value}, new Class[]{Object.class});
  } else {
    MethodUtils.invokeExactMethod(object, "add" + StringUtils.capitalize(fieldName), value);
  }
}
 
开发者ID:DNSBelgium,项目名称:rdap-server-sample-gtld,代码行数:19,代码来源:AbstractWhoisParser.java

示例3: saveEntity

import org.apache.commons.lang3.reflect.MethodUtils; //导入方法依赖的package包/类
/**
 * @param dbEntities
 * @param aEntity
 * @throws SdiException
 */
private void saveEntity( List<Object> dbEntities, Object aEntity ) throws SdiException
{
    if ( myDryRun )
    {
        myLog.trace( "DryRun: Going to save entity: " + aEntity );

        try
        {
            MethodUtils.invokeExactMethod( aEntity, "setId", new Object[] { Long.valueOf( myDummyId ) } );
        }
        catch ( Throwable t )
        {
            throw new SdiException( "Entity has no 'setId( Long )' method", t, SdiException.EXIT_CODE_UNKNOWN_ERROR );
        }

        myDummyId++;
    }
    else
    {
        myLog.trace( "Going to save entity: " + aEntity );
        myEntityManager.persist( aEntity );
    } // if..else myDryRun

    dbEntities.add( aEntity );
}
 
开发者ID:heribender,项目名称:SocialDataImporter,代码行数:31,代码来源:OxSqlJob.java

示例4: getter

import org.apache.commons.lang3.reflect.MethodUtils; //导入方法依赖的package包/类
/**
 * Get property value from an object with the getter method.
 *
 * @param object the object where the property live in
 * @param fieldName property name
 * @return property value. {@code null} if the common java bean accessor method has tried.
 */
public static Object getter(final Object object,String fieldName){
    Object property = null;

    StringBuilder s = new StringBuilder("get");
    s.append(StringUtils.capitalize(fieldName));
    try{
        property = MethodUtils.invokeExactMethod(object,s.toString());
    }catch (Exception e){
        //try with isXXX
        StringBuilder s2 = new StringBuilder("is");
        s2.append(StringUtils.capitalize(fieldName));
        try{
            property = MethodUtils.invokeExactMethod(object,s2.toString());
        }catch (Exception ee){
            LOG.error("Exception",ee);
        }
    }
    return property;
}
 
开发者ID:yaohuiwu,项目名称:CAM,代码行数:27,代码来源:ObjectUtils.java

示例5: validate

import org.apache.commons.lang3.reflect.MethodUtils; //导入方法依赖的package包/类
@Override
public T validate(String input) {
    Object result = null;
    V validator = getValidator();

    try {
        result = (Boolean) MethodUtils.invokeExactMethod(
                validator, VALIDATE_METHOD_NAME, input);
    } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
        Logger.getLogger(AbstractFormValidator.class.getName()).log(Level.SEVERE, null, ex);
    }

    if (result != null) {
        return (T) result;
    }

    return null;
}
 
开发者ID:moosbusch,项目名称:Lumpi,代码行数:19,代码来源:AbstractFormValidator.java

示例6: invokeSingleCommand

import org.apache.commons.lang3.reflect.MethodUtils; //导入方法依赖的package包/类
private void invokeSingleCommand(Command command) {

		try {
			MethodUtils.invokeExactMethod(commandService, "handle", command);
		}
		catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
			throw new IllegalStateException(e.getMessage(), e);
		}
	}
 
开发者ID:bilu,项目名称:yaess,代码行数:10,代码来源:BDDTest.java

示例7: formatObjectGraph

import org.apache.commons.lang3.reflect.MethodUtils; //导入方法依赖的package包/类
@Override
public String formatObjectGraph(Object graph) throws ReflectiveOperationException, ClassCastException {
    Enumeration attrs = (Enumeration) MethodUtils.invokeExactMethod(graph, "getAttributeNames");
    ArrayList attrList = Collections.list(attrs);
    Collections.sort(attrList);
    return attrList.toString();
}
 
开发者ID:commercehub-oss,项目名称:clouseau,代码行数:8,代码来源:HttpSessionAttributeNames.java

示例8: value

import org.apache.commons.lang3.reflect.MethodUtils; //导入方法依赖的package包/类
/** Calls the value() method of the given enum. */
public static <E extends Enum<E>> String value(E type) /*throws NoSuchMethodException, IllegalAccessException, InvocationTargetException*/ {
	try {
		return (String) MethodUtils.invokeExactMethod(type, "value", 
			new Object[]{});
	} catch (Exception e) {
		return null;
	}
}
 
开发者ID:Transkribus,项目名称:TranskribusCore,代码行数:10,代码来源:EnumUtils.java

示例9: getStr

import org.apache.commons.lang3.reflect.MethodUtils; //导入方法依赖的package包/类
public static <E extends Enum<E>> String getStr(E type) /*throws NoSuchMethodException, IllegalAccessException, InvocationTargetException*/ {
	try {
		return (String) MethodUtils.invokeExactMethod(type, "getStr", 
			new Object[]{});
	} catch (Exception e) {
		return null;
	}
}
 
开发者ID:Transkribus,项目名称:TranskribusCore,代码行数:9,代码来源:EnumUtils.java

示例10: isValid

import org.apache.commons.lang3.reflect.MethodUtils; //导入方法依赖的package包/类
@Override
public boolean isValid(String input) {
    Boolean result = Boolean.FALSE;
    V validator = getValidator();

    try {
        result = (Boolean) MethodUtils.invokeExactMethod(
                validator, IS_VALID_METHOD_NAME, input);
    } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
        Logger.getLogger(AbstractFormValidator.class.getName()).log(Level.SEVERE, null, ex);
    }

    return result;
}
 
开发者ID:moosbusch,项目名称:Lumpi,代码行数:15,代码来源:AbstractFormValidator.java


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