⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 integer32.java

📁 snmp hibernate 源码, 类似hibernate的映射.
💻 JAVA
字号:
/*_############################################################################  _##   _##  SNMP4J - Integer32.java    _##   _##  Copyright 2003-2006  Frank Fock and Jochen Katz (SNMP4J.org)  _##    _##  Licensed under the Apache License, Version 2.0 (the "License");  _##  you may not use this file except in compliance with the License.  _##  You may obtain a copy of the License at  _##    _##      http://www.apache.org/licenses/LICENSE-2.0  _##    _##  Unless required by applicable law or agreed to in writing, software  _##  distributed under the License is distributed on an "AS IS" BASIS,  _##  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  _##  See the License for the specific language governing permissions and  _##  limitations under the License.  _##    _##########################################################################*/package org.snmp4j.smi;import java.io.*;import org.snmp4j.asn1.BER;import org.snmp4j.asn1.BERInputStream;/** * The <code>Integer32</code> represents 32bit signed integer values for SNMP. * * @author Frank Fock * @version 1.7 */public class Integer32 extends Variable    implements AssignableFromInteger, AssignableFromString {  private static final long serialVersionUID = 5046132399890132416L;  private int value = 0;  /**   * Creates an <code>Integer32</code> with a zero value.   */  public Integer32() {  }  /**   * Creates an <code>Integer32</code> variable with the supplied value.   * @param value   *    an integer value.   */  public Integer32(int value) {    setValue(value);  }  public void encodeBER(OutputStream outputStream) throws java.io.IOException {    BER.encodeInteger(outputStream, BER.INTEGER, value);  }  public void decodeBER(BERInputStream inputStream) throws java.io.IOException {    BER.MutableByte type = new BER.MutableByte();    int newValue = BER.decodeInteger(inputStream, type);    if (type.getValue() != BER.INTEGER) {      throw new IOException("Wrong type encountered when decoding Counter: "+type.getValue());    }    setValue(newValue);  }  public int getSyntax() {    return SMIConstants.SYNTAX_INTEGER;  }  public int hashCode() {    return value;  }  public int getBERLength() {    if ((value <   0x80) &&        (value >= -0x80)) {      return 3;    }    else if ((value <   0x8000) &&             (value >= -0x8000)) {      return 4;    }    else if ((value <   0x800000) &&             (value >= -0x800000)) {      return 5;    }    return 6;  }  public boolean equals(Object o) {    if (o instanceof Integer32) {      return ((Integer32)o).value == value;    }    return false;  }  public int compareTo(Object o) {    return value - ((Integer32)o).value;  }  public String toString() {    return Integer.toString(value);  }  public final void setValue(String value) {    this.value = Integer.parseInt(value);  }  /**   * Sets the value of this integer.   * @param value   *    an integer value.   */  public final void setValue(int value) {    this.value = value;  }  /**   * Gets the value.   * @return   *    an integer.   */  public final Integer getValue() {    return value;  }  public Object clone() {    return new Integer32(value);  }  public final int toInt() {    return getValue();  }  public final long toLong() {    return getValue();  }  public OID toSubIndex(boolean impliedLength) {    return new OID(new int[] { value });  }  public void fromSubIndex(OID subIndex, boolean impliedLength) {    setValue(subIndex.get(0));  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -