View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.myfaces.view.facelets.tag.jstl.core;
20  
21  import java.io.Serializable;
22  
23  /**
24   * @author Jacob Hookom
25   * @version $Id$
26   */
27  public final class IterationStatus implements Serializable
28  {
29  
30      /**
31       * 
32       */
33      private static final long serialVersionUID = 1L;
34  
35      private final int index;
36  
37      private final boolean first;
38  
39      private final boolean last;
40  
41      private final Integer begin;
42  
43      private final Integer end;
44  
45      private final Integer step;
46      
47      private final Object value;
48      
49      /**
50       * 
51       */
52      public IterationStatus(boolean first, boolean last, int index, Integer begin, Integer end,
53                             Integer step, Object value)
54      {
55          this.index = index;
56          this.begin = begin;
57          this.end = end;
58          this.step = step;
59          this.first = first;
60          this.last = last;
61          this.value = value;
62      }
63  
64      public boolean isFirst()
65      {
66          return this.first;
67      }
68  
69      public boolean isLast()
70      {
71          return this.last;
72      }
73  
74      public Integer getBegin()
75      {
76          return begin;
77      }
78      
79      public Integer getCount()
80      {
81          if ((step == null) || (step == 1))
82          {
83              return (index + 1);
84          }
85          
86          return ((index / step) + 1);
87      }
88      
89      public Object getCurrent()
90      {
91          return value;
92      }
93      
94      public Integer getEnd()
95      {
96          return end;
97      }
98  
99      public int getIndex()
100     {
101         return index;
102     }
103 
104     public Integer getStep()
105     {
106         return step;
107     }
108 
109 }