Example #1
0
 /**
  * Returns <code>String</code> representation of <code>value</code>.
  *
  * <p>If <code>value</code> is a {@link SVNPropertyValue#isBinary() binary} property value, then
  * its bytes are converted to a <code>String</code> encoding them with the <span
  * class="javastring">"UTF-8"</span> charset and returned back to the caller. If that encoding
  * fails, bytes are encoded with the default platform's charset.
  *
  * <p>Otherwise, {@link SVNPropertyValue#getString()} is returned.
  *
  * @param value property value object
  * @return string property value; <span class="javakeyword">null</span> if <code>value</code> is
  *     <span class="javakeyword">null</span>
  */
 public static char[] getPropertyAsChars(SVNPropertyValue value) {
   if (value == null) {
     return null;
   }
   if (value.isBinary()) {
     return SVNEncodingUtil.getChars(value.getBytes(), "UTF-8");
   }
   return value.getString().toCharArray();
 }
 public static StringBuffer generateFileRevisionsRequest(
     StringBuffer buffer, long startRevision, long endRevision, String path) {
   buffer = buffer == null ? new StringBuffer() : buffer;
   buffer.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
   buffer.append("<S:file-revs-report xmlns:S=\"svn:\">");
   if (startRevision >= 0) {
     buffer.append("<S:start-revision>" + startRevision + "</S:start-revision>");
   }
   if (endRevision >= 0) {
     buffer.append("<S:end-revision>" + endRevision + "</S:end-revision>");
   }
   buffer.append("<S:path>" + SVNEncodingUtil.xmlEncodeCDATA(path) + "</S:path>");
   buffer.append("</S:file-revs-report>");
   return buffer;
 }
Example #3
0
  public static DAVLock convertSVNLockToDAVLock(FSLock lock, boolean hideAuthUser, boolean exists) {
    String authUser = null;
    StringBuffer owner = null;
    if (lock.getComment() != null) {
      owner = new StringBuffer();
      if (!lock.isDAVComment()) {
        List namespaces = new ArrayList(1);
        namespaces.add(DAVElement.DAV_NAMESPACE);
        owner =
            DAVXMLUtil.openNamespaceDeclarationTag(
                SVNXMLUtil.DAV_NAMESPACE_PREFIX,
                DAVElement.LOCK_OWNER.getName(),
                namespaces,
                null,
                owner,
                false,
                false);
        owner.append(SVNEncodingUtil.xmlEncodeCDATA(lock.getComment(), true));
        owner =
            SVNXMLUtil.addXMLFooter(
                SVNXMLUtil.DAV_NAMESPACE_PREFIX, DAVElement.LOCK_OWNER.getName(), owner);
      } else {
        owner.append(lock.getComment());
      }
    }

    if (!hideAuthUser) {
      authUser = lock.getOwner();
    }

    return new DAVLock(
        authUser,
        DAVDepth.DEPTH_ZERO,
        exists,
        lock.getID(),
        owner != null ? owner.toString() : null,
        DAVLockRecType.DIRECT,
        DAVLockScope.EXCLUSIVE,
        DAVLockType.WRITE,
        lock.getExpirationDate());
  }
Example #4
0
 public void clear() {
   SVNEncodingUtil.clearArray(myData);
   myValue = null;
 }
Example #5
0
 private SVNPropertyValue(char[] propertyValue, String encoding) {
   myData = SVNEncodingUtil.getBytes(propertyValue, encoding == null ? "UTF-8" : encoding);
 }