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.hostAddress; 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 HostAddress 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 HostAddressStatesEnum implements States 034{ 035 // Start 036 START_STATE, // 0 037 038 // ----- PrincipalName message -------------------------------------- 039 HOST_ADDRESS_SEQ_STATE, // 1 040 041 HOST_ADDRESS_ADDR_TYPE_TAG_STATE, // 2 042 HOST_ADDRESS_ADDR_TYPE_STATE, // 3 043 044 HOST_ADDRESS_ADDRESS_TAG_STATE, // 4 045 HOST_ADDRESS_ADDRESS_STATE, // 5 046 047 // End 048 LAST_HOST_ADDRESS_STATE; // 6 049 050 /** 051 * Get the grammar name 052 * 053 * @param grammar The grammar code 054 * @return The grammar name 055 */ 056 public String getGrammarName( int grammar ) 057 { 058 return "HOST_ADDRESS_GRAMMAR"; 059 } 060 061 062 /** 063 * Get the grammar name 064 * 065 * @param grammar The grammar class 066 * @return The grammar name 067 */ 068 public String getGrammarName( Grammar<HostAddressContainer> grammar ) 069 { 070 if ( grammar instanceof HostAddressGrammar ) 071 { 072 return "HOST_ADDRESS_GRAMMAR"; 073 } 074 else 075 { 076 return "UNKNOWN GRAMMAR"; 077 } 078 } 079 080 081 /** 082 * Get the string representing the state 083 * 084 * @param state The state number 085 * @return The String representing the state 086 */ 087 public String getState( int state ) 088 { 089 return ( ( state == LAST_HOST_ADDRESS_STATE.ordinal() ) ? "HOST_ADDRESS_END_STATE" : name() ); 090 } 091 092 093 /** 094 * {@inheritDoc} 095 */ 096 public boolean isEndState() 097 { 098 return this == LAST_HOST_ADDRESS_STATE; 099 } 100 101 102 /** 103 * {@inheritDoc} 104 */ 105 public HostAddressStatesEnum getStartState() 106 { 107 return START_STATE; 108 } 109}