Package dev.relism.flash.models
Class PathParams
java.lang.Object
dev.relism.flash.models.PathParams
Path parameters captured during routing, stored as byte offsets into the path view.
get(java.lang.String) allocates a String on call (in one allocation when source is
The public constructor below builds a one-shot, fixed-size instance (used by
AbstractWsRouter and by tests) — names.length is taken as the exact param
count. FastPathRouterImpl's per-connection scratch instead owns a single long-lived
PathParams whose backing arrays are grown to the connection's high-water mark and
never reallocated after warmup; because those arrays can be larger than the current request's
actual param count, that path uses reset(dev.relism.fpr.core.ByteView, int), which — unlike the constructor — takes the
live count explicitly rather than inferring it from array length. Both this constructor and
reset(dev.relism.fpr.core.ByteView, int) are public rather than package-private (matching
Http1HeaderMap.reset(byte[], int, int)'s own precedent for a reusable buffer-backed object): the router
implementation that owns the reusable instance lives in a different package
(dev.relism.flash.routing.routers.fastpathrouter), and PathParams.inject's
own doc explains why this codebase prefers a small public surface here over a cross-package
friend-access workaround. A PathParams obtained this way has the same "do not retain
past the handler" lifetime contract as Http1HeaderMap's buffer-backed views: the next
request on the same connection repositions the same arrays.-
Constructor Summary
ConstructorsConstructorDescriptionPathParams(dev.relism.fpr.core.ByteView source, String[] names, int[] starts, int[] lens) PathParams(String[] names, int[] starts, int[] lens) Builds an instance meant only forreset(dev.relism.fpr.core.ByteView, int): no source yet, andcountstarts at 0 until the firstreset(dev.relism.fpr.core.ByteView, int)call. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidinject(Request request, PathParams params) Injects path parameters into a request.voidreset(dev.relism.fpr.core.ByteView source, int count) Repositions this instance over a new request:count(which may be less thannames.length— see the class Javadoc) params are now valid, read out of the same backing arrays the constructor was given, against the newsource.
-
Constructor Details
-
PathParams
-
PathParams
Builds an instance meant only forreset(dev.relism.fpr.core.ByteView, int): no source yet, andcountstarts at 0 until the firstreset(dev.relism.fpr.core.ByteView, int)call.names/starts/lensmay be larger than any single request's param count — see the class Javadoc.
-
-
Method Details
-
reset
public void reset(dev.relism.fpr.core.ByteView source, int count) Repositions this instance over a new request:count(which may be less thannames.length— see the class Javadoc) params are now valid, read out of the same backing arrays the constructor was given, against the newsource. Zero allocation. -
inject
Injects path parameters into a request. The cross-package bridge fromAbstractRouter— keepsRequest.setPathParams(dev.relism.flash.models.PathParams)package-private while allowing the router to set params without a public setter. -
get
-