Package com.xmlcalabash.io

Examples of com.xmlcalabash.io.DataStore$DataReader


            properties = System.getProperties();
        } else {
            properties = new Properties();
            try {
                String base = pURI.toASCIIString();
                DataStore store = runtime.getDataStore();
                store.readEntry(pFn, base, ACCEPT_TEXT, null, new DataReader() {
                    public void load(URI id, String media, InputStream stream,
                            long len) throws IOException {
                        properties.load(stream);
                    }
                });
View Full Code Here


        String base = getOption(_href).getBaseURI().toASCIIString();
        String href = getOption(_href).getString();

        try {
            final FoProcessor processor = provider;
            DataStore store = runtime.getDataStore();
            URI id = store.writeEntry(href, base, contentType, new DataWriter() {
                public void store(OutputStream content) throws IOException {
                    OutputStream out = new BufferedOutputStream(content);
                    try {
                        processor.format(source.read(),out,contentType);
                    } catch (SaxonApiException e) {
View Full Code Here

        }
    }

    private void doFile(String href, String base) {
        try {
            DataStore store = runtime.getDataStore();
            store.readEntry(href, base, "application/xml, text/xml, */*", overrideContentType, new DataReader() {
                public void load(URI id, String contentType, InputStream bodyStream, long len)
                        throws IOException {
                    // FIXME: Is ISO-8859-1 the right default?
                    String charset = HttpUtils.getCharset(contentType, "ISO-8859-1");

View Full Code Here

                    outstr.close();
                }
                returnData(baos);
                return null;
            } else {
                DataStore store = runtime.getDataStore();
                return store.writeEntry(href, base, media, new DataWriter() {
                    public void store(OutputStream outstr)
                            throws IOException {
                        if (method == CompressionMethod.GZIP) {
                            GZIPOutputStream gzout = new GZIPOutputStream(outstr);
                            outstr = gzout;
View Full Code Here

                    outstr.close();
                }
                returnData(baos);
                return null;
            } else {
                DataStore store = runtime.getDataStore();
                return store.writeEntry(href, base, media, new DataWriter() {
                    public void store(OutputStream outstr) throws IOException {
                        if (method == CompressionMethod.GZIP) {
                            GZIPOutputStream gzout = new GZIPOutputStream(outstr);
                            outstr = gzout;
                        }
View Full Code Here

                    outstr.close();
                }
                returnData(baos);
                return null;
            } else {
                DataStore store = runtime.getDataStore();
                return store.writeEntry(href, base, media, new DataWriter() {
                    public void store(OutputStream outstr) throws IOException {
                        if (method == CompressionMethod.GZIP) {
                            GZIPOutputStream gzout = new GZIPOutputStream(outstr);
                            outstr = gzout;
                        }
View Full Code Here

                    outstr.close();
                }
                returnData(baos);
                return null;
            } else {
                DataStore store = runtime.getDataStore();
                return store.writeEntry(href, base, media, new DataWriter() {
                    public void store(OutputStream outstr) throws IOException {
                        if (method == CompressionMethod.GZIP) {
                            GZIPOutputStream gzout = new GZIPOutputStream(outstr);
                            outstr = gzout;
                        }
View Full Code Here

        boolean failOnError = getOption(_fail_on_error, true);

        RuntimeValue href = getOption(_href);

        try {
            final DataStore store = runtime.getDataStore();
            store.readEntry(href.getString(), href.getBaseURI().toASCIIString(), "*/*", null, new DataReader() {
                public void load(URI id, String media, final InputStream src, long len)
                        throws IOException {
                    RuntimeValue target = getOption(_target);
                    URI uri = store.writeEntry(target.getString(), target.getBaseURI().toASCIIString(), media, new DataWriter() {
                        public void store(OutputStream dst) throws IOException {
                            byte[] buffer = new byte[bufsize];
                            int read = src.read(buffer, 0, bufsize);
                            while (read >= 0) {
                                dst.write(buffer, 0, read);
View Full Code Here

        final int maxCount = count >= 0 ? count : -count;

        RuntimeValue href = getOption(_href);

        try {
            DataStore store = runtime.getDataStore();
            store.readEntry(href.getString(), href.getBaseURI().toASCIIString(), "text/*, */*", null, new DataReader() {
                public void load(URI id, String media, InputStream content, long len)
                        throws IOException {
                    TreeWriter tree = new TreeWriter(runtime);
                    tree.startDocument(id);
                    tree.addStartElement(XProcConstants.c_result);
View Full Code Here

        result.write(tree.getResult());
    }

    private void performDelete(RuntimeValue href, String base,
            boolean recursive, boolean fail_on_error) {
        DataStore store = runtime.getDataStore();
        if (recursive) {
            try {
                for (String entry : getAllEntries(href.getString(), base)) {
                    store.deleteEntry(entry, entry);
                }
            } catch (FileNotFoundException e) {
                if (fail_on_error) {
                    throw new XProcException(step.getNode(), "Cannot delete: file does not exist", e);
                }
            } catch (IOException e) {
                if (fail_on_error) {
                    throw new XProcException(step.getNode(), e);
                }
            }
        }
        try {
            store.deleteEntry(href.getString(), base);
        } catch (FileNotFoundException e) {
            if (fail_on_error) {
                throw new XProcException(step.getNode(), "Cannot delete: file does not exist", e);
            }
        } catch (IOException e) {
View Full Code Here

TOP

Related Classes of com.xmlcalabash.io.DataStore$DataReader

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.