eu.bandm.tscore.base
Class Reducer

java.lang.Object
  extended by eu.bandm.tscore.tdom.Visitor
      extended by eu.bandm.tscore.base.Reducer

public class Reducer
extends eu.bandm.tscore.tdom.Visitor

Realizes second step of any tscore text processing pipeline by translating the output of TScoreParser, which is an instance of a eu.bandm.tscore.tdom tdom model, into a eu.bandm.tscore.model umod model.

All parameter strings are left as raw, unparsed data and must be parsed in subsequent steps by dedicated parsers, depending on the score format which is to implement.

Usage Pattern:
Call the constructor Reducer(MuLiMessageReceiver, TimeScape) with a pre-built instance of TimeScape. This serves as a global container for the reduction results!
Then call reduce(Document_file, Reactions) or reduce(Document_file).


Nested Class Summary
protected  class Reducer.MergeSymbols<E extends TypedChoice>
          Creates a new list of elements, where all adjacent idents, numerics and nonAlfanumeric(E/P)s are concatenated in one Element_ident.
static class Reducer.Reaction
          Encodes how the code will react to a specific input condition.
static class Reducer.Reactions
          An instance of this class is used to parametrize the call of reduce(Document_file,Reactions) for defining the reactions to certain critical conditions in the input data.
 
Field Summary
protected  SortedMap<Integer,Tp> col2tp
           
protected  Part currentPart
           
protected  Vox currentVox
           
static Reducer.Reactions defaultReactions
          Contains an instance with default values, as described with the fields of Reducer.Reactions.
protected  MuLiMessageReceiver<XMLDocumentIdentifier> msg
           
protected  Reducer.Reactions reactions
           
protected  TimeScape timescape
          The central container for all reducing results, must set when calling the constructor Reducer(MuLiMessageReceiver,TimeScape)
protected  Map<Tp,Integer> tp2col
           
protected  SortedMap<Integer,Event> voxEvents
           
 
Constructor Summary
Reducer(MuLiMessageReceiver<XMLDocumentIdentifier> msg, TimeScape timescape)
           
 
Method Summary
protected  void checkMeasureLineNumber(eu.bandm.tscore.tdom.Element el)
           
protected  void ERROR(eu.bandm.tscore.tdom.Element el, String txt, Object... args)
           
protected  void ERROR(Tp tp, String txt, Object... args)
           
protected  Tp getCol2tp(eu.bandm.tscore.tdom.Element el)
           
static String getParamText(Event ev, String key, String sep)
           
protected  void makeEvent(int col, Tp tp, eu.bandm.tscore.tdom.Element el)
           
protected  void makeEvent(Tp tp, eu.bandm.tscore.tdom.Element el)
           
protected  void makeParenthesizedEvents(eu.bandm.tscore.tdom.Element_division division, Tp from, Tp to)
          <!ELEMENT division (elementV+) >
 void makeSubdivision(eu.bandm.tscore.tdom.Element[] els, Tp from, Tp to)
          <!ELEMENT subsubdivision EMPTY >
protected  void putCol2tp(eu.bandm.tscore.tdom.Element el, Tp tp)
           
protected  void putCol2tp(int loc, Tp tp)
           
protected  void putTp2Loc(Tp tp, eu.bandm.tscore.tdom.Element el)
          PLEASE NOTE that locations for time points are kept with "part", because they can appear more than once, but not per part.
protected  void react(Reducer.Reaction react, Location<XMLDocumentIdentifier> loc, String txt, Object... args)
           
 void reduce(eu.bandm.tscore.tdom.Document_file file)
          Call the reduce(Document_file,Reactions) method with the default reactions, as described with the fields of Reducer.Reactions.
 void reduce(eu.bandm.tscore.tdom.Document_file file, Reducer.Reactions reactions)
          The result of the parsing process are zero or more instances of Part, Vox and Tp..
