Java Code Examples for com.google.common.base.Ascii#truncate()
The following examples show how to use
com.google.common.base.Ascii#truncate() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChatMessagePanel.java From triplea with GNU General Public License v3.0 | 6 votes |
private void addChatMessage(final String originalMessage, final UserName from) { final String message = Ascii.truncate(originalMessage, 200, "..."); final String time = "(" + DateTimeUtil.getLocalizedTime() + ")"; final Document doc = text.getDocument(); try { doc.insertString( doc.getLength(), ClientSetting.showChatTimeSettings.getSetting() ? time + " " + from + ": " : from + ": ", bold); doc.insertString(doc.getLength(), " " + message + "\n", normal); // don't let the chat get too big trimLines(doc, MAX_LINES); } catch (final BadLocationException e) { log.log( Level.SEVERE, "There was an Error whilst trying to add the Chat Message \"" + message + "\" sent by " + from + " at " + time, e); } }
Example 2
Source File: Util.java From parquet-mr with Apache License 2.0 | 5 votes |
public static String humanReadable(byte[] bytes, int len) { Preconditions.checkArgument(len >= 5, "Display length must be minimum 5"); if (bytes == null || bytes.length == 0) { return "null"; } final String asString = HashCode.fromBytes(bytes).toString(); return "0x" + Ascii.truncate(asString, len - 2, "..."); }
Example 3
Source File: ChatPlayerPanel.java From triplea with GNU General Public License v3.0 | 5 votes |
private String getDisplayString(final ChatParticipant chatParticipant) { if (chat == null) { return ""; } final String extra = chatParticipant.isModerator() ? " " + TAG_MODERATOR : ""; final String status = Ascii.truncate(chat.getStatus(chatParticipant.getUserName()), 25, ""); final String suffix = status.isEmpty() ? "" : " (" + status + ")"; return chatParticipant.getUserName() + extra + suffix; }
Example 4
Source File: CharSource.java From codebuff with BSD 2-Clause "Simplified" License | 4 votes |
@Override public String toString() { return "CharSource.wrap(" + Ascii.truncate(seq, 30, "...") + ")"; }
Example 5
Source File: ErrorReportRequest.java From triplea with GNU General Public License v3.0 | 4 votes |
public String getBody() { return body == null ? null : Ascii.truncate(body, GithubIssueClient.REPORT_BODY_MAX_LENGTH, "..."); }
Example 6
Source File: ErrorReportRequest.java From triplea with GNU General Public License v3.0 | 4 votes |
public String getTitle() { return title == null ? null : Ascii.truncate(title, GithubIssueClient.TITLE_MAX_LENGTH, "..."); }
Example 7
Source File: CreateIssueRequest.java From triplea with GNU General Public License v3.0 | 4 votes |
public String getBody() { return body == null ? null : Ascii.truncate(body, GithubIssueClient.REPORT_BODY_MAX_LENGTH, "..."); }
Example 8
Source File: CreateIssueRequest.java From triplea with GNU General Public License v3.0 | 4 votes |
public String getTitle() { return title == null ? null : Ascii.truncate(title, GithubIssueClient.TITLE_MAX_LENGTH, "..."); }
Example 9
Source File: ChatReceivedMessage.java From triplea with GNU General Public License v3.0 | 4 votes |
private static String truncateToMaxLength(final String message) { return Ascii.truncate(message, MAX_MESSAGE_LENGTH, ELLIPSES); }
Example 10
Source File: ByteSource.java From codebuff with BSD 2-Clause "Simplified" License | 4 votes |
@Override public String toString() { return "ByteSource.wrap(" + Ascii.truncate(BaseEncoding.base16().encode(bytes, offset, length), 30, "...") + ")"; }
Example 11
Source File: NullSafeAscii.java From sfs with Apache License 2.0 | 4 votes |
public static String truncate(CharSequence seq, int maxLength, String truncationIndicator) { if (seq != null) { return Ascii.truncate(seq, maxLength, truncationIndicator); } return null; }
Example 12
Source File: ByteSource.java From codebuff with BSD 2-Clause "Simplified" License | 4 votes |
@Override public String toString() { return "ByteSource.wrap(" + Ascii.truncate(BaseEncoding.base16().encode(bytes, offset, length), 30, "...") + ")"; }
Example 13
Source File: CharSource.java From codebuff with BSD 2-Clause "Simplified" License | 4 votes |
@Override public String toString() { return "CharSource.wrap(" + Ascii.truncate(seq, 30, "...") + ")"; }
Example 14
Source File: ByteSource.java From codebuff with BSD 2-Clause "Simplified" License | 4 votes |
@Override public String toString() { return "ByteSource.wrap(" + Ascii.truncate(BaseEncoding.base16().encode(bytes, offset, length), 30, "...") + ")"; }
Example 15
Source File: CharSource.java From codebuff with BSD 2-Clause "Simplified" License | 4 votes |
@Override public String toString() { return "CharSource.wrap(" + Ascii.truncate(seq, 30, "...") + ")"; }
Example 16
Source File: ByteSource.java From codebuff with BSD 2-Clause "Simplified" License | 4 votes |
@Override public String toString() { return "ByteSource.wrap(" + Ascii.truncate(BaseEncoding.base16().encode(bytes, offset, length), 30, "...") + ")"; }
Example 17
Source File: CharSource.java From codebuff with BSD 2-Clause "Simplified" License | 4 votes |
@Override public String toString() { return "CharSource.wrap(" + Ascii.truncate(seq, 30, "...") + ")"; }
Example 18
Source File: ByteSource.java From codebuff with BSD 2-Clause "Simplified" License | 4 votes |
@Override public String toString() { return "ByteSource.wrap(" + Ascii.truncate(BaseEncoding.base16().encode(bytes, offset, length), 30, "...") + ")"; }
Example 19
Source File: CharSource.java From codebuff with BSD 2-Clause "Simplified" License | 4 votes |
@Override public String toString() { return "CharSource.wrap(" + Ascii.truncate(seq, 30, "...") + ")"; }