CPD Results

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

Duplications

FileProjectLine
us/semblance/example/customer/search/CustomerFilterBean.javaExample57
us/semblance/example/customer/search/CustomerSearchBean.javaExample49
    }
    
    public FilterValue.String getCity() {
        return city;
    }
    public void setCity(FilterValue.String city) {
        this.city = city;
    }
    public FilterValue.Date getCustomerSince() {
        return customerSince;
    }
    public void setCustomerSince(FilterValue.Date customerSince) {
        this.customerSince = customerSince;
    }
    public FilterValue.String getFirstName() {
        return firstName;
    }
    public void setFirstName(FilterValue.String firstName) {
        this.firstName = firstName;
    }
    public FilterValue.Integer getId() {
        return id;
    }
    public void setId(FilterValue.Integer id) {
        this.id = id;
    }
    public FilterValue.String getLastName() {
        return lastName;
    }
    public void setLastName(FilterValue.String lastName) {
        this.lastName = lastName;
    }
    public FilterValue.String getPhoneNumber() {
        return phoneNumber;
    }
    public void setPhoneNumber(FilterValue.String phoneNumber) {
        this.phoneNumber = phoneNumber;
    }
    public FilterValue.DynamicTypeCode getState() {
        return state;
    }
    public void setState(FilterValue.DynamicTypeCode state) {
        this.state = state;
    }
    public FilterValue.String getZip() {
        return zip;
    }
    public void setZip(FilterValue.String zip) {
        this.zip = zip;
    }
    
    /**
     * Returns a <code>Map</code> containing any name transformations the
     * framework will need to perform to match this <code>CriteriaBean</code>'s
     * property names with the identifiers needed to perform a query (in this
     * case, the properties of the {@link Customer} bean.
     * 
     * @see CriteriaBean#criteriaKeyBindings()
     */
    public Map criteriaKeyBindings()
    {
        Map bindings = super.criteriaKeyBindings();
        bindings.put("street", "address.street");
        bindings.put("city", "address.city");
        bindings.put("state", "address.state");
        return bindings;
    }
}

FileProjectLine
us/semblance/formatter/CSVListFormatter.javaFoundation25
us/semblance/formatter/ValueListFormatter.javaFoundation25
public class ValueListFormatter extends Formatter
{
    private static final long serialVersionUID = 1L;

    public final static String ERROR_KEY = "error.list";
    
    static final String PARSE_MSG = "Unable to parse a list of comma-separated values from ";
    static final String FORMAT_MSG = "Unable to format a list of comma-separated values from ";
    
    /**
     * Returns the error key for this Formatter.
     * @see Formatter#getErrorKey()
     */
    public String getErrorKey() { return ERROR_KEY; }

    /**
     * Returns a <code>List</code> containing the values of the substrings, using
     * comma as the delimiter value.
     */
    protected Object convertToObject(String target) 
    {
        if (target == null)
            return null;
        
        String[] stringVals = target.split(",");
        
        /*
        // TODO: Format strings using nestedObjectType, if set...
        if (nestedTargetType == null)
            return;
        
        Formatter formatter = Formatter.getFormatter(nestedTargetType);
        for (int i = 0; i < stringVals.length; i++) {
            ...
        }
        */
        
        return Arrays.asList(stringVals);
    }
    
    /**
     * Returns the provided <code>List</code> formatted as comma-separated values.
     * Note: Overriding formatForPresentation() instead of format() to avoid
     * Collection handling...
     */
    public Object formatForPresentation(Object value)
    {
        if (value == null)
            return null;
        
        if (!(value instanceof List))
            throw new FormatException(FORMAT_MSG + value);
        List values = (List) value;
        
        StringBuffer buf = new StringBuffer();
        Formatter formatter = getNestedFormatter();
        for (int i = 0; i < values.size(); i++)
        {
            if (i > 0)  buf.append(", ");
            Object currObj = values.get(i);
            String stringVal = formatter.format(currObj).toString();
            buf.append(stringVal);
        }
        return buf.toString();
    }
    
    protected Formatter getNestedFormatter() {
        String className = (String) settingForKey("nestedFormatter");
        Class formatterType = Formatter.formatterClassForName(className);
        if (formatterType != null)
            return Formatter.createFormatter(formatterType, Object.class, settings);
        
        return Formatter.getFormatter(String.class, settings);
    }
}

FileProjectLine
us/semblance/strutslive/tableview/SLSearchAction.javaStrutsLive52
us/semblance/strutslive/tableview/TableViewAction.javaStrutsLive123
        return mapping.findForward("tableView");
     }
    
    
    /**
     *  @deprecated as of 0.4.0. Use 
     * {@link SLSearchAction#search(ActionMapping, ActionForm, HttpServletRequest, HttpServletResponse))
     * instead.
     */
    public ActionForward search(ActionMapping mapping, ActionForm form,
           HttpServletRequest request, HttpServletResponse response)
        throws Exception
    {
        // TODO: For now, use the 'parameter' attribute. Later, we'll use
        // a custom attribute of the ActionMapping.
        // 
        // This key tells us where to locate the config file.
        String key = mapping.getParameter();
        TableViewConfig config = TableViewConfig.decode(key);
        if (config == null)
            throw new ConfigurationException("Unable to read TableView config file at path " + key);
        
        String psClassName = config.getPersistenceService();
        if (psClassName == null)
            throw new ConfigurationException("persistenceServiceClassName must be provided in TableView XML");
        
        // FIXME: Provide a separate setting form XML filename...
        Class serviceType = null;
        SLPersistenceServiceAdaptor service = null;
        if (psClassName.endsWith(".xml"))
            service = new XMLServiceAdaptor(psClassName);
        else try {
            serviceType = Class.forName(psClassName, false, Thread.currentThread().getContextClassLoader());
            service = (SLPersistenceServiceAdaptor)serviceType.newInstance();
        }
        catch (InstantiationException e) {
            System.out.println("Unable to create instance of class named " + serviceType);
        }
        catch (ClassCastException e) {
            System.out.println("Must be an instance of MutablePersistenceService");
        }
                
        String entityClassName = config.getEntityType();
        if (entityClassName == null)
            throw new ConfigurationException("entityType must be provided in TableView XML");
        Class entityType = classForName(entityClassName);
            
        String searchFormKey = config.getSearchFormKey();
        if (searchFormKey == null)
            searchFormKey = SLSearchAction.SEARCH_FORM_KEY;

FileProjectLine
us/semblance/formatter/DynamicTypeCodeFormatter.javaFoundation155
us/semblance/formatter/SelectionGroupFormatter.javaFoundation87
            multipleSelection = (MultipleSelectionGroup) propertyType.newInstance();
        }
        catch (IllegalAccessException e) {
            FormatException ex = new FormatException("\nUnable to create instance of " + propertyType.getName()
                + "\nConstructor is not visible.\n" + e);
            if (logger.isLoggable(Level.FINE))  logger.fine(ex.getMessage());
            throw ex;
        }
        catch (InstantiationException e) {
            FormatException ex = new FormatException("\nUnable to create instance of abstract class " + propertyType.getName() 
                    + "\nValue of propertyType must be a concrete subclass of " + Formatter.class.getName());
            if (logger.isLoggable(Level.FINE))  logger.fine(ex.getMessage());
            throw ex;
        }
        catch (ExceptionInInitializerError e) {
            FormatException ex = new FormatException("\nUnable to create instance of " + propertyType.getName()
                    + "\nConstructor or other tatic initialization code threw the following exception\n" + e);