Class NSProperties
- java.lang.Object
-
- java.util.Dictionary<K,V>
-
- java.util.Hashtable<Object,Object>
-
- java.util.Properties
-
- edu.uiuc.ncsa.security.core.configuration.XProperties
-
- edu.uiuc.ncsa.security.core.configuration.NSProperties
-
- All Implemented Interfaces:
Serializable,Cloneable,Map<Object,Object>
public class NSProperties extends XProperties
In addition to the abilities of XProperties this allows for- Basic but extremely useful namespace support. You may get/set properties using a namespace in addition to a property key. Be warned this is simple since it just gloms the namespace in front of the key, but it works quite well for most cases.
xmlns\:fileStore=http://my.ns/fileStore# xmlns\:email=myproxy:ncsa,2011/1.1/email# fileStore\:dataPath=/tmp/data fileStore\:indexPath=/tmp/index email\:enabled=false(The "\" on the left-hand side is colon escaping from the Java Properties class.) In which case you could retrieve values as getBoolean("email", "enabled") or getBoolean("myproxy:ncsa,2011/1.1/email#enabled") You may add or remove prefixes by calling the appropriateaddNSPrefix(String, String)method. These will be saved as part of the properties file.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classNSProperties.StringLengthComparator
-
Field Summary
Fields Modifier and Type Field Description static StringXMLNS_PREFIX-
Fields inherited from class edu.uiuc.ncsa.security.core.configuration.XProperties
DEFAULT_LIST_SEPARATOR, LOGICAL_FALSES, LOGICAL_TRUES, storeFileName
-
Fields inherited from class java.util.Properties
defaults
-
-
Constructor Summary
Constructors Constructor Description NSProperties()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddNSPrefix(String ns, String prefix)booleangetBoolean(String ns, String key)byte[]getBytes(String ns, String key)DategetDate(String ns, String key)doublegetDouble(String ns, String key)FilegetFile(String ns, String key)FilegetFile(String ns, String key, File parent)intgetInt(String ns, String key)String[]getListByNS(String ns, String key)Get the list using the namespace.String[]getListByNS(String ns, String key, String separator)Get the list using the namespace and the separator.longgetLong(String ns, String key)Collection<String>getNamespaces()protected HashMap<String,String>getNsToPrefix()Support for namespace resolution.Collection<String>getPrefixes()HashMap<String,String>getPrefixToNS()ObjectgetSerializable(String ns, String key)Object[]getSerializableList(String ns, String key)StringgetString(String ns, String key)URIgetURI(String ns, String key)URLgetURL(String ns, String key)voidlist(PrintStream out)voidload(InputStream inStream)voidremoveNS(String ns)protected StringresolveKey(String ns, String key)Resolve a namespace to a single key.voidsetBoolean(String ns, String key, boolean value)voidsetBytes(String ns, String key, byte[] ba)voidsetDate(String ns, String key, Date d)voidsetDouble(String ns, String key, double value)voidsetFile(String ns, String key, File f)voidsetInt(String ns, String key, int value)voidsetList(String ns, String key, String list)voidsetList(String ns, String key, String[] list)voidsetList(String ns, String key, String[] list, String separator)voidsetLong(String ns, String key, long value)ObjectsetProperty(String ns, String key, String value)voidsetSerializable(String ns, String key, Serializable object)voidsetSerializableList(String ns, String key, Object[] oList)voidsetString(String ns, String key, String value)voidsetURI(String ns, String key, String uriString)voidsetURI(String ns, String key, URI uri)voidsetURL(String ns, String key, String urlString)voidsetURL(String ns, String key, URL url)voidstore(OutputStream os, String header)protected StringtoNS(String key)Given a key with a prefix or a namespace, resolve it to the namepsace + key.protected StringtoPrefix(String key)Given a namespace, or a prefix, resolve to the actual namespace.-
Methods inherited from class edu.uiuc.ncsa.security.core.configuration.XProperties
add, add, add, clone, equals, getArrayList, getArrayList, getBoolean, getBytes, getClone, getDate, getDouble, getFile, getFile, getInt, getList, getList, getListSeparator, getLong, getSerializable, getSerializableList, getStoreFileName, getString, getURI, getURL, isEmpty, isList, isList, keySubset, load, load, load, main, setBoolean, setBytes, setDate, setDouble, setFile, setInt, setList, setList, setList, setListSeparator, setLong, setProperty, setSerializable, setSerializableList, setStoreFileName, setString, setURI, setURI, setURL, setURL, store, store, toString
-
Methods inherited from class java.util.Properties
clear, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, forEach, get, getOrDefault, getProperty, getProperty, hashCode, keys, keySet, list, load, loadFromXML, merge, propertyNames, put, putAll, putIfAbsent, rehash, remove, remove, replace, replace, replaceAll, save, size, store, storeToXML, storeToXML, storeToXML, stringPropertyNames, toString, values
-
-
-
-
Field Detail
-
XMLNS_PREFIX
public static final String XMLNS_PREFIX
- See Also:
- Constant Field Values
-
-
Method Detail
-
removeNS
public void removeNS(String ns)
-
getNamespaces
public Collection<String> getNamespaces()
-
getPrefixes
public Collection<String> getPrefixes()
-
getNsToPrefix
protected HashMap<String,String> getNsToPrefix()
Support for namespace resolution.- Returns:
-
resolveKey
protected String resolveKey(String ns, String key)
Resolve a namespace to a single key. This is very simple. It appends the key to the namespace, checking if theXProperties.NAMESPACE_DELIMITERis needed. If there is no namespace provided, this just returns the key.- Parameters:
ns-key-- Returns:
-
toPrefix
protected String toPrefix(String key)
Given a namespace, or a prefix, resolve to the actual namespace.- Parameters:
key-- Returns:
-
toNS
protected String toNS(String key)
Given a key with a prefix or a namespace, resolve it to the namepsace + key. If there is no key this is equivalent to just doing a lookup.- Parameters:
key-- Returns:
-
setSerializable
public void setSerializable(String ns, String key, Serializable object)
-
getListByNS
public String[] getListByNS(String ns, String key, String separator)
Get the list using the namespace and the separator. This is named this way to avoid a method name clash
-
getListByNS
public String[] getListByNS(String ns, String key)
Get the list using the namespace. This is named this way to avoid a method name clash.- Parameters:
ns-key-- Returns:
-
load
public void load(InputStream inStream) throws IOException
- Overrides:
loadin classProperties- Throws:
IOException
-
store
public void store(OutputStream os, String header)
- Overrides:
storein classProperties
-
list
public void list(PrintStream out)
- Overrides:
listin classProperties
-
-