Package jme3utilities

Class NameGenerator

java.lang.Object
jme3utilities.NameGenerator
All Implemented Interfaces:
com.jme3.export.Savable

public class NameGenerator extends Object implements com.jme3.export.Savable
A namespace used to generate unique text strings for names.
  • Constructor Summary

    Constructors
    Constructor
    Description
    A no-arg constructor to avoid javadoc warnings from JDK 18.
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    Given a name, recreate its prefix.
    static boolean
    isFrom(String name, String prefix)
    Test whether a name could plausibly have been generated from a specified prefix.
    void
    read(com.jme3.export.JmeImporter importer)
    De-serialize this name generator, for example when loading from a J3O file.
    void
    Restart name generation from scratch, forgetting about any previously used sequence numbers.
    Represent this name generator as a text string.
    unique(String prefix)
    Generate a new unique name consisting of a prefix string followed by the separator followed by a decimal sequence number.
    void
    write(com.jme3.export.JmeExporter exporter)
    Serialize this name generator, for example when saving to a J3O file.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • NameGenerator

      public NameGenerator()
      A no-arg constructor to avoid javadoc warnings from JDK 18.
  • Method Details

    • getPrefix

      public static String getPrefix(String name)
      Given a name, recreate its prefix.
      Parameters:
      name - (not null)
      Returns:
      prefix (or null if the name was not generated here)
    • isFrom

      public static boolean isFrom(String name, String prefix)
      Test whether a name could plausibly have been generated from a specified prefix.
      Parameters:
      name - name to test (not null)
      prefix - (not null)
      Returns:
      true if the name is plausible, otherwise false
    • reset

      public void reset()
      Restart name generation from scratch, forgetting about any previously used sequence numbers.
    • unique

      public String unique(String prefix)
      Generate a new unique name consisting of a prefix string followed by the separator followed by a decimal sequence number.
      Parameters:
      prefix - the prefix string (not null, doesn't contain separator)
      Returns:
      unique String which begins with the specified prefix
    • read

      public void read(com.jme3.export.JmeImporter importer) throws IOException
      De-serialize this name generator, for example when loading from a J3O file.
      Specified by:
      read in interface com.jme3.export.Savable
      Parameters:
      importer - (not null)
      Throws:
      IOException - from importer
    • write

      public void write(com.jme3.export.JmeExporter exporter) throws IOException
      Serialize this name generator, for example when saving to a J3O file.
      Specified by:
      write in interface com.jme3.export.Savable
      Parameters:
      exporter - (not null)
      Throws:
      IOException - from exporter
    • toString

      public String toString()
      Represent this name generator as a text string.
      Overrides:
      toString in class Object
      Returns:
      descriptive string of text (not null)