X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.jcr%2Fsrc%2Forg%2Fargeo%2Fjcr%2FBin.java;fp=org.argeo.jcr%2Fsrc%2Forg%2Fargeo%2Fjcr%2FBin.java;h=0000000000000000000000000000000000000000;hb=623a0db2d0f161c101b9e41abcaccc04d478d32a;hp=0418810ed0188ed58efc191003914702e22dfb35;hpb=46cc2039ac20703c484aa994b830a2da113f2c97;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.jcr/src/org/argeo/jcr/Bin.java b/org.argeo.jcr/src/org/argeo/jcr/Bin.java deleted file mode 100644 index 0418810ed..000000000 --- a/org.argeo.jcr/src/org/argeo/jcr/Bin.java +++ /dev/null @@ -1,60 +0,0 @@ -package org.argeo.jcr; - -import java.io.IOException; -import java.io.InputStream; - -import javax.jcr.Binary; -import javax.jcr.Property; -import javax.jcr.RepositoryException; - -/** - * A {@link Binary} wrapper implementing {@link AutoCloseable} for ease of use - * in try/catch blocks. - */ -public class Bin implements Binary, AutoCloseable { - private final Binary wrappedBinary; - - public Bin(Property property) throws RepositoryException { - this(property.getBinary()); - } - - public Bin(Binary wrappedBinary) { - if (wrappedBinary == null) - throw new IllegalArgumentException("Wrapped binary cannot be null"); - this.wrappedBinary = wrappedBinary; - } - - // private static Binary getBinary(Property property) throws IOException { - // try { - // return property.getBinary(); - // } catch (RepositoryException e) { - // throw new IOException("Cannot get binary from property " + property, e); - // } - // } - - @Override - public void close() { - dispose(); - } - - @Override - public InputStream getStream() throws RepositoryException { - return wrappedBinary.getStream(); - } - - @Override - public int read(byte[] b, long position) throws IOException, RepositoryException { - return wrappedBinary.read(b, position); - } - - @Override - public long getSize() throws RepositoryException { - return wrappedBinary.getSize(); - } - - @Override - public void dispose() { - wrappedBinary.dispose(); - } - -}