001/** 002 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 003 * 004 * Copyright (c) 2005 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: DefaultValues.java,v 1.3 2008/06/25 05:44:03 qcheng Exp $ 026 * 027 */ 028 029package com.sun.identity.sm; 030 031import java.util.Map; 032import java.util.Set; 033import org.w3c.dom.Node; 034 035/** 036 * The abstract class <code>DefaultValues</code> provides a mechanism for 037 * services to obtain their default values dynamically instead of being 038 * statically defined in the service XML file stored in the directory. 039 * <p> 040 * An implementation of this class must be specified in the service 041 * configuration XML file in the definition of the respective attribute schema. 042 * Instead of providing the default values in the XML configuration file, the 043 * class name must be specified within the XML node 044 * <code>DefaultValuesClassName</code>. 045 * 046 * @supported.all.api 047 */ 048public abstract class DefaultValues { 049 050 /** 051 * Abstract method that must be implemented by a class extending this 052 * interface, and should return the default values for the attribute. 053 * 054 * @return defaults values for the attribute as a <code>java.util.Set</code> 055 */ 056 public abstract Set getDefaultValues(); 057 058 /** 059 * Returns a Set of default values for the attribute, given the environment 060 * parameters. The default implementation calls the interface 061 * <code>getDefaultValues()</code> which takes no parameters. The class 062 * extending this class can override this method to take advantage of the 063 * additional environment parameters. 064 * 065 * @return defaults values for the attribute as a <code>java.util.Set</code> 066 */ 067 public Set getDefaultValues(Map envParams) { 068 return (getDefaultValues()); 069 } 070 071 /** 072 * Returns the name of the attribute for which the default values will be 073 * returned. 074 * 075 * @return the name of attribute for which the default values are returned 076 */ 077 public final String getAttributeName() { 078 return (attributeSchema.getName()); 079 } 080 081 /** 082 * Returns the configured key-value pairs for the class in the service's 083 * configuration file 084 * 085 * @return key-value pairs configured for this class in the service schema 086 * XML file 087 */ 088 public final Map getConfiguredKeyValues() { 089 return (keyValues); 090 } 091 092 /** 093 * Returns the XML <code>AttributeSchema</code> node associated with this 094 * attribute 095 * 096 * @return XML node of <code>AttributeSchema</code> 097 */ 098 public final Node getAttributeSchemaNode() { 099 return (parentNode); 100 } 101 102 /** 103 * Set the <code>AttributeSchema</code> for which the default values are 104 * being obtained 105 */ 106 final void setAttributeSchema(AttributeSchemaImpl as) { 107 attributeSchema = as; 108 } 109 110 /** 111 * Sets the key-values pairs configured for this object 112 */ 113 final void setKeyValues(Node node) { 114 keyValues = CreateServiceConfig.getAttributeValuePairs(node); 115 } 116 117 /** 118 * Sets the <code>AttributeSchema</code> node of the XML schema 119 */ 120 final void setParentNode(Node n) { 121 parentNode = n; 122 } 123 124 // Pointer to AttributeSchema, key-value pairs and parent node 125 AttributeSchemaImpl attributeSchema; 126 127 Map keyValues; 128 129 Node parentNode; 130}
Copyright © 2010-2017, ForgeRock All Rights Reserved.