100
100
import java .io .PrintWriter ;
101
101
import java .io .Serializable ;
102
102
import java .io .StringWriter ;
103
- import java .io .UnsupportedEncodingException ;
104
103
import java .lang .management .LockInfo ;
105
104
import java .lang .management .ManagementFactory ;
106
105
import java .lang .management .MonitorInfo ;
@@ -747,10 +746,7 @@ public static String appendSpaceIfNotNull(String n) {
747
746
public static String nbspIndent (String size ) {
748
747
int i = size .indexOf ('x' );
749
748
i = Integer .parseInt (i > 0 ? size .substring (0 , i ) : size ) / 10 ;
750
- StringBuilder buf = new StringBuilder (30 );
751
- for (int j = 2 ; j <= i ; j ++)
752
- buf .append (" " );
753
- return buf .toString ();
749
+ return " " .repeat (Math .max (0 , i - 1 ));
754
750
}
755
751
756
752
public static String getWin32ErrorMessage (IOException e ) {
@@ -777,11 +773,7 @@ public static String urlEncode(String s) {
777
773
if (s == null ) {
778
774
return "" ;
779
775
}
780
- try {
781
- return URLEncoder .encode (s , StandardCharsets .UTF_8 .name ());
782
- } catch (UnsupportedEncodingException e ) {
783
- throw new Error (e ); // impossible
784
- }
776
+ return URLEncoder .encode (s , StandardCharsets .UTF_8 );
785
777
}
786
778
787
779
public static String escape (String s ) {
@@ -1933,19 +1925,19 @@ public void calcCheckUrl(Map attributes, String userDefined, Object descriptor,
1933
1925
*
1934
1926
* Used in {@code task.jelly} to decide if the page should be highlighted.
1935
1927
*/
1936
- public boolean hyperlinkMatchesCurrentPage (String href ) throws UnsupportedEncodingException {
1928
+ public boolean hyperlinkMatchesCurrentPage (String href ) {
1937
1929
String url = Stapler .getCurrentRequest ().getRequestURL ().toString ();
1938
1930
if (href == null || href .length () <= 1 ) return "." .equals (href ) && url .endsWith ("/" );
1939
- url = URLDecoder .decode (url , "UTF-8" );
1940
- href = URLDecoder .decode (href , "UTF-8" );
1931
+ url = URLDecoder .decode (url , StandardCharsets . UTF_8 );
1932
+ href = URLDecoder .decode (href , StandardCharsets . UTF_8 );
1941
1933
if (url .endsWith ("/" )) url = url .substring (0 , url .length () - 1 );
1942
1934
if (href .endsWith ("/" )) href = href .substring (0 , href .length () - 1 );
1943
1935
1944
1936
return url .endsWith (href );
1945
1937
}
1946
1938
1947
1939
public <T > List <T > singletonList (T t ) {
1948
- return Collections . singletonList (t );
1940
+ return List . of (t );
1949
1941
}
1950
1942
1951
1943
/**
0 commit comments