001/* 002 * The contents of this file are subject to the terms of the Common Development and 003 * Distribution License (the License). You may not use this file except in compliance with the 004 * License. 005 * 006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the 007 * specific language governing permission and limitations under the License. 008 * 009 * When distributing Covered Software, include this CDDL Header Notice in each file and include 010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL 011 * Header, with the fields enclosed by brackets [] replaced by your own identifying 012 * information: "Portions Copyright [year] [name of copyright owner]". 013 * 014 * Copyright 2006-2010 Sun Microsystems, Inc. 015 * Portions Copyright 2015 ForgeRock AS. 016 */ 017package org.opends.server.replication.plugin; 018 019/** 020 * Enumeration used for storing type of attribute modification 021 * in the value of the replication historical information. 022 * 023 * Example of ds-sync-hist values: 024 * ds-sync-hist: attrName1:changeNumber1:repl:newReplacingValue 025 * ds-sync-hist: attrName1:changeNumber2:del:deletedValue 026 * ds-sync-hist: attrName3:changeNumber3:add:newAddedvalue 027 * ds-sync-hist: attrName3:changeNumber4:attrDel 028 */ 029public enum HistAttrModificationKey 030{ 031 /** The key for attribute value deletion. */ 032 DEL("del"), 033 /** The key for attribute deletion. */ 034 ATTRDEL("attrDel"), 035 /** The key for attribute replace. */ 036 REPL("repl"), 037 /** The key for attribute value addition. */ 038 ADD("add"); 039 040 /** The string representation of this key. */ 041 private String key; 042 043 /** 044 * Creates a new HistKey type with the provided key string. 045 * 046 * @param histkey The key string 047 */ 048 private HistAttrModificationKey(String histkey) 049 { 050 this.key = histkey; 051 } 052 053 /** 054 * Get a key from the String representation. 055 * 056 * @param histkey the String to decode 057 * @return the key from the enum type 058 */ 059 public static HistAttrModificationKey decodeKey(String histkey) 060 { 061 for (HistAttrModificationKey histKey : values()) 062 { 063 if (histKey.toString().equals(histkey)) 064 { 065 return histKey; 066 } 067 } 068 return null; 069 } 070 071 /** 072 * Retrieves the human-readable name for this HistKey. 073 * 074 * @return The human-readable name for this HistKey. 075 */ 076 public String getKey() 077 { 078 return key; 079 } 080 081 /** 082 * Retrieves a string representation of this HistKey. 083 * 084 * @return A string representation of this HistKey. 085 */ 086 @Override 087 public String toString() 088 { 089 return key; 090 } 091}