package xysoft.im.utils;
import javax.swing.KeyStroke;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.BreakIterator;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.Random;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Utility class to peform common String manipulation algorithms.
*/
public class StringUtils {
// Constants used by escapeHTMLTags
private static final char[] QUOTE_ENCODE = """.toCharArray();
private static final char[] AMP_ENCODE = "&".toCharArray();
private static final char[] LT_ENCODE = "<".toCharArray();
private static final char[] GT_ENCODE = ">".toCharArray();
// patterns for the email address checks
private static Pattern basicAddressPattern;
private static Pattern validUserPattern;
private static Pattern domainPattern;
private static Pattern ipDomainPattern;
private static Pattern tldPattern;
// prepare the patterns
static {
// constants used in the parsing of email addresses
String basicAddress = "^([\\w\\.-]+)@([\\w\\.-]+)$";
String specialChars = "\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
String validChars = "[^ \f\n\r\t" + specialChars + "]";
String atom = validChars + "+";
String quotedUser = "(\"[^\"]+\")";
String word = "(" + atom + "|" + quotedUser + ")";
String validUser = "^" + word + "(\\." + word + ")*$";
String domain = "^" + atom + "(\\." + atom + ")+$";
String ipDomain = "^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$";
// from http://www.icann.org/tlds/
String knownTLDs = "^\\.(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$";
basicAddressPattern = Pattern.compile(basicAddress,
Pattern.CASE_INSENSITIVE);
validUserPattern = Pattern.compile(validUser, Pattern.CASE_INSENSITIVE);
domainPattern = Pattern.compile(domain, Pattern.CASE_INSENSITIVE);
ipDomainPattern = Pattern.compile(ipDomain, Pattern.CASE_INSENSITIVE);
tldPattern = Pattern.compile(knownTLDs, Pattern.CASE_INSENSITIVE);
}
/**
* Replaces all instances of oldString with newString in string.
*
* @param string
* the String to search to perform replacements on
* @param oldString
* the String that should be replaced by newString
* @param newString
* the String that will replace all instances of oldString
* @return a String will all instances of oldString replaced by newString
*/
public static String replace(String string, String oldString,
String newString) {
if (string == null) {
return null;
}
// If the newString is null or zero length, just return the string since
// there's nothing
// to replace.
if (newString == null) {
return string;
}
int i = 0;
// Make sure that oldString appears at least once before doing any
// processing.
if ((i = string.indexOf(oldString, i)) >= 0) {
// Use char []'s, as they are more efficient to deal with.
char[] string2 = string.toCharArray();
char[] newString2 = newString.toCharArray();
int oLength = oldString.length();
StringBuilder buf = new StringBuilder(string2.length);
buf.append(string2, 0, i).append(newString2);
i += oLength;
int j = i;
// Replace all remaining instances of oldString with newString.
while ((i = string.indexOf(oldString, i)) > 0) {
buf.append(string2, j, i - j).append(newString2);
i += oLength;
j = i;
}
buf.append(string2, j, string2.length - j);
return buf.toString();
}
return string;
}
/**
* Replaces all instances of oldString with newString in line with the added
* feature that matches of newString in oldString ignore case.
*
* @param line
* the String to search to perform replacements on
* @param oldString
* the String that should be replaced by newString
* @param newString
* the String that will replace all instances of oldString
* @return a String will all instances of oldString replaced by newString
*/
public static String replaceIgnoreCase(String line, String oldString,
String newString) {
if (line == null) {
return null;
}
String lcLine = line.toLowerCase();
String lcOldString = oldString.toLowerCase();
int i = 0;
if ((i = lcLine.indexOf(lcOldString, i)) >= 0) {
char[] line2 = line.toCharArray();
char[] newString2 = newString.toCharArray();
int oLength = oldString.length();
StringBuilder buf = new StringBuilder(line2.length);
buf.append(line2, 0, i).append(newString2);
i += oLength;
int j = i;
while ((i = lcLine.indexOf(lcOldString, i)) > 0) {
buf.append(line2, j, i - j).append(newString2);
i += oLength;
j = i;
}
buf.append(line2, j, line2.length - j);
return buf.toString();
}
return line;
}
/**
* Replaces all instances of oldString with newString in line with the added
* feature that matches of newString in oldString ignore case. </p> The
* count paramater is set to the number of replaces performed.
*
* @param line
* the String to search to perform replacements on
* @param oldString
* the String that should be replaced by newString
* @param newString
* the String that will replace all instances of oldString
* @param count
* a value that will be updated with the number of replaces
* <p/>
* performed.
* @return a String will all instances of oldString replaced by newString
*/
public static String replaceIgnoreCase(String line, String oldString,
String newString, int[] count) {
if (line == null) {
return null;
}
String lcLine = line.toLowerCase();
String lcOldString = oldString.toLowerCase();
int i = 0;
if ((i = lcLine.indexOf(lcOldString, i)) >= 0) {
int counter = 1;
char[] line2 = line.toCharArray();
char[] newString2 = newString.toCharArray();
int oLength = oldString.length();
StringBuilder buf = new StringBuilder(line2.length);
buf.append(line2, 0, i).append(newString2);
i += oLength;
int j = i;
while ((i = lcLine.indexOf(lcOldString, i)) > 0) {
counter++;
buf.append(line2, j, i - j).append(newString2);
i += oLength;
j = i;
}
buf.append(line2, j, line2.length - j);
count[0] = counter;
return buf.toString();
}
return line;
}
/**
* Replaces all instances of oldString with newString in line.
* <p/>
* The count Integer is updated with number of replaces.
*
* @param line
* the String to search to perform replacements on
* @param oldString
* the String that should be replaced by newString
* @param newString
* the String that will replace all instances of oldString
* @param count
* Number of replaces.
* @return a String will all instances of oldString replaced by newString
*/
public static String replace(String line, String oldString,
String newString, int[] count) {
if (line == null) {
return null;
}
int i = 0;
if ((i = line.indexOf(oldString, i)) >= 0) {
int counter = 1;
char[] line2 = line.toCharArray();
char[] newString2 = newString.toCharArray();
int oLength = oldString.length();
StringBuilder buf = new StringBuilder(line2.length);
buf.append(line2, 0, i).append(newString2);
i += oLength;
int j = i;
while ((i = line.indexOf(oldString, i)) > 0) {
counter++;
buf.append(line2,
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
本源码项目是基于Java的企业即时通讯平台设计,包含1248个文件,主要使用Java编程语言。该平台是一个高并发、高性能、可扩展、安全的企业通信和协作IM平台,提供了百万级的高性能即时通讯服务。它包括仿微信客户端(PC、Android、iOS)、Web门户(用于集成企业应用)和WebAPI,旨在为企业提供一个高效、便捷的即时通讯解决方案。
资源推荐
资源详情
资源评论
收起资源包目录
基于Java的企业即时通讯平台设计源码 (1248个子文件)
.classpath 965B
xytalk.db 504KB
xytalk - 空白库 - 副本.db 504KB
.DS_Store 58KB
.DS_Store 14KB
.DS_Store 10KB
sending.gif 22KB
loading_small.gif 21KB
loading3.gif 13KB
loading.gif 8KB
loading1.gif 4KB
loading2.gif 2KB
loading7.gif 2KB
image_loading.gif 2KB
loading6.gif 723B
loading5.gif 673B
.gitattributes 66B
.gitignore 287B
ic_launcher.icns 19KB
StringUtils.java 60KB
ChatPanel.java 48KB
Base64.java 44KB
MessageAdapter.java 29KB
ChangeAvatarPanel.java 26KB
MucChatService.java 25KB
GraphicUtils.java 24KB
SearchResultItemsAdapter.java 20KB
AvatarUtil.java 20KB
RoomMembersPanel.java 19KB
LoginFrame.java 17KB
ScreenShot.java 16KB
SizeAutoAdjustTextArea.java 14KB
SimulationUserData.java 13KB
RCListView.java 12KB
TitlePanel.java 12KB
SystemConfigDialog.java 11KB
ModelUtil.java 11KB
SearchPanel.java 11KB
ChatService.java 11KB
XmppFileService.java 10KB
ImageViewerFrame.java 10KB
CreateGroupDialog.java 10KB
MessageViewHolderCacheHelper.java 10KB
MessageEditorPanel.java 9KB
CharacterParser.java 9KB
MessagePopupMenu.java 9KB
XmppLogin.java 9KB
VerticalFlowLayout.java 8KB
MainFrame.java 8KB
HttpUtil.java 8KB
MessageItem.java 8KB
ImageCache.java 8KB
ContactsPanel.java 8KB
ClipboardUtil.java 7KB
Launcher.java 7KB
MucRoomInfo.java 7KB
FilesIO.java 7KB
AddOrRemoveMemberDialog.java 7KB
RoomItemsAdapter.java 7KB
SyncOrgPanel.java 7KB
RosterService.java 7KB
UserInfoPopup.java 6KB
CompletableFutureDemo.java 6KB
RoomMembersAdapter.java 6KB
RoomsPanel.java 6KB
SelectUserPanel.java 6KB
ClearCachePanel.java 6KB
UserInfoPanel.java 5KB
ChangeVcardPanel.java 5KB
Room.java 5KB
ChangePasswordPanel.java 5KB
OfflineFile.java 5KB
TabOperationPanel.java 5KB
ContactsItemsAdapter.java 5KB
OfflineFileRobot.java 4KB
RCTextMessageBubble.java 4KB
SelectUserItemsAdapter.java 4KB
MimeTypeUtil.java 4KB
SessionManager.java 4KB
Message.java 4KB
ChatEditorPopupMenu.java 4KB
ClearDBPanel.java 4KB
AttachmentIconHelper.java 4KB
OfflineFileReceipt.java 4KB
JIMSendTextPane.java 4KB
EmojiPanel.java 4KB
MyInfoPanel.java 4KB
ScrollUI.java 3KB
BasicDao.java 3KB
SearchResultPanel.java 3KB
MucInvitation.java 3KB
TimeUtil.java 3KB
MainOperationPopupMenu.java 3KB
RoomItemViewHolder.java 3KB
RCTextEditor.java 3KB
HighLightLabel.java 3KB
SelectedUserItemsAdapter.java 3KB
RCButton.java 3KB
ImageLabel.java 3KB
MessageRightTextViewHolder.java 3KB
共 1248 条
- 1
- 2
- 3
- 4
- 5
- 6
- 13
资源评论
沐知全栈开发
- 粉丝: 5706
- 资源: 5224
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- (源码)基于Spring Boot和Vue的后台管理系统.zip
- 用于将 Power BI 嵌入到您的应用中的 JavaScript 库 查看文档网站和 Wiki 了解更多信息 .zip
- (源码)基于Arduino、Python和Web技术的太阳能监控数据管理系统.zip
- (源码)基于Arduino的CAN总线传感器与执行器通信系统.zip
- (源码)基于C++的智能电力系统通信协议实现.zip
- 用于 Java 的 JSON-RPC.zip
- 用 JavaScript 重新实现计算机科学.zip
- (源码)基于PythonOpenCVYOLOv5DeepSort的猕猴桃自动计数系统.zip
- 用 JavaScript 编写的贪吃蛇游戏 .zip
- (源码)基于ASP.NET Core的美术课程管理系统.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功