View Javadoc

1   /*
2    *   Copyright 2005 The Apache Software Foundation
3    *
4    *   Licensed under the Apache License, Version 2.0 (the "License");
5    *   you may not use this file except in compliance with the License.
6    *   You may obtain a copy of the License at
7    *
8    *       http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *   Unless required by applicable law or agreed to in writing, software
11   *   distributed under the License is distributed on an "AS IS" BASIS,
12   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *   See the License for the specific language governing permissions and
14   *   limitations under the License.
15   *
16   */
17  package org.apache.asn1new.ber.containers;
18  
19  import org.apache.asn1new.ber.grammar.IGrammar;
20  import org.apache.asn1new.ber.grammar.IStates;
21  import org.apache.asn1new.ber.tlv.TLV;
22  
23  
24  /***
25   * Every ASN1 container must implement this interface. 
26   * 
27   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
28   */
29  public interface IAsn1Container
30  {
31      //~ Methods ------------------------------------------------------------------------------------
32  
33      // State accessors
34      /***
35       * Get the current grammar state
36       *
37       * @return Returns the current grammar state
38       */
39      int getState();
40  
41      /***
42       * Set the new current state
43       *
44       * @param state The new state
45       */
46      void setState( int state );
47  
48      /***
49       * Set the current TLV
50       *
51       * @param tlv The current TLV
52       */
53      public void setCurrentTLV( TLV tlv );
54  
55      /***
56       * Get the currentTLV
57       *
58       * @return Returns the current TLV being decoded
59       */
60      public TLV getCurrentTLV();
61  
62      /***
63       * Get the grammar
64       *
65       * @return Returns the grammar used to decode a LdapMessage.
66       */
67      public IGrammar getGrammar();
68  
69      /***
70       * Add a new IGrammar to use
71       *
72       * @param grammar The grammar to add.
73       */
74      public void addGrammar( IGrammar grammar );
75  
76      /***
77       * Switch to another grammar
78       *
79       * @param grammar The grammar to switch to.
80       */
81      public void switchGrammar( int currentState, int grammar );
82  
83      /***
84       * restore the previous grammar (the one before a switch has occured)
85       * 
86       * @return Returns the previous state if any.
87       */
88      public int restoreGrammar();
89  
90      /***
91       * @return Returns the currentGrammar.
92       */
93      public int getCurrentGrammar();
94  
95      /***
96       * Set the first grammar to use
97       * @param The first grammar .
98       */
99      public void setInitGrammar(int grammar);
100 
101     /***
102      * Get the transition
103      *
104      * @return Returns the transition from the previous state to the new 
105      * state
106      */
107     public int getTransition();
108 
109     /***
110      * Update the transition from a state to another
111      *
112      * @param transition The transition to set
113      */
114     public void setTransition( int transition );
115     
116     /***
117      * @return Returns the current Grammar type, or -1 if not found.
118      */
119     public int getCurrentGrammarType();
120     
121     /***
122      * @return Returns the states.
123      */
124     public IStates getStates();
125     
126     /***
127      * @return get the parent TLV.
128      */
129     public TLV getParentTLV();
130 
131     /***
132      * Set the parent TLV
133      * @param The new parent TLV 
134      */
135     public void setParentTLV(TLV parentTLV);
136 }