Package org.tmatesoft.svn.core
Class SVNPropertyValue
java.lang.Object
org.tmatesoft.svn.core.SVNPropertyValue
- All Implemented Interfaces:
Serializable
The SVNPropertyValue represents an object wrapper for string and binary version controlled
properties providing a set of specific methods to work with them.
Since version 1.2 the
SVNKit library supports binary properties as well.- Since:
- 1.2
- Version:
- 1.3
- Author:
- TMate Software Ltd.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanareEqual(SVNPropertyValue propertyValue1, SVNPropertyValue propertyValue2) voidclear()static SVNPropertyValueCreates a new property value object representing a text property value.static SVNPropertyValueCreates a new property value object representing a text property value.static SVNPropertyValueCreates a new property value object from the given byte array.static SVNPropertyValueCreates a new property value object from the given byte array.booleanSays whether this object andobjare equal or not.byte[]getBytes()Returns property value bytes.static byte[]Returnsbyte[]representation ofvalue.static char[]ReturnsStringrepresentation ofvalue.static StringReturnsStringrepresentation ofvalue.Returns property value string.inthashCode()Returns the hash code for this object.booleanisBinary()Says whether the property value wrapped by this object is binary or not.booleanisString()Says whether the property value wrapped by this object isStringor not.toString()Returns a string representation of this object.
-
Method Details
-
create
Creates a new property value object from the given byte array.This method is intended to instantiate binary property values. However if
propertyNameis ofsvn domain, then it attempts to encode the passed bytes into aStringvalue using the "UTF-8" charset. Finally, the property value object is created via a call tocreate(String). In this way the text nature of the property is automatically preserved to avoid binary/text properties mess.- Parameters:
propertyName- property namedata- array containing property bytesoffset- offset indatato copy bytes fromlength- amount of bytes to copy fromdata- Returns:
- new property value object; null if
datais null
-
create
Creates a new property value object from the given byte array.This method is equivalent to
create(propertyName, data, 0, data.length).- Parameters:
propertyName- property namedata- array containing property bytes- Returns:
- new property value object; null if
datais null - See Also:
-
create
Creates a new property value object representing a text property value. This method is intended to create text property values only.- Parameters:
propertyValue- text property value which is stored as is- Returns:
- new property value object; null if
propertyValueis null
-
create
Creates a new property value object representing a text property value. This method is intended to create text property values only.- Parameters:
propertyValue- text property value which is stored as is- Returns:
- new property value object; null if
propertyValueis null
-
getPropertyAsBytes
Returnsbyte[]representation ofvalue. Ifvalueis astringproperty value, then bytes of the string are encoded using the "UTF-8" charset and returned by this method. If encoding fails, then bytes are encoded using the default platform's charset. Otherwise,getBytes()is returned.- Parameters:
value- property value object- Returns:
- bytes of the property value represented by
value; null ifvalueis null
-
getPropertyAsString
ReturnsStringrepresentation ofvalue. Ifvalueis abinaryproperty value, then its bytes are converted to aStringencoding them with the "UTF-8" charset and returned back to the caller. If that encoding fails, bytes are encoded with the default platform's charset. Otherwise,getString()is returned.- Parameters:
value- property value object- Returns:
- string property value; null if
valueis null
-
getPropertyAsChars
ReturnsStringrepresentation ofvalue. Ifvalueis abinaryproperty value, then its bytes are converted to aStringencoding them with the "UTF-8" charset and returned back to the caller. If that encoding fails, bytes are encoded with the default platform's charset. Otherwise,getString()is returned.- Parameters:
value- property value object- Returns:
- string property value; null if
valueis null
-
isBinary
public boolean isBinary()Says whether the property value wrapped by this object is binary or not.- Returns:
- true if binary, otherwise false
-
getBytes
public byte[] getBytes()Returns property value bytes. Note: this will be always null forStringproperty values.- Returns:
- byte array with property value bytes
-
isString
public boolean isString()Says whether the property value wrapped by this object isStringor not.- Returns:
- true if textual, otherwise false
-
getString
Returns property value string. Note: this will be always null for binary property values.- Returns:
- property value string
-
toString
Returns a string representation of this object. Note: irrelevant for binary properties. -
equals
Says whether this object andobjare equal or not.- Overrides:
equalsin classObject- Parameters:
obj- object to compare with- Returns:
- true in the following cases:
objis the same as this one (by reference) ifobjis anSVNPropertyValueand either has got the sameStringvalue in case this object holds aStringvalue, or the same byte array contents if this object represents a binary property value
-
hashCode
public int hashCode()Returns the hash code for this object. If this object represents astringproperty, then returns the hash code of theStringobject. Otherwise, this object represents a binary property and the hash code of thebyte[]array is returned. -
areEqual
-
clear
public void clear()
-