示例#1
1
  /**
   * Gets the name.
   *
   * @return the name
   */
  public String getName() {
    StringBuilder name = new StringBuilder();

    if (!StringUtil.isNullOrEmpty(title)) {
      name.append(title);
    }

    if (!StringUtil.isNullOrEmpty(firstname)) {
      if (name.length() > 0) {
        name.append(" ");
      }

      name.append(firstname);
    }

    if (!StringUtil.isNullOrEmpty(lastname)) {
      if (name.length() > 0) {
        name.append(" ");
      }

      name.append(lastname);
    }

    return name.toString();
  }
 /*.................................................................................................................*/
 boolean checkUsernamePassword(boolean tellUserAboutCipres) {
   if (StringUtil.blank(username) || StringUtil.blank(password)) {
     MesquiteBoolean answer = new MesquiteBoolean(false);
     MesquiteString usernameString = new MesquiteString();
     if (username != null) usernameString.setValue(username);
     MesquiteString passwordString = new MesquiteString();
     if (password != null) passwordString.setValue(password);
     String help =
         "You will need an account on the CIPRes REST system to use this service.  To register, go to https://www.phylo.org/restusers/register.action";
     new UserNamePasswordDialog(
         ownerModule.containerOfModule(),
         "Sign in to CIPRes",
         help,
         "",
         "Username",
         "Password",
         answer,
         usernameString,
         passwordString);
     if (answer.getValue()) {
       username = usernameString.getValue();
       password = passwordString.getValue();
     }
     ownerModule.storePreferences();
   }
   boolean success = StringUtil.notEmpty(username) && StringUtil.notEmpty(password);
   if (!success && tellUserAboutCipres) {
     MesquiteMessage.discreetNotifyUser(
         "Use of the CIPRes service requires an account with CIPRes's REST service.  Go to https://www.phylo.org/restusers/register.action to register for an account");
   }
   return success;
 }
 /**
  * this is the primary method that sends a query to the CIPRes REST service. It expects to receive
  * an XML file, which it returns in Document if the root tag matc hes xmlRootTag
  */
 public Document cipresQuery(HttpClient httpclient, String URL, String xmlRootTag) {
   if (StringUtil.blank(URL)) return null;
   try {
     HttpGet httpget = new HttpGet(URL);
     httpget.addHeader("cipres-appkey", CIPRESkey);
     try {
       HttpResponse response = httpclient.execute(httpget);
       HttpEntity responseEntity = response.getEntity();
       InputStream instream = responseEntity.getContent();
       BufferedReader br = new BufferedReader(new InputStreamReader(instream));
       String line = "";
       StringBuffer sb = new StringBuffer();
       while ((line = br.readLine()) != null) {
         sb.append(line + StringUtil.lineEnding());
       }
       Document cipresResponseDoc = loadXMLFile(xmlRootTag, sb.toString());
       if (cipresResponseDoc != null && verbose) {
         ownerModule.logln(sb.toString());
       }
       if (cipresResponseDoc == null) {
         Document errorDoc = loadXMLFile(sb.toString());
         if (errorDoc != null) reportError(errorDoc, "Error in communicating with CIPRes", true);
       }
       EntityUtils.consume(response.getEntity());
       return cipresResponseDoc;
     } catch (IOException e) {
       Debugg.printStackTrace(e);
     } catch (Exception e) {
       Debugg.printStackTrace(e);
     }
   } catch (Exception e) {
     Debugg.printStackTrace(e);
   }
   return null;
 }
