public synchronized void transferProgress(
      TransferEvent transferEvent, byte[] buffer, int length) {
    Resource resource = transferEvent.getResource();
    if (!downloads.containsKey(resource)) {
      downloads.put(resource, new Long(length));
    } else {
      Long complete = (Long) downloads.get(resource);
      complete = new Long(complete.longValue() + length);
      downloads.put(resource, complete);
    }

    StringBuffer buf = new StringBuffer();
    for (Iterator i = downloads.entrySet().iterator(); i.hasNext(); ) {
      Map.Entry entry = (Map.Entry) i.next();
      Long complete = (Long) entry.getValue();
      String status =
          getDownloadStatusForResource(
              complete.longValue(), ((Resource) entry.getKey()).getContentLength());
      buf.append(status);
      if (i.hasNext()) {
        buf.append(" ");
      }
    }

    if (buf.length() > maxLength) {
      maxLength = buf.length();
    }

    out.print(buf.toString() + "\r");
  }
Ejemplo n.º 2
1
 public static void addBullet(StringBuffer buffer, String bullet) {
   if (bullet != null) {
     buffer.append("<li>"); // $NON-NLS-1$
     buffer.append(bullet);
     buffer.append("</li>"); // $NON-NLS-1$
   }
 }
Ejemplo n.º 3
1
  /**
   * 是否财付通签名,规则是:按参数名称a-z排序,遇到空值的参数不参加签名。
   *
   * @return boolean
   */
  public boolean isTenpaySign() {
    StringBuffer sb = new StringBuffer();
    Set es = this.parameters.entrySet();
    Iterator it = es.iterator();
    while (it.hasNext()) {
      Map.Entry entry = (Map.Entry) it.next();
      String k = (String) entry.getKey();
      String v = (String) entry.getValue();
      if (!"sign".equals(k) && null != v && !"".equals(v)) {
        sb.append(k + "=" + v + "&");
      }
    }

    sb.append("key=" + this.getKey());

    // 算出摘要
    String enc = "UTF-8";
    String sign = MD5Util.MD5Encode(sb.toString(), enc).toLowerCase();

    String tenpaySign = this.getParameter("sign").toLowerCase();

    // debug信息
    this.setDebugInfo(sb.toString() + " => sign:" + sign + " tenpaySign:" + tenpaySign);

    return tenpaySign.equals(sign);
  }
  /**
   * dummy toString method
   *
   * @return the String representation of the operator
   */
  public String toString() {
    StringBuffer strBuf = new StringBuffer();
    strBuf.append("Impute: Punct: " + pSpec.toString() + " Attr: " + pAttr.getName());

    strBuf.append("Stream Punctuating Attr: " + spAttr.getName());
    return strBuf.toString();
  }
Ejemplo n.º 5
1
 /**
  * This is for debug only: print out training matrices in a CSV type format so that the matrices
  * can be examined in a spreadsheet program for debugging purposes.
  */
 private void WriteCSVfile(
     List<String> rowNames, List<String> colNames, float[][] buf, String fileName) {
   p("tagList.size()=" + tagList.size());
   try {
     FileWriter fw = new FileWriter(fileName + ".txt");
     PrintWriter bw = new PrintWriter(new BufferedWriter(fw));
     // write the first title row:
     StringBuffer sb = new StringBuffer(500);
     for (int i = 0, size = colNames.size(); i < size; i++) {
       sb.append("," + colNames.get(i));
     }
     bw.println(sb.toString());
     // loop on remaining rows:
     for (int i = 0, size = buf.length; i < size; i++) {
       sb.delete(0, sb.length());
       sb.append(rowNames.get(i));
       for (int j = 0, size2 = buf[i].length; j < size2; j++) {
         sb.append("," + buf[i][j]);
       }
       bw.println(sb.toString());
     }
     bw.close();
   } catch (IOException ioe) {
     ioe.printStackTrace();
   }
 }
