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

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

?? dynabeanmapdecorator.java

?? 這是一個有關common beanutils 的源碼
?? JAVA
字號:
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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.commons.beanutils;

import java.util.Map;
import java.util.List;
import java.util.ArrayList;
import java.util.Set;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Collection;
import java.util.Collections;

/**
 * <p>Decorates a {@link DynaBean} to provide <code>Map</code> behaviour.</p>
 *
 * <p>The motivation for this implementation is to provide access to {@link DynaBean}
 *    properties in technologies that are unaware of BeanUtils and {@link DynaBean}s -
 *    such as the expression languages of JSTL and JSF.</p>
 *
 * <p>This can be achieved either by wrapping the {@link DynaBean} prior to
 *    providing it to the technolody to process or by providing a <code>Map</code>
 *    accessor method on the DynaBean implementation:
 *    <pre><code>
 *         public Map getMap() {
 *             return new DynaBeanMapDecorator(this);
 *         }</code></pre>
 *   </ul>
 * </p>
 *
 * <p>This, for example, could be used in JSTL in the following way to access
 *    a DynaBean's <code>fooProperty</code>:
 *    <ul><li><code>${myDynaBean.<b>map</b>.fooProperty}</code></li></ul>
 * </p>
 *
 * <h3>Usage</h3>
 *
 * <p>To decorate a {@link DynaBean} simply instantiate this class with the
 *    target {@link DynaBean}:</p>
 *
 * <ul><li><code>Map fooMap = new DynaBeanMapDecorator(fooDynaBean);</code></li></ul>
 *
 * <p>The above example creates a <b><i>read only</i></b> <code>Map</code>.
 *    To create  a <code>Map</code> which can be modified, construct a
 *    <code>DynaBeanMapDecorator</code> with the <b><i>read only</i></b>
 *    attribute set to <code>false</code>:</p>
 *
 * <ul><li><code>Map fooMap = new DynaBeanMapDecorator(fooDynaBean, false);</code></li></ul>
 *
 * <h3>Limitations</h3>
 * <p>In this implementation the <code>entrySet()</code>, <code>keySet()</code>
 *    and <code>values()</code> methods create an <b><i>unmodifiable</i></b>
 *    <code>Set</code> and it does not support the Map's <code>clear()</code>
 *    and <code>remove()</code> operations.</p>
 *
 * @since BeanUtils 1.8.0
 * @version $Revision: 546471 $ $Date: 2007-06-12 13:57:20 +0100 (Tue, 12 Jun 2007) $
 */
public class DynaBeanMapDecorator implements Map {

    private DynaBean dynaBean;
    private boolean readOnly;
    private transient Set keySet;

    // ------------------- Constructors ----------------------------------

    /**
     * Constructs a  read only Map for the specified
     * {@link DynaBean}.
     *
     * @param dynaBean The dyna bean being decorated
     * @throws IllegalArgumentException if the {@link DynaBean} is null.
     */
    public DynaBeanMapDecorator(DynaBean dynaBean) {
        this(dynaBean, true);
    }

    /**
     * Construct a Map for the specified {@link DynaBean}.
     *
     * @param dynaBean The dyna bean being decorated
     * @param readOnly <code>true</code> if the Mpa is read only
     * otherwise <code>false</code>
     * @throws IllegalArgumentException if the {@link DynaBean} is null.
     */
    public DynaBeanMapDecorator(DynaBean dynaBean, boolean readOnly) {
        if (dynaBean == null) {
            throw new IllegalArgumentException("DynaBean is null");
        }
        this.dynaBean = dynaBean;
        this.readOnly = readOnly;
    }


    // ------------------- public Methods --------------------------------


    /**
     * Indicate whether the Map is read only.
     *
     * @return <code>true</code> if the Map is read only,
     * otherwise <code>false</code>.
     */
    public boolean isReadOnly() {
        return readOnly;
    }

    // ------------------- java.util.Map Methods -------------------------

    /**
     * clear() operation is not supported.
     *
     * @throws UnsupportedOperationException
     */
    public void clear() {
        throw new UnsupportedOperationException();
    }

    /**
     * Indicate whether the {@link DynaBean} contains a specified
     * value for one (or more) of its properties.
     *
     * @param key The {@link DynaBean}'s property name
     * @return <code>true</code> if one of the {@link DynaBean}'s
     * properties contains a specified value.
     */
    public boolean containsKey(Object key) {
        DynaClass dynaClass = getDynaBean().getDynaClass();
        DynaProperty dynaProperty = dynaClass.getDynaProperty(toString(key));
        return (dynaProperty == null ? false : true);
    }

