< prev index next >

src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/NetMaskImpl.java

Print this page
rev 10793 : 8055723: Replace concat String to append in StringBuilder parameters


  48 class NetMaskImpl extends PrincipalImpl implements Group, Serializable {
  49     private static final long serialVersionUID = -7332541893877932896L;
  50 
  51     protected byte[] subnet = null;
  52     protected int prefix = -1;
  53     /**
  54      * Constructs an empty group.
  55      * @exception UnknownHostException Not implemented
  56      */
  57     public NetMaskImpl () throws UnknownHostException {
  58     }
  59 
  60     private byte[] extractSubNet(byte[] b) {
  61         int addrLength = b.length;
  62         byte[] subnet = null;
  63         if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
  64             SNMP_LOGGER.logp(Level.FINEST, NetMaskImpl.class.getName(),
  65                 "extractSubNet", "BINARY ARRAY :");
  66             StringBuilder sb = new StringBuilder();
  67             for(int i =0; i < addrLength; i++) {
  68                 sb.append((b[i] & 0xFF) + ":");
  69             }
  70             SNMP_LOGGER.logp(Level.FINEST, NetMaskImpl.class.getName(),
  71                 "extractSubNet", sb.toString());
  72         }
  73 
  74         // 8 is a byte size. Common to any InetAddress (V4 or V6).
  75         int fullyCoveredByte = prefix / 8;
  76         if(fullyCoveredByte == addrLength) {
  77             if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
  78                 SNMP_LOGGER.logp(Level.FINEST, NetMaskImpl.class.getName(), "extractSubNet",
  79                    "The mask is the complete address, strange..." + addrLength);
  80             }
  81             subnet = b;
  82             return subnet;
  83         }
  84         if(fullyCoveredByte > addrLength) {
  85             if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
  86                 SNMP_LOGGER.logp(Level.FINEST, NetMaskImpl.class.getName(), "extractSubNet",
  87                    "The number of covered byte is longer than the address. BUG");
  88             }




  48 class NetMaskImpl extends PrincipalImpl implements Group, Serializable {
  49     private static final long serialVersionUID = -7332541893877932896L;
  50 
  51     protected byte[] subnet = null;
  52     protected int prefix = -1;
  53     /**
  54      * Constructs an empty group.
  55      * @exception UnknownHostException Not implemented
  56      */
  57     public NetMaskImpl () throws UnknownHostException {
  58     }
  59 
  60     private byte[] extractSubNet(byte[] b) {
  61         int addrLength = b.length;
  62         byte[] subnet = null;
  63         if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
  64             SNMP_LOGGER.logp(Level.FINEST, NetMaskImpl.class.getName(),
  65                 "extractSubNet", "BINARY ARRAY :");
  66             StringBuilder sb = new StringBuilder();
  67             for(int i =0; i < addrLength; i++) {
  68                 sb.append(b[i] & 0xFF).append(':');
  69             }
  70             SNMP_LOGGER.logp(Level.FINEST, NetMaskImpl.class.getName(),
  71                 "extractSubNet", sb.toString());
  72         }
  73 
  74         // 8 is a byte size. Common to any InetAddress (V4 or V6).
  75         int fullyCoveredByte = prefix / 8;
  76         if(fullyCoveredByte == addrLength) {
  77             if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
  78                 SNMP_LOGGER.logp(Level.FINEST, NetMaskImpl.class.getName(), "extractSubNet",
  79                    "The mask is the complete address, strange..." + addrLength);
  80             }
  81             subnet = b;
  82             return subnet;
  83         }
  84         if(fullyCoveredByte > addrLength) {
  85             if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
  86                 SNMP_LOGGER.logp(Level.FINEST, NetMaskImpl.class.getName(), "extractSubNet",
  87                    "The number of covered byte is longer than the address. BUG");
  88             }


< prev index next >