List of usage examples for org.apache.commons.lang ArrayUtils contains
public static boolean contains(boolean[] array, boolean valueToFind)
Checks if the value is in the given array.
From source file:com.activecq.samples.clientcontext.impl.ClientContextBuilderImpl.java
@Override public JSONObject xssProtect(JSONObject json, String... whitelist) throws JSONException { final List<String> keys = IteratorUtils.toList(json.keys()); final boolean useWhiteList = !ArrayUtils.isEmpty(whitelist); log.debug("Use Whitelist: " + !ArrayUtils.isEmpty(whitelist)); for (final String key : keys) { log.debug("XSS Key: " + key); if (!useWhiteList || (useWhiteList && !ArrayUtils.contains(whitelist, key))) { log.debug("XSS -> " + key + XSS_SUFFIX + ": " + xss.filter(ProtectionContext.PLAIN_HTML_CONTENT, json.optString(key))); json.put(key + XSS_SUFFIX, xss.filter(ProtectionContext.PLAIN_HTML_CONTENT, json.optString(key))); }//from w w w . j av a 2 s. co m } log.debug("XSS JSON: " + json.toString(4)); return json; }
From source file:com.aionengine.gameserver.restrictions.RestrictionsManager.java
public synchronized static void activate(Restrictions restriction) { for (Method method : restriction.getClass().getMethods()) { RestrictionMode mode = RestrictionMode.parse(method); if (mode == null) continue; if (method.getAnnotation(DisabledRestriction.class) != null) continue; Restrictions[] restrictions = RESTRICTIONS[mode.ordinal()]; if (!ArrayUtils.contains(restrictions, restriction)) restrictions = (Restrictions[]) ArrayUtils.add(restrictions, restriction); Arrays.sort(restrictions, mode); RESTRICTIONS[mode.ordinal()] = restrictions; }//www . j av a 2 s. c o m }
From source file:de.unistuttgart.ims.uimautil.AnnotationUtil.java
/** * Moves the begin-index as long as a character contain in the array is at * the beginning./*from w ww . ja va 2 s . c om*/ * * @param annotation * the annotation to be trimmed * @param ws * an array of chars to be trimmed * @param <T> * the annotation type * @return the trimmed annotation * @since 0.4.2 */ public static <T extends Annotation> T trimBegin(T annotation, char... ws) { char[] s = annotation.getCoveredText().toCharArray(); if (s.length == 0) return annotation; int b = 0; while (ArrayUtils.contains(ws, s[b])) { b++; } annotation.setBegin(annotation.getBegin() + b); return annotation; }
From source file:com.lily.dap.web.util.Struts2Utils.java
/** * /*from w w w . j a v a2s .c om*/ * * @param t * @param allowModifyFields * @return nullnull */ @SuppressWarnings("unchecked") public static <T extends BaseEntity> T writeModel(T t, String[] allowModifyFields) { if (t != null) { Map<String, String> parameters = new HashMap<String, String>(); HttpServletRequest request = getRequest(); Enumeration enumeration = request.getParameterNames(); while (enumeration.hasMoreElements()) { String paramName = (String) enumeration.nextElement(); if (allowModifyFields != null && !ArrayUtils.contains(allowModifyFields, paramName)) continue; String paramValue = request.getParameter(paramName); parameters.put(paramName, paramValue); } // getMapper().map(parameters, t); String[] rules = parameters.keySet().toArray(new String[0]); TransferUtils.copy(rules, parameters, t, null); } return t; }
From source file:com.surfs.nas.sql.ErrorCodeSupport.java
/** * * @param code/*from w w w .j ava 2 s .c om*/ * @return int */ protected static int getDerbyExceptionType(String code) { for (Map.Entry<Integer, String[]> entry : derby_code_map.entrySet()) { String[] codes = entry.getValue(); if (ArrayUtils.contains(codes, code)) { return entry.getKey(); } } return SortedSQLException.UncategorizedException; }
From source file:com.aionemu.gameserver.restrictions.RestrictionsManager.java
public synchronized static void activate(Restrictions restriction) { for (Method method : restriction.getClass().getMethods()) { RestrictionMode mode = RestrictionMode.parse(method); if (mode == null) { continue; }//from ww w . j a va 2 s . c o m if (method.getAnnotation(DisabledRestriction.class) != null) { continue; } Restrictions[] restrictions = RESTRICTIONS[mode.ordinal()]; if (!ArrayUtils.contains(restrictions, restriction)) { restrictions = (Restrictions[]) ArrayUtils.add(restrictions, restriction); } Arrays.sort(restrictions, mode); RESTRICTIONS[mode.ordinal()] = restrictions; } }
From source file:gov.nih.nci.cabig.caaers.domain.AdverseEventCtcTerm.java
@Override @Transient/*from w w w . java2 s. co m*/ public boolean isPositiveAttributionNeeded() { return !(getCtcTerm() != null && ArrayUtils.contains(new String[] { "10042434", "10011912", "10011914", "10042435", "10016479" }, getCtcTerm().getCtepCode())); }
From source file:gda.device.scannable.DummyContinuouslyScannable.java
/** * For testing and simulation only. Real hardware represented by the ContinuousScannable and DummyHistogramDetector * interfaces would be physically wired together. * //from w ww. j a v a 2s .c om * @param detector */ public void addObserver(final SimulatedBufferedDetector detector) { if (!ArrayUtils.contains(observers, detector)) { observers = (SimulatedBufferedDetector[]) ArrayUtils.add(observers, detector); } }
From source file:gda.device.scannable.scannablegroup.ScannableGroup.java
@Override public void addGroupMemberName(String groupMemberName) { if (!ArrayUtils.contains(groupMemberNames, groupMemberName)) { groupMemberNames = (String[]) ArrayUtils.add(groupMemberNames, groupMemberName); }/*from w ww . ja va 2s .c o m*/ }
From source file:com.manydesigns.portofino.dispatcher.DispatcherLogic.java
private static void appendToPagesSelectionProvider(File baseDir, File file, String breadcrumb, DefaultSelectionProvider selectionProvider, boolean includeDetailChildren, File... excludes) { if (ArrayUtils.contains(excludes, file)) { return;//from w ww. j ava2 s . c o m } if (PageInstance.DETAIL.equals(file.getName())) { if (includeDetailChildren) { breadcrumb += " (detail)"; //TODO I18n selectionProvider.appendRow("/" + ElementsFileUtils.getRelativePath(baseDir, file), breadcrumb, true); appendChildrenToPagesSelectionProvider(baseDir, file, breadcrumb, selectionProvider, includeDetailChildren, excludes); } } else { Page page; try { page = getPage(file); } catch (Exception e) { throw new RuntimeException("Couldn't load page", e); } if (breadcrumb == null) { breadcrumb = page.getTitle(); } else { breadcrumb = String.format("%s > %s", breadcrumb, page.getTitle()); } selectionProvider.appendRow("/" + ElementsFileUtils.getRelativePath(baseDir, file), breadcrumb, true); appendChildrenToPagesSelectionProvider(baseDir, file, breadcrumb, selectionProvider, includeDetailChildren, excludes); } }