List of usage examples for org.apache.commons.lang ArrayUtils INDEX_NOT_FOUND
int INDEX_NOT_FOUND
To view the source code for org.apache.commons.lang ArrayUtils INDEX_NOT_FOUND.
Click Source Link
-1
. From source file:com.google.gdt.eclipse.designer.model.widgets.cell.ColumnInfo.java
@Override protected void refresh_finish() throws Exception { super.refresh_finish(); String cellTypeName = null;/* ww w . j a v a2 s.c om*/ // if anonymous, then it was mocked as TextColumn if (getCreationSupport().getNode() instanceof ClassInstanceCreation) { ClassInstanceCreation creation = (ClassInstanceCreation) getCreationSupport().getNode(); if (creation.getAnonymousClassDeclaration() != null) { ITypeBinding anonymousBinding = AstNodeUtils.getTypeBinding(creation); ITypeBinding superBinding = anonymousBinding.getSuperclass(); String superName = AstNodeUtils.getFullyQualifiedName(superBinding, false); if ("com.google.gwt.user.cellview.client.Column".equals(superName)) { Expression cellExpression = DomGenerics.arguments(creation).get(0); cellTypeName = AstNodeUtils.getFullyQualifiedName(cellExpression, false); } } } // get Cell from Column instance if (cellTypeName == null) { Object cell = ReflectionUtils.invokeMethod2(getObject(), "getCell"); Class<?> cellClass = cell.getClass(); cellTypeName = ReflectionUtils.getCanonicalName(cellClass); } // use icon which corresponds to the Cell type if (cellTypeName != null) { int index = ArrayUtils.indexOf(CELL_TYPES, cellTypeName); if (index != ArrayUtils.INDEX_NOT_FOUND) { m_specialIcon = getCreationIcon(CELL_IDS[index]); } } }
From source file:org.apache.hawq.pxf.service.BridgeOutputBuilder.java
/** * Breaks raw bytes into lines. Used only for sampling. * * When sampling a data source, we have to make sure that we deal with * actual rows (lines) and not bigger chunks of data such as used by * LineBreakAccessor for performance. The input byte array is broken into * lines, each one stored in the outputList. In case the read data doesn't * end with a line delimiter, which can happen when reading chunks of bytes, * the partial line is stored separately, and is being completed when * reading the next chunk of data.//from w w w . j a va 2 s . c o m * * @param val input raw data to break into lines */ void convertTextDataToLines(byte[] val) { int len = val.length; int start = 0; int end = 0; byte[] line; BufferWritable writable; while (start < len) { end = ArrayUtils.indexOf(val, DELIM, start); if (end == ArrayUtils.INDEX_NOT_FOUND) { // data finished in the middle of the line end = len; isPartialLine = true; } else { end++; // include the DELIM character isPartialLine = false; } line = Arrays.copyOfRange(val, start, end); if (partialLine != null) { // partial data was completed ((BufferWritable) partialLine).append(line); writable = (BufferWritable) partialLine; partialLine = null; } else { writable = new BufferWritable(line); } if (isPartialLine) { partialLine = writable; } else { outputList.add(writable); } start = end; } }
From source file:org.betaconceptframework.astroboa.engine.jcr.util.JcrValueUtils.java
public static void replaceValue(Node node, ItemQName property, Value newValue, Value oldValue, Boolean isPropertyMultivalued) throws RepositoryException { //Node does not have property if (!node.hasProperty(property.getJcrName())) { //New Value is null. Do nothing if (newValue == null) return; //Determine if property is multiple, if this info is not provided if (isPropertyMultivalued == null) { isPropertyMultivalued = propertyIsMultiValued(node, property); }/*from w w w . j av a 2s . c o m*/ if (isPropertyMultivalued) node.setProperty(property.getJcrName(), new Value[] { newValue }); else node.setProperty(property.getJcrName(), newValue); } else { //Node has property Property jcrProperty = node.getProperty(property.getJcrName()); if (isPropertyMultivalued == null) //Determine by property isPropertyMultivalued = jcrProperty.getDefinition().isMultiple(); if (!isPropertyMultivalued) { if (oldValue == null || (oldValue != null && oldValue.equals(jcrProperty.getValue()))) { //Set newValue only if no old value is provided OR //oldValue is provided and it really exists there jcrProperty.setValue(newValue); } } else { Value[] values = jcrProperty.getValues(); //Remove oldValue if (oldValue != null) { int index = ArrayUtils.indexOf(values, oldValue); if (index == ArrayUtils.INDEX_NOT_FOUND) throw new ItemNotFoundException( "Value " + oldValue.getString() + " in property " + jcrProperty.getPath()); values = (Value[]) ArrayUtils.remove(values, index); } //Add new value if (newValue != null && !ArrayUtils.contains(values, newValue)) values = (Value[]) ArrayUtils.add(values, newValue); //If at the end values array is empty //remove property if (ArrayUtils.isEmpty(values)) { node.setProperty(property.getJcrName(), JcrValueUtils.getJcrNullForMultiValue()); } else { node.setProperty(property.getJcrName(), values); } } } }
From source file:org.eclipse.wb.internal.core.model.property.editor.style.impl.EnumerationStylePropertyImpl.java
@Override public long getFlag(String sFlag) { int index = ArrayUtils.indexOf(m_sValues, sFlag); return index != ArrayUtils.INDEX_NOT_FOUND ? m_values[index] : 0; }
From source file:org.eclipse.wb.internal.core.model.property.editor.style.impl.EnumerationStylePropertyImpl.java
@Override public String getFlagValue(Property property) throws Exception { long value = getStyleValue(property) & m_flagsClearMask; int index = ArrayUtils.indexOf(m_values, value); return index != ArrayUtils.INDEX_NOT_FOUND ? m_sValues[index] : 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"); }/*from w w w.j a v a 2 s . c o 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.jiemamy.utils.JmStringUtil.java
/** * ????????????????/* w w w . j ava 2 s . co m*/ * * @param array ? * @param stringToFind ? * @return ?????{@code true}?????????{@code false} */ public static boolean containsIgnoreCase(String[] array, String stringToFind) { return indexOfIgnoreCase(array, stringToFind) != ArrayUtils.INDEX_NOT_FOUND; }
From source file:org.jiemamy.utils.JmStringUtil.java
/** * ????????????//ww w . j a v a 2 s.co m * * <p>????????????????</p> * * @param array ? * @param stringToFind ? * @param startIndex * @return ?????????{@code -1} */ public static int indexOfIgnoreCase(String[] array, String stringToFind, int startIndex) { if (array == null) { return ArrayUtils.INDEX_NOT_FOUND; } if (startIndex < 0) { startIndex = 0; } if (stringToFind == null) { for (int i = startIndex; i < array.length; i++) { if (array[i] == null) { return i; } } } else { for (int i = startIndex; i < array.length; i++) { if (stringToFind.equalsIgnoreCase(array[i])) { return i; } } } return ArrayUtils.INDEX_NOT_FOUND; }
From source file:org.openhab.binding.upb.internal.UPBReader.java
private int findMessageLength(byte[] buffer, int bufferLength) { int messageLength = ArrayUtils.INDEX_NOT_FOUND; for (int i = 0; i < bufferLength; i++) { if (buffer[i] == 13) { messageLength = i;//from ww w . ja v a2s .c o m break; } } return messageLength; }
From source file:org.openhab.binding.upb.internal.UPBReader.java
/** * Attempts to interpret any messages that may be contained in the buffer. *///from ww w . j a v a2 s .com private void interpretBuffer() { int messageLength = findMessageLength(buffer, bufferLength); while (messageLength != ArrayUtils.INDEX_NOT_FOUND) { String message = new String(Arrays.copyOfRange(buffer, 0, messageLength)); logger.debug("UPB Message: {}", message); int remainingBuffer = bufferLength - messageLength - 1; if (remainingBuffer > 0) { System.arraycopy(buffer, messageLength + 1, buffer, 0, remainingBuffer); } bufferLength = remainingBuffer; notifyListeners(UPBMessage.fromString(message)); messageLength = findMessageLength(buffer, bufferLength); } }