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 * https://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 */ 020 021package org.apache.directory.api.ldap.extras.controls.vlv_impl; 022 023 024import org.apache.directory.api.asn1.ber.grammar.AbstractGrammar; 025import org.apache.directory.api.asn1.ber.grammar.Grammar; 026import org.apache.directory.api.asn1.ber.grammar.GrammarTransition; 027import org.apache.directory.api.asn1.ber.tlv.UniversalTag; 028import org.slf4j.Logger; 029import org.slf4j.LoggerFactory; 030 031 032/** 033 * The grammar for the VLV response which described as : 034 * 035 * <pre> 036 * VirtualListViewResponse ::= SEQUENCE { 037 * targetPosition INTEGER (0 .. maxInt), 038 * contentCount INTEGER (0 .. maxInt), 039 * virtualListViewResult ENUMERATED { 040 * success (0), 041 * operationsError (1), 042 * protocolError (3), 043 * unwillingToPerform (53), 044 * insufficientAccessRights (50), 045 * timeLimitExceeded (3), 046 * adminLimitExceeded (11), 047 * innapropriateMatching (18), 048 * sortControlMissing (60), 049 * offsetRangeError (61), 050 * other(80), 051 * ... 052 * }, 053 * contextID OCTET STRING OPTIONAL 054 * } 055 * </pre> 056 * 057 * 058 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 059 */ 060public final class VirtualListViewResponseGrammar extends AbstractGrammar<VirtualListViewResponseContainer> 061{ 062 static final Logger LOG = LoggerFactory.getLogger( VirtualListViewResponseGrammar.class ); 063 064 private static Grammar<?> instance = new VirtualListViewResponseGrammar(); 065 066 067 @SuppressWarnings("unchecked") 068 private VirtualListViewResponseGrammar() 069 { 070 setName( VirtualListViewResponseGrammar.class.getName() ); 071 072 super.transitions = new GrammarTransition[VirtualListViewResponseStates.END_STATE.ordinal()][256]; 073 074 super.transitions[VirtualListViewResponseStates.START_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] = 075 new GrammarTransition<VirtualListViewResponseContainer>( 076 VirtualListViewResponseStates.START_STATE, 077 VirtualListViewResponseStates.VLV_SEQUENCE_STATE, 078 UniversalTag.SEQUENCE.getValue(), 079 null ); 080 081 super.transitions[VirtualListViewResponseStates.VLV_SEQUENCE_STATE.ordinal()][UniversalTag.INTEGER.getValue()] = 082 new GrammarTransition<VirtualListViewResponseContainer>( 083 VirtualListViewResponseStates.VLV_SEQUENCE_STATE, 084 VirtualListViewResponseStates.VLV_TARGET_POSITION_STATE, 085 UniversalTag.INTEGER.getValue(), 086 new StoreTargetPosition() ); 087 088 super.transitions[VirtualListViewResponseStates.VLV_TARGET_POSITION_STATE.ordinal()][UniversalTag.INTEGER 089 .getValue()] = 090 new GrammarTransition<VirtualListViewResponseContainer>( 091 VirtualListViewResponseStates.VLV_TARGET_POSITION_STATE, 092 VirtualListViewResponseStates.VLV_CONTENT_COUNT_STATE, 093 UniversalTag.INTEGER.getValue(), 094 new StoreContentCountResponse() ); 095 096 super.transitions[VirtualListViewResponseStates.VLV_CONTENT_COUNT_STATE.ordinal()][UniversalTag.ENUMERATED 097 .getValue()] = 098 new GrammarTransition<VirtualListViewResponseContainer>( 099 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}