    /**
     * Indicates whether the decorated {@link DynaBean} contains
     * a specified value.
     *
     * @param value The value to check for.
     * @return <code>true</code> if one of the the {@link DynaBean}'s
     * properties contains the specified value, otherwise
     * <code>false</code>.
     */
    public boolean containsValue(Object value) {
        DynaProperty[] properties = getDynaProperties();
        for (int i = 0; i < properties.length; i++) {
            String key = properties[i].getName();
            Object prop = getDynaBean().get(key);
            if (value == null) {
                if (prop == null) {
                    return true;
                }
            } else {
                if (value.equals(prop)) {
                    return true;
                }
            }
        }
        return false;
    }

    /**
     * <p>Returns the Set of the property/value mappings
     * in the decorated {@link DynaBean}.</p>
     *
     * <p>Each element in the Set is a <code>Map.Entry</code>
     * type.</p>
     *
     * @return An unmodifiable set of the DynaBean
     * property name/value pairs
     */
    public Set entrySet() {
        DynaProperty[] properties = getDynaProperties();
        Set set = new HashSet(properties.length);
        for (int i = 0; i < properties.length; i++) {
            String key = properties[i].getName();
            Object value = getDynaBean().get(key);
            set.add(new MapEntry(key, value));
        }
        return Collections.unmodifiableSet(set);
    }

    /**
     * Return the value for the specified key from
     * the decorated {@link DynaBean}.
     *
     * @param key The {@link DynaBean}'s property name
     * @return The value for the specified property.
     */
    public Object get(Object key) {
        return getDynaBean().get(toString(key));
    }

    /**
     * Indicate whether the decorated {@link DynaBean} has
     * any properties.
     *
     * @return <code>true</code> if the {@link DynaBean} has
     * no properties, otherwise <code>false</code>.
     */
    public boolean isEmpty() {
        return (getDynaProperties().length == 0);
    }

    /**
     * <p>Returns the Set of the property
     * names in the decorated {@link DynaBean}.</p>
     *
     * <p><b>N.B.</b>For {@link DynaBean}s whose associated {@link DynaClass}
     * is a {@link MutableDynaClass} a new Set is created every
     * time, otherwise the Set is created only once and cached.</p>
     *
     * @return An unmodifiable set of the {@link DynaBean}s
     * property names.
     */
    public Set keySet() {
        if (keySet != null) {
            return keySet;
        }

        // Create a Set of the keys
        DynaProperty[] properties = getDynaProperties();
        Set set = new HashSet(properties.length);
        for (int i = 0; i < properties.length; i++) {
            set.add(properties[i].getName());
        }
        set = Collections.unmodifiableSet(set);

        // Cache the keySet if Not a MutableDynaClass
        DynaClass dynaClass = getDynaBean().getDynaClass();
        if (!(dynaClass instanceof MutableDynaClass)) {
            keySet = set;
        }

        return set;

    }

    /**
     * Set the value for the specified property in
     * the decorated {@link DynaBean}.
     *
     * @param key The {@link DynaBean}'s property name
     * @param value The value for the specified property.
     * @return The previous property's value.
     * @throws UnsupportedOperationException if
     * <code>isReadOnly()</code> is true.
     */
    public Object put(Object key, Object value) {
        if (isReadOnly()) {
            throw new UnsupportedOperationException("Map is read only");
        }
        String property = toString(key);
        Object previous = getDynaBean().get(property);
        getDynaBean().set(property, value);
        return previous;
    }

    /**
     * Copy the contents of a Map to the decorated {@link DynaBean}.
     *
     * @param map The Map of values to copy.
     * @throws UnsupportedOperationException if
     * <code>isReadOnly()</code> is true.
     */
    public void putAll(Map map) {
        if (isReadOnly()) {
            throw new UnsupportedOperationException("Map is read only");
        }
        Iterator keys = map.keySet().iterator();
        while (keys.hasNext()) {
            Object key = keys.next();
            put(key, map.get(key));
        }
    }

    /**
     * remove() operation is not supported.
     *
     * @param key The {@link DynaBean}'s property name
     * @return the value removed
     * @throws UnsupportedOperationException
     */
    public Object remove(Object key) {
        throw new UnsupportedOperationException();
    }

    /**
     * Returns the number properties in the decorated
     * {@link DynaBean}.
     * @return The number of properties.
     */
    public int size() {
        return getDynaProperties().length;
    }

    /**
     * Returns the set of property values in the
     * decorated {@link DynaBean}.
     *
     * @return Unmodifiable collection of values.
     */
    public Collection values() {
        DynaProperty[] properties = getDynaProperties();
        List values = new ArrayList(properties.length);
        for (int i = 0; i < properties.length; i++) {
            String key = properties[i].getName();
            Object value = getDynaBean().get(key);
            values.add(value);
        }
        return Collections.unmodifiableList(values);
    }

    // ------------------- protected Methods -----------------------------

    /**
     * Provide access to the underlying {@link DynaBean}
     * this Map decorates.
     *
     * @return the decorated {@link DynaBean}.
     */
    public DynaBean getDynaBean() {
        return dynaBean;
    }

    // ------------------- private Methods -------------------------------

    /**
     * Convenience method to retrieve the {@link DynaProperty}s
     * for this {@link DynaClass}.
     *
     * @return The an array of the {@link DynaProperty}s.
     */
    private DynaProperty[] getDynaProperties() {
        return getDynaBean().getDynaClass().getDynaProperties();
    }

    /**
     * Convenience method to convert an Object
     * to a String.
     *
     * @param obj The Object to convert
     * @return String representation of the object
     */
    private String toString(Object obj) {
        return (obj == null ? null : obj.toString());
    }

