### *** This class provides Binary Compatibility only, not Source Compatibility ***

Package com.sas.services.util

# Class Names

java.lang.Object
com.sas.services.util.Names

@SASScope("ALL") @BinaryCompatibilityOnly public class Names extends Object
Utility classes needed to support consistent naming behavior.

Since:
  1.1.3

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final int`
  `MAX_VARIABLE_NAME_LENGTH`
  The maximum length of a SAS Variable name.
  `static final int`
  `UNIX`
  UNIX operating system.
  `static final int`
  `UNKNOWN`
  Unknown operating system.
  `static final int`
  `WEBDAV`
  WebDAV
  `static final int`
  `WINDOWS`
  Windows operating system.
  `static final int`
  `ZOS_HFS`
  z/OS HFS operating system.
  `static final int`
  `ZOS_PDS`
  z/OS PDS operating system.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static String`
  `generateName(int numOfChars)`
  Attempt to generate a unique name.
  `static String`
  `getObjectName(String name, RemoteServiceInterface remoteService)`
  Create the String representation of the MBean object name.
  `static String`
  `mapNameToFilesystem(String name, int hostOS, String prefix, String suffix)`
  Map the object name to a file system path.
  `static String`
  `mapNameToOMRObjectName(String name)`
  Map the parameter name to a valid OMR object name.
  `static String`
  `mapNameToSASVariableName(String name, Collection existingNames)`
  Map the parameter name to a valid SAS variable name.
  `static String`
  `mapUrlToFilesystem(String url, int hostOS, String prefix, String suffix)`
  Map the object SBIP URLto a file system path.
  `static String`
  `trimName(String name)`
  Trim leading and trailing space and control characters.
  `static boolean`
  `validateIdentityName(String name, boolean throwException)`
  Test for a valid Metadata Repository object name for an Identity.
  `static boolean`
  `validateOMRObjectName(String name, boolean throwException)`
  Test for a valid Metadata Repository object name.
  `static boolean`
  `validateParameterName(String name, boolean throwException)`
  Test for valid parameter name or parameter group name.
  `static boolean`
  `validateSASFilerefName(String name, boolean throwException)`
  Test for valid SAS fileref name.
  `static boolean`
  `validateSASLibrefName(String name, boolean throwException)`
  Test for valid SAS libref name.
  `static boolean`
  `validateSASVariableName(String name, boolean throwException)`
  Test for valid SAS variable name.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### MAX_VARIABLE_NAME_LENGTH

    public static final int MAX_VARIABLE_NAME_LENGTH
    The maximum length of a SAS Variable name.
    See Also:
      - Constant Field Values

  - ### UNKNOWN

    public static final int UNKNOWN
    Unknown operating system.
    See Also:
      - Constant Field Values

  - ### WINDOWS

    public static final int WINDOWS
    Windows operating system.
    See Also:
      - Constant Field Values

  - ### UNIX

    public static final int UNIX
    UNIX operating system.
    See Also:
      - Constant Field Values

  - ### ZOS_HFS

    public static final int ZOS_HFS
    z/OS HFS operating system.
    See Also:
      - Constant Field Values

  - ### ZOS_PDS

    public static final int ZOS_PDS
    z/OS PDS operating system.
    See Also:
      - Constant Field Values

  - ### WEBDAV

    public static final int WEBDAV
    WebDAV
    See Also:
      - Constant Field Values

