List of usage examples for org.apache.commons.lang ArrayUtils indexOf
public static int indexOf(boolean[] array, boolean valueToFind)
Finds the index of the given value in the array.
From source file:org.eclipse.wb.tests.designer.core.nls.ui.FlagRepositoryTest.java
public void test_sortedLocales() throws Exception { Locale[] sortedLocales = FlagImagesRepository.getSortedLocales(); assertTrue(sortedLocales.length >= 140); {/* w ww. j a va2s . c om*/ int index_1 = ArrayUtils.indexOf(sortedLocales, new Locale("en")); int index_2 = ArrayUtils.indexOf(sortedLocales, new Locale("ru")); assertTrue(index_1 < index_2); } { int index_1 = ArrayUtils.indexOf(sortedLocales, new Locale("de")); int index_2 = ArrayUtils.indexOf(sortedLocales, new Locale("it")); assertTrue(index_1 < index_2); } }
From source file:org.eclipse.wb.tests.designer.core.util.ast.BindingsTest.java
/** * Checks that methods with given names returns same values and other (without parameters) methods * fail./*from ww w . j a va 2 s .co m*/ */ private static void assert_sameProperties(Class<?> clazz, Object expectedObject, Object actualObject, String methodNames[]) throws Exception { Method[] allMethods = clazz.getMethods(); for (int i = 0; i < allMethods.length; i++) { Method method = allMethods[i]; if (ArrayUtils.indexOf(methodNames, method.getName()) != -1) { Object expectedValue = method.invoke(expectedObject); Object actualValue = method.invoke(actualObject); assert_equals(method, expectedValue, actualValue); } else if (method.getParameterTypes().length == 0) { assert_methodFails(actualObject, method.getName()); } } }
From source file:org.eclipse.wb.tests.gef.UiContext.java
/** * @return the {@link Control} located in children on its {@link Composite} after {@link Label} * with given text./*from ww w .java 2 s. c o m*/ */ public Control getControlAfterLabel(String text) { List<Label> labels = findWidgets(Label.class); for (Label label : labels) { String labelText = label.getText().trim(); if (isSameText(labelText, text)) { Control[] children = label.getParent().getChildren(); // get next Control int index = ArrayUtils.indexOf(children, label); if (index < children.length - 1) { return children[index + 1]; } // stop it any case break; } } // not found return null; }
From source file:org.eclipse.wb.tests.gef.UiContext.java
/** * @return the {@link Control} located in children on its {@link Composite} after given one. *///from w w w .ja va 2 s . co m @SuppressWarnings("unchecked") public <T> T getControlAfter(Control reference) { Control[] children = reference.getParent().getChildren(); // get next Control int index = ArrayUtils.indexOf(children, reference); if (index < children.length - 1) { return (T) children[index + 1]; } // not found return null; }
From source file:org.esa.beam.occci.bandshift.BandShiftCorrection.java
public double[] correctBandshift(double[] rrs, double[] rrs_wavelengths, double[] qaa) { int number_correction = context.getLambdaI().length; Assert.argument(qaa.length == 3, "qaa must have dimension equal to 3"); // Conversion routine needs RRS at blue and green wavelengths. The blue wavelength // is always 443, however the green wavelength differs according to the sensor. // Note: for processing in-situ data, we have a varying blue center wavelength, therefore we read it from the // spec_model_start context variable tb 2013-10-23 int blue_index = ArrayUtils.indexOf(rrs_wavelengths, context.getSpec_model_start()); if (blue_index == ArrayUtils.INDEX_NOT_FOUND) { throw new IllegalArgumentException("rrs_wavelengths does not contain blue band at 443"); }// w w w.java 2 s. co m double greenWavelength = context.getSensor().getGreenWavelength(); int green_index = ArrayUtils.indexOf(rrs_wavelengths, greenWavelength); if (green_index == ArrayUtils.INDEX_NOT_FOUND) { throw new IllegalArgumentException("rrs_wavelengths does not contain green band at " + greenWavelength); } // Determine the indexes of the correction input products and create the correction output product names int[] input_wavelength_indexes = new int[number_correction]; for (int i = 0; i < number_correction; i++) { double wavelength = context.getLambdaI()[i]; int rrs_prod_position = ArrayUtils.indexOf(rrs_wavelengths, wavelength); if (rrs_prod_position == ArrayUtils.INDEX_NOT_FOUND) { throw new IllegalArgumentException("rrs_wavelengths does not contain band at " + wavelength); } input_wavelength_indexes[i] = rrs_prod_position; } // Determine which intersection bins have valid IOP values (GT MIN and LT MAX) final double qaa_min = context.getQaaMin(); final double qaa_max = context.getQaaMax(); boolean invalid_aph = qaa[APH_INDEX] <= qaa_min || qaa[APH_INDEX] >= qaa_max; boolean invalid_acdm = qaa[ACDM_INDEX] <= qaa_min || qaa[ACDM_INDEX] >= qaa_max; boolean invalid_bbp = qaa[BBP_INDEX] <= qaa_min || qaa[BBP_INDEX] >= qaa_max; if (invalid_aph || invalid_acdm || invalid_bbp) { // no correction return new double[0]; } // Only continue if there are intersection bins with a valid value for all of the used IOPs (aph, acdm, bbp) double[] rrsI = new double[number_correction]; for (int i = 0; i < rrsI.length; i++) { rrsI[i] = rrs[input_wavelength_indexes[i]]; } // Below-water reflectance for blue and green wavelengths double rrs_blue = rrs[blue_index] / 0.52 + 1.7 * rrs[blue_index]; double rrs_green = rrs[green_index] / 0.52 + 1.7 * rrs[green_index]; double[] rrs_corrected = new double[number_correction]; for (int i = 0; i < number_correction; i++) { // Derive the aph, adg and bbp for the correction input wavelengths starting from the blue band double[] spec_model_start = new double[number_correction]; Arrays.fill(spec_model_start, context.getSpec_model_start()); double[] iopSM_i = IopSpectralModel.iopSpectralModel(context.getSpec_model_start(), context.getSmsA(), context.getSmsB(), qaa[APH_INDEX], qaa[ACDM_INDEX], qaa[BBP_INDEX], rrs_blue, rrs_green, context.getLambdaI()[i], context.getA_i()[i], context.getB_i()[i]); // Derive the aph, adg and bbp for the correction output wavelengths starting from the blue band double[] iopSM_o = IopSpectralModel.iopSpectralModel(context.getSpec_model_start(), context.getSmsA(), context.getSmsB(), qaa[APH_INDEX], qaa[ACDM_INDEX], qaa[BBP_INDEX], rrs_blue, rrs_green, context.getLambdaO()[i], context.getA_o()[i], context.getB_o()[i]); // Calculate the total absorption and backscattering at correction output wavelengths double a_tot_out = iopSM_o[APH_INDEX] + iopSM_o[ACDM_INDEX] + context.getAw_o()[i]; double bb_tot_out = iopSM_o[BBP_INDEX] + context.getBbw_o()[i]; // Calculate the total absorption and backscattering at correction input wavelengths double a_tot_in = iopSM_i[APH_INDEX] + iopSM_i[ACDM_INDEX] + context.getAw_i()[i]; double bb_tot_in = iopSM_i[BBP_INDEX] + context.getBbw_i()[i]; // Using the forward QAA mode, calculate the above water RRS for the correction output wavelengths double QAA_u_out = bb_tot_out / (a_tot_out + bb_tot_out); double QAA_rrs_bw_out = (g0 + g1 * QAA_u_out) * QAA_u_out; double QAA_rrs_aw_out = (-0.52 * QAA_rrs_bw_out) / ((1.7 * QAA_rrs_bw_out) - 1.0); // Using the forward QAA model, calculate the above wrater RRS for the correction input wavelengths double QAA_u_in = bb_tot_in / (a_tot_in + bb_tot_in); double QAA_rrs_bw_in = (g0 + g1 * QAA_u_in) * QAA_u_in; double QAA_rrs_aw_in = (-0.52 * QAA_rrs_bw_in) / ((1.7 * QAA_rrs_bw_in) - 1); // Correction factors that, when multiplied with the RRS at correction input wavelengths give RRS at correction output wavelengths double correction_factor = QAA_rrs_aw_out / QAA_rrs_aw_in; // Predict RRS at output wavelengths, multiplying with correction factors rrs_corrected[i] = correction_factor * rrsI[i]; } return rrs_corrected; }
From source file:org.exoplatform.faq.service.search.AnswerSearchResult.java
/** * Checks the id whether is existing or not in result list. * @param id specified id/*from w ww .ja v a 2 s . c om*/ * @return TRUE: existing otherwise FALSE */ public boolean contains(String id) { return ArrayUtils.indexOf(ids, id) >= 0; }
From source file:org.exoplatform.faq.service.search.AnswerSearchResult.java
private boolean contains(String[] skipList, Object o) { if (o instanceof ObjectSearchResult) { ObjectSearchResult a = (ObjectSearchResult) o; return ArrayUtils.indexOf(skipList, a.getId()) >= 0; }//w w w .ja va 2 s. c o m // return false; }
From source file:org.exoplatform.forum.service.search.DiscussionSearchResult.java
private boolean contains(String[] skipList, Object o) { if (o instanceof ForumSearchResult) { ForumSearchResult a = (ForumSearchResult) o; return ArrayUtils.indexOf(skipList, a.getId()) >= 0; }/* ww w. j a v a2 s . c o m*/ // return false; }
From source file:org.exoplatform.social.core.activity.filter.ActivityCounter.java
@Override public boolean contains(Object o) { if (o instanceof ExoSocialActivity) { ExoSocialActivity a = (ExoSocialActivity) o; return ArrayUtils.indexOf(ids, a.getId()) >= 0; }//from ww w.j a v a2 s. c o m // return false; }
From source file:org.exoplatform.social.core.identity.IdentityResult.java
@Override public boolean contains(Object o) { if (o instanceof Identity) { Identity a = (Identity) o; return ArrayUtils.indexOf(ids, a.getId()) >= 0; }//from ww w.j a v a2 s. c o m // return false; }