org.codehaus.stax2.ri.typed

Class AsciiValueEncoder

    • Field Summary

      Fields 
      Modifier and Type Field and Description
      protected static int MIN_CHARS_WITHOUT_FLUSH
      Constant used to determine when caller should flush buffer before calling encode methods.
    • Constructor Summary

      Constructors 
      Modifier Constructor and Description
      protected AsciiValueEncoder() 
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      boolean bufferNeedsFlush(int freeChars)
      Method called by writer to check if it should flush its output buffer (which has specified amount of free space) before encoder can encode more data.
      abstract int encodeMore(byte[] buffer, int ptr, int end) 
      abstract int encodeMore(char[] buffer, int ptr, int end) 
      abstract boolean isCompleted()
      Method that can alternatively be called to determine whether encoder has encoded all data it has.
    • Field Detail

      • MIN_CHARS_WITHOUT_FLUSH

        protected static final int MIN_CHARS_WITHOUT_FLUSH
        Constant used to determine when caller should flush buffer before calling encode methods. Strict minimum would be something like 22 (for floating point numbers), but let's pad it a bit.
        See Also:
        Constant Field Values
    • Constructor Detail

      • AsciiValueEncoder

        protected AsciiValueEncoder()
    • Method Detail

      • bufferNeedsFlush

        public final boolean bufferNeedsFlush(int freeChars)
        Method called by writer to check if it should flush its output buffer (which has specified amount of free space) before encoder can encode more data. Flushing is only needed if (a) encoder has more data to output, and (b) free space is not enough to contain smallest segment of encoded value (individual array element or encoded primitive value).
        Parameters:
        freeChars - Amount of free space (in characters) in the output buffer
        Returns:
        True if encoder still has data to output and specified amount of free space is insufficient for encoding any more data
      • isCompleted

        public abstract boolean isCompleted()
        Method that can alternatively be called to determine whether encoder has encoded all data it has. Generally called right after a call to encodeMore(char[], int, int), to figure out whether buffer flush is needed (there is more data), or encoding is complete.
      • encodeMore

        public abstract int encodeMore(char[] buffer,
                     int ptr,
                     int end)
        Returns:
        Value of pointer after all remaining data (which may be "none") that can be encoded (as constrained by buffer length) has been encoded. Has to exceed 'ptr' value sent in; will be equal to it if nothing was encoded (which should only occur when everything has been encoded, as long as bufferNeedsFlush(int) is appropriately called once before calling this method)
      • encodeMore

        public abstract int encodeMore(byte[] buffer,
                     int ptr,
                     int end)
        Returns:
        Value of pointer after all remaining data (which may be "none") that can be encoded (as constrained by buffer length) has been encoded. Has to exceed 'ptr' value sent in; will be equal to it if nothing was encoded (which should only occur when everything has been encoded, as long as bufferNeedsFlush(int) is appropriately called once before calling this method)

Copyright © 2012-2015 fasterxml.com. All Rights Reserved.