    /**
     * Map.Entry implementation.
     */
    private static class MapEntry implements Map.Entry {
        private Object key;
        private Object value;
        MapEntry(Object key, Object value) {
            this.key = key;
            this.value = value;
        }
        public boolean equals(Object o) {
            if (!(o instanceof Map.Entry)) {
                return false;
            }
            Map.Entry e = (Map.Entry)o;
            return ((key.equals(e.getKey())) &&
                    (value == null ? e.getValue() == null
                                   : value.equals(e.getValue())));
        }
        public int hashCode() {
            return key.hashCode() + (value == null ? 0 : value.hashCode());
        }
        public Object getKey() {
            return key;
        }
        public Object getValue() {
            return value;
        }
        public Object setValue(Object value) {
            throw new UnsupportedOperationException();
        }
    }

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩精品福利| 亚洲综合丁香婷婷六月香| 精品久久国产字幕高潮| 欧美日韩夫妻久久| 在线播放欧美女士性生活| 欧美日韩一区二区三区高清| 在线精品视频小说1| 欧美在线短视频| 欧美精选午夜久久久乱码6080| 欧美日韩一卡二卡三卡| 欧美久久久久久久久| 日韩一区二区三区高清免费看看| 欧美精品色一区二区三区| 欧美一区二区三区公司| 日韩亚洲欧美高清| 精品99久久久久久| 欧美经典一区二区| 自拍偷在线精品自拍偷无码专区 | 玉足女爽爽91| 一区二区三区四区五区视频在线观看| 亚洲色图一区二区三区| 亚洲制服丝袜在线| 理论电影国产精品| 成人av网站在线观看免费| 99re亚洲国产精品| 欧美日韩精品一区视频| 日韩欧美在线1卡| 国产日产精品一区| 亚洲蜜桃精久久久久久久| 亚洲v日本v欧美v久久精品| 日本中文字幕一区| 成人听书哪个软件好| 色婷婷精品大视频在线蜜桃视频| 欧美日韩中文国产| 久久精品人人爽人人爽| 一区二区视频在线| 久久精品国产精品亚洲精品| 成人一道本在线| 欧美日韩国产精选| 国产网站一区二区| 一区二区三区在线视频观看58 | 成人av网在线| 欧美性一区二区| 久久综合九色综合97_久久久| 国产精品不卡在线| 日韩中文字幕亚洲一区二区va在线| 黄色成人免费在线| 欧美中文一区二区三区| 欧美精品一区二区三区四区| 亚洲精品高清在线观看| 久久99九九99精品| 欧美亚一区二区| 久久久久久久精| 天堂一区二区在线| 99久久精品国产麻豆演员表| 日韩一区二区精品葵司在线| 自拍偷拍欧美激情| 国内精品写真在线观看| 欧洲视频一区二区| 欧美国产精品中文字幕| 日本欧美一区二区三区| 色94色欧美sute亚洲线路一ni| 欧美videos大乳护士334| 一区二区三区91| 国产91在线看| 日韩欧美色综合网站| 亚洲国产精品久久艾草纯爱| 懂色av一区二区夜夜嗨| 欧美大尺度电影在线| 五月综合激情婷婷六月色窝| eeuss鲁一区二区三区| 欧美精品一区二区三区在线播放| 婷婷开心激情综合| 日本道精品一区二区三区| 国产欧美日产一区| 九色|91porny| 日韩一区二区影院| 日日噜噜夜夜狠狠视频欧美人 | 中文字幕一区二区5566日韩| 老司机午夜精品99久久| 欧美精品少妇一区二区三区 | av不卡免费在线观看| 久久免费看少妇高潮| 青娱乐精品在线视频| 欧美日韩在线不卡| 亚洲香蕉伊在人在线观| 91行情网站电视在线观看高清版| 国产精品高潮呻吟久久| 成人听书哪个软件好| 国产午夜精品一区二区三区四区 | 欧美日韩午夜在线| 亚洲精品成人天堂一二三| 成人国产视频在线观看| 久久女同精品一区二区| 国内精品不卡在线| 欧美精品一区二区在线观看| 国产综合色视频| 欧美精品一区二区久久婷婷| 精品亚洲免费视频| 精品国产污网站| 国产精品一级二级三级| 国产亚洲一二三区| 国产成人高清视频| 中文字幕第一区| 99riav一区二区三区| 亚洲欧美日韩中文播放| 在线日韩国产精品| 亚洲va天堂va国产va久| 欧美日韩亚洲综合一区| 五月婷婷另类国产| 欧美精品在线观看播放| 蜜臀av一区二区在线观看| 精品久久国产字幕高潮| 国产一区二区三区在线观看免费 | 欧美在线你懂得| 亚洲成人手机在线| 91精品久久久久久久久99蜜臂| 日韩av不卡一区二区| 日韩久久久精品| 国产成人综合网| 日韩毛片高清在线播放| 欧美三级电影在线观看| 欧美a级一区二区| 久久久噜噜噜久久人人看| 北条麻妃国产九九精品视频| 亚洲一区二区在线播放相泽| 91精品免费观看| 国产a精品视频| 亚洲一区二区在线播放相泽 | 免费欧美高清视频| 久久久精品免费网站| 99re66热这里只有精品3直播| 亚洲最大成人综合| 91精品黄色片免费大全| 国产成人精品aa毛片| 亚洲一二三区视频在线观看| 欧美一区二区黄| 懂色av一区二区在线播放| 亚洲狠狠爱一区二区三区| 日韩精品一区国产麻豆| 99在线精品视频| 日韩成人一级大片| 国产精品国产自产拍高清av| 欧美日本国产一区| 国产成人激情av| 丝袜诱惑亚洲看片| 欧美国产一区二区在线观看| 欧美日韩国产美女| 成人污污视频在线观看| 三级久久三级久久| 国产精品乱人伦| 欧美一级欧美三级在线观看| av午夜精品一区二区三区| 爽好多水快深点欧美视频| 国产欧美日本一区视频| 欧美日韩国产成人在线免费| 国产精品性做久久久久久| 亚洲一区二区三区在线看| 久久综合色综合88| 欧美午夜电影在线播放| 国产a视频精品免费观看| 日本免费新一区视频| 亚洲人成人一区二区在线观看| 欧美v亚洲v综合ⅴ国产v| 欧美中文字幕一区| 成人av午夜影院| 国产原创一区二区三区| 天天av天天翘天天综合网| 国产精品丝袜黑色高跟| 欧美一区二区性放荡片| 91亚洲精品一区二区乱码| 狠狠色综合播放一区二区| 性久久久久久久久| 亚洲欧美日韩国产手机在线| 久久精品视频一区二区| 欧美一级xxx| 在线精品视频小说1| av动漫一区二区| 国产宾馆实践打屁股91| 韩国av一区二区三区在线观看| 亚洲国产视频网站| 亚洲欧美另类久久久精品| 国产亚洲短视频| 日韩欧美的一区二区| 91精品免费观看| 欧美日韩在线电影| 精品视频一区二区三区免费| 91啦中文在线观看| 国产成人精品免费在线| 国产一本一道久久香蕉| 久久精品国产亚洲aⅴ| 日韩一区精品字幕| 亚洲影院免费观看| 亚洲乱码国产乱码精品精小说| 国产精品伦一区| 中文字幕在线播放不卡一区| 国产清纯白嫩初高生在线观看91 | 成人深夜福利app| 国产传媒日韩欧美成人| 国产呦萝稀缺另类资源|