All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.nervousync.beans.snmp.SNMPData Maven / Gradle / Ivy

There is a newer version: 1.2.1
Show newest version
/*
 * Licensed to the Nervousync Studio (NSYC) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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.nervousync.beans.snmp;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;

import org.nervousync.utils.DateTimeUtils;
import org.snmp4j.smi.VariableBinding;

/**
 * 

Reading data maps of SNMP datas

*

从SNMP读取的数据结果映射

* * @author Steven Wee [email protected] * @version $Revision: 1.1.3 $ $Date: May 25, 2022 21:55:18 $ */ public final class SNMPData implements Serializable { /** * Serial version UID * 序列化UID */ private static final long serialVersionUID = -9033003833049981503L; /** * Current GMT time in milliseconds * 当前GMT时间的毫秒数 */ private final long currentGMTTime; /** * String value of identified key * 识别代码字符串 */ private String identifiedKey = null; /** * Reading data key-value map * 读取数据的键值映射 */ private final Map dataMap; /** *

Constructor for SNMPData

* Read current GMT time in milliseconds and initialize data map *

SNMPData的构造函数

* 读取当前的GMT时间毫秒数,并初始化数据映射表 */ public SNMPData() { this.currentGMTTime = DateTimeUtils.currentUTCTimeMillis(); this.dataMap = new HashMap<>(); } /** *

Getter method for current GMT time

*

当前GMT时间的毫秒数的Getter方法

* * @return Current GMT time in milliseconds * 当前GMT时间的毫秒数 */ public long getCurrentGMTTime() { return currentGMTTime; } /** *

Getter method for identified key

*

识别代码字符串的Getter方法

* * @return String value of identified key * 识别代码字符串 */ public String getIdentifiedKey() { return identifiedKey; } /** *

Setter method for identified key

*

识别代码字符串的Setter方法

* * @param identifiedKey String value of identified key * 识别代码字符串 */ public void setIdentifiedKey(String identifiedKey) { this.identifiedKey = identifiedKey; } /** *

Parse instance of VariableBinding and add data to data map

*

解析VariableBinding实例对象,并添加数据到数据映射表

* * @param variableBinding Instance of VariableBinding * VariableBinding实例对象 * @see org.snmp4j.smi.VariableBinding */ public void addData(VariableBinding variableBinding) { if (!this.dataMap.containsKey(variableBinding.getOid().toString())) { this.dataMap.put(variableBinding.getOid().toString(), variableBinding.getVariable().toString()); } } /** *

Read data from data map by given oid string

*

根据给定的oid字符串读取数据值

* * @param oid oid string * oid字符串 * * @return Mapping data * 映射数据值 */ public String readData(final String oid) { return this.dataMap.get(oid); } /** *

Retrieve iterator over the elements in data map

*

获取当前数据集元素的遍历器

* * @return Iterator instance * 遍历器实例对象 */ public Iterator> iterator() { return this.dataMap.entrySet().iterator(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy