java.lang.Object
com.dassault_systemes.modeler.kerml.model.Names

@OpenApiAll public class Names extends Object
Utility class to work with Element names.
  • Constructor Details

    • Names

      public Names()
  • Method Details

    • escapeName

      @CheckForNull public static String escapeName(@CheckForNull String name)
      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

      public static String getDeclaredShortNameOrEmpty(Element element)
      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

      public static String getNameOrEmpty(Element element)
      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

      public static String getQualifiedNameOrEmpty(Element element)
      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

      public static String getNameOrProvided(Element element, String provided)
      Returns the element's name, or the provided fallback if the name is empty.
      Parameters:
      element - the element to inspect
      provided - fallback name
      Returns:
      name or fallback
    • isDeclaredNameApplicable

      public static boolean isDeclaredNameApplicable(Element element)
      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

      public static String getDeclaredNameOrEmpty(Element element)
      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

      public static String escapeString(String string)
      Escapes special characters in a string according to KerML rules.
      Parameters:
      string - the string to escape
      Returns:
      escaped string
    • unescapeString

      @CheckForNull public static String unescapeString(@CheckForNull 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. 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