Ejemplo n.º 6
1
  static String getSpaces(int num) {
    try {
      // 99.9% of the time num is going to be
      // smaller than 50, so just try it
      return SPACES[num];
    } catch (ArrayIndexOutOfBoundsException e) {
      if (num < 0) return "";

      // too big!
      int len = SPACES.length;
      StringBuffer buf;
      buf = new StringBuffer(num);
      int rem = num;
      while (true) {
        if (rem < len) {
          buf.append(SPACES[rem]);
          break;
        } else {
          buf.append(SPACES[len - 1]);
          rem -= len - 1;
        }
      }
      return buf.toString();
    }
  }
Ejemplo n.º 7
1
 /**
  * @param str 原字符
  * @param prefix 前几位(0,表示不做替换)
  * @param postfix 后几位(0,表示不做替换)
  * @param character 替换字符(若替换字符为一位,则保持长度不变)
  * @return 替换后的字符
  */
 public static String stringSwitch(String str, int prefix, int postfix, String character) {
   if (prefix < 0 || postfix < 0) {
     return str;
   }
   if (prefix == 0 && postfix == 0) {
     return str;
   }
   if (str != null && str.trim().length() > 0) {
     StringBuffer buf = new StringBuffer();
     int argsLength = str.length();
     // 保证被替换的长度大于原字符长度
     if (argsLength > prefix + postfix) {
       if (prefix != 0) {
         String stringPrefix = str.substring(0, prefix);
         buf.append(stringPrefix);
       }
       for (int i = prefix; i < argsLength - postfix; i++) {
         buf.append(character);
       }
       if (postfix != 0) {
         String stringPostfix = str.substring(argsLength - postfix);
         buf.append(stringPostfix);
       }
       return buf.toString();
     } else {
       return str;
     }
   }
   return null;
 }
  // 活动短信发送
  public static void noteSend(String str, String mobile) {
    String postUrl = "http://106.ihuyi.cn/webservice/sms.php?method=Submit";
    String account = "cf_CatMiao";
    String password = "******";
    String content = new String("冰川网贷:" + str);
    try {
      URL url = new URL(postUrl);
      HttpURLConnection connection = (HttpURLConnection) url.openConnection();
      connection.setDoOutput(true); // 允许连接提交信息
      connection.setRequestMethod("POST"); // 网页提交方式“GET”、“POST”
      connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
      connection.setRequestProperty("Connection", "Keep-Alive");
      StringBuffer sb = new StringBuffer();
      sb.append("account=" + account);
      sb.append("&password="******"&mobile=" + mobile);
      sb.append("&content=" + content);
      OutputStream os = connection.getOutputStream();
      os.write(sb.toString().getBytes());
      os.close();

      String line, result = "";
      BufferedReader in =
          new BufferedReader(new InputStreamReader(connection.getInputStream(), "utf-8"));
      while ((line = in.readLine()) != null) {
        result += line + "\n";
      }
      in.close();
      System.out.println("result=" + result);
    } catch (IOException e) {
      e.printStackTrace(System.out);
    }
  }
  // MD5加密,32位
  public static String MD5(String str) {
    MessageDigest md5 = null;
    try {
      md5 = MessageDigest.getInstance("MD5");
    } catch (Exception e) {
      e.printStackTrace();
      return "";
    }

    char[] charArray = str.toCharArray();
    byte[] byteArray = new byte[charArray.length];

    for (int i = 0; i < charArray.length; i++) {
      byteArray[i] = (byte) charArray[i];
    }
    byte[] md5Bytes = md5.digest(byteArray);

    StringBuffer hexValue = new StringBuffer();
    for (int i = 0; i < md5Bytes.length; i++) {
      int val = ((int) md5Bytes[i]) & 0xff;
      if (val < 16) {
        hexValue.append("0");
      }
      hexValue.append(Integer.toHexString(val));
    }
    return hexValue.toString();
  }
