test_class.file: server/src/test/java/com/abiquo/abiserver/networking/IPNetworkRangTest.java
test_class.identifier: IPNetworkRangTest
test_case.body: @Test
      public void testLastIPAddressWithNumNodes() throws InvalidIPAddressException
      {
          IPAddress beginIP = IPAddress.newIPAddress("23.23.23.23");
          assertTrue(IPNetworkRang.lastIPAddressWithNumNodes(beginIP, 20).toString()
              .equalsIgnoreCase("23.23.23.42"));
          assertTrue(IPNetworkRang.lastIPAddressWithNumNodes(beginIP, 1293879).toString()
              .equalsIgnoreCase("23.42.213.77"));
          assertTrue(IPNetworkRang.lastIPAddressWithNumNodes(beginIP, 1).toString()
              .equalsIgnoreCase("23.23.23.23"));
          assertTrue(IPNetworkRang.lastIPAddressWithNumNodes(beginIP, 871287).toString()
              .equalsIgnoreCase("23.36.98.141"));
          assertTrue(IPNetworkRang.lastIPAddressWithNumNodes(beginIP, 4294967).toString()
              .equalsIgnoreCase("23.88.160.77"));
          assertNull(IPNetworkRang.lastIPAddressWithNumNodes(beginIP, 0));
          assertTrue(IPNetworkRang.lastIPAddressWithNumNodes(beginIP, 1).toString()
              .equalsIgnoreCase("23.23.23.23"));
          assertTrue(IPNetworkRang.lastIPAddressWithNumNodes(beginIP, 2).toString()
              .equalsIgnoreCase("23.23.23.24"));
          assertTrue(IPNetworkRang.lastIPAddressWithNumNodes(beginIP, 233).toString()
              .equalsIgnoreCase("23.23.23.255"));
          assertTrue(IPNetworkRang.lastIPAddressWithNumNodes(beginIP, 12343).toString()
              .equalsIgnoreCase("23.23.71.77"));
          assertTrue(IPNetworkRang.lastIPAddressWithNumNodes(beginIP, 78).toString()
              .equalsIgnoreCase("23.23.23.100"));
          assertTrue(IPNetworkRang.lastIPAddressWithNumNodes(beginIP, 123).toString()
              .equalsIgnoreCase("23.23.23.145"));
          assertTrue(IPNetworkRang.lastIPAddressWithNumNodes(beginIP, 16777216).toString()
              .equalsIgnoreCase("24.23.23.22"));
          assertTrue(IPNetworkRang.lastIPAddressWithNumNodes(beginIP, 65536).toString()
              .equalsIgnoreCase("23.24.23.22"));
          assertTrue(IPNetworkRang.lastIPAddressWithNumNodes(beginIP, 256).toString()
              .equalsIgnoreCase("23.23.24.22"));
          assertTrue(IPNetworkRang.lastIPAddressWithNumNodes(beginIP, 34).toString()
              .equalsIgnoreCase("23.23.23.56"));
  
          beginIP = IPAddress.newIPAddress("10.0.0.0");
          assertTrue(IPNetworkRang.lastIPAddressWithNumNodes(beginIP, 256).toString()
              .equalsIgnoreCase("10.0.0.255"));
      }
