Exemplo n.º 1
1
  /**
   * Appends a json encoded key/value pair to the given string builder.
   *
   * @param json
   * @param key
   * @param value
   * @throws UnsupportedEncodingException
   */
  private static void appendJSONPair(StringBuilder json, String key, String value)
      throws UnsupportedEncodingException {
    boolean isValueNumeric = false;

    try {
      if (value.equals("0") || !value.endsWith("0")) {
        Double.parseDouble(value);
        isValueNumeric = true;
      }
    } catch (NumberFormatException e) {
      isValueNumeric = false;
    }

    if (json.charAt(json.length() - 1) != '{') {
      json.append(',');
    }

    json.append(escapeJSON(key));
    json.append(':');

    if (isValueNumeric) {
      json.append(value);
    } else {
      json.append(escapeJSON(value));
    }
  }
  /**
   * converts back slashes to forward slashes removes double slashes inside the path, e.g. "x/y//z"
   * => "x/y/z"
   */
  @NotNull
  public static String normalize(@NotNull String path) {
    final StringBuilder result = new StringBuilder(path.length());

    int start = 0;
    boolean separator = false;
    if (SystemInfo.isWindows && (path.startsWith("//") || path.startsWith("\\\\"))) {
      start = 2;
      result.append("//");
      separator = true;
    }

    for (int i = start; i < path.length(); ++i) {
      final char c = path.charAt(i);
      if (c == '/' || c == '\\') {
        if (!separator) result.append('/');
        separator = true;
      } else {
        result.append(c);
        separator = false;
      }
    }

    return result.toString();
  }
Exemplo n.º 3
1
  public static String formatBranches(
      LogInformation.Revision revision, boolean useNumbersIfNamesNotAvailable) {
    String branches = revision.getBranches();
    if (branches == null) return ""; // NOI18N

    boolean branchNamesAvailable = true;
    StringBuilder branchNames = new StringBuilder();
    StringTokenizer st = new StringTokenizer(branches, ";"); // NOI18N
    while (st.hasMoreTokens()) {
      String branchNumber = st.nextToken().trim();
      List<LogInformation.SymName> names =
          revision
              .getLogInfoHeader()
              .getSymNamesForRevision(createBranchRevisionNumber(branchNumber));
      if (names.size() > 0) {
        branchNames.append(names.get(0).getName());
      } else {
        branchNamesAvailable = false;
        if (useNumbersIfNamesNotAvailable) {
          branchNames.append(branchNumber);
        } else {
          break;
        }
      }
      branchNames.append("; "); // NOI18N
    }
    if (branchNamesAvailable || useNumbersIfNamesNotAvailable) {
      branchNames.delete(branchNames.length() - 2, branchNames.length());
    } else {
      branchNames.delete(0, branchNames.length());
    }
    return branchNames.toString();
  }
Exemplo n.º 4
1
 /**
  * Returns a map with variable bindings.
  *
  * @param opts main options
  * @return bindings
  */
 public static HashMap<String, String> bindings(final MainOptions opts) {
   final HashMap<String, String> bindings = new HashMap<>();
   final String bind = opts.get(MainOptions.BINDINGS).trim();
   final StringBuilder key = new StringBuilder();
   final StringBuilder val = new StringBuilder();
   boolean first = true;
   final int sl = bind.length();
   for (int s = 0; s < sl; s++) {
     final char ch = bind.charAt(s);
     if (first) {
       if (ch == '=') {
         first = false;
       } else {
         key.append(ch);
       }
     } else {
       if (ch == ',') {
         if (s + 1 == sl || bind.charAt(s + 1) != ',') {
           bindings.put(key.toString().trim(), val.toString());
           key.setLength(0);
           val.setLength(0);
           first = true;
           continue;
         }
         // literal commas are escaped by a second comma
         s++;
       }
       val.append(ch);
     }
   }
   if (key.length() != 0) bindings.put(key.toString().trim(), val.toString());
   return bindings;
 }
