當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。