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 class
NSProperties.StringLengthComparator
-
Field Summary
Fields Modifier and Type Field Description static String
XMLNS_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 void
addNSPrefix(String ns, String prefix)
boolean
getBoolean(String ns, String key)
byte[]
getBytes(String ns, String key)
Date
getDate(String ns, String key)
double
getDouble(String ns, String key)
File
getFile(String ns, String key)
File
getFile(String ns, String key, File parent)
int
getInt(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.long
getLong(String ns, String key)
Collection<String>
getNamespaces()
protected HashMap<String,String>
getNsToPrefix()
Support for namespace resolution.Collection<String>
getPrefixes()
HashMap<String,String>
getPrefixToNS()
Object
getSerializable(String ns, String key)
Object[]
getSerializableList(String ns, String key)
String
getString(String ns, String key)
URI
getURI(String ns, String key)
URL
getURL(String ns, String key)
void
list(PrintStream out)
void
load(InputStream inStream)
void
removeNS(String ns)
protected String
resolveKey(String ns, String key)
Resolve a namespace to a single key.void
setBoolean(String ns, String key, boolean value)
void
setBytes(String ns, String key, byte[] ba)
void
setDate(String ns, String key, Date d)
void
setDouble(String ns, String key, double value)
void
setFile(String ns, String key, File f)
void
setInt(String ns, String key, int value)
void
setList(String ns, String key, String list)
void
setList(String ns, String key, String[] list)
void
setList(String ns, String key, String[] list, String separator)
void
setLong(String ns, String key, long value)
Object
setProperty(String ns, String key, String value)
void
setSerializable(String ns, String key, Serializable object)
void
setSerializableList(String ns, String key, Object[] oList)
void
setString(String ns, String key, String value)
void
setURI(String ns, String key, String uriString)
void
setURI(String ns, String key, URI uri)
void
setURL(String ns, String key, String urlString)
void
setURL(String ns, String key, URL url)
void
store(OutputStream os, String header)
protected String
toNS(String key)
Given a key with a prefix or a namespace, resolve it to the namepsace + key.protected String
toPrefix(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_DELIMITER
is 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:
load
in classProperties
- Throws:
IOException
-
store
public void store(OutputStream os, String header)
- Overrides:
store
in classProperties
-
list
public void list(PrintStream out)
- Overrides:
list
in classProperties
-
-