一、前言
关于gbh_util源码包edu.colorado.museum.greg.util.LogUtils、edu.colorado.museum.greg.util.FileUtils日志文件工具类,对指定路径日志文件追加addAppender、对指定路径日志文件deleteLogs等操作。
二、源码说明
1.LogUtils日志工具类
package edu.colorado.museum.greg.util;@b@@b@import java.io.File;@b@import java.io.FileOutputStream;@b@import java.io.IOException;@b@import java.io.PrintStream;@b@import org.apache.log4j.HTMLLayout;@b@import org.apache.log4j.Level;@b@import org.apache.log4j.Logger;@b@import org.apache.log4j.WriterAppender;@b@@b@public class LogUtils@b@{@b@ static FileUtils fu = new FileUtils();@b@@b@ public static FileOutputStream getFOS(String default_path, String default_log)@b@ throws IOException@b@ {@b@ File tmpf = new File(default_path);@b@ FileOutputStream output = new FileOutputStream(fu.addTrailingSlash(default_path) + default_log, true);@b@ return output;@b@ }@b@@b@ public static boolean addAppender(Logger log, FileOutputStream output)@b@ {@b@ try {@b@ if (log == null)@b@ return false;@b@@b@ HTMLLayout layout = new HTMLLayout();@b@ WriterAppender appender = null;@b@ appender = new WriterAppender(layout, output);@b@ if (appender == null)@b@ return false;@b@@b@ log.addAppender(appender);@b@ log.setLevel(Level.DEBUG);@b@ } catch (Exception e) {@b@ return false;@b@ }@b@ return true;@b@ }@b@@b@ public static void deleteLogs(String default_output, String default_log)@b@ {@b@ File f = new File(fu.addTrailingSlash(default_output) + default_log);@b@ if (f.exists()) {@b@ try {@b@ FileOutputStream fis = new FileOutputStream(f, false);@b@ fis.close();@b@ } catch (IOException ioe) {@b@ System.out.println(ioe.toString() + " :70");@b@ }@b@ f.delete();@b@ }@b@ }@b@}
2.FileUtils文件工具类
package edu.colorado.museum.greg.util;@b@@b@import java.io.IOException;@b@import java.io.LineNumberReader;@b@import java.io.RandomAccessFile;@b@import java.text.ParseException;@b@import java.text.SimpleDateFormat;@b@import java.util.ArrayList;@b@import java.util.Date;@b@import java.util.HashMap;@b@import java.util.Iterator;@b@import java.util.ListIterator;@b@import java.util.regex.Matcher;@b@import java.util.regex.Pattern;@b@@b@public class FileUtils@b@{@b@ Matcher m = null;@b@ public static final String[] exclusions = new String[0];@b@@b@ public String[] readOnceRandom(RandomAccessFile ralfer, int inc)@b@ throws IOException@b@ {@b@ if (ralfer == null)@b@ return null;@b@@b@ ArrayList intera = new ArrayList();@b@@b@ for (int jj = 0; jj < inc; ++jj)@b@ {@b@ long pos = ralfer.getFilePointer();@b@ try {@b@ intera.add(jj, ralfer.readLine());@b@ } catch (IOException ioe) {@b@ while (true) { ralfer.skipBytes(1);@b@ }@b@@b@ }@b@@b@ if (intera.get(jj) == null)@b@ break;@b@ }@b@@b@ String[] s = new String[intera.size()];@b@ intera.toArray(s);@b@ return s;@b@ }@b@@b@ public String[] readOnce(LineNumberReader bleeder, int inc) throws IOException {@b@ if (bleeder == null)@b@ return null;@b@@b@ ArrayList intera = new ArrayList();@b@@b@ for (int jj = 0; jj < inc; ++jj) {@b@ int lno = bleeder.getLineNumber();@b@ intera.add(jj, bleeder.readLine());@b@ if (intera.get(jj) == null)@b@ break;@b@ }@b@@b@ String[] s = new String[intera.size()];@b@ intera.toArray(s);@b@ return s;@b@ }@b@@b@ public String[][] getDefaultGlasses() {@b@ String[][] glasses = new String[1][];@b@ String[] glass = { "true", "NIMA Feature Designation", "AREA (area)" };@b@ glasses[0] = glass;@b@ return glasses;@b@ }@b@@b@ public Boolean isEmpty(String ins) {@b@ if ((ins == null) || (ins.length() == 0))@b@ return Boolean.valueOf(true);@b@@b@ return Boolean.valueOf(false);@b@ }@b@@b@ public Boolean isEmpty(StringBuffer ins) {@b@ if ((ins == null) || (ins.length() == 0))@b@ return Boolean.valueOf(true);@b@@b@ return Boolean.valueOf(false);@b@ }@b@@b@ public Boolean isEmpty(ArrayList ina) {@b@ if ((ina == null) || (ina.size() == 0))@b@ return Boolean.valueOf(true);@b@@b@ return Boolean.valueOf(false);@b@ }@b@@b@ public Boolean isEmpty(HashMap inh) {@b@ if ((inh == null) || (inh.size() == 0))@b@ return Boolean.valueOf(true);@b@@b@ return Boolean.valueOf(false);@b@ }@b@@b@ public Boolean isEmpty(String[] ins) {@b@ if ((ins == null) || (ins.length == 0))@b@ return Boolean.valueOf(true);@b@@b@ return Boolean.valueOf(false);@b@ }@b@@b@ public Boolean isEmpty(String[][] ins) {@b@ if ((ins == null) || (ins.length == 0))@b@ return Boolean.valueOf(true);@b@@b@ return isEmpty(ins[0]);@b@ }@b@@b@ public Boolean isEmpty(Object[] os) {@b@ if ((os == null) || (os.length == 0))@b@ return Boolean.valueOf(true);@b@@b@ return Boolean.valueOf(false);@b@ }@b@@b@ public Boolean isEmpty(Object o) {@b@ if (o == null)@b@ return Boolean.valueOf(true);@b@@b@ return Boolean.valueOf(false);@b@ }@b@@b@ public String checkDate(String ins) {@b@ if (isEmpty(ins).booleanValue())@b@ return null;@b@@b@ SimpleDateFormat d_f = new SimpleDateFormat();@b@ String new_date = null;@b@ try {@b@ new_date = d_f.parse(ins).toString();@b@ } catch (ParseException pe) {@b@ new_date = "01/01/01";@b@ } catch (Exception e) {@b@ new_date = "01/01/01";@b@ }@b@ return new_date;@b@ }@b@@b@ public byte[] strToByteA(String ins) {@b@ Integer localInteger1;@b@ if (isEmpty(ins).booleanValue())@b@ return null;@b@@b@ byte[] buf = new byte[ins.length() + 1];@b@ Integer ii = Integer.valueOf(0);@b@ while (ii.intValue() < ins.length()) {@b@ buf[ii.intValue()] = (byte)ins.charAt(ii.intValue());@b@@b@ localInteger1 = ii; Integer localInteger2 = ii = Integer.valueOf(ii.intValue() + 1);@b@ }@b@@b@ buf[ii.intValue()] = 10;@b@ return buf;@b@ }@b@@b@ public StringBuffer WKTToGML21Simple(StringBuffer ins) {@b@ if (isEmpty(ins).booleanValue())@b@ return null;@b@@b@ String tmp_ins = ins.toString();@b@ Pattern p = Pattern.compile("[\\p{Digit}\\.-]+");@b@ Matcher m = p.matcher(tmp_ins);@b@ if (m.find()) {@b@ tmp_ins = tmp_ins.substring(m.start());@b@ }@b@@b@ tmp_ins = tmp_ins.replace("))',4326)", "");@b@ tmp_ins = tmp_ins.replace(")',4326)", "");@b@@b@ p = Pattern.compile("[\\s]+");@b@ m = p.matcher(tmp_ins);@b@ while (m.find())@b@ tmp_ins = tmp_ins.replace(m.group(), "z");@b@@b@ tmp_ins = tmp_ins.replaceAll(",", " ");@b@ tmp_ins = tmp_ins.replaceAll("z", ",");@b@@b@ String prefix = "<gml:Polygon xmlns:gml=\"http://www.opengis.net/gml\" srsName=\"http://www.opengis.net/gml/epsg.xml#4326\"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates cs=\",\" decimal=\".\" ts=\" \">";@b@ String suffix = "</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon>";@b@ tmp_ins = prefix + tmp_ins + suffix;@b@ return new StringBuffer(tmp_ins);@b@ }@b@@b@ public String polyToGC(String ins) {@b@ if (isEmpty(ins).booleanValue())@b@ return null;@b@@b@ String tmp_ins = new String(ins);@b@ Integer ri = Integer.valueOf(tmp_ins.indexOf("POLYGON", 0));@b@ if (ri.intValue() == -1)@b@ return "";@b@@b@ if (ri.intValue() > 0) {@b@ tmp_ins = tmp_ins.substring(ri.intValue());@b@ if ((tmp_ins == null) || (tmp_ins.length() == 0))@b@ return "";@b@ }@b@@b@ tmp_ins = "GEOMETRYCOLLECTION(" + tmp_ins + ")";@b@ return tmp_ins;@b@ }@b@@b@ public StringBuffer gcToWKTSimple(StringBuffer ins) {@b@ if (isEmpty(ins).booleanValue())@b@ return null;@b@@b@ String tmp_ins = ins.toString();@b@ String fn = "GeomCollFromText";@b@ String srid = "4326";@b@ tmp_ins = fn + "('" + tmp_ins + "'," + srid + ")";@b@ return new StringBuffer(tmp_ins);@b@ }@b@@b@ public String gcToWKT(String ins, String[] gtypes, String fn, String srid) {@b@ if (isEmpty(ins).booleanValue())@b@ return null;@b@@b@ return gcToWKT(new StringBuffer(ins), gtypes, fn, srid).toString();@b@ }@b@@b@ public StringBuffer gcToWKT(StringBuffer ins, String[] gtypes, String fn, String srid) {@b@ if (isEmpty(ins).booleanValue())@b@ return null;@b@@b@ String tmp_ins = ins.toString();@b@ if ((gtypes == null) || (gtypes.length == 0))@b@ return ins;@b@@b@ if ((fn == null) || (fn.length() == 0))@b@ return ins;@b@@b@ if ((srid == null) || (srid.length() == 0))@b@ srid = "4326";@b@@b@ Integer ri = null;@b@@b@ for (int ii = 0; ii < gtypes.length; ++ii) {@b@ ri = Integer.valueOf(tmp_ins.indexOf(gtypes[ii], 0));@b@ if (ri.intValue() != -1)@b@ break;@b@ }@b@@b@ if (ri.intValue() == -1)@b@ return null;@b@@b@ if (ri.intValue() > 0) {@b@ tmp_ins = tmp_ins.substring(ri.intValue());@b@ if ((tmp_ins != null) && (tmp_ins.length() != 0)) break label203;@b@ return null;@b@ }@b@@b@ tmp_ins = fn + "('" + tmp_ins + "'," + srid + ")";@b@ return new StringBuffer(tmp_ins);@b@@b@ label203: Pattern p = Pattern.compile("SRID=[\\p{Digit}\\.-]*[)]");@b@ Matcher m = p.matcher(tmp_ins);@b@ do { if ((m == null) || (!(m.find()))) break label261;@b@ tmp_ins = tmp_ins.replace(m.group(), "),"); }@b@ while ((tmp_ins != null) && (tmp_ins.length() != 0));@b@ return null;@b@@b@ label261: tmp_ins = fn + "('" + tmp_ins + "'," + srid + ")";@b@ return new StringBuffer(tmp_ins);@b@ }@b@@b@ public String[] compressStringArray(ArrayList ina) {@b@ if (isEmpty(ina).booleanValue())@b@ return null;@b@@b@ String s = null;@b@ Iterator it = ina.iterator();@b@ ArrayList a_ret = new ArrayList();@b@ String[] ret = null;@b@ Integer ii = Integer.valueOf(0);@b@ while (true) { do { if (!(it.hasNext())) break label78;@b@ s = (String)it.next(); }@b@ while ((s == null) || (s.length() == 0));@b@ a_ret.add(s);@b@ }@b@@b@ label78: ret = new String[a_ret.size()];@b@ a_ret.toArray(ret);@b@ return ret;@b@ }@b@@b@ public String removeTrailingSlashes(String ins)@b@ throws IOException@b@ {@b@ if (isEmpty(ins).booleanValue())@b@ return null;@b@@b@ String rets = "";@b@ int lastSlash = ins.lastIndexOf(47);@b@ while ((lastSlash == ins.length() - 1) && (ins.length() > 0)) {@b@ ins = ins.substring(0, ins.length() - 1);@b@ lastSlash = ins.lastIndexOf(47);@b@ }@b@ rets = ins;@b@@b@ return rets;@b@ }@b@@b@ public String trimTrailingRParen(String ins) {@b@ if (isEmpty(ins).booleanValue())@b@ return null;@b@@b@ String rets = "";@b@ int lastParen = ins.lastIndexOf(41);@b@ if ((lastParen == ins.length() - 1) && (ins.length() > 0))@b@ ins = ins.substring(0, ins.length() - 1);@b@@b@ rets = ins;@b@ return rets;@b@ }@b@@b@ public String uToWPath(String ins) {@b@ if (isEmpty(ins).booleanValue())@b@ return null;@b@@b@ try@b@ {@b@ Pattern p = Pattern.compile("/");@b@ Matcher m = p.matcher(ins);@b@ while (m.find())@b@ ins = ins.replace(m.group(), "\\");@b@ }@b@ catch (Exception e) {@b@ return null;@b@ }@b@ return ins;@b@ }@b@@b@ public String addTrailingSlash(String ins)@b@ {@b@ if (isEmpty(ins).booleanValue())@b@ return "/";@b@@b@ ins = ins.trim();@b@ String rets = "";@b@ if (!(ins.endsWith("/")))@b@ ins = ins + "/";@b@@b@ rets = ins;@b@@b@ return rets;@b@ }@b@@b@ public int countSlashes(String ins) {@b@ if (isEmpty(ins).booleanValue())@b@ return 0;@b@@b@ int count = 0;@b@ try {@b@ Pattern p = Pattern.compile("/");@b@ Matcher m = p.matcher(ins);@b@ while (m.find())@b@ ++count;@b@ }@b@ catch (Exception e) {@b@ return -1;@b@ }@b@ return count;@b@ }@b@@b@ public String removeMultipleSlashes(String ins) {@b@ if (isEmpty(ins).booleanValue())@b@ return null;@b@ try@b@ {@b@ Pattern p = Pattern.compile("//");@b@ while (true) {@b@ Matcher m = p.matcher(ins);@b@ boolean b = m.find();@b@ if (!(b))@b@ break;@b@@b@ while (b) {@b@ ins = ins.replace(m.group(), "/");@b@ b = m.find();@b@ }@b@ }@b@ } catch (Exception e) {@b@ return null;@b@ }@b@ return ins;@b@ }@b@@b@ public Double[] getDelta_xy(String ins) {@b@ int jj;@b@ Boolean incjj;@b@ int ii;@b@ if (isEmpty(ins).booleanValue())@b@ return null;@b@@b@ String[] splits = null;@b@ String[] nsplits = null;@b@ Double[] dsplits = null;@b@ Pattern n = null;@b@ Pattern p = null;@b@ String tmp = null;@b@ Integer ri = null;@b@ try {@b@ p = Pattern.compile("[\\s]");@b@ n = Pattern.compile("[^\\p{Digit}\\.-]");@b@ splits = n.split(ins);@b@ dsplits = new Double[splits.length];@b@ jj = 0;@b@ incjj = Boolean.valueOf(true);@b@ for (ii = 0; ii < splits.length; ++ii) {@b@ try {@b@ nsplits = n.split(splits[ii]);@b@ int kk = 0; if (kk < nsplits.length) {@b@ try {@b@ dsplits[jj] = new Double(nsplits[kk]);@b@ } catch (NumberFormatException nf) {@b@ while (true) {@b@ incjj = Boolean.valueOf(false);@b@@b@ ++kk;@b@ }@b@@b@ }@b@@b@ }@b@@b@ }@b@ catch (NumberFormatException nfe)@b@ {@b@ incjj = Boolean.valueOf(false);@b@ }@b@ if (incjj.booleanValue())@b@ ++jj;@b@ else@b@ incjj = Boolean.valueOf(true);@b@ }@b@ }@b@ catch (Exception e) {@b@ return null;@b@ }@b@ return dsplits;@b@ }@b@@b@ public String startWithLastSmallest(String ins) {@b@ if (isEmpty(ins).booleanValue()) {@b@ return null;@b@ }@b@@b@ Double smallest = null;@b@ Integer tmpi = null;@b@ try@b@ {@b@ Pattern p = Pattern.compile("/");@b@ String[] splits = p.split(ins);@b@ smallest = new Double(splits[1]);@b@ tmpi = Integer.valueOf(ins.lastIndexOf(smallest.toString()));@b@ ins = ins.substring(tmpi.intValue() - 1);@b@ } catch (Exception e) {@b@ }@b@ return ins;@b@ }@b@@b@ public String removeRepeatingGroups(String ins) {@b@ String[] splits;@b@ int ii;@b@ if (isEmpty(ins).booleanValue())@b@ return null;@b@ try@b@ {@b@ Pattern p = Pattern.compile("/");@b@ splits = p.split(ins);@b@ for (ii = 1; ii < splits.length; ++ii) {@b@ if (splits[ii].compareTo(splits[(ii - 1)]) == 0)@b@ splits[(ii - 1)] = "";@b@@b@ }@b@@b@ ins = "/";@b@@b@ for (ii = 1; ii < splits.length; ++ii)@b@ if (splits[ii] != "")@b@ ins = ins + splits[ii] + '/';@b@ }@b@ catch (Exception e)@b@ {@b@ return null;@b@ }@b@ return ins;@b@ }@b@@b@ public String[] getFileParts(String ins)@b@ throws IOException@b@ {@b@ if (isEmpty(ins).booleanValue())@b@ return null;@b@@b@ String[] rets = new String[2];@b@ int index = ins.lastIndexOf(46);@b@@b@ if (index != -1) {@b@ rets[0] = ins.substring(0, index);@b@ rets[1] = ins.substring(index + 1);@b@ } else {@b@ rets[0] = ins;@b@ rets[1] = null;@b@ }@b@ return rets;@b@ }@b@@b@ public String[] removeLeadingPath(String ins) throws IOException@b@ {@b@ if (isEmpty(ins).booleanValue())@b@ return null;@b@@b@ String[] rets = { "", "" };@b@ ins = removeTrailingSlashes(ins);@b@ if (ins.lastIndexOf(47) != -1) {@b@ rets[0] = ins.substring(0, ins.lastIndexOf(47));@b@ rets[1] = ins.substring(ins.lastIndexOf(47) + 1);@b@ } else {@b@ rets[1] = ins;@b@ }@b@ return rets;@b@ }@b@@b@ public String[] removeLeadingNodePath(String ins, String prefix) throws IOException {@b@ if (isEmpty(ins).booleanValue())@b@ return null;@b@@b@ String[] prefixes = new String[1];@b@ prefixes[0] = prefix;@b@ return removeLeadingNodePaths(ins, prefixes);@b@ }@b@@b@ public String[] removeLeadingNodePaths(String ins, String[] prefixes) throws IOException@b@ {@b@ if (isEmpty(ins).booleanValue())@b@ return null;@b@@b@ for (int ii = 0; ii < prefixes.length; ++ii)@b@ if (ins.startsWith(prefixes[ii]))@b@ ins = ins.substring(prefixes[ii].length());@b@@b@@b@ return removeLeadingPath(ins);@b@ }@b@@b@ public String replaceSingleQuote(String ins)@b@ {@b@ if (isEmpty(ins).booleanValue())@b@ return null;@b@@b@ return ins.replace("'", "\\'");@b@ }@b@@b@ public String replaceQuotedPatterns(String inter, ArrayList qs, Pattern quoted_csv_separator) throws Exception {@b@ if (qs == null)@b@ return inter;@b@@b@ if (qs.size() == 0)@b@ return inter;@b@@b@ if ((quoted_csv_separator != null) && (inter != null) && (inter.length() > 0)) {@b@ this.m = quoted_csv_separator.matcher(inter);@b@ StringBuffer inter_buffer = new StringBuffer(inter);@b@ while (this.m.find()) {@b@ String tmp = inter.substring(this.m.start() + 1, this.m.end() - 1);@b@ String tmp2 = tmp.replaceAll("[,]", ";");@b@ if (tmp.contains("\",\"")) {@b@ tmp2 = tmp.replace("\",\"", "\"&&&\"");@b@ tmp2 = tmp2.replaceAll(",", ";");@b@ tmp2 = tmp2.replace("\"&&&\"", ",");@b@ }@b@ inter_buffer.replace(this.m.start(), this.m.end(), tmp2);@b@ inter = inter_buffer.toString();@b@ }@b@ }@b@ return inter;@b@ }@b@@b@ public String replaceNonLatin(String ins, String rep_str) {@b@ if (isEmpty(ins).booleanValue())@b@ return ins;@b@@b@ Pattern p = Pattern.compile("[\\P{InBasic_Latin}]");@b@ Matcher m = p.matcher(ins);@b@ if (m == null)@b@ return ins;@b@@b@ boolean b = m.find();@b@ while (b) {@b@ ins = ins.replace(m.group(), rep_str);@b@ b = m.find();@b@ }@b@ return ins;@b@ }@b@@b@ public String replacePatterns(String ins, ArrayList ps, ArrayList qs) {@b@ if (isEmpty(ins).booleanValue())@b@ return ins;@b@@b@ if ((ps == null) || (qs == null))@b@ return ins;@b@@b@ if ((ps.size() == 0) || (qs.size() != ps.size()))@b@ return ins;@b@@b@ while (ps.size() > qs.size())@b@ qs.add("");@b@@b@ ListIterator it = ps.listIterator();@b@ ListIterator itq = qs.listIterator();@b@ Pattern p = (Pattern)it.next();@b@ String q = (String)itq.next();@b@ Matcher m = null;@b@@b@ String tmp = ins;@b@ while (p != null) {@b@ m = p.matcher(ins);@b@ boolean b = m.find();@b@ while (b) {@b@ tmp = tmp.replace(m.group(), q);@b@ b = m.find();@b@ }@b@ if (!(it.hasNext()))@b@ break;@b@ p = (Pattern)it.next(); q = (String)itq.next();@b@ }@b@@b@ return tmp;@b@ }@b@@b@ public String getSFeature_ID(int feature_id, String prefix, String suffix) {@b@ String s_feature_id = prefix + "-" + feature_id + suffix;@b@ return s_feature_id;@b@ }@b@@b@ public String[] delimitedToStringArray(int size_min, String ins, String delim) {@b@ if (isEmpty(ins).booleanValue())@b@ return null;@b@@b@ ArrayList ret_a = delimitedToStringArrayList(size_min, ins, delim);@b@ if ((ret_a == null) || (ret_a.size() == 0))@b@ return null;@b@@b@ String[] ret = new String[ret_a.size()];@b@ ret_a.toArray(ret);@b@ return ret;@b@ }@b@@b@ public ArrayList delimitedToStringArrayList(int size_min, String ins, String delim) {@b@ if (isEmpty(ins).booleanValue())@b@ return null;@b@@b@ boolean haveContent = false;@b@ int ii = 0;@b@ String[] splits = ins.split(delim);@b@ if (splits == null)@b@ return null;@b@@b@ int endi = Math.max(size_min, splits.length);@b@ ArrayList ret = new ArrayList();@b@ for (ii = 0; ii < endi; ++ii)@b@ ret.add("");@b@@b@ for (ii = 0; ii < splits.length; ++ii) {@b@ if (splits[ii].length() > 0)@b@ haveContent = true;@b@@b@ ret.set(ii, splits[ii]);@b@ }@b@ if (!(haveContent))@b@ return null;@b@@b@ return ret;@b@ }@b@@b@ public String stringArrayToDelimited(String[] ins, String delim) {@b@ if (isEmpty(ins).booleanValue())@b@ return null;@b@@b@ String ret = null;@b@ String ret_part = null;@b@ ArrayList non_null_ins_a = new ArrayList();@b@ String[] non_null_ins = null;@b@@b@ int ii = 0;@b@@b@ if ((ins == null) || (ins.length == 0))@b@ return null;@b@@b@ if (delim == null) {@b@ delim = ";";@b@ }@b@@b@ for (ii = 0; ii < ins.length; ++ii) {@b@ if ((ins[ii] != null) && (ins[ii].length() > 0))@b@ non_null_ins_a.add(ins[ii]);@b@@b@ }@b@@b@ non_null_ins = new String[non_null_ins_a.size()];@b@ non_null_ins_a.toArray(non_null_ins);@b@@b@ for (ii = 0; ii < non_null_ins.length; ++ii) {@b@ ret_part = non_null_ins[ii];@b@ if (ii == 0)@b@ ret = ret_part;@b@ else {@b@ ret = ret + ret_part;@b@ }@b@@b@ if (ii < non_null_ins.length - 1)@b@ ret = ret + delim;@b@@b@ }@b@@b@ return ret;@b@ }@b@@b@ public ArrayList deriveNames(String specific_locality)@b@ {@b@ if (isEmpty(specific_locality).booleanValue()) {@b@ return null;@b@ }@b@@b@ String this_string = null;@b@@b@ Pattern b = Pattern.compile("[\\p{Blank}]");@b@ Pattern p = Pattern.compile("[\\p{Punct}]");@b@@b@ ArrayList ps = new ArrayList();@b@ ArrayList qs = new ArrayList();@b@ ps.add(p);@b@ qs.add(" ");@b@ specific_locality = replacePatterns(specific_locality, ps, qs);@b@@b@ String[] splits = b.split(specific_locality);@b@ ArrayList al_splits = new ArrayList();@b@ for (int ii = 0; ii < splits.length; ++ii) {@b@ al_splits.add(splits[ii].toUpperCase());@b@ }@b@@b@ ArrayList keeps = new ArrayList();@b@ String comparator = null;@b@ String comparand = null;@b@ int res = 0;@b@@b@ for (ii = 0; ii < splits.length; ++ii) {@b@ comparator = (String)al_splits.get(ii);@b@ for (int jj = 0; jj < exclusions.length; ++jj) {@b@ comparand = exclusions[jj];@b@ res = comparator.compareToIgnoreCase(comparand);@b@ if (res == 0)@b@ break label205:@b@ }@b@@b@ keeps.add(comparator);@b@ }@b@@b@ label205: splits = new String[keeps.size()];@b@ keeps.toArray(splits);@b@@b@ this_string = splits[(splits.length - 1)];@b@ ArrayList rev_for_return = new ArrayList();@b@ rev_for_return.add(this_string);@b@ for (ii = 2; ii <= splits.length; ++ii) {@b@ if (splits[(splits.length - ii)].length() > 0) {@b@ this_string = splits[(splits.length - ii)] + ";" + this_string;@b@ rev_for_return.add(this_string);@b@ }@b@@b@ }@b@@b@ ArrayList for_return = new ArrayList();@b@ String[] a_rev_for_return = new String[rev_for_return.size()];@b@ rev_for_return.toArray(a_rev_for_return);@b@ for (ii = a_rev_for_return.length - 1; ii > -1; --ii) {@b@ for_return.add(a_rev_for_return[ii]);@b@ }@b@@b@ String s = null;@b@ for (ii = 0; ii < for_return.size(); ++ii) {@b@ s = (String)for_return.get(ii);@b@ if (!(s.endsWith(";")))@b@ for_return.set(ii, s + ";");@b@@b@ }@b@@b@ s = (String)for_return.get(0);@b@ if (!(s.endsWith(";;"))) {@b@ for_return.set(0, s + ";");@b@ }@b@@b@ return for_return;@b@ }@b@@b@ public Integer getIdentifierFromFullIdentifier(String fullidentifier) throws ArrayIndexOutOfBoundsException {@b@ if (isEmpty(fullidentifier).booleanValue())@b@ return null;@b@@b@ Integer featureId = null;@b@ String[] splits = null;@b@ splits = fullidentifier.split("-");@b@ if (splits.length > 2)@b@ featureId = Integer.valueOf(Integer.parseInt(splits[2]));@b@ else@b@ featureId = Integer.valueOf(Integer.parseInt(fullidentifier));@b@@b@ return featureId;@b@ }@b@@b@ public String[] truncWordsPastLimit(String[] bnew, int limit)@b@ {@b@ if (isEmpty(bnew).booleanValue())@b@ return null;@b@@b@ Pattern w = Pattern.compile("[\\w]+\\b");@b@ String copy = new String(bnew[0]);@b@ if ((copy == null) || (copy.length() == 0))@b@ return null;@b@@b@ Matcher m = w.matcher(copy);@b@ if (m == null)@b@ return bnew;@b@@b@ boolean b = m.find();@b@ int start = m.start();@b@ int end = m.end();@b@ String last = null;@b@ String result = null;@b@ String lastrem = null;@b@ String rem = null;@b@ do {@b@ last = bnew[0];@b@ lastrem = bnew[1];@b@ bnew[1] = copy.substring(end);@b@ bnew[0] = copy.substring(0, end);@b@ b = m.find();@b@ if (b) {@b@ start = m.start();@b@ end = m.end(); }@b@ }@b@ while ((b) && (bnew[0].length() < limit));@b@ bnew[0] = last;@b@ lastrem = lastrem.replaceAll("\\p{Cntrl}", "");@b@ lastrem = lastrem.replaceAll("[ ]{2,}", " ");@b@ bnew[1] = lastrem;@b@ return bnew;@b@ }@b@}