001: /*_############################################################################
002: _##
003: _## SNMP4J-Agent - MOTableSubIndex.java
004: _##
005: _## Copyright (C) 2005-2007 Frank Fock (SNMP4J.org)
006: _##
007: _## Licensed under the Apache License, Version 2.0 (the "License");
008: _## you may not use this file except in compliance with the License.
009: _## You may obtain a copy of the License at
010: _##
011: _## http://www.apache.org/licenses/LICENSE-2.0
012: _##
013: _## Unless required by applicable law or agreed to in writing, software
014: _## distributed under the License is distributed on an "AS IS" BASIS,
015: _## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016: _## See the License for the specific language governing permissions and
017: _## limitations under the License.
018: _##
019: _##########################################################################*/
020:
021: package org.snmp4j.agent.mo;
022:
023: import org.snmp4j.smi.OID; // JavaDoc
024: import org.snmp4j.smi.SMIConstants;
025:
026: /**
027: * The <code>MOTableSubIndex</code> class represents a sub-index definition.
028: *
029: * @author Frank Fock
030: * @version 1.0
031: */
032: public class MOTableSubIndex {
033:
034: private int smiSyntax;
035: private int minLength = 1;
036: private int maxLength = 1;
037: private OID oid;
038:
039: /**
040: * Creates a sub-index definition based on a SMI syntax.
041: * @param smiSyntax
042: * a SMI syntax ID as defined by {@link SMIConstants}.
043: */
044: public MOTableSubIndex(int smiSyntax) {
045: this .smiSyntax = smiSyntax;
046: }
047:
048: /**
049: * Creates a sub-index definition based on a SMI syntax and the OID of the
050: * sub-index OBJECT-TYPE definition.
051: * @param oid
052: * the OID of the sub-index definition's OBJECT-TYPE.
053: * @param smiSyntax
054: * a SMI syntax ID as defined by {@link SMIConstants}.
055: */
056: public MOTableSubIndex(OID oid, int smiSyntax) {
057: this (smiSyntax);
058: this .oid = oid;
059: }
060:
061: /**
062: * Creates a sub-index definition based on a SMI syntax, minimum, and maximum
063: * sub-index length.
064: * @param smiSyntax
065: * a SMI syntax ID as defined by {@link SMIConstants}.
066: * @param minLength
067: * the minimum length of the sub-index (must not be greater than
068: * <code>maxLength</code>).
069: * @param maxLength
070: * the maximum length of the sub-index (must not be less than
071: * <code>minLength</code>).
072: */
073: public MOTableSubIndex(int smiSyntax, int minLength, int maxLength) {
074: this (smiSyntax);
075: if (minLength > maxLength) {
076: throw new IllegalArgumentException();
077: }
078: this .minLength = minLength;
079: this .maxLength = maxLength;
080: }
081:
082: /**
083: * Creates a sub-index definition based on a SMI syntax, minimum, and maximum
084: * sub-index length as well as the OID of the sub-index OBJECT-TYPE.
085: * @param oid
086: * the OID of the sub-index definition's OBJECT-TYPE.
087: * @param smiSyntax
088: * a SMI syntax ID as defined by {@link SMIConstants}.
089: * @param minLength
090: * the minimum length of the sub-index (must not be greater than
091: * <code>maxLength</code>).
092: * @param maxLength
093: * the maximum length of the sub-index (must not be less than
094: * <code>minLength</code>).
095: */
096: public MOTableSubIndex(OID oid, int smiSyntax, int minLength,
097: int maxLength) {
098: this (smiSyntax, minLength, maxLength);
099: this .oid = oid;
100: }
101:
102: /**
103: * Gets the SMI syntax of the sub-index.
104: * @return
105: * a SMI syntax as defined by {@link SMIConstants}.
106: */
107: public int getSmiSyntax() {
108: return smiSyntax;
109: }
110:
111: /**
112: * Returns the minimum sub-index length.
113: * @return
114: * the minimum length.
115: */
116: public int getMinLength() {
117: return minLength;
118: }
119:
120: /**
121: * Returns the maximum sub-index length.
122: * @return
123: * the maximum length.
124: */
125: public int getMaxLength() {
126: return maxLength;
127: }
128:
129: /**
130: * Returns the optional OID of the sub-index object definition.
131: * @return
132: * the OID of the sub-index object or <code>null</code> if that has not
133: * been specified on sub-index creation.
134: */
135: public OID getOid() {
136: return oid;
137: }
138: }
|