Class StoredPreferences


  • public class StoredPreferences
    extends Object
    Parses/writes preferences from/to a Config file.

    This is a low-level API. Read/write of preferences in a user branch should be done through AccountsUpdate or AccountConfig.

    The config file has separate sections for general, diff and edit preferences:

       [diff]
         hideTopMenu = true
       [edit]
         lineLength = 80
     

    The parameter names match the names that are used in the preferences REST API.

    If the preference is omitted in the config file, then the default value for the preference is used.

    Defaults for preferences that apply for all accounts can be configured in the refs/users/default branch in the All-Users repository. The config for the default preferences must be provided to this class so that it can read default values from it.

    The preferences are lazily parsed.

    • Method Detail

      • parse

        public void parse()
      • parseGeneralPreferences

        public static GeneralPreferencesInfo parseGeneralPreferences​(org.eclipse.jgit.lib.Config cfg,
                                                                     org.eclipse.jgit.lib.Config defaultCfg,
                                                                     GeneralPreferencesInfo input)
                                                              throws org.eclipse.jgit.errors.ConfigInvalidException
        Returns a GeneralPreferencesInfo that is the result of parsing defaultCfg for the server's default configs and cfg for the user's config. These configs are then overlaid to inherit values (default -> user -> input (if provided).
        Throws:
        org.eclipse.jgit.errors.ConfigInvalidException
      • parseDiffPreferences

        public static DiffPreferencesInfo parseDiffPreferences​(org.eclipse.jgit.lib.Config cfg,
                                                               org.eclipse.jgit.lib.Config defaultCfg,
                                                               DiffPreferencesInfo input)
                                                        throws org.eclipse.jgit.errors.ConfigInvalidException
        Returns a DiffPreferencesInfo that is the result of parsing defaultCfg for the server's default configs and cfg for the user's config. These configs are then overlaid to inherit values (default -> user -> input (if provided).
        Throws:
        org.eclipse.jgit.errors.ConfigInvalidException
      • parseEditPreferences

        public static EditPreferencesInfo parseEditPreferences​(org.eclipse.jgit.lib.Config cfg,
                                                               org.eclipse.jgit.lib.Config defaultCfg,
                                                               EditPreferencesInfo input)
                                                        throws org.eclipse.jgit.errors.ConfigInvalidException
        Returns a EditPreferencesInfo that is the result of parsing defaultCfg for the server's default configs and cfg for the user's config. These configs are then overlaid to inherit values (default -> user -> input (if provided).
        Throws:
        org.eclipse.jgit.errors.ConfigInvalidException
      • readDefaultGeneralPreferences

        public static GeneralPreferencesInfo readDefaultGeneralPreferences​(AllUsersName allUsersName,
                                                                           org.eclipse.jgit.lib.Repository allUsersRepo)
                                                                    throws IOException,
                                                                           org.eclipse.jgit.errors.ConfigInvalidException
        Throws:
        IOException
        org.eclipse.jgit.errors.ConfigInvalidException
      • readDefaultDiffPreferences

        public static DiffPreferencesInfo readDefaultDiffPreferences​(AllUsersName allUsersName,
                                                                     org.eclipse.jgit.lib.Repository allUsersRepo)
                                                              throws IOException,
                                                                     org.eclipse.jgit.errors.ConfigInvalidException
        Throws:
        IOException
        org.eclipse.jgit.errors.ConfigInvalidException
      • readDefaultEditPreferences

        public static EditPreferencesInfo readDefaultEditPreferences​(AllUsersName allUsersName,
                                                                     org.eclipse.jgit.lib.Repository allUsersRepo)
                                                              throws IOException,
                                                                     org.eclipse.jgit.errors.ConfigInvalidException
        Throws:
        IOException
        org.eclipse.jgit.errors.ConfigInvalidException