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

com.davfx.ninio.snmp.FromMapSnmpServerHandler Maven / Gradle / Ivy

There is a newer version: 3.0.50
Show newest version
package com.davfx.ninio.snmp;

import java.io.IOException;
import java.util.Map;
import java.util.SortedMap;

import com.davfx.ninio.core.Address;

public final class FromMapSnmpServerHandler implements SnmpServerHandler {
	private final SortedMap map;
	private final SnmpServerHandler wrappee;
	
	public FromMapSnmpServerHandler(SortedMap map, SnmpServerHandler wrappee) {
		this.map = map;
		this.wrappee = wrappee;
	}

	@Override
	public void from(Oid oid, SnmpServerHandler.Callback callback) {
		SortedMap tail = map.tailMap(oid);
		for (Map.Entry e : tail.entrySet()) {
			if (!callback.handle(new SnmpResult(e.getKey(), e.getValue()))) {
				break;
			}
		}
	}
	
	@Override
	public void connected(Address address) {
		if (wrappee != null) {
			wrappee.connected(address);
		}
	}
	@Override
	public void closed() {
		if (wrappee != null) {
			wrappee.closed();
		}
	}
	@Override
	public void failed(IOException ioe) {
		if (wrappee != null) {
			wrappee.failed(ioe);
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy