⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jboperator.java

📁 OPIAM stands for Open Identity and Access Management. This Suite will provide modules for user & rig
💻 JAVA
字号:
/*
 * OPIAM Suite
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */

package opiam.admin.faare.struts.service.beans;

import opiam.admin.faare.service.javabeans.Criteria;
import opiam.admin.faare.service.services.references.ReferenceElement;

import java.lang.reflect.Field;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.ResourceBundle;


/**
 * This class corersponds to the "operator" element of the operators_conf.xml file.
 * It allows to define a set of search operator associated with a name.
 *
 */
public class JBOperator
{
    /** Operator name. */
    private String name;

    /** List of search operators. */
    private List opList = new ArrayList();

    /** List of computed ReferenceElement. */
    private List refList = new ArrayList();

    /**
     * Returns the operator name.
     * @return name
     */
    public String getName()
    {
        return name;
    }

    /**
     * Returns the list of operators.
     * @return List
     */
    public List getOperators()
    {
        return opList;
    }

    /**
     * Sets the operator name.
     * @param aname The name to set
     */
    public void setName(String aname)
    {
        this.name = aname;
    }

    /**
     * Adds a search operator.
     *
     * @param opStr operator. One of
     * opiam.admin.faare.service.javabeans.Criteria
     * operators constant names.
     */
    public void addOpList(String opStr)
    {
        opList.add(opStr);
    }

    /**
     * Displays operator definition.
     *
     * @return String formatted operator definition.
     */
    public String toString()
    {
        StringBuffer buf = new StringBuffer();
        java.util.Iterator it = null;

        buf.append("   name = ");
        buf.append(name);
        buf.append(System.getProperty("line.separator"));

        if (opList != null)
        {
            buf.append("   List components of opList = ");
            buf.append(System.getProperty("line.separator"));
            it = opList.iterator();

            while (it.hasNext())
            {
                buf.append("   ...");
                buf.append(it.next());
                buf.append(System.getProperty("line.separator"));
            }
        }

        if (refList != null)
        {
            buf.append("   List components of refList = ");
            buf.append(System.getProperty("line.separator"));
            it = refList.iterator();

            ReferenceElement elt = null;

            while (it.hasNext())
            {
                elt = (ReferenceElement) it.next();
                buf.append("   ...");
                buf.append(elt.getLabel());
                buf.append(" = ");
                buf.append(elt.getValue());
                buf.append(System.getProperty("line.separator"));
            }
        }

        return buf.toString();
    }

    /**
     * Computes the search operators labels and values to build the reference list.
     * @param ress resource bundle for label names
     */
    public void compute(ResourceBundle ress)
    {
        Class c = Criteria.class;

        try
        {
            Iterator it = opList.iterator();
            String key = null;
            String keyMsg = null;
            Field tmpField = null;
            Integer value = null;

            while (it.hasNext())
            {
                key = (String) it.next();
                tmpField = c.getField(key);
                value = (Integer) tmpField.get(c);

                keyMsg = ress.getString(key);

                if (keyMsg == null)
                {
                    // non trouv

⌨️ 快捷键说明

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