public abstract class AddressNetwork<S extends AddressSegment> extends Object implements Serializable
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.
Modifier and Type | Class and Description |
---|---|
static interface |
AddressNetwork.AddressSegmentCreator<S extends AddressSegment> |
static class |
AddressNetwork.HostIdentifierStringGenerator<T extends HostIdentifierString>
Generates and caches HostIdentifierString instances.
|
static class |
AddressNetwork.PrefixConfiguration
Prefix Handling Configuration
The library is designed to treat prefixes three different ways:
|
Constructor and Description |
---|
AddressNetwork() |
Modifier and Type | Method and Description |
---|---|
void |
clearCaches() |
abstract AddressCreator<?,?,?,S> |
getAddressCreator() |
static AddressNetwork.PrefixConfiguration |
getDefaultPrefixConfiguration() |
abstract AddressNetwork.PrefixConfiguration |
getPrefixConfiguration()
This method determines the prefix configuration in use by this network.
|
void |
setSegmentCaching(boolean enable) |
public abstract AddressCreator<?,?,?,S> getAddressCreator()
public void clearCaches()
public void setSegmentCaching(boolean enable)
public abstract AddressNetwork.PrefixConfiguration getPrefixConfiguration()
The prefix configuration determines whether a prefixed address like 1.2.0.0/16 results in a subnet block (ie 1.2.*.*) or just a single address (1.2.0.0) with a prefix length.
If you wish to change the default behaviour, you can either call inet.ipaddr.ipv4.IPv4AddressNetwork#setDefaultPrefixConfiguration(PrefixConfiguration)
,
or inet.ipaddr.ipv6.IPv6AddressNetwork#setDefaultPrefixConfiguration(PrefixConfiguration)
or you can override this method in your own network and use your own network for your addresses.
AddressNetwork.PrefixConfiguration
public static AddressNetwork.PrefixConfiguration getDefaultPrefixConfiguration()