本文整理汇总了Java中org.eclipse.jetty.util.StringUtil类的典型用法代码示例。如果您正苦于以下问题:Java StringUtil类的具体用法?Java StringUtil怎么用?Java StringUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StringUtil类属于org.eclipse.jetty.util包,在下文中一共展示了StringUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addJars
import org.eclipse.jetty.util.StringUtil; //导入依赖的package包/类
/**
* Add elements to the class path for the context from the jar and zip files found
* in the specified resource.
*
* @param resource the resource that contains the jar and/or zip files.
*/
public void addJars(Resource resource) {
if (resource.exists() && resource.isDirectory()) {
String[] files = resource.list();
for (int f = 0; files != null && f < files.length; f++) {
try {
Resource fn = resource.addPath(files[f]);
String fnlc = fn.getName().toLowerCase(Locale.ENGLISH);
// don't check if this is a directory, see Bug 353165
if (isFileSupported(fnlc)) {
String name = fn.toString();
name = StringUtil.replace(name, ",", "%2C");
name = StringUtil.replace(name, ";", "%3B");
addClassPath(name);
List<Class<?>> classes = getClassesInJar(name);
for (Class<?> clazz : classes) {
knownClasses.put(clazz.getName(), clazz);
}
}
} catch (Exception ex) {
LOG.error(String.format("Exception adding classpath entry from resource %s", resource.getName()), ex);
}
}
}
}
示例2: createErrorContent
import org.eclipse.jetty.util.StringUtil; //导入依赖的package包/类
public byte[] createErrorContent(String requestUri, int statusCode, Optional<String> message) {
String sanitizedString = message.map(StringUtil::sanitizeXmlString).orElse("");
String statusCodeString = Integer.toString(statusCode);
writer.resetWriter();
try {
writer.write("<html>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html;charset=ISO-8859-1\"/>\n<title>Error ");
writer.write(statusCodeString);
writer.write("</title>\n</head>\n<body>\n<h2>HTTP ERROR: ");
writer.write(statusCodeString);
writer.write("</h2>\n<p>Problem accessing ");
writer.write(StringUtil.sanitizeXmlString(requestUri));
writer.write(". Reason:\n<pre> ");
writer.write(sanitizedString);
writer.write("</pre></p>\n<hr/>\n</body>\n</html>\n");
} catch (IOException e) {
// IOException should not be thrown unless writer is constructed using byte[] parameter
throw new RuntimeException(e);
}
return writer.getByteArray();
}
示例3: createBatch
import org.eclipse.jetty.util.StringUtil; //导入依赖的package包/类
@Override
public void createBatch(InputStream batchStream, String jobId, ContentType contentTypeEnum,
final BatchInfoResponseCallback callback) {
final Request post = getRequest(HttpMethod.POST, batchUrl(jobId, null));
post.content(new InputStreamContentProvider(batchStream));
post.header(HttpHeader.CONTENT_TYPE, getContentType(contentTypeEnum) + ";charset=" + StringUtil.__UTF8);
// make the call and parse the result
doHttpRequest(post, new ClientResponseCallback() {
@Override
public void onResponse(InputStream response, SalesforceException ex) {
BatchInfo value = null;
try {
value = unmarshalResponse(response, post, BatchInfo.class);
} catch (SalesforceException e) {
ex = e;
}
callback.onResponse(value, ex);
}
});
}
示例4: doHttpRequest
import org.eclipse.jetty.util.StringUtil; //导入依赖的package包/类
@Override
protected void doHttpRequest(Request request, ClientResponseCallback callback) {
// set access token for all requests
setAccessToken(request);
// set default charset
request.header(HttpHeader.ACCEPT_CHARSET, StringUtil.__UTF8);
// TODO check if this is really needed or not, since SF response content type seems fixed
// check if the default accept content type must be used
if (!request.getHeaders().contains(HttpHeader.ACCEPT)) {
final String contentType = getContentType(DEFAULT_ACCEPT_TYPE);
request.header(HttpHeader.ACCEPT, contentType);
// request content type and charset is set by the request entity
}
super.doHttpRequest(request, callback);
}
示例5: tell
import org.eclipse.jetty.util.StringUtil; //导入依赖的package包/类
/**
* Send private tell message to the given toon.
*
* @param who the toon name
* @param text the message content
*/
public void tell(String who, String text) {
if (who == null) {
throw new IllegalArgumentException("Toon name must not be null!");
}
if (text == null) {
throw new IllegalArgumentException("Text to be send must not be null!");
}
// ignore blank text messages (the blank messages are the ones that consist of the
// whitespace characters only)
if (StringUtil.isBlank(text)) {
return;
}
if (!wsSocket.isRyzomUserLoggedIn()) {
throw new IllegalStateException("Cannot send tell because user is not logged in");
}
executor.execute((Runnable) () -> {
wsSocket.msgMethodChat(Lv20Socket.CHAT_TELL, who.trim() + " " + text.trim());
});
}
示例6: send
import org.eclipse.jetty.util.StringUtil; //导入依赖的package包/类
/**
* Send message to the given chat.
*
* @param chat the chat type
* @param text the message content
*/
public void send(Chat chat, String text) {
if (chat == null) {
throw new IllegalArgumentException("Chat type must not be null!");
}
if (text == null) {
throw new IllegalArgumentException("Text to be send must not be null!");
}
// ignore blank text messages (the blank messages are the ones that consist of the
// whitespace characters only)
if (StringUtil.isBlank(text)) {
return;
}
executor.execute((Runnable) () -> {
wsSocket.msgMethodChat(chat.getId(), text.trim());
});
}
示例7: basicAuthenticationLogin
import org.eclipse.jetty.util.StringUtil; //导入依赖的package包/类
private Optional<User> basicAuthenticationLogin() {
String header = request.getHeader(HttpHeaders.AUTHORIZATION);
if (header != null) {
int space = header.indexOf(' ');
if (space > 0) {
String method = header.substring(0, space);
if (PREFIX.equalsIgnoreCase(method)) {
String decoded = B64Code.decode(header.substring(space + 1), StringUtil.__ISO_8859_1);
int i = decoded.indexOf(':');
if (i > 0) {
String username = decoded.substring(0, i);
String password = decoded.substring(i + 1);
return userService.login(username, password);
}
}
}
}
return Optional.empty();
}
示例8: getCharacterEncoding
import org.eclipse.jetty.util.StringUtil; //导入依赖的package包/类
@Override
public String getCharacterEncoding()
{
if (_characterEncoding == null)
_characterEncoding = StringUtil.__ISO_8859_1;
return _characterEncoding;
}
示例9: reset
import org.eclipse.jetty.util.StringUtil; //导入依赖的package包/类
@Override
public void reset()
{
resetForForward();
_status = 200;
_reason = null;
_contentLength = -1;
_fields.clear();
String connection = _channel.getRequest().getHeader(HttpHeader.CONNECTION.asString());
if (connection != null)
{
for (String value: StringUtil.csvSplit(null,connection,0,connection.length()))
{
HttpHeaderValue cb = HttpHeaderValue.CACHE.get(value);
if (cb != null)
{
switch (cb)
{
case CLOSE:
_fields.put(HttpHeader.CONNECTION, HttpHeaderValue.CLOSE.toString());
break;
case KEEP_ALIVE:
if (HttpVersion.HTTP_1_0.is(_channel.getRequest().getProtocol()))
_fields.put(HttpHeader.CONNECTION, HttpHeaderValue.KEEP_ALIVE.toString());
break;
case TE:
_fields.put(HttpHeader.CONNECTION, HttpHeaderValue.TE.toString());
break;
default:
}
}
}
}
}
示例10: getExtraTestsClasses
import org.eclipse.jetty.util.StringUtil; //导入依赖的package包/类
@Override
public List<String> getExtraTestsClasses() {
String extraTests = config.getString("e2e.extraTests");
if (StringUtil.isNotBlank(extraTests)) {
return Arrays.asList(extraTests.split(EXTRA_TESTS_CLASSES_NAMES_DELIMETER));
} else {
return Collections.emptyList();
}
}
示例11: doHttpRequest
import org.eclipse.jetty.util.StringUtil; //导入依赖的package包/类
@Override
protected void doHttpRequest(Request request, ClientResponseCallback callback) {
// set standard headers for all requests
final String contentType = PayloadFormat.JSON.equals(format) ? APPLICATION_JSON_UTF8 : APPLICATION_XML_UTF8;
request.header(HttpHeader.ACCEPT, contentType);
request.header(HttpHeader.ACCEPT_CHARSET, StringUtil.__UTF8);
// request content type and charset is set by the request entity
super.doHttpRequest(request, callback);
}
示例12: doHttpRequest
import org.eclipse.jetty.util.StringUtil; //导入依赖的package包/类
@Override
protected void doHttpRequest(Request request, ClientResponseCallback callback) {
// set access token for all requests
setAccessToken(request);
// set request and response content type and charset, which is always JSON for analytics API
request.header(HttpHeader.CONTENT_TYPE, APPLICATION_JSON_UTF8);
request.header(HttpHeader.ACCEPT, APPLICATION_JSON_UTF8);
request.header(HttpHeader.ACCEPT_CHARSET, StringUtil.__UTF8);
super.doHttpRequest(request, callback);
}
示例13: validate
import org.eclipse.jetty.util.StringUtil; //导入依赖的package包/类
public Map<String, String> validate() {
Map<String, String> result = new HashMap<String, String>();
if (!JsonRpcSocket.JSON_RPC_VERSION.equals(jsonrpc)) {
result.put("jsonrpc", "Invalid version: " + jsonrpc);
}
if (StringUtil.isBlank(method)) {
result.put("method", "No method provided");
}
return result;
}
示例14: parseGetCustomerByClientIdResponse
import org.eclipse.jetty.util.StringUtil; //导入依赖的package包/类
private Client parseGetCustomerByClientIdResponse(ResponseWrapper response) {
String clientId = response.getStringAttribute(GetClientByPersonalId.CUSTOMER_CLIENT_ID);
String lastName = response.getStringAttribute(GetClientByPersonalId.CUSTOMER_LAST_NAME);
String customerId = response.getStringAttribute(GetClientByPersonalId.CUSTOMER_ID);
boolean hasEmail = StringUtil.isNotBlank(response.getStringAttribute(GetClientByPersonalId.CUSTOMER_EMAIL));
boolean hasMobile = StringUtil.isNotBlank(response.getStringAttribute(GetClientByPersonalId.CUSTOMER_TELEPHONE1));
boolean isActive = "true".equals(response.getStringAttribute(GetClientByPersonalId.CUSTOMER_ACTIVE));
ResponseWrapper customPropertiesResponse = getCustomPropertiesResponse(customerId);
ServiceDetails serviceDetails = getServiceDetails(customPropertiesResponse, customerId);
String appointmentTypeId = getAppointmentTypeId(customPropertiesResponse, customerId);
checkUserConfiguredCorrectly(serviceDetails, appointmentTypeId);
return new Client(clientId, lastName, customerId, hasEmail, hasMobile, serviceDetails.getUnitId(), serviceDetails.getServiceId(), appointmentTypeId, isActive);
}
示例15: sendMessage
import org.eclipse.jetty.util.StringUtil; //导入依赖的package包/类
public void sendMessage(String content) throws IOException
{
if (_closedOut)
throw new IOException("closedOut "+_closeCode+":"+_closeMessage);
byte[] data = content.getBytes(StringUtil.__UTF8);
_outbound.addFrame((byte)FLAG_FIN,WebSocketConnectionRFC6455.OP_TEXT,data,0,data.length);
checkWriteable();
}