Class JavaPropsFactory.ReadConstrainedReader

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, java.lang.Readable
    Enclosing class:
    JavaPropsFactory

    private static class JavaPropsFactory.ReadConstrainedReader
    extends java.io.Reader
    Reader decorator that enforces StreamReadConstraints.getMaxDocumentLength() by counting characters read through it. Needed since actual decoding is done by Properties.load(Reader), reading content directly from a Reader, so the parser itself does not see input as it is consumed.

    Only installed when constraints define a maximum document length (see StreamReadConstraints.hasMaxDocumentLength()).

    Since:
    2.18.11
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private long _charsRead
      Total number of characters read (or skipped) so far.
      private com.fasterxml.jackson.core.StreamReadConstraints _constraints  
      private java.io.Reader _delegate  
      • Fields inherited from class java.io.Reader

        lock
    • Constructor Summary

      Constructors 
      Constructor Description
      ReadConstrainedReader​(java.io.Reader delegate, com.fasterxml.jackson.core.StreamReadConstraints constraints)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void _count​(long n)  
      void close()  
      int read()  
      int read​(char[] cbuf, int off, int len)  
      boolean ready()  
      long skip​(long n)  
      • Methods inherited from class java.io.Reader

        mark, markSupported, nullReader, read, read, reset, transferTo
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • _delegate

        private final java.io.Reader _delegate
      • _constraints

        private final com.fasterxml.jackson.core.StreamReadConstraints _constraints
      • _charsRead

        private long _charsRead
        Total number of characters read (or skipped) so far.
    • Constructor Detail

      • ReadConstrainedReader

        public ReadConstrainedReader​(java.io.Reader delegate,
                                     com.fasterxml.jackson.core.StreamReadConstraints constraints)
    • Method Detail

      • _count

        private void _count​(long n)
                     throws com.fasterxml.jackson.core.exc.StreamConstraintsException
        Throws:
        com.fasterxml.jackson.core.exc.StreamConstraintsException
      • read

        public int read()
                 throws java.io.IOException
        Overrides:
        read in class java.io.Reader
        Throws:
        java.io.IOException
      • read

        public int read​(char[] cbuf,
                        int off,
                        int len)
                 throws java.io.IOException
        Specified by:
        read in class java.io.Reader
        Throws:
        java.io.IOException
      • skip

        public long skip​(long n)
                  throws java.io.IOException
        Overrides:
        skip in class java.io.Reader
        Throws:
        java.io.IOException
      • ready

        public boolean ready()
                      throws java.io.IOException
        Overrides:
        ready in class java.io.Reader
        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
        Specified by:
        close in class java.io.Reader
        Throws:
        java.io.IOException