NameListpublic 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 $ |
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 void | addValueToNamedList(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.String | addValueToProperList(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 void | buildList(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 void | buildLists(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.String | getDomainValueSourceXPath(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.String | getListNameForXpath(java.lang.String xpath)
return XPathHelper.getXPathPrefix(xpath, _scope_depth);
| private java.util.Hashtable | getNamedList(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 boolean | isValueInNameDomain(java.lang.Object value, java.lang.String xpath, boolean bRef)
return (getDomainValueSourceXPath(value, xpath, bRef)!=null);
| public java.lang.String | toString()
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;
|
|