Return a specific envelope in the block by it's index.

@param envelopeIndex the index into list.
@return envelopeIndex the index
@throws InvalidProtocolBufferException
161115
public EnvelopeInfo getEnvelopeInfo(int envelopeIndex) throws InvalidProtocolBufferException {

        try {

            EnvelopeInfo ret;

            if (isFiltered()) {

                switch (filteredBlock.getFilteredTransactions(envelopeIndex).getType().getNumber()) {
                    case Common.HeaderType.ENDORSER_TRANSACTION_VALUE:
                        ret = new TransactionEnvelopeInfo(this.filteredBlock.getFilteredTransactions(envelopeIndex));
                        break;
                    default: //just assume base properties.
                        ret = new EnvelopeInfo(this.filteredBlock.getFilteredTransactions(envelopeIndex));
                        break;
                }

            } else {

                EnvelopeDeserializer ed = EnvelopeDeserializer.newInstance(block.getBlock().getData().getData(envelopeIndex), block.getTransActionsMetaData()[envelopeIndex]);

                switch (ed.getType()) {
                    case Common.HeaderType.ENDORSER_TRANSACTION_VALUE:
                        ret = new TransactionEnvelopeInfo((EndorserTransactionEnvDeserializer) ed);
                        break;
                    default: //just assume base properties.
                        ret = new EnvelopeInfo(ed);
                        break;

                }

            }
            return ret;

        } catch (InvalidProtocolBufferRuntimeException e) {
            throw e.getCause();
        }

    }
1348337
@SuppressWarnings("unchecked")
  public <T extends Entry> T get(long index) {
    Entry entry = buffer[offset(index)];
    return entry != null && entry.getIndex() == index ? (T) entry.acquire() : null;
  }
1031331
public static <T extends Collection<?>> T validIndex(final T collection, final int index, final String message) {
        return INSTANCE.validIndex(collection, index, message);
    }
137121
public int indexOf(final OIdentifiable iElement) {
		if (delegate.isEmpty())
			return -1;

		final boolean prevConvert = delegate.isAutoConvertToRecord();
		if (prevConvert)
			delegate.setAutoConvertToRecord(false);

		final int pos = Collections.binarySearch(delegate, iElement);

		if (prevConvert)
			// RESET PREVIOUS SETTINGS
			delegate.setAutoConvertToRecord(true);

		return pos;
	}
102366
public static function createNotMerged(Envelope $envelope, \Exception $e = null)
    {
        $message = 'The given DigiDoc envelope must be merged with Api (using Api::merge) before calling this method.';

        return new static($message, null, $e);
    }
1143446
public int columnIndex(final int _tableIndex, final String _columnName)
    {
        final Optional<Column> colOpt = getColumns().stream()
                        .filter(column -> column.tableIndex == _tableIndex && column.columnName.equals(_columnName))
                        .findFirst();
        final int ret;
        if (colOpt.isPresent()) {
            ret = getColumns().indexOf(colOpt.get());
        } else {
            columns.add(new Column(tablePrefix, _tableIndex, _columnName));
            ret = getColumnIdx();
        }
        return ret;
    }
1153299
@Override
	@Pure
	public RoadPolyline getMapElementAt(int index) {
		final Iterator<RoadSegment> segments = this.roadNetwork.iterator();
		for (int i = 0; i < index - 1 && segments.hasNext(); ++i) {
			segments.next();
		}
		if (segments.hasNext()) {
			return (RoadPolyline) segments.next();
		}
		throw new IndexOutOfBoundsException();
	}
546188
public Envelope tileBbox(int tx, int ty, int zoomLevel) {
        Coordinate topLeft = tileTopLeft(tx, ty, zoomLevel);
        // upperLeft of tx+1,ty+1 == lowRight
        Coordinate lowerRight = tileTopLeft(tx + 1, ty + 1, zoomLevel);
        Envelope result = new Envelope(topLeft, lowerRight);
        return result;
    }
