class FormInput {
        public String type;
        public String name;
        public String value;
        public boolean checked = false;
        @Override
        public String toString() {
            String str = "input[@type='" + type+"'][@name='" + name + "'][@value='" + value + "']";
            if (checked) {
                str = str + "[@checked]";
            }
            return str;
        } 
    }

    protected String method;
    protected String action;
    protected String enctype;

    protected List<FormInput> allInputs = new ArrayList<FormInput>();
    protected List<FormInput> candidateUsernameInputs = new ArrayList<FormInput>();
    protected List<FormInput> candidatePasswordInputs = new ArrayList<FormInput>();

    /**
     * Add a discovered INPUT, tracking it as potential 
     * username/password receiver. 
     * @param type
     * @param name
     * @param value
     * @param checked true if "checked" attribute is present (for radio buttons and checkboxes)
     */
    public void addField(String type, String name, String value, boolean checked) {
        FormInput input = new FormInput();
        input.type = type;
        
        if (isMultipleFormSubmitInputs(type)) {
            return;
        }
             
        // default input type is text per html standard
        if (input.type == null) {
            input.type = "text";
        }
        input.name = name;
        input.value = value; 
        input.checked = checked;
        allInputs.add(input);

        if("text".equalsIgnoreCase(input.type) || "email".equalsIgnoreCase(input.type)) {
            candidateUsernameInputs.add(input);
        } else if ("password".equalsIgnoreCase(type)) {
            candidatePasswordInputs.add(input);
        }
    }
    
    public boolean isMultipleFormSubmitInputs(String type) {
        if (type != null && !type.toLowerCase().equals("submit"))
            return false;

        for (FormInput input : allInputs) {
            if (input.type.toLowerCase().equals("submit")) {
                return true;
            }
        }

        return false;
    }    

    /**
     * Add a discovered INPUT, tracking it as potential 
     * username/password receiver. 
     * @param type
     * @param name
     * @param value
     */
    public void addField(String type, String name, String value) {
        addField(type, name, value, false);
    }

    public void setMethod(String method) {
        this.method = method; 
    }

    public String getAction() {
        return action;
    }

    public void setAction(String action) {
        this.action = action;
    }

    public String getEnctype() {
        return enctype;
    }

    public void setEnctype(String enctype) {
        this.enctype = enctype;
    }

    /**
     * For now, we consider a POST form with only 1 password
     * field and 1 potential username field (type text or email)
     * to be a likely login form.
     * 
     * @return boolean likely login form
     */
    public boolean seemsLoginForm() {
        return "post".equalsIgnoreCase(method) 
                && candidatePasswordInputs.size() == 1
                && presumedUsernameInput() != null;
    }

    protected FormInput presumedUsernameInput() {<FILL_FUNCTION_BODY>

        if (candidateUsernameInputs.size() < 1) {
            return null;
        } else if (candidateUsernameInputs.size() == 1) {
            return candidateUsernameInputs.get(0);
        } else {
            // more than one candidate; if there is exactly one whose name
            // contains the string "username", choose that one
            FormInput choice = null;
            for (FormInput input: candidateUsernameInputs) {
                if (input.name != null && input.name.toLowerCase().indexOf("username") != -1) {
                    if (choice == null) {
                        choice = input;
                    } else {
                        return null;
                    }
                }
            }
            return choice;
        }
    
<no_super_class>