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: ResourceID.java,v 1.2 2008/06/25 05:47:11 qcheng Exp $ 026 * 027 */ 028 029 030package com.sun.identity.liberty.ws.disco; 031 032import org.w3c.dom.Element; 033 034import com.sun.identity.liberty.ws.disco.common.DiscoConstants; 035import com.sun.identity.liberty.ws.disco.common.DiscoUtils; 036import com.sun.identity.shared.xml.XMLUtils; 037 038/** 039 * The class <code>ResourceID</code> represents a discovery service resource ID. 040 * The following schema fragment specifies the expected content within the 041 * <code>ResourceID</code> object. 042 * <pre> 043 * <xs:element name="ResourceID" type="ResourceIDType"/> 044 * <complexType name="ResourceIDType"> 045 * <simpleContent> 046 * <extension base="<http://www.w3.org/2001/XMLSchema>anyURI"> 047 * <attribute name="id" type="{http://www.w3.org/2001/XMLSchema}ID" /> 048 * </extension> 049 * </simpleContent> 050 * </complexType> 051 * </pre> 052 * 053 * @supported.all.api 054 */ 055public class ResourceID { 056 057 private String resourceID = null; 058 private String id = null; 059 060 /** 061 * Constructor. 062 * @param resourceID resource ID string 063 */ 064 public ResourceID(java.lang.String resourceID) { 065 this.resourceID = resourceID; 066 } 067 068 /** 069 * Constructor. 070 * @param elem <code>ResourceID</code> in DOM Element 071 * @exception DiscoveryException if error occurs 072 */ 073 public ResourceID(Element elem) throws DiscoveryException { 074 if (elem == null) { 075 DiscoUtils.debug.message("ResourceID(Element): null input."); 076 throw new DiscoveryException( 077 DiscoUtils.bundle.getString("nullInput")); 078 } 079 String tag = null; 080 String nameSpaceURI = null; 081 if (((tag = elem.getLocalName()) == null) || 082 (!tag.equals("ResourceID")) || 083 ((nameSpaceURI = elem.getNamespaceURI()) == null) || 084 (!nameSpaceURI.equals(DiscoConstants.DISCO_NS))) 085 { 086 DiscoUtils.debug.message("ResourceID(Element): wrong input"); 087 throw new DiscoveryException( 088 DiscoUtils.bundle.getString("wrongInput")); 089 } 090 091 id = elem.getAttribute("id"); 092 resourceID = XMLUtils.getElementValue(elem); 093 if ((resourceID == null) || (resourceID.length() == 0)) { 094 if (DiscoUtils.debug.messageEnabled()) { 095 DiscoUtils.debug.message("ResourceID(Element): missing " 096 + "ResourceID element value."); 097 } 098 throw new DiscoveryException( 099 DiscoUtils.bundle.getString("missingResourceIDValue")); 100 } 101 } 102 103 /** 104 * Gets id attribute. 105 * 106 * @return id attribute. 107 * @see #setId(String) 108 */ 109 public java.lang.String getId() { 110 return id; 111 } 112 113 /** 114 * Sets id attribute. 115 * 116 * @param id id attribute. 117 * @see #getId() 118 */ 119 public void setId(String id) { 120 this.id = id; 121 } 122 123 124 /** 125 * Gets resource id. 126 * @return resource id. 127 * @see #setResourceID(String) 128 */ 129 public String getResourceID() { 130 return resourceID; 131 } 132 133 /** 134 * Sets resource id. 135 * @param resourceID resource id to be set 136 * @see #getResourceID() 137 */ 138 public void setResourceID(String resourceID) { 139 this.resourceID = resourceID; 140 } 141 142 143 /** 144 * Returns string format of object <code>ResourceID</code>. 145 * 146 * @return formatted string. 147 */ 148 public String toString() { 149 StringBuffer sb = new StringBuffer(300); 150 sb.append("<ResourceID xmlns=\"").append(DiscoConstants.DISCO_NS). 151 append("\""); 152 if ((id != null) && id.length() != 0) { 153 sb.append(" id=\"").append(id).append("\""); 154 } 155 sb.append(">"); 156 if (resourceID != null) { 157 sb.append(resourceID); 158 } 159 sb.append("</ResourceID>"); 160 return sb.toString(); 161 } 162}
Copyright © 2010-2017, ForgeRock All Rights Reserved.