Ejemplo n.º 10
0
  private static void appendStyleSheet(StringBuffer buffer, String styleSheet) {
    if (styleSheet == null) return;

    buffer.append("<head><style CHARSET=\"ISO-8859-1\" TYPE=\"text/css\">"); // $NON-NLS-1$
    buffer.append(styleSheet);
    buffer.append("</style></head>"); // $NON-NLS-1$
  }
 protected void setToolTip() {
   TileI currentTile =
       orUIManager.getGameUIManager().getGameManager().getTileManager().getTile(internalId);
   StringBuffer tt = new StringBuffer("<html>");
   tt.append("<b>Tile</b>: ").append(currentTile.getName()); // or
   // getId()
   if (currentTile.hasStations()) {
     // for (Station st : currentTile.getStations())
     int cityNumber = 0;
     // TileI has stations, but
     for (Station st : currentTile.getStations()) {
       cityNumber++; // = city.getNumber();
       tt.append("<br>  ")
           .append(st.getType())
           .append(" ")
           .append(cityNumber) // .append("/").append(st.getNumber())
           .append(": value ");
       tt.append(st.getValue());
       if (st.getBaseSlots() > 0) {
         tt.append(", ").append(st.getBaseSlots()).append(" slots");
       }
     }
   }
   tt.append("</html>");
   toolTip = tt.toString();
 }
  @Override
  protected SqlObject<Map<String, Object>> getSqlObject() {
    SqlObject<Map<String, Object>> sqlObject = new SqlObject<Map<String, Object>>();

    // 构建查询语句,where和order by不要包含在sql中(要统一放到condition中)
    StringBuffer sql = new StringBuffer();
    sql.append(
        "select s.id,s.status_,s.type_,s.order_,s.subject,s.event_code,e.type_ actor_type,e.file_date");
    sql.append(" from bc_subscribe s");
    sql.append(" inner join bc_subscribe_actor e on e.pid=s.id");
    sql.append(" inner join bc_identity_actor f on f.id=e.aid");
    sqlObject.setSql(sql.toString());

    // 注入参数
    sqlObject.setArgs(null);

    // 数据映射器
    sqlObject.setRowMapper(
        new RowMapper<Map<String, Object>>() {
          public Map<String, Object> mapRow(Object[] rs, int rowNum) {
            Map<String, Object> map = new HashMap<String, Object>();
            int i = 0;
            map.put("id", rs[i++]);
            map.put("status", rs[i++]);
            map.put("type", rs[i++]);
            map.put("orderNo", rs[i++]);
            map.put("subject", rs[i++]);
            map.put("eventCode", rs[i++]);
            map.put("actorType", rs[i++]);
            map.put("fileDate", rs[i++]);
            return map;
          }
        });
    return sqlObject;
  }
Ejemplo n.º 13
0
  public String getLauncherDetails(String prefix) {
    try {
      final String javaVersionCommand = javaCommand + " -version";
      Process proc = Runtime.getRuntime().exec(javaVersionCommand);

      try {
        InputStream inputStream = proc.getErrorStream();
        BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));

        String line = null;
        StringBuffer buffer = new StringBuffer();
        while ((line = reader.readLine()) != null) {
          buffer.append(prefix);
          buffer.append(line);
          buffer.append('\n');
        }

        return buffer.toString();
      } finally {
        proc.destroy();
      }
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
Ejemplo n.º 14
0
 @Override
 public String toString() {
   StringBuffer buff = new StringBuffer(getParentString());
   buff.append(", queueName=" + queueName);
   buff.append("]");
   return buff.toString();
 }
Ejemplo n.º 15
0
 private void appendLoadOnStartup(StringBuffer result, Object startupOrder) {
   if (startupOrder == null) return;
   result.append("    <load-on-startup");
   if (startupOrder instanceof Number)
     result.append(">").append(startupOrder).append("</load-on-startup>\n");
   else result.append("/>\n");
 }
  /**
   * Load an entire resource text file into {@link String}.
   *
   * @param path the path to the resource file.
   * @return the entire content of the resource text file.
   */
  private String getResourceDocumentContent(String path) {
    InputStream in = this.getClass().getClassLoader().getResourceAsStream(path);

    if (in != null) {
      try {
        StringBuffer content = new StringBuffer(in.available());

        InputStreamReader isr = new InputStreamReader(in);
        try {
          BufferedReader reader = new BufferedReader(isr);
          for (String str = reader.readLine(); str != null; str = reader.readLine()) {
            content.append(str);
            content.append('\n');
          }
        } finally {
          isr.close();
        }

        return content.toString();
      } catch (IOException e) {
        // No resource file as been found or there is a problem when read it.
      }
    }

    return null;
  }
