/** * 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(); }
/** * 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(); }
/** * 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(); }
/** * 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(); }
/** * 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(); }
private byte[] getPropertyAsBytes(SVNPropertyValue value, String encoding){ if (value == null){ return null; } if (value.isString()){ try { return value.getString().getBytes(encoding); } catch (UnsupportedEncodingException e) { return value.getString().getBytes(); } } return value.getBytes(); }
private byte[] getPropertyAsBytes(SVNPropertyValue value, String encoding){ if (value == null){ return null; } if (value.isString()){ try { return value.getString().getBytes(encoding); } catch (UnsupportedEncodingException e) { return value.getString().getBytes(); } } return value.getBytes(); }
private byte[] getPropertyAsBytes(SVNPropertyValue value, String encoding){ if (value == null){ return null; } if (value.isString()){ try { return value.getString().getBytes(encoding); } catch (UnsupportedEncodingException e) { return value.getString().getBytes(); } } return value.getBytes(); }
private byte[] getPropertyAsBytes(SVNPropertyValue value, String encoding){ if (value == null){ return null; } if (value.isString()){ try { return value.getString().getBytes(encoding); } catch (UnsupportedEncodingException e) { return value.getString().getBytes(); } } return value.getBytes(); }
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(""); } }
/** * Returns <code>byte[]</code> representation of <code>value</code>. * * <p/> * If <code>value</code> is a {@link SVNPropertyValue#isString() string} property value, then bytes of * the string are encoded using the <span class="javastring">"UTF-8"</span> charset and returned by this * method. If encoding fails, then bytes are encoded using the default platform's charset. * * <p/> * Otherwise, {@link SVNPropertyValue#getBytes()} is returned. * * @param value property value object * @return bytes of the property value represented by <code>value</code>; * <span class="javakeyword">null</span> if <code>value</code> is * <span class="javakeyword">null</span> */ public static byte[] getPropertyAsBytes(SVNPropertyValue value) { if (value == null) { return null; } if (value.isString()) { try { return value.getString().getBytes("UTF-8"); } catch (UnsupportedEncodingException e) { return value.getString().getBytes(); } } return 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 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 void prependPropValue(SVNPropertyValue fromVal, SVNSkel skel) throws SVNException { SVNSkel valueSkel = SVNSkel.createEmptyList(); if (fromVal != null && (fromVal.getBytes() != null || fromVal.getString() != null)) { valueSkel.prependPropertyValue(fromVal); } skel.prepend(valueSkel); }
@NotNull private RevCommit getCommit(@NotNull Repository git, @NotNull SVNPropertyValue hash) throws IOException { return new RevWalk(git).parseCommit(ObjectId.fromString(new String(hash.getBytes()))); }
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()); }
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()); }
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()); }
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()); }
protected void printProperty(SVNPropertyValue value, boolean isPropListLike, boolean omitNewLine) { if (value.isString()) { String stringValue = value.getString(); if (isPropListLike) { stringValue += '\n'; String[] lines = SVNCommandUtil.breakToLines(stringValue); for (int i = 0; lines != null && i < lines.length; i++) { String line = lines[i]; getSVNEnvironment().getOut().print(" "); getSVNEnvironment().getOut().print(line); } } else { getSVNEnvironment().getOut().print(stringValue); } } else { try { if (isPropListLike) { //indent here getSVNEnvironment().getOut().print(" "); } getSVNEnvironment().getOut().write(value.getBytes()); if (isPropListLike) { if (!omitNewLine) { getSVNEnvironment().getOut().println(); } } } catch (IOException e) { } } }
private void checkReplaySelf(@NotNull ReplayMethod replayMethod) throws Exception { try ( SvnTestServer src = SvnTestServer.createMasterRepository(); SvnTestServer dst = SvnTestServer.createEmpty() ) { final SVNRepository srcRepo = src.openSvnRepository(); final SVNRepository dstRepo = dst.openSvnRepository(); final Repository srcGit = src.getRepository(); final Repository dstGit = dst.getRepository(); final long lastRevision = Math.min(200, srcRepo.getLatestRevision()); log.info("Start replay"); for (long revision = 1; revision <= lastRevision; revision++) { final SVNPropertyValue message = srcRepo.getRevisionPropertyValue(revision, "svn:log"); final SVNPropertyValue srcHash = srcRepo.getRevisionPropertyValue(revision, SvnConstants.PROP_GIT); log.info(" replay commit #{} {}: {}", revision, new String(srcHash.getBytes()), StringHelper.getFirstLine(message.getString())); replayMethod.replay(srcRepo, dstRepo, revision); log.info(" compare revisions #{}: {}", revision, StringHelper.getFirstLine(message.getString())); compareRevision(srcRepo, revision, dstRepo, revision); final SVNPropertyValue dstHash = dstRepo.getRevisionPropertyValue(revision, SvnConstants.PROP_GIT); compareGitRevision(srcGit, srcHash, dstGit, dstHash); } log.info("End replay"); } }