public void AddProperty(String key, Object token)
{
Object o = this[key];
/*
* $$$ GMJ
* FIXME : post 1.0 release, we need to not assume
* that a scalar is a String - it can be an Object
* so we should make a little vector-like class
* say, Foo that wraps (not extends Vector),
* so we can do things like
* if ( !( o instanceof Foo) )
* so we know it's our 'vector' container
*
* This applies throughout
*/
if (o is String)
{
ArrayList v = new ArrayList(2);
v.Add(o);
v.Add(token);
CollectionsUtil.PutElement(this, key, v);
}
else if (o is ArrayList)
{
((ArrayList) o).Add(token);
}
else
{
/*
* This is the first time that we have seen
* request to place an object in the
* configuration with the key 'key'. So
* we just want to place it directly into
* the configuration ... but we are going to
* make a special exception for String objects
* that contain "," characters. We will take
* CSV lists and turn the list into a vector of
* Strings before placing it in the configuration.
* This is a concession for Properties and the
* like that cannot parse multiple same key
* values.
*/
if (token is String && ((String) token).IndexOf(PropertiesTokenizer.DELIMITER) > 0)
{
PropertiesTokenizer tokenizer = new PropertiesTokenizer((String) token);
while(tokenizer.HasMoreTokens())
{
String s = tokenizer.NextToken();
/*
* we know this is a string, so make sure it
* just goes in rather than risking vectorization
* if it contains an escaped comma
*/
AddStringProperty(key, s);
}
}
else
{
/*
* We want to keep track of the order the keys
* are parsed, or dynamically entered into
* the configuration. So when we see a key
* for the first time we will place it in
* an ArrayList so that if a client class needs
* to perform operations with configuration
* in a definite order it will be possible.
*/
AddPropertyDirect(key, token);
}
}
}