示例#4
0
  /*.................................................................................................................*/
  public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equalsIgnoreCase("setToDefaults")) {
      setDefaultTNTCommandsSearchOptions();
      searchField.setText(searchArguments);
      bootstrapSearchField.setText(bootstrapSearchArguments);
      harvestOnlyStrictConsensusBox.setState(harvestOnlyStrictConsensus);
      resamplingAllConsensusTreesBox.setState(!resamplingAllConsensusTrees);
      bootStrapRepsField.setValue(bootstrapreps);

    } else if (e.getActionCommand().equalsIgnoreCase("setToDefaultsOtherOptions")) {
      setDefaultTNTCommandsOtherOptions();
      otherOptionsField.setText(otherOptions);
      convertGapsBox.setState(convertGapsToMissing);
    } else if (e.getActionCommand().equalsIgnoreCase("browseSearchScript")
        && searchScriptPathField != null) {
      MesquiteString directoryName = new MesquiteString();
      MesquiteString fileName = new MesquiteString();
      String path =
          MesquiteFile.openFileDialog("Choose Search Script File", directoryName, fileName);
      if (StringUtil.notEmpty(path)) searchScriptPathField.setText(path);
    } else if (e.getActionCommand().equalsIgnoreCase("browseBootSearchScript")
        && bootSearchScriptPathField != null) {

      MesquiteString directoryName = new MesquiteString();
      MesquiteString fileName = new MesquiteString();
      String path =
          MesquiteFile.openFileDialog(
              "Choose Resampling Search Script File", directoryName, fileName);
      if (StringUtil.notEmpty(path)) bootSearchScriptPathField.setText(path);
    }
  }
 /*.................................................................................................................*/
 public boolean downloadWorkingResults(
     HttpClient httpclient,
     String jobURL,
     String rootDir,
     String fileName,
     boolean onlyNewOrModified) {
   if (StringUtil.blank(fileName)) return false;
   String workingUri = getWorkingDirectory(jobURL);
   if (StringUtil.notEmpty(workingUri)) {
     Document cipresResponseDoc = cipresQuery(httpclient, workingUri, "workingdir");
     if (cipresResponseDoc != null) {
       CipresJobFile[] cipresJobFiles = processFilesDocument(cipresResponseDoc);
       if (cipresJobFiles == null || cipresJobFiles.length == 0) {
         return false;
       }
       for (int job = 0; job < cipresJobFiles.length; job++) {
         if (fileName.equalsIgnoreCase(cipresJobFiles[job].getFileName())
             && (!onlyNewOrModified
                 || fileNewOrModified(previousCipresJobFiles, cipresJobFiles, job)))
           cipresDownload(
               httpclient,
               cipresJobFiles[job].getDownloadURL(),
               rootDir + cipresJobFiles[job].getFileName());
       }
       previousCipresJobFiles = cipresJobFiles.clone();
       return true;
     }
   }
   return false;
 }
示例#6
0
 /** Called to alter data in all cells */
 public boolean operateOnData(CharacterData data) {
   if (!(data instanceof ContinuousData)) return false;
   ContinuousData cData = (ContinuousData) data;
   int numItems = cData.getNumItems();
   String[] items = new String[numItems];
   for (int i = 0; i < items.length; i++) {
     if (StringUtil.blank(cData.getItemName(i))) items[i] = "(unnamed)";
     else items[i] = cData.getItemName(i);
   }
   int d =
       ListDialog.queryList(
           containerOfModule(),
           "Rename item",
           "Rename item:",
           MesquiteString.helpString,
           items,
           0);
   if (!MesquiteInteger.isCombinable(d) || d < 0 || d >= numItems) return false;
   else {
     String s =
         MesquiteString.queryString(
             containerOfModule(), "Rename Item", "New name for " + items[d], items[d]);
     if (StringUtil.blank(s)) return false;
     cData.setItemReference(d, NameReference.getNameReference(s));
     return true;
   }
 }
  /** Create LockssKeystore from a config subtree */
  LockssKeyStore createLockssKeyStore(Configuration config) {
    log.debug2("Creating LockssKeyStore from config: " + config);
    String name = config.get(KEYSTORE_PARAM_NAME);
    LockssKeyStore lk = new LockssKeyStore(name);

    String file = config.get(KEYSTORE_PARAM_FILE);
    String resource = config.get(KEYSTORE_PARAM_RESOURCE);
    String url = config.get(KEYSTORE_PARAM_URL);

    if (!StringUtil.isNullString(file)) {
      lk.setLocation(file, LocationType.File);
    } else if (!StringUtil.isNullString(resource)) {
      lk.setLocation(resource, LocationType.Resource);
    } else if (!StringUtil.isNullString(url)) {
      lk.setLocation(url, LocationType.Url);
    }

    lk.setType(config.get(KEYSTORE_PARAM_TYPE, defaultKeyStoreType));
    lk.setProvider(config.get(KEYSTORE_PARAM_PROVIDER, defaultKeyStoreProvider));
    lk.setPassword(config.get(KEYSTORE_PARAM_PASSWORD));
    lk.setKeyPassword(config.get(KEYSTORE_PARAM_KEY_PASSWORD));
    lk.setKeyPasswordFile(config.get(KEYSTORE_PARAM_KEY_PASSWORD_FILE));
    lk.setMayCreate(config.getBoolean(KEYSTORE_PARAM_CREATE, DEFAULT_CREATE));
    return lk;
  }
 /** This method simply lists the tools available */
 public void listTools(HttpClient httpclient) {
   Document cipresResponseDoc = cipresQuery(httpclient, baseURL + "/tool", "tools");
   if (cipresResponseDoc != null) {
     String elementName = "tool";
     List tools = cipresResponseDoc.getRootElement().elements(elementName);
     int count = 0;
     for (Iterator iter = tools.iterator();
         iter.hasNext(); ) { // let's get a count as to how many tools there are.
       Element nextTool = (Element) iter.next();
       count++;
     }
     String[] toolName = new String[count];
     count = 0;
     for (Iterator iter = tools.iterator(); iter.hasNext(); ) {
       Element nextTool = (Element) iter.next();
       String name = nextTool.elementText("toolId");
       if (!StringUtil.blank(name) && count < toolName.length) {
         ownerModule.logln(name);
       }
       name = nextTool.elementText("toolName");
       if (!StringUtil.blank(name) && count < toolName.length) {
         ownerModule.logln("   " + name);
       }
       count++;
     }
   }
 }
