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.kerberos.codec.hostAddresses; 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 HostAddresess grammar's constants. It is also used for debugging 029 * purpose 030 * 031 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 032 */ 033public enum HostAddressesStatesEnum implements States 034{ 035 // Start 036 START_STATE, // 0 037 038 // ----- HostAddresses message -------------------------------------- 039 HOST_ADDRESSES_SEQ_STATE, // 1 040 041 HOST_ADDRESSES_ADDRESS_STATE, // 2 042 043 // End 044 LAST_HOST_ADDRESSES_STATE; // 3 045 046 /** 047 * Get the grammar name 048 * 049 * @param grammar The grammar code 050 * @return The grammar name 051 */ 052 public String getGrammarName( int grammar ) 053 { 054 return "HOST_ADDRESSES_GRAMMAR"; 055 } 056 057 058 /** 059 * Get the grammar name 060 * 061 * @param grammar The grammar class 062 * @return The grammar name 063 */ 064 public String getGrammarName( Grammar<HostAddressesContainer> grammar ) 065 { 066 if ( grammar instanceof HostAddressesGrammar ) 067 { 068 return "HOST_ADDRESSES_GRAMMAR"; 069 } 070 else 071 { 072 return "UNKNOWN GRAMMAR"; 073 } 074 } 075 076 077 /** 078 * Get the string representing the state 079 * 080 * @param state The state number 081 * @return The String representing the state 082 */ 083 public String getState( int state ) 084 { 085 return ( ( state == LAST_HOST_ADDRESSES_STATE.ordinal() ) ? "HOST_ADDRESSES_END_STATE" : name() ); 086 } 087 088 089 /** 090 * {@inheritDoc} 091 */ 092 public boolean isEndState() 093 { 094 return this == LAST_HOST_ADDRESSES_STATE; 095 } 096 097 098 /** 099 * {@inheritDoc} 100 */ 101 public HostAddressesStatesEnum getStartState() 102 { 103 return START_STATE; 104 } 105}