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 2010 Sun Microsystems, Inc. 025 * Portions copyright 2013 ForgeRock AS. 026 */ 027 028package org.forgerock.opendj.server.core; 029 030import java.util.Set; 031 032/** 033 * Interface declares common functionality for objects, which can store 034 * {@link Attachment}s. 035 */ 036public interface AttachmentHolder { 037 /** 038 * Retrieves the attachment with the specified name. 039 * 040 * @param name 041 * The name for the attachment to retrieve. It will be treated in 042 * a case-sensitive manner. 043 * @return The requested attachment object, or {@code null} if it does not 044 * exist. 045 */ 046 Object getAttachment(String name); 047 048 /** 049 * Retrieves the set of attachment names defined for this holder, as a 050 * mapping between the attachment name and the associated object. 051 * 052 * @return The set of attachments defined for this operation. 053 */ 054 Set<String> getAttachmentNames(); 055 056 /** 057 * Removes the attachment with the specified name. 058 * 059 * @param name 060 * The name for the attachment to remove. It will be treated in a 061 * case-sensitive manner. 062 * @return The attachment that was removed, or {@code null} if it does not 063 * exist. 064 */ 065 Object removeAttachment(String name); 066 067 /** 068 * Sets the value of the specified attachment. If an attachment already 069 * exists with the same name, it will be replaced. Otherwise, a new 070 * attachment will be added. 071 * 072 * @param name 073 * The name to use for the attachment. 074 * @param value 075 * The value to use for the attachment. 076 * @return The former value held by the attachment with the given name, or 077 * {@code null} if there was previously no such attachment. 078 */ 079 Object setAttachment(String name, Object value); 080}