aoqi@0: /*
aoqi@0: * Copyright (c) 1997, 2010, 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.policy;
aoqi@0:
aoqi@0: import com.sun.xml.internal.ws.policy.privateutil.LocalizationMessages;
aoqi@0: import com.sun.xml.internal.ws.policy.privateutil.PolicyLogger;
aoqi@0:
aoqi@0: import javax.xml.namespace.QName;
aoqi@0:
aoqi@0: /**
aoqi@0: * This class provides implementation of PolicyMapKey interface to be used in connection with {@link PolicyMap}.
aoqi@0: * Instances of the class are created by a call to one of {@link PolicyMap} createWsdl
aoqi@0: * methods.
aoqi@0: *
get...
call on {@link PolicyMap}, before the actual scope map search is performed.
aoqi@0: *
aoqi@0: *
aoqi@0: * @author Marek Potociar (marek.potociar at sun.com)
aoqi@0: * @author Fabian Ritzmann
aoqi@0: */
aoqi@0: final public class PolicyMapKey {
aoqi@0: private static final PolicyLogger LOGGER = PolicyLogger.getLogger(PolicyMapKey.class);
aoqi@0:
aoqi@0: private final QName service;
aoqi@0: private final QName port;
aoqi@0: private final QName operation;
aoqi@0: private final QName faultMessage;
aoqi@0:
aoqi@0: private PolicyMapKeyHandler handler;
aoqi@0:
aoqi@0: PolicyMapKey(final QName service, final QName port, final QName operation, final PolicyMapKeyHandler handler) {
aoqi@0: this(service, port, operation, null, handler);
aoqi@0: }
aoqi@0:
aoqi@0: PolicyMapKey(final QName service, final QName port, final QName operation, final QName faultMessage, final PolicyMapKeyHandler handler) {
aoqi@0: if (handler == null) {
aoqi@0: throw LOGGER.logSevereException(new IllegalArgumentException(LocalizationMessages.WSP_0046_POLICY_MAP_KEY_HANDLER_NOT_SET()));
aoqi@0: }
aoqi@0:
aoqi@0: this.service = service;
aoqi@0: this.port = port;
aoqi@0: this.operation = operation;
aoqi@0: this.faultMessage = faultMessage;
aoqi@0: this.handler = handler;
aoqi@0: }
aoqi@0:
aoqi@0: PolicyMapKey(final PolicyMapKey that) {
aoqi@0: this.service = that.service;
aoqi@0: this.port = that.port;
aoqi@0: this.operation = that.operation;
aoqi@0: this.faultMessage = that.faultMessage;
aoqi@0: this.handler = that.handler;
aoqi@0: }
aoqi@0:
aoqi@0: public QName getOperation() {
aoqi@0: return operation;
aoqi@0: }
aoqi@0:
aoqi@0: public QName getPort() {
aoqi@0: return port;
aoqi@0: }
aoqi@0:
aoqi@0: public QName getService() {
aoqi@0: return service;
aoqi@0: }
aoqi@0:
aoqi@0: void setHandler(PolicyMapKeyHandler handler) {
aoqi@0: if (handler == null) {
aoqi@0: throw LOGGER.logSevereException(new IllegalArgumentException(LocalizationMessages.WSP_0046_POLICY_MAP_KEY_HANDLER_NOT_SET()));
aoqi@0: }
aoqi@0:
aoqi@0: this.handler = handler;
aoqi@0: }
aoqi@0:
aoqi@0: public QName getFaultMessage() {
aoqi@0: return faultMessage;
aoqi@0: }
aoqi@0:
aoqi@0: @Override
aoqi@0: public boolean equals(final Object that) {
aoqi@0: if (this == that) {
aoqi@0: return true; // we are lucky here => no special handling is required
aoqi@0: }
aoqi@0:
aoqi@0: if (that == null) {
aoqi@0: return false;
aoqi@0: }
aoqi@0:
aoqi@0: if (that instanceof PolicyMapKey) {
aoqi@0: return handler.areEqual(this, (PolicyMapKey) that);
aoqi@0: } else {
aoqi@0: return false;
aoqi@0: }
aoqi@0: }
aoqi@0:
aoqi@0: @Override
aoqi@0: public int hashCode() {
aoqi@0: return handler.generateHashCode(this);
aoqi@0: }
aoqi@0:
aoqi@0: @Override
aoqi@0: public String toString() {
aoqi@0: final StringBuffer result = new StringBuffer("PolicyMapKey(");
aoqi@0: result.append(this.service).append(", ").append(port).append(", ").append(operation).append(", ").append(faultMessage);
aoqi@0: return result.append(")").toString();
aoqi@0: }
aoqi@0: }