KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > snmp4j > agent > mo > MOTableSubIndex


1 /*_############################################################################
2   _##
3   _## SNMP4J-Agent - MOTableSubIndex.java
4   _##
5   _## Copyright (C) 2005-2007 Frank Fock (SNMP4J.org)
6   _##
7   _## Licensed under the Apache License, Version 2.0 (the "License");
8   _## you may not use this file except in compliance with the License.
9   _## You may obtain a copy of the License at
10   _##
11   _## http://www.apache.org/licenses/LICENSE-2.0
12   _##
13   _## Unless required by applicable law or agreed to in writing, software
14   _## distributed under the License is distributed on an "AS IS" BASIS,
15   _## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   _## See the License for the specific language governing permissions and
17   _## limitations under the License.
18   _##
19   _##########################################################################*/

20
21
22 package org.snmp4j.agent.mo;
23
24 import org.snmp4j.smi.OID;
25 // JavaDoc
26
import org.snmp4j.smi.SMIConstants;
27
28
29 /**
30  * The <code>MOTableSubIndex</code> class represents a sub-index definition.
31  *
32  * @author Frank Fock
33  * @version 1.0
34  */

35 public class MOTableSubIndex {
36
37   private int smiSyntax;
38   private int minLength = 1;
39   private int maxLength = 1;
40   private OID oid;
41
42   /**
43    * Creates a sub-index definition based on a SMI syntax.
44    * @param smiSyntax
45    * a SMI syntax ID as defined by {@link SMIConstants}.
46    */

47   public MOTableSubIndex(int smiSyntax) {
48     this.smiSyntax = smiSyntax;
49   }
50
51   /**
52    * Creates a sub-index definition based on a SMI syntax and the OID of the
53    * sub-index OBJECT-TYPE definition.
54    * @param oid
55    * the OID of the sub-index definition's OBJECT-TYPE.
56    * @param smiSyntax
57    * a SMI syntax ID as defined by {@link SMIConstants}.
58    */

59   public MOTableSubIndex(OID oid, int smiSyntax) {
60     this(smiSyntax);
61     this.oid = oid;
62   }
63
64   /**
65    * Creates a sub-index definition based on a SMI syntax, minimum, and maximum
66    * sub-index length.
67    * @param smiSyntax
68    * a SMI syntax ID as defined by {@link SMIConstants}.
69    * @param minLength
70    * the minimum length of the sub-index (must not be greater than
71    * <code>maxLength</code>).
72    * @param maxLength
73    * the maximum length of the sub-index (must not be less than
74    * <code>minLength</code>).
75    */

76   public MOTableSubIndex(int smiSyntax, int minLength, int maxLength) {
77     this(smiSyntax);
78     if (minLength > maxLength) {
79       throw new IllegalArgumentException JavaDoc();
80     }
81     this.minLength = minLength;
82     this.maxLength = maxLength;
83   }
84
85   /**
86    * Creates a sub-index definition based on a SMI syntax, minimum, and maximum
87    * sub-index length as well as the OID of the sub-index OBJECT-TYPE.
88    * @param oid
89    * the OID of the sub-index definition's OBJECT-TYPE.
90    * @param smiSyntax
91    * a SMI syntax ID as defined by {@link SMIConstants}.
92    * @param minLength
93    * the minimum length of the sub-index (must not be greater than
94    * <code>maxLength</code>).
95    * @param maxLength
96    * the maximum length of the sub-index (must not be less than
97    * <code>minLength</code>).
98    */

99   public MOTableSubIndex(OID oid, int smiSyntax, int minLength, int maxLength) {
100     this(smiSyntax, minLength, maxLength);
101     this.oid = oid;
102   }
103
104   /**
105    * Gets the SMI syntax of the sub-index.
106    * @return
107    * a SMI syntax as defined by {@link SMIConstants}.
108    */

109   public int getSmiSyntax() {
110     return smiSyntax;
111   }
112
113   /**
114    * Returns the minimum sub-index length.
115    * @return
116    * the minimum length.
117    */

118   public int getMinLength() {
119     return minLength;
120   }
121
122   /**
123    * Returns the maximum sub-index length.
124    * @return
125    * the maximum length.
126    */

127   public int getMaxLength() {
128     return maxLength;
129   }
130
131   /**
132    * Returns the optional OID of the sub-index object definition.
133    * @return
134    * the OID of the sub-index object or <code>null</code> if that has not
135    * been specified on sub-index creation.
136    */

137   public OID getOid() {
138     return oid;
139   }
140 }
141
Popular Tags