Package com.caucho.vfs

Examples of com.caucho.vfs.WriteStream


        if (stream.getOutputStream() != null)
          transform(node, stream.getOutputStream(), null, result.getSystemId());
        else if (stream.getWriter() != null) {
          Writer writer = stream.getWriter();
          WriteStream os = Vfs.openWrite(writer);

          if (writer instanceof OutputStreamWriter) {
            String javaEncoding = ((OutputStreamWriter) writer).getEncoding();
            String mimeEncoding = Encoding.getMimeName(javaEncoding);
            transform(node, os, mimeEncoding, result.getSystemId());
          }
          else
            transform(node, os, null, result.getSystemId());

          os.flush();
          os.free();
        }
        else {
          WriteStream os = Vfs.lookup(result.getSystemId()).openWrite();
           
          try {
            transform(node, os, null, result.getSystemId());
          } finally {
            os.close();
          }
        }
      }
      else if (result instanceof DOMResult) {
        DOMResult domResult = (DOMResult) result;
View Full Code Here


    try {
      _lineMap = null;
      Properties output = getOutputProperties();

      WriteStream ws;

      if (os instanceof WriteStream)
        ws = (WriteStream) os;
      else {
        ws = Vfs.openWrite(os);

        if (systemId != null)
          ws.setPath(Vfs.lookup(systemId));
        else if (node instanceof QNode) {
          String baseURI = ((QNode) node).getBaseURI();

          if (baseURI != null)
            ws.setPath(Vfs.lookup(baseURI));
        }
      }

      XmlPrinter out = new XmlPrinter(ws);

      String method = (String) output.get(OutputKeys.METHOD);
      out.setMethod(method);
      if (encoding == null)
        encoding = (String) output.get(OutputKeys.ENCODING);
      if (encoding == null && ! (os instanceof WriteStream) &&
          ! "html".equals(method))
        encoding = "UTF-8";
      if (encoding != null)
        out.setEncoding(encoding);
      out.setMimeType((String) output.get(OutputKeys.MEDIA_TYPE));
      String omit = (String) output.get(OutputKeys.OMIT_XML_DECLARATION);

      if (omit == null || omit.equals("false") || omit.equals("no"))
        out.setPrintDeclaration(true);
     
      out.setStandalone((String) output.get(OutputKeys.STANDALONE));
      out.setSystemId((String) output.get(OutputKeys.DOCTYPE_SYSTEM));
      out.setPublicId((String) output.get(OutputKeys.DOCTYPE_PUBLIC));
   
      String indent = (String) output.get(OutputKeys.INDENT);
      if (indent != null)
        out.setPretty(indent.equals("true") || indent.equals("yes"));
     
      String jsp = (String) output.get("caucho.jsp");
      if (jsp != null)
        out.setJSP(jsp.equals("true") || jsp.equals("yes"));
     
      out.setVersion((String) output.get(OutputKeys.VERSION));

      String includeContentType = (String) output.get("include-content-type");
      if (includeContentType != null)
        out.setIncludeContentType(includeContentType.equals("true") ||
                                  includeContentType.equals("yes"));
     
      if (! _stylesheet.getGenerateLocation()) {
      }
      else if (node instanceof CauchoNode) {
        String filename = ((CauchoNode) node).getFilename();
        if (filename != null)
          out.setLineMap(filename);
        else
          out.setLineMap("anonymous.xsl");
      }
      else
        out.setLineMap("anonymous.xsl");

      //out.beginDocument();
      _stylesheet.transform(node, out, this);
      //out.endDocument();
      _lineMap = out.getLineMap();
      if (os != ws) {
        ws.flush();
        ws.free();
      }
    } catch (TransformerException e) {
      throw e;
    } catch (Exception e) {
      throw new TransformerExceptionWrapper(e);
View Full Code Here

  private int _lastColumn;

  private SelectResultSetImpl()
  {
    _ws = new WriteStream();
    _ws.setReuseBuffer(true);
    _ts = new TempStream();
    _rs = new ReadStream();
    _rs.setReuseBuffer(true);
    _buf = TempBuffer.allocate();
View Full Code Here

        try {
          destPath.getParent().mkdirs();
        } catch (IOException e) {
        }

        WriteStream os = destPath.openWrite();

        try {
          Properties output = stylesheet.getOutputProperties();

          String encoding = (String) output.get("encoding");
          String mimeType = (String) output.get("mime-type");
          String method = (String) output.get("method");

          if (encoding == null && (method == null || ! method.equals("html")))
            encoding = "UTF-8";

          TransformerImpl transformer =
            (TransformerImpl) stylesheet.newTransformer();

          if (encoding != null)
            os.setEncoding(encoding);

          transformer.setProperty("caucho.pwd", Vfs.lookup());

          for (int j = 0; j < keyList.size(); j++) {
            String key = (String) keyList.get(j);
            String value = (String) valueList.get(j);

            transformer.setParameter(key, value);
          }

          transformer.transform(doc, os);
        } finally {
          os.close();
        }
      }
    } catch (Throwable e) {
      while ((e instanceof ExceptionWrapper) &&
             ((ExceptionWrapper) e).getRootCause() != null)
View Full Code Here

    try {
      BytesMessage message = _jmsSession.createBytesMessage();

      BytesMessageOutputStream out = new BytesMessageOutputStream(message);
      WriteStream ws = VfsStream.openWrite(out);

      ws.writeStream(is);

      ws.flush();
      out.flush();

      _producer.send(message);
    } catch (JMSException e) {
      throw new ServletException(e);
View Full Code Here

      init((WriteStream) os);
    else if (os instanceof EnclosedWriteStream)
      init(((EnclosedWriteStream) os).getWriteStream());
    else {
      _isEnclosedStream = true;
      WriteStream ws = Vfs.openWrite(os);
      try {
        ws.setEncoding("UTF-8");
      } catch (UnsupportedEncodingException e) {
      }
      init(ws);
    }
  }
View Full Code Here

  {
    if (writer instanceof EnclosedWriteStream)
      init(((EnclosedWriteStream) writer).getWriteStream());
    else {
      _isEnclosedStream = true;
      WriteStream ws = Vfs.openWrite(writer);
      init(ws);
    }
  }
View Full Code Here

   * @param node source DOM node
   */
  public static void print(Path path, Node node)
    throws IOException
  {
    WriteStream os = path.openWrite();

    try {
      new XmlPrinter(os).printXml(node);
    } finally {
      os.close();
    }
  }
View Full Code Here

   
    String depthString = req.getHeader("Depth");
    int depth = Integer.MAX_VALUE;

    OutputStream os = res.getOutputStream();
    WriteStream out = Vfs.openWrite(os);
    out.setEncoding("UTF-8");

    if (_addCrLf)
      out.setNewlineString("\r\n");

    try {
      if ("0".equals(depthString))
        depth = 0;
      else if ("1".equals(depthString))
        depth = 1;

      if (req.getMethod().equals("OPTIONS")) {
        res.setHeader("DAV", "1");

        res.setHeader("MS-Author-Via", "DAV");
        if (_enableWrite)
          res.setHeader("Allow", "OPTIONS, PROPFIND, GET, HEAD, PUT, MKCOL, DELETE, COPY, MOVE, PROPPATCH");
        else if (_enable)
          res.setHeader("Allow", "OPTIONS, PROPFIND, GET, HEAD");
      }
      else if (req.getMethod().equals("PROPFIND")) {
        handlePropfind(req, res, out, depth);
      }
      else if (req.getMethod().equals("GET") ||
               req.getMethod().equals("HEAD")) {
        handleGet(req, res, out);
      }
      else if (req.getMethod().equals("PUT") && _enableWrite) {
        handlePut(req, res, out);
      }
      else if (req.getMethod().equals("MKCOL") && _enableWrite) {
        handleMkcol(req, res, out);
      }
      else if (req.getMethod().equals("DELETE") && _enableWrite) {
        handleDelete(req, res, out);
      }
      else if (req.getMethod().equals("COPY") && _enableWrite) {
        handleCopy(req, res, out, depth);
      }
      else if (req.getMethod().equals("MOVE") && _enableWrite) {
        handleMove(req, res, out);
      }
      else if (req.getMethod().equals("PROPPATCH") && _enableWrite) {
        handleProppatch(req, res, out, depth);
      }
      else if (! _enableWrite &&
               "PUT".equals(req.getMethod()) ||
               "MKCOL".equals(req.getMethod()) ||
               "DELETE".equals(req.getMethod()) ||
               "COPY".equals(req.getMethod()) ||
               "MOVE".equals(req.getMethod()) ||
               "PROPPATCH".equals(req.getMethod())) {
        res.sendError(res.SC_FORBIDDEN);
      }
      else {
        res.sendError(res.SC_NOT_IMPLEMENTED, "Method not implemented");
      }
    } finally {
      out.close();
    }
  }
View Full Code Here

      sendError(res, out, 403, "Forbidden", "PUT forbidden");
      return;
    }
   
    WriteStream ws = Vfs.openWrite(os);
    Path path =ws.getPath();
    try {
      InputStream is = req.getInputStream();
      ws.writeStream(is);
    } finally {
      ws.close();
    }
  }
View Full Code Here

TOP

Related Classes of com.caucho.vfs.WriteStream

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.