public String getUrl() {
    StringBuilder sb = new StringBuilder();
    StringBuilder ori = getOut();
    this.setOut(sb);
    TreeMap<Integer, cn.bran.japid.template.ActionRunner> parentActionRunners = actionRunners;
    actionRunners = new TreeMap<Integer, cn.bran.japid.template.ActionRunner>();
    // line 48, japidviews\AdminController\flashPurchaseList.html
    p("            	"); // line 48, japidviews\AdminController\flashPurchaseList.html
    p(
        lookup(
            "AdminController.flashPurchaseList",
            new Object[] {})); // line 49, japidviews\AdminController\flashPurchaseList.html
    p("            "); // line 49, japidviews\AdminController\flashPurchaseList.html

    this.setOut(ori);
    if (actionRunners.size() > 0) {
      StringBuilder _sb2 = new StringBuilder();
      int segStart = 0;
      for (Map.Entry<Integer, cn.bran.japid.template.ActionRunner> _arEntry :
          actionRunners.entrySet()) {
        int pos = _arEntry.getKey();
        _sb2.append(sb.substring(segStart, pos));
        segStart = pos;
        cn.bran.japid.template.ActionRunner _a_ = _arEntry.getValue();
        _sb2.append(_a_.run().getContent().toString());
      }
      _sb2.append(sb.substring(segStart));
      actionRunners = parentActionRunners;
      return _sb2.toString();
    } else {
      actionRunners = parentActionRunners;
      return sb.toString();
    }
  }
  public static UUID generateUuidForName(String name) {
    TFM_Log.info("Generating spoof UUID for " + name);
    name = name.toLowerCase();
    try {
      final MessageDigest mDigest = MessageDigest.getInstance("SHA1");
      byte[] result = mDigest.digest(name.getBytes());
      final StringBuilder sb = new StringBuilder();
      for (int i = 0; i < result.length; i++) {
        sb.append(Integer.toString((result[i] & 0xff) + 0x100, 16).substring(1));
      }

      return UUID.fromString(
          sb.substring(0, 8)
              + "-"
              + sb.substring(8, 12)
              + "-"
              + sb.substring(12, 16)
              + "-"
              + sb.substring(16, 20)
              + "-"
              + sb.substring(20, 32));
    } catch (NoSuchAlgorithmException ex) {
      TFM_Log.severe(ex);
    }

    return UUID.randomUUID();
  }
Exemple #3
1
  /**
   * Static method that removes path and filetype from pathname.
   *
   * @param inString <code>String</code> containing filename with possible extension
   */
  static String toStubName(String inString) {

    File F = new File(inString);
    String name = F.getName(); // strips pathname from filename

    StringBuilder buf = new StringBuilder(name);
    String stubName;

    stubName = null;

    int dotIndex = buf.length(); // point to last char
    while (dotIndex > 0) {
      dotIndex--;
      if (buf.charAt(dotIndex) == '.') // look for file type sep
      {
        break;
      }
    }

    if (dotIndex > 0) {
      stubName = buf.substring(0, dotIndex);
    }

    return stubName;
  }
Exemple #4
1
 @Override
 public String getHeaderField(final String field) {
   final List<String> values = headers.get(field);
   final StringBuilder sb = new StringBuilder();
   for (final String v : values) sb.append(v).append(';');
   return sb.substring(0, sb.length() - 1);
 }
Exemple #5
1
 private String getTag(Document d) {
   StringBuilder ab =
       new StringBuilder(
           d.getValues(DocumentBuilder.FIELD_NAME_IDENTIFIER)[0].replace(
               "E:\\I:\\ACM_complete_dataset\\", ""));
   return ab.substring(0, ab.indexOf("\\")).toString();
 }
