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:edu.illinois.cs.cogcomp.edison.features.lrec.TestWordTypeInformation.java
public final void test() throws EdisonException { log.debug("WordTypeInformation"); // Using the first TA and a constituent between span of 0 - 20 as a test TextAnnotation ta = tas.get(1);//from www . ja v a2s.c o m View TOKENS = ta.getView("TOKENS"); log.debug("GOT TOKENS FROM TEXTAnn"); List<Constituent> testlist = TOKENS.getConstituentsCoveringSpan(0, 20); String[] teststrings = new String[5]; int i = 0, start = 1, end = 6; for (Constituent c : testlist) { log.debug(c.getSurfaceForm()); if (i >= start && i < end) { teststrings[i - start] = c.getSurfaceForm(); } i++; } log.debug("Testlist size is " + testlist.size()); Constituent test = testlist.get(3); log.debug("The constituent we are extracting features from in this test is: " + test.getSurfaceForm()); WordTypeInformation wti = new WordTypeInformation("WordTypeInformation"); log.debug("Startspan is " + test.getStartSpan() + " and Endspan is " + test.getEndSpan()); Set<Feature> feats = wti.getFeatures(test); String[] expected_outputs = { "WordTypeInformation:c0(false)", "WordTypeInformation:d0(false)", "WordTypeInformation:c1(false)", "WordTypeInformation:d1(false)", "WordTypeInformation:c2(false)", "WordTypeInformation:d2(false)", "WordTypeInformation:c2(true)", "WordTypeInformation:c3(false)", "WordTypeInformation:d3(false)", "WordTypeInformation:c4(false)", "WordTypeInformation:d4(false)", "WordTypeInformation:c4(true)" }; Set<String> __result = new LinkedHashSet<String>(); String __id; String __value; String classifier = "WordTypeInformation"; if (feats == null) { log.debug("Feats are returning NULL."); assertFalse(true); } log.debug("Printing Set of Features"); for (Feature f : feats) { log.debug(f.getName()); assert (ArrayUtils.contains(expected_outputs, f.getName())); } for (; (start < end && teststrings[start - 1] != null); start++) { boolean allCapitalized = true, allDigits = true, allNonLetters = true; for (int j = 0; j < teststrings[start - 1].length(); ++j) { allCapitalized &= Character.isUpperCase(teststrings[start - 1].charAt(j)); allDigits &= Character.isDigit(teststrings[start - 1].charAt(j)); allNonLetters &= !Character.isLetter(teststrings[start - 1].charAt(j)); } __id = classifier + ":" + ("c" + (start - 1)); __value = "(" + (allCapitalized) + ")"; __result.add(__id + __value); __id = classifier + ":" + ("d" + (start - 1)); __value = "(" + (allDigits) + ")"; __result.add(__id + __value); __id = classifier + ":" + ("c" + (start - 1)); __value = "(" + (allNonLetters) + ")"; __result.add(__id + __value); } for (Feature feat : feats) { if (!__result.contains(feat.getName())) { assertFalse(true); } } // System.exit(0); }
From source file:gda.device.scannable.DummyContinuouslyScannable.java
/** * For testing and simulation only.// w w w . jav a2 s . co m * * @param detector */ public void removeObserver(final SimulatedBufferedDetector detector) { if (ArrayUtils.contains(observers, detector)) { int index = ArrayUtils.indexOf(observers, detector); observers = (SimulatedBufferedDetector[]) ArrayUtils.remove(observers, index); } }
From source file:net.rrm.ehour.ui.admin.config.MainConfigBackingBean.java
@SuppressWarnings("UnusedDeclaration") public List<Locale> getAvailableLanguages() { Locale[] locales = Locale.getAvailableLocales(); Map<String, Locale> localeMap = new HashMap<>(); // remove all variants for (Locale locale : locales) { if (isTranslationsOnly() && !ArrayUtils.contains(config.getAvailableTranslations(), locale.getLanguage())) { continue; }// w w w . j a v a 2 s . co m if (localeMap.containsKey(locale.getLanguage()) && locale.getDisplayName().indexOf('(') != -1) { continue; } localeMap.put(locale.getLanguage(), locale); } SortedSet<Locale> localeSet = new TreeSet<>(new LocaleComparator(LocaleComparator.CompareType.LANGUAGE)); for (Locale locale : localeMap.values()) { localeSet.add(locale); } return new ArrayList<>(localeSet); }
From source file:eu.dime.ps.semantic.service.context.AspectBasedStrategy.java
@Override public void update(List<Statement> toAdd, List<Statement> toRemove) { // --------/*from w w w . j a v a2 s . co m*/ // updating previous context with values from live context // -------- ClosableIterator<Statement> lcStmts = liveContext.iterator(); List<URI> aspects = new ArrayList<URI>(); List<Statement> toKeep = new ArrayList<Statement>(); // find all aspects in live context and keep these statements statements (to copy to previous context) while (lcStmts.hasNext()) { Statement statement = lcStmts.next(); Node object = statement.getObject(); if (object instanceof URI && ArrayUtils.contains(ASPECTS, object.asURI())) { aspects.add(statement.getSubject().asURI()); toKeep.add(statement); } } lcStmts.close(); // find all statements linking aspects to elements lcStmts = liveContext.iterator(); while (lcStmts.hasNext()) { Statement statement = lcStmts.next(); Resource subject = statement.getSubject(); if (subject instanceof URI && aspects.contains(subject.asURI())) { toKeep.add(statement); } } lcStmts.close(); // removes data in previous context which will be updated (will be removed from live context, thus moved to previous context) for (Statement stmt : toRemove) { URI resource = stmt.getSubject().asURI(); if (!aspects.contains(resource)) { previousContext.removeStatements(resource.asResource(), Variable.ANY, Variable.ANY); } } // move data from live context to previous context List<Statement> all = new ArrayList<Statement>(); all.addAll(toAdd); all.addAll(toRemove); for (Statement stmt : all) { URI resource = stmt.getSubject().asURI(); if (!aspects.contains(resource)) { previousContext.addAll(liveContext.findStatements(resource, Variable.ANY, Variable.ANY)); } } previousContext.addAll(toKeep.iterator()); // -------- // updating live context with method parameters // -------- liveContext.removeAll(toRemove.iterator()); liveContext.addAll(toAdd.iterator()); }
From source file:com.evolveum.polygon.connector.ldap.ad.AdSchemaTranslator.java
@Override protected void setAttributeMultiplicityAndPermissions(AttributeType ldapAttributeType, String connidAttributeName, AttributeInfoBuilder aib) { super.setAttributeMultiplicityAndPermissions(ldapAttributeType, connidAttributeName, aib); if (ArrayUtils.contains(OPTIONAL_TOP_ATTRIBUTES, ldapAttributeType.getName().toLowerCase())) { aib.setRequired(false);//from www .j a v a 2s. c o m } }
From source file:com.adobe.acs.commons.users.impl.ProtectedAuthorizables.java
public static final boolean isProtected(String principalName) { return ArrayUtils.contains(PRINCIPAL_NAMES, principalName); }
From source file:com.flexive.cmis.spi.PrivateWorkingCopyManager.java
/** * Return true if the given PK is currently checked out. * * @param pk the document PK/* w w w . j a va 2s .c om*/ * @return true if the given PK is currently checked out. */ public boolean isCheckedOut(FxPK pk) { return ArrayUtils.contains(getCheckedOutIds(), pk.getId()); }
From source file:edu.illinois.cs.cogcomp.edison.features.lrec.TestPOSandPositionWindowThree.java
public final void test() throws EdisonException { log.debug("POSWindowpp Feature Extractor"); // Using the first TA and a constituent between span of 30-40 as a test TextAnnotation ta = tas.get(2);/* ww w .j a v a 2 s. c om*/ View TOKENS = ta.getView("TOKENS"); log.debug("GOT TOKENS FROM TEXTAnn"); List<Constituent> testlist = TOKENS.getConstituentsCoveringSpan(0, 20); for (Constituent c : testlist) { log.debug(c.getSurfaceForm()); } log.debug("Testlist size is " + testlist.size()); Constituent test = testlist.get(1); log.debug("The constituent we are extracting features from in this test is: " + test.getSurfaceForm()); POSandPositionWindowThree POSWpp = new POSandPositionWindowThree("POSandPositionWindowThree"); // Formpp.initViews(test); log.debug("Startspan is " + test.getStartSpan() + " and Endspan is " + test.getEndSpan()); Set<Feature> feats = POSWpp.getFeatures(test); String[] expected_outputs = { "POSandPositionWindowThree:0_0(DT)", "POSandPositionWindowThree:1_0(VBZ)", "POSandPositionWindowThree:2_0(DT)", "POSandPositionWindowThree:3_0(NN)", "POSandPositionWindowThree:4_0(.)", "POSandPositionWindowThree:5_0(null)", "POSandPositionWindowThree:6_0(null)", "POSandPositionWindowThree:0_1(DT_VBZ)", "POSandPositionWindowThree:1_1(VBZ_DT)", "POSandPositionWindowThree:2_1(DT_NN)", "POSandPositionWindowThree:3_1(NN_.)", "POSandPositionWindowThree:4_1(._null)", "POSandPositionWindowThree:5_1(null_null)", "POSandPositionWindowThree:6_1(null)", "POSandPositionWindowThree:0_2(DT_VBZ_DT)", "POSandPositionWindowThree:1_2(VBZ_DT_NN)", "POSandPositionWindowThree:2_2(DT_NN_.)", "POSandPositionWindowThree:3_2(NN_._null)", "POSandPositionWindowThree:4_2(._null_null)", "POSandPositionWindowThree:5_2(null_null)", "POSandPositionWindowThree:6_2(null)" }; if (feats == null) { log.debug("Feats are returning NULL."); } log.debug("Printing Set of Features"); for (Feature f : feats) { log.debug(f.getName()); assert (ArrayUtils.contains(expected_outputs, f.getName())); } log.debug("GOT FEATURES YES!"); // System.exit(0); }
From source file:eu.dime.ps.semantic.query.BasicQueryTest.java
@Test public void testOrWhere() throws Exception { Collection<FileDataObject> results = resourceStore.find(FileDataObject.class).where(NFO.fileName) .like("motivation").orWhere(NFO.fileName).like("composition").results(); assertEquals(2, results.size());/*from ww w . j av a2s.c o m*/ URI[] files = new URI[] { new URIImpl("file:/home/ismriv/example/dir1/motivation-long-tail.png"), new URIImpl("file:/home/ismriv/example/dir1/different-levels-of-composition.png"), }; for (FileDataObject f : results) { assertTrue(ArrayUtils.contains(files, f.asURI())); } }
From source file:com.googlecode.osde.internal.ui.OsdePreferenceBinder.java
/** * Binds a <code>preferenceName<code> to the attribute of the provided <code>control</code>. * The supported controls are:/*from w w w . j av a 2s. com*/ * <ul> * <li>org.eclipse.swt.widgets.Button (Radio or Checkbox)</li> * <li>org.eclipse.swt.widgets.Combo</li> * <li>org.eclipse.swt.widgets.Text</li> * </ul> * * The supported preference types are: * <ul> * <li>java.lang.Boolean</li> * <li>java.lang.String</li> * </ul> * * @param control * the SWT widget will be bound * @param preferenceName * a key used to the preference store * @param type * model type * @param targetToModel * strategy to employ when the target is the source of the change * and the model is the destination * @param modelToTarget * strategy to employ when the model is the source of the change * and the target is the destination */ public void bind(Control control, String preferenceName, Class<?> type, IConverter targetToModel, IConverter modelToTarget) { if (!ArrayUtils.contains(supportedTypes, type)) { throw new IllegalArgumentException("type[" + type + "] is not supported."); } IObservableValue model = new ObservableMapValue(store, preferenceName); IObservableValue ui = null; UpdateValueStrategy modelUpdater = new UpdateValueStrategy(); UpdateValueStrategy uiUpdater = new UpdateValueStrategy(); if (targetToModel != null) { modelUpdater.setConverter(targetToModel); } if (modelToTarget != null) { uiUpdater.setConverter(modelToTarget); } if (control instanceof Button) { boolean isRadio = (control.getStyle() & SWT.RADIO) != 0; boolean isCheck = (control.getStyle() & SWT.CHECK) != 0; if (isRadio || isCheck) { ui = SWTObservables.observeSelection(control); } } else if (control instanceof Text) { ui = SWTObservables.observeText(control, SWT.Modify); } else if (control instanceof Combo) { ui = SWTObservables.observeText(control); } if (ui == null) { logger.error(control + " is not supported yet."); throw new UnsupportedOperationException(control + " is not supported yet."); } propagateData(preferenceName, type); context.bindValue(ui, model, modelUpdater, uiUpdater); }