Package nux.xom.binary

Examples of nux.xom.binary.BinaryXMLCodec$Entry


  }

  @Override
  protected void doDelete(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
    Entry e = entry(req);
    S3Object remove = map.remove(e);
    if (remove == null) {
      resp.sendError(404, "Not found " + e);
    } else {
      resp.sendError(HttpURLConnection.HTTP_NO_CONTENT, "Deleted");
View Full Code Here


    }

  }

  private Entry entry(HttpServletRequest req) {
    return new Entry(key(uri(req)));
  }
View Full Code Here

        log("doGet " + uri);
    if ("/".equals(uri.getPath())) {
      list(req, resp);
    } else {
      String key = uri.getPath().substring(1);
      Entry e = new Entry(key);
      S3Object obj = map.get(e);
        if (debug)
          log("map.get(" + key + ") = " + obj);
      if (obj == null) {
        resp.sendError(404, "Not here: " + e);
View Full Code Here

    if (maxKeysStr != null)
      maxKeys = Integer.parseInt(maxKeysStr);
    Writer w = new Writer();
    SortedMap<Entry, S3Object> submap = new TreeMap<Entry, S3Object>(map);
    if (prefix != null)
      submap = submap.tailMap(new Entry(prefix));
    int keyCount = 0;
    boolean truncated = false;
    String nextMarker = null;
    for (Entry e : submap.keySet()) {
      if (++keyCount > maxKeys) {
View Full Code Here

    log("doPut " + uri);
    if ("/".equals(uri.getPath())) {
      log("create bucket");
      bucket = true;
    } else {
      Entry e = new Entry(key(uri));
      e.setLastModified(new Date());
      e.setSize(req.getContentLength());
      e.setOwner(new Owner("id", "name"));
      ByteArrayOutputStream os = new ByteArrayOutputStream();
      ServletInputStream is = req.getInputStream();
      byte b[] = new byte[128];
      while (true) {
        int len = is.read(b);
View Full Code Here

   *            a number in the range 0..9
   * @return a streaming serializer that writes bnux binary XML
   */
  public StreamingSerializer createBinaryXMLSerializer(OutputStream out, int zlibCompressionLevel) {
//    BinaryXMLCodec codec = XOMUtil.getBinaryXMLCodec();
    BinaryXMLCodec codec = new BinaryXMLCodec();
    return codec.createStreamingSerializer(out, zlibCompressionLevel);
  }
View Full Code Here

 
            if (input == null && baseURI == null)
              throw new IllegalArgumentException("input and baseURI must not both be null");
            if (input == null) input = baseURI.toURL().openStream();
            try {
              doc = new BinaryXMLCodec().deserialize(input, filter.createNodeFactory(null, myTransform));
              if (baseURI != null) doc.setBaseURI(baseURI.toASCIIString());
            } finally {
              input.close(); // do what SAX XML parsers do
            }
          }
View Full Code Here

    int compressionLevel = Integer.getInteger("nux.xom.tests.BinaryXMLConverter.compressionLevel", 0).intValue();
    int runs = Integer.getInteger("nux.xom.tests.BinaryXMLConverter.runs", 1).intValue();
    boolean readOnly = Boolean.getBoolean("nux.xom.tests.BinaryXMLConverter.readOnly");
   
    StreamingSerializerFactory factory = new StreamingSerializerFactory();
    BinaryXMLCodec codec = new BinaryXMLCodec();

    if (args.length == 0) { // simply convert from System.in to System.out
      InputStream in = new BufferedInputStream(System.in);
      if (codec.isBnuxDocument(in)) {
        StreamingSerializer ser = factory.createXMLSerializer(System.out, "UTF-8");
        NodeFactory redirector = XOMUtil.getRedirectingNodeFactory(ser);
        codec.deserialize(in, redirector);
      } else { // it's an XML document (or rubbish)
        StreamingSerializer ser = factory.createBinaryXMLSerializer(System.out, compressionLevel);
        NodeFactory redirector = XOMUtil.getRedirectingNodeFactory(ser);
        new Builder(redirector).build(in);
      }
      return;
    }
   
    for (int run=0; run < runs; run++) {
      long s = System.currentTimeMillis();
      for (int i=0; i < args.length; i++) {
        long start, end;
        String fileName = args[i];
        File file = new File(fileName);
        if (file.isDirectory()) continue; // ignore
        System.out.print(fileName + " --> ");
        InputStream in = new FileInputStream(file);       
        OutputStream out = null;
       
        if (fileName.endsWith(".bnux")) {
          NodeFactory redirector = null;
          if (readOnly) {
            redirector = XOMUtil.getNullNodeFactory();
          } else {
            String destFileName = fileName.substring(0, fileName.length() - ".bnux".length());
            System.out.print(destFileName);
            out = new FileOutputStream(destFileName);
            StreamingSerializer ser = factory.createXMLSerializer(out, "UTF-8");
            redirector = XOMUtil.getRedirectingNodeFactory(ser);
          }
         
          start = System.currentTimeMillis();
         
          codec.deserialize(in, redirector); // perform conversion       
        }
        else { // it's a textual XML document
          NodeFactory redirector = null;
          if (readOnly) {
            redirector = XOMUtil.getNullNodeFactory();
          } else {
            String destFileName = fileName + ".bnux";
            System.out.print(destFileName);
            out = new FileOutputStream(destFileName);
            StreamingSerializer ser = codec.createStreamingSerializer(out, compressionLevel);
            redirector = XOMUtil.getRedirectingNodeFactory(ser);
          }

          start = System.currentTimeMillis();
         
View Full Code Here

    fileData = null;
    fileData = FileUtil.toByteArray(new FileInputStream(file));
   
    if (mode.startsWith("bnux")) {
      doc = new Builder().build(new ByteArrayInputStream(fileData));
      data = new BinaryXMLCodec().serialize(doc, compressionLevel);
      if (!cmd.equals("deser")) {
        doc = codec.deserialize(data); // use "interned" strings
        data = null;
      }
      if (cmd.equals("deser")) {
View Full Code Here

  }
 
  // called once per mode (i.e. VM invocation)
  private void init() throws Exception {   // TODO: merge with constructor?
    // bnux and XOM
    codec = new BinaryXMLCodec();
    bnuxFactory = null;
    if (mode.startsWith("bnux")) {
      if (mode.indexOf("NNF") >= 0) {
        bnuxFactory = XOMUtil.getNullNodeFactory();
      }
View Full Code Here

TOP

Related Classes of nux.xom.binary.BinaryXMLCodec$Entry

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.