FileDocCategorySizeDatePackage
NameList.javaAPI DocGlassfish v2 API10159Fri May 04 22:24:36 BST 2007com.sun.enterprise.config.serverbeans.validation

NameList

public class NameList extends Object
This class represents name list for given config context $Id: NameList.java,v 1.5 2007/05/05 05:24:36 tcfujii Exp $
author
alexkrav $Log: NameList.java,v $ Revision 1.5 2007/05/05 05:24:36 tcfujii CDDL+GPL header updates. Revision 1.4 2005/12/25 03:44:23 tcfujii Updated copyright text and year. Revision 1.3 2005/08/18 17:10:08 kravtch M3: Admin Config Validator changes: 1. referencees support in name domains; 2. "virtual servers" name domain is added; 3. required elements existance validation (for ADD/DELETE element); 4. Clean up of custom validators (removed duplication testy, covered by generic validation; 5. Validation messages are prefixed by message code (for SQE negative tests) Submitted by: kravtch Reviewed by: Shreedhar Affected modules admin/validator; admin-core/config-api Tests passed: SQE, QLT/EE + devtests Revision 1.2 2005/06/27 21:18:16 tcfujii Issue number: CDDL header updates. Revision 1.1 2005/06/17 17:09:58 kravtch MS3: Config Validator's infrastructure changes: - new "VALIDATE" ConfigContextEvent type introduced for "static" validation; - host "static" validation as ConfigContext listener for "VALIDATE" events; - new namespace "http://www.sun.com/ias/validation" support for RelaxNG schemas extension: - "name-domains" metadata support for test uniquiness/references; - new "belongs-to"/"references-to"/"type"/"**-than" schema attributes; - most rng element definitions and xslt scripts changed; - new base validation classes to perform generic validation; - custom validation test classes cleaned from performing generic validation cases; - ConfigBeans and domain dtd re-generated; - Schematron(scripts and validation) and Relax NG (validator only) not used for validation any more; Submitted by: kravtch Tests passed QLT/EE + devtests Modules affected: appserver-commons; admin/validator; admin-core/config-api

Fields Summary
static Logger
_logger
com.sun.enterprise.util.LocalStringManagerImpl
_localStrings
com.sun.enterprise.config.ConfigContext
_ctx
ArrayList
_srcXPathes
ArrayList
_refXPathes
Hashtable
_srcLists
Hashtable
_refLists
boolean
_bKeepList
String
_name
String
_fullName
String
_scope
int
_scope_depth
Constructors Summary
public NameList(String name, String fullName, String scope, ArrayList srcXPathes, ArrayList refXPathes, com.sun.enterprise.config.ConfigContext ctx, boolean bPreCreateAndKeepList)

    
    
                   
        _name = name;
        _fullName = fullName;
        _srcXPathes = srcXPathes;
        _refXPathes = refXPathes;
        if(scope!=null && !scope.equals("/"))
        {
            _scope = scope.trim();
            _scope_depth = XPathHelper.getNumberOfElemTokens(_scope);
//System.out.println("######################### _scope = " +_scope + " _scope_depth="+_scope_depth);
        }
        _ctx = ctx;
        _bKeepList = bPreCreateAndKeepList;
        _srcLists = new Hashtable();
        _refLists = new Hashtable();
        if(bPreCreateAndKeepList)
            buildLists(null);
    
Methods Summary
private voidaddValueToNamedList(java.lang.String listName, java.lang.String sourceXPath, java.lang.Object value, boolean bRef)

        if(listName!=null && value!=null)
        {
            Hashtable list = getNamedList(listName, bRef, true);
            if(list.get(value)==null)
                list.put(value, sourceXPath);
        }
    
private java.lang.StringaddValueToProperList(java.lang.String xpath, java.lang.Object value, boolean bRef)

        String listName;
        if(xpath==null || value==null || (listName = getListNameForXpath(xpath))==null)
            return null;
//System.out.println("+++addValueToProperList() domain-name=" + _name + " sublistName=" + listName + "  value=" + value);
        addValueToNamedList(listName, xpath,  value, bRef);
        return listName;
    
private voidbuildList(java.util.ArrayList xpathes, java.lang.String onlyPrefix, boolean bRef)

        //build list
        AttributeList arr = XPathHelper.resolve(_ctx, xpathes, onlyPrefix);
        for(int i=0; i<arr.size(); i++)
        {
            Attribute attr = (Attribute)arr.get(i);
            String[] values = ((String)attr.getValue()).split(",");
            for(int j=0; j<values.length; j++)
            {
                addValueToProperList(attr.getName(), values[j], bRef);
            }
        }
    
protected voidbuildLists(java.lang.String onlyPrefix)

        //FIXME: should clear only poroper sublist
        _srcLists.clear();
        _refLists.clear();
        
        //source lists
        buildList(_srcXPathes, onlyPrefix, false);
        //referencees lists
        buildList(_refXPathes, onlyPrefix, true);
    
public java.lang.StringgetDomainValueSourceXPath(java.lang.Object value, java.lang.String xpath, boolean bRef)

        String listName;
        if(xpath==null || value==null || (listName = getListNameForXpath(xpath))==null)
            return null;
        Hashtable list = getNamedList(listName, bRef, false);
        if(list!=null)
            return (String)list.get(value);
        return null;
    
private java.lang.StringgetListNameForXpath(java.lang.String xpath)

        return XPathHelper.getXPathPrefix(xpath, _scope_depth);
    
private java.util.HashtablegetNamedList(java.lang.String listName, boolean bRef, boolean bCreateIfNotFound)

        Hashtable lists = bRef?_refLists:_srcLists;
        Hashtable list = (Hashtable)lists.get(listName);
        if(list==null && bCreateIfNotFound)
        {
            list = new Hashtable();
            lists.put(listName, list);
        }
        return list;
    
public booleanisValueInNameDomain(java.lang.Object value, java.lang.String xpath, boolean bRef)

        return (getDomainValueSourceXPath(value, xpath, bRef)!=null);
    
public java.lang.StringtoString()

        String str = "domain name: " + _name;
        
        if(_srcLists!=null)
        {
            Iterator lists = _srcLists.keySet().iterator();
            while(lists.hasNext())
            {
                String key = (String)lists.next();
                str = str + "\n    " + "list name: " + key;
                Hashtable list = (Hashtable)_srcLists.get(key);
                if(list!=null)
                {
                    Object[] keys = (Object[])list.keySet().toArray();
                    for(int i=0; i<keys.length; i++)
                        str = str + "\n      " + keys[i]; // + "   xpath=" + list.get(keys[i]);
                }
            }
        }
        if(_refLists!=null)
        {
            Iterator lists = _refLists.keySet().iterator();
            while(lists.hasNext())
            {
                String key = (String)lists.next();
                str = str + "\n    " + "Referencees list name: " + key;
                Hashtable list = (Hashtable)_refLists.get(key);
                if(list!=null)
                {
                    Object[] keys = (Object[])list.keySet().toArray();
                    for(int i=0; i<keys.length; i++)
                        str = str + "\n      " + keys[i]; // + "   xpath=" + list.get(keys[i]);
                }
            }
        }
        return str;