Class AnnotatedText


  • public class AnnotatedText
    extends java.lang.Object
    A text with markup and with a mapping so error positions will refer to the original position that includes the markup, even though only the plain text parts are checked. Use AnnotatedTextBuilder to create objects of this type.
    Since:
    2.3
    • Constructor Summary

      Constructors 
      Constructor Description
      AnnotatedText​(java.util.List<TextPart> parts, java.util.Map<java.lang.Integer,​MappingValue> mapping, java.util.Map<AnnotatedText.MetaDataKey,​java.lang.String> metaData, java.util.Map<java.lang.String,​java.lang.String> customMetaData)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getGlobalMetaData​(java.lang.String key, java.lang.String defaultValue)  
      java.lang.String getGlobalMetaData​(AnnotatedText.MetaDataKey key, java.lang.String defaultValue)  
      java.lang.String getOriginalText()
      Get the plain text, without markup and content from interpretAs.
      int getOriginalTextPositionFor​(int plainTextPosition, boolean isToPos)
      Internally used by LanguageTool to adjust error positions to point to the original location with markup, even though markup was ignored during text checking.
      java.lang.String getPlainText()
      Get the plain text, without markup but with content from interpretAs.
      java.lang.String getTextWithMarkup()  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • parts

        private final java.util.List<TextPart> parts
      • mapping

        private final java.util.Map<java.lang.Integer,​MappingValue> mapping
      • customMetaData

        private final java.util.Map<java.lang.String,​java.lang.String> customMetaData
    • Constructor Detail

      • AnnotatedText

        AnnotatedText​(java.util.List<TextPart> parts,
                      java.util.Map<java.lang.Integer,​MappingValue> mapping,
                      java.util.Map<AnnotatedText.MetaDataKey,​java.lang.String> metaData,
                      java.util.Map<java.lang.String,​java.lang.String> customMetaData)
    • Method Detail

      • getOriginalText

        public java.lang.String getOriginalText()
        Get the plain text, without markup and content from interpretAs.
        Since:
        4.3
      • getPlainText

        public java.lang.String getPlainText()
        Get the plain text, without markup but with content from interpretAs.
      • getTextWithMarkup

        public java.lang.String getTextWithMarkup()
        Since:
        4.3
      • getOriginalTextPositionFor

        public int getOriginalTextPositionFor​(int plainTextPosition,
                                              boolean isToPos)
        Internally used by LanguageTool to adjust error positions to point to the original location with markup, even though markup was ignored during text checking.
        Parameters:
        plainTextPosition - the position in the plain text (no markup) that was checked
        isToPos - the from/to position needed
        Returns:
        an adjusted position of the same location in the text with markup
      • getGlobalMetaData

        public java.lang.String getGlobalMetaData​(java.lang.String key,
                                                  java.lang.String defaultValue)
        Since:
        3.9
      • getGlobalMetaData

        public java.lang.String getGlobalMetaData​(AnnotatedText.MetaDataKey key,
                                                  java.lang.String defaultValue)
        Since:
        3.9
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object