Exemple #6
1
 private CIJobStatus deleteCI(CIJob job, List<String> builds) throws PhrescoException {
   S_LOGGER.debug("Entering Method CIManagerImpl.deleteCI(CIJob job)");
   S_LOGGER.debug("Job name " + job.getName());
   cli = getCLI(job);
   String deleteType = null;
   List<String> argList = new ArrayList<String>();
   S_LOGGER.debug("job name " + job.getName());
   S_LOGGER.debug("Builds " + builds);
   if (CollectionUtils.isEmpty(builds)) { // delete job
     S_LOGGER.debug("Job deletion started");
     S_LOGGER.debug("Command " + FrameworkConstants.CI_JOB_DELETE_COMMAND);
     deleteType = DELETE_TYPE_JOB;
     argList.add(FrameworkConstants.CI_JOB_DELETE_COMMAND);
     argList.add(job.getName());
   } else { // delete Build
     S_LOGGER.debug("Build deletion started");
     deleteType = DELETE_TYPE_BUILD;
     argList.add(FrameworkConstants.CI_BUILD_DELETE_COMMAND);
     argList.add(job.getName());
     StringBuilder result = new StringBuilder();
     for (String string : builds) {
       result.append(string);
       result.append(",");
     }
     String buildNos = result.substring(0, result.length() - 1);
     argList.add(buildNos);
     S_LOGGER.debug("Command " + FrameworkConstants.CI_BUILD_DELETE_COMMAND);
     S_LOGGER.debug("Build numbers " + buildNos);
   }
   try {
     int status = cli.execute(argList);
     String message = deleteType + " deletion started in jenkins";
     if (status == FrameworkConstants.JOB_STATUS_NOTOK) {
       deleteType = deleteType.substring(0, 1).toLowerCase() + deleteType.substring(1);
       message = "Error while deleting " + deleteType + " in jenkins";
     }
     S_LOGGER.debug("Delete CI Status " + status);
     S_LOGGER.debug("Delete CI Message " + message);
     return new CIJobStatus(status, message);
   } finally {
     if (cli != null) {
       try {
         cli.close();
       } catch (IOException e) {
         if (debugEnabled) {
           S_LOGGER.error(
               "Entered into catch block of CIManagerImpl.deleteCI(CIJob job) "
                   + e.getLocalizedMessage());
         }
       } catch (InterruptedException e) {
         if (debugEnabled) {
           S_LOGGER.error(
               "Entered into catch block of CIManagerImpl.deleteCI(CIJob job) "
                   + e.getLocalizedMessage());
         }
       }
     }
   }
 }
Exemple #7
1
 /**
  * Adds human readable shortcuts to the specified string.
  *
  * @param str text of tooltip
  * @param sc shortcut
  * @return tooltip
  */
 public static String addShortcut(final String str, final String sc) {
   if (sc == null || str == null) return str;
   final StringBuilder sb = new StringBuilder();
   for (final String s : sc.split(" ")) {
     String t = "%".equals(s) ? Prop.MAC ? "meta" : "control" : s;
     if (t.length() != 1) t = Toolkit.getProperty("AWT." + t.toLowerCase(Locale.ENGLISH), t);
     sb.append('+').append(t);
   }
   return str + " (" + sb.substring(1) + ')';
 }
Exemple #8
1
 public void searchTags() {
   StringBuilder strTags = new StringBuilder();
   for (int i = 0; i < tempStrBuilder.length() - 1; i++) {
     i = tempStrBuilder.indexOf("<");
     if (i == -1) {
       break;
     }
     strTags.append(tempStrBuilder.substring(i, tempStrBuilder.indexOf(">") + 1));
     tempStrBuilder.delete(i, tempStrBuilder.indexOf(">") + 1);
     tags.add(strTags.toString());
     strTags.delete(0, strTags.length());
   }
 }
 private void expect(StringBuilder src, String expected) throws RequestMessageParsingException {
   String actual = src.substring(0, expected.length());
   if (!actual.equals(expected)) {
     String message = String.format("Expected \"%s\" next in \"%s\".", expected, src.toString());
     throw new RequestMessageParsingException(message);
   }
   src.delete(0, expected.length());
 }
  private String readUntil(StringBuilder src, String stop) throws RequestMessageParsingException {
    int stopIndex = src.indexOf(stop);

    if (stopIndex == -1) {
      String message = String.format("String \"%s\" not found in \"%s\".", stop, src.toString());
      throw new RequestMessageParsingException(message);
    }

    String res = src.substring(0, stopIndex);
    src.delete(0, stopIndex);
    return res;
  }
