本文整理汇总了Java中org.apache.commons.lang3.StringUtils.normalizeSpace方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtils.normalizeSpace方法的具体用法?Java StringUtils.normalizeSpace怎么用?Java StringUtils.normalizeSpace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang3.StringUtils
的用法示例。
在下文中一共展示了StringUtils.normalizeSpace方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makeErrorMessage
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private String makeErrorMessage(DeferredElementImpl testCaseElem) {
try {
Node failureNode = getNodeByTagName(testCaseElem.getChildNodes(), "failure");
Node messageNode = getNodeByTagName(failureNode.getChildNodes(), "message");
Node stackTraceNode = getNodeByTagName(failureNode.getChildNodes(), "stack-trace");
return "Error message: " + StringUtils.normalizeSpace(messageNode.getTextContent()) + " Stack trace: " + StringUtils.normalizeSpace(stackTraceNode.getTextContent());
} catch (Exception e) {
return null;
}
}
示例2: readFile
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Override
public String readFile(final String fileName) {
try {
return StringUtils.normalizeSpace(
IOUtils.toString(
this.getClass().getClassLoader().getResourceAsStream(fileName)));
}
catch (IOException e) {
LOGGER.error("File could not be loaded from resource: {}", e.getMessage());
}
return null;
}
开发者ID:blmalone,项目名称:Blockchain-Academic-Verification-Service,代码行数:13,代码来源:FileReaderServiceImpl.java
示例3: normalizeString
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
public static String normalizeString(String input) {
// Contain only ASCII letters, digits, or underscore characters (_).
// Begin with an alphabetic character or underscore character.
// Subsequent characters may include letters, digits, underscores.
// Be between 1 and 127 characters in length, not including quotes for
// delimited identifiers.
// Contain no quotation marks and no spaces.
StringBuffer sb = new StringBuffer();
// To lowercase and remove all extra whitespaces.
input = StringUtils.normalizeSpace(input.toLowerCase());
for (char c : input.toCharArray()) {
if (VALID_CHARS.contains(String.valueOf(c))) {
if (sb.length() == 0 && INVALID_FIRST_CHARS.contains(String.valueOf(c))) {
sb.append(REPLACEMENT_CHAR);
}
else {
sb.append(c);
}
}
else {
sb.append(REPLACEMENT_CHAR);
}
}
String normalizedName = sb.toString();
// Remove leading and trailing underscore and multiple underscores
normalizedName = StringUtils.replacePattern(normalizedName, "_{2,}", REPLACEMENT_CHAR);
normalizedName = StringUtils.strip(normalizedName, REPLACEMENT_CHAR);
return normalizedName.length() > 127 ? normalizedName.substring(0, 127) : normalizedName;
}
示例4: getSmartContract
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private String getSmartContract(final String contract) {
try {
return StringUtils.normalizeSpace(
IOUtils.toString(
this.getClass().getClassLoader().getResourceAsStream(contract)));
}
catch (IOException e) {
LOGGER.error("Failed to serialize contract", e);
}
return null;
}
示例5: processChatMessage
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
* Process chat messages (broadcast back to clients) and commands (executes)
*/
public void processChatMessage(C01PacketChatMessage packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerForPlayer());
if (this.playerEntity.getChatVisibility() == EntityPlayer.EnumChatVisibility.HIDDEN)
{
ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("chat.cannotSend", new Object[0]);
chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.RED);
this.sendPacket(new S02PacketChat(chatcomponenttranslation));
}
else
{
this.playerEntity.markPlayerActive();
String s = packetIn.getMessage();
s = StringUtils.normalizeSpace(s);
for (int i = 0; i < s.length(); ++i)
{
if (!ChatAllowedCharacters.isAllowedCharacter(s.charAt(i)))
{
this.kickPlayerFromServer("Illegal characters in chat");
return;
}
}
if (s.startsWith("/"))
{
this.handleSlashCommand(s);
}
else
{
IChatComponent ichatcomponent = new ChatComponentTranslation("chat.type.text", new Object[] {this.playerEntity.getDisplayName(), s});
this.serverController.getConfigurationManager().sendChatMsgImpl(ichatcomponent, false);
}
this.chatSpamThresholdCount += 20;
if (this.chatSpamThresholdCount > 200 && !this.serverController.getConfigurationManager().canSendCommands(this.playerEntity.getGameProfile()))
{
this.kickPlayerFromServer("disconnect.spam");
}
}
}
示例6: processChatMessage
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
* Process chat messages (broadcast back to clients) and commands (executes)
*/
public void processChatMessage(CPacketChatMessage packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerWorld());
if (this.playerEntity.getChatVisibility() == EntityPlayer.EnumChatVisibility.HIDDEN)
{
TextComponentTranslation textcomponenttranslation = new TextComponentTranslation("chat.cannotSend", new Object[0]);
textcomponenttranslation.getStyle().setColor(TextFormatting.RED);
this.sendPacket(new SPacketChat(textcomponenttranslation));
}
else
{
this.playerEntity.markPlayerActive();
String s = packetIn.getMessage();
s = StringUtils.normalizeSpace(s);
for (int i = 0; i < s.length(); ++i)
{
if (!ChatAllowedCharacters.isAllowedCharacter(s.charAt(i)))
{
this.kickPlayerFromServer("Illegal characters in chat");
return;
}
}
if (s.startsWith("/"))
{
this.handleSlashCommand(s);
}
else
{
ITextComponent itextcomponent = new TextComponentTranslation("chat.type.text", new Object[] {this.playerEntity.getDisplayName(), s});
this.serverController.getPlayerList().sendChatMsgImpl(itextcomponent, false);
}
this.chatSpamThresholdCount += 20;
if (this.chatSpamThresholdCount > 200 && !this.serverController.getPlayerList().canSendCommands(this.playerEntity.getGameProfile()))
{
this.kickPlayerFromServer("disconnect.spam");
}
}
}
示例7: processChatMessage
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
* Process chat messages (broadcast back to clients) and commands (executes)
*/
public void processChatMessage(CPacketChatMessage packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerWorld());
if (this.playerEntity.getChatVisibility() == EntityPlayer.EnumChatVisibility.HIDDEN)
{
TextComponentTranslation textcomponenttranslation = new TextComponentTranslation("chat.cannotSend", new Object[0]);
textcomponenttranslation.getStyle().setColor(TextFormatting.RED);
this.sendPacket(new SPacketChat(textcomponenttranslation));
}
else
{
this.playerEntity.markPlayerActive();
String s = packetIn.getMessage();
s = StringUtils.normalizeSpace(s);
for (int i = 0; i < s.length(); ++i)
{
if (!ChatAllowedCharacters.isAllowedCharacter(s.charAt(i)))
{
this.kickPlayerFromServer("Illegal characters in chat");
return;
}
}
if (s.startsWith("/"))
{
this.handleSlashCommand(s);
}
else
{
ITextComponent itextcomponent = new TextComponentTranslation("chat.type.text", this.playerEntity.getDisplayName(), net.minecraftforge.common.ForgeHooks.newChatWithLinks(s));
itextcomponent = net.minecraftforge.common.ForgeHooks.onServerChatEvent(this, s, itextcomponent);
if (itextcomponent == null) return;
this.serverController.getPlayerList().sendChatMsgImpl(itextcomponent, false);
}
this.chatSpamThresholdCount += 20;
if (this.chatSpamThresholdCount > 200 && !this.serverController.getPlayerList().canSendCommands(this.playerEntity.getGameProfile()))
{
this.kickPlayerFromServer("disconnect.spam");
}
}
}