1 28 29 package com.caucho.jsp; 30 31 import javax.servlet.jsp.jstl.core.LoopTag; 32 import javax.servlet.jsp.jstl.core.LoopTagStatus; 33 import javax.servlet.jsp.tagext.JspTag ; 34 import javax.servlet.jsp.tagext.SimpleTag ; 35 import javax.servlet.jsp.tagext.Tag ; 36 import javax.servlet.jsp.tagext.TagAdapter ; 37 import javax.servlet.jsp.tagext.TagSupport ; 38 39 public class IntegerLoopSupportTag extends TagSupport 40 implements LoopTag, LoopTagStatus { 41 private JspTag _parent; 42 43 private int _begin; 44 private int _end; 45 private int _step; 46 47 private int _index; 48 private int _count; 49 50 53 public void setParent(JspTag parent) 54 { 55 _parent = parent; 56 } 57 58 61 public void setParent(Tag parent) 62 { 63 _parent = parent; 64 } 65 66 69 public Tag getParent() 70 { 71 if (_parent == null || _parent instanceof Tag) 72 return (Tag) _parent; 73 else 74 return new TagAdapter ((SimpleTag ) _parent); 75 } 76 77 80 public void init(int begin, int end, int step) 81 { 82 _begin = begin; 83 _end = end; 84 _step = step; 85 _count = 0; 86 } 87 88 91 public void setCurrent(int current) 92 { 93 _index = current; 94 _count++; 95 } 96 97 100 public Object getCurrent() 101 { 102 return new Integer (_index); 103 } 104 105 108 public LoopTagStatus getLoopStatus() 109 { 110 return this; 111 } 112 113 public int getIndex() 114 { 115 return _index; 116 } 117 118 public int getCount() 119 { 120 return _count; 121 } 122 123 public boolean isFirst() 124 { 125 return _count == 1; 126 } 127 128 public boolean isLast() 129 { 130 return _end < _index + _step; 131 } 132 133 public Integer getBegin() 134 { 135 return new Integer (_begin); 136 } 137 138 public Integer getEnd() 139 { 140 return new Integer (_end); 141 } 142 143 public Integer getStep() 144 { 145 return new Integer (_step); 146 } 147 } 148 | Popular Tags |