亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? iteratetag.java

?? struts的源代碼
?? JAVA
字號:
/*
 * $Id: IterateTag.java 56513 2004-11-03 19:20:47Z niallp $ 
 *
 * Copyright 1999-2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.struts.taglib.logic;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.Map;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyTagSupport;

import org.apache.struts.util.IteratorAdapter;
import org.apache.struts.taglib.TagUtils;
import org.apache.struts.util.MessageResources;

/**
 * Custom tag that iterates the elements of a collection, which can be
 * either an attribute or the property of an attribute.  The collection
 * can be any of the following:  an array of objects, an Enumeration,
 * an Iterator, a Collection (which includes Lists, Sets and Vectors),
 * or a Map (which includes Hashtables) whose elements will be iterated over.
 *
 * @version $Rev: 56513 $ $Date: 2004-11-03 19:20:47 +0000 (Wed, 03 Nov 2004) $
 */

public class IterateTag extends BodyTagSupport {

    // ----------------------------------------------------- Instance Variables

    /**
     * Iterator of the elements of this collection, while we are actually
     * running.
     */
    protected Iterator iterator = null;

    /**
     * The number of elements we have already rendered.
     */
    protected int lengthCount = 0;

    /**
     * The actual length value (calculated in the start tag).
     */
    protected int lengthValue = 0;

    /**
     * The message resources for this package.
     */
    protected static MessageResources messages =
        MessageResources.getMessageResources("org.apache.struts.taglib.logic.LocalStrings");

    /**
     * The actual offset value (calculated in the start tag).
     */
    protected int offsetValue = 0;

    /**
     * Has this tag instance been started?
     */
    protected boolean started = false;

    // ------------------------------------------------------------- Properties

    /**
     * The collection over which we will be iterating.
     */
    protected Object collection = null;

    public Object getCollection() {
        return (this.collection);
    }

    public void setCollection(Object collection) {
        this.collection = collection;
    }

    /**
     * The name of the scripting variable to be exposed.
     */
    protected String id = null;

    public String getId() {
        return (this.id);
    }

    public void setId(String id) {
        this.id = id;
    }

    /**
     * <p>Return the zero-relative index of the current iteration through the
     * loop.  If you specify an <code>offset</code>, the first iteration
     * through the loop will have that value; otherwise, the first iteration
     * will return zero.</p>
     *
     * <p>This property is read-only, and gives nested custom tags access to
     * this information.  Therefore, it is <strong>only</strong> valid in
     * between calls to <code>doStartTag()</code> and <code>doEndTag()</code>.
     * </p>
     */
    public int getIndex() {
        if (started)
            return (offsetValue + lengthCount - 1);
        else
            return (0);
    }

    /**
     * The name of the scripting variable to be exposed as the current index.
     */
    protected String indexId = null;

    public String getIndexId() {
        return (this.indexId);
    }

    public void setIndexId(String indexId) {
        this.indexId = indexId;
    }

    /**
     * The length value or attribute name (<=0 means no limit).
     */
    protected String length = null;

    public String getLength() {
        return (this.length);
    }

    public void setLength(String length) {
        this.length = length;
    }

    /**
     * The name of the collection or owning bean.
     */
    protected String name = null;

    public String getName() {
        return (this.name);
    }

    public void setName(String name) {
        this.name = name;
    }

    /**
     * The starting offset (zero relative).
     */
    protected String offset = null;

    public String getOffset() {
        return (this.offset);
    }

    public void setOffset(String offset) {
        this.offset = offset;
    }

    /**
     * The property name containing the collection.
     */
    protected String property = null;

    public String getProperty() {
        return (this.property);
    }

    public void setProperty(String property) {
        this.property = property;
    }

    /**
     * The scope of the bean specified by the name property, if any.
     */
    protected String scope = null;

    public String getScope() {
        return (this.scope);
    }

    public void setScope(String scope) {
        this.scope = scope;
    }

    /**
     * The Java class of each exposed element of the collection.
     */
    protected String type = null;

