Package org.tmatesoft.svn.core
Class SVNProperties
java.lang.Object
org.tmatesoft.svn.core.SVNProperties
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
public class SVNProperties
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable
The SVNProperties class represents an object wrapper for
String
to SVNPropertyValue
mappings where
String
keys represent property names and values - property
values wrapped in SVNPropertyValue
objects.
This class is backed by a Map
object and brings specific methods
useful for working with version controlled properties.
Objects of this type are modifiable.
- Since:
- 1.2
- Version:
- 1.3
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate java.util.Map<java.lang.String,
SVNPropertyValue> private static final long
-
Constructor Summary
ConstructorsModifierConstructorDescriptionCreates an emptySVNProperties
object.private
SVNProperties
(java.util.Map properties) SVNProperties
(SVNProperties properties) Creates a newSVNProperties
object copying the given one. -
Method Summary
Modifier and TypeMethodDescriptionjava.util.Map<java.lang.String,
SVNPropertyValue> asMap()
Returns SVNProperties as Map of String, SVNPropertyValue pairs.void
clear()
Removes all properties from this object.java.lang.Object
clone()
Creates and returns a copy of this object.compareTo
(SVNProperties properties) Compares this object against another one returning a difference between them.boolean
containsName
(java.lang.String propertyName) Tells whether this properties object contains the specified property name.boolean
containsValue
(SVNPropertyValue value) Tells whether this properties object contains the specified property value.void
dispose()
boolean
equals
(java.lang.Object obj) Tells whether this object andobj
are equal.byte[]
getBinaryValue
(java.lang.String propertyName) Returns a binary property value.Returns a subset of properties contained in this properties object which suffice forSVNProperty.isRegularProperty(String)
clause.java.lang.String
getStringValue
(java.lang.String propertyName) Returns aString
property value.getSVNPropertyValue
(java.lang.String propertyName) Returns a property value as anSVNPropertyValue
.int
hashCode()
Returns a hash code of this object.boolean
isEmpty()
Tells if this properties object holds no properties (empty).java.util.Set<java.lang.String>
nameSet()
Returns a set of property names contained by this object.void
put
(java.lang.String propertyName, byte[] propertyValue) Stores a new property name-to-value mapping in this object.void
put
(java.lang.String propertyName, char[] propertyValue, java.lang.String encoding) Stores a new property name-to-value mapping in this object.void
put
(java.lang.String propertyName, java.lang.String propertyValue) Stores a new property name-to-value mapping in this object.void
put
(java.lang.String propertyName, SVNPropertyValue propertyValue) Stores a new mappingpropertyName
topropertyValue
in this object.void
putAll
(SVNProperties properties) Puts all properties from the specified properties object to this object.remove
(java.lang.String propertyName) Removes the specified property from this properties object.void
Removes all mappings which values are nulls from this object.int
size()
Returns the number of properties held by this object.java.lang.String
toString()
static SVNProperties
unmodifiableProperties
(SVNProperties properties) Returns an unmodifiable view of the specifiedproperties
.java.util.Collection
values()
Returns a collection of property values contained in this properties object.static SVNProperties
wrap
(java.util.Map map) Creates a newSVNProperties
object wrapping a given map with properties.Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
myProperties
-
-
Constructor Details
-
SVNProperties
public SVNProperties()Creates an emptySVNProperties
object. -
SVNProperties
Creates a newSVNProperties
object copying the given one.- Parameters:
properties
- an initializer
-
SVNProperties
private SVNProperties(java.util.Map properties)
-
-
Method Details
-
wrap
Creates a newSVNProperties
object wrapping a given map with properties.map
is not stored by this object, instead its contents are copied into a newMap
object (which will be backed by a newSVNProperties
object) according to the following rules:-
if the value is of type
String
, then it's wrapped intoSVNPropertyValue
using theSVNPropertyValue.create(String)
method; if the value is of typebyte[]
, then it's wrapped intoSVNPropertyValue
using theSVNPropertyValue.create(String, byte[])
method; if the value is of typeSVNPropertyValue
, then it's not copied but is put into a new map as is;- Parameters:
map
- initial map holding properties- Returns:
SVNProperties
object; ifmap
is null, returns an emptySVNProperties
object created asnew SVNProperties()
- See Also:
-
unmodifiableProperties
Returns an unmodifiable view of the specifiedproperties
. Any attempt to modify the returnedSVNProperties
object result in anUnsupportedOperationException
.- Parameters:
properties
-SVNProperties
object for which an unmodifiable view is to be returned.- Returns:
- an unmodifiable view of the specified properties.
-
asMap
Returns SVNProperties as Map of String, SVNPropertyValue pairs.- Returns:
- copy of SVNProperties as Map object
-
put
Stores a new mappingpropertyName
topropertyValue
in this object.- Parameters:
propertyName
- property namepropertyValue
- property value object
-
put
public void put(java.lang.String propertyName, java.lang.String propertyValue) Stores a new property name-to-value mapping in this object.propertyValue
is converted to anSVNPropertyValue
object through a call toSVNPropertyValue.create(String)
.- Parameters:
propertyName
- property namepropertyValue
- property value string
-
put
public void put(java.lang.String propertyName, char[] propertyValue, java.lang.String encoding) Stores a new property name-to-value mapping in this object.propertyValue
is converted to anSVNPropertyValue
object through a call toSVNPropertyValue.create(String)
.- Parameters:
propertyName
- property namepropertyValue
- property value string
-
put
public void put(java.lang.String propertyName, byte[] propertyValue) Stores a new property name-to-value mapping in this object.propertyValue
is converted to anSVNPropertyValue
object through a call toSVNPropertyValue.create(String, byte[])
.- Parameters:
propertyName
- property namepropertyValue
- property value bytes
-
getStringValue
public java.lang.String getStringValue(java.lang.String propertyName) Returns aString
property value.- Parameters:
propertyName
- property name- Returns:
- property value string; null if
there's no such property or if it's not a
String
property value
-
getBinaryValue
public byte[] getBinaryValue(java.lang.String propertyName) Returns a binary property value.- Parameters:
propertyName
- property name- Returns:
- byte array containing property value bytes; null if there's no such property or if it's not a binary property value
-
getSVNPropertyValue
Returns a property value as anSVNPropertyValue
.- Parameters:
propertyName
- property name- Returns:
- property value object; null if there's no such property
-
remove
Removes the specified property from this properties object.- Parameters:
propertyName
- name of the property to remove from this object- Returns:
- the value of the removed object
-
putAll
Puts all properties from the specified properties object to this object.- Parameters:
properties
- properties object
-
isEmpty
public boolean isEmpty()Tells if this properties object holds no properties (empty).- Returns:
- true if this object holds no properties; otherwise false
-
clear
public void clear()Removes all properties from this object. -
removeNullValues
public void removeNullValues()Removes all mappings which values are nulls from this object. -
size
public int size()Returns the number of properties held by this object.- Returns:
- number of properties
-
containsName
public boolean containsName(java.lang.String propertyName) Tells whether this properties object contains the specified property name.- Parameters:
propertyName
- property name- Returns:
- true if this object contains a
mapping with the specified key (
propertyName
)
-
nameSet
public java.util.Set<java.lang.String> nameSet()Returns a set of property names contained by this object.- Returns:
- property names set
-
containsValue
Tells whether this properties object contains the specified property value.- Parameters:
value
- property value- Returns:
- true if this object contains
value
-
values
public java.util.Collection values()Returns a collection of property values contained in this properties object.- Returns:
- property values collection
-
getRegularProperties
Returns a subset of properties contained in this properties object which suffice forSVNProperty.isRegularProperty(String)
clause.- Returns:
- regular properties; if there are no properties which would
suffice the aforementioned clause, an empty
SVNProperties
object is returned
-
compareTo
Compares this object against another one returning a difference between them. Properties which are present in this object but are not inproperties
, are put to the result as property name to null mappings. Properties which are present only inproperties
but not in this object, are added to the result. Also result will include those properties which are present in both objects but have different values; in this case result will include such properties with values fromproperties
.- Parameters:
properties
- another properties object- Returns:
- properties object holding the properties difference
-
hashCode
public int hashCode()Returns a hash code of this object. A hash code is evaluated as follows:31 +
hash code
of the underlyingMap
holding the property key to property value mappings.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- hash code of this object
-
equals
public boolean equals(java.lang.Object obj) Tells whether this object andobj
are equal.- Overrides:
equals
in classjava.lang.Object
- Parameters:
obj
- object to compare with- Returns:
- true if
obj
is either this very object, or is an instance ofSVNProperties
with the same contents of properties
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedExceptionCreates and returns a copy of this object.- Overrides:
clone
in classjava.lang.Object
- Returns:
- a clone of this instance
- Throws:
java.lang.CloneNotSupportedException
-
toString
public java.lang.String toString()- Overrides:
toString
in classjava.lang.Object
-
dispose
public void dispose()
-