Package de.mhus.lib.core
Class MProperties
- java.lang.Object
-
- de.mhus.lib.core.MLog
-
- de.mhus.lib.core.lang.MObject
-
- de.mhus.lib.core.AbstractProperties
-
- de.mhus.lib.core.MProperties
-
- All Implemented Interfaces:
ILog,IProperties,IReadProperties,MNlsProvider,Nls,Externalizable,Serializable,Iterable<Map.Entry<String,Object>>,Map<String,Object>
- Direct Known Subclasses:
LogProperties,PemBlockModel
public class MProperties extends AbstractProperties implements Externalizable
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Propertiesproperties
-
Constructor Summary
Constructors Constructor Description MProperties()MProperties(IProperties in)MProperties(IReadProperties in)MProperties(String... values)MProperties(Dictionary<?,?> config)MProperties(Map<?,?> in)MProperties(Properties properties)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidappendToMap(Map<?,?> p, String para)static voidappendToMap(Map<?,?> p, String para, char keySeparator, char typeSeparator)voidclear()booleancontainsValue(Object value)Set<Map.Entry<String,Object>>entrySet()static MPropertiesexplodeToMProperties(String properties)This will handle the strings like properties.static MPropertiesexplodeToMProperties(String[] properties)This will handle the strings like properties.static MPropertiesexplodeToMProperties(String[] properties, char keySeparator, char typeSeparator)This will handle the strings like properties.static MPropertiesexplodeToMProperties(String[] properties, char keySeparator, char typeSeparator, int offset, int length)static MPropertiesexplodeToMProperties(String[] properties, int offset, int length)static MPropertiesexplodeToOptions(String properties)This will handle the strings like options.static MPropertiesexplodeToOptions(String[] properties)This will handle the strings like options.static MPropertiesexplodeToOptions(String[] properties, char separator)This will handle the strings like options.static PropertiesexplodeToProperties(String[] properties)This will handle the strings like properties.ObjectgetProperty(String name)Overwrite this function to provide values in string format.booleanisEditable()Overwrite this function and return true if the property set can be edited.static booleanisFunctional(String key)Return true if key starts with underscore but not with two underscores.booleanisProperty(String name)Return true if the property exists.Set<String>keys()static MPropertiesload(File f)static MPropertiesload(InputStream inStream)static MPropertiesload(Reader is)static MPropertiesload(String fileName)static MPropertiesloadOrEmpty(File f)voidputAll(String prefix, Map<?,?> map)voidreadExternal(ObjectInput in)voidremoveProperty(String key)Remove the property field in the list of properties.booleansave(File file)booleansave(OutputStream out)voidsetProperty(String key, Object value)Overwrite this function to allow changes in properties.intsize()static IPropertiestoIProperties(IReadProperties properties)static MPropertiestoMProperties(IReadProperties properties)StringtoString()static voidupdateFunctional(Map<String,Object> in)In this scenario we separate between functional parameters (starting with one underscore) and data.Collection<Object>values()voidwriteExternal(ObjectOutput out)-
Methods inherited from class de.mhus.lib.core.AbstractProperties
containsKey, get, getBoolean, getBoolean, getCalendar, getDate, getDouble, getFloat, getFormatted, getInt, getLong, getNumber, getString, getString, isEmpty, iterator, keySet, put, putAll, putReadProperties, remove, setBoolean, setCalendar, setDate, setDouble, setFloat, setInt, setLong, setNumber, setString, toMap
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
-
-
-
-
Field Detail
-
properties
protected Properties properties
-
-
Constructor Detail
-
MProperties
public MProperties()
-
MProperties
public MProperties(String... values)
-
MProperties
public MProperties(Dictionary<?,?> config)
-
MProperties
public MProperties(Map<?,?> in)
-
MProperties
public MProperties(IReadProperties in)
-
MProperties
public MProperties(IProperties in)
-
MProperties
public MProperties(Properties properties)
-
-
Method Detail
-
getProperty
public Object getProperty(String name)
Description copied from class:AbstractPropertiesOverwrite this function to provide values in string format.- Specified by:
getPropertyin interfaceIReadProperties- Specified by:
getPropertyin classAbstractProperties- Returns:
- null if the property not exists or the property value.
-
isProperty
public boolean isProperty(String name)
Description copied from class:AbstractPropertiesReturn true if the property exists.- Specified by:
isPropertyin interfaceIReadProperties- Specified by:
isPropertyin classAbstractProperties- Returns:
- if exists
-
removeProperty
public void removeProperty(String key)
Description copied from class:AbstractPropertiesRemove the property field in the list of properties.- Specified by:
removePropertyin interfaceIProperties- Specified by:
removePropertyin classAbstractProperties
-
setProperty
public void setProperty(String key, Object value)
Description copied from class:AbstractPropertiesOverwrite this function to allow changes in properties.- Specified by:
setPropertyin classAbstractProperties
-
isEditable
public boolean isEditable()
Description copied from class:AbstractPropertiesOverwrite this function and return true if the property set can be edited.- Specified by:
isEditablein interfaceIProperties- Specified by:
isEditablein classAbstractProperties- Returns:
- if is editable
-
keys
public Set<String> keys()
- Specified by:
keysin interfaceIReadProperties- Specified by:
keysin classAbstractProperties- Returns:
- the keys
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
explodeToOptions
public static MProperties explodeToOptions(String properties)
This will handle the strings like options. Means a string without separator will handled as key and set to true. e.g. val1&val2&a=b will be val1=true, val2=true, a=b- Parameters:
properties- Rfc1738 (Url Encode) encoded string- Returns:
- The MProperties
-
explodeToOptions
public static MProperties explodeToOptions(String[] properties)
This will handle the strings like options. Means a string without separator will handled as key and set to true. e.g. [val1, val2, a=b] will be val1=true, val2=true, a=b- Parameters:
properties-- Returns:
- The MProperties
-
explodeToMProperties
public static MProperties explodeToMProperties(String properties)
This will handle the strings like properties. Means a string without separator will be stored as value with an increasing key as integer, e.g. val1&val2&a=b will be 0=val1, 1=val2, a=b- Parameters:
properties- Rfc1738 (Url Encoded) encoded string- Returns:
- The MProperties
-
explodeToMProperties
public static MProperties explodeToMProperties(String[] properties)
This will handle the strings like properties. Means a string without separator will be stored as value with an increasing key as integer, e.g. [val1, val2, a=b] will be 0=val1, 1=val2, a=b- Parameters:
properties-- Returns:
- The MProperties
-
explodeToMProperties
public static MProperties explodeToMProperties(String[] properties, int offset, int length)
-
explodeToOptions
public static MProperties explodeToOptions(String[] properties, char separator)
This will handle the strings like options. Means a string without separator will handled as key and set to true. e.g. [val1, val2, a=b] will be val1=true, val2=true, a=b- Parameters:
properties-separator-- Returns:
- The MProperties
-
explodeToMProperties
public static MProperties explodeToMProperties(String[] properties, char keySeparator, char typeSeparator)
This will handle the strings like properties. Means a string without separator will be stored as value with an increasing key as integer, e.g. [val1, val2, a=b] will be 0=val1, 1=val2, a=b- Parameters:
properties-keySeparator-typeSeparator-- Returns:
- The MProperties
-
explodeToMProperties
public static MProperties explodeToMProperties(String[] properties, char keySeparator, char typeSeparator, int offset, int length)
-
explodeToProperties
public static Properties explodeToProperties(String[] properties)
This will handle the strings like properties. Means a string without separator will be stored as value with an increasing key as integer, e.g. [val1, val2, a=b] will be 0=val1, 1=val2, a=b- Parameters:
properties-- Returns:
- The Properties
-
containsValue
public boolean containsValue(Object value)
- Specified by:
containsValuein interfaceIReadProperties- Specified by:
containsValuein interfaceMap<String,Object>
-
values
public Collection<Object> values()
-
load
public static MProperties load(String fileName)
-
loadOrEmpty
public static MProperties loadOrEmpty(File f)
-
load
public static MProperties load(File f)
-
load
public static MProperties load(InputStream inStream) throws IOException
- Throws:
IOException
-
load
public static MProperties load(Reader is)
-
size
public int size()
-
save
public boolean save(File file) throws IOException
- Throws:
IOException
-
save
public boolean save(OutputStream out) throws IOException
- Throws:
IOException
-
clear
public void clear()
-
updateFunctional
public static void updateFunctional(Map<String,Object> in)
In this scenario we separate between functional parameters (starting with one underscore) and data. Using this method functional parameters can be cascaded over multiple levels. Will remove all parameters starting with underscore and not two underscore and remove one underscore from thoos with more underscores. _test will be removed __test will be _test after update- Parameters:
in-
-
isFunctional
public static boolean isFunctional(String key)
Return true if key starts with underscore but not with two underscores.- Parameters:
key-- Returns:
- true if actual internal
-
toIProperties
public static IProperties toIProperties(IReadProperties properties)
-
toMProperties
public static MProperties toMProperties(IReadProperties properties)
-
-