public class Util extends Object
| Constructor and Description |
|---|
Util() |
| Modifier and Type | Method and Description |
|---|---|
static String |
base64Encode(String plainTextString)
Encodes a string using Base64 encoding.
|
static long |
copyStream(InputStream input,
OutputStream output,
boolean closeStreams)
Copies one stream to another, optionally closing the streams.
|
static void |
ensureEndsWithSlash(StringBuilder str)
Given a string builder, this ensures its last character is a forward-slash.
|
static <T> T |
fromJson(Reader in,
com.fasterxml.jackson.core.type.TypeReference<T> typeReference) |
static <T> T |
fromJson(String json,
Class<T> clazz) |
static StringBuilder |
getContextUrlString(String baseUrl,
String context)
Given a base URL (like 'http://localhost:8080') this will append the given context string to it and will return
the URL with a forward-slash as its last character.
|
static MonitorServiceConfiguration |
getMonitorServiceConfiguration(org.jboss.as.controller.OperationContext context)
Used by extension classes that need to get the subsystem's configuration.
|
static String |
getSystemId()
Tries to determine the system ID for the machine where this JVM is located.
|
static String |
read(File file)
|
static void |
registerOnlyRestartAttributes(org.jboss.as.controller.registry.ManagementResourceRegistration resourceRegistration,
Collection<org.jboss.as.controller.AttributeDefinition> allAttributes)
This will register only those given attributes that require a restart.
|
static String |
slurpStream(InputStream input,
String encoding)
Given an input stream, its data will be slurped in memory and returned as a String.
|
static String |
toJson(Object obj) |
static String |
urlEncode(String str)
Encodes the given string so it can be placed inside a URL.
|
static String |
urlEncodeQuery(String str)
Encodes the given string so it can be placed inside a URL.
|
static void |
write(String string,
File file)
|
public static <T> T fromJson(Reader in, com.fasterxml.jackson.core.type.TypeReference<T> typeReference)
public static String urlEncode(String str)
urlEncodeQuery(String).str - non-query string to encodepublic static String urlEncodeQuery(String str)
urlEncode(String).str - non-query string to encodepublic static StringBuilder getContextUrlString(String baseUrl, String context) throws MalformedURLException
baseUrl - base URL to append the given context tocontext - the context to add to the given base URLMalformedURLException - if URL cannot be builtpublic static void ensureEndsWithSlash(StringBuilder str)
str - string builder to have a forward-slash character as its last when this method returnspublic static long copyStream(InputStream input, OutputStream output, boolean closeStreams) throws RuntimeException
input - the data to copyoutput - where to copy the datacloseStreams - if true input and output will be closed when the method returnsRuntimeException - if the copy failedpublic static String slurpStream(InputStream input, String encoding) throws IOException
input - the input stream to slupthe - encoding to use when reading from inputIOException - in IO problemspublic static String read(File file) throws IOException
file - the File to read fromfileIOException - in IO problemspublic static void write(String string, File file) throws IOException
string - the String to storefile - the file to store toIOException - on IO errorspublic static String base64Encode(String plainTextString)
plainTextString - the string to encodepublic static void registerOnlyRestartAttributes(org.jboss.as.controller.registry.ManagementResourceRegistration resourceRegistration,
Collection<org.jboss.as.controller.AttributeDefinition> allAttributes)
resourceRegistration - there the restart attributes will be registeredallAttributes - a collection of attributes where some, all, or none will require a restart upon change.public static MonitorServiceConfiguration getMonitorServiceConfiguration(org.jboss.as.controller.OperationContext context) throws org.jboss.as.controller.OperationFailedException
context - context used to obtain the configorg.jboss.as.controller.OperationFailedExceptionpublic static String getSystemId()
Copyright © 2015–2017 Red Hat, Inc.. All rights reserved.