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.SerializableThe SVNProperties class represents an object wrapper forStringtoSVNPropertyValuemappings whereStringkeys represent property names and values - property values wrapped inSVNPropertyValueobjects.This class is backed by a
Mapobject and brings specific methods useful for working with version controlled properties.Objects of this type are modifiable.
- Since:
- 1.2
- Version:
- 1.3
- Author:
- TMate Software Ltd.
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description SVNProperties()Creates an emptySVNPropertiesobject.SVNProperties(SVNProperties properties)Creates a newSVNPropertiesobject copying the given one.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Map<java.lang.String,SVNPropertyValue>asMap()Returns SVNProperties as Map of String, SVNPropertyValue pairs.voidclear()Removes all properties from this object.java.lang.Objectclone()Creates and returns a copy of this object.SVNPropertiescompareTo(SVNProperties properties)Compares this object against another one returning a difference between them.booleancontainsName(java.lang.String propertyName)Tells whether this properties object contains the specified property name.booleancontainsValue(SVNPropertyValue value)Tells whether this properties object contains the specified property value.voiddispose()booleanequals(java.lang.Object obj)Tells whether this object andobjare equal.byte[]getBinaryValue(java.lang.String propertyName)Returns a binary property value.SVNPropertiesgetRegularProperties()Returns a subset of properties contained in this properties object which suffice forSVNProperty.isRegularProperty(String)clause.java.lang.StringgetStringValue(java.lang.String propertyName)Returns aStringproperty value.SVNPropertyValuegetSVNPropertyValue(java.lang.String propertyName)Returns a property value as anSVNPropertyValue.inthashCode()Returns a hash code of this object.booleanisEmpty()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.voidput(java.lang.String propertyName, byte[] propertyValue)Stores a new property name-to-value mapping in this object.voidput(java.lang.String propertyName, char[] propertyValue, java.lang.String encoding)Stores a new property name-to-value mapping in this object.voidput(java.lang.String propertyName, java.lang.String propertyValue)Stores a new property name-to-value mapping in this object.voidput(java.lang.String propertyName, SVNPropertyValue propertyValue)Stores a new mappingpropertyNametopropertyValuein this object.voidputAll(SVNProperties properties)Puts all properties from the specified properties object to this object.SVNPropertyValueremove(java.lang.String propertyName)Removes the specified property from this properties object.voidremoveNullValues()Removes all mappings which values are nulls from this object.intsize()Returns the number of properties held by this object.java.lang.StringtoString()static SVNPropertiesunmodifiableProperties(SVNProperties properties)Returns an unmodifiable view of the specifiedproperties.java.util.Collectionvalues()Returns a collection of property values contained in this properties object.static SVNPropertieswrap(java.util.Map map)Creates a newSVNPropertiesobject wrapping a given map with properties.
-
-
-
Constructor Detail
-
SVNProperties
public SVNProperties()
Creates an emptySVNPropertiesobject.
-
SVNProperties
public SVNProperties(SVNProperties properties)
Creates a newSVNPropertiesobject copying the given one.- Parameters:
properties- an initializer
-
-
Method Detail
-
wrap
public static SVNProperties wrap(java.util.Map map)
Creates a newSVNPropertiesobject wrapping a given map with properties.mapis not stored by this object, instead its contents are copied into a newMapobject (which will be backed by a newSVNPropertiesobject) according to the following rules:-
if the value is of type
String, then it's wrapped intoSVNPropertyValueusing theSVNPropertyValue.create(String)method; if the value is of typebyte[], then it's wrapped intoSVNPropertyValueusing 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:
SVNPropertiesobject; ifmapis null, returns an emptySVNPropertiesobject created asnew SVNProperties()- See Also:
SVNProperties()
-
unmodifiableProperties
public static SVNProperties unmodifiableProperties(SVNProperties properties)
Returns an unmodifiable view of the specifiedproperties. Any attempt to modify the returnedSVNPropertiesobject result in anUnsupportedOperationException.- Parameters:
properties-SVNPropertiesobject for which an unmodifiable view is to be returned.- Returns:
- an unmodifiable view of the specified properties.
-
asMap
public java.util.Map<java.lang.String,SVNPropertyValue> asMap()
Returns SVNProperties as Map of String, SVNPropertyValue pairs.- Returns:
- copy of SVNProperties as Map object
-
put
public void put(java.lang.String propertyName, SVNPropertyValue propertyValue)Stores a new mappingpropertyNametopropertyValuein 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.propertyValueis converted to anSVNPropertyValueobject 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.propertyValueis converted to anSVNPropertyValueobject 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.propertyValueis converted to anSVNPropertyValueobject 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 aStringproperty value.- Parameters:
propertyName- property name- Returns:
- property value string; null if
there's no such property or if it's not a
Stringproperty 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
public SVNPropertyValue getSVNPropertyValue(java.lang.String propertyName)
Returns a property value as anSVNPropertyValue.- Parameters:
propertyName- property name- Returns:
- property value object; null if there's no such property
-
remove
public SVNPropertyValue remove(java.lang.String propertyName)
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
public void putAll(SVNProperties properties)
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
public boolean containsValue(SVNPropertyValue value)
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
public SVNProperties 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
SVNPropertiesobject is returned
-
compareTo
public SVNProperties compareTo(SVNProperties properties)
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 inpropertiesbut 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 codeof the underlyingMapholding the property key to property value mappings.- Overrides:
hashCodein classjava.lang.Object- Returns:
- hash code of this object
-
equals
public boolean equals(java.lang.Object obj)
Tells whether this object andobjare equal.- Overrides:
equalsin classjava.lang.Object- Parameters:
obj- object to compare with- Returns:
- true if
objis either this very object, or is an instance ofSVNPropertieswith the same contents of properties
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedExceptionCreates and returns a copy of this object.- Overrides:
clonein classjava.lang.Object- Returns:
- a clone of this instance
- Throws:
java.lang.CloneNotSupportedException
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
dispose
public void dispose()
-
-