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 010 * trunk/opends/resource/legal-notices/OpenDS.LICENSE 011 * or https://OpenDS.dev.java.net/OpenDS.LICENSE. 012 * See the License for the specific language governing permissions 013 * and limitations under the License. 014 * 015 * When distributing Covered Code, include this CDDL HEADER in each 016 * file and include the License file at 017 * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, 018 * add the following below this CDDL HEADER, with the fields enclosed 019 * by brackets "[]" replaced with your own identifying information: 020 * Portions Copyright [yyyy] [name of copyright owner] 021 * 022 * CDDL HEADER END 023 * 024 * 025 * Copyright 2006-2008 Sun Microsystems, Inc. 026 */ 027 package org.opends.server.replication.plugin; 028 029 /** 030 * Enumeration used for storing type of historical information. 031 */ 032 public enum HistKey 033 { 034 /** 035 * The key for attribute value deletion. 036 */ 037 DEL("del"), 038 039 /** 040 * The key for attribute deletion. 041 */ 042 DELATTR("delAttr"), 043 044 /** 045 * The key for attribute replace. 046 */ 047 REPL("repl"), 048 049 /** 050 * The key for attribute value addition. 051 */ 052 ADD("add"); 053 054 // The string representation of this key. 055 private String key; 056 057 /** 058 * Creates a new HistKey type with the provided key string. 059 * 060 * @param histkey The key string 061 */ 062 private HistKey(String histkey) 063 { 064 this.key = histkey; 065 } 066 067 /** 068 * Get a key from the String representation. 069 * 070 * @param histkey the String to decode 071 * @return the key from the enum type 072 */ 073 public static HistKey decodeKey(String histkey) 074 { 075 if (histkey == null) 076 return null; 077 078 if (histkey.compareTo("repl") == 0) 079 return HistKey.REPL; 080 081 if (histkey.compareTo("add") == 0) 082 return HistKey.ADD; 083 084 if (histkey.compareTo("del") == 0) 085 return HistKey.DEL; 086 087 if (histkey.compareTo("attrDel") == 0) 088 return HistKey.DELATTR; 089 090 return null; 091 } 092 093 /** 094 * Retrieves the human-readable name for this HistKey. 095 * 096 * @return The human-readable name for this HistKey. 097 */ 098 public String getKey() 099 { 100 return key; 101 } 102 103 /** 104 * Retrieves a string representation of this HistKey. 105 * 106 * @return A string representation of this HistKey. 107 */ 108 public String toString() 109 { 110 return key; 111 } 112 113 }