protected  boolean testMakeEvent(int col, Map<Integer,eu.bandm.tscore.tdom.Element> col2sub)
          Test whether there is an event on the "one-beat".
protected  Location<XMLDocumentIdentifier> tp2loc(Tp tp)
           
 void visit(eu.bandm.tscore.tdom.Element_akkolade element)
          <!ELEMENT akkolade (measureline, voxs) >
 void visit(eu.bandm.tscore.tdom.Element_formatdef element)
          <!ELEMENT formatdef (ident) >
 void visit(eu.bandm.tscore.tdom.Element_measureline.Seq_1 seq)
           
 void visit(eu.bandm.tscore.tdom.Element_measureline element)
          <!ELEMENT measureline ((ident | numeric), subsubdivision*, subdivision*)* >
 void visit(eu.bandm.tscore.tdom.Element_paramline element)
          <!ELEMENT paramline (ident, element*) >
 void visit(eu.bandm.tscore.tdom.Element_parsdef element)
          <!ELEMENT parsDef (ident_or_string, useFormat?, akkolade*) >
 void visit(eu.bandm.tscore.tdom.Element_useFormat element)
          <!ELEMENT useFormat (ident) >
 void visit(eu.bandm.tscore.tdom.Element_voiceline element)
          Makes all events in one voiceline, relative to a current status of column/timepoint definitions, as defined by a preceding timeline.
protected  void WARNING(eu.bandm.tscore.tdom.Element el, String txt, Object... args)
           
protected  void WARNING(Tp tp, String txt, Object... args)
           
 
Methods inherited from class eu.bandm.tscore.tdom.Visitor
visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

defaultReactions

public static final Reducer.Reactions defaultReactions
Contains an instance with default values, as described with the fields of Reducer.Reactions.


reactions

protected Reducer.Reactions reactions

timescape

protected final TimeScape timescape
The central container for all reducing results, must set when calling the constructor Reducer(MuLiMessageReceiver,TimeScape)


msg

protected final MuLiMessageReceiver<XMLDocumentIdentifier> msg

currentPart

protected Part currentPart

col2tp

protected SortedMap<Integer,Tp> col2tp

tp2col

protected Map<Tp,Integer> tp2col

voxEvents

protected SortedMap<Integer,Event> voxEvents

currentVox

protected Vox currentVox
Constructor Detail

Reducer

public Reducer(MuLiMessageReceiver<XMLDocumentIdentifier> msg,
               TimeScape timescape)
Parameters:
msg - the message channel for all errors/warnings
timescape - the container for all processing results, seereduce(Document_file,Reactions),
Method Detail

reduce

public void reduce(eu.bandm.tscore.tdom.Document_file file,
                   Reducer.Reactions reactions)
The result of the parsing process are zero or more instances of Part, Vox and Tp.. They all will be entered into the corresponding maps in timescape. FIXME MISSING: Parsing of format definitions (Element_formatdef) and their application.


reduce

public void reduce(eu.bandm.tscore.tdom.Document_file file)
Call the reduce(Document_file,Reactions) method with the default reactions, as described with the fields of Reducer.Reactions.


getParamText

public static String getParamText(Event ev,
                                  String key,
                                  String sep)

putTp2Loc

protected void putTp2Loc(Tp tp,
                         eu.bandm.tscore.tdom.Element el)
PLEASE NOTE that locations for time points are kept with "part", because they can appear more than once, but not per part.


ERROR

protected void ERROR(eu.bandm.tscore.tdom.Element el,
                     String txt,
                     Object... args)

WARNING

protected void WARNING(eu.bandm.tscore.tdom.Element el,
                       String txt,
                       Object... args)

ERROR

protected void ERROR(Tp tp,
                     String txt,
                     Object... args)

WARNING

protected void WARNING(Tp tp,
                       String txt,
                       Object... args)

tp2loc

protected Location<XMLDocumentIdentifier> tp2loc(Tp tp)

react

protected void react(Reducer.Reaction react,
                     Location<XMLDocumentIdentifier> loc,
                     String txt,
                     Object... args)

