Package org.apache.felix.gogo.runtime
Class Reflective
java.lang.Object
org.apache.felix.gogo.runtime.Reflective
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Objectcoerce(CommandSession session, Class<?> type, Object arg, int[] convert) converts given argument to specified type and increments convert[0] if any conversion was needed.private static intcoerce(CommandSession session, Object target, Method m, Class<?>[] types, Object[] out, List<Object> in) Complex routein to convert the arguments given from the command line to the arguments of the method call.private static intdocoerce(CommandSession session, Object target, Method m, Class<?>[] types, Object[] out, List<Object> in) static Objectinvokes the named method on the given target using the supplied args, which are converted if necessary.private static Class<?>primitiveToObject(Class<?> type) private static StringtransformParameters(Method method, List<Object> in) transform name/value parameters into ordered argument list.private static voidwriteValue(StringBuilder sb, Object o)
-
Field Details
-
NO_MATCH
-
MAIN
- See Also:
-
KEYWORDS
-
-
Constructor Details
-
Reflective
public Reflective()
-
-
Method Details
-
invoke
public static Object invoke(CommandSession session, Object target, String name, List<Object> args) throws Exception invokes the named method on the given target using the supplied args, which are converted if necessary.- Parameters:
session- the sessiontarget- the targetname- the nameargs- the args- Returns:
- the result of the invoked method
- Throws:
Exception- on exception
-
transformParameters
transform name/value parameters into ordered argument list. params: --param2, value2, --flag1, arg3 args: true, value2, arg3- Returns:
- new ordered list of args.
-
coerce
private static int coerce(CommandSession session, Object target, Method m, Class<?>[] types, Object[] out, List<Object> in) Complex routein to convert the arguments given from the command line to the arguments of the method call. First, an attempt is made to convert each argument. If this fails, a check is made to see if varargs can be applied. This happens when the last method argument is an array.- Returns:
- -1 if arguments can't be coerced; 0 if no coercion was necessary; > 0 if coercion was needed.
-
docoerce
-
coerce
converts given argument to specified type and increments convert[0] if any conversion was needed.- Parameters:
session- the sessiontype- the typearg- the argconvert- convert[0] is incremented according to the conversion needed, to allow the "best" conversion to be determined.- Returns:
- converted arg or NO_MATCH if no conversion possible.
-
toString
-
writeValue
-
primitiveToObject
-