Exemplo n.º 5
1
 /**
  * Returns a tooltip for the specified options string.
  *
  * @param opts serialization options
  * @return string
  */
 private static String tooltip(final Options opts) {
   final StringBuilder sb = new StringBuilder("<html><b>").append(PARAMETERS).append(":</b><br>");
   for (final Option<?> so : opts) {
     if (!(so instanceof OptionsOption)) sb.append("\u2022 ").append(so).append("<br/>");
   }
   return sb.append("</html>").toString();
 }
Exemplo n.º 6
1
  @Override
  public String toString() {
    /* Condition validation */
    if (this._bytes == null || this._bytes.length == 0) return "<>";

    char[] _hexTable = {
      '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
    };

    // Calculate length
    int c = this._bytes.length * 2;
    int r = this._bytes.length % 4;
    int a = (this._bytes.length - r) >> 2;
    StringBuilder builder = new StringBuilder(c + a + 2);

    builder.append('<');
    for (int i = 0; i < this._bytes.length; i++) {
      int b = this._bytes[i] & 0xff;
      builder.append(_hexTable[(b >> 4)]);
      builder.append(_hexTable[(b & 0x0f)]);

      if (i > 0 && i < (this._bytes.length - 1) && ((i + 1) % 4) == 0) {
        builder.append(' ');
      }
    }
    builder.append('>');
    return builder.toString();
  }
Exemplo n.º 7
1
  // ## operation writeChemkinSpecies(ReactionModel,SystemSnapshot)
  public static String writeChemkinSpecies(
      ReactionModel p_reactionModel, SystemSnapshot p_beginStatus) {
    // #[ operation writeChemkinSpecies(ReactionModel,SystemSnapshot)

    StringBuilder result = new StringBuilder();
    result.append("SPECIES\n");

    CoreEdgeReactionModel cerm = (CoreEdgeReactionModel) p_reactionModel;

    // write inert gas
    for (Iterator iter = p_beginStatus.getInertGas(); iter.hasNext(); ) {
      String name = (String) iter.next();
      result.append('\t' + name + '\n');
    }

    // write species
    for (Iterator iter = cerm.getSpecies(); iter.hasNext(); ) {
      Species spe = (Species) iter.next();
      result.append('\t' + spe.getChemkinName() + '\n');
    }

    result.append("END\n");

    return result.toString();

    // #]
  }