Ejemplo n.º 17
0
 private int getFieldErrorMsgByErrorType(
     StringBuffer allErrorMsg, List<Field> list, FormComp fc, int index, String titleError) {
   List<FormElement> fes = fc.getElementList();
   if (fes != null && fes.size() > 0) {
     boolean isNeedToShowError = false;
     FormElement[] formElements = new FormElement[fes.size()];
     int size = list.size();
     for (int i = 0; i < size; i++) {
       Field f = list.get(i);
       int fieldIndex = fc.idToIndex(f.getId());
       if (fieldIndex != -1 && fc.getElementById(f.getId()).isVisible()) {
         formElements[fieldIndex] = fes.get(fieldIndex);
         isNeedToShowError = true;
       }
     }
     if (isNeedToShowError) {
       allErrorMsg.append(((index > 1) ? " " : "") + index + ")");
       index++;
       allErrorMsg.append(titleError);
       boolean temp = false;
       for (int i = 0; i < formElements.length; i++) {
         if (formElements[i] != null) {
           String text = formElements[i].getText();
           allErrorMsg.append(((temp) ? "," : "") + "“" + text + "”");
           temp = true;
         }
       }
     }
   }
   return index;
 }
Ejemplo n.º 18
0
  /**
   * Return the REST path EG:
   * {layer}/{style}/{firstDimension}/{...}/{lastDimension}/{TileMatrixSet}/{scale}/{TileRow}/{TileCol}.{format_extension}
   */
  public String mapFromModel(IModel model) throws UnsupportedModelException {

    StringBuffer result = new StringBuffer("");

    if (model instanceof RestModel) {
      RestModel m = (RestModel) model;

      for (String propertyName : m.order) {
        String property = m.getProperties().get(propertyName);

        if (property != null) {
          if (result.length() != 0) {
            result.append("/");
          }
          result.append(property);
        }
      }
    } else {
      throw new UnsupportedModelException(
          String.format(
              "%s cannot map from model %s", getClass().getName(), model.getClass().getName()));
    }

    return result.toString();
  }
Ejemplo n.º 19
0
  // Algo 0: output string order.
  public String convert0(String s, int numRows) {

    if (numRows == 1) {
      return s;
    }
    StringBuffer sb = new StringBuffer();
    int borderRowStep = 2 * numRows - 2;
    for (int i = 0; i < numRows; i++) {
      if (i == 0 || i == numRows - 1) {
        for (int j = i; j < s.length(); j += borderRowStep) {
          sb.append(s.charAt(j));
        }
      } else {
        int j = i;
        boolean flag = true;
        int insideRowLargeStep = 2 * (numRows - 1 - i);
        int insideRowSmallStep = borderRowStep - insideRowLargeStep;
        while (j < s.length()) {
          sb.append(s.charAt(j));
          if (flag) j += insideRowLargeStep;
          else j += insideRowSmallStep;
          flag = !flag;
        }
      }
    }
    return sb.toString();
  }
Ejemplo n.º 20
0
 public static void addSmallHeader(StringBuffer buffer, String header) {
   if (header != null) {
     buffer.append("<h5>"); // $NON-NLS-1$
     buffer.append(header);
     buffer.append("</h5>"); // $NON-NLS-1$
   }
 }
  /**
   * Returns the canonical string representation of the actions, separated by comma.
   *
   * @return the canonical string representation of the actions.
   */
  public String getActions() {
    if (actions == null) {
      StringBuffer sb = new StringBuffer();
      boolean comma = false;

      if ((action_mask & ACTION_CHANGE_CREDENTIAL) == ACTION_CHANGE_CREDENTIAL) {
        sb.append(CHANGE_CREDENTIAL);
        comma = true;
      }

      if ((action_mask & ACTION_CHANGE_PROPERTY) == ACTION_CHANGE_PROPERTY) {
        if (comma) sb.append(',');
        sb.append(CHANGE_PROPERTY);
        comma = true;
      }

      if ((action_mask & ACTION_GET_CREDENTIAL) == ACTION_GET_CREDENTIAL) {
        if (comma) sb.append(',');
        sb.append(GET_CREDENTIAL);
      }

      actions = sb.toString();
    }

    return (actions);
  }
