aoqi@0: /* aoqi@0: * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. Oracle designates this aoqi@0: * particular file as subject to the "Classpath" exception as provided aoqi@0: * by Oracle in the LICENSE file that accompanied this code. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: */ aoqi@0: aoqi@0: package com.sun.xml.internal.ws.api; aoqi@0: aoqi@0: import java.util.Map; aoqi@0: import java.util.Set; aoqi@0: import java.util.Map.Entry; aoqi@0: aoqi@0: /** aoqi@0: * Placeholder for backwards compatibility. aoqi@0: * aoqi@0: * @deprecated Use com.oracle.webservices.internal.api.message.PropertySet instead. aoqi@0: * @author snajper aoqi@0: */ aoqi@0: public abstract class PropertySet extends com.oracle.webservices.internal.api.message.BasePropertySet { aoqi@0: /** aoqi@0: * Represents the list of strongly-typed known properties aoqi@0: * (keyed by property names.) aoqi@0: * aoqi@0: *

aoqi@0: * Just giving it an alias to make the use of this class more fool-proof. aoqi@0: * @deprecated aoqi@0: */ aoqi@0: protected static class PropertyMap extends com.oracle.webservices.internal.api.message.BasePropertySet.PropertyMap {} aoqi@0: aoqi@0: /** aoqi@0: * @deprecated aoqi@0: */ aoqi@0: protected static PropertyMap parse(final Class clazz) { aoqi@0: com.oracle.webservices.internal.api.message.BasePropertySet.PropertyMap pm = com.oracle.webservices.internal.api.message.BasePropertySet.parse(clazz); aoqi@0: PropertyMap map = new PropertyMap(); aoqi@0: map.putAll(pm); aoqi@0: return map; aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Gets the name of the property. aoqi@0: * aoqi@0: * @param key aoqi@0: * This field is typed as {@link Object} to follow the {@link Map#get(Object)} aoqi@0: * convention, but if anything but {@link String} is passed, this method aoqi@0: * just returns null. aoqi@0: */ aoqi@0: public Object get(Object key) { aoqi@0: Accessor sp = getPropertyMap().get(key); aoqi@0: if(sp!=null) aoqi@0: return sp.get(this); aoqi@0: throw new IllegalArgumentException("Undefined property "+key); aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Sets a property. aoqi@0: * aoqi@0: *

Implementation Note

aoqi@0: * This method is slow. Code inside JAX-WS should define strongly-typed aoqi@0: * fields in this class and access them directly, instead of using this. aoqi@0: * aoqi@0: * @throws ReadOnlyPropertyException aoqi@0: * if the given key is an alias of a strongly-typed field, aoqi@0: * and if the name object given is not assignable to the field. aoqi@0: * aoqi@0: * @see Property aoqi@0: */ aoqi@0: public Object put(String key, Object value) { aoqi@0: Accessor sp = getPropertyMap().get(key); aoqi@0: if(sp!=null) { aoqi@0: Object old = sp.get(this); aoqi@0: sp.set(this,value); aoqi@0: return old; aoqi@0: } else { aoqi@0: throw new IllegalArgumentException("Undefined property "+key); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: public boolean supports(Object key) { aoqi@0: return getPropertyMap().containsKey(key); aoqi@0: } aoqi@0: aoqi@0: public Object remove(Object key) { aoqi@0: Accessor sp = getPropertyMap().get(key); aoqi@0: if(sp!=null) { aoqi@0: Object old = sp.get(this); aoqi@0: sp.set(this,null); aoqi@0: return old; aoqi@0: } else { aoqi@0: throw new IllegalArgumentException("Undefined property "+key); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: protected void createEntrySet(Set> core) { aoqi@0: for (final Entry e : getPropertyMap().entrySet()) { aoqi@0: core.add(new Entry() { aoqi@0: public String getKey() { aoqi@0: return e.getKey(); aoqi@0: } aoqi@0: aoqi@0: public Object getValue() { aoqi@0: return e.getValue().get(PropertySet.this); aoqi@0: } aoqi@0: aoqi@0: public Object setValue(Object value) { aoqi@0: Accessor acc = e.getValue(); aoqi@0: Object old = acc.get(PropertySet.this); aoqi@0: acc.set(PropertySet.this,value); aoqi@0: return old; aoqi@0: } aoqi@0: }); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: protected abstract PropertyMap getPropertyMap(); aoqi@0: }