src/share/jaxws_classes/com/sun/xml/internal/ws/api/PropertySet.java

changeset 0
373ffda63c9a
child 637
9c07ef4934dd
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/api/PropertySet.java	Wed Apr 27 01:27:09 2016 +0800
     1.3 @@ -0,0 +1,135 @@
     1.4 +/*
     1.5 + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.  Oracle designates this
    1.11 + * particular file as subject to the "Classpath" exception as provided
    1.12 + * by Oracle in the LICENSE file that accompanied this code.
    1.13 + *
    1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.17 + * version 2 for more details (a copy is included in the LICENSE file that
    1.18 + * accompanied this code).
    1.19 + *
    1.20 + * You should have received a copy of the GNU General Public License version
    1.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.23 + *
    1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.25 + * or visit www.oracle.com if you need additional information or have any
    1.26 + * questions.
    1.27 + */
    1.28 +
    1.29 +package com.sun.xml.internal.ws.api;
    1.30 +
    1.31 +import java.util.Map;
    1.32 +import java.util.Set;
    1.33 +import java.util.Map.Entry;
    1.34 +
    1.35 +/**
    1.36 + * Placeholder for backwards compatibility.
    1.37 + *
    1.38 + * @deprecated Use com.oracle.webservices.internal.api.message.PropertySet instead.
    1.39 + * @author snajper
    1.40 + */
    1.41 +public abstract class PropertySet extends com.oracle.webservices.internal.api.message.BasePropertySet {
    1.42 +    /**
    1.43 +     * Represents the list of strongly-typed known properties
    1.44 +     * (keyed by property names.)
    1.45 +     *
    1.46 +     * <p>
    1.47 +     * Just giving it an alias to make the use of this class more fool-proof.
    1.48 +     * @deprecated
    1.49 +     */
    1.50 +    protected static class PropertyMap extends com.oracle.webservices.internal.api.message.BasePropertySet.PropertyMap {}
    1.51 +
    1.52 +    /**
    1.53 +     * @deprecated
    1.54 +     */
    1.55 +    protected static PropertyMap parse(final Class clazz) {
    1.56 +        com.oracle.webservices.internal.api.message.BasePropertySet.PropertyMap pm = com.oracle.webservices.internal.api.message.BasePropertySet.parse(clazz);
    1.57 +        PropertyMap map = new PropertyMap();
    1.58 +        map.putAll(pm);
    1.59 +        return map;
    1.60 +    }
    1.61 +
    1.62 +    /**
    1.63 +     * Gets the name of the property.
    1.64 +     *
    1.65 +     * @param key
    1.66 +     *      This field is typed as {@link Object} to follow the {@link Map#get(Object)}
    1.67 +     *      convention, but if anything but {@link String} is passed, this method
    1.68 +     *      just returns null.
    1.69 +     */
    1.70 +    public Object get(Object key) {
    1.71 +        Accessor sp = getPropertyMap().get(key);
    1.72 +        if(sp!=null)
    1.73 +            return sp.get(this);
    1.74 +        throw new IllegalArgumentException("Undefined property "+key);
    1.75 +    }
    1.76 +
    1.77 +    /**
    1.78 +     * Sets a property.
    1.79 +     *
    1.80 +     * <h3>Implementation Note</h3>
    1.81 +     * This method is slow. Code inside JAX-WS should define strongly-typed
    1.82 +     * fields in this class and access them directly, instead of using this.
    1.83 +     *
    1.84 +     * @throws ReadOnlyPropertyException
    1.85 +     *      if the given key is an alias of a strongly-typed field,
    1.86 +     *      and if the name object given is not assignable to the field.
    1.87 +     *
    1.88 +     * @see Property
    1.89 +     */
    1.90 +    public Object put(String key, Object value) {
    1.91 +        Accessor sp = getPropertyMap().get(key);
    1.92 +        if(sp!=null) {
    1.93 +            Object old = sp.get(this);
    1.94 +            sp.set(this,value);
    1.95 +            return old;
    1.96 +        } else {
    1.97 +            throw new IllegalArgumentException("Undefined property "+key);
    1.98 +        }
    1.99 +    }
   1.100 +
   1.101 +    public boolean supports(Object key) {
   1.102 +        return getPropertyMap().containsKey(key);
   1.103 +    }
   1.104 +
   1.105 +    public Object remove(Object key) {
   1.106 +        Accessor sp = getPropertyMap().get(key);
   1.107 +        if(sp!=null) {
   1.108 +            Object old = sp.get(this);
   1.109 +            sp.set(this,null);
   1.110 +            return old;
   1.111 +        } else {
   1.112 +            throw new IllegalArgumentException("Undefined property "+key);
   1.113 +        }
   1.114 +    }
   1.115 +
   1.116 +    protected void createEntrySet(Set<Entry<String,Object>> core) {
   1.117 +        for (final Entry<String, Accessor> e : getPropertyMap().entrySet()) {
   1.118 +            core.add(new Entry<String, Object>() {
   1.119 +                public String getKey() {
   1.120 +                    return e.getKey();
   1.121 +                }
   1.122 +
   1.123 +                public Object getValue() {
   1.124 +                    return e.getValue().get(PropertySet.this);
   1.125 +                }
   1.126 +
   1.127 +                public Object setValue(Object value) {
   1.128 +                    Accessor acc = e.getValue();
   1.129 +                    Object old = acc.get(PropertySet.this);
   1.130 +                    acc.set(PropertySet.this,value);
   1.131 +                    return old;
   1.132 +                }
   1.133 +            });
   1.134 +        }
   1.135 +    }
   1.136 +
   1.137 +    protected abstract PropertyMap getPropertyMap();
   1.138 +}

mercurial