    public String getType() {
        return (this.type);
    }

    public void setType(String type) {
        this.type = type;
    }

    // --------------------------------------------------------- Public Methods

    /**
     * Construct an iterator for the specified collection, and begin
     * looping through the body once per element.
     *
     * @exception JspException if a JSP exception has occurred
     */
    public int doStartTag() throws JspException {

        // Acquire the collection we are going to iterate over
        Object collection = this.collection;
        if (collection == null) {
            collection = TagUtils.getInstance().lookup(pageContext, name, property, scope);
        }

        if (collection == null) {
            JspException e = new JspException(messages.getMessage("iterate.collection"));
            TagUtils.getInstance().saveException(pageContext, e);
            throw e;
        }

        // Construct an iterator for this collection
        if (collection.getClass().isArray()) {
            try {
                // If we're lucky, it is an array of objects
                // that we can iterate over with no copying
                iterator = Arrays.asList((Object[]) collection).iterator();
            } catch (ClassCastException e) {
                // Rats -- it is an array of primitives
                int length = Array.getLength(collection);
                ArrayList c = new ArrayList(length);
                for (int i = 0; i < length; i++) {
                    c.add(Array.get(collection, i));
                }
                iterator = c.iterator();
            }
        } else if (collection instanceof Collection) {
            iterator = ((Collection) collection).iterator();
        } else if (collection instanceof Iterator) {
            iterator = (Iterator) collection;
        } else if (collection instanceof Map) {
            iterator = ((Map) collection).entrySet().iterator();
        } else if (collection instanceof Enumeration) {
            iterator = new IteratorAdapter((Enumeration) collection);
        } else {
            JspException e = new JspException(messages.getMessage("iterate.iterator"));
            TagUtils.getInstance().saveException(pageContext, e);
            throw e;
        }

        // Calculate the starting offset
        if (offset == null) {
            offsetValue = 0;
        } else {
            try {
                offsetValue = Integer.parseInt(offset);
            } catch (NumberFormatException e) {
                Integer offsetObject = (Integer) TagUtils.getInstance().lookup(pageContext, offset, null);
                if (offsetObject == null) {
                    offsetValue = 0;
                } else {
                    offsetValue = offsetObject.intValue();
                }
            }
        }
        if (offsetValue < 0) {
            offsetValue = 0;
        }

        // Calculate the rendering length
        if (length == null) {
            lengthValue = 0;
        } else {
            try {
                lengthValue = Integer.parseInt(length);
            } catch (NumberFormatException e) {
                Integer lengthObject = (Integer) TagUtils.getInstance().lookup(pageContext, length, null);
                if (lengthObject == null) {
                    lengthValue = 0;
                } else {
                    lengthValue = lengthObject.intValue();
                }
            }
        }
        if (lengthValue < 0) {
            lengthValue = 0;
        }
        lengthCount = 0;

        // Skip the leading elements up to the starting offset
        for (int i = 0; i < offsetValue; i++) {
            if (iterator.hasNext()) {
                iterator.next();
            }
        }

        // Store the first value and evaluate, or skip the body if none
        if (iterator.hasNext()) {
            Object element = iterator.next();
            if (element == null) {
                pageContext.removeAttribute(id);
            } else {
                pageContext.setAttribute(id, element);
            }
            lengthCount++;
            started = true;
            if (indexId != null) {
                pageContext.setAttribute(indexId, new Integer(getIndex()));
            }
            return (EVAL_BODY_TAG);
        } else {
            return (SKIP_BODY);
        }

    }