Exemple #11
0
 @Override
 public void processTerminated(ProcessEvent event) {
   if (firstUnprocessedIndex < output.length()) {
     handleSkippedOutput(output.substring(firstUnprocessedIndex).trim());
   }
   int exitCode = event.getExitCode();
   // 0 is normal, 1 is "errors found" — handled by the messages above
   if (exitCode != 0 && exitCode != 1) {
     compileContext.addMessage(
         ERROR, "Compiler terminated with exit code: " + exitCode, "", -1, -1);
   }
 }
  /**
   * Advances to the next sequence in the database file and returns true unless there is no more
   * sequences in the file and then false is returned.
   *
   * @return false if we are already at the end of the file else true
   */
  public boolean gotoNextSequence() {
    if (reader == null) {
      throw new MprcException(
          "FASTA stream not initalized properly. Call beforeFirst() before reading first sequence");
    }
    // we should have been left after reading a header because that is how we detect
    // the end of the next sequence
    if (nextHeader == null) {
      return false;
    }
    this.currentHeader = nextHeader;

    // read in lines until we reach the next header
    final StringBuilder sequenceBuilder = new StringBuilder();
    String nextLine = null;
    try {
      nextLine = this.reader.readLine();
    } catch (IOException e) {
      LOGGER.warn(e);
    }
    // if the next line is not a header or an end of line then append it to the sequence
    while (isSequence(nextLine)) {
      sequenceBuilder.append(cleanupSequence(nextLine));
      try {
        // read in the next line
        nextLine = this.reader.readLine();
      } catch (IOException e) {
        LOGGER.warn(e);
      }
    }

    while (nextLine != null && !isHeader(nextLine)) {
      try {
        nextLine = this.reader.readLine();
      } catch (IOException e) {
        LOGGER.warn(e);
      }
    }
    this.nextHeader = nextLine;

    // set the current sequence to the concatenation of all strings
    // If the sequence ends with an * signalizing end codon, quietly drop it
    if (sequenceBuilder.charAt(sequenceBuilder.length() - 1) == '*') {
      currentSequence = sequenceBuilder.substring(0, sequenceBuilder.length() - 1);
    } else {
      currentSequence = sequenceBuilder.toString();
    }

    // return true since we will have a next header
    return true;
  }
Exemple #13
0
 public static void putCommaSeparatedStringList(Bundle b, String key, ArrayList<String> list) {
   if (list != null) {
     StringBuilder builder = new StringBuilder();
     for (String string : list) {
       builder.append(string);
       builder.append(",");
     }
     String commaSeparated = "";
     if (builder.length() > 0) {
       commaSeparated = builder.substring(0, builder.length() - 1);
     }
     b.putString(key, commaSeparated);
   }
 }
Exemple #14
0
 private String trim(String s) {
   int minIndent = 1000;
   final String[] lines = s.split("\n");
   for (final String line : lines) {
     int pos = 0;
     while (pos < line.length() && line.charAt(pos) <= ' ') {
       pos++;
     }
     if (pos < line.length() && pos < minIndent) {
       minIndent = pos;
     }
   }
   final StringBuilder sb = new StringBuilder();
   for (final String line : lines) {
     sb.append(line.length() >= minIndent ? line.substring(minIndent) : line).append('\n');
   }
   return s.endsWith("\n") ? sb.toString() : sb.substring(0, sb.length() - 1);
 }
  /**
   * Add multiple new nodes (SpeciesZoneType objects) to a manipulation and then submit. HJR
   *
   * @param manipSpeciesMap - species being added
   * @param fullSpeciesMap - full list; for predator/prey info
   * @param timestep
   * @param isFirstManipulation
   * @param networkOrManipulationId
   * @return manipulation ID (String)
   * @throws SimulationException
   */
  public String addMultipleSpeciesType(
      HashMap<Integer, SpeciesZoneType> manipSpeciesMap,
      HashMap<Integer, SpeciesZoneType> fullSpeciesMap,
      int timestep,
      boolean isFirstManipulation,
      String networkOrManipulationId) {

    // job.setNode_Config("5,
    // [5],2000,1.000,1,K=9431.818,0,
    // [14],1751,20.000,1,X=0.273,0,
    // [31],1415,0.008,1,X=1.000,0,
    // [42],240,0.205,1,X=0.437,0,
    // [70],2494,13.000,1,X=0.155,0");

    //		  		  In addMultipleSpeciesType: node [70], biomass 2494, K = -1, R = -1.0000, X = 0.1233
    //				  In addMultipleSpeciesType: node [5], biomass 2000, K = 10000, R = 1.0000, X = 0.5000
    //				  In addMultipleSpeciesType: node [42], biomass 240, K = -1, R = -1.0000, X = 0.3478
    //				  In addMultipleSpeciesType: node [31], biomass 1415, K = -1, R = -1.0000, X = 0.7953
    //				  In addMultipleSpeciesType: node [14], biomass 1752, K = -1, R = -1.0000, X = 0.0010
    StringBuilder builder = new StringBuilder();
    builder.append(fullSpeciesMap.size()).append(",");
    for (SpeciesZoneType species : fullSpeciesMap.values()) {
      System.out.printf(
          "In addMultipleSpeciesType: node [%d], " + "biomass %d, K = %d, R = %6.4f, X = %6.4f\n",
          species.getNodeIndex(),
          +(int) species.getCurrentBiomass(),
          (int) species.getParamK(),
          species.getParamR(),
          species.getParamX());

      builder.append("[").append(species.getNodeIndex()).append("]").append(",");
      builder.append((int) species.getCurrentBiomass()).append(",");
      builder.append(roundToThreeDigits(species.getPerSpeciesBiomass())).append(",");

      String systemParam = this.setSystemParameters(species, fullSpeciesMap, timestep);
      builder.append(systemParam);
      System.out.println(builder);
    }
    String node_config = builder.substring(0, builder.length() - 1);
    // call processsim job here
    return node_config;
  }
