1 5 package com.opensymphony.webwork.views.jsp; 6 7 8 15 public class IteratorStatus { 16 18 protected StatusState state; 20 21 23 public IteratorStatus(StatusState aState) { 26 state = aState; 27 } 28 29 31 public int getCount() { 32 return state.index + 1; 33 } 34 35 public boolean isEven() { 36 return ((state.index + 1) % 2) == 0; 37 } 38 39 public boolean isFirst() { 41 return state.index == 0; 42 } 43 44 public int getIndex() { 45 return state.index; 46 } 47 48 public boolean isLast() { 49 return state.last; 50 } 51 52 public boolean isOdd() { 53 return ((state.index + 1) % 2) == 1; 54 } 55 56 public int modulus(int operand) { 57 return (state.index + 1) % operand; 58 } 59 60 62 public static class StatusState { 63 boolean last = false; 64 int index = 0; 65 66 public void setLast(boolean isLast) { 67 last = isLast; 68 } 69 70 public void next() { 71 index++; 72 } 73 } 74 } 75 | Popular Tags |