putCol2tp

protected void putCol2tp(int loc,
                         Tp tp)

putCol2tp

protected void putCol2tp(eu.bandm.tscore.tdom.Element el,
                         Tp tp)

getCol2tp

protected Tp getCol2tp(eu.bandm.tscore.tdom.Element el)

visit

public void visit(eu.bandm.tscore.tdom.Element_formatdef element)
<!ELEMENT formatdef (ident) >

Overrides:
visit in class eu.bandm.tscore.tdom.Visitor

visit

public void visit(eu.bandm.tscore.tdom.Element_useFormat element)
<!ELEMENT useFormat (ident) >

Overrides:
visit in class eu.bandm.tscore.tdom.Visitor

visit

public void visit(eu.bandm.tscore.tdom.Element_parsdef element)
<!ELEMENT parsDef (ident_or_string, useFormat?, akkolade*) >

Overrides:
visit in class eu.bandm.tscore.tdom.Visitor

visit

public void visit(eu.bandm.tscore.tdom.Element_akkolade element)
<!ELEMENT akkolade (measureline, voxs) >

Overrides:
visit in class eu.bandm.tscore.tdom.Visitor

visit

public void visit(eu.bandm.tscore.tdom.Element_measureline element)
<!ELEMENT measureline ((ident | numeric), subsubdivision*, subdivision*)* >

Overrides:
visit in class eu.bandm.tscore.tdom.Visitor

checkMeasureLineNumber

protected void checkMeasureLineNumber(eu.bandm.tscore.tdom.Element el)

visit

public void visit(eu.bandm.tscore.tdom.Element_measureline.Seq_1 seq)
Overrides:
visit in class eu.bandm.tscore.tdom.Visitor

makeSubdivision

public void makeSubdivision(eu.bandm.tscore.tdom.Element[] els,
                            Tp from,
                            Tp to)
<!ELEMENT subsubdivision EMPTY >


visit

public void visit(eu.bandm.tscore.tdom.Element_voiceline element)
Makes all events in one voiceline, relative to a current status of column/timepoint definitions, as defined by a preceding timeline.
  1. creates a new voice, if necessary, and inserts it into part and timescape.
  2. creates a first, provisionary map "col2sub" of columns to sub-elements
  3. operates on this map segment-wise. Segments defined by timeline columns.
  1. pending parentheses are memorized across segment borders.
  2. otherwise it is tested whether there is an event on the "beat" by calling testMakeEvent(int,Map)
  3. then, iff more than one event is in this segment, a TDivision is created and the events are made at the corresponding sub-points of this division. In this turn, it is tested explicitly wheter a sub-division or a single event has to be made.
  4. Element_subdivision being the LAST in the input and extending beyond the current section are NOT treated but memorized.
Creates events, writes them to voice object (in different sortings!) and to the global map voxEvents, for parsing of subsequent parameter lines.

Overrides:
visit in class eu.bandm.tscore.tdom.Visitor

testMakeEvent

protected boolean testMakeEvent(int col,
                                Map<Integer,eu.bandm.tscore.tdom.Element> col2sub)
Test whether there is an event on the "one-beat". Iff true, than "make" it and return true. IST FALSCH, TESTET NICHT AUF PARENTHS !FIXME


makeParenthesizedEvents

protected void makeParenthesizedEvents(eu.bandm.tscore.tdom.Element_division division,
                                       Tp from,
                                       Tp to)
<!ELEMENT division (elementV+) >


makeEvent

protected void makeEvent(Tp tp,
                         eu.bandm.tscore.tdom.Element el)

makeEvent

protected void makeEvent(int col,
                         Tp tp,
                         eu.bandm.tscore.tdom.Element el)

visit

public void visit(eu.bandm.tscore.tdom.Element_paramline element)
<!ELEMENT paramline (ident, element*) >

Overrides:
visit in class eu.bandm.tscore.tdom.Visitor