Example #1
0
 public static String smartDecode(String value) {
   if (SmartUtil.isBlankObject(value)) return value;
   value = value.replaceAll(""", "\"");
   value = value.replaceAll("&squo;", "\'");
   value = value.replaceAll("&lt;", "<");
   value = value.replaceAll("&gt;", ">");
   return value;
 }
Example #2
0
 public static Date convertDateStringToDate(String yyyyMMdd) throws Exception {
   if (SmartUtil.isBlankObject(yyyyMMdd) || yyyyMMdd.length() != 10) return null;
   DateFormat df = new SimpleDateFormat("yyyy.MM.dd");
   try {
     return new Date((df.parse(yyyyMMdd)).getTime());
   } catch (Exception e) {
     return null;
   }
 }
Example #3
0
  public static boolean isEmailAddress(String str) {

    if (SmartUtil.isBlankObject(str)) return false;

    //		  Pattern pattern =
    // Pattern.compile("^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$");
    return Pattern.matches(
        "^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[_A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$",
        str);
  }
Example #4
0
 public static String combineStrings(String first, String second) {
   if (SmartUtil.isBlankObject(first)) return second;
   if (SmartUtil.isBlankObject(second)) return first;
   String combined = first;
   String[] firstTokens = first.split(", ");
   String[] secondTokens = second.split(", ");
   if (!SmartUtil.isBlankObject(firstTokens) && !SmartUtil.isBlankObject(secondTokens)) {
     for (int i = 0; i < secondTokens.length; i++) {
       boolean found = false;
       for (int j = 0; j < firstTokens.length; j++) {
         if (firstTokens[j].equals(secondTokens[i])) {
           found = true;
           break;
         }
       }
       if (!found) {
         combined = combined + ", " + secondTokens[i];
       }
     }
   }
   return combined;
 }
Example #5
0
  public static String getBriefTitle(String title, int length) {
    if (SmartUtil.isBlankObject(title)) return "";
    if (length < 0) return title;

    byte[] titleBytes = title.getBytes();
    if (titleBytes.length <= length) return title;
    length =
        titleBytes[length] >= 0
            ? length
            : titleBytes[length - 1] >= 0
                ? length - 1
                : titleBytes[length - 2] >= 0 ? length - 2 : length - 2;
    return new String(titleBytes, 0, length) + "...";
  }
Example #6
0
 public static String getFileExtension(String filename) {
   String extension = "none";
   if (SmartUtil.isBlankObject(filename)) return extension;
   int pos = filename.lastIndexOf('.');
   String[] extTypes =
       new String[] {
         "asf", "avi", "bmp", "doc", "docx", "exe", "gif", "hwp", "jpg", "mid", "mp3", "mpeg",
         "mpg", "pdf", "pds", "ppt", "pptx", "rar", "txt", "wav", "wma", "wmv", "word", "xls",
         "xlsx", "zip"
       };
   if (pos != -1) {
     String extTemp = filename.substring(pos + 1, filename.length()).toLowerCase();
     for (int i = 0; i < extTypes.length; i++) {
       if (extTypes[i].equals(extTemp)) extension = extTemp;
     }
   }
   return extension;
 }
Example #7
0
 public static String getBriefTitle(String title) {
   if (SmartUtil.isBlankObject(title)) return "";
   return getBriefTitle(title, 40);
 }
Example #8
0
 public static boolean isTilesLocation(String str) {
   if (SmartUtil.isBlankObject(str) || str.length() <= 3) return false;
   if (TILES_POSTFIX.equals(str.substring(str.length() - TILES_POSTFIX.length(), str.length())))
     return true;
   return false;
 }
Example #9
0
 public static String getDepartNameFromFullpath(String departFullpathName) {
   if (SmartUtil.isBlankObject(departFullpathName)) return "";
   String[] tokens = departFullpathName.split("▶");
   return tokens[tokens.length - 1];
 }