Module inet.ipaddr
Package inet.ipaddr

Class AddressNetwork<S extends AddressSegment>

java.lang.Object
inet.ipaddr.AddressNetwork<S>
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
IPAddressNetwork, MACAddressNetwork

public abstract class AddressNetwork<S extends AddressSegment> extends Object implements Serializable
An object representing a collection of addresses.

It also encapsulates settings for handling all addresses in the network like the prefix configuration that determines certain properties of the addresses in the network.

If your use of the IPAddress library has non-default configuration settings in this AddressNetwork class, and within the same JVM the IPAddress library is being used elsewhere with different configuration settings, then you have two options available to you:

1. Use classloaders to load the two uses of IPAddress in different classloaders, a common Java architecture that is part of the language itself to address just this issue

2. Use your own network classes, and within them overide the configuration methods to return the values you desire.

All access to the network classes is through public virtual accessor methods getNetwork or getXNetwork in the classes XAddress, XAddressSection, XAddressSegment where X is one of MAC, IPv6, or IPv4. So you need to subclass those classes, and then override those getNetwork and getXNetwork methods to return your own network instances. There are a couple of other places to consider to ensure only your own network instances are used. XAddressString objects obtain their network object from the validation parameters supplied to the constructor, so you would customize those validation parameters as well. The same is true for the HostName class, which uses an embedded address validation instance inside the host name parameters instance. Finally, the address generator/cache classes (that are nested classes that in the network) use validation parameters as well that would be customized to your own network instances.

Generally you would use the same network object for any given address type (ie one for IPv6, one for IPv4, one for MAC), although this is not necessary. However, it is necessary that the configuration is the same for any given address type.

Now suppose you wish to ensure any and all methods in this library create instances of your own subclasses of the XAddress, XAddressSection, XAddressSegment classes. All internally created address components are created by the address creator instance owned by the network object. So you override the getAddressCreator() in your new network classes to provide your own address creator object.

Author:
sfoley
See Also: