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.api.ldap.extras.controls.syncrepl_impl; 021 022 023import org.apache.directory.api.asn1.ber.grammar.Grammar; 024import org.apache.directory.api.asn1.ber.grammar.States; 025 026 027/** 028 * This class store the SyncStateValueControl'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 SyncStateValueStatesEnum implements States 034{ 035 /** The END_STATE */ 036 END_STATE, 037 038 // ========================================================================= 039 // SyncStateValue control grammar states 040 // ========================================================================= 041 /** Initial state */ 042 START_STATE, 043 044 /** Sequence Value */ 045 SYNC_STATE_VALUE_SEQUENCE_STATE, 046 047 /** sync state type Value */ 048 SYNC_TYPE_STATE, 049 050 /** syncUUID Value */ 051 SYNC_UUID_STATE, 052 053 /** cookie Value */ 054 COOKIE_STATE, 055 056 /** terminal state */ 057 LAST_SYNC_STATE_VALUE_STATE; 058 059 /** 060 * Get the grammar name 061 * 062 * @param grammar The grammar code 063 * @return The grammar name 064 */ 065 public String getGrammarName( int grammar ) 066 { 067 return "SYNC_REQUEST_VALUE_GRAMMAR"; 068 } 069 070 071 /** 072 * Get the grammar name 073 * 074 * @param grammar The grammar class 075 * @return The grammar name 076 */ 077 public String getGrammarName( Grammar<SyncStateValueContainer> grammar ) 078 { 079 if ( grammar instanceof SyncStateValueGrammar ) 080 { 081 return "SYNC_STATE_VALUE_GRAMMAR"; 082 } 083 084 return "UNKNOWN GRAMMAR"; 085 } 086 087 088 /** 089 * Get the string representing the state 090 * 091 * @param state The state number 092 * @return The String representing the state 093 */ 094 public String getState( int state ) 095 { 096 return ( ( state == END_STATE.ordinal() ) ? "SYNC_STATE_VALUE_END_STATE" : this.name() ); 097 } 098 099 100 /** 101 * {@inheritDoc} 102 */ 103 public boolean isEndState() 104 { 105 return this == END_STATE; 106 } 107 108 109 /** 110 * {@inheritDoc} 111 */ 112 public SyncStateValueStatesEnum getStartState() 113 { 114 return START_STATE; 115 } 116}