Package eu.bandm.tools.location
Class Location.Set<D>
java.lang.Object
eu.bandm.tools.location.Location<D>
eu.bandm.tools.location.Location.Set<D>
- Type Parameters:
D
- the type of document identifiers, possiblyVoid
.
- All Implemented Interfaces:
Locatable<D>
,Serializable
,Cloneable
The third sub-class, representing regions with gaps, or even in
different documents.
All kind of locations (points, ranges, and sets) can be entered.
No sorting or unification is performed. For this, the special
class
Spectrum
responsible.-
Nested Class Summary
Nested classes/interfaces inherited from class eu.bandm.tools.location.Location
Location.Set<D>
-
Field Summary
Fields inherited from class eu.bandm.tools.location.Location
EMACS_FIRST_COLUMN_NUMBER, EMACS_FIRST_LINE_NUMBER, eq, formatEmacs, MAX_PARTICULAR, MIN_PARTICULAR, NOT_APPLICABLE, UNKNOWN
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
Calculate the relative distance of a point to the start of this region.boolean
Whether the argument is contained in this Location.int
The number of spanned characters, iff the LocationLocation.isContiguous()
.Returns the begin point of this location.Returns the end point of this location.Returns the reference point of this location.Returns every kind of Location as a collection of Point and Region instances.boolean
Whether this Location describes a range of characters in the same line.boolean
isPoint()
Checks whether this location is a point.boolean
isRegion()
Checks whether this location is an Region.<E> Location
<E> mapDocumentId
(Function<? super D, ? extends E> f) Return a new location, by applying "f" to the document id/ids therein.rel2abs
(int off) Defined for Regions covering only one line: Delivers a point in the Region which has the given offset from the start of the region.Methods inherited from class eu.bandm.tools.location.Location
cast, clone, comparable, equals, formatEmacs, getBeginColumn, getBeginLine, getColumn, getDocumentId, getEndColumn, getEndLine, getLine, getLocation, hashCode, increment, isAdjacent, isApplicable, isColumnDeficient, isDeficient, isLineDeficient, isParticular, isPointOrRegion, isRegionInOneLine, isSet, isSpecified, isValid, liftMapDocumentId, line, line_from_to, live, live, live, mapDocumentId, max, min, nextColumn, nextLine, noLocation, offset, point, pointOrder, referencePointOrder, region, region, regionRobust, regionSorted, setOf, subsequentChars, toString
-
Constructor Details
-
Set
Set(Collection<? extends Location<D>> locations) Constructor, not callable. The construction goes by the factory methods inLocation
- Parameters:
locations
- the locations to include in this sets.
-
-
Method Details
-
mapDocumentId
Return a new location, by applying "f" to the document id/ids therein.- Specified by:
mapDocumentId
in classLocation<D>
- Type Parameters:
E
- the type of the DocumentId.- Parameters:
f
- the function to apply- Returns:
- a new location, by applying "f" to the document id/ids therein.
-
isPoint
public boolean isPoint()Checks whether this location is a point. If this method returnstrue
, then the reference point, begin point and end point of this location are all equal to this location. -
isRegion
public boolean isRegion()Checks whether this location is an Region. If this method returnstrue
, then the region partition (as returned byLocation.getRegions()
) of this location contains a single location equal to this location. -
getReferencePoint
Returns the reference point of this location. The reference point is a point. If this location is a point, then the reference point is equal to this location. If this location is an region, then the reference point lies within this location. If this location is a set, then the reference point lies within one of the member regions.- Specified by:
getReferencePoint
in classLocation<D>
- Returns:
- the reference point of this location.
-
getBeginPoint
Returns the begin point of this location. The begin point is a point. If this location is a point, then the begin point is equal to this location. If this location is an region, then the begin point lies at the beginning of this location. If this location is a set, then the begin point lies at the beginning of one of the member regions, such that there is no member region that lies in the same document and begins before the begin point.- Specified by:
getBeginPoint
in classLocation<D>
- Returns:
- the begin point of this location.
-
getEndPoint
Returns the end point of this location. The end point is a point. If this location is a point, then the end point is equal to this location. If this location is an region, then the end point lies at the end of this location. If this location is a set, then the end point lies at the end of one of the member regions, such that there is no member region that lies in the same document and ends after the end point.- Specified by:
getEndPoint
in classLocation<D>
- Returns:
- the end point of this location.
-
getRegions
Returns every kind of Location as a collection of Point and Region instances. If this is a Point or Region, than only this is contained in that collection.- Specified by:
getRegions
in classLocation<D>
- Returns:
- the Location as a collection of Point and Region instances.
-
contains
Whether the argument is contained in this Location. If this is a point, then this and loc must be identical. Otherwise for every Region or Point in loc there must be an Region or Point in this which completely contains it. -
isContiguous
public boolean isContiguous()Whether this Location describes a range of characters in the same line. This is the case for every Point and possibly for a Region, but never for a Set.(Implementation note: Since this class has no information about the number of characters in particular lines of the referred document, contiguous regions across line breaks cannot be detected. The naming therefore is better "isDefinitelyContiguous".)
- Specified by:
isContiguous
in classLocation<D>
- Returns:
- whether this describes a set of characters in the same line.
-
contiguousSize
public int contiguousSize()The number of spanned characters, iff the LocationLocation.isContiguous()
. Otherwise the returned value is meaningless.- Specified by:
contiguousSize
in classLocation<D>
- Returns:
- the number of spanned characters.
-
abs2rel
Calculate the relative distance of a point to the start of this region. Tested is theLocation.getBeginPoint()
of the argument. Is defined when this is a region whichLocation.isContiguous()
and contains this start point, or when thisLocation.isPoint()
and is equal to that start point (which delivers the constant 0).. Not defined for sets, throws exception. -
rel2abs
Defined for Regions covering only one line: Delivers a point in the Region which has the given offset from the start of the region. And defined for a point and offset==0, yielding this point. The containement of the point in the region is not tested.. Not defined for sets, throws exception.
-