Class DocHandlerContext

java.lang.Object
com.norconex.importer.handler.DocHandlerContext

public class DocHandlerContext extends Object
  • Method Details

    • metadata

      public Properties metadata()
    • reference

      public String reference()
    • contentType

      public ContentType contentType()
    • parentReferences

      public List<String> parentReferences()
    • charset

      public Charset charset()
    • streamFactory

      public CachedStreamFactory streamFactory()
    • isRejected

      public boolean isRejected()
    • resolveCharset

      public Charset resolveCharset(Charset charset)
      Return the most appropriate charset for the current context. Logic (in order):
      • If the document has been parsed already, return UTF-8.
      • If the provided Charset if not null, return it.
      • If the document has a Charset on it, return it.
      • Fallback to UTF-8.
      Parameters:
      charset - the charset to use if non-null and the document has not been parsed yet.
      Returns:
      a character set (never null)
    • flush

      public void flush() throws IOException
      Flush and dispose any output that has been written to with output() and apply it as the input source of the underlying document.
      Throws:
      IOException
    • input

      public ReadAdapter input() throws IOException
      Flushes any output and returns an adapter for the document input..
      Returns:
      document input adapter
      Throws:
      IOException
    • output

      public WriteAdapter output()
      Make sure to close the stream when done or explictly flush the stream.
      Returns:
      output adapter
    • executeDocHandler

      public boolean executeDocHandler(DocHandler docHandler) throws IOException
      Executes a document handler taking care of firing proper events and passing it this context as well as assigning the handler to "rejectedBy" in case of rejection.
      Parameters:
      docHandler - document handler to invoke
      Returns:
      true to move to the next handler
      Throws:
      IOException
    • builder

    • parseState

      public DocHandlerContext parseState(@NonNull @NonNull ParseState parseState)
      Returns:
      this.
    • condition

      public DocHandlerContext condition(Condition condition)
      Closest wrapping Condition, if applicable.
      Parameters:
      condition - a condition
      Returns:
      this.
    • rejectedBy

      public DocHandlerContext rejectedBy(Object rejectedBy)
      Returns:
      this.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • childDocs

      public List<Doc> childDocs()
    • parseState

      @NonNull public @NonNull ParseState parseState()
    • condition

      public Condition condition()
      Closest wrapping Condition, if applicable.
      Returns:
      condition
    • eventManager

      @NonNull public @NonNull EventManager eventManager()
    • rejectedBy

      public Object rejectedBy()