- ## Method Details

  - ### mapNameToFilesystem

    public static String mapNameToFilesystem(String name, int hostOS, String prefix, String suffix) throws IllegalArgumentException
    Map the object name to a file system path.
    Parameters:
      `name` - The name to map to a file system path.
      `hostOS` - The host operating system. Valid values include `UNKNOWN`,`WINDOWS`,`UNIX`, `ZOS_HFS`,`ZOS_PDS`and `WEBDAV`.
      `prefix` - The prefix to use when creating the file system path.
      `suffix` - The suffix to use when creating the file system path.
    Returns:
      `String` The file system path.
    Throws:
      `IllegalArgumentException` - If a `null` name is specified or if an invalid host operating system value is specified.

  - ### mapUrlToFilesystem

    public static String mapUrlToFilesystem(String url, int hostOS, String prefix, String suffix) throws IllegalArgumentException
    Map the object SBIP URLto a file system path.
    Parameters:
      `url` - The url to map to a file system path.
      `hostOS` - The host operating system. Valid values include `UNKNOWN`,`WINDOWS`,`UNIX`, `ZOS_HFS`,`ZOS_PDS`and `WEBDAV`.
      `prefix` - The prefix to use when creating the file system path.
      `suffix` - The suffix to use when creating the file system path.
    Returns:
      `String` The file system path.
    Throws:
      `IllegalArgumentException` - If an invalid SBIP URL is specified.

  - ### mapNameToSASVariableName

    public static String mapNameToSASVariableName(String name, Collection existingNames) throws IllegalArgumentException
    Map the parameter name to a valid SAS variable name. The rules for conversion are as follows:
    - lower case the parameter name
    - convert all characters that are not a-z or 0-9 to an UNDERSCORE
    - if the first character is a digit, prepend an UNDERSCORE
    - truncate to 32 chars
    - make sure the name is unique (case insensitive). If not unique then append _#1 or _#2 until unique.
    Parameters:
      `name` - The name to map to a SAS variable name.
      `existingNames` - Is an optional collection containingg all pre-existing parameters so that the method can avoid name collisions. A value of null for this Collection would disable any name collision checking.
    Returns:
      `String` the SAS variable name.
    Throws:
      `IllegalArgumentException` - If a `null` name is specified.

  - ### mapNameToOMRObjectName

    public static String mapNameToOMRObjectName(String name)
    Map the parameter name to a valid OMR object name. The rules for conversion are as follows:
    - remove all leading and trailing whitespace
    - convert all forward and back slash characters to an UNDERSCORE
    - remove all control characters
    - truncate to 60 chars
    Parameters:
      `name` - the name to map to a valid OMR object name
    Returns:
      `String` the OMR object name.
    Throws:
      `IllegalArgumentException` - If a `null` name is specified.

  - ### validateIdentityName

    public static boolean validateIdentityName(String name, boolean throwException) throws IllegalArgumentException
    Test for a valid Metadata Repository object name for an Identity. The rules for validating are as follows. The object name is invalid if any of the following are true:
    - if the name is `null`
    - if the name length is greater than 60
    - if the name contains any control characters
    - if the name contains leading or trailing blanks (the Character.isSpaceChar is used to determine if the character is a blank
    Parameters:
      `name` - The name to validate
      `throwException` - indicates whether to throw an exception if the value is not valid.
    Returns:
      `boolean` is `true` if this is a valid name; is `false` if the name contains an illegal character or is too long.
    Throws:
      `IllegalArgumentException` - If the throwException parameter is `true` and the name is invalid.

  - ### validateOMRObjectName

    public static boolean validateOMRObjectName(String name, boolean throwException) throws IllegalArgumentException
    Test for a valid Metadata Repository object name. The rules for validating are as follows. The object name is invalid if any of the following are true:
    - if the name is `null`
    - if the name length is greater than 60
    - if the name contains any control characters
    - if the name contains leading or trailing blanks (the Character.isSpaceChar is used to determine if the character is a blank
    - if the name contains any forward or backwards slashes
    Parameters:
      `name` - The name to validate
      `throwException` - indicates whether to throw an exception if the value is not valid.
    Returns:
      `boolean` is `true` if this is a valid name; is `false` if the name contains an illegal character or is too long.
    Throws:
      `IllegalArgumentException` - If the throwException parameter is `true` and the name is invalid.

  - ### validateParameterName

    public static boolean validateParameterName(String name, boolean throwException) throws IllegalArgumentException
    Test for valid parameter name or parameter group name. The rules for validating are as follows. The parameter name is invalid if any of the following are true:
    - if the name length is greater than 60
    - if the name contains any control characters
    - if the name contains leading or trailing blanks (the Character.isSpaceChar is used to determine if the character is a blank
    - if the name contains any forward or backwards slashes
    Parameters:
      `name` - The name to validate.
      `throwException` - indicates whether to throw an exception if the value is not valid.
    Returns:
      `boolean` is `true` if this is a valid name; is `false` if the name contains an illegal character or is too long.
    Throws:
      `IllegalArgumentException` - If the throwException parameter is `true` and the name is invalid.

  - ### validateSASVariableName

    public static boolean validateSASVariableName(String name, boolean throwException) throws IllegalArgumentException
    Test for valid SAS variable name. The rules for validating are as follows. The variable name is invalid if any of the following are true:
    - if the name length is greater than 32
    - if the name does not start with Latin alphabetic character (A-Z or a-z) or UNDERSCORE
    - if the name contains characters other than Latin alphabetic characters, UNDERSCOREs or numeric digits(0-9)
    Parameters:
      `name` - The SAS variable name to validate.
      `throwException` - indicates whether to throw an exception if the value is not valid.
    Returns:
      `boolean` is `true` if this is a valid name; is `false` if the name contains an illegal character or is too long.
    Throws:
      `IllegalArgumentException` - If the throwException parameter is code>true and the name is invalid.

  - ### validateSASLibrefName

    public static boolean validateSASLibrefName(String name, boolean throwException) throws IllegalArgumentException
    Test for valid SAS libref name. The rules for validating are as follows. The libref name is invalid if any of the following are true:
    - if the name length is greater than 8
    - if the name does not start with Latin alphabetic character (A-Z or a-z) or UNDERSCORE
    - if the name contains characters other than Latin alphabetic characters, UNDERSCOREs or numeric digits(0-9)
    Parameters:
      `name` - The SAS libref name to validate.
      `throwException` - indicates whether to throw an exception if the value is not valid.
    Returns:
      `boolean` is `true` if this is a valid name; is `false` if the name contains an illegal character or is too long.
    Throws:
      `IllegalArgumentException` - If the throwException parameter is code>true and the name is invalid.

  - ### validateSASFilerefName

    public static boolean validateSASFilerefName(String name, boolean throwException) throws IllegalArgumentException
    Test for valid SAS fileref name. The SAS fileref name is invalid if any of the following are true:
    - if the name length is greater than 8
    - if the name does not start with Latin alphabetic character (A-Z or a-z) or UNDERSCORE
    - if the name contains characters other than Latin alphabetic characters, UNDERSCOREs, numeric digits(0-9), $, #, or @
    Parameters:
      `name` - The SAS fileref name to validate.
      `throwException` - indicates whether to throw an exception if the value is not valid.
    Returns:
      `boolean` is `true` if this is a valid name; is `false` if the name contains an illegal character or is too long.
    Throws:
      `IllegalArgumentException` - If the throwException parameter is code>true and the name is invalid.

  - ### trimName

    public static String trimName(String name) throws IllegalArgumentException
    Trim leading and trailing space and control characters. Whitespace identified by the Character.isSpaceChar method will be trimmed. Control characters identified by the Character.isISOControl method will be trimmed.
    Parameters:
      `name` - The name to trim.
    Returns:
      `String` The trimmed name.
    Throws:
      `IllegalArgumentException` - If a `null` name is specified.

  - ### generateName

    public static String generateName(int numOfChars)
    Attempt to generate a unique name. This generates the name based on the CRC32 checksum of a VMID.

    The unique name generation is not guaranteed to be 100% unique so calling applications should handle duplicates accordingly.

    Parameters:
      `numOfChars` - the number of characters in the generated name. Specify zero to get the default name/length.
    Returns:
      the unique name

  - ### getObjectName

    public static String getObjectName(String name, RemoteServiceInterface remoteService)
    Create the String representation of the MBean object name.
    Parameters:
      `name` - The name of the Service.
      `remoteService` - the remote service
    Returns:
      the String representation of the MBean object name