test_case.class_method_signature: IPNetworkRangTest.testLastIPAddressWithNumNodes()
test_case.full_signature: @Test public void testLastIPAddressWithNumNodes()
test_case.identifier: testLastIPAddressWithNumNodes
test_case.invocations: newIPAddress assertTrue equalsIgnoreCase toString lastIPAddressWithNumNodes assertTrue equalsIgnoreCase toString lastIPAddressWithNumNodes assertTrue equalsIgnoreCase toString lastIPAddressWithNumNodes assertTrue equalsIgnoreCase toString lastIPAddressWithNumNodes assertTrue equalsIgnoreCase toString lastIPAddressWithNumNodes assertNull lastIPAddressWithNumNodes assertTrue equalsIgnoreCase toString lastIPAddressWithNumNodes assertTrue equalsIgnoreCase toString lastIPAddressWithNumNodes assertTrue equalsIgnoreCase toString lastIPAddressWithNumNodes assertTrue equalsIgnoreCase toString lastIPAddressWithNumNodes assertTrue equalsIgnoreCase toString lastIPAddressWithNumNodes assertTrue equalsIgnoreCase toString lastIPAddressWithNumNodes assertTrue equalsIgnoreCase toString lastIPAddressWithNumNodes assertTrue equalsIgnoreCase toString lastIPAddressWithNumNodes assertTrue equalsIgnoreCase toString lastIPAddressWithNumNodes assertTrue equalsIgnoreCase toString lastIPAddressWithNumNodes newIPAddress assertTrue equalsIgnoreCase toString lastIPAddressWithNumNodes
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testLastIPAddressWithNumNodes()
focal_class.file: server/src/main/java/com/abiquo/abiserver/networking/IPNetworkRang.java
focal_class.identifier: IPNetworkRang
focal_class.class_method_signature: IPNetworkRang.masktoNumberOfNodes(Integer mask)
focal_class.full_signature: public static Integer masktoNumberOfNodes(Integer mask)
focal_class.identifier: masktoNumberOfNodes
focal_class.modifiers: public static
focal_class.parameters: (Integer mask)
focal_class.return: Integer
focal_class.signature: Integer masktoNumberOfNodes(Integer mask)
focal_class.class_method_signature: IPNetworkRang.numberOfNodesToMask(Integer numOfNodes)
focal_class.full_signature: public static Integer numberOfNodesToMask(Integer numOfNodes)
focal_class.identifier: numberOfNodesToMask
focal_class.modifiers: public static
focal_class.parameters: (Integer numOfNodes)
focal_class.return: Integer
focal_class.signature: Integer numberOfNodesToMask(Integer numOfNodes)
focal_class.class_method_signature: IPNetworkRang.transformIntegerMaskToIPMask(Integer mask)
focal_class.full_signature: public static IPAddress transformIntegerMaskToIPMask(Integer mask)
focal_class.identifier: transformIntegerMaskToIPMask
focal_class.modifiers: public static
focal_class.parameters: (Integer mask)
focal_class.return: IPAddress
focal_class.signature: IPAddress transformIntegerMaskToIPMask(Integer mask)
focal_class.class_method_signature: IPNetworkRang.calculateWholeRange(IPAddress networkAddress, Integer mask)
focal_class.full_signature: public static List<IPAddress> calculateWholeRange(IPAddress networkAddress, Integer mask)
focal_class.identifier: calculateWholeRange
focal_class.modifiers: public static
focal_class.parameters: (IPAddress networkAddress, Integer mask)
focal_class.return: List<IPAddress>
focal_class.signature: List<IPAddress> calculateWholeRange(IPAddress networkAddress, Integer mask)
focal_class.class_method_signature: IPNetworkRang.transformIPMaskToIntegerMask(IPAddress ipAddress)
focal_class.full_signature: public static Integer transformIPMaskToIntegerMask(IPAddress ipAddress)
focal_class.identifier: transformIPMaskToIntegerMask
focal_class.modifiers: public static
focal_class.parameters: (IPAddress ipAddress)
focal_class.return: Integer
focal_class.signature: Integer transformIPMaskToIntegerMask(IPAddress ipAddress)
focal_class.class_method_signature: IPNetworkRang.lastIPAddressWithNumNodes(IPAddress networkAddress,
          Integer numberOfNodes)
focal_class.full_signature: public static IPAddress lastIPAddressWithNumNodes(IPAddress networkAddress,
          Integer numberOfNodes)
focal_class.identifier: lastIPAddressWithNumNodes
focal_class.modifiers: public static
focal_class.parameters: (IPAddress networkAddress,
          Integer numberOfNodes)