    /**
     * Make the next collection element available and loop, or
     * finish the iterations if there are no more elements.
     *
     * @exception JspException if a JSP exception has occurred
     */
    public int doAfterBody() throws JspException {

        // Render the output from this iteration to the output stream
        if (bodyContent != null) {
            TagUtils.getInstance().writePrevious(pageContext, bodyContent.getString());
            bodyContent.clearBody();
        }

        // Decide whether to iterate or quit
        if ((lengthValue > 0) && (lengthCount >= lengthValue)) {
            return (SKIP_BODY);
        }

        if (iterator.hasNext()) {
            Object element = iterator.next();
            if (element == null) {
                pageContext.removeAttribute(id);
            } else {
                pageContext.setAttribute(id, element);
            }
            lengthCount++;
            if (indexId != null) {
                pageContext.setAttribute(indexId, new Integer(getIndex()));
            }
            return (EVAL_BODY_TAG);
        } else {
            return (SKIP_BODY);
        }

    }

    /**
     * Clean up after processing this enumeration.
     *
     * @exception JspException if a JSP exception has occurred
     */
    public int doEndTag() throws JspException {

        // Clean up our started state
        started = false;
        iterator = null;

        // Continue processing this page
        return (EVAL_PAGE);

    }

    /**
     * Release all allocated resources.
     */
    public void release() {

        super.release();

        iterator = null;
        lengthCount = 0;
        lengthValue = 0;
        offsetValue = 0;

        id = null;
        collection = null;
        length = null;
        name = null;
        offset = null;
        property = null;
        scope = null;
        started = false;

    }

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产无一区二区| 亚洲少妇30p| 91成人国产精品| 久久99蜜桃精品| 一区二区三区国产| 国产亚洲一区二区在线观看| 欧美人牲a欧美精品| a级高清视频欧美日韩| 久久99热这里只有精品| 亚洲午夜激情网站| 综合亚洲深深色噜噜狠狠网站| 精品久久久久久综合日本欧美| 欧美视频一区二区三区| 99这里只有精品| 国产成人av一区二区三区在线| 石原莉奈在线亚洲二区| 亚洲综合在线第一页| 成人免费在线视频| 国产精品天美传媒沈樵| 亚洲精品一区二区精华| 欧美一卡二卡在线观看| 在线观看91视频| 91在线视频免费观看| 岛国一区二区三区| 国产激情视频一区二区三区欧美 | 樱桃国产成人精品视频| 国产色综合一区| 久久亚洲免费视频| www国产精品av| 欧美mv日韩mv国产| 欧美videos大乳护士334| 欧美一级一区二区| 制服丝袜亚洲播放| 制服视频三区第一页精品| 欧美日韩视频在线观看一区二区三区| 91美女在线视频| 97久久精品人人做人人爽| 91在线视频在线| 色哦色哦哦色天天综合| 在线视频综合导航| 欧美性猛片aaaaaaa做受| 91网站在线播放| 91麻豆swag| 91国偷自产一区二区使用方法| 色88888久久久久久影院按摩 | yourporn久久国产精品| 成人av在线电影| av亚洲精华国产精华| 成人性色生活片免费看爆迷你毛片| 国产成人丝袜美腿| av一区二区三区四区| 成人的网站免费观看| av电影天堂一区二区在线观看| 9色porny自拍视频一区二区| 99综合影院在线| 欧美在线free| 欧美精品黑人性xxxx| 欧美日韩精品一区二区天天拍小说 | 欧美视频中文字幕| 欧美高清视频一二三区| 日韩你懂的在线观看| 国产亚洲欧美日韩在线一区| 国产精品国产精品国产专区不蜜 | 亚洲色欲色欲www| 亚洲一区二区成人在线观看| 欧美aaa在线| 粗大黑人巨茎大战欧美成人| 日本高清视频一区二区| 日韩欧美精品三级| 国产精品视频yy9299一区| 一区二区三区色| 日韩高清在线观看| 国产精品白丝av| 色综合一区二区| 欧美一区二区三区婷婷月色| 国产丝袜在线精品| 亚洲国产一区二区三区青草影视| 琪琪一区二区三区| av电影一区二区| 日韩午夜三级在线| 国产精品初高中害羞小美女文| 亚洲在线视频免费观看| 国内精品第一页| 在线一区二区观看| 亚洲精品一区二区三区四区高清 | 久久网站最新地址| 亚洲人成伊人成综合网小说| 蜜臀av性久久久久蜜臀av麻豆| 国产一区二区在线观看视频| 色综合欧美在线| www国产成人| 亚洲电影在线免费观看| 风间由美一区二区三区在线观看 | 欧美日韩成人综合在线一区二区| 久久日韩精品一区二区五区| 一区二区三区鲁丝不卡| 国产精品正在播放| 91精品国产麻豆| 亚洲人成网站色在线观看| 极品少妇一区二区| 欧美三级日韩三级国产三级| 中文字幕中文字幕在线一区 | 免费黄网站欧美| 日本精品裸体写真集在线观看| 久久网站最新地址| 免费看欧美美女黄的网站| 欧美综合久久久| 国产精品的网站| 国产成人av电影| 精品国产伦一区二区三区观看体验| 亚洲免费av网站| www.欧美色图| 中文字幕精品在线不卡| 国产一区二区h| 精品国产第一区二区三区观看体验| 一区二区三区高清在线| av一区二区三区在线| 国产精品热久久久久夜色精品三区 | 亚洲国产精品二十页| 精品一区二区三区免费观看| 欧美一卡二卡在线观看| 三级一区在线视频先锋| 欧美欧美午夜aⅴ在线观看| 亚洲最大色网站| 色婷婷亚洲综合| 一区二区三区免费观看| 色先锋久久av资源部| 亚洲欧美在线视频| 99久久精品免费看国产| 国产精品久久久久久久蜜臀 | 美脚の诱脚舐め脚责91| 欧美一区二区三区四区视频| 水野朝阳av一区二区三区| 欧美日韩国产一区二区三区地区| 亚洲精品视频免费看| hitomi一区二区三区精品| 国产女人18毛片水真多成人如厕 | 久久不见久久见免费视频7| 欧美一二三区在线观看| 日本不卡视频在线| 日韩精品一区二区在线| 激情综合五月天| 久久精品人人做人人综合| 国产呦精品一区二区三区网站| 精品国产乱码91久久久久久网站| 国内精品伊人久久久久av一坑| 久久久亚洲午夜电影| 成人黄色电影在线| 亚洲欧美经典视频| 欧美日韩一区二区不卡| 日韩电影免费在线看| 日韩一区二区三区电影| 国产一区二区三区电影在线观看| 中文字幕不卡在线播放| 97aⅴ精品视频一二三区| 亚洲日本va在线观看| 欧美性欧美巨大黑白大战| 日韩精品三区四区| 久久五月婷婷丁香社区| 99综合影院在线| 亚洲1区2区3区4区| 欧美不卡视频一区| 成人小视频免费观看| 亚洲午夜av在线| 精品成人佐山爱一区二区| 成人精品亚洲人成在线| 亚洲综合激情网| 日韩欧美精品在线视频| av影院午夜一区| 日韩中文字幕一区二区三区| 国产精品欧美久久久久一区二区| 91在线小视频| 美美哒免费高清在线观看视频一区二区 | 国模娜娜一区二区三区| ...av二区三区久久精品| 欧美妇女性影城| 国产成人8x视频一区二区 | 不卡av在线网| 午夜精彩视频在线观看不卡| 久久欧美一区二区| 日本道色综合久久| 国产一区二区不卡在线| 亚洲国产精品精华液网站| 国产亚洲一二三区| 欧美丰满高潮xxxx喷水动漫| 国产很黄免费观看久久| 偷拍日韩校园综合在线| 国产精品免费aⅴ片在线观看| 51午夜精品国产| 色综合视频在线观看| 精品一区二区久久| 一区二区三区四区av| 久久美女艺术照精彩视频福利播放| 欧美日韩亚洲综合在线 | 午夜精品福利一区二区三区蜜桃| 国产三级一区二区| 日韩欧美色综合网站| 日本道在线观看一区二区| 国产91精品精华液一区二区三区 | 三级一区在线视频先锋 |