Exemplo n.º 8
1
  private void read() throws FileNotFoundException {
    mapKeyWords = new HashMap<>();
    StringBuilder sb = new StringBuilder();
    try {

      BufferedReader in = new BufferedReader(new FileReader(fNameInput));
      try {
        // В цикле построчно считываем файл
        String s;
        while ((s = in.readLine()) != null) {
          sb.append(s);

          sb.append("\n");
        }
      } finally {
        // Также не забываем закрыть файл
        in.close();
      }
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
    String[] str = sb.toString().split(" ");
    for (String s : str) {
      if (keyWords.findString(s) == 1) {
        putStringToMap(s);
      }
    }
    System.out.println(mapKeyWords);
  }
Exemplo n.º 9
1
 /**
  * Removes comments from the specified string and returns the first characters of a query.
  *
  * @param qu query string
  * @param max maximum length of string to return
  * @return result
  */
 public static String removeComments(final String qu, final int max) {
   final StringBuilder sb = new StringBuilder();
   int m = 0;
   boolean s = false;
   final int cl = qu.length();
   for (int c = 0; c < cl && sb.length() < max; ++c) {
     final char ch = qu.charAt(c);
     if (ch == 0x0d) continue;
     if (ch == '(' && c + 1 < cl && qu.charAt(c + 1) == ':') {
       if (m == 0 && !s) {
         sb.append(' ');
         s = true;
       }
       ++m;
       ++c;
     } else if (m != 0 && ch == ':' && c + 1 < cl && qu.charAt(c + 1) == ')') {
       --m;
       ++c;
     } else if (m == 0) {
       if (ch > ' ') sb.append(ch);
       else if (!s) sb.append(' ');
       s = ch <= ' ';
     }
   }
   if (sb.length() >= max) sb.append("...");
   return sb.toString().trim();
 }
 public static void main(String[] args) {
   InputReader1 sc = new InputReader1(System.in);
   int N = sc.nextInt();
   for (int i = 0; i <= N; i++) map.add(new ArrayList<Edge>());
   for (int i = 1; i < N; i++) {
     int x = sc.nextInt(), y = sc.nextInt(), z = sc.nextInt();
     map.get(x).add(new Edge(y, i));
     map.get(y).add(new Edge(x, i));
     edges[i] = z;
   }
   StringBuilder op = new StringBuilder();
   for (int i = 1; i <= N; i++) {
     dfs(i, 0, -1);
   }
   int temp = ans / 2;
   op.append(temp).append("\n");
   int Q = sc.nextInt();
   while (Q-- > 0) {
     ans = 0;
     int edgeNumber = sc.nextInt(), newEdgeCost = sc.nextInt();
     edges[edgeNumber] = newEdgeCost;
     for (int i = 1; i <= N; i++) {
       dfs(i, 0, -1);
     }
     temp = ans / 2;
     op.append(temp).append("\n");
   }
   System.out.println(op);
 }
Exemplo n.º 11
1
Arquivo: Macro.java Projeto: bramk/bnd
 public static void verifyCommand(
     String args[],
     @SuppressWarnings("unused") String help,
     Pattern[] patterns,
     int low,
     int high) {
   String message = "";
   if (args.length > high) {
     message = "too many arguments";
   } else if (args.length < low) {
     message = "too few arguments";
   } else {
     for (int i = 0; patterns != null && i < patterns.length && i < args.length; i++) {
       if (patterns[i] != null) {
         Matcher m = patterns[i].matcher(args[i]);
         if (!m.matches())
           message +=
               String.format(
                   "Argument %s (%s) does not match %s%n", i, args[i], patterns[i].pattern());
       }
     }
   }
   if (message.length() != 0) {
     StringBuilder sb = new StringBuilder();
     String del = "${";
     for (String arg : args) {
       sb.append(del);
       sb.append(arg);
       del = ";";
     }
     sb.append("}, is not understood. ");
     sb.append(message);
     throw new IllegalArgumentException(sb.toString());
   }
 }
Exemplo n.º 12
1
  static {
    // jquery权限验证

    sb.append(
        "<link rel=\"stylesheet\" type=\"text/css\" href=\"../globalRes/js/jquery_easyui/themes/gray/easyui.css\"/>");
    sb.append(
        "<link rel=\"stylesheet\" type=\"text/css\" href=\"../globalRes/js/jquery_easyui/themes/icon.css\"/>");
    sb.append(
        "<script type=\"text/javascript\" src=\"../globalRes/js/jquery-1.7.2.min.js\"></script>");
    sb.append(
        "<script type=\"text/javascript\" src=\"../globalRes/js/jquery_easyui/jquery.easyui.min.js\"></script>");
    sb.append(
        "<script type=\"text/javascript\" src=\"../globalRes/js/jquery-automic-global.js\"></script>");
    sb.append("<script tepe=\"text/javascript\">");
    // 常规权限验证
    sb.append(
        "$j(document).ready(function(){$j.messager.alert('信息提示','无权访问!','warning',function(){window.history.go(-1);});})");
    sb.append("</script>");

    // jquery权限验证信息补全
    sbJQuery.append("{\"noJQueryPriv\":\"无权访问!\"}");

    /** 此处<noFlexPriv></mess>,必须原样使用,直接可以写入信息, 供flex中FaultEvent调用,捕获异常事件及无权信息... */
    sbFlex.append("<noFlexPriv>无权访问</noFlexPriv0>");
  }
Exemplo n.º 13
1
Arquivo: Macro.java Projeto: bramk/bnd
  public String _range(String args[]) {
    verifyCommand(args, _rangeHelp, _rangePattern, 2, 3);
    Version version = null;
    if (args.length >= 3) version = new Version(args[2]);
    else {
      String v = domain.getProperty("@");
      if (v == null) return null;
      version = new Version(v);
    }
    String spec = args[1];

    Matcher m = RANGE_MASK.matcher(spec);
    m.matches();
    String floor = m.group(1);
    String floorMask = m.group(2);
    String ceilingMask = m.group(3);
    String ceiling = m.group(4);

    String left = version(version, floorMask);
    String right = version(version, ceilingMask);
    StringBuilder sb = new StringBuilder();
    sb.append(floor);
    sb.append(left);
    sb.append(",");
    sb.append(right);
    sb.append(ceiling);

    String s = sb.toString();
    VersionRange vr = new VersionRange(s);
    if (!(vr.includes(vr.getHigh()) || vr.includes(vr.getLow()))) {
      domain.error(
          "${range} macro created an invalid range %s from %s and mask %s", s, version, spec);
    }
    return sb.toString();
  }
Exemplo n.º 14
0
 /**
  * Writes begin layer operator "%AI5_BeginLayer" and various parameters to output. Layer is
  * visible and enabled.
  *
  * @param layerName <code>String</code>, name of layer
  * @param colorIndex <code>int</code>, index to color associated with layer
  * @param pw <code>PrintWriter</code> for file output
  */
 public static void beginLayer(String layerName, int colorIndex, PrintWriter pw) {
   StringBuilder buf = new StringBuilder(100);
   buf.append("%AI5_BeginLayer\n");
   buf.append("1 1 1 1 0 0 " + colorIndex + " 255 79 79 Lb\n");
   buf.append("(" + layerName + ") Ln\n");
   pw.print(buf.toString());
 }
 public static String buildFileName(String prefix, String date, String suffix) {
   StringBuilder sb = new StringBuilder();
   sb.append(prefix);
   sb.append(date);
   sb.append(suffix);
   return sb.toString();
 }
Exemplo n.º 16
0
  /**
   * Connects this CDDB instance to the CDDB server running on the supplied host using the specified
   * port.
   *
   * <p><b>Note well:</b> you must close a CDDB connection once you are done with it, otherwise the
   * socket connection will remain open and pointlessly consume machine resources.
   *
   * @param hostname The host to which to connect.
   * @param port The port number on which to connect to the host.
   * @exception IOException Thrown if a network error occurs attempting to connect to the host.
   * @exception CDDBException Thrown if an error occurs after identifying ourselves to the host.
   * @return The message supplied with the succesful connection response.
   * @see #close
   */
  public String connect(String hostname, int port) throws IOException, CDDBException {
    // obtain the necessary information we'll need to identify
    // ourselves to the CDDB server
    String localhost = InetAddress.getLocalHost().getHostName();
    String username = System.getProperty("user.name");
    if (username == null) {
      username = "******";
    }

    // establish our socket connection and IO streams
    InetAddress addr = InetAddress.getByName(hostname);
    _sock = new Socket(addr, port);
    _in = new BufferedReader(new InputStreamReader(_sock.getInputStream()));
    _out = new PrintStream(new BufferedOutputStream(_sock.getOutputStream()));

    // first read (and discard) the banner string
    _in.readLine();

    // send a hello request
    StringBuilder req = new StringBuilder("cddb hello ");
    req.append(username).append(" ");
    req.append(localhost).append(" ");
    req.append(CLIENT_NAME).append(" ");
    req.append(CLIENT_VERSION);

    Response rsp = request(req.toString());

    // confirm that the response was a successful one
    if (CDDBProtocol.codeFamily(rsp.code) != CDDBProtocol.OK
        && rsp.code != 402 /* already shook hands */) {
      throw new CDDBException(rsp.code, rsp.message);
    }

    return rsp.message;
  }
  private String paramsToQueryString(Map<String, String> params)
      throws UnsupportedEncodingException {
    if (params == null || params.size() == 0) {
      return null;
    }
    String[] sortedKeys = params.keySet().toArray(new String[] {});
    Arrays.sort(sortedKeys);

    StringBuilder paramString = new StringBuilder();
    boolean first = true;
    for (String key : sortedKeys) {
      Object val = params.get(key);
      if (!first) {
        paramString.append("&");
      }
      if (val instanceof String) {
        paramString.append(URLEncoder.encode(key, ENCODING));
        if (val != null) {
          String strValue = (String) val;
          paramString.append("=").append(URLEncoder.encode(strValue, ENCODING));
        }
      }
      first = false;
    }
    return paramString.toString();
  }
  private String computeSignature(String httpMethod, Map<String, String> parameters) {
    String[] sortedKeys = parameters.keySet().toArray(new String[] {});
    Arrays.sort(sortedKeys);
    final String SEPARATOR = "&";

    StringBuilder sbStringToSign = new StringBuilder();
    sbStringToSign.append(String.format("%s\n/app/\n", httpMethod));

    String signature = "";
    try {
      int count = 0;

      for (String key : sortedKeys) {
        if (count != 0) {
          sbStringToSign.append(SEPARATOR);
        }
        sbStringToSign
            .append(percentEncode(key))
            .append("=")
            .append(percentEncode(parameters.get(key)));
        count++;
      }

      String strToSign = sbStringToSign.toString();
      signature = calculateSignature(secretAppKey, strToSign);
    } catch (UnsupportedEncodingException e) {
    } catch (Exception e) {
    }
    return signature;
  }
Exemplo n.º 19
0
  public void composition_tokenizer(String comp_line) {
    comp_line = remove_for_agg(comp_line);

    String c_name = get_first(comp_line, "COMPOSITION");
    String comp_name = get_latter(comp_line, "COMPOSITION");

    StringBuilder construct_param = new StringBuilder();

    construct_param.append(comp_name);
    construct_param.append("_");
    construct_param.append(Integer.toString(param_count));

    String param = construct_param.toString();

    param_count++;

    if (output.get(c_name) != null) {
      comp_name = get_latter(comp_line, "COMPOSITION");
      output.get(c_name).add_parameters(param);
      output.get(c_name).add_comp(param);
    } else {
      comp_name = get_first(comp_line, "COMPOSITION");
      output.put(c_name, classes[object_count]);
      output.get(c_name).set_weird_name(c_name);
      current_class = c_name;
      object_count++;
      output.get(c_name).add_parameters(param);
      output.get(c_name).add_comp(param);
    }
  }
Exemplo n.º 20
0
 public static String normalizePath(String path) {
   if (!path.contains("./")) {
     return path;
   }
   boolean absolute = path.startsWith("/");
   String[] elements = path.split(Repository.SEPARATOR);
   LinkedList<String> list = new LinkedList<String>();
   for (String e : elements) {
     if ("..".equals(e)) {
       if (list.isEmpty() || "..".equals(list.getLast())) {
         list.add(e);
       } else {
         list.removeLast();
       }
     } else if (!".".equals(e) && e.length() > 0) {
       list.add(e);
     }
   }
   StringBuilder sb = new StringBuilder(path.length());
   if (absolute) {
     sb.append("/");
   }
   int count = 0, last = list.size() - 1;
   for (String e : list) {
     sb.append(e);
     if (count++ < last) sb.append("/");
   }
   return sb.toString();
 }
Exemplo n.º 21
0
  public static void main(String[] args) throws MessagingException, IOException {
    Properties props = new Properties();
    try (InputStream in = Files.newInputStream(Paths.get("mail", "mail.properties"))) {
      props.load(in);
    }
    List<String> lines = Files.readAllLines(Paths.get(args[0]), Charset.forName("UTF-8"));

    String from = lines.get(0);
    String to = lines.get(1);
    String subject = lines.get(2);

    StringBuilder builder = new StringBuilder();
    for (int i = 3; i < lines.size(); i++) {
      builder.append(lines.get(i));
      builder.append("\n");
    }

    Console console = System.console();
    String password = new String(console.readPassword("Password: "));

    Session mailSession = Session.getDefaultInstance(props);
    // mailSession.setDebug(true);
    MimeMessage message = new MimeMessage(mailSession);
    message.setFrom(new InternetAddress(from));
    message.addRecipient(RecipientType.TO, new InternetAddress(to));
    message.setSubject(subject);
    message.setText(builder.toString());
    Transport tr = mailSession.getTransport();
    try {
      tr.connect(null, password);
      tr.sendMessage(message, message.getAllRecipients());
    } finally {
      tr.close();
    }
  }
Exemplo n.º 22
0
  public static void updateOCSSWRoot(String installDir) {
    FileWriter fileWriter = null;
    try {
      final FileReader reader =
          new FileReader(new File(RuntimeContext.getConfig().getConfigFilePath()));
      final BufferedReader br = new BufferedReader(reader);

      StringBuilder text = new StringBuilder();
      String line;
      boolean isOCSSWRootSpecified = false;
      while ((line = br.readLine()) != null) {
        if (line.startsWith("seadas.ocssw.root")) {
          line = "seadas.ocssw.root = " + installDir;
          isOCSSWRootSpecified = true;
        }
        text.append(line);
        text.append("\n");
      }
      // Append "seadas.ocssw.root = " + installDir + "\n" to the runtime config file if it is not
      // exist
      if (!isOCSSWRootSpecified) {
        text.append("seadas.ocssw.root = " + installDir + "\n");
      }
      fileWriter = new FileWriter(new File(RuntimeContext.getConfig().getConfigFilePath()));
      fileWriter.write(text.toString());
      if (fileWriter != null) {
        fileWriter.close();
      }
      ocsswRoot = installDir;
    } catch (IOException ioe) {
      handleException(ioe.getMessage());
    }
  }
Exemplo n.º 23
0
  /**
   * Constructor.
   *
   * @param format The format to use
   * @param version The spec major and minor version number(such as 3.2)
   * @param profile The profile to use when exporting
   * @param components The components to add to the profile. Null means none.
   * @param levels The components levels
   */
  public Web3DExporter(
      ExternalFormat format, String version, String profile, String[] components, int[] levels) {

    StringBuilder sb = new StringBuilder();
    sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
    sb.append("<X3D profile=\"");
    sb.append(profile);
    sb.append("\" version=\"");
    sb.append(version);
    sb.append("\">\n");
    sb.append("<head>\n");

    if (components != null && levels != null) {
      int len = Math.min(components.length, levels.length);

      for (int i = 0; i < len; i++) {
        sb.append("\t<component name=\"");
        sb.append(components[i]);
        sb.append("\" level=\"");
        sb.append(levels[i]);
        sb.append("\" />\n");
      }
    }

    sb.append("</head>\n");
    sb.append("<Scene>\n");

    header = sb.toString();

    errorReporter = DefaultErrorReporter.getDefaultReporter();
  }
Exemplo n.º 24
0
  private void fixTabs(int tabSize) {

    int rowIndex = 0;

    for (StringBuilder row1 : rows) {
      String row = row1.toString();
      StringBuilder newRow = new StringBuilder();

      char[] chars = row.toCharArray();
      for (char c : chars) {
        if (c == '\t') {
          int spacesLeft = tabSize - newRow.length() % tabSize;
          if (DEBUG) {
            System.out.println("Found tab. Spaces left: " + spacesLeft);
          }
          String spaces = StringUtils.repeatString(" ", spacesLeft);
          newRow.append(spaces);
        } else {
          String character = Character.toString(c);
          newRow.append(character);
        }
      }
      rows.set(rowIndex, newRow);
      rowIndex++;
    }
  }
Exemplo n.º 25
0
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

    String line;
    StringBuilder sb = new StringBuilder();
    while ((line = in.readLine()) != null) {
      int k = Integer.parseInt(line);
      List<Integer> xd = new ArrayList<Integer>();
      List<Integer> yd = new ArrayList<Integer>();

      for (int y = k + 1; y <= 2 * k; ++y) {
        if (k * y % (y - k) == 0) {
          int x = k * y / (y - k);
          xd.add(x);
          yd.add(y);
        }
      }

      sb.append(xd.size() + "\n");
      for (int i = 0; i < xd.size(); ++i)
        sb.append(String.format("1/%d = 1/%d + 1/%d\n", k, xd.get(i), yd.get(i)));
    }

    System.out.print(sb);

    in.close();
    System.exit(0);
  }
