001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 * 019 */ 020package org.apache.directory.shared.ldap.extras.controls.syncrepl_impl; 021 022 023import org.apache.directory.shared.asn1.ber.grammar.Grammar; 024import org.apache.directory.shared.asn1.ber.grammar.States; 025 026 027/** 028 * This class store the SyncModifyDnControl's grammar constants. It is also used for 029 * debugging purposes. 030 * 031 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 032 */ 033public enum SyncModifyDnStatesEnum implements States 034{ 035 // ~ Static fields/initializers 036 // ----------------------------------------------------------------- 037 038 /** The END_STATE */ 039 END_STATE, 040 041 // ========================================================================= 042 // SyncModifyDnControl's control grammar states 043 // ========================================================================= 044 /** Initial state */ 045 START_SYNC_MODDN, 046 047 /** Sequence Value */ 048 SYNC_MODDN_VALUE_SEQUENCE_STATE, 049 050 /** modDn control's entryDN */ 051 ENTRY_DN_STATE, 052 053 /** modDn control's move operation state */ 054 MOVE_STATE, 055 056 /** modDn rename sequence */ 057 RENAME_STATE, 058 059 /** modDn rename sequence */ 060 MOVE_AND_RENAME_STATE, 061 062 /** modDn control's rename newRDN */ 063 RENAME_NEW_RDN_STATE, 064 065 /** modDn control's rename deleteOldRdn flag */ 066 RENAME_DEL_OLD_RDN_STATE, 067 068 /** modDn control's move and rename newSuperiorDN */ 069 MOVE_AND_RENAME_NEW_SUPERIOR_DN_STATE, 070 071 /** modDn control's move and rename newRDN */ 072 MOVE_AND_RENAME_NEW_RDN_STATE, 073 074 /** modDn control's move and rename deleteOldRdn flag */ 075 MOVE_AND_RENAME_DEL_OLD_RDN_STATE, 076 077 /** terminal state */ 078 LAST_SYNC_MODDN_VALUE_STATE; 079 080 /** 081 * Get the grammar name 082 * 083 * @param grammar The grammar code 084 * @return The grammar name 085 */ 086 public String getGrammarName( int grammar ) 087 { 088 return "SYNC_MODIFYDN_GRAMMAR"; 089 } 090 091 092 /** 093 * Get the grammar name 094 * 095 * @param grammar The grammar class 096 * @return The grammar name 097 */ 098 public String getGrammarName( Grammar grammar ) 099 { 100 if ( grammar instanceof SyncModifyDnGrammar ) 101 { 102 return "SYNC_MODIFYDN_GRAMMAR"; 103 } 104 105 return "UNKNOWN GRAMMAR"; 106 } 107 108 109 /** 110 * Get the string representing the state 111 * 112 * @param state The state number 113 * @return The String representing the state 114 */ 115 public String getState( int state ) 116 { 117 return ( ( state == END_STATE.ordinal() ) ? "SYNC_MODDN_VALUE_END_STATE" : this.name() ); 118 } 119 120 121 /** 122 * {@inheritDoc} 123 */ 124 public boolean isEndState() 125 { 126 return this == END_STATE; 127 } 128 129 130 /** 131 * {@inheritDoc} 132 */ 133 public SyncModifyDnStatesEnum getStartState() 134 { 135 return START_SYNC_MODDN; 136 } 137}