示例#9
0
 void setConfig(Configuration config) {
   log.debug("config: " + config);
   proxyHost = config.get(PARAM_PROXY_HOST);
   proxyPort = config.getInt(PARAM_PROXY_PORT, DEFAULT_PROXY_PORT);
   if (StringUtil.isNullString(proxyHost) || proxyPort <= 0) {
     String http_proxy = System.getenv("http_proxy");
     if (!StringUtil.isNullString(http_proxy)) {
       try {
         HostPortParser hpp = new HostPortParser(http_proxy);
         proxyHost = hpp.getHost();
         proxyPort = hpp.getPort();
       } catch (HostPortParser.InvalidSpec e) {
         log.warning("Can't parse http_proxy environment var, ignoring: " + http_proxy + ": " + e);
       }
     }
   }
   if (StringUtil.isNullString(proxyHost) || proxyPort <= 0) {
     proxyHost = null;
   } else {
     log.info("Proxying through " + proxyHost + ":" + proxyPort);
   }
   userAgent = config.get(PARAM_USER_AGENT);
   if (StringUtil.isNullString(userAgent)) {
     userAgent = null;
   } else {
     log.debug("Setting User-Agent to " + userAgent);
   }
 }
  /**
   * Gets background color for cell for row ic. Override it if you want to change the color from the
   * default.
   */
  public Color getBackgroundColorOfCell(int it, boolean selected) {
    if (observedStates == null) {
      doCalcs();
      if (observedStates == null) return null;
    }
    if (observedStates.getParentData() != null) {
      captureCharacterDataFromObservedStates();

      Associable tInfo = data.getTaxaInfo(false);
      NameReference genBankColor = NameReference.getNameReference("genbankcolor");
      Object obj = tInfo.getAssociatedObject(genBankColor, it); // not saved to file
      if (obj instanceof Color) return (Color) obj;
    }
    if (bits == null || it < 0 || it > bits.getSize()) return null;
    String note = getNote(it);
    if (selected) {
      if (bits.isBitOn(it)) return ColorDistribution.darkGreen;
      else return ColorDistribution.darkRed;
    } else if (bits.isBitOn(it)) {
      if (StringUtil.blank(note)) return ColorDistribution.veryLightGreen;
      if (!(note.equalsIgnoreCase("x"))) return ColorDistribution.lightGreenYellowish;
      return ColorDistribution.lightGreenYellow;
    } else {
      if (StringUtil.blank(note)) return ColorDistribution.brown;
      if (!(note.equalsIgnoreCase("x"))) {
        return Color.red;
      }
      return ColorDistribution.lightRed;
    }
  }
示例#11
0
 public void processCompletedOutputFiles(String[] outputFilePaths) {
   if (outputFilePaths.length > 1 && !StringUtil.blank(outputFilePaths[1])) {
     ZephyrUtil.copyLogFile(this, "TNT", outputFilePaths[1]);
   }
   if (outputFilePaths.length > 2 && !StringUtil.blank(outputFilePaths[2])) {
     ZephyrUtil.copyOutputText(this, outputFilePaths[2], commands);
   }
 }
示例#12
0
 // Break the line at commas, return a map of the resulting strings
 // broken at equals sign.  (<i>Ie</i>, name value pairs.)
 Map getRow(String line) {
   Map map = new HashMap();
   for (Iterator iter = StringUtil.breakAt(line, ',').iterator(); iter.hasNext(); ) {
     String item = (String) iter.next();
     List pair = StringUtil.breakAt(item, '=');
     map.put(pair.get(0), pair.get(1));
   }
   return map;
 }
