*** 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
FieldsModifier and TypeFieldDescriptionstatic final intThe maximum length of a SAS Variable name.static final intUNIX operating system.static final intUnknown operating system.static final intWebDAVstatic final intWindows operating system.static final intz/OS HFS operating system.static final intz/OS PDS operating system. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgenerateName(int numOfChars) Attempt to generate a unique name.static StringgetObjectName(String name, RemoteServiceInterface remoteService) Create the String representation of the MBean object name.static StringmapNameToFilesystem(String name, int hostOS, String prefix, String suffix) Map the object name to a file system path.static StringmapNameToOMRObjectName(String name) Map the parameter name to a valid OMR object name.static StringmapNameToSASVariableName(String name, Collection existingNames) Map the parameter name to a valid SAS variable name.static StringmapUrlToFilesystem(String url, int hostOS, String prefix, String suffix) Map the object SBIP URLto a file system path.static StringtrimName(String name) Trim leading and trailing space and control characters.static booleanvalidateIdentityName(String name, boolean throwException) Test for a valid Metadata Repository object name for an Identity.static booleanvalidateOMRObjectName(String name, boolean throwException) Test for a valid Metadata Repository object name.static booleanvalidateParameterName(String name, boolean throwException) Test for valid parameter name or parameter group name.static booleanvalidateSASFilerefName(String name, boolean throwException) Test for valid SAS fileref name.static booleanvalidateSASLibrefName(String name, boolean throwException) Test for valid SAS libref name.static booleanvalidateSASVariableName(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_LENGTHThe maximum length of a SAS Variable name.- See Also:
-
UNKNOWN
public static final int UNKNOWNUnknown operating system.- See Also:
-
WINDOWS
public static final int WINDOWSWindows operating system.- See Also:
-
UNIX
public static final int UNIXUNIX operating system.- See Also:
-
ZOS_HFS
public static final int ZOS_HFSz/OS HFS operating system.- See Also:
-
ZOS_PDS
public static final int ZOS_PDSz/OS PDS operating system.- See Also:
-
WEBDAV
public static final int WEBDAVWebDAV- See Also:
-
-
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 includeUNKNOWN,WINDOWS,UNIX,ZOS_HFS,ZOS_PDSandWEBDAV.prefix- The prefix to use when creating the file system path.suffix- The suffix to use when creating the file system path.- Returns:
StringThe file system path.- Throws:
IllegalArgumentException- If anullname 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 includeUNKNOWN,WINDOWS,UNIX,ZOS_HFS,ZOS_PDSandWEBDAV.prefix- The prefix to use when creating the file system path.suffix- The suffix to use when creating the file system path.- Returns:
StringThe 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:
Stringthe SAS variable name.- Throws:
IllegalArgumentException- If anullname 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:
Stringthe OMR object name.- Throws:
IllegalArgumentException- If anullname 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 validatethrowException- indicates whether to throw an exception if the value is not valid.- Returns:
booleanistrueif this is a valid name; isfalseif the name contains an illegal character or is too long.- Throws:
IllegalArgumentException- If the throwException parameter istrueand the name is invalid.
- if the name is
-
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 validatethrowException- indicates whether to throw an exception if the value is not valid.- Returns:
booleanistrueif this is a valid name; isfalseif the name contains an illegal character or is too long.- Throws:
IllegalArgumentException- If the throwException parameter istrueand the name is invalid.
- if the name is
-
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:
booleanistrueif this is a valid name; isfalseif the name contains an illegal character or is too long.- Throws:
IllegalArgumentException- If the throwException parameter istrueand 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:
booleanistrueif this is a valid name; isfalseif 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:
booleanistrueif this is a valid name; isfalseif 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:
booleanistrueif this is a valid name; isfalseif 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:
StringThe trimmed name.- Throws:
IllegalArgumentException- If anullname 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
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
-