focal_class.return: IPAddress
focal_class.signature: IPAddress lastIPAddressWithNumNodes(IPAddress networkAddress,
          Integer numberOfNodes)
focal_method.body: public static IPAddress lastIPAddressWithNumNodes(IPAddress networkAddress,
          Integer numberOfNodes) throws InvalidIPAddressException
      {
          // if we want 0 numberOfNodes it is an error, we return null
          if (numberOfNodes == 0)
          {
              return null;
          }
  
          // Please note if number of nodes is 1, we return the same IP
          // (if we have a first ip 10.0.0.1 and we want to know the last IP
          // with number of nodes = 1, it is the same IP... isn't it?)
          // So, the first we do is subtract 1
          Long numberOfNodesRemain = new Long(numberOfNodes);
          numberOfNodesRemain--;
  
          if (numberOfNodesRemain < new Long("4294967296"))
          {
              StringTokenizer tokenizer = new StringTokenizer(networkAddress.toString(), ".");
  
              // Thanks to the static method we can be sure we have 4 tokens
              // and they live between 0 and 256
              int tokenOne = Integer.parseInt(tokenizer.nextToken());
              int tokenTwo = Integer.parseInt(tokenizer.nextToken());
              int tokenThree = Integer.parseInt(tokenizer.nextToken());
              int tokenFour = Integer.parseInt(tokenizer.nextToken());
  
              while (numberOfNodesRemain > 0)
              {
                  if (numberOfNodesRemain > 16777216)
                  {
                      tokenOne = (tokenOne + 1) % 256;
                      numberOfNodesRemain -= 16777216;
                  }
                  else if (numberOfNodesRemain > 65536)
                  {
                      tokenTwo = (tokenTwo + 1) % 256;
                      if (tokenTwo == 0)
                      {
                          tokenOne = (tokenOne + 1) % 256;
                      }
                      numberOfNodesRemain -= 65536;
                  }
                  else if (numberOfNodesRemain > 256)
                  {
                      tokenThree = (tokenThree + 1) % 256;
                      if (tokenThree == 0)
                      {
                          tokenTwo = (tokenTwo + 1) % 256;
                          if (tokenTwo == 0)
                          {
                              tokenOne = (tokenOne + 1) % 256;
                          }
                      }
                      numberOfNodesRemain -= 256;
                  }
                  else
                  {
                      tokenFour = (tokenFour + 1) % 256;
  
                      if (tokenFour == 0)
                      {
                          tokenThree = (tokenThree + 1) % 256;
  
                          if (tokenThree == 0)
                          {
                              tokenTwo = (tokenTwo + 1) % 256;
                              if (tokenTwo == 0)
                              {
                                  tokenOne = (tokenOne + 1) % 256;
                              }
                          }
                      }
                      numberOfNodesRemain--;
                  }
  
              }
  
              return IPAddress.newIPAddress(tokenOne + "." + tokenTwo + "." + tokenThree + "."
                  + tokenFour);
          }
          else
          {
              throw new InvalidIPAddressException("To much values");
          }
  
      }
focal_method.class_method_signature: IPNetworkRang.lastIPAddressWithNumNodes(IPAddress networkAddress,
          Integer numberOfNodes)
focal_method.full_signature: public static IPAddress lastIPAddressWithNumNodes(IPAddress networkAddress,
          Integer numberOfNodes)
focal_method.identifier: lastIPAddressWithNumNodes
focal_method.invocations: toString parseInt nextToken parseInt nextToken parseInt nextToken parseInt nextToken newIPAddress
focal_method.modifiers: public static
focal_method.parameters: (IPAddress networkAddress,
          Integer numberOfNodes)
focal_method.return: IPAddress
focal_method.signature: IPAddress lastIPAddressWithNumNodes(IPAddress networkAddress,
          Integer numberOfNodes)