463625
protected User safeGetRecipient(MessageEnvelope envelope) {
		if (envelope != null && envelope.getRecipient() != null
				&& envelope.getRecipient().getId() != null) {
			return envelope.getRecipient();
		}
		return new User();
	}
425708
public static Bbox fromJts(Envelope envelope) throws JtsConversionException {
		if (envelope == null) {
			throw new  JtsConversionException("Cannot convert null argument");
		}
		return new Bbox(envelope.getMinX(), envelope.getMinY(), envelope.getWidth(), envelope.getHeight());
	}
947842
private void processEnvelope(Envelope envelope) {

        ActorScope scope = envelope.getScope();

        if (actorSystem.getTraceInterface() != null) {
            actorSystem.getTraceInterface().onEnvelopeDelivered(envelope);
        }

        long start = ActorTime.currentTime();
        if (scope.getActor() == null) {

            if (envelope.getMessage() == PoisonPill.INSTANCE) {
                // Not creating actor for PoisonPill
                return;
            }

            try {
                Actor actor = scope.getProps().create();
                actor.initActor(scope.getPath(), new ActorContext(scope), scope.getMailbox());
                ThreadDispatcher.pushDispatcher(actor.getDispatcher());
                try {
                    actor.preStart();
                } finally {
                    ThreadDispatcher.popDispatcher();
                }

                scope.onActorCreated(actor);
            } catch (Exception e) {
                e.printStackTrace();
                if (envelope.getSender() != null) {
                    envelope.getSender().send(new DeadLetter("Unable to create actor"));
                }
                return;
            }
        }

        try {
            if (envelope.getMessage() == StartActor.INSTANCE) {
                // Already created actor
            } else if (envelope.getMessage() == PoisonPill.INSTANCE) {
                ThreadDispatcher.pushDispatcher(scope.getActor().getDispatcher());
                try {
                    scope.getActor().postStop();
                } finally {
                    ThreadDispatcher.popDispatcher();
                }
                onActorDie(scope);
            } else {
                scope.getActor().handleMessage(envelope.getMessage(), envelope.getSender());
            }
        } catch (Exception e) {
            if (actorSystem.getTraceInterface() != null) {
                actorSystem.getTraceInterface().onActorDie(scope.getActorRef(), envelope, e);
            }
            ThreadDispatcher.pushDispatcher(scope.getActor().getDispatcher());
            try {
                scope.getActor().postStop();
            } finally {
                ThreadDispatcher.popDispatcher();
            }
            onActorDie(scope);
        } finally {
            if (actorSystem.getTraceInterface() != null) {
                actorSystem.getTraceInterface().onEnvelopeProcessed(envelope, ActorTime.currentTime() - start);
            }
        }
    }
1051870
private function getSenders(Envelope $envelope, &$handle, ?RedeliveryStamp $redeliveryStamp): iterable
    {
        if (null !== $redeliveryStamp) {
            return [
                $redeliveryStamp->getSenderClassOrAlias() => $this->sendersLocator->getSenderByAlias($redeliveryStamp->getSenderClassOrAlias()),
            ];
        }

        return $this->sendersLocator->getSenders($envelope, $handle);
    }
