Package eu.bandm.tools.message
Class LocationMap<D,E>
java.lang.Object
eu.bandm.tools.message.LocationMap<D,E>
- Type Parameters:
D
- the document identifier type of the domain locationsE
- the document identifier type of the range locations
Facility to translate
Eg. when fragents from a source text are concatenated into a StringBuilder, which is then subject to a lexical sanner, the scanner will produce error messages which must be re-mapped to the original context to become meaningful for the user.
All locations entered into this map must be of the "region" flavour (see
Location
s. Is needed in case of re-arranging text fragments,
and location info must be adjusted accordingly.
Eg. when fragents from a source text are concatenated into a StringBuilder, which is then subject to a lexical sanner, the scanner will produce error messages which must be re-mapped to the original context to become meaningful for the user.
All locations entered into this map must be of the "region" flavour (see
Location
). They must be entered pairwise, with identical lengths.-
Nested Class Summary
Modifier and TypeClassDescriptionclass
A message receiver which passes on all messages after translating the location according to the mapping represented by its outer class. -
Field Summary
Modifier and TypeFieldDescriptionLocations making up the translation's domain.Total function, which translates null to null and maps every location according to the containing .final Function<SimpleMessage<D>,
SimpleMessage<E>> A publicFunction
object which applies the mapping of the containing class to the location fields ofSimpleMessage
s.Locations making up the translation's range.protected boolean
Whether locatiosn not in the domain are delivered unmodified, as their own Translation. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
DOCMEResolve a point or a region.void
dump
(PrintStream p) Auxiliary debugging routine.void
Establishes the mapping between both locations.Performs the mapping from left to right, Can currently only deal with points and intervals, not with sets.resolve_backward
(Location<E> loc) Performs the mapping from right to left, Can currently only deal with points and intervals, not with sets.Translates a location point at offset p in domain region n to the point at the same offset in the range region n.boolean
setTransparent
(boolean trans) Sets the transparent attribute and returns its old value.
-
Field Details
-
leftlocs
Locations making up the translation's domain. List is in one-to-one-correspondance torightlocs
. -
rightlocs
Locations making up the translation's range. List is in one-to-one-correspondance toleftlocs
. -
transparent
protected boolean transparentWhether locatiosn not in the domain are delivered unmodified, as their own Translation. If not set, null is returned in this case. -
mapLocations
Total function, which translates null to null and maps every location according to the containing . -
mapMessages
A publicFunction
object which applies the mapping of the containing class to the location fields ofSimpleMessage
s.
-
-
Constructor Details
-
LocationMap
public LocationMap()
-
-
Method Details
-
clear
public void clear()DOCME -
put
Establishes the mapping between both locations.left
andright
must be of "region" type and must have equal length. -
setTransparent
public boolean setTransparent(boolean trans) Sets the transparent attribute and returns its old value. Id decides that locatiosn not in the domain are delivered unmodified, as their own Translation. This is only sensible if type parameters D and E have the same value. Otherwise a type error will occur at runtime.
iftransparent
is not set, null is returned in this case. -
resolve
Performs the mapping from left to right, Can currently only deal with points and intervals, not with sets.- Returns:
- the translated location, or null if not in domain.
-
resolve_backward
Performs the mapping from right to left, Can currently only deal with points and intervals, not with sets. -
doResolve
@Opt protected <P,Q> @Opt Location<Q> doResolve(List<Location<P>> from, List<Location<Q>> to, Location<P> loc) Resolve a point or a region. If a point is not in a domain region return null (iff transparent not set) or the unmodified point.
If only one end of a region is in a domain region, then return this end. If no end of a region is in a domain region, return null or the original, depending ontransparent
. -
resolvePoint
@Opt protected static <P,Q> @Opt Location<Q> resolvePoint(List<Location<P>> from, List<Location<Q>> to, Location<P> loc) Translates a location point at offset p in domain region n to the point at the same offset in the range region n. -
dump
Auxiliary debugging routine. Prints all pairs of regions to stderr.
-