示例#13
0
  /**
   * Did the client provide the minimal parameters required?
   *
   * @return true If so
   */
  private boolean verifyMinimumParameters() {
    int count = 0;

    if (!StringUtil.isNullString(getParameter(AP_E_PUBLICATION))) count++;
    if (!StringUtil.isNullString(getParameter(AP_E_CLASSNAME))) count++;
    if (!StringUtil.isNullString(getParameter(AP_E_PLUGIN))) count++;

    return (count > 0);
  }
示例#14
0
 /** Concatenate params for URL string */
 static String concatParams(String p1, String p2) {
   if (StringUtil.isNullString(p1)) {
     return p2;
   }
   if (StringUtil.isNullString(p2)) {
     return p1;
   }
   return p1 + "&" + p2;
 }
示例#15
0
 private void doSleep() throws IOException {
   String timestr = getParameter(KEY_TIME);
   try {
     long time = StringUtil.parseTimeInterval(timestr);
     Deadline.in(time).sleep();
     statusMsg = "Slept for " + StringUtil.timeIntervalToString(time);
   } catch (NumberFormatException e) {
     errMsg = "Illegal duration: " + e;
   } catch (InterruptedException e) {
     errMsg = "Interrupted: " + e;
   }
 }
示例#16
0
 private StringSet getStringSet(String key, String deli) {
   StringSet set = new StringSet();
   String v = getValue(key);
   if (v != null) {
     String[] vv = StringUtil.split(v, deli);
     for (String x : vv) {
       x = StringUtil.trimToEmpty(x);
       if (x.length() > 0) set.put(x);
     }
   }
   return set;
 }
