Class UtilFunctions
- java.lang.Object
-
- jetbrains.buildServer.web.functions.UtilFunctions
-
public class UtilFunctions extends Object
TeamCity utility functions- Since:
- 6.0
-
-
Constructor Summary
Constructors Constructor Description UtilFunctions()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
add(List list, Object item)
Adds the specified item to the list.static boolean
contains(Collection collection, Object item)
Check whether collection contains specified item.static String
escapeFullUrl(String fullUrl)
Escapes url to be used inside quotes and ensures URL is valid, accepts only http(s):// urlsstatic String
escapeJavaScript(String text, boolean removeLineFeeds, boolean forHTMLAttribute)
escape given text to be used in javascriptstatic String
escapeJavaScriptIdentifier(String text)
escape given text to make it an javascript identifierstatic String
escapeUrlForQuotes(String url)
Escapes url to be used inside quotes using WebUtil.escapeUrlForQuotes()static int
indexOfNewLine(String data)
Returns index of new line charactersstatic int
indexOfNewLine(String data, int start, boolean useHtml)
Gets index of line separator sequence Uses either\n
char of html<br>
sequencestatic String
lineSeparator(boolean useHtml)
Gets line separator either for html or for plain textstatic String
removeTrailingSlash(String url)
Removes last slash character from the given URL.static <E> Set<E>
toSet(E[] array)
Transform the given array into a Set.static String
uniqueId()
Generate unique id.
-
-
-
Method Detail
-
escapeJavaScriptIdentifier
public static String escapeJavaScriptIdentifier(@Nullable String text)
escape given text to make it an javascript identifier- Parameters:
text
- text to escape- Returns:
- string that could be used as javascript identifier
- Since:
- 6.0
-
escapeJavaScript
public static String escapeJavaScript(@Nullable String text, boolean removeLineFeeds, boolean forHTMLAttribute)
escape given text to be used in javascript- Parameters:
text
- text to escaperemoveLineFeeds
- true to make it removing new linesforHTMLAttribute
- true if escaped text is used inside HTML element's attribute- Returns:
- string that could be used as javascript identifier
- Since:
- 6.0
-
escapeUrlForQuotes
public static String escapeUrlForQuotes(@Nullable String url)
Escapes url to be used inside quotes using WebUtil.escapeUrlForQuotes()- Parameters:
url
- the url to escape- Returns:
- escaped url
- Since:
- 7.0
- See Also:
WebUtil.escapeUrlForQuotes(String)
-
escapeFullUrl
public static String escapeFullUrl(@Nullable String fullUrl)
Escapes url to be used inside quotes and ensures URL is valid, accepts only http(s):// urls- Parameters:
url
- the url to escape- Returns:
- escaped url or null if URL is invalid
- Since:
- 2022.04
- See Also:
WebUtil#escapeFullUrl(String)
-
uniqueId
public static String uniqueId()
Generate unique id.- Returns:
- unique id withing the bounds of the server
-
add
public static void add(@NotNull List list, @NotNull Object item)
Adds the specified item to the list.- Parameters:
list
- the listitem
- the item to add
-
contains
public static boolean contains(@NotNull Collection collection, @NotNull Object item)
Check whether collection contains specified item.- Since:
- 9.0
-
indexOfNewLine
public static int indexOfNewLine(@Nullable String data)
Returns index of new line characters- Since:
- 10.0
-
indexOfNewLine
public static int indexOfNewLine(@Nullable String data, int start, boolean useHtml)
Gets index of line separator sequence Uses either\n
char of html<br>
sequence- Parameters:
data
- string to search instart
- start positionuseHtml
- switches search to html mode- Returns:
- index of line separator sequence after
start
, if there is a non-empty next line, {-1} otherwise - Since:
- 10.0 (26/10/16)
-
lineSeparator
public static String lineSeparator(boolean useHtml)
Gets line separator either for html or for plain text- Parameters:
useHtml
- flag for using html line separator- Returns:
- line separator
-
removeTrailingSlash
public static String removeTrailingSlash(@NotNull String url)
Removes last slash character from the given URL.- Returns:
- URL without the last slash character
-
toSet
public static <E> Set<E> toSet(@Nullable E[] array)
Transform the given array into a Set.- Parameters:
array
-- Returns:
- a new Set
- Since:
- 2023.11
-
-