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 2006-2010 Sun Microsystems, Inc. 025 * Portions Copyright 2015 ForgeRock AS. 026 */ 027package org.opends.server.replication.plugin; 028 029/** 030 * Enumeration used for storing type of attribute modification 031 * in the value of the replication historical information. 032 * 033 * Example of ds-sync-hist values: 034 * ds-sync-hist: attrName1:changeNumber1:repl:newReplacingValue 035 * ds-sync-hist: attrName1:changeNumber2:del:deletedValue 036 * ds-sync-hist: attrName3:changeNumber3:add:newAddedvalue 037 * ds-sync-hist: attrName3:changeNumber4:attrDel 038 */ 039public enum HistAttrModificationKey 040{ 041 /** The key for attribute value deletion. */ 042 DEL("del"), 043 /** The key for attribute deletion. */ 044 ATTRDEL("attrDel"), 045 /** The key for attribute replace. */ 046 REPL("repl"), 047 /** The key for attribute value addition. */ 048 ADD("add"); 049 050 /** The string representation of this key. */ 051 private String key; 052 053 /** 054 * Creates a new HistKey type with the provided key string. 055 * 056 * @param histkey The key string 057 */ 058 private HistAttrModificationKey(String histkey) 059 { 060 this.key = histkey; 061 } 062 063 /** 064 * Get a key from the String representation. 065 * 066 * @param histkey the String to decode 067 * @return the key from the enum type 068 */ 069 public static HistAttrModificationKey decodeKey(String histkey) 070 { 071 for (HistAttrModificationKey histKey : values()) 072 { 073 if (histKey.toString().equals(histkey)) 074 { 075 return histKey; 076 } 077 } 078 return null; 079 } 080 081 /** 082 * Retrieves the human-readable name for this HistKey. 083 * 084 * @return The human-readable name for this HistKey. 085 */ 086 public String getKey() 087 { 088 return key; 089 } 090 091 /** 092 * Retrieves a string representation of this HistKey. 093 * 094 * @return A string representation of this HistKey. 095 */ 096 @Override 097 public String toString() 098 { 099 return key; 100 } 101}