/** * Creates a String representation of the given object. * * @param certificate to print * @return the String representation */ private String toString(Object certificate) { final StringBuilder sb = new StringBuilder(); sb.append("<html><body>\n"); if (certificate instanceof X509Certificate) { renderX509(sb, (X509Certificate) certificate); } else { sb.append("<pre>\n"); sb.append(certificate.toString()); sb.append("</pre>\n"); } sb.append("</body></html>"); return sb.toString(); }
public String toString() { StringBuilder buf = new StringBuilder(); buf.append(idToString(getId())); buf.append(' '); buf.append(getLength()); if (data == null) { buf.append(' '); buf.append(idToString(getType())); } return buf.toString(); }
/** * Converts the byte array to hex string. * * @param raw the data. * @return the hex string. */ private String getHex(byte[] raw) { if (raw == null) return null; StringBuilder hex = new StringBuilder(2 * raw.length); Formatter f = new Formatter(hex); try { for (byte b : raw) f.format("%02x", b); } finally { f.close(); } return hex.toString(); }
String makeFQN(Object[] path) { StringBuilder sb = new StringBuilder(""); String tmp_name; if (path == null) return null; for (int i = 0; i < path.length; i++) { tmp_name = ((MyNode) path[i]).name; if (tmp_name.equals(SEP)) continue; else sb.append(SEP + tmp_name); } tmp_name = sb.toString(); if (tmp_name.length() == 0) return SEP; else return tmp_name; }
private String tameTooltipText(String text) { List<String> lines = new ArrayList<String>(); while (text.length() > MAX_LENGTH) { int pos = text.indexOf(' ', MAX_LENGTH - 10); if (pos < 0) break; if (pos > MAX_LENGTH + 5) pos = MAX_LENGTH; lines.add(text.substring(0, pos).trim()); text = text.substring(pos).trim(); } if (!text.trim().isEmpty()) lines.add(text); StringBuilder html = new StringBuilder("<html>"); for (String line : lines) html.append(line).append("<br/>\n"); return html.toString(); }
public String dump(int depth) { StringBuilder buf = new StringBuilder(); for (int i = 0; i < depth; i++) { buf.append('.'); } buf.append(idToString(getId())); buf.append(' '); buf.append(getLength()); if (getChildCount() > 0) { buf.append(' '); buf.append(idToString(getType())); for (MutableIFFChunk child : childChunks()) { buf.append('\n'); buf.append(child.dump(depth + 1)); } } return buf.toString(); }
/** * Calculates the hash of the certificate known as the "thumbprint" and returns it as a string * representation. * * @param cert The certificate to hash. * @param algorithm The hash algorithm to use. * @return The SHA-1 hash of the certificate. * @throws CertificateException */ private static String getThumbprint(X509Certificate cert, String algorithm) throws CertificateException { MessageDigest digest; try { digest = MessageDigest.getInstance(algorithm); } catch (NoSuchAlgorithmException e) { throw new CertificateException(e); } byte[] encodedCert = cert.getEncoded(); StringBuilder sb = new StringBuilder(encodedCert.length * 2); Formatter f = new Formatter(sb); try { for (byte b : digest.digest(encodedCert)) f.format("%02x", b); } finally { f.close(); } return sb.toString(); }
String print(int indent) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < indent; i++) sb.append(' '); if (!isRoot()) { if (name == null) sb.append("/<unnamed>"); else { sb.append(ReplicatedTreeView.SEP + name); } } sb.append('\n'); if (getChildCount() > 0) { if (isRoot()) indent = 0; else indent += 4; for (int i = 0; i < getChildCount(); i++) sb.append(((MyNode) getChildAt(i)).print(indent)); } return sb.toString(); }
private static String getNodePathString(final MyNode node) { StringBuilder path = new StringBuilder(); MyNode current = node; while (current != null) { final Object userObject = current.getUserObject(); if (!(userObject instanceof NamedConfigurable)) break; final String displayName = current.getDisplayName(); if (StringUtil.isEmptyOrSpaces(displayName)) break; if (path.length() > 0) { path.append('|'); } path.append(displayName); final TreeNode parent = current.getParent(); if (!(parent instanceof MyNode)) break; current = (MyNode) parent; } return path.toString(); }
// =========================================================== private PoolThreadsInfo(TangoServer server) throws DevFailed { DbDatum[] data = server.get_property(propertyNames); String[] config = new String[0]; int threadsNumber = 1; if (data[NB_THREADS].is_empty() && data[THREADS_CONFIG].is_empty()) { // If no property --> get device list from db String[] s = server.queryDeviceFromDb(); // and set all for on thread StringBuilder sb = new StringBuilder(); for (int i = 0; i < s.length; i++) { sb.append(s[i]); if (i < s.length - 1) sb.append(','); } config = new String[] {sb.toString()}; } if (!data[NB_THREADS].is_empty()) threadsNumber = data[NB_THREADS].extractLong(); if (!data[THREADS_CONFIG].is_empty()) config = data[THREADS_CONFIG].extractStringArray(); buildConfig(config, threadsNumber); }
public void addJavacMessage(AntMessage message, String url) { final StringBuilder builder = StringBuilderSpinAllocator.alloc(); try { final VirtualFile file = message.getFile(); if (message.getLine() > 0) { if (file != null) { ApplicationManager.getApplication() .runReadAction( new Runnable() { public void run() { String presentableUrl = file.getPresentableUrl(); builder.append(presentableUrl); builder.append(' '); } }); } else if (url != null) { builder.append(url); builder.append(' '); } builder.append('('); builder.append(message.getLine()); builder.append(':'); builder.append(message.getColumn()); builder.append(") "); } addJavacMessageImpl( new AntMessage( message.getType(), message.getPriority(), builder.toString() + message.getText(), message.getFile(), message.getLine(), message.getColumn())); } finally { StringBuilderSpinAllocator.dispose(builder); } }