/** * {@inheritDoc} */ public boolean isAfterLast() throws Exception { checkNotClosed( "()" ); return afterLast; }
/** * {@inheritDoc} */ public void beforeFirst() throws Exception { checkNotClosed( "()" ); beforeFirst = true; afterLast = false; onSingleton = false; }
/** * {@inheritDoc} */ public boolean isBeforeFirst() throws Exception { checkNotClosed( "()" ); return beforeFirst; }
/** * {@inheritDoc} */ public boolean isFirst() throws Exception { checkNotClosed( "()" ); return onSingleton; }
/** * {@inheritDoc} */ public boolean last() throws Exception { checkNotClosed( "()" ); beforeFirst = false; onSingleton = true; afterLast = false; return true; }
/** * {@inheritDoc} */ public void afterLast() throws Exception { checkNotClosed( "()" ); beforeFirst = false; afterLast = true; onSingleton = false; }
/** * {@inheritDoc} */ public boolean first() throws Exception { checkNotClosed( "()" ); beforeFirst = false; onSingleton = true; afterLast = false; return true; }
/** * {@inheritDoc} */ public boolean isLast() throws Exception { checkNotClosed( "()" ); return onSingleton; }
/** * {@inheritDoc} */ public boolean previous() throws Exception { checkNotClosed( "()" ); if ( beforeFirst ) { return false; } if ( afterLast ) { beforeFirst = false; onSingleton = true; afterLast = false; return true; } // must be on the singleton beforeFirst = true; onSingleton = false; afterLast = false; return false; }
/** * {@inheritDoc} */ public boolean next() throws Exception { checkNotClosed( "()" ); if ( beforeFirst ) { beforeFirst = false; onSingleton = true; afterLast = false; return true; } if ( afterLast ) { return false; } // must be on the singleton beforeFirst = false; onSingleton = false; afterLast = true; return false; }
/** * {@inheritDoc} */ public void before( E element ) throws Exception { checkNotClosed( "before()" ); if ( comparator == null ) { throw new UnsupportedOperationException( I18n.err( I18n.ERR_02010 ) ); } int comparison = comparator.compare( singleton, element ); if ( comparison < 0 ) { first(); } else { beforeFirst(); } }
/** * {@inheritDoc} */ public void after( E element ) throws Exception { checkNotClosed( "after()" ); if ( comparator == null ) { throw new UnsupportedOperationException( I18n.err( I18n.ERR_02011 ) ); } int comparison = comparator.compare( singleton, element ); if ( comparison > 0 ) { first(); } else { afterLast(); } }
/** * {@inheritDoc} */ public E get() throws Exception { checkNotClosed( "()" ); if ( onSingleton ) { return singleton; } if ( beforeFirst ) { throw new InvalidCursorPositionException( I18n.err( I18n.ERR_02012 ) ); } else { throw new InvalidCursorPositionException( I18n.err( I18n.ERR_02013 ) ); } }