Class EntityCatalog<E extends Entity>

java.lang.Object
eu.bandm.tscore.base.EntityCatalog<E>
All Implemented Interfaces:
Translet.Parseable<E>

public class EntityCatalog<E extends Entity> extends Object implements Translet.Parseable<E>
Contains collection of basic score entities used as parameter values, indexed and documented in a multi lingual way. Each Entity must be contained in one such EntityCatalog. The name and documentation of the catalog itself is also multi lingual.

This class also defines a pseudo language for symbolic, non-national representations.

  • Field Details

    • symbolic

      public static final String symbolic
      Language code of a pseudo language, used to index symbolic, non-national representations. E.g. articulation indications like "." or "^" for "staccato" are indexed by this language code, while the wording "staccato" would be indexed by "it", meaning "Italian".
      See Also:
    • unicode

      public static final String unicode
      Language code for the unicode symbols as a translation target (=pseudo language). Used to represent the one-symbol unicode representation, if present.
      See Also:
    • noNames

      public static final MuLi noNames
      Constant for constructing an entity without any name.
    • ownNames

      protected MuLi ownNames
      The name of this catalog, which in most cases is different in different human languages, like .
    • entityNames

      protected Catalog<E extends Entity> entityNames
      The multi-lingual catalog of entities contained.
    • defaultLang

      @Opt protected @Opt String defaultLang
      The default language to present its entities and the catalogue itself, if any.
  • Constructor Details

    • EntityCatalog

      public EntityCatalog(Class<E> itemClass, String defaultLang, MuLi ownNames)
      Constructor configuring all fields ocmpletely.
      Parameters:
      itemClass - the class of all entities contained in the new catalog.
      defaultLang - the language code used as default for all entities contained herein, and for name and doc of the catalog itself.
      ownNames - the names of the catalog, possibly in more than one language.
    • EntityCatalog

      public EntityCatalog(Class<E> itemClass, String defaultLang, String defaultLangOwnName)
      Constructor with slightly restricted values.
      Parameters:
      itemClass - the class of all entities contained in the new catalog.
      defaultLang - the language code used as default for all entities contained herein, and for name and doc of the catalog itself.
      defaultLangOwnName - only one name for the catalog itself, in its default language.
  • Method Details

    • doesNotOverrideSymbolic

      public static boolean doesNotOverrideSymbolic(MuLi muli)
      Checks whether the symbolic language is used in the MuLi argument. Called in all cases where the symbolic representation is calculated and may not be set by the user explicitly.
    • ownName

      public String ownName()
    • dump

      public void dump(PrintStream ps)
      Debugging method to print its contents. @see Catalog#dump(PrintStream)
    • getDefaultLanguage

      public String getDefaultLanguage()
      Returns:
      default language, see constructor doc.
    • setDefaultLanguage

      public void setDefaultLanguage(String l)
      Changes default language dynamically. Currently there is NO CHECK whether the new value is sensible. FIXME?
    • getName

      @Opt public @Opt String getName()
      Returns the name of the catalog, in the default language or "null" if no such is present.
    • getName

      @Opt public @Opt String getName(String lang)
      Returns the name of the catalog, in the given language, or "null" if no such is present.
    • getEntity

      @Opt public E getEntity(String lang, String name)
      Returns the Entity with the given name in the in given language, or "null" if no such present.
    • getEntity

      @Opt public E getEntity(String name)
      Returns the Entity with the given name in the catalog's default language, or "null" if no such present.
    • getSymbolic

      @Opt public E getSymbolic(String name)
      Returns the Entity with the given name in the symboolic language, or "null" if no such present.
    • getEntities

      public Set<E> getEntities()
      Returns all entities contained.
    • getNames

      public MuLi getNames(E entity)
      Returns all names of the given Entity.
    • addEntityNames

      public void addEntityNames(E entity, MuLi humanNames)
      Put additional names for an entity, beyond those defined at creation.
    • addEntityName

      public void addEntityName(E entity, String lang, String name)
      Put one additional name for an entity, beyond those defined at creation.
    • getParser

      @Opt public Translet.Parser<E> getParser(String lang)
      Get a parser which accepts the names of the entities in the given language and returns the possibly found Entity as its value. Recurs to Translet._CAT, see there for the behaviour in case of failure.
      Specified by:
      getParser in interface Translet.Parseable<E extends Entity>
    • getParser

      @Opt public Translet.Parser<E> getParser()
      Get a parser which accepts the names of the entities in the default language.
      Specified by:
      getParser in interface Translet.Parseable<E extends Entity>
    • lendFrom

      public void lendFrom(EntityCatalog<? extends E> origCat, String lang, String name)
      Duplicate the reference to an entity in a different catalog by this catalog. ATTENION: Only the currently defined names are copied. Later added names (in other languages) will not show up in this catalog. This catalog is a secondary catalog to retrieve this entity; its primary catalog (set on its construction) is not altered. This method is useful for selections and local enhancements of collections.
    • lend

      public <F extends E> void lend(F ent)
      Duplicate the reference to an entity in a different catalog by this catalog. ATTENION: Only the currently defined names are copied. Later added names (in other languages) will not show up in this catalog. This catalog is a secondary catalog to retrieve this entity; its primary catalog (set on its construction) is not altered. This method is useful for selections and local enhancements of collections.