/** * Constructs an <b>SVNPropertyData</b> given a property name and its * value. * * <p> * if <code>data</code> is not <span class="javakeyword">null</span>, is a * {@link SVNPropertyValue#isString() string} property and <code>name</code> is an * {@link SVNProperty#isSVNProperty(String) svn-namespace} property name, then <code>options</code>, * if not <span class="javakeyword">null</span>, is used to translate the property value replacing * all LF end of line markers in the property value with ones returned by {@link ISVNOptions#getNativeEOL()}. * Otherwise, if <code>options</code> is <span class="javakeyword">null</span>, * the <span class="javastring">"line.separator"</span> system property is used to retrieve a new EOL marker. * * @param name a property name * @param data a property value * @param options provides EOL style information */ public SVNPropertyData(String name, SVNPropertyValue data, ISVNOptions options) { myName = name; myValue = data; if (myValue != null && SVNProperty.isSVNProperty(myName) && myValue.isString()) { String nativeEOL = options == null ? System.getProperty("line.separator") : new String(options.getNativeEOL()); if (myValue.getString().indexOf(nativeEOL) < 0) { myValue = SVNPropertyValue.create(myValue.getString().replaceAll("\n", nativeEOL)); } } }
public static PropertyData createPropertyData(Object client, String path, String name, SVNPropertyValue value) { if (client instanceof SVNClientImpl){ if (value.isString()) { return new JavaHLPropertyData((SVNClientImpl) client, null, path, name, value.getString(), SVNPropertyValue.getPropertyAsBytes(value)); } return new JavaHLPropertyData((SVNClientImpl) client, null, path, name, SVNPropertyValue.getPropertyAsString(value), value.getBytes()); } if (value.isString()) { return new PropertyData((SVNClient) client, path, name, value.getString(), SVNPropertyValue.getPropertyAsBytes(value)); } return new PropertyData((SVNClient) client, path, name, SVNPropertyValue.getPropertyAsString(value), value.getBytes()); }
/** * 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 String getPropertyAsString(SVNPropertyValue value) { if (value == null) { return null; } if (value.isBinary()) { try { return new String(value.getBytes(), "UTF-8"); } catch (UnsupportedEncodingException e) { return new String(value.getBytes()); } } return value.getString(); }
public void changeDirProperty(String name, SVNPropertyValue value) throws SVNException { if (SVNProperty.isRegularProperty(name)) { if (SVNPropertiesManager.propNeedsTranslation(name)) { String normalizedValue = SVNAdminClient.normalizeString(SVNPropertyValue.getPropertyAsString(value)); if (normalizedValue != null) { value = SVNPropertyValue.create(normalizedValue); myNormalizedNodePropsCounter++; } } getWrappedEditor().changeDirProperty(name, value); } }
/** * Says whether this object and <code>obj</code> are equal or not. * * @param obj object to compare with * @return <span class="javakeyword">true</span> in the following cases: * <ul> * <li/><code>obj</code> is the same as this one (by reference) * <li/>if <code>obj</code> is an <code>SVNPropertyValue</code> and either has got the same * <code>String</code> value in case this object holds a <code>String</code> value, or * the same byte array contents if this object represents a binary property value * </ul> */ public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (obj instanceof SVNPropertyValue) { SVNPropertyValue value = (SVNPropertyValue) obj; if (isString()) { return myValue.equals(value.getString()); } else if (isBinary()) { return Arrays.equals(myData, getPropertyAsBytes(value)); } } return false; }
/** * Says whether this object and <code>obj</code> are equal or not. * * @param obj object to compare with * @return <span class="javakeyword">true</span> in the following cases: * <ul> * <li/><code>obj</code> is the same as this one (by reference) * <li/>if <code>obj</code> is an <code>SVNPropertyValue</code> and either has got the same * <code>String</code> value in case this object holds a <code>String</code> value, or * the same byte array contents if this object represents a binary property value * </ul> */ public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (obj instanceof SVNPropertyValue) { SVNPropertyValue value = (SVNPropertyValue) obj; if (isString()) { return myValue.equals(getPropertyAsString(value)); } else if (isBinary()) { return Arrays.equals(myData, getPropertyAsBytes(value)); } } return false; }
public void propertyCreate(String path, String name, String value, int depth, String[] changelists, boolean force) throws ClientException { propertyCreate(path, name, SVNPropertyValue.create(value), depth, changelists, force); }
private static SVNSkel createAtom(SVNPropertyValue propertyValue) { if (propertyValue != null && propertyValue.getString() != null) { return createAtom(propertyValue.getString()); } else if (propertyValue != null && propertyValue.getBytes() != null) { return createAtom(propertyValue.getBytes()); } else { return createAtom(""); } }
private static boolean arePropsEqual(SVNPropertyValue propertyValue1, SVNPropertyValue propertyValue2) { byte[] baseBytes = SVNPropertyValue.getPropertyAsBytes(propertyValue1); byte[] incomingOldBytes = SVNPropertyValue.getPropertyAsBytes(propertyValue2); return Arrays.equals(baseBytes, incomingOldBytes); }
public void changeDirProperty(String name, SVNPropertyValue value) throws SVNException { if (SVNProperty.EXTERNALS.equals(name) && value != null) { myExternals.put(myCurrentPath, value.getString()); } }
private void listExternals(SVNRepository repository, Map<SVNURL, SVNPropertyValue> externals, SVNDepth depth, int entryFields, boolean fetchLocks, ISVNDirEntryHandler handler) throws SVNException { for (Map.Entry<SVNURL, SVNPropertyValue> entry : externals.entrySet()) { SVNURL externalParentUrl = entry.getKey(); SVNPropertyValue externalValue = entry.getValue(); SVNExternal[] externalItems = SVNExternal.parseExternals(externalParentUrl, SVNPropertyValue.getPropertyAsString(externalValue)); if (externalItems == null || externalItems.length == 0) { continue; } listExternalItems(repository, externalItems, externalParentUrl, depth, entryFields, fetchLocks, handler); } }
private File maybeUpdateTargetEols(File oldTargetAbspath, SVNProperties propDiff) throws SVNException { SVNPropertyValue prop = propDiff.getSVNPropertyValue(SVNProperty.EOL_STYLE); if (prop != null && prop.isString()) { byte[] eol = SVNEolStyleInfo.fromValue(prop.getString()).eolStr; File tmpNew = openUniqueFile(null, false).path; SVNTranslator.copyAndTranslate(oldTargetAbspath, tmpNew, null, eol, null, false, false, true); return tmpNew; } return oldTargetAbspath; }
private static boolean equals(SVNPropertyValue oldValue, SVNPropertyValue newValue) { if (oldValue == null || newValue == null) { return oldValue == newValue; } return oldValue.equals(newValue); }
/** * Returns a binary property value. * * @param propertyName property name * @return byte array containing property value bytes; <span class="javakeyword">null</span> * if there's no such property or if it's not a binary property value */ public byte[] getBinaryValue(String propertyName) { SVNPropertyValue value = (SVNPropertyValue) myProperties.get(propertyName); return value == null ? null : value.getBytes(); }
public void changeFileProperty(String path, String name, SVNPropertyValue value) throws SVNException { if (SVNProperty.isRegularProperty(name)) { if (SVNPropertiesManager.propNeedsTranslation(name)) { String normalizedVal = SVNAdminClient.normalizeString(SVNPropertyValue.getPropertyAsString(value)); if (normalizedVal != null) { value = SVNPropertyValue.create(normalizedVal); myNormalizedNodePropsCounter++; } } getWrappedEditor().changeFileProperty(path, name, value); } }
/** * Says whether this object and <code>obj</code> are equal or not. * * @param obj object to compare with * @return <span class="javakeyword">true</span> in the following cases: * <ul> * <li/><code>obj</code> is the same as this one (by reference) * <li/>if <code>obj</code> is an <code>SVNPropertyValue</code> and either has got the same * <code>String</code> value in case this object holds a <code>String</code> value, or * the same byte array contents if this object represents a binary property value * </ul> */ public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (obj instanceof SVNPropertyValue) { SVNPropertyValue value = (SVNPropertyValue) obj; if (isString()) { return myValue.equals(value.getString()); } else if (isBinary()) { return Arrays.equals(myData, getPropertyAsBytes(value)); } } return false; }
public boolean savePassphrase(String realm, char[] passphrase, SVNAuthentication auth, SVNProperties authParameters, boolean force) { if (passphrase == null) { return false; } char[] encrypted = SVNJNAUtil.encrypt(passphrase); if (encrypted == null) { return false; } authParameters.put("passphrase", SVNPropertyValue.create(encrypted, "UTF-8")); return true; }