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   *     http://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      static final boolean IS_DEBUG = LOG.isDebugEnabled();
65  
66      private static Grammar<?> instance = new VirtualListViewResponseGrammar();
67  
68  
69      /**
70       * Creates a new VirtualListViewResponseGrammar object.
71       */
72      @SuppressWarnings("unchecked")
73      private VirtualListViewResponseGrammar()
74      {
75          setName( VirtualListViewResponseGrammar.class.getName() );
76  
77          super.transitions = new GrammarTransition[VirtualListViewResponseStates.END_STATE.ordinal()][256];
78  
79          super.transitions[VirtualListViewResponseStates.START_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] =
80              new GrammarTransition<VirtualListViewResponseContainer>(
81                  VirtualListViewResponseStates.START_STATE,
82                  VirtualListViewResponseStates.VLV_SEQUENCE_STATE,
83                  UniversalTag.SEQUENCE.getValue(),
84                  null );
85  
86          super.transitions[VirtualListViewResponseStates.VLV_SEQUENCE_STATE.ordinal()][UniversalTag.INTEGER.getValue()] =
87              new GrammarTransition<VirtualListViewResponseContainer>(
88                  VirtualListViewResponseStates.VLV_SEQUENCE_STATE,
89                  VirtualListViewResponseStates.VLV_TARGET_POSITION_STATE,
90                  UniversalTag.INTEGER.getValue(),
91                  new StoreTargetPosition() );
92  
93          super.transitions[VirtualListViewResponseStates.VLV_TARGET_POSITION_STATE.ordinal()][UniversalTag.INTEGER
94              .getValue()] =
95              new GrammarTransition<VirtualListViewResponseContainer>(
96                  VirtualListViewResponseStates.VLV_TARGET_POSITION_STATE,
97                  VirtualListViewResponseStates.VLV_CONTENT_COUNT_STATE,
98                  UniversalTag.INTEGER.getValue(),
99                  new StoreContentCountResponse() );
100 
101         super.transitions[VirtualListViewResponseStates.VLV_CONTENT_COUNT_STATE.ordinal()][UniversalTag.ENUMERATED
102             .getValue()] =
103             new GrammarTransition<VirtualListViewResponseContainer>(
104                 VirtualListViewResponseStates.VLV_CONTENT_COUNT_STATE,
105                 VirtualListViewResponseStates.VLV_VIRTUAL_LIST_VIEW_RESULT_STATE,
106                 UniversalTag.ENUMERATED.getValue(),
107                 new StoreVirtualListViewResult() );
108 
109         super.transitions[VirtualListViewResponseStates.VLV_VIRTUAL_LIST_VIEW_RESULT_STATE.ordinal()][UniversalTag.OCTET_STRING
110             .getValue()] =
111             new GrammarTransition<VirtualListViewResponseContainer>(
112                 VirtualListViewResponseStates.VLV_VIRTUAL_LIST_VIEW_RESULT_STATE,
113                 VirtualListViewResponseStates.VLV_CONTEXT_ID_STATE,
114                 UniversalTag.OCTET_STRING.getValue(),
115                 new StoreContextIdResponse() );
116     }
117 
118 
119     /**
120      * @return the singleton instance of the VirtualListViewResponseGrammar
121      */
122     public static Grammar<?> getInstance()
123     {
124         return instance;
125     }
126 }