List of usage examples for org.apache.commons.lang3 ArrayUtils INDEX_NOT_FOUND
int INDEX_NOT_FOUND
To view the source code for org.apache.commons.lang3 ArrayUtils INDEX_NOT_FOUND.
Click Source Link
From source file:com.github.koraktor.steamcondenser.PacketBuffer.java
/** * Returns a string value from the buffer's current position * <p>/*from w ww . j av a 2 s .co m*/ * This reads the bytes up to the first zero-byte of the underlying byte * buffer into a String * * @return A string value */ public String getString() { byte[] remainingBytes = new byte[this.byteBuffer.remaining()]; this.byteBuffer.slice().get(remainingBytes); int zeroPosition = ArrayUtils.indexOf(remainingBytes, (byte) 0); if (zeroPosition == ArrayUtils.INDEX_NOT_FOUND) { return null; } else { byte[] stringBytes = new byte[zeroPosition]; System.arraycopy(remainingBytes, 0, stringBytes, 0, zeroPosition); this.byteBuffer.position(this.byteBuffer.position() + zeroPosition + 1); return new String(stringBytes); } }
From source file:edu.fullerton.jspWebUtils.PageItem.java
public void addEvent(String evt, String call) throws WebUtilException { int idx = ArrayUtils.indexOf(events, evt, 0); if (idx == ArrayUtils.INDEX_NOT_FOUND) { throw new WebUtilException("Unknown event.(" + evt + ")"); } else {/*from w w w . jav a2 s.c o m*/ if (event == null) { event = new TreeMap<String, String>(); } if (event.containsKey(evt)) { throw new WebUtilException("Event: " + evt + " already assigned"); } event.put(evt, call); } }
From source file:fr.inria.atlanmod.neoemf.data.berkeleydb.store.DirectWriteBerkeleyDBStore.java
@Override public int indexOf(InternalEObject object, EStructuralFeature feature, Object value) { int resultValue; PersistentEObject persistentEObject = PersistentEObject.from(object); Object[] array = (Object[]) getFromMap(persistentEObject, feature); if (isNull(array)) { resultValue = ArrayUtils.INDEX_NOT_FOUND; } else if (feature instanceof EAttribute) { resultValue = ArrayUtils.indexOf(array, serializeToProperty((EAttribute) feature, value)); } else {// w w w . j ava 2 s. c om PersistentEObject childEObject = PersistentEObject.from(value); resultValue = ArrayUtils.indexOf(array, childEObject.id()); } return resultValue; }
From source file:com.opencsv.ResultSetColumnNameHelperService.java
private void populateColumnData(ResultSet rs) throws SQLException { String[] realColumnNames = super.getColumnNames(rs); if (columnNames == null) { columnNames = Arrays.copyOf(realColumnNames, realColumnNames.length); columnHeaders = Arrays.copyOf(realColumnNames, realColumnNames.length); }// w w w .j a v a 2 s.c o m for (String name : columnNames) { int position = ArrayUtils.indexOf(realColumnNames, name); if (position == ArrayUtils.INDEX_NOT_FOUND) { throw new UnsupportedOperationException( "The column named " + name + " does not exist in the result set!"); } columnNamePositionMap.put(name, position); } }
From source file:fr.inria.atlanmod.neoemf.data.berkeleydb.store.DirectWriteBerkeleyDBStore.java
@Override public int lastIndexOf(InternalEObject object, EStructuralFeature feature, Object value) { int resultValue; PersistentEObject persistentEObject = PersistentEObject.from(object); Object[] array = (Object[]) getFromMap(persistentEObject, feature); if (isNull(array)) { resultValue = ArrayUtils.INDEX_NOT_FOUND; } else if (feature instanceof EAttribute) { resultValue = ArrayUtils.lastIndexOf(array, serializeToProperty((EAttribute) feature, value)); } else {/* w w w. ja v a2s . c om*/ PersistentEObject childEObject = PersistentEObject.from(value); resultValue = ArrayUtils.lastIndexOf(array, childEObject.id()); } return resultValue; }
From source file:edu.harvard.hms.dbmi.bd2k.irct.model.result.tabular.ResultSetImpl.java
@Override public int findColumn(String columnLabel) throws ResultSetException { if (isClosed()) { throw new ResultSetException("ResultSet is closed"); }//w w w . j a v a2 s.co m int position = ArrayUtils.indexOf(this.columnNames, columnLabel); if (position == ArrayUtils.INDEX_NOT_FOUND) { throw new ResultSetException("Column not found"); } return position; }
From source file:fr.inria.atlanmod.neoemf.data.blueprints.store.DirectWriteBlueprintsStore.java
@Override protected int indexOfReference(PersistentEObject object, EReference eReference, PersistentEObject value) { if (nonNull(value)) { Vertex inVertex = persistenceBackend.getVertex(object.id()); Vertex outVertex = persistenceBackend.getVertex(value.id()); for (Edge e : outVertex.getEdges(Direction.IN, eReference.getName())) { if (Objects.equals(e.getVertex(Direction.OUT), inVertex)) { return e.getProperty(POSITION); }//from ww w. j av a 2s . co m } } return ArrayUtils.INDEX_NOT_FOUND; }
From source file:fr.inria.atlanmod.neoemf.data.blueprints.store.DirectWriteBlueprintsStore.java
@Override protected int lastIndexOfReference(PersistentEObject object, EReference eReference, PersistentEObject value) { int resultValue; if (isNull(value)) { resultValue = ArrayUtils.INDEX_NOT_FOUND; } else {/*from w w w . j a v a 2 s . c o m*/ Vertex inVertex = persistenceBackend.getVertex(object.id()); Vertex outVertex = persistenceBackend.getVertex(value.id()); Edge lastPositionEdge = null; for (Edge e : outVertex.getEdges(Direction.IN, eReference.getName())) { if (Objects.equals(e.getVertex(Direction.OUT), inVertex) && (isNull(lastPositionEdge) || (int) e.getProperty(POSITION) > (int) lastPositionEdge.getProperty(POSITION))) { lastPositionEdge = e; } } if (isNull(lastPositionEdge)) { resultValue = ArrayUtils.INDEX_NOT_FOUND; } else { resultValue = lastPositionEdge.getProperty(POSITION); } } return resultValue; }
From source file:org.dice_research.topicmodeling.preprocessing.DocumentShedulerTest.java
@Test public void TestListBasedDocumentSheduler() { documentCount = 0;/*from ww w . j ava2s .c o m*/ documentsAvailable = 10000; String values[][] = new String[][] { { "2", "7", "18", "99" }, { "105", "100", "22", "1", "9" } }; @SuppressWarnings("unchecked") ListBasedDocumentSheduler sheduler = new ListBasedDocumentSheduler((DocumentSupplier) this, DocumentTracer.class, (Set<String>[]) new Set[] { new HashSet<String>(Arrays.asList(values[0])), new HashSet<String>(Arrays.asList(values[1])) }); PartialDocumentSupplier docSuppliers[] = new PartialDocumentSupplier[values.length + 1]; for (int i = 0; i < docSuppliers.length; ++i) { docSuppliers[i] = sheduler.getPartialDocumentSupplier(i); } int sum = 0; int expectedDocumentCounts[] = new int[values.length + 1]; for (int i = 0; i < values.length; ++i) { expectedDocumentCounts[i + 1] = values[i].length; sum += values[i].length; } expectedDocumentCounts[0] = documentsAvailable - sum; Document tempDoc; sum = -1; do { ++sum; tempDoc = docSuppliers[0].getNextDocument(); } while (tempDoc != null); Assert.assertEquals(expectedDocumentCounts[0], sum); int tempDocCount; for (int i = 1; i < docSuppliers.length; ++i) { tempDocCount = -1; do { ++tempDocCount; tempDoc = docSuppliers[i].getNextDocument(); if (tempDoc != null) { Assert.assertNotNull(tempDoc.getProperty(DocumentTracer.class)); Assert.assertTrue(ArrayUtils.indexOf(values[i - 1], tempDoc.getProperty(DocumentTracer.class) .getStringValue()) != ArrayUtils.INDEX_NOT_FOUND); } } while (tempDoc != null); Assert.assertEquals(expectedDocumentCounts[i], tempDocCount); sum += tempDocCount; } Assert.assertEquals(documentsAvailable, sum); }
From source file:org.midonet.netlink.rtnetlink.Link.java
@Override public void use(ByteBuffer buf, short id) { ByteOrder originalOrder = buf.order(); try {//from ww w. ja v a 2 s .co m if (!NetlinkMessage.isNested(id)) { switch (id) { case Attr.IFLA_ADDRESS: if (buf.remaining() != 6) { this.mac = null; } else { byte[] rhs = new byte[6]; buf.get(rhs); this.mac = MAC.fromAddress(rhs); } break; case Attr.IFLA_IFNAME: byte[] s = new byte[buf.remaining() - 1]; buf.get(s); this.ifname = new String(s); break; case Attr.IFLA_MASTER: if (buf.remaining() == 4) { this.masterIndex = buf.getInt(); } break; case Attr.IFLA_MTU: if (buf.remaining() != 4) { this.mtu = 0; } else { this.mtu = buf.getInt(); } break; case Attr.IFLA_LINK: if (buf.remaining() != 4) { this.link = this.ifi.index; } else { this.link = buf.getInt(); } break; case Attr.IFLA_LINKINFO: NetlinkMessage.scanNestedAttribute(buf, this); break; default: break; } } else { switch (NetlinkMessage.unnest(id)) { case NestedAttr.LinkInfo.IFLA_INFO_KIND: byte[] s = new byte[buf.remaining() - 1]; buf.get(s); // Since the longest length for the field is 7, netlink // assigns 7 bytes here, by padding with '0's to the // right int zeroIdx = ArrayUtils.indexOf(s, (byte) 0); if (zeroIdx == ArrayUtils.INDEX_NOT_FOUND) { info.kind = new String(s); } else { info.kind = new String(Arrays.copyOf(s, zeroIdx)); } break; case NestedAttr.LinkInfo.IFLA_INFO_DATA: byte[] data = new byte[buf.remaining() - 1]; buf.get(data); info.data = ByteBuffer.wrap(data); break; default: break; } } } finally { buf.order(originalOrder); } }