Exemplo n.º 26
0
  public void solve() throws Exception {
    int x = sc.nextInt();
    int y = sc.nextInt();
    StringBuilder sb = new StringBuilder();
    String p = null;
    String m = null;
    if (x >= 0) {
      p = "E";
      m = "W";
    } else {
      p = "W";
      m = "E";
    }
    x = abs(x);

    for (int i = 0; i < x; i++) {
      sb.append(m + p);
    }
    if (y >= 0) {
      p = "N";
      m = "S";
    } else {
      p = "S";
      m = "N";
    }
    y = abs(y);
    for (int i = 0; i < y; i++) {
      sb.append(m + p);
    }
    out.println(sb);
  }
Exemplo n.º 27
0
  @Override
  protected void writeConnectors(StringBuilder output) throws Exception {
    String[] connectorClasses = getConnectorClasses();
    String[] connectorNames = getConnectorNames();
    for (int i = 0; i < connectorNames.length; i++) {
      output.append(
          "    <repositoryconnector name=\""
              + connectorNames[i]
              + "\" class=\""
              + connectorClasses[i]
              + "\"/>\n");
    }

    String[] outputClasses = getOutputClasses();
    String[] outputNames = getOutputNames();
    for (int i = 0; i < outputNames.length; i++) {
      output.append(
          "    <outputconnector name=\""
              + outputNames[i]
              + "\" class=\""
              + outputClasses[i]
              + "\"/>\n");
    }

    String[] authorityClasses = getAuthorityClasses();
    String[] authorityNames = getAuthorityNames();
    for (int i = 0; i < authorityNames.length; i++) {
      output.append(
          "    <authorityconnector name=\""
              + authorityNames[i]
              + "\" class=\""
              + authorityClasses[i]
              + "\"/>\n");
    }
  }
