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
472 public static boolean isChar(char c) {
473 int x = c;
474
475 if (((x >= _CHAR_LOWER_CASE_BEGIN) && (x <= _CHAR_LOWER_CASE_END)) ||
476 ((x >= _CHAR_UPPER_CASE_BEGIN) && (x <= _CHAR_UPPER_CASE_END))) {
477
478 return true;
479 }
480
481 return false;
482 }
483
484
492 public static boolean isChar(String s) {
493 if (isNull(s)) {
494 return false;
495 }
496
497 for (char c : s.toCharArray()) {
498 if (!isChar(c)) {
499 return false;
500 }
501 }
502
503 return true;
504 }
505
506
515 public static boolean isDate(int month, int day, int year) {
516 return isGregorianDate(month, day, year);
517 }
518
519
527 public static boolean isDigit(char c) {
528 int x = c;
529
530 if ((x >= _DIGIT_BEGIN) && (x <= _DIGIT_END)) {
531 return true;
532 }
533
534 return false;
535 }
536
537
545 public static boolean isDigit(String s) {
546 if (isNull(s)) {
547 return false;
548 }
549
550 for (char c : s.toCharArray()) {
551 if (!isDigit(c)) {
552 return false;
553 }
554 }
555
556 return true;
557 }
558
559
568 public static boolean isDomain(String domainName) {
569
570
571
572
573 if (isNull(domainName)) {
574 return false;
575 }
576
577 if (domainName.length() > 255) {
578 return false;
579 }
580
581 if (domainName.startsWith(StringPool.PERIOD)) {
582 return false;
583 }
584
585 String[] domainNameArray = StringUtil.split(
586 domainName, CharPool.PERIOD);
587
588 for (String domainNamePart : domainNameArray) {
589 char[] domainNamePartCharArray = domainNamePart.toCharArray();
590
591 for (int i = 0; i < domainNamePartCharArray.length; i++) {
592 char c = domainNamePartCharArray[i];
593
594 if ((i == 0) && (c == CharPool.DASH)) {
595 return false;
596 }
597
598 if ((i == (domainNamePartCharArray.length - 1)) &&
599 (c == CharPool.DASH)) {
600
601 return false;
602 }
603
604 if (!Character.isLetterOrDigit(c) && (c != CharPool.DASH)) {
605 return false;
606 }
607 }
608 }
609
610 return true;
611 }
612
613
620 public static boolean isEmailAddress(String emailAddress) {
621 Matcher matcher = _emailAddressPattern.matcher(emailAddress);
622
623 return matcher.matches();
624 }
625
626
634 public static boolean isEmailAddressSpecialChar(char c) {
635
636
637
638 for (char specialChar : _EMAIL_ADDRESS_SPECIAL_CHAR) {
639 if (c == specialChar) {
640 return true;
641 }
642 }
643
644 return false;
645 }
646
647
654 public static boolean isFileExtension(String fileExtension) {
655 if (isNull(fileExtension) ||
656 fileExtension.contains(StringPool.BACK_SLASH) ||
657 fileExtension.contains(StringPool.NULL_CHAR) ||
658 fileExtension.contains(StringPool.SLASH)) {
659
660 return false;
661 }
662
663 return true;
664 }
665
666 public static boolean isFileName(String name) {
667 if (isNull(name) || name.equals(StringPool.PERIOD) ||
668 name.equals(StringPool.DOUBLE_PERIOD) ||
669 name.contains(StringPool.BACK_SLASH) ||
670 name.contains(StringPool.NULL_CHAR) ||
671 name.contains(StringPool.SLASH)) {
672
673 return false;
674 }
675
676 return true;
677 }
678
679 public static boolean isFilePath(String path, boolean isParentDirAllowed) {
680 if (isNull(path)) {
681 return false;
682 }
683
684 if (path.contains(StringPool.NULL_CHAR)) {
685 return false;
686 }
687
688 if (isParentDirAllowed) {
689 return true;
690 }
691
692 if (path.equals(StringPool.DOUBLE_PERIOD)) {
693 return false;
694 }
695
696 String normalizedPath = path.replace(
697 CharPool.BACK_SLASH, CharPool.SLASH);
698
699 if (normalizedPath.startsWith(
700 StringPool.DOUBLE_PERIOD.concat(StringPool.SLASH))) {
701
702 return false;
703 }
704
705 if (normalizedPath.endsWith(
706 StringPool.SLASH.concat(StringPool.DOUBLE_PERIOD))) {
707
708 return false;
709 }
710
711 if (normalizedPath.contains(
712 StringPool.SLASH.concat(
713 StringPool.DOUBLE_PERIOD).concat(StringPool.SLASH))) {
714
715 return false;
716 }
717
718 return true;
719 }
720
721
730 public static boolean isGregorianDate(int month, int day, int year) {
731 if ((month < 0) || (month > 11)) {
732 return false;
733 }
734
735 int[] months = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
736
737 if (month == 1) {
738 int febMax = 28;
739
740 if (((year % 4) == 0) && ((year % 100) != 0) ||
741 ((year % 400) == 0)) {
742
743 febMax = 29;
744 }
745
746 if ((day < 1) || (day > febMax)) {
747 return false;
748 }
749 }
750 else if ((day < 1) || (day > months[month])) {
751 return false;
752 }
753
754 return true;
755 }
756
757
767 public static boolean isHex(String s) {
768 if (isNull(s)) {
769 return false;
770 }
771
772 return true;
773 }
774
775
782 public static boolean isHostName(String name) {
783 if (isNull(name)) {
784 return false;
785 }
786
787 char[] nameCharArray = name.toCharArray();
788
789 if ((nameCharArray[0] == CharPool.DASH) ||
790 (nameCharArray[0] == CharPool.PERIOD) ||
791 (nameCharArray[nameCharArray.length - 1] == CharPool.DASH)) {
792
793 return false;
794 }
795
796 for (char c : nameCharArray) {
797 if (!isChar(c) && !isDigit(c) && (c != CharPool.CLOSE_BRACKET) &&
798 (c != CharPool.COLON) && (c != CharPool.DASH) &&
799 (c != CharPool.OPEN_BRACKET) && (c != CharPool.PERIOD)) {
800
801 return false;
802 }
803 }
804
805 return true;
806 }
807
808
816 public static boolean isHTML(String s) {
817 if (isNull(s)) {
818 return false;
819 }
820
821 if ((s.contains("<html>") || s.contains("<HTML>")) &&
822 (s.contains("</html>") || s.contains("</HTML>"))) {
823
824 return true;
825 }
826
827 return false;
828 }
829
830
838 public static boolean isIPAddress(String ipAddress) {
839 if (isIPv4Address(ipAddress) || isIPv6Address(ipAddress)) {
840 return true;
841 }
842
843 return false;
844 }
845
846
853 public static boolean isIPv4Address(String ipAddress) {
854 Matcher matcher = _ipv4AddressPattern.matcher(ipAddress);
855
856 return matcher.matches();
857 }
858
859
866 public static boolean isIPv6Address(String ipAddress) {
867 if (isNull(ipAddress)) {
868 return false;
869 }
870
871 if (StringUtil.startsWith(ipAddress, CharPool.OPEN_BRACKET) &&
872 StringUtil.endsWith(ipAddress, CharPool.CLOSE_BRACKET)) {
873
874 ipAddress = ipAddress.substring(1, ipAddress.length() - 1);
875 }
876
877 Matcher matcher = _ipv6AddressPattern.matcher(ipAddress);
878
879 return matcher.matches();
880 }
881
882
891 public static boolean isJulianDate(int month, int day, int year) {
892 if ((month < 0) || (month > 11)) {
893 return false;
894 }
895
896 int[] months = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
897
898 if (month == 1) {
899 int febMax = 28;
900
901 if ((year % 4) == 0) {
902 febMax = 29;
903 }
904
905 if ((day < 1) || (day > febMax)) {
906 return false;
907 }
908 }
909 else if ((day < 1) || (day > months[month])) {
910 return false;
911 }
912
913 return true;
914 }
915
916
924 public static boolean isLUHN(String number) {
925 if (number == null) {
926 return false;
927 }
928
929 number = StringUtil.reverse(number);
930
931 int total = 0;
932
933 for (int i = 0; i < number.length(); i++) {
934 int x = 0;
935
936 if (((i + 1) % 2) == 0) {
937 x = GetterUtil.getInteger(number.substring(i, i + 1)) * 2;
938
939 if (x >= 10) {
940 String s = String.valueOf(x);
941
942 x =
943 GetterUtil.getInteger(s.substring(0, 1)) +
944 GetterUtil.getInteger(s.substring(1, 2));
945 }
946 }
947 else {
948 x = GetterUtil.getInteger(number.substring(i, i + 1));
949 }
950
951 total = total + x;
952 }
953
954 if ((total % 10) == 0) {
955 return true;
956 }
957 else {
958 return false;
959 }
960 }
961
962
970 public static boolean isName(String name) {
971 if (isNull(name)) {
972 return false;
973 }
974
975 for (char c : name.trim().toCharArray()) {
976 if (!isChar(c) && !Character.isWhitespace(c)) {
977 return false;
978 }
979 }
980
981 return true;
982 }
983
984
993 public static boolean isNotNull(Long l) {
994 return !isNull(l);
995 }
996
997
1006 public static boolean isNotNull(Object obj) {
1007 return !isNull(obj);
1008 }
1009
1010
1014 public static boolean isNotNull(Object[] array) {
1015 return ArrayUtil.isNotEmpty(array);
1016 }
1017
1018
1027 public static boolean isNotNull(String s) {
1028 return !isNull(s);
1029 }
1030
1031
1039 public static boolean isNull(Long l) {
1040 if ((l == null) || (l.longValue() == 0)) {
1041 return true;
1042 }
1043 else {
1044 return false;
1045 }
1046 }
1047
1048
1057 public static boolean isNull(Object obj) {
1058 if (obj instanceof Long) {
1059 return isNull((Long)obj);
1060 }
1061 else if (obj instanceof String) {
1062 return isNull((String)obj);
1063 }
1064 else if (obj == null) {
1065 return true;
1066 }
1067 else {
1068 return false;
1069 }
1070 }
1071
1072
1075 public static boolean isNull(Object[] array) {
1076 return ArrayUtil.isEmpty(array);
1077 }
1078
1079
1088 public static boolean isNull(String s) {
1089 if (s == null) {
1090 return true;
1091 }
1092
1093 int counter = 0;
1094
1095 for (int i = 0; i < s.length(); i++) {
1096 char c = s.charAt(i);
1097
1098 if (c == CharPool.SPACE) {
1099 continue;
1100 }
1101 else if (counter > 3) {
1102 return false;
1103 }
1104
1105 if (counter == 0) {
1106 if (c != CharPool.LOWER_CASE_N) {
1107 return false;
1108 }
1109 }
1110 else if (counter == 1) {
1111 if (c != CharPool.LOWER_CASE_U) {
1112 return false;
1113 }
1114 }
1115 else if ((counter == 2) || (counter == 3)) {
1116 if (c != CharPool.LOWER_CASE_L) {
1117 return false;
1118 }
1119 }
1120
1121 counter++;
1122 }
1123
1124 if ((counter == 0) || (counter == 4)) {
1125 return true;
1126 }
1127
1128 return false;
1129 }
1130
1131
1139 public static boolean isNumber(String number) {
1140 if (isNull(number)) {
1141 return false;
1142 }
1143
1144 for (char c : number.toCharArray()) {
1145 if (!isDigit(c)) {
1146 return false;
1147 }
1148 }
1149
1150 return true;
1151 }
1152
1153
1162 public static boolean isPassword(String password) {
1163 if (isNull(password)) {
1164 return false;
1165 }
1166
1167 if (password.length() < 4) {
1168 return false;
1169 }
1170
1171 for (char c : password.toCharArray()) {
1172 if (!isChar(c) && !isDigit(c)) {
1173 return false;
1174 }
1175 }
1176
1177 return true;
1178 }
1179
1180
1189 public static boolean isPhoneNumber(String phoneNumber) {
1190 return isNumber(StringUtil.extractDigits(phoneNumber));
1191 }
1192
1193 public static boolean isUri(String uri) {
1194 if (isNotNull(uri)) {
1195 try {
1196 new URI(uri);
1197
1198 return true;
1199 }
1200 catch (URISyntaxException urise) {
1201 }
1202 }
1203
1204 return false;
1205 }
1206
1207
1215 public static boolean isUrl(String url) {
1216 if (isNotNull(url)) {
1217 if (url.indexOf(CharPool.COLON) == -1) {
1218 return false;
1219 }
1220
1221 try {
1222 new URL(url);
1223
1224 return true;
1225 }
1226 catch (MalformedURLException murle) {
1227 }
1228 }
1229
1230 return false;
1231 }
1232
1233
1240 public static boolean isVariableName(String variableName) {
1241 if (isNull(variableName)) {
1242 return false;
1243 }
1244
1245 Matcher matcher = _variableNamePattern.matcher(variableName);
1246
1247 if (matcher.matches()) {
1248 return true;
1249 }
1250 else {
1251 return false;
1252 }
1253 }
1254
1255
1263 public static boolean isVariableTerm(String s) {
1264 if (s.startsWith(_VARIABLE_TERM_BEGIN) &&
1265 s.endsWith(_VARIABLE_TERM_END)) {
1266
1267 return true;
1268 }
1269 else {
1270 return false;
1271 }
1272 }
1273
1274
1283 public static boolean isWhitespace(char c) {
1284 int i = c;
1285
1286 if ((i == 0) || Character.isWhitespace(c)) {
1287 return true;
1288 }
1289 else {
1290 return false;
1291 }
1292 }
1293
1294
1303 public static boolean isXml(String s) {
1304 if (s.startsWith(_XML_BEGIN) || s.startsWith(_XML_EMPTY)) {
1305 return true;
1306 }
1307 else {
1308 return false;
1309 }
1310 }
1311
1312 private static final int _CHAR_LOWER_CASE_BEGIN = 97;
1313
1314 private static final int _CHAR_LOWER_CASE_END = 122;
1315
1316 private static final int _CHAR_UPPER_CASE_BEGIN = 65;
1317
1318 private static final int _CHAR_UPPER_CASE_END = 90;
1319
1320 private static final int _DIGIT_BEGIN = 48;
1321
1322 private static final int _DIGIT_END = 57;
1323
1324 private static final char[] _EMAIL_ADDRESS_SPECIAL_CHAR = new char[] {
1325 '.', '!', '#', '$', '%', '&', '\'', '*', '+', '-', '/', '=', '?', '^',
1326 '_', '`', '{', '|', '}', '~'
1327 };
1328
1329 private static final String _VARIABLE_TERM_BEGIN = "[$";
1330
1331 private static final String _VARIABLE_TERM_END = "$]";
1332
1333 private static final String _XML_BEGIN = "<?xml";
1334
1335 private static final String _XML_EMPTY = "<root />";
1336
1337 private static Pattern _emailAddressPattern = Pattern.compile(
1338 "[\\w!#$%&'*+/=?^_`{|}~-]+(?:\\.[\\w!#$%&'*+/=?^_`{|}~-]+)*@" +
1339 "(?:[\\w](?:[\\w-]*[\\w])?\\.)+[\\w](?:[\\w-]*[\\w])?");
1340 private static Pattern _ipv4AddressPattern = Pattern.compile(
1341 "^" +
1342 "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\." +
1343 "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\." +
1344 "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\." +
1345 "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)" +
1346 "$");
1347 private static Pattern _ipv6AddressPattern = Pattern.compile(
1348 "^" +
1349 "\\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|" +
1350 "(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|" +
1351 "((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)" +
1352 "(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|" +
1353 "(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:" +
1354 "((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)" +
1355 "(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|" +
1356 "(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|" +
1357 "((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)" +
1358 "(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|" +
1359 "(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|" +
1360 "((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)" +
1361 "(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|" +
1362 "(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|" +
1363 "((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)" +
1364 "(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|" +
1365 "(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|" +
1366 "((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)" +
1367 "(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|" +
1368 "(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:" +
1369 "((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\." +
1370 "(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:)))(%.+)?\\s*" +
1371 "$");
1372 private static Pattern _variableNamePattern = Pattern.compile(
1373 "[_a-zA-Z]+[_a-zA-Z0-9]*");
1374
1375 }