StrPool.java 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. package cn.com.ty.lift.common.utils;
  2. /**
  3. * Copy to jodd.util
  4. * <p>
  5. * Pool of <code>String</code> constants to prevent repeating of
  6. * hard-coded <code>String</code> literals in the code.
  7. * Due to fact that these are <code>public static final</code>
  8. * they will be inlined by java compiler and
  9. * reference to this class will be dropped.
  10. * There is <b>no</b> performance gain of using this pool.
  11. * Read: https://java.sun.com/docs/books/jls/third_edition/html/lexical.html#3.10.5
  12. * <ul>
  13. * <li>Literal strings within the same class in the same package represent references to the same <code>String</code> object.</li>
  14. * <li>Literal strings within different classes in the same package represent references to the same <code>String</code> object.</li>
  15. * <li>Literal strings within different classes in different packages likewise represent references to the same <code>String</code> object.</li>
  16. * <li>Strings computed by constant expressions are computed at compile time and then treated as if they were literals.</li>
  17. * <li>Strings computed by concatenation at run time are newly created and therefore distinct.</li>
  18. * </ul>
  19. */
  20. public interface StrPool {
  21. String AMPERSAND = "&";
  22. String AND = "and";
  23. String AT = "@";
  24. String ASTERISK = "*";
  25. String STAR = ASTERISK;
  26. String BACK_SLASH = "\\";
  27. String COLON = ":";
  28. String COMMA = ",";
  29. String DASH = "-";
  30. String DOLLAR = "$";
  31. String DOT = ".";
  32. String DOTDOT = "..";
  33. String DOT_CLASS = ".class";
  34. String DOT_JAVA = ".java";
  35. String EMPTY = "";
  36. String EQUALS = "=";
  37. String FALSE = "false";
  38. String SLASH = "/";
  39. String HASH = "#";
  40. String HAT = "^";
  41. String LEFT_BRACE = "{";
  42. String LEFT_BRACKET = "(";
  43. String LEFT_CHEV = "<";
  44. String NEWLINE = "\n";
  45. String N = "n";
  46. String NO = "no";
  47. String NULL = "null";
  48. String OFF = "off";
  49. String ON = "on";
  50. String PERCENT = "%";
  51. String PIPE = "|";
  52. String PLUS = "+";
  53. String QUESTION_MARK = "?";
  54. String EXCLAMATION_MARK = "!";
  55. String QUOTE = "\"";
  56. String RETURN = "\r";
  57. String TAB = "\t";
  58. String RIGHT_BRACE = "}";
  59. String RIGHT_BRACKET = ")";
  60. String RIGHT_CHEV = ">";
  61. String SEMICOLON = ";";
  62. String SINGLE_QUOTE = "'";
  63. String SPACE = " ";
  64. String LEFT_SQ_BRACKET = "[";
  65. String RIGHT_SQ_BRACKET = "]";
  66. String TRUE = "true";
  67. String UNDERSCORE = "_";
  68. String UTF_8 = "UTF-8";
  69. String ISO_8859_1 = "ISO-8859-1";
  70. String Y = "y";
  71. String YES = "yes";
  72. String ONE = "1";
  73. String ZERO = "0";
  74. String DOLLAR_LEFT_BRACE = "${";
  75. String HASH_LEFT_BRACE = "#{";
  76. String CRLF = "\r\n";
  77. String HTML_NBSP = "&nbsp;";
  78. String HTML_AMP = "&amp";
  79. String HTML_QUOTE = "&quot;";
  80. String HTML_LT = "&lt;";
  81. String HTML_GT = "&gt;";
  82. // ----------------------------------------------------------------log
  83. String LOG_PREFIX = "###| ";
  84. String LOG_LINE = "============================================================";
  85. String LOG_GLOBAL_EXCEPTION_LINE = "====================== GlobalDefaultException ======================";
  86. String LOG_URL = StrPool.LOG_PREFIX + "URL : ";
  87. String LOG_HTTP_METHOD = StrPool.LOG_PREFIX + "HTTP_METHOD : ";
  88. String LOG_IP = StrPool.LOG_PREFIX + "IP : ";
  89. String LOG_CLASS_METHOD = StrPool.LOG_PREFIX + "CLASS_METHOD : ";
  90. String LOG_ARGS = StrPool.LOG_PREFIX + "ARGS : ";
  91. String LOG_RESPONSE = StrPool.LOG_PREFIX + "RESPONSE : ";
  92. String LOG_STATUS = StrPool.LOG_PREFIX + "STATUS : ";
  93. String LOG_EXCEPTION = StrPool.LOG_PREFIX + "EXCEPTION : ";
  94. //是否打印全部的结果
  95. boolean LOG_PRINT_ALL = false;
  96. // 结果字符串 > LOG_PRINT_MAX ,格式化打印首尾(LOG_PRINT_MAX / 2)部分,中间省略
  97. int LOG_PRINT_MAX = 1000;
  98. // 方法处理耗时 > LOG_GOOD_TIME,日志到warn中
  99. long LOG_GOOD_TIME = 10 * 1000;
  100. // ---------------------------------------------------------------- array
  101. String[] EMPTY_ARRAY = new String[0];
  102. byte[] BYTES_NEW_LINE = StrPool.NEWLINE.getBytes();
  103. // 查询记录的最大时间间隔
  104. long QUERY_MAX_DAYS = 366;
  105. }