Package javax.jcr

Examples of javax.jcr.Binary


    }

    /** Wrapper around {@link #setValue(Value)} */
    public void setValue(InputStream value) throws RepositoryException {
        if (value != null) {
            Binary binary = getValueFactory().createBinary(value);
            try {
                setValue(getValueFactory().createValue(binary));
            } finally {
                binary.dispose();
            }
        } else {
            setValue((Value) null);
        }
    }
View Full Code Here


     * mechanism to provide random access defined on {@link Binary}.
     *
     * @see QValue#getBinary()
     */
    public Binary getBinary() throws RepositoryException {
        return new Binary() {
            public InputStream getStream() throws RepositoryException {
                return AbstractQValue.this.getStream();
            }

            public int read(byte[] b, long position) throws IOException, RepositoryException {
View Full Code Here

                }
                pack = new ZipVaultPackage(archive, true);
            } else {
                File tmpFile = File.createTempFile("vaultpack", ".zip");
                FileOutputStream out = FileUtils.openOutputStream(tmpFile);
                Binary bin = getData().getBinary();
                InputStream in = null;
                try {
                    in = bin.getStream();
                    IOUtils.copy(in, out);
                } finally {
                    IOUtils.closeQuietly(in);
                    IOUtils.closeQuietly(out);
                    bin.dispose();
                }
                pack = new ZipVaultPackage(tmpFile, true);
            }
        }
        return pack;
View Full Code Here

        /**
         * @see QValue#getBinary()
         */
        public Binary getBinary() throws RepositoryException {
            // TODO FIXME consolidate Binary implementations
            return new Binary() {
                public InputStream getStream() throws RepositoryException {
                    return QValueImpl.this.getStream();
                }

                public int read(byte[] b, long position) throws IOException, RepositoryException {
View Full Code Here

        /**
         * @see QValue#getBinary()
         */
        public Binary getBinary() throws RepositoryException {
            // TODO FIXME consolidate Binary implementations
            return new Binary() {
                public InputStream getStream() throws RepositoryException {
                    return QValueImpl.this.getStream();
                }

                public int read(byte[] b, long position) throws IOException, RepositoryException {
View Full Code Here

         * @see QValue#getBinary()
         */
        public Binary getBinary() throws RepositoryException {
            // TODO FIXME consolidate Binary implementations
            // TODO optimize
            return new Binary() {
                public InputStream getStream() throws RepositoryException {
                    return BinaryQValue.this.getStream();
                }

                public int read(byte[] b, long position) throws IOException, RepositoryException {
View Full Code Here

        return getValue().getString();
    }

    /** Wrapper around {@link #getValue()} */
    public InputStream getStream() throws RepositoryException {
        final Binary binary = getValue().getBinary();
        // make sure binary is disposed after stream had been consumed
        return new AutoCloseInputStream(binary.getStream()) {
            public void close() throws IOException {
                super.close();
                binary.dispose();
            }
        };
    }
View Full Code Here

        }
    }

    private void spoolSingleValued(OutputStream out) throws IOException {
        try {
            Binary binary = ((Property) item).getBinary();
            try {
                InputStream in = binary.getStream();
                try {
                    IOUtil.spool(in, out);
                } finally {
                    in.close();
                }
            } finally {
                binary.dispose();
            }
        } catch (RepositoryException e) {
            log.error("Cannot obtain stream from " + item, e);
        }
    }
View Full Code Here

    /** Wrapper around {@link #setProperty(String, Value)} */
    public Property setProperty(String name, InputStream value)
            throws RepositoryException {
        if (value != null) {
            Binary binary = getValueFactory().createBinary(value);
            try {
                return setProperty(name, getValueFactory().createValue(binary));
            } finally {
                binary.dispose();
            }
        } else {
            return setProperty(name, (Value) null);
        }
    }
View Full Code Here

                            }
                        }
                    }
                }
                if (blob == null) {
                    Binary b = value.getBinary();
                    boolean dispose = false;
                    try {
                        if (b instanceof BLOBFileValue) {
                            // use as is
                            blob = (BLOBFileValue) b;
                        } else {
                            // create a copy from the stream
                            dispose = true;
                            blob = getBLOBFileValue(store, b.getStream(), true);
                        }
                    } finally {
                        if (dispose) {
                            b.dispose();
                        }
                    }
                }
                return new InternalValue(blob);
            case PropertyType.BOOLEAN:
View Full Code Here

TOP

Related Classes of javax.jcr.Binary

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.