类 SimpleState<E>

java.lang.Object
jaskell.parsec.common.SimpleState<E>
所有已实现的接口:
State<E>, State<E,​Integer,​Integer>

public class SimpleState<E>
extends Object
implements State<E>
Created by Mars Liu on 2016-01-02. BasicState 类型提供一个基本的 state 实现,它将线性信息序列放到一个List<E%gt;中作为缓存,不保证并发安全. 如果我们要处理的数据量不至于对内存使用造成负担,也没有并发安全的需要,可以使用它.
  • 构造器详细资料

    • SimpleState

      public SimpleState​(List<E> items)
  • 方法详细资料

    • next

      public E next() throws EOFException
      指定者:
      next 在接口中 State<E,​Integer,​Integer>
      返回:
      总是返回 state 的当前元素,并迭代到下一个位置。如果到达结尾,会抛出 eof。
      抛出:
      EOFException - 到达终结状态时,再调用 next 会抛出 EOF 异常。
    • status

      public Integer status()
      指定者:
      status 在接口中 State<E,​Integer,​Integer>
      返回:
      返回当前 state 的状态,对于线性序列,通常即是索引。调用 next 时,会返回这个状态对应的元素。
    • begin

      public Integer begin()
      指定者:
      begin 在接口中 State<E,​Integer,​Integer>
      返回:
      返回一个事务标示,state 应记录和管理这个事务。
    • begin

      public Integer begin​(Integer tran)
      从接口复制的说明: State
      在很多场合,调用者使用自动生成的事务标示已经足够,但是 jparsec 也提供了显式指定事务标示的接口。 在通常的线性序列状态中,通常不需要这样的模式,但是对于具名事务环境,例如一些数据库,可能这种方式 是最佳的实践。State 应尽可能的使用给定的标示构造事务,并返回最终得到的事务标示,这表示我们允许 State 给出与期待不同的事务标示。
      指定者:
      begin 在接口中 State<E,​Integer,​Integer>
      参数:
      tran - 接受一个事务标示参数,state 应尽可能使用这个标示生成事务。
      返回:
      返回一个事务标示,state 应记录和管理这个事务。
    • rollback

      public void rollback​(Integer tran)
      指定者:
      rollback 在接口中 State<E,​Integer,​Integer>
      参数:
      tran - 回滚指定事务号对应的事务。
    • commit

      public void commit​(Integer tran)
      指定者:
      commit 在接口中 State<E,​Integer,​Integer>
      参数:
      tran - 提交指定的事务号。
    • trap

      public ParsecException trap​(String message)
      指定者:
      trap 在接口中 State<E,​Integer,​Integer>
      参数:
      message - 接受指定的消息文本,用于构造异常
      返回:
      总是返回一个 ParsecException 或它的子类。具体的 State 实现者可以提供继承自 ParsecException 的异常。