Class SVNPropertyValue

java.lang.Object
org.tmatesoft.svn.core.SVNPropertyValue
All Implemented Interfaces:
java.io.Serializable

public class SVNPropertyValue extends java.lang.Object implements java.io.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
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private byte[]
     
    private java.lang.String
     
    private static final long
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    SVNPropertyValue(byte[] data, int offset, int length)
     
    private
    SVNPropertyValue(char[] propertyValue, java.lang.String encoding)
     
    private
    SVNPropertyValue(java.lang.String propertyValue)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    areEqual(SVNPropertyValue propertyValue1, SVNPropertyValue propertyValue2)
     
    void
     
    create(char[] propertyValue, java.lang.String encoding)
    Creates a new property value object representing a text property value.
    create(java.lang.String propertyValue)
    Creates a new property value object representing a text property value.
    create(java.lang.String propertyName, byte[] data)
    Creates a new property value object from the given byte array.
    create(java.lang.String propertyName, byte[] data, int offset, int length)
    Creates a new property value object from the given byte array.
    boolean
    equals(java.lang.Object obj)
    Says whether this object and obj are equal or not.
    byte[]
    Returns property value bytes.
    static byte[]
    Returns byte[] representation of value.
    static char[]
    Returns String representation of value.
    static java.lang.String
    Returns String representation of value.
    java.lang.String
    Returns property value string.
    int
    Returns the hash code for this object.
    boolean
    Says whether the property value wrapped by this object is binary or not.
    boolean
    Says whether the property value wrapped by this object is String or not.
    java.lang.String
    Returns a string representation of this object.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • myValue

      private java.lang.String myValue
    • myData

      private byte[] myData
  • Constructor Details

    • SVNPropertyValue

      private SVNPropertyValue(byte[] data, int offset, int length)
    • SVNPropertyValue

      private SVNPropertyValue(java.lang.String propertyValue)
    • SVNPropertyValue

      private SVNPropertyValue(char[] propertyValue, java.lang.String encoding)
  • Method Details

    • create

      public static SVNPropertyValue create(java.lang.String propertyName, byte[] data, int offset, int length)
      Creates a new property value object from the given byte array.

      This method is intended to instantiate binary property values. However if propertyName is of svn domain, then it attempts to encode the passed bytes into a String value using the "UTF-8" charset. Finally, the property value object is created via a call to create(String). In this way the text nature of the property is automatically preserved to avoid binary/text properties mess.

      Parameters:
      propertyName - property name
      data - array containing property bytes
      offset - offset in data to copy bytes from
      length - amount of bytes to copy from data
      Returns:
      new property value object; null if data is null
    • create

      public static SVNPropertyValue create(java.lang.String propertyName, byte[] data)
      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 name
      data - array containing property bytes
      Returns:
      new property value object; null if data is null
      See Also:
    • create

      public static SVNPropertyValue create(java.lang.String propertyValue)
      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 propertyValue is null
    • create

      public static SVNPropertyValue create(char[] propertyValue, java.lang.String encoding)
      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 propertyValue is null
    • getPropertyAsBytes

      public static byte[] getPropertyAsBytes(SVNPropertyValue value)
      Returns byte[] representation of value.

      If value is a string property 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 if value is null
    • getPropertyAsString

      public static java.lang.String getPropertyAsString(SVNPropertyValue value)
      Returns String representation of value.

      If value is a binary property value, then its bytes are converted to a String encoding 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 value is null
    • getPropertyAsChars

      public static char[] getPropertyAsChars(SVNPropertyValue value)
      Returns String representation of value.

      If value is a binary property value, then its bytes are converted to a String encoding 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 value is 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 for String property values.

      Returns:
      byte array with property value bytes
    • isString

      public boolean isString()
      Says whether the property value wrapped by this object is String or not.
      Returns:
      true if textual, otherwise false
    • getString

      public java.lang.String getString()
      Returns property value string.

      Note: this will be always null for binary property values.

      Returns:
      property value string
    • toString

      public java.lang.String toString()
      Returns a string representation of this object.

      Note: irrelevant for binary properties.

      Overrides:
      toString in class java.lang.Object
      Returns:
      string representation of this object
    • equals

      public boolean equals(java.lang.Object obj)
      Says whether this object and obj are equal or not.
      Overrides:
      equals in class java.lang.Object
      Parameters:
      obj - object to compare with
      Returns:
      true in the following cases:
      • obj is the same as this one (by reference)
      • if obj is an SVNPropertyValue and either has got the same String value in case this object holds a String value, 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 a string property, then returns the hash code of the String object. Otherwise, this object represents a binary property and the hash code of the byte[] array is returned.
      Overrides:
      hashCode in class java.lang.Object
      Returns:
      hash code
    • areEqual

      public static boolean areEqual(SVNPropertyValue propertyValue1, SVNPropertyValue propertyValue2)
    • clear

      public void clear()