
es.tid.ipnms.datamodel.misc.IPAddressUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of topology Show documentation
Show all versions of topology Show documentation
Traffic Engineering Database, BGP-LS peer, Topology Module
The newest version!
package es.tid.ipnms.datamodel.misc;
public class IPAddressUtils {
/**Parses input subnet and returns the longest prefix format*/
public static String parseSubnet(String input){
input=input.trim();
String temp = "";
if (input.length()<3){
int temp2 = Integer.parseInt(input);
if ((temp2<=32) && (temp2 >=0))
temp=Integer.toString(temp2);
}
else {
//input subnet is of type 255.255.255.0
//Get binary String represenation of the individual blocks in the subnet and concatenate to get single represenation
String finalString = "";
String[] temp1 = input.split("\\.");
for (int i=0;i255) || (x<0))
{
System.out.println("Error");
}
String binaryString = "";
for (int i=0;i<8;i++){
int y= x%2;
x=x/2;
binaryString = y + binaryString;
}
return binaryString;
}
public static void main (String[] args){
System.out.println(parseSubnetDotFormat("16"));
}
public static String parseSubnetDotFormat(String input) {
input=input.trim();
String temp = "";
if (input.length()<3){
int temp2 = Integer.parseInt(input);
if ((temp2<=32) && (temp2 >=0)){
for (int i=0;i<4;i++){
if (temp2>=8){
temp+="255.";
temp2=temp2-8;
}
else if (temp2==0){
temp+="0.";
}
else {
int temp3 = 0;
for (int j=0;j
© 2015 - 2025 Weber Informatics LLC | Privacy Policy