Package org.snmp4j
Class AbstractTarget
java.lang.Object
org.snmp4j.AbstractTarget
- All Implemented Interfaces:
 Serializable,Cloneable,Target
- Direct Known Subclasses:
 CommunityTarget,SecureTarget
A 
AbstractTarget class is an abstract representation of a remote
 SNMP entity. It represents a target with an Address object, as well protocol
 parameters such as retransmission and timeout policy. Implementers of the
 Target interface can subclass AbstractTarget to
 take advantage of the implementation of common Target
 properties.- Since:
 - 1.2
 - Version:
 - 2.0
 - Author:
 - Frank Fock
 - See Also:
 
- 
Field Summary
Fields - 
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDefault constructorprotectedAbstractTarget(Address address) Creates a SNMPv3 target with no retries and a timeout of one second.protectedAbstractTarget(Address address, OctetString securityName)  - 
Method Summary
Modifier and TypeMethodDescriptionclone()booleanGets the address of this target.intGets the maximum size of request PDUs that this target is able to respond to.List<TransportMapping<? extends Address>>Gets the prioritised list of transport mappings to be used for this target.intGets the number of retries.intGets the security level associated with this target.intGets the security model associated with this target.final OctetStringGets the security name associated with this target.longGets the timeout for a target.intGets the SNMP version (NMP messagen processing model) of the target.inthashCode()voidsetAddress(Address address) Sets the address of the target.voidsetMaxSizeRequestPDU(int maxSizeRequestPDU) Sets the maximum size of request PDUs that this target is able to receive.voidsetPreferredTransports(List<TransportMapping<? extends Address>> preferredTransports) Sets the prioritised list of transport mappings to be used for this target.voidsetRetries(int retries) Sets the number of retries to be performed before a request is timed out.voidsetSecurityLevel(int securityLevel) Sets the security level for this target.voidsetSecurityModel(int securityModel) Sets the security model for this target.final voidsetSecurityName(OctetString securityName) Sets the security name to be used with this target.voidsetTimeout(long timeout) Sets the timeout for a target.voidsetVersion(int version) Sets the SNMP version (thus the SNMP message processing model) of the target.toString()protected String 
- 
Field Details
- 
securityLevel
protected int securityLevel - 
securityModel
protected int securityModel - 
securityName
 
 - 
 - 
Constructor Details
- 
AbstractTarget
protected AbstractTarget()Default constructor - 
AbstractTarget
Creates a SNMPv3 target with no retries and a timeout of one second.- Parameters:
 address- anAddressinstance.
 - 
AbstractTarget
 
 - 
 - 
Method Details
- 
getAddress
Gets the address of this target.- Specified by:
 getAddressin interfaceTarget- Returns:
 - an Address instance.
 
 - 
setAddress
Sets the address of the target.- Specified by:
 setAddressin interfaceTarget- Parameters:
 address- an Address instance.
 - 
setVersion
public void setVersion(int version) Sets the SNMP version (thus the SNMP message processing model) of the target.- Specified by:
 setVersionin interfaceTarget- Parameters:
 version- the message processing model ID.- See Also:
 
 - 
getVersion
public int getVersion()Gets the SNMP version (NMP messagen processing model) of the target.- Specified by:
 getVersionin interfaceTarget- Returns:
 - the message processing model ID.
 - See Also:
 
 - 
setRetries
public void setRetries(int retries) Sets the number of retries to be performed before a request is timed out.- Specified by:
 setRetriesin interfaceTarget- Parameters:
 retries- the number of retries. Note: If the number of retries is set to 0, then the request will be sent out exactly once.
 - 
getRetries
public int getRetries()Gets the number of retries.- Specified by:
 getRetriesin interfaceTarget- Returns:
 - an integer >= 0.
 
 - 
setTimeout
public void setTimeout(long timeout) Sets the timeout for a target.- Specified by:
 setTimeoutin interfaceTarget- Parameters:
 timeout- timeout in milliseconds before a confirmed request is resent or timed out.
 - 
getTimeout
public long getTimeout()Gets the timeout for a target.- Specified by:
 getTimeoutin interfaceTarget- Returns:
 - the timeout in milliseconds.
 
 - 
getMaxSizeRequestPDU
public int getMaxSizeRequestPDU()Gets the maximum size of request PDUs that this target is able to respond to. The default is 65535.- Specified by:
 getMaxSizeRequestPDUin interfaceTarget- Returns:
 - the maximum PDU size of request PDUs for this target. Which is always greater than 484.
 
 - 
setMaxSizeRequestPDU
public void setMaxSizeRequestPDU(int maxSizeRequestPDU) Sets the maximum size of request PDUs that this target is able to receive.- Specified by:
 setMaxSizeRequestPDUin interfaceTarget- Parameters:
 maxSizeRequestPDU- the maximum PDU (SNMP message) size this session will be able to process.
 - 
getPreferredTransports
Description copied from interface:TargetGets the prioritised list of transport mappings to be used for this target. The first mapping in the list that matches the target address is chosen for sending new requests.- Specified by:
 getPreferredTransportsin interfaceTarget- Returns:
 - an ordered list of 
TransportMappinginstances. 
 - 
setPreferredTransports
Sets the prioritised list of transport mappings to be used for this target. The first mapping in the list that matches the target address will be chosen for sending new requests. If the value is set tonull(default), the appropriateTransportMappingwill be chosen by the suppliedaddressof the target. If an entity supports more than oneTransportMappingfor anAddressclass, the the results are not defined. This situation can be controlled by setting this preferredTransports list.- Parameters:
 preferredTransports- a list of transport mappings that are preferred for this target class.- Since:
 - 2.0
 
 - 
toStringAbstractTarget
 - 
toString
 - 
clone
 - 
getSecurityModel
public int getSecurityModel()Description copied from interface:TargetGets the security model associated with this target.- Specified by:
 getSecurityModelin interfaceTarget- Returns:
 - an 
intvalue as defined in theSecurityModelinterface or any third party subclass thereof. 
 - 
getSecurityName
Description copied from interface:TargetGets the security name associated with this target. The security name is used by the security model to lookup further parameters like authentication and privacy protocol settings from the security model dependent internal storage.- Specified by:
 getSecurityNamein interfaceTarget- Returns:
 - an 
OctetStringinstance (nevernull). 
 - 
getSecurityLevel
public int getSecurityLevel()Description copied from interface:TargetGets the security level associated with this target.- Specified by:
 getSecurityLevelin interfaceTarget- Returns:
 - one of
 
 - 
setSecurityLevel
public void setSecurityLevel(int securityLevel) Sets the security level for this target. The supplied security level must be supported by the security model dependent information associated with the security name set for this target.- Specified by:
 setSecurityLevelin interfaceTarget- Parameters:
 securityLevel- one of
 - 
setSecurityModel
public void setSecurityModel(int securityModel) Sets the security model for this target.- Specified by:
 setSecurityModelin interfaceTarget- Parameters:
 securityModel- anintvalue as defined in theSecurityModelinterface or any third party subclass thereof.
 - 
setSecurityName
Sets the security name to be used with this target.- Specified by:
 setSecurityNamein interfaceTarget- Parameters:
 securityName- anOctetStringinstance (must not benull).- See Also:
 
 - 
equals
 - 
hashCode
public int hashCode() 
 -