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;
22  
23  
24  /**
25   * Enumeration of the result codes of a Virtual List View response control as specified in draft-ietf-ldapext-ldapv3-vlv-09.
26   *
27   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
28   */
29  public enum VirtualListViewResultCode
30  {
31      SUCCESS(0, "Success"),
32  
33      OPERATIONSERROR(1, "Server internal failure"),
34  
35      TIMELIMITEXCEEDED(3, "Timelimit exceeded"),
36  
37      ADMINLIMITEXCEEDED(11, "Admin limit exceeded"),
38  
39      INAPPROPRIATEMATCHING(18, "Unrecognized or inappropriate matching rule"),
40  
41      INSUFFICIENTACCESSRIGHTS(50, "Insufficient access rights"),
42  
43      UNWILLINGTOPERFORM(53, "Unwilling to perform"),
44  
45      SORTCONTROLMISSING(60, "Sort control missing"),
46  
47      OFFSETRANGEERROR(61, "Offset range error"),
48  
49      OTHER(80, "Other");
50  
51      private int val;
52      private String desc;
53  
54  
55      private VirtualListViewResultCode( int val, String desc )
56      {
57          this.val = val;
58          this.desc = desc;
59      }
60  
61  
62      public int getVal()
63      {
64          return val;
65      }
66  
67  
68      /**
69       * returns the enum value representing the given code.
70       * 
71       * @param code the result code
72       * @return returns the corresponding ResultCode, throws IllegalArgumentException when there
73       *         is no matching ResultCode exists for the given value.
74       */
75      public static VirtualListViewResultCode get( int code )
76      {
77          switch ( code )
78          {
79              case 0:
80                  return SUCCESS;
81  
82              case 1:
83                  return OPERATIONSERROR;
84  
85              case 3:
86                  return TIMELIMITEXCEEDED;
87  
88              case 11:
89                  return ADMINLIMITEXCEEDED;
90  
91              case 18:
92                  return INAPPROPRIATEMATCHING;
93  
94              case 50:
95                  return INSUFFICIENTACCESSRIGHTS;
96  
97              case 53:
98                  return UNWILLINGTOPERFORM;
99  
100             case 60:
101                 return SORTCONTROLMISSING;
102 
103             case 61:
104                 return OFFSETRANGEERROR;
105 
106             case 80:
107                 return OTHER;
108 
109             default:
110                 throw new IllegalArgumentException( "Unknown VLV response result code " + code );
111         }
112     }
113 }