Просмотр исходного кода

添加{}使代码更容易理解

Sxile лет назад: 5
Родитель
Сommit
2c250c1d1b

+ 12 - 6
ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/ip/IpUtils.java

@@ -110,8 +110,9 @@ public class IpUtils
110
             {
110
             {
111
                 case 1:
111
                 case 1:
112
                     l = Long.parseLong(elements[0]);
112
                     l = Long.parseLong(elements[0]);
113
-                    if ((l < 0L) || (l > 4294967295L))
113
+                    if ((l < 0L) || (l > 4294967295L)){
114
                         return null;
114
                         return null;
115
+                    }
115
                     bytes[0] = (byte) (int) (l >> 24 & 0xFF);
116
                     bytes[0] = (byte) (int) (l >> 24 & 0xFF);
116
                     bytes[1] = (byte) (int) ((l & 0xFFFFFF) >> 16 & 0xFF);
117
                     bytes[1] = (byte) (int) ((l & 0xFFFFFF) >> 16 & 0xFF);
117
                     bytes[2] = (byte) (int) ((l & 0xFFFF) >> 8 & 0xFF);
118
                     bytes[2] = (byte) (int) ((l & 0xFFFF) >> 8 & 0xFF);
@@ -119,12 +120,14 @@ public class IpUtils
119
                     break;
120
                     break;
120
                 case 2:
121
                 case 2:
121
                     l = Integer.parseInt(elements[0]);
122
                     l = Integer.parseInt(elements[0]);
122
-                    if ((l < 0L) || (l > 255L))
123
+                    if ((l < 0L) || (l > 255L)) {
123
                         return null;
124
                         return null;
125
+                    }
124
                     bytes[0] = (byte) (int) (l & 0xFF);
126
                     bytes[0] = (byte) (int) (l & 0xFF);
125
                     l = Integer.parseInt(elements[1]);
127
                     l = Integer.parseInt(elements[1]);
126
-                    if ((l < 0L) || (l > 16777215L))
128
+                    if ((l < 0L) || (l > 16777215L)) {
127
                         return null;
129
                         return null;
130
+                    }
128
                     bytes[1] = (byte) (int) (l >> 16 & 0xFF);
131
                     bytes[1] = (byte) (int) (l >> 16 & 0xFF);
129
                     bytes[2] = (byte) (int) ((l & 0xFFFF) >> 8 & 0xFF);
132
                     bytes[2] = (byte) (int) ((l & 0xFFFF) >> 8 & 0xFF);
130
                     bytes[3] = (byte) (int) (l & 0xFF);
133
                     bytes[3] = (byte) (int) (l & 0xFF);
@@ -133,13 +136,15 @@ public class IpUtils
133
                     for (i = 0; i < 2; ++i)
136
                     for (i = 0; i < 2; ++i)
134
                     {
137
                     {
135
                         l = Integer.parseInt(elements[i]);
138
                         l = Integer.parseInt(elements[i]);
136
-                        if ((l < 0L) || (l > 255L))
139
+                        if ((l < 0L) || (l > 255L)) {
137
                             return null;
140
                             return null;
141
+                        }
138
                         bytes[i] = (byte) (int) (l & 0xFF);
142
                         bytes[i] = (byte) (int) (l & 0xFF);
139
                     }
143
                     }
140
                     l = Integer.parseInt(elements[2]);
144
                     l = Integer.parseInt(elements[2]);
141
-                    if ((l < 0L) || (l > 65535L))
145
+                    if ((l < 0L) || (l > 65535L)) {
142
                         return null;
146
                         return null;
147
+                    }
143
                     bytes[2] = (byte) (int) (l >> 8 & 0xFF);
148
                     bytes[2] = (byte) (int) (l >> 8 & 0xFF);
144
                     bytes[3] = (byte) (int) (l & 0xFF);
149
                     bytes[3] = (byte) (int) (l & 0xFF);
145
                     break;
150
                     break;
@@ -147,8 +152,9 @@ public class IpUtils
147
                     for (i = 0; i < 4; ++i)
152
                     for (i = 0; i < 4; ++i)
148
                     {
153
                     {
149
                         l = Integer.parseInt(elements[i]);
154
                         l = Integer.parseInt(elements[i]);
150
-                        if ((l < 0L) || (l > 255L))
155
+                        if ((l < 0L) || (l > 255L)) {
151
                             return null;
156
                             return null;
157
+                        }
152
                         bytes[i] = (byte) (int) (l & 0xFF);
158
                         bytes[i] = (byte) (int) (l & 0xFF);
153
                     }
159
                     }
154
                     break;
160
                     break;