Ejemplo n.º 22
0
Archivo: List.java Proyecto: znerd/xins
  /**
   * Converts the specified <code>ItemList</code> to a string.
   *
   * @param value the value to convert, can be <code>null</code>.
   * @return the textual representation of the value, or <code>null</code> if and only if <code>
   *     value == null</code>.
   */
  public String toString(ItemList value) {

    // Short-circuit if the argument is null
    if (value == null) {
      return null;
    }

    // Use a buffer to create the string
    StringBuffer buffer = new StringBuffer(255);

    // Iterate over the list
    int listSize = value.getSize();
    for (int i = 0; i < listSize; i++) {
      if (i != 0) {
        buffer.append('&');
      }

      Object nextItem = value.getItem(i);
      String stringItem;
      try {
        stringItem = _itemType.toString(nextItem);
      } catch (Exception ex) {

        // Should never happens as only add() is able to add items in the list.
        throw new IllegalArgumentException("Incorrect value for type: " + nextItem);
      }
      buffer.append(URLEncoding.encode(stringItem));
    }

    return buffer.toString();
  }
Ejemplo n.º 23
0
 /**
  * 将数组中重复的字符串 去除
  *
  * @param destmsisdns
  * @return
  */
 public static String removeSameDestmsisdn(String destmsisdns) {
   String tmp = null;
   StringBuffer sb_destmsisdn = new StringBuffer();
   String[] destmsisdnArray = destmsisdns.split(",");
   if (destmsisdnArray == null || destmsisdnArray.length == 0) {
     return null;
   }
   ArrayList<String> resultList = new ArrayList<String>();
   for (int i = 0; i < destmsisdnArray.length; i++) {
     if (resultList.contains(destmsisdnArray[i])) {
       continue;
     } else {
       resultList.add(destmsisdnArray[i]);
     }
   }
   for (int i = 0; i < resultList.size(); i++) {
     sb_destmsisdn.append(resultList.get(i));
     sb_destmsisdn.append(",");
   }
   if (sb_destmsisdn.length() > 0) {
     tmp = sb_destmsisdn.substring(0, sb_destmsisdn.length() - 1);
   } else {
     tmp = sb_destmsisdn.toString();
   }
   return tmp;
 }
Ejemplo n.º 24
0
  public synchronized String format(LogRecord record) {
    StringBuffer sb = new StringBuffer();
    date.setTime(record.getMillis() + timeDiff);
    sb.append(dFormat.format(date));
    if (isShowingThreads) {
      Thread currentThread = Thread.currentThread();
      if (currentThread != lastThread) {
        lastThread = currentThread;
        lastThreadName = currentThread.getName();
      }
      sb.append(" [").append(lastThreadName).append(']');
    }
    sb.append(' ')
        .append(record.getLevel())
        .append(' ')
        .append(getAliasFor(record.getLoggerName()))
        .append('|')
        .append(record.getMessage())
        .append(EOL);

    if (record.getThrown() != null) {
      try {
        StringWriter out = new StringWriter();
        PrintWriter pout = new PrintWriter(out);
        record.getThrown().printStackTrace(pout);
        pout.close();
        sb.append(out.toString());
      } catch (Exception e) {
        // Ignore any errors while extracting stack trace
      }
    }

    return sb.toString();
  }
Ejemplo n.º 25
0
  /** Generates the foreign key declaration for a given Constraint object. */
  private void getFKStatement(StringBuffer a) {

    if (!getName().isReservedName()) {
      a.append(Tokens.T_CONSTRAINT).append(' ');
      a.append(getName().statementName);
      a.append(' ');
    }

    a.append(Tokens.T_FOREIGN).append(' ').append(Tokens.T_KEY);

    int[] col = getRefColumns();

    getColumnList(getRef(), col, col.length, a);
    a.append(' ').append(Tokens.T_REFERENCES).append(' ');
    a.append(getMain().getName().getSchemaQualifiedStatementName());

    col = getMainColumns();

    getColumnList(getMain(), col, col.length, a);

    if (getDeleteAction() != Constraint.NO_ACTION) {
      a.append(' ').append(Tokens.T_ON).append(' ').append(Tokens.T_DELETE).append(' ');
      a.append(getDeleteActionString());
    }

    if (getUpdateAction() != Constraint.NO_ACTION) {
      a.append(' ').append(Tokens.T_ON).append(' ').append(Tokens.T_UPDATE).append(' ');
      a.append(getUpdateActionString());
    }
  }
