Class Entity<E extends Entity>

java.lang.Object
eu.bandm.tscore.base.Entity<E>
All Implemented Interfaces:
Translet.Parseable<E>
Direct Known Subclasses:
Accidental, Artikulation, Clef, ClefUsage, Color_rgb_8, DoppelHaken, FunctionalGender, FunctionalInterval, FunctionalKey, Haken, InterpolationKind, MixedNoteheadAddendum, OctaveRegister, Ornament, PitchModOctave, RelWert, ScalaNumAbstrPOcts

public abstract class Entity<E extends Entity> extends Object implements Translet.Parseable<E>
Base class for all things which are in a certain multi-lingual catalog, and have a common parser for their symbolic appearance in scores, and which form a common semantic domain.

Attention
The type parameter of each subclass must be that subclass itself! It is needed to parametrize instantiation, of the above-mentioned catalog, parsers, etc. Eg.:
public class Articulation extends Entity <Articulation>
Every constructor requires the EntityCatalog into which the new Entity instance is stored. (So the relation from Entity to EntityCatalog is "many-to-one").
The basic architecture of tscore is multi lingual, based on the eu.bandm.tools.muli package. Therefore the different constructors may get more than one "name" argument, and there are different retrieve methods for names. Please note that a default for the language is defined one level above, in the catalog, namely by EntityCatalog.getDefaultLanguage(). So are the MuLi objects for the entity instances.
  • Field Details

    • catalog

      protected EntityCatalog<E extends Entity> catalog
      The multi-lingual catalog in which this entitiy is contained.
    • documentations

      protected MuLi documentations
      The multi-lingual explanation texts for this entitiy.
  • Constructor Details

    • Entity

      public Entity(EntityCatalog<E> catalog)
      Creates a new entity with (possibly) multiple names in multiple languages. This constructor is special as it does not define any name, but the the names must be added afterwards by calling EntityCatalog.addEntityNames(Entity,MuLi), or sim.

      ATTENTION The uniqeness of the names of the different entities in the same EntityCatalog (in different languages or in the same language) is not checked.

      Parameters:
      catalog - where to enter the new instance
    • Entity

      public Entity(EntityCatalog<E> catalog, Map<String,String> names)
      Creates a new entity with (possibly) multiple names in multiple languages. Further names can be added afterwards by calling EntityCatalog.addEntityNames(Entity,MuLi), or sim.

      ATTENTION The uniqeness of the names of the different entities in one EntityCatalog (in the different languages or even in the same language) is curently not checked.

      Parameters:
      catalog - where to enter the new instance
      names - mapping from language to name
    • Entity

      public Entity(EntityCatalog<E> catalog, String lang, String name)
      Creates a new entity with only one name. Further names can be added afterwards by calling EntityCatalog.addEntityNames(Entity,MuLi), or sim.

      ATTENTION The uniqeness of the names of the different entities in one EntityCatalog (in the different languages or the same language) is not checked.

      Parameters:
      catalog - where to enter the new instance
      lang - language of the name
      name - name of the entity
    • Entity

      public Entity(EntityCatalog<E> catalog, MuLi humanNames)
      Creates a new entity with (possibly) multiple names in multiple languages. Further names can be added afterwards by calling EntityCatalog.addEntityNames(Entity,MuLi), or sim.

      ATTENTION The uniqeness of the names of the different entities in one EntityCatalog (in the different languages or the same language) is not checked.

      Parameters:
      catalog - where to enter the new instance
      humanNames - mapping from language to name
  • Method Details

    • getCatalog

      public EntityCatalog<E> getCatalog()
      The multi-lingual catalog in which this entitiy is contained.
    • addName

      public E addName(String language, String name)
      Add a further name.
      Returns:
      this instance, to support chained invocations.
    • getParser

      public Translet.Parser<E> getParser(String language)
      Gets the default parser for this entity, which accepts the name in the given language only.
      Specified by:
      getParser in interface Translet.Parseable<E extends Entity>
    • getParser

      public Translet.Parser<E> getParser()
      Gets the default parser for this entity, which accepts the name in the default language, as specified by EntityCatalog.getDefaultLanguage()
      Specified by:
      getParser in interface Translet.Parseable<E extends Entity>
    • toString

      public String toString(String... languages)
      Get the name according to the given language priority, as defined in MuLi.get(String...). If this fails, get built-in Object.toString() conversion result.
    • toString

      public String toString()
      Get any name, preferable in the EntityCatalog.SYMBOLIC language, as defined in MuLi.get(String...). If this fails, get built-in Object.toString() conversion result.
      Overrides:
      toString in class Object
    • getSpecific

      public String getSpecific(String language)
      Return the name stored under a particular key. In contrast to other methods, no fall-back mechanisms take place.
    • getName

      public String getName(String... langs)
      Look up the name in the given languages, or in default. If the list is empty, try the
      invalid @link
      {@link EntityCatalog#getDefaultLanguage(),
      followed by EntityCatalog.SYMBOLIC.
    • getNames

      public MuLi getNames()
      Returns MuLi containing the names in the different languages.
    • getDocumentations

      public MuLi getDocumentations()
      Returns MuLi containing documentation text in different languages.
    • setDocumentation

      public void setDocumentation(String language, String doc)
      Add a documentation text in the given langauge.
    • getDocumentation

      public String getDocumentation(String language)
    • getDocumentation

      public String getDocumentation()
      Returns:
      the documentation text in the default language, as specified by EntityCatalog.getDefaultLanguage()
    • dump

      public void dump(PrintStream ps)
      Debugging method to display this entity. Called by EntityCatalog.dump(PrintStream)
    • dump

      public void dump()
      Convenience method, dumping to System.err.