formutils.java

来自「OPIAM stands for Open Identity and Acces」· Java 代码 · 共 61 行

JAVA
61
字号
/*
 * OPIAM Suite
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */

package opiam.admin.faare.struts.utils;

import java.util.ArrayList;
import java.util.StringTokenizer;

/**
 * This class contains utility methods for HTML forms processing.
 */

public final class FormUtils
{
    /** Utility class. */
    private FormUtils()
    {
    }

    /**
     * This method must be called by an edition FormBean to get the values of
     * a multivalued attribute filled by the MultiEdit tag.
     *
     * @param desc value gor from the form
     * @return list of values of the attribute
     */
    public static ArrayList getMultiVal(String desc)
    {
        if (desc.trim().equals(""))
        {
            return null;
        }

        desc = desc.substring(1);

        StringTokenizer tok = new StringTokenizer(desc, "#");
        ArrayList vals = new ArrayList();

        while (tok.hasMoreTokens())
        {
            String aval = tok.nextToken();

            if (!aval.trim().equals(""))
            {
                vals.add(aval);
            }
        }

        if (vals.size() == 0)
        {
            vals = null;
        }

        return vals;
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?