Ejemplo n.º 26
0
  /**
   * Reads the example file specified by the example tag of a doc member and adds it to the example
   * section of the doc
   *
   * @param doc
   * @throws IOException
   */
  void setExample(Doc doc) throws IOException {
    Tag[] exampleTag = doc.tags("@example");
    if (exampleTag.length > 0) {
      StringBuffer exampleBuffer = new StringBuffer();
      FileReader in;
      int c;
      String[] pathComponents = exampleTag[0].text().split("/");
      String filePath =
          exampleTag[0].text() + "/" + pathComponents[pathComponents.length - 1] + ".pde";
      in = new FileReader(new File(exampleFolder, filePath));

      while ((c = in.read()) != -1) {
        if ((char) c == '<') {
          exampleBuffer.append("&lt;");
        } else {
          exampleBuffer.append((char) c);
        }
      }

      in.close();

      String exampleString = exampleBuffer.toString();

      EXAMPLE_TAG.setContent(exampleString);

    } else {
      EXAMPLE_TAG.setContent("None available");
    }
  }
Ejemplo n.º 27
0
  /**
   * * Login to the POP3 server with the given username and authentication information. Use this
   * method when connecting to a server requiring authentication using the APOP command. Because the
   * timestamp produced in the greeting banner varies from server to server, it is not possible to
   * consistently extract the information. Therefore, after connecting to the server, you must call
   * {@link org.apache.commons.net.pop3.POP3#getReplyString getReplyString } and parse out the
   * timestamp information yourself.
   *
   * <p>You must first connect to the server with {@link org.apache.commons.net.SocketClient#connect
   * connect } before attempting to login. A login attempt is only valid if the client is in the
   * {@link org.apache.commons.net.pop3.POP3#AUTHORIZATION_STATE AUTHORIZATION_STATE } . After
   * logging in, the client enters the {@link org.apache.commons.net.pop3.POP3#TRANSACTION_STATE
   * TRANSACTION_STATE } . After connecting, you must parse out the server specific information to
   * use as a timestamp, and pass that information to this method. The secret is a shared secret
   * known to you and the server. See RFC 1939 for more details regarding the APOP command.
   *
   * <p>
   *
   * @param username The account name being logged in to.
   * @param timestamp The timestamp string to combine with the secret.
   * @param secret The shared secret which produces the MD5 digest when combined with the timestamp.
   * @return True if the login attempt was successful, false if not.
   * @exception IOException If a network I/O error occurs in the process of logging in.
   * @exception NoSuchAlgorithmException If the MD5 encryption algorithm cannot be instantiated by
   *     the Java runtime system. *
   */
  public boolean login(String username, String timestamp, String secret)
      throws IOException, NoSuchAlgorithmException {
    int i;
    byte[] digest;
    StringBuffer buffer, digestBuffer;
    MessageDigest md5;

    if (getState() != AUTHORIZATION_STATE) return false;

    md5 = MessageDigest.getInstance("MD5");
    timestamp += secret;
    digest = md5.digest(timestamp.getBytes());
    digestBuffer = new StringBuffer(128);

    for (i = 0; i < digest.length; i++) digestBuffer.append(Integer.toHexString(digest[i] & 0xff));

    buffer = new StringBuffer(256);
    buffer.append(username);
    buffer.append(' ');
    buffer.append(digestBuffer.toString());

    if (sendCommand(POP3Command.APOP, buffer.toString()) != POP3Reply.OK) return false;

    setState(TRANSACTION_STATE);

    return true;
  }
