Package com.xmlcalabash.io.DataStore

Examples of com.xmlcalabash.io.DataStore.DataReader


        } 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


    }

    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

    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() {
      public void load(URI id, String media, InputStream content, long len)
          throws IOException {
        byte[] buf = new byte[1024];
        assertEquals("content", new String(buf, 0, content.read(buf)));
      }
View Full Code Here

      public void list(URI id, String media, long lastModified)
          throws IOException {
        assertEquals("text/plain", media);
      }
    });
    store.readEntry(file.getPath(), tmp, "text/plain", null, new DataReader() {
      public void load(URI id, String media, InputStream content, long len)
          throws IOException {
        byte[] buf = new byte[1024];
        assertEquals("content", new String(buf, 0, content.read(buf)));
      }
View Full Code Here

      writer.write("read content");
    } finally {
      writer.close();
    }
    String uri = file.toURI().toASCIIString();
    store.readEntry(uri, uri, "*/*", null, new DataReader() {
      public void load(URI id, String media, InputStream content, long len)
          throws IOException {
        byte[] buf = new byte[1024];
        assertEquals("read content", new String(buf, 0, content.read(buf)));
      }
View Full Code Here

      writer.write("read content");
    } finally {
      writer.close();
    }
    String uri = file.toURI().toASCIIString();
    store.readEntry(uri, uri, "*/*", null, new DataReader() {
      public void load(URI id, String media, InputStream content, long len)
          throws IOException {
        assertEquals("text/plain", media);
      }
    });
View Full Code Here

                    final DataStore store = runtime.getDataStore();
                    store.infoEntry(uri, base, "*/*", new DataInfo() {
                        public void list(URI id, String media, long lastModified)
                                throws IOException {
                            final String accept = pattern == null ? ACCEPT_XML : "*/*";
                            final DataReader handler = new DataReader() {
                                public void load(URI id, String media,
                                        InputStream content, long len)
                                        throws IOException {
                                    content.close();
                                    String name = new File(id).getName();
                                    if (pattern == null || pattern.matcher(name).matches()) {
                                        documents.add(parse(id.toASCIIString(), base));
                                    }
                                }
                            };
                            String entry = id.toASCIIString();
                            if (media == null) {
                                store.listEachEntry(entry, entry, accept, new DataInfo() {
                                    public void list(URI id, String media, long lastModified)
                                            throws IOException {
                                        String entry = id.toASCIIString();
                                        store.readEntry(entry, entry, accept, null, handler);
                                    }
                                });
                            } else {
                                store.readEntry(entry, entry, accept, null, handler);
                            }
                        }
                    });
                } else {
                    try {
                        documents.add(parse(uri, base));
                    } catch (XProcException xe) {
                        if (runtime.transparentJSON()) {
                            try {
                                DataStore store = runtime.getDataStore();
                                store.readEntry(uri, base, ACCPET_JSON, null, new DataReader() {
                                    public void load(URI id, String media, InputStream content, long len)
                                            throws IOException {
                                        String cs = HttpUtils.getCharset(media);
                                        if (cs == null) {
                                            cs = Charset.defaultCharset().name();
View Full Code Here

        String accept = "application/json, text/json, text/*, */*";
        if (userContentType != null) {
          accept = userContentType + ", */*";
        }
        DataStore store = runtime.getDataStore();
        store.readEntry(uri, uri, accept, null, new DataReader() {
          public void load(URI dataURI, String serverContentType,
              InputStream stream, long len) throws IOException {
            read(userContentType, dataURI, stream,
                serverContentType);
          }
View Full Code Here

        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 {
View Full Code Here

        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

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.