Class OptionsHelper


  • public class OptionsHelper
    extends java.lang.Object
    Since:
    8/09/2016
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String OPTPFX
      String used to prefix options for the server.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String applyRule​(java.lang.String ruleName, java.lang.String serverOptStr, boolean value)
      Apply an optional rule to a boolean option value.
      static java.lang.String applyRule​(java.lang.String ruleName, java.lang.String serverOptStr, int value)
      Apply an optional rule to an integer option value.
      static java.lang.String applyRule​(java.lang.String ruleName, java.lang.String serverOptStr, long value)
      Apply an optional rule to a long option value.
      static java.lang.String applyRule​(java.lang.String ruleName, java.lang.String serverOptStr, java.lang.String value)
      Apply an optional rule to a string option value.
      static boolean objectToBoolean​(java.lang.Object optValue)  
      • Methods inherited from class java.lang.Object

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

      • OPTPFX

        public static final java.lang.String OPTPFX
        String used to prefix options for the server. This is pretty fundamental; don't change this unless you really know what you're doing....
        See Also:
        Constant Field Values
    • Method Detail

      • applyRule

        public static java.lang.String applyRule​(java.lang.String ruleName,
                                                 java.lang.String serverOptStr,
                                                 boolean value)
                                          throws OptionsException
        Apply an optional rule to a boolean option value. This method is always called by the default implementation of Options.processOptions to process boolean values; you should override this if you need your own rules processing.

        There are currently no rules recognised or implemented in this method.

        Parameters:
        ruleName - rule name string from the options spec string. If null, no rule was specified.
        serverOptStr - the flag string to be sent to the Perforce server prefixing this value
        value - the boolean value itself.
        Returns:
        processed value or null if the rules resulted in nothing to be sent to the Perforce server.
        Throws:
        OptionsException - if any errors occurred during options processing.
      • applyRule

        public static java.lang.String applyRule​(java.lang.String ruleName,
                                                 java.lang.String serverOptStr,
                                                 int value)
                                          throws OptionsException
        Apply an optional rule to an integer option value. This method is always called by the default implementation of Options.processOptions to process integer values; you should override this if you need your own rules processing.

        This version of applyRules implements the rules specified below:

         "gtz": don't return anything unless the value is > 0; typically used for
                        things like maxUsers or maxRows.
         "cl": ignore negative values; convert 0 to the string "default". Typically
                        used for changelists.
         "clz": ignore non-positive values; typically used for changelists where we
                        let the server infer "default" for IChangelist.DEFAULT rather than
                        spelling it out.
         "dcn": implements the -dc[n] rule for diff contexts, i.e. if the int value is
                        zero, emit the flag alone; if it's positive, emit the flag with the int
                        value attached; if it's negative, don't emit anything.
         
        If the passed-in ruleName is non-null and not recognized, the behaviour is the same as if a null rule name was passed in.
        Parameters:
        ruleName - rule name string from the options spec string. If null, no rule was specified.
        serverOptStr - the flag string to be sent to the Perforce server prefixing this value If the flag start with "-" it will be passed as "--flag=value". Eg: The flag "-offset" will be passed as "--offset=value"
        value - the integer value itself.
        Returns:
        processed value or null if the rules resulted in nothing to be sent to the Perforce server.
        Throws:
        OptionsException - if any errors occurred during options processing.
      • applyRule

        public static java.lang.String applyRule​(java.lang.String ruleName,
                                                 java.lang.String serverOptStr,
                                                 long value)
                                          throws OptionsException
        Apply an optional rule to a long option value. This method is always called by the default implementation of Options.processOptions to process long values; you should override this if you need your own rules processing.

        This version of applyRules implements the rules specified below:

         "gtz": don't return anything unless the value is > 0.
         "gez": don't return anything unless the value is >= 0.
         
        If the passed-in ruleName is non-null and not recognized, the behaviour is the same as if a null rule name was passed in.
        Parameters:
        ruleName - rule name string from the options spec string. If null, no rule was specified.
        serverOptStr - the flag string to be sent to the Perforce server prefixing this value If the flag start with "-" it will be passed as "--flag=value". Eg: The flag "-offset" will be passed as "--offset=value"
        value - the long value itself.
        Returns:
        processed value or null if the rules resulted in nothing to be sent to the Perforce server.
        Throws:
        OptionsException - if any errors occurred during options processing.
      • applyRule

        public static java.lang.String applyRule​(java.lang.String ruleName,
                                                 java.lang.String serverOptStr,
                                                 java.lang.String value)
                                          throws OptionsException
        Apply an optional rule to a string option value. This method is always called by the default implementation of Options.processOptions to process string values; you should override this if you need your own rules processing.

        There are currently no rules recognised or implemented in this method.

        Parameters:
        ruleName - rule name string from the options spec string. If null, no rule was specified.
        serverOptStr - the flag string to be sent to the Perforce server prefixing this value If the flag start with "-" it will be passed as "--flag=value". Eg: The flag "-offset" will be passed as "--offset=value"
        value - the string value itself; may be null.
        Returns:
        processed value or null if the rules resulted in nothing to be sent to the Perforce server.
        Throws:
        OptionsException - if any errors occurred during options processing.