本文整理汇总了Java中org.apache.commons.lang.ArrayUtils.contains方法的典型用法代码示例。如果您正苦于以下问题:Java ArrayUtils.contains方法的具体用法?Java ArrayUtils.contains怎么用?Java ArrayUtils.contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang.ArrayUtils
的用法示例。
在下文中一共展示了ArrayUtils.contains方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: delete
import org.apache.commons.lang.ArrayUtils; //导入方法依赖的package包/类
/**
* 删除用户
*/
@SysLog("删除用户")
@RequestMapping("/delete")
@RequiresPermissions("sys:user:delete")
public R delete(@RequestBody Long[] userIds){
if(ArrayUtils.contains(userIds, 1L)){
return R.error("系统管理员不能删除");
}
if(ArrayUtils.contains(userIds, getUserId())){
return R.error("当前用户不能删除");
}
sysUserService.deleteBatch(userIds);
return R.ok();
}
示例2: delete
import org.apache.commons.lang.ArrayUtils; //导入方法依赖的package包/类
/**
* 删除用户
*/
@SysLog("删除用户")
@RequestMapping("/delete")
@RequiresPermissions("sys:user:delete")
public Result delete(@RequestBody Long[] userIds) {
if (ArrayUtils.contains(userIds, 1L)) {
return Result.error("系统管理员不能删除");
}
if (ArrayUtils.contains(userIds, getUserId())) {
return Result.error("当前用户不能删除");
}
try {
sysUserService.deleteBatch(userIds);
} catch (Exception e) {
logger.error("删除用户异常", e);
return Result.error("删除用户异常");
}
return Result.ok();
}
示例3: filter
import org.apache.commons.lang.ArrayUtils; //导入方法依赖的package包/类
@Override
public ContainerRequest filter(ContainerRequest request) {
// only if the query parameters contain the configured name
// and one of the values from "fromValues"
if (request.getQueryParameters() != null
&& !request.getQueryParameters().isEmpty()
&& request.getQueryParameters().containsKey(queryParamToModify)
&& ArrayUtils.contains(fromValues,
request.getQueryParameters().getFirst(queryParamToModify))) {
URI modifiedUri = getModifiedUri(request.getRequestUri());
request.setUris(request.getBaseUri(), modifiedUri);
}
return request;
}
示例4: register
import org.apache.commons.lang.ArrayUtils; //导入方法依赖的package包/类
/**
* <p>
* 保存画面的内容
* </p>
*
* @return
* @throws Exception
*/
public String register() {
logger.debug("register start.");
if (ArrayUtils.contains(YiDuConstants.ALLOW_SAMPLE_TYPES, getSampleContentType())) {
try {
// saveArticlespic();
} catch (Exception e) {
addActionError(getText("errors.file.save"));
return FREEMARKER;
}
} else {
addActionError(getText("errors.file.type"));
return FREEMARKER;
}
addActionMessage(getText("messages.save.success"));
logger.debug("register normally end.");
return FREEMARKER;
}
示例5: escapeKey
import org.apache.commons.lang.ArrayUtils; //导入方法依赖的package包/类
private String escapeKey(String key)
{
StringBuilder newkey = new StringBuilder();
for( int i = 0; i < key.length(); i++ )
{
char c = key.charAt(i);
if( ArrayUtils.contains(SEPARATORS, c) || ArrayUtils.contains(WHITE_SPACE, c) )
{
// escape the separator
newkey.append('\\');
newkey.append(c);
}
else
{
newkey.append(c);
}
}
return newkey.toString();
}
示例6: escapeKey
import org.apache.commons.lang.ArrayUtils; //导入方法依赖的package包/类
private String escapeKey(String key)
{
StringBuffer newkey = new StringBuffer();
for( int i = 0; i < key.length(); i++ )
{
char c = key.charAt(i);
if( ArrayUtils.contains(SEPARATORS, c) || ArrayUtils.contains(WHITE_SPACE, c) )
{
// escape the separator
newkey.append('\\');
newkey.append(c);
}
else
{
newkey.append(c);
}
}
return newkey.toString();
}
示例7: reflectionAppend
import org.apache.commons.lang.ArrayUtils; //导入方法依赖的package包/类
/**
* <p>Appends the fields and values defined by the given object of the
* given Class.</p>
*
* @param lhs the left hand object
* @param rhs the right hand object
* @param clazz the class to append details of
* @param builder the builder to append to
* @param useTransients whether to test transient fields
* @param excludeFields array of field names to exclude from testing
*/
private static void reflectionAppend(
Object lhs,
Object rhs,
Class clazz,
EqualsBuilder builder,
boolean useTransients,
String[] excludeFields) {
Field[] fields = clazz.getDeclaredFields();
AccessibleObject.setAccessible(fields, true);
for (int i = 0; i < fields.length && builder.isEquals; i++) {
Field f = fields[i];
if (!ArrayUtils.contains(excludeFields, f.getName())
&& (f.getName().indexOf('$') == -1)
&& (useTransients || !Modifier.isTransient(f.getModifiers()))
&& (!Modifier.isStatic(f.getModifiers()))) {
try {
builder.append(f.get(lhs), f.get(rhs));
} catch (IllegalAccessException e) {
//this can't happen. Would get a Security exception instead
//throw a runtime exception in case the impossible happens.
throw new InternalError("Unexpected IllegalAccessException");
}
}
}
}
示例8: addFtrVect
import org.apache.commons.lang.ArrayUtils; //导入方法依赖的package包/类
/**
* @param base
* @param ftrId
* @return a new feature vector composed by base with the addition of ftrId.
*/
public static int[] addFtrVect(int[] base, int ftrId) {
if (base == null)
return new int[] { ftrId };
else {
if (ArrayUtils.contains(base, ftrId))
throw new IllegalArgumentException("Trying to add a feature to a vector that already contains it.");
int[] newVect = new int[base.length + 1];
System.arraycopy(base, 0, newVect, 0, base.length);
newVect[newVect.length - 1] = ftrId;
Arrays.sort(newVect);
return newVect;
}
}
示例9: writeLineLibSvm
import org.apache.commons.lang.ArrayUtils; //导入方法依赖的package包/类
private String writeLineLibSvm(double[] ftrVect, BufferedWriter wr, double gold, int id, int[] selectedFeatures)
throws IOException {
String line = String.format("%.5f ", gold);
for (int ftr = 0; ftr < ftrVect.length; ftr++)
if (selectedFeatures == null || ArrayUtils.contains(selectedFeatures, ftr + 1))
line += String.format("%d:%.9f ", ftr + 1, ftrVect[ftr]);
line += " #id=" + id;
return line;
}
示例10: containsAll
import org.apache.commons.lang.ArrayUtils; //导入方法依赖的package包/类
/**
* 检查one数组是否包含two数组所有元素
*
* @param one
* @param two
* @return
*/
public static boolean containsAll(Object[] one, Object[] two) {
for (Object b : two) {
if (!ArrayUtils.contains(one, b)) {
return false;
}
}
return true;
}
示例11: reflectionAppend
import org.apache.commons.lang.ArrayUtils; //导入方法依赖的package包/类
/**
* <p>
* Appends the fields and values defined by the given object of the given <code>Class</code>.
* </p>
*
* @param object
* the object to append details of
* @param clazz
* the class to append details of
* @param builder
* the builder to append to
* @param useTransients
* whether to use transient fields
* @param excludeFields
* Collection of String field names to exclude from use in calculation of hash code
*/
private static void reflectionAppend(Object object, Class clazz, HashCodeBuilder builder, boolean useTransients,
String[] excludeFields) {
if (isRegistered(object)) {
return;
}
try {
register(object);
Field[] fields = clazz.getDeclaredFields();
AccessibleObject.setAccessible(fields, true);
for (int i = 0; i < fields.length; i++) {
Field field = fields[i];
if (!ArrayUtils.contains(excludeFields, field.getName())
&& (field.getName().indexOf('$') == -1)
&& (useTransients || !Modifier.isTransient(field.getModifiers()))
&& (!Modifier.isStatic(field.getModifiers()))) {
try {
Object fieldValue = field.get(object);
builder.append(fieldValue);
} catch (IllegalAccessException e) {
// this can't happen. Would get a Security exception instead
// throw a runtime exception in case the impossible happens.
throw new InternalError("Unexpected IllegalAccessException");
}
}
}
} finally {
unregister(object);
}
}
示例12: reflectionAppend
import org.apache.commons.lang.ArrayUtils; //导入方法依赖的package包/类
/**
* <p>Appends to <code>builder</code> the comparison of <code>lhs</code>
* to <code>rhs</code> using the fields defined in <code>clazz</code>.</p>
*
* @param lhs left-hand object
* @param rhs right-hand object
* @param clazz <code>Class</code> that defines fields to be compared
* @param builder <code>CompareToBuilder</code> to append to
* @param useTransients whether to compare transient fields
* @param excludeFields fields to exclude
*/
private static void reflectionAppend(
Object lhs,
Object rhs,
Class clazz,
CompareToBuilder builder,
boolean useTransients,
String[] excludeFields) {
Field[] fields = clazz.getDeclaredFields();
AccessibleObject.setAccessible(fields, true);
for (int i = 0; i < fields.length && builder.comparison == 0; i++) {
Field f = fields[i];
if (!ArrayUtils.contains(excludeFields, f.getName())
&& (f.getName().indexOf('$') == -1)
&& (useTransients || !Modifier.isTransient(f.getModifiers()))
&& (!Modifier.isStatic(f.getModifiers()))) {
try {
builder.append(f.get(lhs), f.get(rhs));
} catch (IllegalAccessException e) {
// This can't happen. Would get a Security exception instead.
// Throw a runtime exception in case the impossible happens.
throw new InternalError("Unexpected IllegalAccessException");
}
}
}
}
示例13: existProperty
import org.apache.commons.lang.ArrayUtils; //导入方法依赖的package包/类
public VocabularyProperty existProperty(String propertyName, String aspect, String vocabularyIRI) throws NameException {
String realAspect = aspect;
VocabularyProperty vocabularyProperty = (VocabularyProperty) vocabularyPropertyCache.getCachedElement(propertyName + aspect + vocabularyIRI);
if (vocabularyProperty == null) {
if (vocabularies.get(vocabularyIRI) != null) {
Map<String, VocabularyProperty> propertyMap = vocabularies.get(vocabularyIRI).getProperties();
vocabularyProperty = propertyMap.get(propertyName);
if (vocabularyProperty != null) {
if (realAspect != null && realAspect.trim().length() > 0) {
if (ArrayUtils.contains(vocabularyProperty.getAspects(), realAspect)) {
vocabularyPropertyCache.setCachedElement(propertyName + aspect + vocabularyIRI, vocabularyProperty);
return vocabularyProperty;
} else {
throw new NameException(NameException.ASPECT_NOT_RECOGNIZED, "unknow \"" + realAspect + "\" aspect");
}
} else {
return vocabularyProperty;
}
} else {
throw new NameException(NameException.PROPERTY_NOT_RECOGNIZED, "unknow \"" + propertyName + "\" property");
}
} else {
throw new NameException(NameException.VOCABULARY_NOT_RECOGNIZED, "unknow \"" + vocabularyIRI + "\" vacabulary");
}
} else {
return vocabularyProperty;
}
}
示例14: getSSLSocketCreator
import org.apache.commons.lang.ArrayUtils; //导入方法依赖的package包/类
private SocketCreator getSSLSocketCreator(final SecurableCommunicationChannel sslComponent,
final SSLConfig sslConfig) {
if (sslConfig.isEnabled()) {
if (ArrayUtils.contains(getDistributionConfig().getSecurableCommunicationChannels(),
SecurableCommunicationChannel.ALL)) {
return createSSLSocketCreator(SecurableCommunicationChannel.ALL, sslConfig);
// } else if
// (ArrayUtils.contains(getDistributionConfig().getSecurableCommunicationChannels(),
// sslComponent)) {
} else {
return createSSLSocketCreator(sslComponent, sslConfig);
}
}
return createSSLSocketCreator(sslComponent, sslConfig);
}
示例15: populateTable
import org.apache.commons.lang.ArrayUtils; //导入方法依赖的package包/类
/**
* Writes the content from a String[][] into the provided table.
*
* @param tContent
* has the content, which has to be populated
* @param t
* has the table, which is populated
* @param skipRows
* holds the indexes for header, empty and sum rows. These rows are skipped,
* because they do not belong to the content. Likewise these rows
* do not increase the row id, thus table row id and parsed table
* row id maid slightly differ depending on the header.
*/
public void populateTable(String[][] tContent, Table t, int[] skipRows) {
int tableRowIndex = 0;
for (int rowIdx = 0; rowIdx < tContent.length; rowIdx++) {
if (!ArrayUtils.contains(skipRows, rowIdx)) {
String[] rowData = tContent[rowIdx];
Object[] values = new Object[tContent[rowIdx].length];
for (int i = 0; i < rowData.length && i < values.length; i++) {
if (rowData[i] != null && !rowData[i].trim().isEmpty()) {
values[i] = stringNormalizer.normaliseValue(rowData[i], false);
if (((String) values[i]).equalsIgnoreCase(StringNormalizer.nullValue)) {
values[i] = null;
} else {
values[i] = values[i];
}
}
}
// make sure the row number is the row's position in the table.
TableRow r = new TableRow(tableRowIndex, t);
tableRowIndex++;
r.set(values);
t.addRow(r);
}
}
}