CPD Results

The following document contains the results of PMD's CPD 4.1.

Duplications

File Line
org\apache\commons\workflow\core\WhileAnyStep.java 77
org\apache\commons\workflow\core\WhileNotAnyStep.java 77
    public WhileNotAnyStep(String id, Descriptor descriptor) {

        super();
        setId(id);
        if (descriptor != null)
            addDescriptor(descriptor);

    }


    // --------------------------------------------------------- Public Methods


    /**
     * Render a string representation of this Step.
     */
    public String toString() {

        StringBuffer sb = new StringBuffer("<core:whileAny");
        if (getId() != null) {
            sb.append(" id=\"");
            sb.append(getId());
            sb.append("\"");
        }
        sb.append(">");
        Descriptor descriptors[] = findDescriptors();
        for (int i = 0; i < descriptors.length; i++)
            sb.append(descriptors[i]);
        Step steps[] = getSteps();
        for (int i = 0; i < steps.length; i++)
            sb.append(steps[i]);
        sb.append("</core:whileAny>");
        return (sb.toString());

    }


    // ------------------------------------------------------ Protected Methods


    /**
     * Evaluate the condition specified by the Descriptors associated with
     * this Block, and return the resulting boolean value.
     *
     * @param context Context within which to evaluate the descriptors
     */
    protected boolean evaluate(Context context) {

        boolean condition = false;
        Descriptor descriptors[] = findDescriptors();
        for (int i = 0; i < descriptors.length; i++) {
            if (descriptors[i].positive(context))
                condition = true;
        }
        return (!condition);

File Line
org\apache\commons\workflow\web\ForwardStep.java 83
org\apache\commons\workflow\web\IncludeStep23.java 88
    public IncludeStep23(String id, String page) {

        super();
        setId(id);
        setPage(page);

    }


    // ------------------------------------------------------------- Properties


    /**
     * The context-relative URL (starting with '/') of the resource to be
     * retrieved.
     */
    protected String page = null;

    public String getPage() {
        return (this.page);
    }

    public void setPage(String page) {
        this.page = page;
    }


    // --------------------------------------------------------- Public Methods


    /**
     * Perform the executable actions related to this Step, in the context of
     * the specified Context.
     *
     * @param context The Context that is tracking our execution state
     *
     * @exception StepException if a processing error has occurred
     */
    public void execute(Context context) throws StepException {

        // Make sure our executing Context is a WebContext
        if (!(context instanceof WebContext))
            throw new StepException("Execution context is not a WebContext",
                                    this);
        WebContext webContext = (WebContext) context;

        // Get the actual resource reference we will be using
        String resource = page;
        if (resource == null) {
            try {
                resource = (String) webContext.pop();
            } catch (EmptyStackException e) {
                throw new StepException("Evaluation stack is empty", this);
            }
        }

        // Create a request dispatcher and response wrapper for this resource
        RequestDispatcher rd =
            webContext.getServletContext().getRequestDispatcher(resource);
        if (rd == null)
            throw new StepException("No request dispatcher for '" +
                                    resource + "'", this);
        ServletRequest request = webContext.getServletRequest();
        ServletResponse response =

File Line
org\apache\commons\workflow\core\WhileAnyStep.java 77
org\apache\commons\workflow\core\WhileNotStep.java 77
    public WhileNotStep(String id, Descriptor descriptor) {

        super();
        setId(id);
        if (descriptor != null)
            addDescriptor(descriptor);

    }


    // --------------------------------------------------------- Public Methods


    /**
     * Render a string representation of this Step.
     */
    public String toString() {

        StringBuffer sb = new StringBuffer("<core:whileAny");
        if (getId() != null) {
            sb.append(" id=\"");
            sb.append(getId());
            sb.append("\"");
        }
        sb.append(">");
        Descriptor descriptors[] = findDescriptors();
        for (int i = 0; i < descriptors.length; i++)
            sb.append(descriptors[i]);
        Step steps[] = getSteps();
        for (int i = 0; i < steps.length; i++)
            sb.append(steps[i]);
        sb.append("</core:whileAny>");
        return (sb.toString());

    }


    // ------------------------------------------------------ Protected Methods


    /**
     * Evaluate the condition specified by the Descriptors associated with
     * this Block, and return the resulting boolean value.
     *
     * @param context Context within which to evaluate the descriptors
     */
    protected boolean evaluate(Context context) {

        boolean condition = true;

File Line
org\apache\commons\workflow\core\NotOrStep.java 71
org\apache\commons\workflow\core\OrStep.java 91
    public OrStep(String id, String step, Descriptor descriptor) {

        super();
        setId(id);
        setStep(step);
        addDescriptor(descriptor);

    }


    // --------------------------------------------------------- Public Methods


    /**
     * Perform the executable actions related to this Step, in the context of
     * the specified Context.
     *
     * @param context The Context that is tracking our execution state
     *
     * @exception StepException if a processing error has occurred
     */
    public void execute(Context context) throws StepException {

        // Process all associated descriptors
        boolean condition = false;
        Descriptor descriptors[] = findDescriptors();
        for (int i = 0; i < descriptors.length; i++) {
            Object value = descriptors[i].get(context);
            if (value != null) {
                if (value instanceof Boolean) {
                    if (((Boolean) value).booleanValue())
                        condition = true;
                } else {
                    condition = true;
                }
            }
        }

        // Conditionally forward control to the specified step
        if (condition) {

File Line
org\apache\commons\workflow\core\AndStep.java 91
org\apache\commons\workflow\core\NotAndStep.java 71
    public NotAndStep(String id, String step, Descriptor descriptor) {

        super();
        setId(id);
        setStep(step);
        addDescriptor(descriptor);

    }
    // --------------------------------------------------------- Public Methods


    /**
     * Perform the executable actions related to this Step, in the context of
     * the specified Context.
     *
     * @param context The Context that is tracking our execution state
     *
     * @exception StepException if a processing error has occurred
     */
    public void execute(Context context) throws StepException {

        // Process all associated descriptors
        boolean condition = true;
        Descriptor descriptors[] = findDescriptors();
        for (int i = 0; i < descriptors.length; i++) {
            Object value = descriptors[i].get(context);
            if (value == null)
                condition = false;
            else if ((value instanceof Boolean) &&
                     !((Boolean) value).booleanValue())
                condition = false;
        }

        // Conditionally forward control to the specified step
        if (!condition) {

File Line
org\apache\commons\workflow\core\ConstructStep.java 117
org\apache\commons\workflow\core\InvokeStep.java 152
        Object values[] = new Object[descriptors.length - 1];
        for (int i = 1; i < descriptors.length; i++) {
            values[i-1] = descriptors[i].get(context);
            types[i-1] = descriptors[i].getType();
            if (types[i-1] == null) {
                if (values[i-1] == null)
                    types[i-1] = Object.class;
                else
                    types[i-1] = values[i-1].getClass();
            }
        }

File Line
org\apache\commons\workflow\core\IfAnyStep.java 93
org\apache\commons\workflow\core\WhileStep.java 95
        StringBuffer sb = new StringBuffer("<core:while");
        if (getId() != null) {
            sb.append(" id=\"");
            sb.append(getId());
            sb.append("\"");
        }
        sb.append(">");
        Descriptor descriptors[] = findDescriptors();
        for (int i = 0; i < descriptors.length; i++)
            sb.append(descriptors[i]);
        Step steps[] = getSteps();
        for (int i = 0; i < steps.length; i++)
            sb.append(steps[i]);
        sb.append("</core:while>");

File Line
org\apache\commons\workflow\web\HttpSessionScope.java 278
org\apache\commons\workflow\web\ServletContextScope.java 278
            servletRequest.setAttribute(key, bean);
            support.fireBeanAdded(key, bean);
        }
        return (old);
            
    }


    /**
     * Copy all of the mappings from the specified map into this map,
     * firing appropriate <code>beanAdded()</code> and
     * <code>beanReplaced()</code> events along the way.
     *
     * @param in Map whose contents are to be added
     */
    public void putAll(Map in) {

        Iterator keys = in.keySet().iterator();
        while (keys.hasNext()) {
            Object key = keys.next();
            put(key, in.get(key));
        }

    }


    /**
     * Remove the bean associated with the specified key (if any), and return
     * the old value if removed.
     *
     * @param key Key of the bean to remove (cannot be null)
     */
    public Object remove(Object key) {

        return (remove((String) key));

    }



    /**
     * Remove the bean associated with the specified key (if any).  If such
     * a bean is found and removed, call <code>beanRemoved()</code> on all
     * registered <code>ScopeListeners</code> after the removal is done.
     * Return the old value (if any); otherwise return <code>null</code>.
     *
     * @param key Key of the bean to remove (cannot be null)
     *
     * @exception IllegalArgumentException if <code>key</code> is null
     */
    public Object remove(String key) {

        Object old = servletRequest.getAttribute(key);

File Line
org\apache\commons\workflow\io\ReadStep.java 83
org\apache\commons\workflow\io\WriteStep.java 86
    public WriteStep(String id, String encoding, String file) {

        super();
        setId(id);
        setEncoding(encoding);
        setFile(file);

    }


    // ------------------------------------------------------------- Properties


    /**
     * The character encoding used to write the contents of this file.
     */
    protected String encoding = null;

    public String getEncoding() {
        return (this.encoding);
    }

    public void setEncoding(String encoding) {
        this.encoding = encoding;
    }


    /**
     * The relative or absolute pathname of the operating system file.
     */
    protected String file = null;

    public String getFile() {
        return (this.file);
    }

    public void setFile(String file) {
        this.file = file;
    }


    // --------------------------------------------------------- Public Methods


    /**
     * Perform the executable actions related to this Step, in the context of
     * the specified Context.
     *
     * @param context The Context that is tracking our execution state
     *
     * @exception StepException if a processing error has occurred
     */
    public void execute(Context context) throws StepException {

File Line
org\apache\commons\workflow\core\IfStep.java 106
org\apache\commons\workflow\core\WhileStep.java 108
        sb.append("</core:while>");
        return (sb.toString());

    }


    // ------------------------------------------------------ Protected Methods


    /**
     * Evaluate the condition specified by the Descriptors associated with
     * this Block, and return the resulting boolean value.
     *
     * @param context Context within which to evaluate the descriptors
     */
    protected boolean evaluate(Context context) {

        boolean condition = true;
        Descriptor descriptors[] = findDescriptors();
        for (int i = 0; i < descriptors.length; i++) {
            if (descriptors[i] == null)
                continue;
            if (!descriptors[i].positive(context))
                condition = false;
        }
        return (condition);

    }


    /**
     * Process the initial entry into this Block.
     *
     * @param context Context within which to evaluate the condition
     */
    protected void initial(Context context) {

        if (evaluate(context)) {
            BlockState state = new BlockState(this, true);