Ejemplo n.º 28
0
  /**
   * Adds a syntax to the syntaxsection
   *
   * @param doc, doc item that has to be add to the syntax section
   */
  void addSyntax(Doc doc) {
    if (doc.isConstructor() || doc.isMethod()) {
      StringBuffer syntaxBuffer = new StringBuffer();
      for (Parameter parameter : ((ExecutableMemberDoc) doc).parameters()) {
        syntaxBuffer.append(parameter.typeName() + " " + parameter.name());
        syntaxBuffer.append(", ");
      }
      if (syntaxBuffer.length() > 2) {
        syntaxBuffer.delete(syntaxBuffer.length() - 2, syntaxBuffer.length());
      }

      String returnType = "";

      if (doc.isMethod()) {
        MethodDoc methodDoc = (MethodDoc) doc;
        returnType = methodDoc.returnType().toString();
        int lastDot = returnType.lastIndexOf('.');
        if (lastDot != -1) {
          returnType = returnType.substring(lastDot + 1);
        }
        returnType += " ";
      }

      if (doc.isConstructor()) {
        addSyntax("<em>" + doc.commentText() + "</em>");
      }

      addSyntax(returnType + doc.name() + "(" + syntaxBuffer.toString() + ")");
    } else if (doc.isField()) {
      FieldDoc fieldDoc = (FieldDoc) doc;
      addSyntax(fieldDoc.type().typeName() + " " + doc.name());
    }
  }
  /**
   * Returns a textual description of this classifier.
   *
   * @return a textual description of this classifier.
   */
  @Override
  public String toString() {

    if (m_probOfClass == null) {
      return "NaiveBayesMultinomialText: No model built yet.\n";
    }

    StringBuffer result = new StringBuffer();

    // build a master dictionary over all classes
    HashSet<String> master = new HashSet<String>();
    for (int i = 0; i < m_data.numClasses(); i++) {
      LinkedHashMap<String, Count> classDict = m_probOfWordGivenClass.get(i);

      for (String key : classDict.keySet()) {
        master.add(key);
      }
    }

    result.append("Dictionary size: " + master.size()).append("\n\n");

    result.append("The independent frequency of a class\n");
    result.append("--------------------------------------\n");

    for (int i = 0; i < m_data.numClasses(); i++) {
      result
          .append(m_data.classAttribute().value(i))
          .append("\t")
          .append(Double.toString(m_probOfClass[i]))
          .append("\n");
    }

    result.append("\nThe frequency of a word given the class\n");
    result.append("-----------------------------------------\n");

    for (int i = 0; i < m_data.numClasses(); i++) {
      result.append(Utils.padLeft(m_data.classAttribute().value(i), 11)).append("\t");
    }

    result.append("\n");

    Iterator<String> masterIter = master.iterator();
    while (masterIter.hasNext()) {
      String word = masterIter.next();

      for (int i = 0; i < m_data.numClasses(); i++) {
        LinkedHashMap<String, Count> classDict = m_probOfWordGivenClass.get(i);
        Count c = classDict.get(word);
        if (c == null) {
          result.append("<laplace=1>\t");
        } else {
          result.append(Utils.padLeft(Double.toString(c.m_count), 11)).append("\t");
        }
      }
      result.append(word);
      result.append("\n");
    }

    return result.toString();
  }
  /**
   * create a 1-d String array from a network, for easy transmission to R. triples (source,
   * edgeType, target) are filled in to an array of length 3 * # of interactions
   *
   * @param network a gaggle network
   * @return the edge attributes of the network as a string array
   */
  protected String[] networkEdgeAttributesToStringArray(Network network) {
    Interaction[] interactions = network.getInteractions();
    String source, target, type;
    String[] attributeNames = network.getEdgeAttributeNames();
    ArrayList<String> list = new ArrayList<String>();

    for (Interaction interaction : interactions) {
      source = interaction.getSource();
      type = interaction.getType();
      target = interaction.getTarget();
      String edgeName = source + " (" + type + ") " + target;
      String terseEdgeName = source + "::" + target + "::" + type;
      for (String name : attributeNames) {
        HashMap hash = network.getEdgeAttributes(name);
        if (hash.containsKey(edgeName)) {
          Object value = hash.get(edgeName);
          StringBuffer sb = new StringBuffer();
          sb.append(terseEdgeName);
          sb.append("::");
          sb.append(name);
          sb.append("::");
          sb.append(value.toString());
          list.add(sb.toString());
        } else {
          System.out.println("no " + name + " attribute for " + edgeName);
        }
      } // for a
    } // for r

    return list.toArray(new String[0]);
  } // networkEdgeAttributesToStringArray