001
014
015 package com.liferay.portal.kernel.util;
016
017 import java.net.MalformedURLException;
018 import java.net.URI;
019 import java.net.URISyntaxException;
020 import java.net.URL;
021
022 import java.util.Arrays;
023 import java.util.regex.Matcher;
024 import java.util.regex.Pattern;
025
026
032 public class Validator {
033
034
042 public static boolean equals(boolean boolean1, boolean boolean2) {
043 if (boolean1 == boolean2) {
044 return true;
045 }
046 else {
047 return false;
048 }
049 }
050
051
059 public static boolean equals(byte byte1, byte byte2) {
060 if (byte1 == byte2) {
061 return true;
062 }
063 else {
064 return false;
065 }
066 }
067
068
076 public static boolean equals(char char1, char char2) {
077 if (char1 == char2) {
078 return true;
079 }
080 else {
081 return false;
082 }
083 }
084
085
093 public static boolean equals(double double1, double double2) {
094 if (Double.compare(double1, double2) == 0) {
095 return true;
096 }
097 else {
098 return false;
099 }
100 }
101
102
110 public static boolean equals(float float1, float float2) {
111 if (Float.compare(float1, float2) == 0) {
112 return true;
113 }
114 else {
115 return false;
116 }
117 }
118
119
127 public static boolean equals(int int1, int int2) {
128 if (int1 == int2) {
129 return true;
130 }
131 else {
132 return false;
133 }
134 }
135
136
144 public static boolean equals(long long1, long long2) {
145 if (long1 == long2) {
146 return true;
147 }
148 else {
149 return false;
150 }
151 }
152
153
162 public static boolean equals(Object obj1, Object obj2) {
163 if (obj1 == obj2) {
164 return true;
165 }
166 else if ((obj1 == null) || (obj2 == null)) {
167 return false;
168 }
169 else {
170 return obj1.equals(obj2);
171 }
172 }
173
174
182 public static boolean equals(short short1, short short2) {
183 if (short1 == short2) {
184 return true;
185 }
186 else {
187 return false;
188 }
189 }
190
191
199 public static boolean equalsSorted(
200 boolean[] booleanArray1, boolean[] booleanArray2) {
201
202 Boolean[] booleanObjArray1 = ArrayUtil.toArray(booleanArray1);
203
204 Arrays.sort(booleanObjArray1);
205
206 Boolean[] booleanObjArray2 = ArrayUtil.toArray(booleanArray2);
207
208 Arrays.sort(booleanObjArray2);
209
210 return Arrays.equals(booleanObjArray1, booleanObjArray2);
211 }
212
213
221 public static boolean equalsSorted(byte[] byteArray1, byte[] byteArray2) {
222 byteArray1 = ArrayUtil.clone(byteArray1);
223
224 Arrays.sort(byteArray1);
225
226 byteArray2 = ArrayUtil.clone(byteArray2);
227
228 Arrays.sort(byteArray2);
229
230 return Arrays.equals(byteArray1, byteArray2);
231 }
232
233
241 public static boolean equalsSorted(char[] charArray1, char[] charArray2) {
242 charArray1 = ArrayUtil.clone(charArray1);
243
244 Arrays.sort(charArray1);
245
246 charArray2 = ArrayUtil.clone(charArray2);
247
248 Arrays.sort(charArray2);
249
250 return Arrays.equals(charArray1, charArray2);
251 }
252
253
261 public static boolean equalsSorted(
262 double[] doubleArray1, double[] doubleArray2) {
263
264 doubleArray1 = ArrayUtil.clone(doubleArray1);
265
266 Arrays.sort(doubleArray1);
267
268 doubleArray2 = ArrayUtil.clone(doubleArray2);
269
270 Arrays.sort(doubleArray2);
271
272 return Arrays.equals(doubleArray1, doubleArray2);
273 }
274
275
283 public static boolean equalsSorted(
284 float[] floatArray1, float[] floatArray2) {
285
286 floatArray1 = ArrayUtil.clone(floatArray1);
287
288 Arrays.sort(floatArray1);
289
290 floatArray2 = ArrayUtil.clone(floatArray2);
291
292 Arrays.sort(floatArray2);
293
294 return Arrays.equals(floatArray1, floatArray2);
295 }
296
297
305 public static boolean equalsSorted(int[] intArray1, int[] intArray2) {
306 intArray1 = ArrayUtil.clone(intArray1);
307
308 Arrays.sort(intArray1);
309
310 intArray2 = ArrayUtil.clone(intArray2);
311
312 Arrays.sort(intArray2);
313
314 return Arrays.equals(intArray1, intArray2);
315 }
316
317
325 public static boolean equalsSorted(long[] longArray1, long[] longArray2) {
326 longArray1 = ArrayUtil.clone(longArray1);
327
328 Arrays.sort(longArray1);
329
330 longArray2 = ArrayUtil.clone(longArray2);
331
332 Arrays.sort(longArray2);
333
334 return Arrays.equals(longArray1, longArray2);
335 }
336
337
345 public static boolean equalsSorted(Object[] objArray1, Object[] objArray2) {
346 objArray1 = ArrayUtil.clone(objArray1);
347
348 Arrays.sort(objArray1);
349
350 objArray2 = ArrayUtil.clone(objArray2);
351
352 Arrays.sort(objArray2);
353
354 return Arrays.equals(objArray1, objArray2);
355 }
356
357
365 public static boolean equalsSorted(
366 short[] shortArray1, short[] shortArray2) {
367
368 shortArray1 = ArrayUtil.clone(shortArray1);
369
370 Arrays.sort(shortArray1);
371
372 shortArray2 = ArrayUtil.clone(shortArray2);
373
374 Arrays.sort(shortArray2);
375
376 return Arrays.equals(shortArray1, shortArray2);
377 }
378
379
388 public static boolean isAddress(String address) {
389 if (isNull(address)) {
390 return false;
391 }
392
393 String[] tokens = address.split(StringPool.AT);
394
395 if (tokens.length != 2) {
396 return false;
397 }
398
399 for (String token : tokens) {
400 for (char c : token.toCharArray()) {
401 if (Character.isWhitespace(c)) {
402 return false;
403 }
404 }
405 }
406
407 return true;
408 }
409
410
418 public static boolean isAlphanumericName(String name) {
419 if (isNull(name)) {
420 return false;
421 }
422
423 for (char c : name.trim().toCharArray()) {
424 if (!isChar(c) && !isDigit(c) && !Character.isWhitespace(c)) {
425 return false;
426 }
427 }
428
429 return true;
430 }
431
432
441 public static boolean isAscii(char c) {
442 int i = c;
443
444 if ((i >= 32) && (i <= 126)) {
445 return true;
446 }
447 else {
448 return false;
449 }
450 }
451
452 public static boolean isBlank(String s) {
453 if (s == null) {
454 return true;
455 }
456
457 if (s.length() == 0) {
458 return true;
459 }
460
461 return false;
462 }
463
464 public static boolean isBoolean(String value) {
465 return ArrayUtil.contains(_BOOLEANS, value);
466 }
467
468
476 public static boolean isChar(char c) {
477 int x = c;
478
479 if (((x >= _CHAR_LOWER_CASE_BEGIN) && (x <= _CHAR_LOWER_CASE_END)) ||
480 ((x >= _CHAR_UPPER_CASE_BEGIN) && (x <= _CHAR_UPPER_CASE_END))) {
481
482 return true;
483 }
484
485 return false;
486 }
487
488
496 public static boolean isChar(String s) {
497 if (isNull(s)) {
498 return false;
499 }
500
501 for (char c : s.toCharArray()) {
502 if (!isChar(c)) {
503 return false;
504 }
505 }
506
507 return true;
508 }
509
510
518 public static boolean isContent(String s) {
519 if (isNotNull(
520 StringUtil.replace(
521 s, new String[] {StringPool.NEW_LINE, StringPool.TAB},
522 new String[] {StringPool.BLANK, StringPool.BLANK}))) {
523
524 return true;
525 }
526
527 return false;
528 }
529
530
539 public static boolean isDate(int month, int day, int year) {
540 return isGregorianDate(month, day, year);
541 }
542
543
551 public static boolean isDigit(char c) {
552 int x = c;
553
554 if ((x >= _DIGIT_BEGIN) && (x <= _DIGIT_END)) {
555 return true;
556 }
557
558 return false;
559 }
560
561
569 public static boolean isDigit(String s) {
570 if (isNull(s)) {
571 return false;
572 }
573
574 for (char c : s.toCharArray()) {
575 if (!isDigit(c)) {
576 return false;
577 }
578 }
579
580 return true;
581 }
582
583
592 public static boolean isDomain(String domainName) {
593
594
595
596
597 if (isNull(domainName)) {
598 return false;
599 }
600
601 if (domainName.length() > 255) {
602 return false;
603 }
604
605 if (domainName.startsWith(StringPool.PERIOD)) {
606 return false;
607 }
608
609 String[] domainNameArray = StringUtil.split(
610 domainName, CharPool.PERIOD);
611
612 for (String domainNamePart : domainNameArray) {
613 char[] domainNamePartCharArray = domainNamePart.toCharArray();
614
615 for (int i = 0; i < domainNamePartCharArray.length; i++) {
616 char c = domainNamePartCharArray[i];
617
618 if ((i == 0) && (c == CharPool.DASH)) {
619 return false;
620 }
621
622 if ((i == (domainNamePartCharArray.length - 1)) &&
623 (c == CharPool.DASH)) {
624
625 return false;
626 }
627
628 if (!Character.isLetterOrDigit(c) && (c != CharPool.DASH)) {
629 return false;
630 }
631 }
632 }
633
634 return true;
635 }
636
637
644 public static boolean isEmailAddress(String emailAddress) {
645 Matcher matcher = _emailAddressPattern.matcher(emailAddress);
646
647 return matcher.matches();
648 }
649
650
658 public static boolean isEmailAddressSpecialChar(char c) {
659
660
661
662 for (char specialChar : _EMAIL_ADDRESS_SPECIAL_CHAR) {
663 if (c == specialChar) {
664 return true;
665 }
666 }
667
668 return false;
669 }
670
671
678 public static boolean isFileExtension(String fileExtension) {
679 if (isNull(fileExtension) ||
680 fileExtension.contains(StringPool.BACK_SLASH) ||
681 fileExtension.contains(StringPool.NULL_CHAR) ||
682 fileExtension.contains(StringPool.SLASH)) {
683
684 return false;
685 }
686
687 return true;
688 }
689
690 public static boolean isFileName(String name) {
691 if (isNull(name) || name.equals(StringPool.PERIOD) ||
692 name.equals(StringPool.DOUBLE_PERIOD) ||
693 name.contains(StringPool.BACK_SLASH) ||
694 name.contains(StringPool.NULL_CHAR) ||
695 name.contains(StringPool.SLASH)) {
696
697 return false;
698 }
699
700 return true;
701 }
702
703 public static boolean isFilePath(String path, boolean isParentDirAllowed) {
704 if (isNull(path)) {
705 return false;
706 }
707
708 if (path.contains(StringPool.NULL_CHAR)) {
709 return false;
710 }
711
712 if (isParentDirAllowed) {
713 return true;
714 }
715
716 if (path.equals(StringPool.DOUBLE_PERIOD)) {
717 return false;
718 }
719
720 String normalizedPath = path.replace(
721 CharPool.BACK_SLASH, CharPool.SLASH);
722
723 if (normalizedPath.startsWith(
724 StringPool.DOUBLE_PERIOD.concat(StringPool.SLASH))) {
725
726 return false;
727 }
728
729 if (normalizedPath.endsWith(
730 StringPool.SLASH.concat(StringPool.DOUBLE_PERIOD))) {
731
732 return false;
733 }
734
735 if (normalizedPath.contains(
736 StringPool.SLASH.concat(
737 StringPool.DOUBLE_PERIOD).concat(StringPool.SLASH))) {
738
739 return false;
740 }
741
742 return true;
743 }
744
745
754 public static boolean isGregorianDate(int month, int day, int year) {
755 if ((month < 0) || (month > 11)) {
756 return false;
757 }
758
759 int[] months = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
760
761 if (month == 1) {
762 int febMax = 28;
763
764 if (((year % 4) == 0) && ((year % 100) != 0) ||
765 ((year % 400) == 0)) {
766
767 febMax = 29;
768 }
769
770 if ((day < 1) || (day > febMax)) {
771 return false;
772 }
773 }
774 else if ((day < 1) || (day > months[month])) {
775 return false;
776 }
777
778 return true;
779 }
780
781
791 public static boolean isHex(String s) {
792 if (isNull(s)) {
793 return false;
794 }
795
796 return true;
797 }
798
799
806 public static boolean isHostName(String name) {
807 if (isNull(name)) {
808 return false;
809 }
810
811 char[] nameCharArray = name.toCharArray();
812
813 if ((nameCharArray[0] == CharPool.DASH) ||
814 (nameCharArray[0] == CharPool.PERIOD) ||
815 (nameCharArray[nameCharArray.length - 1] == CharPool.DASH)) {
816
817 return false;
818 }
819
820 for (char c : nameCharArray) {
821 if (!isChar(c) && !isDigit(c) && (c != CharPool.CLOSE_BRACKET) &&
822 (c != CharPool.COLON) && (c != CharPool.DASH) &&
823 (c != CharPool.OPEN_BRACKET) && (c != CharPool.PERIOD)) {
824
825 return false;
826 }
827 }
828
829 return true;
830 }
831
832
840 public static boolean isHTML(String s) {
841 if (isNull(s)) {
842 return false;
843 }
844
845 if ((s.contains("<html>") || s.contains("<HTML>")) &&
846 (s.contains("</html>") || s.contains("</HTML>"))) {
847
848 return true;
849 }
850
851 return false;
852 }
853
854
862 public static boolean isIPAddress(String ipAddress) {
863 if (isIPv4Address(ipAddress) || isIPv6Address(ipAddress)) {
864 return true;
865 }
866
867 return false;
868 }
869
870
877 public static boolean isIPv4Address(String ipAddress) {
878 Matcher matcher = _ipv4AddressPattern.matcher(ipAddress);
879
880 return matcher.matches();
881 }
882
883
890 public static boolean isIPv6Address(String ipAddress) {
891 if (isNull(ipAddress)) {
892 return false;
893 }
894
895 if (StringUtil.startsWith(ipAddress, CharPool.OPEN_BRACKET) &&
896 StringUtil.endsWith(ipAddress, CharPool.CLOSE_BRACKET)) {
897
898 ipAddress = ipAddress.substring(1, ipAddress.length() - 1);
899 }
900
901 Matcher matcher = _ipv6AddressPattern.matcher(ipAddress);
902
903 return matcher.matches();
904 }
905
906
915 public static boolean isJulianDate(int month, int day, int year) {
916 if ((month < 0) || (month > 11)) {
917 return false;
918 }
919
920 int[] months = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
921
922 if (month == 1) {
923 int febMax = 28;
924
925 if ((year % 4) == 0) {
926 febMax = 29;
927 }
928
929 if ((day < 1) || (day > febMax)) {
930 return false;
931 }
932 }
933 else if ((day < 1) || (day > months[month])) {
934 return false;
935 }
936
937 return true;
938 }
939
940
948 public static boolean isLUHN(String number) {
949 if (number == null) {
950 return false;
951 }
952
953 number = StringUtil.reverse(number);
954
955 int total = 0;
956
957 for (int i = 0; i < number.length(); i++) {
958 int x = 0;
959
960 if (((i + 1) % 2) == 0) {
961 x = GetterUtil.getInteger(number.substring(i, i + 1)) * 2;
962
963 if (x >= 10) {
964 String s = String.valueOf(x);
965
966 x =
967 GetterUtil.getInteger(s.substring(0, 1)) +
968 GetterUtil.getInteger(s.substring(1, 2));
969 }
970 }
971 else {
972 x = GetterUtil.getInteger(number.substring(i, i + 1));
973 }
974
975 total = total + x;
976 }
977
978 if ((total % 10) == 0) {
979 return true;
980 }
981 else {
982 return false;
983 }
984 }
985
986
994 public static boolean isName(String name) {
995 if (isNull(name)) {
996 return false;
997 }
998
999 for (char c : name.trim().toCharArray()) {
1000 if (!isChar(c) && !Character.isWhitespace(c)) {
1001 return false;
1002 }
1003 }
1004
1005 return true;
1006 }
1007
1008
1017 public static boolean isNotNull(Long l) {
1018 return !isNull(l);
1019 }
1020
1021
1030 public static boolean isNotNull(Object obj) {
1031 return !isNull(obj);
1032 }
1033
1034
1038 @Deprecated
1039 public static boolean isNotNull(Object[] array) {
1040 return ArrayUtil.isNotEmpty(array);
1041 }
1042
1043
1052 public static boolean isNotNull(String s) {
1053 return !isNull(s);
1054 }
1055
1056
1064 public static boolean isNull(Long l) {
1065 if ((l == null) || (l.longValue() == 0)) {
1066 return true;
1067 }
1068 else {
1069 return false;
1070 }
1071 }
1072
1073
1082 public static boolean isNull(Object obj) {
1083 if (obj instanceof Long) {
1084 return isNull((Long)obj);
1085 }
1086 else if (obj instanceof String) {
1087 return isNull((String)obj);
1088 }
1089 else if (obj == null) {
1090 return true;
1091 }
1092 else {
1093 return false;
1094 }
1095 }
1096
1097
1100 @Deprecated
1101 public static boolean isNull(Object[] array) {
1102 return ArrayUtil.isEmpty(array);
1103 }
1104
1105
1114 public static boolean isNull(String s) {
1115 if (s == null) {
1116 return true;
1117 }
1118
1119 int counter = 0;
1120
1121 for (int i = 0; i < s.length(); i++) {
1122 char c = s.charAt(i);
1123
1124 if (c == CharPool.SPACE) {
1125 continue;
1126 }
1127 else if (counter > 3) {
1128 return false;
1129 }
1130
1131 if (counter == 0) {
1132 if (c != CharPool.LOWER_CASE_N) {
1133 return false;
1134 }
1135 }
1136 else if (counter == 1) {
1137 if (c != CharPool.LOWER_CASE_U) {
1138 return false;
1139 }
1140 }
1141 else if ((counter == 2) || (counter == 3)) {
1142 if (c != CharPool.LOWER_CASE_L) {
1143 return false;
1144 }
1145 }
1146
1147 counter++;
1148 }
1149
1150 if ((counter == 0) || (counter == 4)) {
1151 return true;
1152 }
1153
1154 return false;
1155 }
1156
1157
1165 public static boolean isNumber(String number) {
1166 if (isNull(number)) {
1167 return false;
1168 }
1169
1170 for (char c : number.toCharArray()) {
1171 if (!isDigit(c)) {
1172 return false;
1173 }
1174 }
1175
1176 return true;
1177 }
1178
1179
1188 public static boolean isPassword(String password) {
1189 if (isNull(password)) {
1190 return false;
1191 }
1192
1193 if (password.length() < 4) {
1194 return false;
1195 }
1196
1197 for (char c : password.toCharArray()) {
1198 if (!isChar(c) && !isDigit(c)) {
1199 return false;
1200 }
1201 }
1202
1203 return true;
1204 }
1205
1206
1215 public static boolean isPhoneNumber(String phoneNumber) {
1216 return isNumber(StringUtil.extractDigits(phoneNumber));
1217 }
1218
1219 public static boolean isUri(String uri) {
1220 if (isNotNull(uri)) {
1221 try {
1222 new URI(uri);
1223
1224 return true;
1225 }
1226 catch (URISyntaxException urise) {
1227 }
1228 }
1229
1230 return false;
1231 }
1232
1233
1241 public static boolean isUrl(String url) {
1242 if (isNotNull(url)) {
1243 if (url.indexOf(CharPool.COLON) == -1) {
1244 return false;
1245 }
1246
1247 try {
1248 new URL(url);
1249
1250 return true;
1251 }
1252 catch (MalformedURLException murle) {
1253 }
1254 }
1255
1256 return false;
1257 }
1258
1259
1266 public static boolean isVariableName(String variableName) {
1267 if (isNull(variableName)) {
1268 return false;
1269 }
1270
1271 Matcher matcher = _variableNamePattern.matcher(variableName);
1272
1273 if (matcher.matches()) {
1274 return true;
1275 }
1276 else {
1277 return false;
1278 }
1279 }
1280
1281
1289 public static boolean isVariableTerm(String s) {
1290 if (s.startsWith(_VARIABLE_TERM_BEGIN) &&
1291 s.endsWith(_VARIABLE_TERM_END)) {
1292
1293 return true;
1294 }
1295 else {
1296 return false;
1297 }
1298 }
1299
1300
1309 public static boolean isWhitespace(char c) {
1310 int i = c;
1311
1312 if ((i == 0) || Character.isWhitespace(c)) {
1313 return true;
1314 }
1315 else {
1316 return false;
1317 }
1318 }
1319
1320
1329 public static boolean isXml(String s) {
1330 if (isNull(s)) {
1331 return false;
1332 }
1333 else if (s.startsWith(_XML_BEGIN) || s.startsWith(_XML_EMPTY)) {
1334 return true;
1335 }
1336 else {
1337 return false;
1338 }
1339 }
1340
1341 private static final String[] _BOOLEANS = {"false", "on", "off", "true"};
1342
1343 private static final int _CHAR_LOWER_CASE_BEGIN = 97;
1344
1345 private static final int _CHAR_LOWER_CASE_END = 122;
1346
1347 private static final int _CHAR_UPPER_CASE_BEGIN = 65;
1348
1349 private static final int _CHAR_UPPER_CASE_END = 90;
1350
1351 private static final int _DIGIT_BEGIN = 48;
1352
1353 private static final int _DIGIT_END = 57;
1354
1355 private static final char[] _EMAIL_ADDRESS_SPECIAL_CHAR = new char[] {
1356 '.', '!', '#', '$', '%', '&', '\'', '*', '+', '-', '/', '=', '?', '^',
1357 '_', '`', '{', '|', '}', '~'
1358 };
1359
1360 private static final String _VARIABLE_TERM_BEGIN = "[$";
1361
1362 private static final String _VARIABLE_TERM_END = "$]";
1363
1364 private static final String _XML_BEGIN = "<?xml";
1365
1366 private static final String _XML_EMPTY = "<root />";
1367
1368 private static final Pattern _emailAddressPattern = Pattern.compile(
1369 "[\\w!#$%&'*+/=?^_`{|}~-]+(?:\\.[\\w!#$%&'*+/=?^_`{|}~-]+)*@" +
1370 "(?:[a-zA-Z0-9](?:-*[a-zA-Z0-9])?\\.*)+");
1371 private static final Pattern _ipv4AddressPattern = Pattern.compile(
1372 "^" +
1373 "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\." +
1374 "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\." +
1375 "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\." +
1376 "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)" +
1377 "$");
1378 private static final Pattern _ipv6AddressPattern = Pattern.compile(
1379 "^" +
1380 "\\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|" +
1381 "(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|" +
1382 "((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)" +
1383 "(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|" +
1384 "(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:" +
1385 "((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)" +
1386 "(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|" +
1387 "(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|" +
1388 "((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)" +
1389 "(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|" +
1390 "(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|" +
1391 "((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)" +
1392 "(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|" +
1393 "(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|" +
1394 "((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)" +
1395 "(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|" +
1396 "(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|" +
1397 "((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)" +
1398 "(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|" +
1399 "(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:" +
1400 "((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\." +
1401 "(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:)))(%.+)?\\s*" +
1402 "$");
1403 private static final Pattern _variableNamePattern = Pattern.compile(
1404 "[_a-zA-Z]+[_a-zA-Z0-9]*");
1405
1406 }