Class GmailMessageReader


public class GmailMessageReader extends GoogleApiReader
Reads Gmail messages, optionally selected by a search query, one record per message with its addresses, headers, flags, content parts and Gmail metadata such as label and thread IDs.
  • Field Details

  • Constructor Details

    • GmailMessageReader

      public GmailMessageReader(Credential credential, HttpTransport httpTransport)
      Creates a reader that uses the caller's transport, which is not shut down on close.
    • GmailMessageReader

      public GmailMessageReader(Credential credentials)
      Creates a reader with its own HTTP transport, which is shut down on close.
  • Method Details

    • getQuery

      public String getQuery()
      Returns the search query used to list messages or null if none was set (the default).
    • setQuery

      public GmailMessageReader setQuery(String query)
      Sets the search query used to list messages; null (the default) means no query.
    • getBatchSize

      public int getBatchSize()
      Returns the number of messages requested per page (defaults to 25).
    • isIncludeSpamAndTrash

      public boolean isIncludeSpamAndTrash()
    • setIncludeSpamAndTrash

      public GmailMessageReader setIncludeSpamAndTrash(boolean includeSpamAndTrash)
    • getLabelIds

      public List<String> getLabelIds()
    • addLabelIds

      public GmailMessageReader addLabelIds(String... labelIds)
    • setBatchSize

      public GmailMessageReader setBatchSize(int batchSize)
      Sets the number of messages requested per page, from MIN_BATCH_SIZE to MAX_BATCH_SIZE (defaults to 25).
    • open

      public void open() throws DataException
      Description copied from class: DataEndpoint
      Makes this endpoint ready for reading or writing.
      Overrides:
      open in class IntegrationReader
      Throws:
      DataException
    • close

      public void close() throws DataException
      Description copied from class: DataEndpoint
      Indicates that this endpoint has finished reading or writing.
      Overrides:
      close in class GoogleApiReader
      Throws:
      DataException
    • available

      public int available() throws DataException
      Description copied from class: DataReader
      Returns the number of records that can probably be read without blocking.
      Overrides:
      available in class DataReader
      Throws:
      DataException
    • readImpl

      protected Record readImpl() throws Throwable
      Description copied from class: DataReader
      Overridden by subclasses to read the next record from this DataReader. The default implementation of DataReader.read() now insures that this method will not be called again after it returns a null.

      If no record is available, null will be returned.

      Contract for subclasses (see also docs/authoring/DataReader.md):

      Specified by:
      readImpl in class DataReader
      Throws:
      Throwable
    • addExceptionProperties

      public DataException addExceptionProperties(DataException exception)
      Description copied from class: Endpoint
      Adds this endpoint's current state to a DataException. Since this method is called whenever an exception is thrown, subclasses should override it to add their specific information.
      Overrides:
      addExceptionProperties in class GoogleApiReader