Class OptionsHelper

java.lang.Object
com.perforce.p4java.option.server.OptionsHelper

public class OptionsHelper extends Object
Since:
8/09/2016
  • Field Details

    • OPTPFX

      public static final 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:
  • Method Details

    • applyRule

      public static String applyRule(String ruleName, 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 String applyRule(String ruleName, 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 String applyRule(String ruleName, 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 String applyRule(String ruleName, String serverOptStr, 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.
    • objectToBoolean

      public static boolean objectToBoolean(Object optValue) throws OptionsException
      Throws:
      OptionsException