Class PlainText

java.lang.Object
org.openrewrite.text.PlainText
All Implemented Interfaces:
SourceFile, Tree

public class PlainText extends Object implements SourceFile, Tree
The simplest of all ASTs representing nothing more than just unstructured text.
  • Constructor Details

    • PlainText

      public PlainText()
  • Method Details

    • getCharset

      public Charset getCharset()
      Specified by:
      getCharset in interface SourceFile
    • withCharset

      public SourceFile withCharset(Charset charset)
      Specified by:
      withCharset in interface SourceFile
    • withText

      public PlainText withText(String text)
    • isAcceptable

      public <P> boolean isAcceptable(TreeVisitor<?,P> v, P p)
      Description copied from interface: Tree
      Checks the supplied argument to see if the supplied visitor and its context would be valid arguments to accept(). Typically this involves checking that the visitor is of a type that operates on this kind of tree. e.g.: A Java Tree implementation would return true for JavaVisitors and false for MavenVisitors
      Specified by:
      isAcceptable in interface Tree
      Type Parameters:
      P - the visitor's context argument
      Returns:
      'true' if the arguments to this function would be valid arguments to accept()
    • accept

      public <R extends Tree, P> R accept(TreeVisitor<R,P> v, P p)
      Description copied from interface: Tree
      Supports polymorphic visiting via TreeVisitor.visit(Tree, Object). This is useful in cases where an AST type contains a field that is of a type with a hierarchy. The visitor doesn't have to figure out which visit method to call by using instanceof.
      Specified by:
      accept in interface Tree
      Type Parameters:
      R - visitor return type
      P - visit context type
      Parameters:
      v - visitor
      p - visit context
      Returns:
      visitor result
    • printer

      public <P> TreeVisitor<?,PrintOutputCapture<P>> printer(Cursor cursor)
      Specified by:
      printer in interface SourceFile
      Specified by:
      printer in interface Tree
    • getWeight

      public long getWeight(Predicate<Object> uniqueIdentity)
      Description copied from interface: SourceFile
      A measure of the size of the AST by count of number of AST nodes or some other similar measure. Because perfect referential uniqueness is space inefficient, this weight will always be approximate and is best used for comparative size between two ASTs rather than an absolute measure.
      Specified by:
      getWeight in interface SourceFile
      Parameters:
      uniqueIdentity - A means of only counting referentially equal AST nodes once. In performance sensitive situations this should use a probabilistic set membership data structure.
      Returns:
      The weight of the AST.
    • getSnippets

      public List<PlainText.Snippet> getSnippets()
    • withSnippets

      public PlainText withSnippets(@Nullable @Nullable List<PlainText.Snippet> snippets)