Exemplo n.º 28
0
    public String toString() {
      StringBuilder ret = new StringBuilder();
      InetAddress local = null, remote = null;
      String local_str, remote_str;

      Socket tmp_sock = sock;
      if (tmp_sock == null) ret.append("<null socket>");
      else {
        // since the sock variable gets set to null we want to make
        // make sure we make it through here without a nullpointer exception
        local = tmp_sock.getLocalAddress();
        remote = tmp_sock.getInetAddress();
        local_str = local != null ? Util.shortName(local) : "<null>";
        remote_str = remote != null ? Util.shortName(remote) : "<null>";
        ret.append(
            '<'
                + local_str
                + ':'
                + tmp_sock.getLocalPort()
                + " --> "
                + remote_str
                + ':'
                + tmp_sock.getPort()
                + "> ("
                + ((System.currentTimeMillis() - last_access) / 1000)
                + " secs old)");
      }
      tmp_sock = null;

      return ret.toString();
    }
Exemplo n.º 29
0
 @Override
 public String toString() {
   StringBuilder sb = new StringBuilder();
   sb.append("LineColor");
   sb.append(super.toString());
   return sb.toString();
 }
Exemplo n.º 30
0
  // ## operation writeChemkinReactions(ReactionModel)
  // 10/26/07 gmagoon: changed to take temperature as parameter (it doesn't seem like this method is
  // currently used anywhere)
  public static String writeChemkinReactions(
      ReactionModel p_reactionModel, Temperature p_temperature) {
    // #[ operation writeChemkinReactions(ReactionModel)
    StringBuilder result = new StringBuilder();
    result.append("REACTIONS	KCAL/MOLE\n");
    CoreEdgeReactionModel cerm = (CoreEdgeReactionModel) p_reactionModel;

    LinkedHashSet all = cerm.getReactedReactionSet();

    HashSet hs = new HashSet();
    int numfor = 0;
    int numrev = 0;
    int numdup = 0;
    int numnorev = 0;
    for (Iterator iter = all.iterator(); iter.hasNext(); ) {
      Reaction rxn = (Reaction) iter.next();
      if (rxn.isForward()) {
        result.append(
            " "
                + rxn.toChemkinString(p_temperature)
                + "\n"); // 10/26/07 gmagoon: changed to avoid use of Global.temperature
        //	result.append(" " + rxn.toChemkinString(Global.temperature) + "\n");

      }
    }

    result.append("END\n");

    return result.toString();

    // #]
  }