if (lastName != null && !lastName.equals("")) { lasts.add(lastName); firsts.add(firstNames); }
lasts.add(lastName); firsts.add(firstNames);
    private void readNames(HttpServletRequest request,        Item item,        String element,        String qualifier,        boolean repeated)    {        String dcname = element;        if (qualifier != null)        {            dcname = element + "_" + qualifier;        }        // Names to add        List firsts = new LinkedList();        List lasts = new LinkedList();        if (repeated)        {            firsts = getRepeatedParameter(request, dcname + "_first");            lasts = getRepeatedParameter(request, dcname + "_last");            // Find out if the relevant "remove" button was pressed            String buttonPressed = UIUtil.getSubmitButton(request, "");            String removeButton = "submit_" + dcname + "_remove_";            if (buttonPressed.startsWith(removeButton))            {                int valToRemove = Integer.parseInt(                    buttonPressed.substring(removeButton.length()));                firsts.remove(valToRemove);                lasts.remove(valToRemove);            }        }        else        {            // Just a single name            String lastName = request.getParameter(dcname + "_last");            String firstNames = request.getParameter(dcname + "_first");            // Only put it in if there was a name present            if (lastName != null && !lastName.equals(""))            {                lasts.add(lastName);                firsts.add(firstNames);            }        }        // Remove existing values        item.clearDC(element, qualifier, Item.ANY);        // Put the names in the correct form        for (int i = 0; i < lasts.size(); i++)        {            String f = ((String) firsts.get(i)).trim();            String l = ((String) lasts.get(i)).trim();            // If there is a comma in the last name, we take everything            // after that comma, and add it to the right of the            // first name            int comma = l.indexOf(',');            if (comma >= 0)            {                f = f + l.substring(comma + 1);                l = l.substring(0, comma);                // Remove leading whitespace from first name                while (f.startsWith(" "))                {                    f = f.substring(1);                }            }            // Add to the database            item.addDC(element, qualifier, null,                new DCPersonName(l, f).toString());        }    }