📄 mapattribute.java
字号:
/* * Copyright (c) 2005, John Mettraux, OpenWFE.org * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * . Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * . Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * . Neither the name of the "OpenWFE" nor the names of its contributors may be * used to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * $Id: MapAttribute.java,v 1.5 2005/07/19 07:30:28 jmettraux Exp $ *///// MapAttribute.java//// john.mettraux@openwfe.org//// generated with // jtmpl 1.0.04 31.10.2002 John Mettraux (jmettraux@openwfe.org)//package openwfe.org.engine.workitem;/** * A dictionary of attributes * * <p><font size=2>CVS Info : * <br>$Author: jmettraux $ * <br>$Date: 2005/07/19 07:30:28 $ * <br>$Id: MapAttribute.java,v 1.5 2005/07/19 07:30:28 jmettraux Exp $ </font> * * @author john.mettraux@openwfe.org */public class MapAttribute extends CollectionAttribute{ // // FIELDS private java.util.Map map = new java.util.HashMap(); // // CONSTRUCTORS public MapAttribute () { } public MapAttribute (int initialCapacity) { this.map = new java.util.HashMap(initialCapacity); } // // BEAN METHODS public java.util.Map getMap () { return this.map; } public void setMap (java.util.Map m) { this.map = m; } // // METHODS public java.util.Set keySet () { return this.map.keySet(); } public java.util.Collection values () { return this.map.values(); } public java.util.Set entrySet () { return this.map.entrySet(); } public Attribute get (Attribute key) { return (Attribute)this.map.get(key); } public void put (Attribute key, Attribute value) { this.map.put(key, value); } public void remove (Attribute key) { this.map.remove(key); } public int size () { return this.map.size(); } public int hashCode () { return this.map.hashCode(); } public Object clone () { MapAttribute clone = new MapAttribute(this.size()); java.util.Iterator it = this.map.keySet().iterator(); while (it.hasNext()) { Attribute key = (Attribute)it.next(); Attribute value = this.get(key); clone.put((Attribute)key.clone(), (Attribute)value.clone()); } return clone; } /** * Adds the content of a given map attribute to this map attribute. */ public void putAll (final MapAttribute ma) { this.map.putAll(ma.getMap()); } // // STATIC METHODS /* * * This method 'flattens' and sorts a MapAttribute content * so that crypto signature and verification can succeed. * / public static java.util.List neutralizeMap (MapAttribute map) { if (map == null) return null; java.util.List result = new java.util.ArrayList(map.keySet().size()); java.util.Iterator it = map.entrySet().iterator(); while (it.hasNext()) { java.util.Map.Entry entry = (java.util.Map.Entry)it.next(); String key = entry.getKey().toString(); Object val = entry.getValue(); if (val instanceof MapAttribute) { val = neutralizeMap((MapAttribute)val); } else { // don't touch } Object oEntry = new Object [] { key, val }; result.add(oEntry); } java.util.Collections.sort(result, new java.util.Comparator () { public int compare (Object o1, Object o2) { String o1Key = (String)((Object[])o1)[0]; String o2Key = (String)((Object[])o2)[0]; return o1Key.compareTo(o2Key); } }); return result; } */}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -