Class Names
java.lang.Object
com.dassault_systemes.modeler.kerml.model.Names
Utility class to work with
Element names.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringescapeName(String name) Escapes a name according to the KerML specification.static StringescapeString(String string) Escapes special characters in a string according to KerML rules.static StringgetDeclaredNameOrEmpty(Element element) Returns the declared name of the element, or an empty string if none exists.static StringgetDeclaredShortNameOrEmpty(Element element) Returns the declared short name of the element, or an empty string if none exists.static StringgetNameOrEmpty(Element element) Returns the name of the element, or an empty string if none exists.static StringgetNameOrProvided(Element element, String provided) Returns the element's name, or the provided fallback if the name is empty.static StringgetQualifiedNameOrEmpty(Element element) Returns the fully qualified name of the element, or an empty string if it has no owning namespace.static booleanisDeclaredNameApplicable(Element element) Checks whether the element's declared name is applicable.static StringunescapeString(String string) Converts a string literal or unrestricted name with escaped characters into a string in which the escape sequences are replaced with the corresponding represented characters.
-
Constructor Details
-
Names
public Names()
-
-
Method Details
-
escapeName
Escapes a name according to the KerML specification. If the name is null, empty, or already a valid identifier, it is returned unchanged. Otherwise, it is wrapped in quotes and escape sequences are applied.- Parameters:
name- the name to escape- Returns:
- escaped name, or null if input is null
-
getDeclaredShortNameOrEmpty
Returns the declared short name of the element, or an empty string if none exists.- Parameters:
element- the element to inspect- Returns:
- declared short name or empty string
-
getNameOrEmpty
Returns the name of the element, or an empty string if none exists.- Parameters:
element- the element to inspect- Returns:
- name or empty string
-
getQualifiedNameOrEmpty
Returns the fully qualified name of the element, or an empty string if it has no owning namespace.- Parameters:
element- the element to inspect- Returns:
- qualified name or empty string
-
getNameOrProvided
Returns the element's name, or the provided fallback if the name is empty.- Parameters:
element- the element to inspectprovided- fallback name- Returns:
- name or fallback
-
isDeclaredNameApplicable
Checks whether the element's declared name is applicable. Declared names are not applicable for root namespaces or non-member relationships.- Parameters:
element- the element to inspect- Returns:
- true if declared name is applicable
-
getDeclaredNameOrEmpty
Returns the declared name of the element, or an empty string if none exists.- Parameters:
element- the element to inspect- Returns:
- declared name or empty string
-
escapeString
Escapes special characters in a string according to KerML rules.- Parameters:
string- the string to escape- Returns:
- escaped string
-
unescapeString
Converts a string literal or unrestricted name with escaped characters into a string in which the escape sequences are replaced with the corresponding represented characters. If the input string starts with a single or double quote character, it is assumed to be a lexically valid unrestricted name or string literal, respectively. Otherwise, the input string is returned without change.- Parameters:
string- the string to unescape- Returns:
- unescaped string, or null if input is null
-