# Google Data APIs Client Library (1.43.0)

## com.google.gdata.util.parser
Class Action<T,U extends T>

    java.lang.Object
      com.google.gdata.util.parser.Parser<U>
          com.google.gdata.util.parser.Action<T,U>

Type Parameters:
  `T` -
  `U` -

    public class Action<T,U extends T>

extends Parser<U>

Actions are fired when their `subject` parser matches. The `Callback` class is passed the matching portion of the parse text. Note that the `Action` parser wraps around its subject. It will parse exactly the same text that its subject parser parses. Parser p = Chset.ALPHA.plus().action(new Callback() { public void handle(char[] buf, int start, int end, Object data) { StringBuffer str = (StringBuffer) data; str.delete(0, str.length()); str.append(buf, start, end - start); } }); StringBuffer buf = new StringBuffer(); p.parse("a") -> matches "a", buf == "a" p.parse("abcde") -> matches "abcde", buf == "abcde" p.parse("a0") -> matches "a", buf == "a" p.parse("0") -> no match, buf unchanged

See Also:
  `Callback`, `Parser`

Field Summary

Fields inherited from class com.google.gdata.util.parser.Parser
`NO_MATCH`

Constructor Summary
`Action(Parser<T> subject, Callback<U> callback)` Class constructor.

Method Summary
`int` `parse(char[] buf, int start, int end, U data)` Matches the `subject` parser against the current state of the buffer being parsed.

Methods inherited from class com.google.gdata.util.parser.Parser
`action, alternative, difference, intersection, list, optional, parse, parse, parse, plus, repeat, repeat, sequence, sequence, sequence, sequence, star`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Action

    public Action(Parser<T> subject,
                  Callback<U> callback)

  Class constructor.

  Parameters:
    `subject` - The `Parser` that this action is wrapping around.
    `callback` - The `Callback` that will be invoked if the `subject` parser returns a result different than `NO_MATCH`.

Method Detail

### parse

    public int parse(char[] buf,
                     int start,
                     int end,
                     U data)

  Matches the `subject` parser against the current state of the buffer being parsed. If the `subject` parser hits (returns a result other than `NO_MATCH`), `callback.handle` will be invoked and passed the matching region of the parse buffer.

  Specified by:
    `parse` in class `Parser<U extends T>`
  Parameters:
    `buf` - The character array to match against.
    `start` - The start offset of data within the character array to match against.
    `end` - The end offset of data within the character array to match against.
    `data` - User defined object that is passed to `Callback.handle` when an `Action` fires.
  See Also:
    `Parser.parse(char[], int, int, T)`