001/*
002 * CDDL HEADER START
003 *
004 * The contents of this file are subject to the terms of the
005 * Common Development and Distribution License, Version 1.0 only
006 * (the "License").  You may not use this file except in compliance
007 * with the License.
008 *
009 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
010 * or http://forgerock.org/license/CDDLv1.0.html.
011 * See the License for the specific language governing permissions
012 * and limitations under the License.
013 *
014 * When distributing Covered Code, include this CDDL HEADER in each
015 * file and include the License file at legal-notices/CDDLv1_0.txt.
016 * If applicable, add the following below this CDDL HEADER, with the
017 * fields enclosed by brackets "[]" replaced with your own identifying
018 * information:
019 *      Portions Copyright [yyyy] [name of copyright owner]
020 *
021 * CDDL HEADER END
022 *
023 *
024 *      Copyright 2009 Sun Microsystems, Inc.
025 */
026
027package org.forgerock.opendj.ldap.schema;
028
029/**
030 * This enumeration defines the set of possible attribute usage values that may
031 * apply to an attribute type, as defined in RFC 2252.
032 *
033 * @see <a href="http://tools.ietf.org/html/rfc2252">RFC 2252 - Lightweight
034 *      Directory Access Protocol (v3): Attribute Syntax Definitions</a>
035 */
036public enum AttributeUsage {
037    /**
038     * The attribute usage intended for user-defined attribute types.
039     */
040    USER_APPLICATIONS("userApplications", false),
041
042    /**
043     * The attribute usage intended for standard operational attributes.
044     */
045    DIRECTORY_OPERATION("directoryOperation", true),
046
047    /**
048     * The attribute usage intended for non-standard operational attributes
049     * shared among multiple DSAs.
050     */
051    DISTRIBUTED_OPERATION("distributedOperation", true),
052
053    /**
054     * The attribute usage intended for non-standard operational attributes used
055     * by a single DSA.
056     */
057    DSA_OPERATION("dSAOperation", true);
058
059    /** The string representation of this attribute usage. */
060    private final String usageString;
061
062    /**
063     * Flag indicating whether or not the usage should be categorized as
064     * operational.
065     */
066    private final boolean isOperational;
067
068    /**
069     * Creates a new attribute usage with the provided string representation.
070     *
071     * @param usageString
072     *            The string representation of this attribute usage.
073     * @param isOperational
074     *            <code>true</code> if attributes having this attribute usage
075     *            are operational, or <code>false</code> otherwise.
076     */
077    private AttributeUsage(final String usageString, final boolean isOperational) {
078        this.usageString = usageString;
079        this.isOperational = isOperational;
080    }
081
082    /**
083     * Determine whether or not attributes having this attribute usage are
084     * operational.
085     *
086     * @return Returns <code>true</code> if attributes having this attribute
087     *         usage are operational, or <code>false</code> otherwise.
088     */
089    public boolean isOperational() {
090        return isOperational;
091    }
092
093    /**
094     * Retrieves a string representation of this attribute usage.
095     *
096     * @return A string representation of this attribute usage.
097     */
098    @Override
099    public String toString() {
100        return usageString;
101    }
102}