/** * Returns a new {@code ByteSource} instance representing the specified character array's bytes. The byte * array is obtained assuming {@code UTF-8} encoding. * * @param chars the character array to represent as a {@code ByteSource} instance. * @return a new {@code ByteSource} instance representing the specified character array's bytes. */ public static ByteSource bytes(char[] chars) { return new SimpleByteSource(chars); }
public String toString() { return toBase64(); }
public String toBase64() { if ( this.cachedBase64 == null ) { this.cachedBase64 = Base64.encodeToString(getBytes()); } return this.cachedBase64; }
/** * Returns {@code true} if the specified object can be easily represented as a {@code ByteSource} using * the {@link ByteSource.Util}'s default heuristics, {@code false} otherwise. * <p/> * This implementation merely returns {@link SimpleByteSource}.{@link SimpleByteSource#isCompatible(Object) isCompatible(source)}. * * @param source the object to test to see if it can be easily converted to ByteSource instances using default * heuristics. * @return {@code true} if the specified object can be easily represented as a {@code ByteSource} using * the {@link ByteSource.Util}'s default heuristics, {@code false} otherwise. */ public static boolean isCompatible(Object source) { return SimpleByteSource.isCompatible(source); }
@Override public String toHex() { return getDelegate().toHex(); }
@Override public boolean isEmpty() { return getDelegate().isEmpty(); }
/** * Returns {@code true} if the specified object can be easily represented as a {@code ByteSource} using * the {@link ByteSource.Util}'s default heuristics, {@code false} otherwise. * <p/> * This implementation merely returns {@link SimpleByteSource}.{@link SimpleByteSource#isCompatible(Object) isCompatible(source)}. * * @param source the object to test to see if it can be easily converted to ByteSource instances using default * heuristics. * @return {@code true} if the specified object can be easily represented as a {@code ByteSource} using * the {@link ByteSource.Util}'s default heuristics, {@code false} otherwise. */ public static boolean isCompatible(Object source) { return SimpleByteSource.isCompatible(source); }
/** * Returns a new {@code ByteSource} instance representing the specified byte array. * * @param bytes the bytes to represent as a {@code ByteSource} instance. * @return a new {@code ByteSource} instance representing the specified byte array. */ public static ByteSource bytes(byte[] bytes) { return new SimpleByteSource(bytes); }
public String toString() { return toBase64(); }
public String toHex() { if ( this.cachedHex == null ) { this.cachedHex = Hex.encodeToString(getBytes()); } return this.cachedHex; }
/** * Returns a new {@code ByteSource} instance representing the specified string's bytes. The byte * array is obtained assuming {@code UTF-8} encoding. * * @param string the string to represent as a {@code ByteSource} instance. * @return a new {@code ByteSource} instance representing the specified string's bytes. */ public static ByteSource bytes(String string) { return new SimpleByteSource(string); }
public String toString() { return toBase64(); }
public boolean equals(Object o) { if (o == this) { return true; } if (o instanceof ByteSource) { ByteSource bs = (ByteSource) o; return Arrays.equals(getBytes(), bs.getBytes()); } return false; }
/** * Returns a new {@code ByteSource} instance representing the specified File's bytes. * * @param file the file to represent as a {@code ByteSource} instance. * @return a new {@code ByteSource} instance representing the specified File's bytes. */ public static ByteSource bytes(File file) { return new SimpleByteSource(file); }
@Override public String toBase64() { return getDelegate().toBase64(); }
public String toHex() { if ( this.cachedHex == null ) { this.cachedHex = Hex.encodeToString(getBytes()); } return this.cachedHex; }
/** * Returns a new {@code ByteSource} instance representing the specified InputStream's bytes. * * @param stream the InputStream to represent as a {@code ByteSource} instance. * @return a new {@code ByteSource} instance representing the specified InputStream's bytes. */ public static ByteSource bytes(InputStream stream) { return new SimpleByteSource(stream); }
public String toBase64() { if ( this.cachedBase64 == null ) { this.cachedBase64 = Base64.encodeToString(getBytes()); } return this.cachedBase64; }
/** * Returns a new {@code ByteSource} instance representing the specified ByteSource. * * @param source the ByteSource to represent as a new {@code ByteSource} instance. * @return a new {@code ByteSource} instance representing the specified ByteSource. */ public static ByteSource bytes(ByteSource source) { return new SimpleByteSource(source); }
public String toHex() { if ( this.cachedHex == null ) { this.cachedHex = Hex.encodeToString(getBytes()); } return this.cachedHex; }