1327024
Envelope2D getExtent(int quad_handle) {
		Envelope2D quad_extent = new Envelope2D();
		quad_extent.setCoords(m_extent);

		if (quad_handle == m_root)
			return quad_extent;

		AttributeStreamOfInt32 quadrants = new AttributeStreamOfInt32(0);

		int q = quad_handle;

		do {
			quadrants.add(get_quadrant_(q));
			q = get_parent_(q);

		} while (q != m_root);

		int sz = quadrants.size();
		assert (sz == getHeight(quad_handle));

		for (int i = 0; i < sz; i++) {
			int child = quadrants.getLast();
			quadrants.removeLast();

			if (child == 0) {//northeast
				quad_extent.xmin = 0.5 * (quad_extent.xmin + quad_extent.xmax);
				quad_extent.ymin = 0.5 * (quad_extent.ymin + quad_extent.ymax);
			} else if (child == 1) {//northwest
				quad_extent.xmax = 0.5 * (quad_extent.xmin + quad_extent.xmax);
				quad_extent.ymin = 0.5 * (quad_extent.ymin + quad_extent.ymax);
			} else if (child == 2) {//southwest
				quad_extent.xmax = 0.5 * (quad_extent.xmin + quad_extent.xmax);
				quad_extent.ymax = 0.5 * (quad_extent.ymin + quad_extent.ymax);
			} else {//southeast
				quad_extent.xmin = 0.5 * (quad_extent.xmin + quad_extent.xmax);
				quad_extent.ymax = 0.5 * (quad_extent.ymin + quad_extent.ymax);
			}
		}

		return quad_extent;
	}
430792
public Envelope toInternal(Bbox bbox) {
		return new Envelope(bbox.getX(), bbox.getMaxX(), bbox.getY(), bbox.getMaxY());
	}
1134826
public List<? extends Element> getMemberList(Character index) {
        SortedSet<Element> set = indexmap.get(index);
        if (set == null)
            return null;
        List<Element> out = new ArrayList<>();
        out.addAll(set);
        return out;
    }
180516
public static List<LasLevel> getLasLevels( ASpatialDb db, int levelNum, Envelope envelope ) throws Exception {
        String tableName = TABLENAME + levelNum;
        List<LasLevel> lasLevels = new ArrayList<>();
        String sql = "SELECT " + COLUMN_GEOM + "," + //
                COLUMN_ID + "," + COLUMN_SOURCE_ID + "," + COLUMN_AVG_ELEV + "," + //
                COLUMN_MIN_ELEV + "," + //
                COLUMN_MAX_ELEV + "," + //
                COLUMN_AVG_INTENSITY + "," + //
                COLUMN_MIN_INTENSITY + "," + //
                COLUMN_MAX_INTENSITY;

        sql += " FROM " + tableName;

        if (envelope != null) {
            double x1 = envelope.getMinX();
            double y1 = envelope.getMinY();
            double x2 = envelope.getMaxX();
            double y2 = envelope.getMaxY();
            sql += " WHERE " + db.getSpatialindexBBoxWherePiece(tableName, null, x1, y1, x2, y2);
        }

        String _sql = sql;
        IGeometryParser gp = db.getType().getGeometryParser();
        return db.execOnConnection(conn -> {
            try (IHMStatement stmt = conn.createStatement(); IHMResultSet rs = stmt.executeQuery(_sql)) {
                while( rs.next() ) {
                    LasLevel lasLevel = new LasLevel();
                    lasLevel.level = levelNum;
                    int i = 1;
                    Geometry geometry = gp.fromResultSet(rs, i++);
                    if (geometry instanceof Polygon) {
                        Polygon polygon = (Polygon) geometry;
                        lasLevel.polygon = polygon;
                        lasLevel.id = rs.getLong(i++);
                        lasLevel.sourceId = rs.getLong(i++);
                        lasLevel.avgElev = rs.getDouble(i++);
                        lasLevel.minElev = rs.getDouble(i++);
                        lasLevel.maxElev = rs.getDouble(i++);
                        lasLevel.avgIntensity = rs.getShort(i++);
                        lasLevel.minIntensity = rs.getShort(i++);
                        lasLevel.maxIntensity = rs.getShort(i++);
                        lasLevels.add(lasLevel);
                    }
                }
                return lasLevels;
            }
        });

    }
1203612
protected final int getIndex(long stamp)
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(this, tc, "getIndex", Long.valueOf(stamp));

    int first = 0;
    int last = blockVector.size();

    int index = linearSearch(stamp, first, last - 1);
    
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "getIndex", index);

    return index;
  }