001/** 002 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 003 * 004 * Copyright (c) 2006 Sun Microsystems Inc. All Rights Reserved 005 * 006 * The contents of this file are subject to the terms 007 * of the Common Development and Distribution License 008 * (the License). You may not use this file except in 009 * compliance with the License. 010 * 011 * You can obtain a copy of the License at 012 * https://opensso.dev.java.net/public/CDDLv1.0.html or 013 * opensso/legal/CDDLv1.0.txt 014 * See the License for the specific language governing 015 * permission and limitations under the License. 016 * 017 * When distributing Covered Code, include this CDDL 018 * Header Notice in each file and include the License file 019 * at opensso/legal/CDDLv1.0.txt. 020 * If applicable, add the following below the CDDL Header, 021 * with the fields enclosed by brackets [] replaced by 022 * your own identifying information: 023 * "Portions Copyrighted [year] [name of copyright owner]" 024 * 025 * $Id: ResourceMatch.java,v 1.2 2008/06/25 05:43:45 qcheng Exp $ 026 * 027 */ 028 029 030package com.sun.identity.policy; 031 032/** 033 * The class <code>ResourceMatch</code> defines the results 034 * of a resource match with respect to Policy. 035 * 036 * @supported.all.api 037 */ 038public class ResourceMatch extends Object { 039 040 private String resourceMatch; 041 042 /** 043 * The <code>EXACT_MATCH</code> specifies 044 * the resources are exactly the same. 045 */ 046 public static final ResourceMatch 047 EXACT_MATCH = new ResourceMatch("exact_match"); 048 049 /** 050 * The <code>WILDCARD_MATCH</code> specifies 051 * the resources are wildcard match 052 */ 053 public static final ResourceMatch 054 WILDCARD_MATCH = new ResourceMatch("wildcard_match"); 055 056 /** 057 * The <code>SUB_RESOURCE_MATCH</code> specifies 058 * the provided resource is a sub resource. 059 */ 060 public static final ResourceMatch 061 SUB_RESOURCE_MATCH = new ResourceMatch("sub_resource_match"); 062 063 /** 064 * The <code>SUPER_RESOURCE_MATCH</code> specifies 065 * the provided resource is more specific than 066 * this resource 067 */ 068 public static final ResourceMatch 069 SUPER_RESOURCE_MATCH = new ResourceMatch("super_resource_match"); 070 071 /** 072 * The <code>NO_MATCH</code> specifies 073 * the resources do not match 074 */ 075 public static final ResourceMatch 076 NO_MATCH = new ResourceMatch("no_match"); 077 078 private ResourceMatch() { 079 // do nothing 080 } 081 082 private ResourceMatch(String matchType) { 083 resourceMatch = matchType; 084 } 085 086 /** 087 * Method to get string representation of the resource match. 088 * 089 * @return string representation of the resource match. 090 */ 091 public String toString() { 092 return (resourceMatch); 093 } 094 095 /** 096 * Method to check if two resource match objects are equal. 097 * 098 * @param resourceMatch object to which this object will be 099 * compared with 100 * 101 * @return <code>true</code> if the resources match; 102 * <code>false</code> otherwise; 103 */ 104 public boolean equals(Object resourceMatch) { 105 if (resourceMatch instanceof ResourceMatch) { 106 ResourceMatch rm = (ResourceMatch) resourceMatch; 107 return (rm.resourceMatch.equals(this.resourceMatch)); 108 } 109 return (false); 110 } 111}