Examples of DataWriter


Examples of com.xmlcalabash.io.DataStore.DataWriter

                }
                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

Examples of com.xmlcalabash.io.DataStore.DataWriter

  public void setUp() throws Exception {
    store = new FileDataStore(new FallbackDataStore());
  }

  public void testWriteFile() throws IOException {
    store.writeEntry("file.txt", tmp, "text/plain", new DataWriter() {
      public void store(OutputStream content) throws IOException {
        content.write("content".getBytes());
      }
    });
    store.readEntry("file.txt", tmp, "text/plain", null, new DataReader() {
View Full Code Here

Examples of com.xmlcalabash.io.DataStore.DataWriter

    });
    store.deleteEntry("file.txt", tmp);
  }

  public void testWriteDirectory() throws IOException {
    URI file = store.writeEntry("dir/", tmp, "text/plain", new DataWriter() {
      public void store(OutputStream content) throws IOException {
        content.write("content".getBytes());
      }
    });
    store.infoEntry(file.getPath(), tmp, "text/plain", new DataInfo() {
View Full Code Here

Examples of com.xmlcalabash.io.DataStore.DataWriter

    URI dir = store.createList("dir", tmp);
    assertTrue(new File(dir).isDirectory());
  }

  public void testDeleteEntry() throws IOException {
    URI file = store.writeEntry("dir/", tmp, "text/plain", new DataWriter() {
      public void store(OutputStream content) throws IOException {
        content.write("content".getBytes());
      }
    });
    assertTrue(new File(file).exists());
View Full Code Here

Examples of com.xmlcalabash.io.DataStore.DataWriter

            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

Examples of com.xmlcalabash.io.DataStore.DataWriter

            String base = href.getBaseURI().toASCIIString();
            store.readEntry(href.getString(), base, "*/*", 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

Examples of com.xmlcalabash.io.DataStore.DataWriter

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

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

Examples of com.xmlcalabash.io.DataStore.DataWriter

                serializer.setOutputStream(System.out);
                S9apiUtils.serialize(runtime, doc, serializer);
            } else {
                try {
                  DataStore store = runtime.getDataStore();
                  store.writeEntry(uri, uri, media, new DataWriter() {
            public void store(OutputStream ostream)
                throws IOException {
                          logger.trace("Attempt to write file: " + uri);
                          serializer.setOutputStream(ostream);
                          try {
View Full Code Here

Examples of com.xmlcalabash.io.DataStore.DataWriter

                        // file already exists
                        tree.addText(id.toASCIIString());
                    }
                });
            } catch (FileNotFoundException e) {
                URI uri = store.writeEntry(href.getString(), base, "text/plain", new DataWriter() {
                    public void store(OutputStream content) throws IOException {
                        // empty file
                    }
                });
                tree.addText(uri.toASCIIString());
View Full Code Here

Examples of krati.io.DataWriter

     * @throws IOException
     */
    public final void save(File file) throws IOException {
        _entryFile = file;
        Chronos c = new Chronos();
        DataWriter out = new FastDataWriter(file);

        try {
            out.open();

            // Save entry head
            out.writeLong(STORAGE_VERSION); // write the entry file version
            out.writeLong(_minScn);
            out.writeLong(_maxScn);
            out.writeInt(size());

            // Save entry body
            saveDataSection(out);

            // Save entry tail.
            out.writeLong(_minScn);
            out.writeLong(_maxScn);
        } finally {
            out.close();
        }
       
        if(_log.isInfoEnabled()) {
            _log.info("Saved entry: minScn=" + _minScn + " maxScn=" + _maxScn + " size=" + size() + " file=" + file.getName() + " in " + c.getElapsedTime());
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.