Package io.jenkins.blueocean.preload
Class BlueUrlTokenizer
- java.lang.Object
-
- io.jenkins.blueocean.preload.BlueUrlTokenizer
-
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public class BlueUrlTokenizer extends Object
General purpose Blue Ocean UI URL parser.This class performs a "best effort" attempt to parse a URL as a Blue Ocean URL, extracting what it thinks are the relevant "parts" and making available via the
getPart(UrlPart)
andhasPart(UrlPart)
functions.See TBD comment on
BlueUrlTokenizer.UrlPart
.- Author:
- tom.fennelly@gmail.com
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
BlueUrlTokenizer.UrlPart
Enum of URL "parts".
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description BlueUrlTokenizer.UrlPart
getLastPart()
Get the lastBlueUrlTokenizer.UrlPart
for the URL.String
getPart(BlueUrlTokenizer.UrlPart urlPart)
boolean
hasPart(BlueUrlTokenizer.UrlPart urlPart)
boolean
lastPartIs(BlueUrlTokenizer.UrlPart urlPart)
boolean
lastPartIs(BlueUrlTokenizer.UrlPart urlPart, String value)
static BlueUrlTokenizer
parse(String url)
Parse the supplied URL string and return aBlueUrlTokenizer
instance iff the URL is a Blue Ocean UI URL.static BlueUrlTokenizer
parseCurrentRequest()
Parse thecurrent Stapler request
and return aBlueUrlTokenizer
instance iff the URL is a Blue Ocean UI URL.
-
-
-
Method Detail
-
parseCurrentRequest
@CheckForNull public static BlueUrlTokenizer parseCurrentRequest() throws IllegalStateException
Parse thecurrent Stapler request
and return aBlueUrlTokenizer
instance iff the URL is a Blue Ocean UI URL.- Returns:
- A
BlueUrlTokenizer
instance iff the URL is a Blue Ocean UI URL, otherwisenull
. - Throws:
IllegalStateException
- Called outside the scope of an activeStaplerRequest
.
-
parse
@CheckForNull public static BlueUrlTokenizer parse(@NonNull String url)
Parse the supplied URL string and return aBlueUrlTokenizer
instance iff the URL is a Blue Ocean UI URL.- Parameters:
url
- The URL to be parsed. The URL must not be decoded in any way, so as to ensure that no URL component data is lost.- Returns:
- A
BlueUrlTokenizer
instance iff the URL is a Blue Ocean UI URL, otherwisenull
.
-
hasPart
public boolean hasPart(@NonNull BlueUrlTokenizer.UrlPart urlPart)
-
getPart
@CheckForNull public String getPart(@NonNull BlueUrlTokenizer.UrlPart urlPart)
-
getLastPart
@CheckForNull public BlueUrlTokenizer.UrlPart getLastPart()
Get the lastBlueUrlTokenizer.UrlPart
for the URL.- Returns:
- The last
BlueUrlTokenizer.UrlPart
for the URL.
-
lastPartIs
public boolean lastPartIs(@NonNull BlueUrlTokenizer.UrlPart urlPart)
-
lastPartIs
public boolean lastPartIs(@NonNull BlueUrlTokenizer.UrlPart urlPart, @NonNull String value)
-
-