Package gnu.kawa.xml

Class HttpPrinter

  • All Implemented Interfaces:
    Consumer, XConsumer, java.io.Closeable, java.io.Flushable, java.lang.Appendable, java.lang.AutoCloseable, java.util.function.Consumer<java.lang.Object>, java.util.function.DoubleConsumer, java.util.function.IntConsumer, java.util.function.LongConsumer
    Direct Known Subclasses:
    ServletPrinter

    public class HttpPrinter
    extends PrintConsumer
    Output as an Http response. Used for both CGI scripts (default) and HttpServletResponse (future).
    • Field Detail

      • sawContentType

        protected java.lang.String sawContentType
      • ostream

        protected java.io.OutputStream ostream
    • Constructor Detail

      • HttpPrinter

        public HttpPrinter​(java.io.OutputStream out)
    • Method Detail

      • printHeader

        public void printHeader​(java.lang.String label,
                                java.lang.String value)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • printHeaders

        public void printHeaders()
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • addHeader

        public void addHeader​(java.lang.String label,
                              java.lang.String value)
      • startAttribute

        public void startAttribute​(java.lang.Object attrType)
        Description copied from interface: Consumer
        Write a attribute for the current element. This is only allowed immediately after a startElement.
        Specified by:
        startAttribute in interface Consumer
        Overrides:
        startAttribute in class PrintConsumer
      • endAttribute

        public void endAttribute()
        Description copied from interface: Consumer
        End of an attribute or end of an actual parameter. The former use matches a startAttribute; the latter may not, and can be used to separate parameters in a parameter list. This double duty suggsts the method should at least be re-named.
        Specified by:
        endAttribute in interface Consumer
        Overrides:
        endAttribute in class PrintConsumer
      • beginData

        public void beginData()
      • write

        public void write​(java.lang.CharSequence str,
                          int start,
                          int length)
        Specified by:
        write in interface Consumer
        Overrides:
        write in class PrintConsumer
      • write

        public void write​(char[] buf,
                          int off,
                          int len)
        Specified by:
        write in interface Consumer
        Overrides:
        write in class java.io.PrintWriter
      • ignoring

        public boolean ignoring()
        Description copied from interface: Consumer
        True if consumer is ignoring rest of element. The producer can use this information to skip ahead.
        Specified by:
        ignoring in interface Consumer
        Overrides:
        ignoring in class PrintConsumer
      • reset

        public boolean reset​(boolean headersAlso)
        Try to reset (delete) any response generated so far.
        Parameters:
        headersAlso - if response headers should also be reset.
        Returns:
        true on success, false if it's too late.