示例#17
0
 /**
  * 从一个string类型的list中移出没有实际内容(包括只含空格内容)的元素 返回一个新的list
  *
  * @param list
  * @return
  */
 public static List<String> filterBlankElements(List<String> list) {
   List<String> result = new ArrayList<String>();
   if (list == null || list.isEmpty()) {
     return result;
   }
   for (String element : list) {
     if (StringUtil.isEmpty(element) || StringUtil.isEmpty(element.trim())) {
       continue;
     }
     result.add(element);
   }
   return result;
 }
 private static void appendHTML(JEditorPane editor, String html) {
   try {
     html = StringUtil.replaceAll(html, "\t", "&nbsp;&nbsp;&nbsp;&nbsp;");
     html = StringUtil.replaceAll(html, "\r\n", "\n");
     html = StringUtil.replaceAll(html, "\r", "");
     Vector vt = StringUtil.toStringVector(html, "\n");
     HTMLEditorKit kit = (HTMLEditorKit) editor.getEditorKit();
     HTMLDocument doc = (HTMLDocument) editor.getDocument();
     for (int iIndex = 0; iIndex < vt.size(); iIndex++)
       kit.insertHTML(doc, doc.getLength(), (String) vt.elementAt(iIndex), 0, 0, null);
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
示例#19
0
 /** Concatenate params for URL string */
 String concatParams(Properties props) {
   if (props == null) {
     return null;
   }
   java.util.List list = new ArrayList();
   for (Iterator iter = props.keySet().iterator(); iter.hasNext(); ) {
     String key = (String) iter.next();
     String val = props.getProperty(key);
     if (!StringUtil.isNullString(val)) {
       list.add(key + "=" + urlEncode(val));
     }
   }
   return StringUtil.separatedString(list, "&");
 }
  /*.................................................................................................................*/
  public boolean monitorAndCleanUpShell(String jobURL) {
    boolean stillGoing = true;

    if (!checkUsernamePassword(true)) {
      return false;
    }
    lastModified = null;
    if (outputFilePaths != null) {
      lastModified = new long[outputFilePaths.length];
      LongArray.deassignArray(lastModified);
    }
    String status = "";
    while (!jobCompleted(jobURL) && stillGoing) {
      if (StringUtil.blank(status))
        ownerModule.logln(
            "CIPRes Job Status: " + getJobStatus(jobURL) + "  (" + StringUtil.getDateTime() + ")");

      //	if (jobSubmitted(jobURL))
      //		processOutputFiles();
      try {
        Thread.sleep(minPollIntervalSeconds * 1000);
      } catch (InterruptedException e) {
        MesquiteMessage.notifyProgrammer("InterruptedException in CIPRes monitoring");
        return false;
      }

      stillGoing = watcher == null || watcher.continueShellProcess(null);
      String newStatus = getJobStatus(jobURL);
      if (newStatus != null && !newStatus.equalsIgnoreCase(status)) {
        ownerModule.logln(
            "CIPRes Job Status: " + newStatus + "  (" + StringUtil.getDateTime() + ")");
        status = newStatus;
      } else ownerModule.log(".");
      if (newStatus != null && newStatus.equalsIgnoreCase("SUBMITTED")) { // job is running
        processOutputFiles(jobURL);
      }
    }
    ownerModule.logln("CIPRes job completed.");
    if (outputFileProcessor != null) {
      if (rootDir != null) {
        ownerModule.logln("About to download results from CIPRes.");
        if (downloadResults(jobURL, rootDir, false))
          outputFileProcessor.processCompletedOutputFiles(outputFilePaths);
        else return false;
      }
    }

    return true;
  }
示例#21
0
 protected Properties filterResponseProps(Properties props) {
   Properties res = new Properties();
   for (Map.Entry ent : props.entrySet()) {
     String key = (String) ent.getKey();
     if (StringUtil.startsWithIgnoreCase(key, "x-lockss")
         || StringUtil.startsWithIgnoreCase(key, "x_lockss")
         || key.equalsIgnoreCase("org.lockss.version.number")) {
       continue;
     }
     // We've lost the original case - capitalize them the way most people
     // expect
     res.put(StringUtil.titleCase(key, '-'), (String) ent.getValue());
   }
   return res;
 }
  protected String doHandleGet(UserSession ctx, String link, Map args) {
    PhotoFilter filter = ctx.getPhotoFilter();

    String un = ctx.getAsString(args, PhotoFilter.USER_NAME);
    if (StringUtil.isLegalUserName(un)) {
      filter.setUserName(un);
    }

    String tags = ctx.getAsString(args, PhotoFilter.TAGS);
    if (StringUtil.isLegalTagsString(tags)) {
      filter.setTags(new Tags(tags));
    }

    return PartUtil.SHOW_PHOTO_PAGE_NAME;
  }
  /*.................................................................................................................*/
  public boolean downloadResults(
      HttpClient httpclient, String jobURL, String rootDir, boolean onlyNewOrModified) {

    String resultsUri = getResultsDirectory(jobURL);
    if (StringUtil.notEmpty(resultsUri)) {
      Document cipresResponseDoc = cipresQuery(httpclient, resultsUri, "results");
      if (cipresResponseDoc != null) {
        CipresJobFile[] cipresJobFiles = processFilesDocument(cipresResponseDoc);
        if (cipresJobFiles == null || cipresJobFiles.length == 0) {
          ownerModule.logln(cipresResponseDoc.toString());
          return false;
        }
        for (int job = 0; job < cipresJobFiles.length; job++) {
          if (!onlyNewOrModified || fileNewOrModified(previousCipresJobFiles, cipresJobFiles, job))
            cipresDownload(
                httpclient,
                cipresJobFiles[job].getDownloadURL(),
                rootDir + cipresJobFiles[job].getFileName());
        }
        previousCipresJobFiles = cipresJobFiles.clone();
        return true;
      }
    }
    return false;
  }
 public String[] getJobURLs(Document cipresResponseDoc) {
   String elementName = "jobstatus";
   Element jobs = cipresResponseDoc.getRootElement().element("jobs");
   if (jobs == null) return null;
   List tools = jobs.elements("jobstatus");
   int count = 0;
   for (Iterator iter = tools.iterator(); iter.hasNext(); ) {
     Element nextTool = (Element) iter.next();
     count++;
   }
   String[] url = new String[count];
   count = 0;
   for (Iterator iter = tools.iterator(); iter.hasNext(); ) {
     Element nextJob = (Element) iter.next();
     if (nextJob != null) {
       Element selfUriElement = nextJob.element("selfUri");
       if (selfUriElement != null) {
         String jobURL = selfUriElement.elementText("url");
         if (!StringUtil.blank(jobURL) && count < url.length) {
           url[count] = jobURL;
         }
       }
       count++;
     }
   }
   return url;
 }
示例#25
0
  /**
   * A target system is required to create an AU - was it provided?
   *
   * @return true If at least one target was specified
   */
  private boolean verifyTarget() {
    if (!isCreateCommand()) {
      return true;
    }

    return !StringUtil.isNullString(getParameter(AP_E_TARGET));
  }
  /*................................................................................................*/
  public boolean startJob(String arguments, Object condition, boolean hiredByName) {
    addMenuItem("Directory for Sample Trees From Directory...", makeCommand("setDirPath", this));
    fillerTasks = new Vector();
    if (!MesquiteThread
        .isScripting()) { // enclosed in conditional to avoid hiring query when opening file; should
      // be handled by snapshot/doCommand when file is opened.
      String directoryPath =
          MesquiteFile.chooseDirectory(
              "Choose directory containing tree files:",
              previousDirectory); // MesquiteFile.saveFileAsDialog("Base name for files (files will
      // be named <name>1.nex, <name>2.nex, etc.)", baseName);

      if (StringUtil.blank(directoryPath)) { // TODO: clean this up?
        return false;
      } else {
        directory = new File(directoryPath);
        previousDirectory = directory.getParent();
        if (directory.exists() && directory.isDirectory()) {
          return hireFillers(directoryPath);
        }
      }
    }
    return true; // Add something to make sure directory paths are set up correctly, when not
    // scripting...
  }
  /*................................................................................................*/
  private boolean hireFillers(String directoryPath) {
    String[] files = directory.list();
    String treePath;
    for (int i = 0; i < files.length; i++) {
      if (files[i] != null) {
        String fileLowerCase = files[i].toLowerCase();
        if (fileLowerCase.endsWith(".nex") || fileLowerCase.endsWith(".nexus")) {
          treePath = directoryPath + MesquiteFile.fileSeparator + files[i];
          File treeFile = new File(treePath);
          String treeFileName = treeFile.getName();
          if (StringUtil.blank(treeFileName)) {
            return false;
          }
          TreeBlockFiller newFiller;
          newFiller =
              (TreeBlockFiller)
                  hireNamedEmployee(TreeBlockFiller.class, "#SampleOneTreeFromFile"); // treePath);
          if (newFiller != null) {
            if (((SampleOneTreeFromFile) newFiller).setFilePath(treePath)
                && ((SampleOneTreeFromFile) newFiller).processFile()) {
              fillerTasks.addElement(newFiller);
            } else
              Debugg.println(
                  "Filler "
                      + i
                      + " processFile = "
                      + ((SampleOneTreeFromFile) newFiller).processFile());
          }
        }
      }
    }

    return true;
  }
  /** monitors the run. */
  public boolean monitorAndCleanUpShell() {
    lastModified = null;
    boolean stillGoing = true;
    if (outputFilePaths != null) {
      lastModified = new long[outputFilePaths.length];
      LongArray.deassignArray(lastModified);
    }

    if (!StringUtil.blank(
        runningFilePath)) // is file at runningFilePath; watch for its disappearance
    while (MesquiteFile.fileExists(runningFilePath) && stillGoing) {
        processOutputFiles();
        try {
          Thread.sleep(sleepTime);
        } catch (InterruptedException e) {
          MesquiteMessage.notifyProgrammer(
              "InterruptedException in shell script executed by " + name);
          return false;
        }
        stillGoing = watcher == null || watcher.continueShellProcess(proc);
      }

    if (outputFileProcessor != null)
      outputFileProcessor.processCompletedOutputFiles(outputFilePaths);
    return true;
  }
示例#29
0
  public static ArrayList<String> getTagListFromString(String tags, char separator) {
    ArrayList<String> result = new ArrayList<String>(8);

    if (tags != null) {
      int i = 0;
      int j = 0;
      for (; i < tags.length(); i = j) {
        for (; ((i < tags.length()) && (tags.charAt(i) == separator)); ) {
          i++;
        }

        for (j = i; ((j < tags.length()) && (tags.charAt(j) != separator)); ) {
          j++;
        }

        if (i != j) {
          String tag = asTag(tags.substring(i, j));
          if (!result.contains(tag) && !StringUtil.isNullOrEmptyString(tag)) {
            result.add(tag);
          }
        }
      }
    }

    return result;
  }
示例#30
0
 protected void logParams() {
   Enumeration en = req.getParameterNames();
   while (en.hasMoreElements()) {
     String name = (String) en.nextElement();
     String vals[];
     String dispval;
     if (StringUtil.indexOfIgnoreCase(name, "passw") >= 0) {
       dispval = req.getParameter(name).length() == 0 ? "" : "********";
     } else if (log.isDebug2() && (vals = req.getParameterValues(name)).length > 1) {
       dispval = StringUtil.separatedString(vals, ", ");
     } else {
       dispval = req.getParameter(name);
     }
     log.debug(name + " = " + dispval);
   }
 }