Interface Rewriter<R extends Resource<?>,P1 extends Point,P2 extends Point>

All Known Implementing Classes:
XPathNormalizer, XPathNormalizerWithXPath, XPathRefinedByRFC5147CharSchemeBackwardMapper, XPathRefinedByRFC5147CharSchemeForwardMapper, XPathRefinedByRFC5147CharSchemeToTextBackwardMapper, XPathRefinedByRFC5147CharSchemeToTextForwardMapper

public interface Rewriter<R extends Resource<?>,P1 extends Point,P2 extends Point>
A Rewriter is a utility for rewriting a representation of a Point in Resource to another representation. There are different types of rewriters: normalizers, forward mappers, and reverse mappers, which all do some kind of rewriting a representation of a point. This common interface offers type-safe rewriting of points in resources by type parameters.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static enum 
    Rewriting a Point in FORWARD direction means to transform it in the same direction as using the same transformation for transforming a preimage to an image of a resource.
  • Method Summary

    Modifier and Type
    Method
    Description
    rewrite(R resource, P1 position, RewriterConfig config)
    Rewrite a Point in a Resource to the same point, but with a different (or potentially different) representation.
  • Method Details

    • rewrite

      List<P2> rewrite(R resource, P1 position, RewriterConfig config) throws SelectorException
      Rewrite a Point in a Resource to the same point, but with a different (or potentially different) representation.

      A normalizer will typically return one recalculated point. A so-called forward mapper, which maps a point from a preimage resource to a derived resource, the image, may return zero, one or multiple points, depending on how many times a point in the preimage was mapped to the image. Thus, the return type is List of Points.

      Note: It would be desirable, if we could declare a monadic return type with a type parameter, M; and then use, e.g., the identity monad for normalizers, the list monad for forward mappers, the maybe monad Optional for reverse mappers. However, that cannot be expressed in the Java type system. Since the implied arities can easily be covered with an iterable, we use a List.

      Parameters:
      resource - the Resource to operate on
      position - a Point in the resource
      config - a record with configuration parameters
      Returns:
      the same point like position, but in a recalculated representation and wrapped into a List, which should represent the occurrences of the point in document order, if an order exists in the source.
      Throws:
      SelectorException - when the position cannot be found in the resource //