本文整理汇总了Java中com.helger.commons.collection.ArrayHelper.contains方法的典型用法代码示例。如果您正苦于以下问题:Java ArrayHelper.contains方法的具体用法?Java ArrayHelper.contains怎么用?Java ArrayHelper.contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.helger.commons.collection.ArrayHelper
的用法示例。
在下文中一共展示了ArrayHelper.contains方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: jsonUnescape
import com.helger.commons.collection.ArrayHelper; //导入方法依赖的package包/类
@Nonnull
public static String jsonUnescape (@Nonnull final char [] aInput)
{
ValueEnforcer.notNull (aInput, "Input");
if (!ArrayHelper.contains (aInput, MASK_CHAR))
{
// Nothing to unescape
return new String (aInput);
}
// Perform unescape
final StringBuilder aSB = new StringBuilder (aInput.length);
jsonUnescapeToStringBuilder (aInput, aSB);
return aSB.toString ();
}
示例2: _unifySinglePart
import com.helger.commons.collection.ArrayHelper; //导入方法依赖的package包/类
/**
* Unify a single name part. Performs the following transformations:
* <ul>
* <li>Remove leading and trailing whitespaces</li>
* <li>If the name is all upper case, down case all except the first character
* </li>
* </ul>
*
* @param sPart
* The string part to be unified
* @param aSortLocale
* The local to use (for case changing)
* @return The unified part
*/
@Nullable
private static String _unifySinglePart (@Nonnull final String sPart, @Nonnull final Locale aSortLocale)
{
// empty name?
String s = sPart.trim ();
final int nLength = s.length ();
if (nLength == 0)
return null;
// all upper case name?
if (nLength == 1)
return s.toUpperCase (aSortLocale);
// uppercase first only
s = s.substring (0, 1).toUpperCase (aSortLocale) + s.substring (1).toLowerCase (aSortLocale);
// special cases: nobiliary particles ;-)
if (ArrayHelper.contains (NOBILIARY_PARTICLES, s))
s = s.toLowerCase (aSortLocale);
return s;
}
示例3: startsWithAny
import com.helger.commons.collection.ArrayHelper; //导入方法依赖的package包/类
public static boolean startsWithAny (@Nullable final CharSequence aCS, @Nullable final char [] aChars)
{
if (hasText (aCS) && aChars != null)
if (ArrayHelper.contains (aChars, aCS.charAt (0)))
return true;
return false;
}
示例4: endsWithAny
import com.helger.commons.collection.ArrayHelper; //导入方法依赖的package包/类
public static boolean endsWithAny (@Nullable final CharSequence aCS, @Nullable final char [] aChars)
{
if (hasText (aCS) && aChars != null)
if (ArrayHelper.contains (aChars, getLastChar (aCS)))
return true;
return false;
}
示例5: replaceMultiple
import com.helger.commons.collection.ArrayHelper; //导入方法依赖的package包/类
/**
* Optimized replace method that replaces a set of characters with another
* character. This method was created for efficient unsafe character
* replacements!
*
* @param sInputString
* The input string.
* @param aSearchChars
* The characters to replace.
* @param cReplacementChar
* The new char to be used instead of the search chars.
* @return The replaced version of the string or an empty char array if the
* input string was <code>null</code>.
*/
@Nonnull
public static char [] replaceMultiple (@Nullable final String sInputString,
@Nonnull final char [] aSearchChars,
final char cReplacementChar)
{
ValueEnforcer.notNull (aSearchChars, "SearchChars");
// Any input text?
if (hasNoText (sInputString))
return ArrayHelper.EMPTY_CHAR_ARRAY;
// Get char array
final char [] aInput = sInputString.toCharArray ();
// Any replacement patterns?
if (aSearchChars.length == 0)
return aInput;
// build result
final char [] aOutput = new char [aInput.length];
int nOutputIndex = 0;
for (final char c : aInput)
{
if (ArrayHelper.contains (aSearchChars, c))
aOutput[nOutputIndex] = cReplacementChar;
else
aOutput[nOutputIndex] = c;
nOutputIndex++;
}
return aOutput;
}
示例6: replaceMultipleTo
import com.helger.commons.collection.ArrayHelper; //导入方法依赖的package包/类
/**
* Optimized replace method that replaces a set of characters with another
* character. This method was created for efficient unsafe character
* replacements!
*
* @param sInputString
* The input string.
* @param aSearchChars
* The characters to replace.
* @param cReplacementChar
* The new char to be used instead of the search chars.
* @param aTarget
* The target StringBuilder to write the result to. May not be
* <code>null</code>.
*/
public static void replaceMultipleTo (@Nullable final String sInputString,
@Nonnull final char [] aSearchChars,
final char cReplacementChar,
@Nonnull final StringBuilder aTarget)
{
ValueEnforcer.notNull (aSearchChars, "SearchChars");
ValueEnforcer.notNull (aTarget, "Target");
// Any input text?
if (hasText (sInputString))
{
// Any search chars?
if (aSearchChars.length == 0)
{
aTarget.append (sInputString);
}
else
{
// Perform the replacement
for (final char c : sInputString.toCharArray ())
{
if (ArrayHelper.contains (aSearchChars, c))
aTarget.append (cReplacementChar);
else
aTarget.append (c);
}
}
}
}
示例7: containsAny
import com.helger.commons.collection.ArrayHelper; //导入方法依赖的package包/类
/**
* Check if any of the passed searched characters is contained in the input
* char array.
*
* @param aInput
* The input char array. May be <code>null</code>.
* @param aSearchChars
* The char array to search. May not be <code>null</code>.
* @return <code>true</code> if at least any of the search char is contained
* in the input char array, <code>false</code> otherwise.
*/
public static boolean containsAny (@Nullable final char [] aInput, @Nonnull final char [] aSearchChars)
{
ValueEnforcer.notNull (aSearchChars, "SearchChars");
if (aInput != null)
for (final char cIn : aInput)
if (ArrayHelper.contains (aSearchChars, cIn))
return true;
return false;
}
示例8: isTSpecialChar
import com.helger.commons.collection.ArrayHelper; //导入方法依赖的package包/类
/**
* Check if the passed character is a special character according to RFC 2045
* chapter 5.1
*
* @param c
* The character to check
* @return <code>true</code> if the character is a special character,
* <code>false</code> otherwise.
*/
public static boolean isTSpecialChar (final char c)
{
return ArrayHelper.contains (TSPECIAL, c);
}