Class FormatPreferences


  • public final class FormatPreferences
    extends java.lang.Object
    Formatter preferences.
    • Constructor Detail

      • FormatPreferences

        public FormatPreferences()
        Construct a new instance using default values.
      • FormatPreferences

        public FormatPreferences​(java.util.Properties properties)
        Construct a new instance, mapping the given properties to the formatter configurations.
        Parameters:
        properties - the properties to map
      • FormatPreferences

        public FormatPreferences​(java.lang.ClassLoader classLoader)
                          throws java.io.IOException
        Construct a new instance using a properties file loaded from the given class loader.
        Parameters:
        classLoader - the class loader
        Throws:
        java.io.IOException - if an error occurs while reading the properties
      • FormatPreferences

        public FormatPreferences​(javax.annotation.processing.Filer filer,
                                 java.lang.String name)
                          throws java.io.IOException
        Construct a new instance using a properties file loaded from the given annotation processing filer.
        Parameters:
        filer - the filer to read from
        name - the name of the properties file to read
        Throws:
        java.io.IOException - if an error occurs while reading the properties
      • FormatPreferences

        public FormatPreferences​(javax.annotation.processing.Filer filer)
                          throws java.io.IOException
        Construct a new instance using a properties file loaded from the given annotation processing filer.
        Parameters:
        filer - the filer to read from
        Throws:
        java.io.IOException - if an error occurs while reading the properties
      • FormatPreferences

        public FormatPreferences​(java.io.File file)
                          throws java.io.IOException
        Construct a new instance using a properties file loaded from the given file name.
        Parameters:
        file - the name of the properties file to read
        Throws:
        java.io.IOException - if an error occurs while reading the properties
      • FormatPreferences

        public FormatPreferences​(java.io.InputStream inputStream)
                          throws java.io.IOException
        Construct a new instance using a properties read from the given stream.
        Parameters:
        inputStream - the stream to read properties from
        Throws:
        java.io.IOException - if an error occurs while reading the properties
      • FormatPreferences

        public FormatPreferences​(java.io.Reader reader)
                          throws java.io.IOException
        Construct a new instance using a properties read from the given stream.
        Parameters:
        reader - the stream to read properties from
        Throws:
        java.io.IOException - if an error occurs while reading the properties
    • Method Detail

      • fnf

        private static java.io.InputStream fnf​(java.io.InputStream stream)
                                        throws java.io.IOException
        Throws:
        java.io.IOException
      • xf

        private static java.lang.String xf​(java.lang.String name)
      • split

        private static void split​(java.util.ArrayList<java.lang.String> dest,
                                  char delim,
                                  java.lang.String s)
      • load

        private static java.util.Properties load​(java.io.Reader reader)
                                          throws java.io.IOException
        Throws:
        java.io.IOException
      • def

        private <T> T def​(T val,
                          T def)
      • getLineLength

        public int getLineLength()
        Get the configured line length.
        Returns:
        the configured line length
      • getIndent

        public int getIndent​(FormatPreferences.Indentation indentation)
        Get the configured indentation for the given context.
        Parameters:
        indentation - the indentation context
        Returns:
        the indentation
      • setIndent

        public int setIndent​(FormatPreferences.Indentation indentation,
                             int value)
        Set the configured indentation for the given context.
        Parameters:
        indentation - the indentation context
        value - the indentation
        Returns:
        the previous indentation
      • isIndentAbsolute

        public boolean isIndentAbsolute​(FormatPreferences.Indentation indentation)
        Determine whether the indentation for the given context is absolute or relative.
        Parameters:
        indentation - the indentation context
        Returns:
        true if absolute, false if relative
      • setIndentAbsolute

        public void setIndentAbsolute​(FormatPreferences.Indentation indentation)
        Set absolute indentation for the given context.
        Parameters:
        indentation - the indentation context
      • clearIndentAbsolute

        public void clearIndentAbsolute​(FormatPreferences.Indentation indentation)
        Clear absolute indentation for the given context.
        Parameters:
        indentation - the indentation context
      • addOption

        public void addOption​(FormatPreferences.Opt... opts)
        Add option flags to these preferences.
        Parameters:
        opts - the flags to add
      • removeOption

        public void removeOption​(FormatPreferences.Opt... opts)
        Remove option flags from these preferences.
        Parameters:
        opts - the flags to remove
      • hasOption

        public boolean hasOption​(FormatPreferences.Opt opt)
        Determine whether the given option flag is set on these preferences.
        Parameters:
        opt - the flag to check
        Returns:
        true if the flag is present, false if it is absent