Class EncodingOutputStream

java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
eu.bandm.tools.tdom.runtime.EncodingOutputStream
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable

public class EncodingOutputStream extends FilterOutputStream
DOCME CHECK: Uses direct and inherited aggregation in parallel ? (=inherited and overwritten methods?)
  • Constructor Details

    • EncodingOutputStream

      public EncodingOutputStream(OutputStream out)
  • Method Details

    • writeInt

      public void writeInt(int min, int n) throws IOException
      Write out "n" for a value which is always geq "min", but no upper limit is known. Use a Fibonacci encoding = Zeckendorf representation: Each strictly positive integer is represented as a sum of Fibonacci numbers. Anywhere a sequence of digits "..011.." is canonically represented as "..100..", so never two adjacent one bits "11" do appear. The bits are written lowest to highest. The highest is always "1" and an additional stop bit "1" follows. E.g.
              1    2    5    8    13    stopbit
        15 =  0    1    0    0    1     1 
        
      Throws:
      IOException
    • writeInt

      public void writeInt(int n, int min, int max) throws IOException
      Write out "n" for a value always geq "min" and leq "max". Writes out the relative position of "n" in this range. Writes out as many bits as necessary for this maximal position. Writes out epsilon (=the empty bitstring) iff only one value is possible ("min==max").
      Throws:
      IOException
    • bitWidth

      static int bitWidth(int w)
      DOCME nicht ganz klar was das soll? https://cmsdk.com/java/get-the-position-instead-of-the-value-of-the-highest-one-bit-in-integer-duplicate.html suggests int ho = Integer.highestOneBit(f) int pos = ho==0 ? 0 : Integer.numberOfTrailingZeros(ho)
    • writeString

      public void writeString(String string) throws IOException
      Write out a character sequence. Write either only the index number into the constant pool, or define a new entry in this pool. The resp bit encodings are.:
            0 
            1  
        
      Throws:
      IOException