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 == null) && (obj2 == null)) {
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
514 public static boolean isDate(int month, int day, int year) {
515 return isGregorianDate(month, day, year);
516 }
517
518
526 public static boolean isDigit(char c) {
527 int x = c;
528
529 if ((x >= _DIGIT_BEGIN) && (x <= _DIGIT_END)) {
530 return true;
531 }
532
533 return false;
534 }
535
536
544 public static boolean isDigit(String s) {
545 if (isNull(s)) {
546 return false;
547 }
548
549 for (char c : s.toCharArray()) {
550 if (!isDigit(c)) {
551 return false;
552 }
553 }
554
555 return true;
556 }
557
558
567 public static boolean isDomain(String domainName) {
568
569
570
571
572 if (isNull(domainName)) {
573 return false;
574 }
575
576 if (domainName.length() > 255) {
577 return false;
578 }
579
580 if (domainName.startsWith(StringPool.PERIOD)) {
581 return false;
582 }
583
584 String[] domainNameArray = StringUtil.split(
585 domainName, CharPool.PERIOD);
586
587 for (String domainNamePart : domainNameArray) {
588 char[] domainNamePartCharArray = domainNamePart.toCharArray();
589
590 for (int i = 0; i < domainNamePartCharArray.length; i++) {
591 char c = domainNamePartCharArray[i];
592
593 if ((i == 0) && (c == CharPool.DASH)) {
594 return false;
595 }
596
597 if ((i == (domainNamePartCharArray.length - 1)) &&
598 (c == CharPool.DASH)) {
599
600 return false;
601 }
602
603 if (!isChar(c) && !isDigit(c) && (c != CharPool.DASH)) {
604 return false;
605 }
606 }
607 }
608
609 return true;
610 }
611
612
619 public static boolean isEmailAddress(String emailAddress) {
620 Matcher matcher = _emailAddressPattern.matcher(emailAddress);
621
622 return matcher.matches();
623 }
624
625
633 public static boolean isEmailAddressSpecialChar(char c) {
634
635
636
637 for (char specialChar : _EMAIL_ADDRESS_SPECIAL_CHAR) {
638 if (c == specialChar) {
639 return true;
640 }
641 }
642
643 return false;
644 }
645
646
653 public static boolean isFileExtension(String fileExtension) {
654 if (isNull(fileExtension) ||
655 fileExtension.contains(StringPool.BACK_SLASH) ||
656 fileExtension.contains(StringPool.NULL_CHAR) ||
657 fileExtension.contains(StringPool.SLASH)) {
658
659 return false;
660 }
661
662 return true;
663 }
664
665 public static boolean isFileName(String name) {
666 if (isNull(name) || name.equals(StringPool.PERIOD) ||
667 name.equals(StringPool.DOUBLE_PERIOD) ||
668 name.contains(StringPool.BACK_SLASH) ||
669 name.contains(StringPool.NULL_CHAR) ||
670 name.contains(StringPool.SLASH)) {
671
672 return false;
673 }
674
675 return true;
676 }
677
678 public static boolean isFilePath(String path, boolean isParentDirAllowed) {
679 if (isNull(path)) {
680 return false;
681 }
682
683 if (path.contains(StringPool.NULL_CHAR)) {
684 return false;
685 }
686
687 if (isParentDirAllowed) {
688 return true;
689 }
690
691 if (path.equals(StringPool.DOUBLE_PERIOD)) {
692 return false;
693 }
694
695 String normalizedPath = path.replace(
696 CharPool.BACK_SLASH, CharPool.SLASH);
697
698 if (normalizedPath.startsWith(
699 StringPool.DOUBLE_PERIOD.concat(StringPool.SLASH))) {
700
701 return false;
702 }
703
704 if (normalizedPath.endsWith(
705 StringPool.SLASH.concat(StringPool.DOUBLE_PERIOD))) {
706
707 return false;
708 }
709
710 if (normalizedPath.contains(
711 StringPool.SLASH.concat(
712 StringPool.DOUBLE_PERIOD).concat(StringPool.SLASH))) {
713
714 return false;
715 }
716
717 return true;
718 }
719
720
729 public static boolean isGregorianDate(int month, int day, int year) {
730 if ((month < 0) || (month > 11)) {
731 return false;
732 }
733
734 int[] months = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
735
736 if (month == 1) {
737 int febMax = 28;
738
739 if (((year % 4) == 0) && ((year % 100) != 0) ||
740 ((year % 400) == 0)) {
741
742 febMax = 29;
743 }
744
745 if ((day < 1) || (day > febMax)) {
746 return false;
747 }
748 }
749 else if ((day < 1) || (day > months[month])) {
750 return false;
751 }
752
753 return true;
754 }
755
756
766 public static boolean isHex(String s) {
767 if (isNull(s)) {
768 return false;
769 }
770
771 return true;
772 }
773
774
781 public static boolean isHostName(String name) {
782 if (isNull(name)) {
783 return false;
784 }
785
786 char[] nameCharArray = name.toCharArray();
787
788 if ((nameCharArray[0] == CharPool.DASH) ||
789 (nameCharArray[0] == CharPool.PERIOD) ||
790 (nameCharArray[nameCharArray.length - 1] == CharPool.DASH)) {
791
792 return false;
793 }
794
795 for (char c : nameCharArray) {
796 if (!isChar(c) && !isDigit(c) && (c != CharPool.CLOSE_BRACKET) &&
797 (c != CharPool.COLON) && (c != CharPool.DASH) &&
798 (c != CharPool.OPEN_BRACKET) && (c != CharPool.PERIOD)) {
799
800 return false;
801 }
802 }
803
804 return true;
805 }
806
807
815 public static boolean isHTML(String s) {
816 if (isNull(s)) {
817 return false;
818 }
819
820 if ((s.contains("<html>") || s.contains("<HTML>")) &&
821 (s.contains("</html>") || s.contains("</HTML>"))) {
822
823 return true;
824 }
825
826 return false;
827 }
828
829
837 public static boolean isIPAddress(String ipAddress) {
838 if (isIPv4Address(ipAddress) || isIPv6Address(ipAddress)) {
839 return true;
840 }
841
842 return false;
843 }
844
845
852 public static boolean isIPv4Address(String ipAddress) {
853 Matcher matcher = _ipv4AddressPattern.matcher(ipAddress);
854
855 return matcher.matches();
856 }
857
858
865 public static boolean isIPv6Address(String ipAddress) {
866 if (isNull(ipAddress)) {
867 return false;
868 }
869
870 if (StringUtil.startsWith(ipAddress, CharPool.OPEN_BRACKET) &&
871 StringUtil.endsWith(ipAddress, CharPool.CLOSE_BRACKET)) {
872
873 ipAddress = ipAddress.substring(1, ipAddress.length() - 1);
874 }
875
876 Matcher matcher = _ipv6AddressPattern.matcher(ipAddress);
877
878 return matcher.matches();
879 }
880
881
890 public static boolean isJulianDate(int month, int day, int year) {
891 if ((month < 0) || (month > 11)) {
892 return false;
893 }
894
895 int[] months = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
896
897 if (month == 1) {
898 int febMax = 28;
899
900 if ((year % 4) == 0) {
901 febMax = 29;
902 }
903
904 if ((day < 1) || (day > febMax)) {
905 return false;
906 }
907 }
908 else if ((day < 1) || (day > months[month])) {
909 return false;
910 }
911
912 return true;
913 }
914
915
923 public static boolean isLUHN(String number) {
924 if (number == null) {
925 return false;
926 }
927
928 number = StringUtil.reverse(number);
929
930 int total = 0;
931
932 for (int i = 0; i < number.length(); i++) {
933 int x = 0;
934
935 if (((i + 1) % 2) == 0) {
936 x = GetterUtil.getInteger(number.substring(i, i + 1)) * 2;
937
938 if (x >= 10) {
939 String s = String.valueOf(x);
940
941 x =
942 GetterUtil.getInteger(s.substring(0, 1)) +
943 GetterUtil.getInteger(s.substring(1, 2));
944 }
945 }
946 else {
947 x = GetterUtil.getInteger(number.substring(i, i + 1));
948 }
949
950 total = total + x;
951 }
952
953 if ((total % 10) == 0) {
954 return true;
955 }
956 else {
957 return false;
958 }
959 }
960
961
969 public static boolean isName(String name) {
970 if (isNull(name)) {
971 return false;
972 }
973
974 for (char c : name.trim().toCharArray()) {
975 if (!isChar(c) && !Character.isWhitespace(c)) {
976 return false;
977 }
978 }
979
980 return true;
981 }
982
983
992 public static boolean isNotNull(Long l) {
993 return !isNull(l);
994 }
995
996
1005 public static boolean isNotNull(Object obj) {
1006 return !isNull(obj);
1007 }
1008
1009
1017 public static boolean isNotNull(Object[] array) {
1018 return !isNull(array);
1019 }
1020
1021
1030 public static boolean isNotNull(String s) {
1031 return !isNull(s);
1032 }
1033
1034
1042 public static boolean isNull(Long l) {
1043 if ((l == null) || (l.longValue() == 0)) {
1044 return true;
1045 }
1046 else {
1047 return false;
1048 }
1049 }
1050
1051
1060 public static boolean isNull(Object obj) {
1061 if (obj instanceof Long) {
1062 return isNull((Long)obj);
1063 }
1064 else if (obj instanceof String) {
1065 return isNull((String)obj);
1066 }
1067 else if (obj == null) {
1068 return true;
1069 }
1070 else {
1071 return false;
1072 }
1073 }
1074
1075
1083 public static boolean isNull(Object[] array) {
1084 if ((array == null) || (array.length == 0)) {
1085 return true;
1086 }
1087 else {
1088 return false;
1089 }
1090 }
1091
1092
1101 public static boolean isNull(String s) {
1102 if (s == null) {
1103 return true;
1104 }
1105
1106 int counter = 0;
1107
1108 for (int i = 0; i < s.length(); i++) {
1109 char c = s.charAt(i);
1110
1111 if (c == CharPool.SPACE) {
1112 continue;
1113 }
1114 else if (counter > 3) {
1115 return false;
1116 }
1117
1118 if (counter == 0) {
1119 if (c != CharPool.LOWER_CASE_N) {
1120 return false;
1121 }
1122 }
1123 else if (counter == 1) {
1124 if (c != CharPool.LOWER_CASE_U) {
1125 return false;
1126 }
1127 }
1128 else if ((counter == 2) || (counter == 3)) {
1129 if (c != CharPool.LOWER_CASE_L) {
1130 return false;
1131 }
1132 }
1133
1134 counter++;
1135 }
1136
1137 if ((counter == 0) || (counter == 4)) {
1138 return true;
1139 }
1140
1141 return false;
1142 }
1143
1144
1152 public static boolean isNumber(String number) {
1153 if (isNull(number)) {
1154 return false;
1155 }
1156
1157 for (char c : number.toCharArray()) {
1158 if (!isDigit(c)) {
1159 return false;
1160 }
1161 }
1162
1163 return true;
1164 }
1165
1166
1175 public static boolean isPassword(String password) {
1176 if (isNull(password)) {
1177 return false;
1178 }
1179
1180 if (password.length() < 4) {
1181 return false;
1182 }
1183
1184 for (char c : password.toCharArray()) {
1185 if (!isChar(c) && !isDigit(c)) {
1186 return false;
1187 }
1188 }
1189
1190 return true;
1191 }
1192
1193
1202 public static boolean isPhoneNumber(String phoneNumber) {
1203 return isNumber(StringUtil.extractDigits(phoneNumber));
1204 }
1205
1206 public static boolean isUri(String uri) {
1207 if (isNotNull(uri)) {
1208 try {
1209 new URI(uri);
1210
1211 return true;
1212 }
1213 catch (URISyntaxException urise) {
1214 }
1215 }
1216
1217 return false;
1218 }
1219
1220
1228 public static boolean isUrl(String url) {
1229 if (isNotNull(url)) {
1230 if (url.indexOf(CharPool.COLON) == -1) {
1231 return false;
1232 }
1233
1234 try {
1235 new URL(url);
1236
1237 return true;
1238 }
1239 catch (MalformedURLException murle) {
1240 }
1241 }
1242
1243 return false;
1244 }
1245
1246
1253 public static boolean isVariableName(String variableName) {
1254 if (isNull(variableName)) {
1255 return false;
1256 }
1257
1258 Matcher matcher = _variableNamePattern.matcher(variableName);
1259
1260 if (matcher.matches()) {
1261 return true;
1262 }
1263 else {
1264 return false;
1265 }
1266 }
1267
1268
1276 public static boolean isVariableTerm(String s) {
1277 if (s.startsWith(_VARIABLE_TERM_BEGIN) &&
1278 s.endsWith(_VARIABLE_TERM_END)) {
1279
1280 return true;
1281 }
1282 else {
1283 return false;
1284 }
1285 }
1286
1287
1296 public static boolean isWhitespace(char c) {
1297 int i = c;
1298
1299 if ((i == 0) || Character.isWhitespace(c)) {
1300 return true;
1301 }
1302 else {
1303 return false;
1304 }
1305 }
1306
1307
1316 public static boolean isXml(String s) {
1317 if (s.startsWith(_XML_BEGIN) || s.startsWith(_XML_EMPTY)) {
1318 return true;
1319 }
1320 else {
1321 return false;
1322 }
1323 }
1324
1325 private static final int _CHAR_LOWER_CASE_BEGIN = 97;
1326
1327 private static final int _CHAR_LOWER_CASE_END = 122;
1328
1329 private static final int _CHAR_UPPER_CASE_BEGIN = 65;
1330
1331 private static final int _CHAR_UPPER_CASE_END = 90;
1332
1333 private static final int _DIGIT_BEGIN = 48;
1334
1335 private static final int _DIGIT_END = 57;
1336
1337 private static final char[] _EMAIL_ADDRESS_SPECIAL_CHAR = new char[] {
1338 '.', '!', '#', '$', '%', '&', '\'', '*', '+', '-', '/', '=', '?', '^',
1339 '_', '`', '{', '|', '}', '~'
1340 };
1341
1342 private static final String _VARIABLE_TERM_BEGIN = "[$";
1343
1344 private static final String _VARIABLE_TERM_END = "$]";
1345
1346 private static final String _XML_BEGIN = "<?xml";
1347
1348 private static final String _XML_EMPTY = "<root />";
1349
1350 private static Pattern _emailAddressPattern = Pattern.compile(
1351 "[\\w!#$%&'*+/=?^_`{|}~-]+(?:\\.[\\w!#$%&'*+/=?^_`{|}~-]+)*@" +
1352 "(?:[\\w](?:[\\w-]*[\\w])?\\.)+[\\w](?:[\\w-]*[\\w])?");
1353 private static Pattern _ipv4AddressPattern = Pattern.compile(
1354 "^" +
1355 "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\." +
1356 "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\." +
1357 "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\." +
1358 "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)" +
1359 "$");
1360 private static Pattern _ipv6AddressPattern = Pattern.compile(
1361 "^" +
1362 "\\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|" +
1363 "(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|" +
1364 "((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)" +
1365 "(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|" +
1366 "(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:" +
1367 "((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)" +
1368 "(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|" +
1369 "(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|" +
1370 "((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)" +
1371 "(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|" +
1372 "(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|" +
1373 "((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)" +
1374 "(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|" +
1375 "(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|" +
1376 "((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)" +
1377 "(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|" +
1378 "(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|" +
1379 "((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)" +
1380 "(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|" +
1381 "(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:" +
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}))|:)))(%.+)?\\s*" +
1384 "$");
1385 private static Pattern _variableNamePattern = Pattern.compile(
1386 "[_a-zA-Z]+[_a-zA-Z0-9]*");
1387
1388 }