# # Definition of the internal functions # # Converts name to the initials get_initials = public String get_initials(String str) {\ //if (isCJK(str)) return str;\n\ if (str==null || str.length()==0) return "";\ StringTokenizer st = new StringTokenizer(str, " .-");\ String res = "";\ String dlmtr = str.indexOf('-') != -1 ? "-" : " ";\ while (st.hasMoreElements( ))\ res += st.nextElement().toString().charAt(0) + "." + dlmtr;\ return res.substring(0, res.length() - dlmtr.length());\ } # gets year from date get_year = public String get_year(String str) {\ return str != null ? str.split("-")[0] : null;\ } # gets months from date get_month = public String get_month(String str) {\ String[] sa = str.split("-");\ return sa.length >= 2 ? sa[1] : null; \ } # gets months name from date get_month_name = public String get_month_name(String str) {\ String[] months = new String[]{"January","February","March","April","May","June","July","August","September","October","November","December"};\ String m = get_month(str);\ if(m==null) return null;\ int mi = Integer.parseInt(m) - 1;\ return mi>=0 && mi<=11 ? months[mi]:null;\ } # gets day from date get_day = public String get_day(String str) {\ String[] sa = str.split("-");\ return sa.length >= 3 ? sa[2] : null;\ } # transform String to int toInt = public int toInt(String str) {\ return str==null?0:Integer.parseInt(str);\ } # mostRecentDate($F{published-online}, $F{issued}, $F{dateAccepted}, $F{dateSubmitted}, $F{modified}, $F{created}) most_recent_date = public String mostRecentDate(String[] dates) {\ List list = Arrays.asList(dates);\ Collections.replaceAll(list, null, "");\ Collections.sort(list);\ return (String)list.get(list.size() - 1);\ } # mostRecentDateStatus($F{published-online}, $F{issued}, $F{dateAccepted}, $F{dateSubmitted}, $F{modified}, $F{created}) most_recent_date_status = public String mostRecentDateStatus(String[] dates) {\ String max = mostRecentDate(dates);\ return max.equals(dates[0]) ? "escidoc.published-online":\ max.equals(dates[1]) ? "escidoc.issued":\ max.equals(dates[2]) ? "escidoc.dateAccepted" :\ max.equals(dates[3]) ? "escidoc.dateSubmitted" :\ max.equals(dates[4]) ? "escidoc.modified":\ max.equals(dates[5]) ? "escidoc.created":\ ""; \ } # Joins the elements of the provided array into a single String containing the provided list of elements join = public String join(String[] arr, String delimiter)\ {\ if ( arr==null || arr.length == 0 ) return null;\ if ( arr.length == 1 ) return arr[0];\ StringBuffer sb = new StringBuffer();\ if (delimiter==null) delimiter="";\ for (int i=0, n=arr.length; i=19968 && codePoint<=40911) return true;\ # }\ # return false;\ # } #