Class TagSearchingOutputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.AutoCloseable

    public class TagSearchingOutputStream
    extends java.io.FilterOutputStream
    An OutputStream that searches for a specific tag in the data stream and when found it calls back.
    • Constructor Detail

      • TagSearchingOutputStream

        public TagSearchingOutputStream​(java.io.OutputStream out,
                                        byte[] tag,
                                        TagSearchingOutputStream.Callback callback)
                                 throws java.io.IOException
        Constructor.
        Throws:
        java.io.IOException
    • Method Detail

      • searchForTag

        public boolean searchForTag​(boolean search)
                             throws java.io.IOException
        Turn on or off the tag searching. This must not be called during the TagSearchingOutputStream.Callback.tagFound(TagSearchingOutputStream). If tag searching should be turned off after the return from the callback then the client can use the return value from the callback method to turn searching off.
        Parameters:
        search - true if tag should be searched for; false otherwise
        Returns:
        the tag search state before the call
        Throws:
        java.io.IOException
      • searchForTag

        public boolean searchForTag()
                             throws java.io.IOException
        Query whether the tag searching is turned on or off.
        Returns:
        the current tag search state true if tag searching is on; false otherwise
        Throws:
        java.io.IOException
      • outputTag

        public int outputTag​(int tagOutput)
                      throws java.io.IOException
        Sets whether the tag being searched for is output or not and if so if it is before or after the call to TagSearchingOutputStream.Callback.tagFound(TagSearchingOutputStream). By default the tag being searched for will not be output.
        Parameters:
        tagOutput - 0 if tag should not be output; -1 (or any -ve number) if the tag should be output before the callback; 1 (or any +ve number) if the tag should be output after the callback
        Returns:
        the tag output state before the call
        Throws:
        java.io.IOException
      • outputTag

        public int outputTag()
                      throws java.io.IOException
        Queries whether the tag being searched for is output or not and if so if it is before or after the call to TagSearchingOutputStream.Callback.tagFound(TagSearchingOutputStream). By default the tag being searched for will not be output. -1 (or any -ve number) if the tag should be output before the callback; 1 (or any +ve number) if thte tag should be output after the callback
        Returns:
        the current tag output state 0 if tag should not be output; -1 (or any -ve number) if the tag should be output before the callback; 1 (or any +ve number) if the tag should be output after the callback
        Throws:
        java.io.IOException
      • write

        public void write​(int b)
                   throws java.io.IOException
        Overrides:
        write in class java.io.FilterOutputStream
        Throws:
        java.io.IOException
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.FilterOutputStream
        Throws:
        java.io.IOException