Exemple #16
0
  /**
   * Extract the XML message and construct validated Message object based on the terminator string
   * (either "</request>" or "</response>"). Returns null if communication is interrupted in any
   * way.
   */
  static Message extractMessage(BufferedReader in, String terminator) {
    try {
      String line = in.readLine();
      if (line == null) {
        return null;
      }
      StringBuilder buf = new StringBuilder(line);
      while (!buf.substring(buf.length() - terminator.length(), buf.length()).equals(terminator)) {
        line = in.readLine();
        if (line == null) {
          return null;
        }
        buf.append(line);
      }

      return new Message(buf.toString());
    } catch (IOException ioe) {
      return null;
    }
  }
 public static String getOperationsList() {
   StringBuilder sb = new StringBuilder();
   for (String s : getPropertyFile().stringPropertyNames()) sb.append("'").append(s).append("', ");
   if (sb.length() < 3) return "";
   return sb.substring(0, sb.length() - 2);
 }
  /**
   * returns null on eof. throws exception or returns parsed object.
   *
   * @return
   * @throws java.io.IOException
   */
  public DynMap readNext() throws TrendrrException {
    StringBuilder json = new StringBuilder("{");
    try {
      long numRead = 0;
      int openBrackets = 1;
      boolean isQuote = false;
      boolean isEscape = false;

      // read until the first open bracket
      int current = this.reader.read();
      while (current != '{' && current != -1) {
        numRead++;
        if (numRead > this.maxBufferedChars) {
          throw new TrendrrParseException(
              "Read "
                  + this.maxBufferedChars
                  + " chars without a valid json dict.  Beginning with: "
                  + json.substring(0, 256));
        }
        current = this.reader.read();
      }

      do {
        current = this.reader.read();
        if (current == -1) {
          return null;
        }
        char c = (char) current;
        json.append(c);
        if (!isQuote) {
          if (c == '{') {
            openBrackets++;
          } else if (c == '}') {
            openBrackets--;
          }
        }
        if (c == '"' && !isEscape) {
          isQuote = !isQuote;
        }

        if (isQuote && !isEscape && c == '\\') {
          isEscape = true;
        } else {
          isEscape = false;
        }

        numRead++;
        if (numRead > this.maxBufferedChars) {
          throw new TrendrrParseException(
              "Read "
                  + this.maxBufferedChars
                  + " chars without a valid json dict.  Beginning with: "
                  + json.substring(0, 256));
        }
      } while (openBrackets != 0);

      DynMap dm = DynMapFactory.instanceFromJSON(json.toString());
      if (dm == null) {
        throw new TrendrrParseException("unable to parse json string");
      }
      return dm;
    } catch (IOException x) {
      throw new TrendrrIOException(x);
    }
  }