View Javadoc
1   /*
2    *   Licensed to the Apache Software Foundation (ASF) under one
3    *   or more contributor license agreements.  See the NOTICE file
4    *   distributed with this work for additional information
5    *   regarding copyright ownership.  The ASF licenses this file
6    *   to you under the Apache License, Version 2.0 (the
7    *   "License"); you may not use this file except in compliance
8    *   with the License.  You may obtain a copy of the License at
9    *
10   *     https://www.apache.org/licenses/LICENSE-2.0
11   *
12   *   Unless required by applicable law or agreed to in writing,
13   *   software distributed under the License is distributed on an
14   *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *   KIND, either express or implied.  See the License for the
16   *   specific language governing permissions and limitations
17   *   under the License.
18   *
19   */
20  
21  package org.apache.directory.api.ldap.extras.controls.vlv_impl;
22  
23  
24  import org.apache.directory.api.asn1.ber.grammar.AbstractGrammar;
25  import org.apache.directory.api.asn1.ber.grammar.Grammar;
26  import org.apache.directory.api.asn1.ber.grammar.GrammarTransition;
27  import org.apache.directory.api.asn1.ber.tlv.UniversalTag;
28  import org.slf4j.Logger;
29  import org.slf4j.LoggerFactory;
30  
31  
32  /**
33   * The grammar for the VLV response which described as :
34   * 
35   * <pre>
36   *  VirtualListViewResponse ::= SEQUENCE {
37   *         targetPosition    INTEGER (0 .. maxInt),
38   *         contentCount     INTEGER (0 .. maxInt),
39   *         virtualListViewResult ENUMERATED {
40   *              success (0),
41   *              operationsError (1),
42   *              protocolError (3),
43   *              unwillingToPerform (53),
44   *              insufficientAccessRights (50),
45   *              timeLimitExceeded (3),
46   *              adminLimitExceeded (11),
47   *              innapropriateMatching (18),
48   *              sortControlMissing (60),
49   *              offsetRangeError (61),
50   *              other(80),
51   *              ... 
52   *         },
53   *         contextID     OCTET STRING OPTIONAL 
54   * }
55   * </pre>
56   * 
57   *
58   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
59   */
60  public final class VirtualListViewResponseGrammar extends AbstractGrammar<VirtualListViewResponseContainer>
61  {
62      static final Logger LOG = LoggerFactory.getLogger( VirtualListViewResponseGrammar.class );
63  
64      private static Grammar<?> instance = new VirtualListViewResponseGrammar();
65  
66  
67      @SuppressWarnings("unchecked")
68      private VirtualListViewResponseGrammar()
69      {
70          setName( VirtualListViewResponseGrammar.class.getName() );
71  
72          super.transitions = new GrammarTransition[VirtualListViewResponseStates.END_STATE.ordinal()][256];
73  
74          super.transitions[VirtualListViewResponseStates.START_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] =
75              new GrammarTransition<VirtualListViewResponseContainer>(
76                  VirtualListViewResponseStates.START_STATE,
77                  VirtualListViewResponseStates.VLV_SEQUENCE_STATE,
78                  UniversalTag.SEQUENCE.getValue(),
79                  null );
80  
81          super.transitions[VirtualListViewResponseStates.VLV_SEQUENCE_STATE.ordinal()][UniversalTag.INTEGER.getValue()] =
82              new GrammarTransition<VirtualListViewResponseContainer>(
83                  VirtualListViewResponseStates.VLV_SEQUENCE_STATE,
84                  VirtualListViewResponseStates.VLV_TARGET_POSITION_STATE,
85                  UniversalTag.INTEGER.getValue(),
86                  new StoreTargetPosition() );
87  
88          super.transitions[VirtualListViewResponseStates.VLV_TARGET_POSITION_STATE.ordinal()][UniversalTag.INTEGER
89              .getValue()] =
90              new GrammarTransition<VirtualListViewResponseContainer>(
91                  VirtualListViewResponseStates.VLV_TARGET_POSITION_STATE,
92                  VirtualListViewResponseStates.VLV_CONTENT_COUNT_STATE,
93                  UniversalTag.INTEGER.getValue(),
94                  new StoreContentCountResponse() );
95  
96          super.transitions[VirtualListViewResponseStates.VLV_CONTENT_COUNT_STATE.ordinal()][UniversalTag.ENUMERATED
97              .getValue()] =
98              new GrammarTransition<VirtualListViewResponseContainer>(
99                  VirtualListViewResponseStates.VLV_CONTENT_COUNT_STATE,
100                 VirtualListViewResponseStates.VLV_VIRTUAL_LIST_VIEW_RESULT_STATE,
101                 UniversalTag.ENUMERATED.getValue(),
102                 new StoreVirtualListViewResult() );
103 
104         super.transitions[VirtualListViewResponseStates.VLV_VIRTUAL_LIST_VIEW_RESULT_STATE.ordinal()][UniversalTag.OCTET_STRING
105             .getValue()] =
106             new GrammarTransition<VirtualListViewResponseContainer>(
107                 VirtualListViewResponseStates.VLV_VIRTUAL_LIST_VIEW_RESULT_STATE,
108                 VirtualListViewResponseStates.VLV_CONTEXT_ID_STATE,
109                 UniversalTag.OCTET_STRING.getValue(),
110                 new StoreContextIdResponse() );
111     }
112 
113 
114     /**
115      * @return the singleton instance of the VirtualListViewResponseGrammar
116      */
117     public static Grammar<?> getInstance()
118     {
119         return instance;
120     }
121 }