Package com.logicaldoc.util.config
Class ContextProperties
- java.lang.Object
-
- java.util.Dictionary<K,V>
-
- java.util.Hashtable<Object,Object>
-
- java.util.Properties
-
- com.logicaldoc.util.config.OrderedProperties
-
- com.logicaldoc.util.config.ContextProperties
-
- All Implemented Interfaces:
Serializable
,Cloneable
,Map<Object,Object>
public class ContextProperties extends OrderedProperties
A configuration utility used to retrieve and alter context properties- Since:
- 3.0
- Author:
- Marco Meschieri - LogicalDOC
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ContextProperties()
ContextProperties(int maxBackups)
ContextProperties(File file)
ContextProperties(InputStream is)
Creates new XMLBean from an input stream; XMLBean is read-only!!!ContextProperties(String filePath)
ContextProperties(URL fileUrl)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<File>
getBackups()
boolean
getBoolean(String property)
boolean
getBoolean(String property, boolean defaultValue)
double
getDouble(String property)
double
getDouble(String property, double defaultValue)
int
getInt(String property)
int
getInt(String property, int defaultValue)
long
getLong(String property)
long
getLong(String property, long defaultValue)
int
getMaxBackups()
Map<String,String>
getProperties(String prefix)
Gets all the properties whose name starts with the given prefix.String
getPropertyWithSubstitutions(String property)
Gets the property value replacing all variable referencesString
getPropertyWithSubstitutions(String property, String defaultValue)
String
getString(String property)
String
getString(String property, String defaultValue)
Map<String,String>
getTenantProperties(String tenant)
String
getTenantProperty(String tenant, String property)
void
removeTenantProperties(String tenant)
Removes all the properties of a specific tenantvoid
replicateTenantSettings(String tenant)
Replicates the settings of the default tenant to a new tenantvoid
setMaxBackups(int maxBackups)
void
write()
This method saves the properties-file connected by ContextProperties.
NOTE: only call this on an ContextProperties _NOT_ created from an InputStream!-
Methods inherited from class com.logicaldoc.util.config.OrderedProperties
getKeys, keys, store
-
Methods inherited from class java.util.Properties
clear, clone, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, equals, forEach, get, getOrDefault, getProperty, getProperty, hashCode, isEmpty, keySet, list, list, load, load, loadFromXML, merge, propertyNames, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, save, setProperty, size, store, storeToXML, storeToXML, storeToXML, stringPropertyNames, toString, values
-
-
-
-
Constructor Detail
-
ContextProperties
public ContextProperties(int maxBackups) throws IOException
- Throws:
IOException
-
ContextProperties
public ContextProperties() throws IOException
- Throws:
IOException
-
ContextProperties
public ContextProperties(String filePath) throws IOException
- Throws:
IOException
-
ContextProperties
public ContextProperties(URL fileUrl) throws IOException
- Throws:
IOException
-
ContextProperties
public ContextProperties(File file) throws IOException
- Throws:
IOException
-
ContextProperties
public ContextProperties(InputStream is) throws IOException
Creates new XMLBean from an input stream; XMLBean is read-only!!!- Parameters:
is
- the stream that represents the XML to parse- Throws:
IOException
- raised when the stream cannot be read
-
-
Method Detail
-
write
public void write() throws IOException
This method saves the properties-file connected by ContextProperties.
NOTE: only call this on an ContextProperties _NOT_ created from an InputStream!- Throws:
IOException
- raised when the file cannot be written
-
getBackups
public List<File> getBackups() throws IOException
- Throws:
IOException
-
getInt
public int getInt(String property)
-
getInt
public int getInt(String property, int defaultValue)
-
getLong
public long getLong(String property)
-
getLong
public long getLong(String property, long defaultValue)
-
getBoolean
public boolean getBoolean(String property)
-
getBoolean
public boolean getBoolean(String property, boolean defaultValue)
-
getDouble
public double getDouble(String property)
-
getDouble
public double getDouble(String property, double defaultValue)
-
getPropertyWithSubstitutions
public String getPropertyWithSubstitutions(String property)
Gets the property value replacing all variable references- Parameters:
property
- name of the setting to process- Returns:
- the porperty's value with expanded variables
-
getPropertyWithSubstitutions
public String getPropertyWithSubstitutions(String property, String defaultValue)
-
getMaxBackups
public int getMaxBackups()
-
setMaxBackups
public void setMaxBackups(int maxBackups)
-
getProperties
public Map<String,String> getProperties(String prefix)
Gets all the properties whose name starts with the given prefix.- Parameters:
prefix
- property's prefix- Returns:
- the map property_name = property_value
-
removeTenantProperties
public void removeTenantProperties(String tenant)
Removes all the properties of a specific tenant- Parameters:
tenant
- name of the tenant
-
replicateTenantSettings
public void replicateTenantSettings(String tenant)
Replicates the settings of the default tenant to a new tenant- Parameters:
tenant
- name of the tenant
-
-