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, possibly Void.
All Implemented Interfaces:
Locatable<D>, Serializable, Cloneable
Enclosing class:
Location<D>

static class Location.Set<D> extends Location<D>
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.
  • Constructor Details

    • Set

      Set(Collection<? extends Location<D>> locations)
      Constructor, not callable. The construction goes by the factory methods in Location
      Parameters:
      locations - the locations to include in this sets.
  • Method Details

    • mapDocumentId

      public <E> Location<E> mapDocumentId(Function<? super D,? extends E> f)
      Return a new location, by applying "f" to the document id/ids therein.
      Specified by:
      mapDocumentId in class Location<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 returns true, then the reference point, begin point and end point of this location are all equal to this location.
      Specified by:
      isPoint in class Location<D>
      Returns:
      true if this location is a point, false if this location is an region or a set.
    • isRegion

      public boolean isRegion()
      Checks whether this location is an Region. If this method returns true, then the region partition (as returned by Location.getRegions()) of this location contains a single location equal to this location.
      Specified by:
      isRegion in class Location<D>
      Returns:
      true if this location is a region, false if this location is a point or set.
    • getReferencePoint

      public Location<D> 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 class Location<D>
      Returns:
      the reference point of this location.
    • getBeginPoint

      public Location<D> 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 class Location<D>
      Returns:
      the begin point of this location.
    • getEndPoint

      public Location<D> 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 class Location<D>
      Returns:
      the end point of this location.
    • getRegions

      public Collection<Location<D>> 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 class Location<D>
      Returns:
      the Location as a collection of Point and Region instances.
    • contains

      public boolean contains(Location<?> loc)
      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.
      Specified by:
      contains in class Location<D>
      Parameters:
      loc - The location tested whether to be contained in this Location.
      Returns:
      whether the location tested is in this Location.
    • 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 class Location<D>
      Returns:
      whether this describes a set of characters in the same line.
    • contiguousSize

      public int contiguousSize()
      The number of spanned characters, iff the Location Location.isContiguous(). Otherwise the returned value is meaningless.
      Specified by:
      contiguousSize in class Location<D>
      Returns:
      the number of spanned characters.
    • abs2rel

      public int abs2rel(Location<D> loc)
      Calculate the relative distance of a point to the start of this region. Tested is the Location.getBeginPoint() of the argument. Is defined when this is a region which Location.isContiguous() and contains this start point, or when this Location.isPoint() and is equal to that start point (which delivers the constant 0).. Not defined for sets, throws exception.
      Specified by:
      abs2rel in class Location<D>
      Parameters:
      loc - the Location which is searched relative to this Location.
      Returns:
      the offset of the parameter Location to this Location.
    • rel2abs

      public Location<D> 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. 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.
      Specified by:
      rel2abs in class Location<D>
      Parameters:
      off - the offset which determins the result location
      Returns:
      the location with the given distance from the start of this.