当前位置: 首页>>代码示例>>Java>>正文


Java StringUtil类代码示例

本文整理汇总了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);
            }
        }
    }
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:31,代码来源:BeyondJWebAppClassLoader.java

示例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();
}
 
开发者ID:vespa-engine,项目名称:vespa,代码行数:21,代码来源:ErrorResponseContentCreator.java

示例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);
        }
    });
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:22,代码来源:DefaultBulkApiClient.java

示例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);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:DefaultBulkApiClient.java

示例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());
	});
}
 
开发者ID:sarxos,项目名称:ryzom-network-client,代码行数:31,代码来源:Lv20Client.java

示例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());
	});
}
 
开发者ID:sarxos,项目名称:ryzom-network-client,代码行数:27,代码来源:Lv20Client.java

示例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();
}
 
开发者ID:Athou,项目名称:commafeed,代码行数:20,代码来源:SecurityCheckFactory.java

示例8: getCharacterEncoding

import org.eclipse.jetty.util.StringUtil; //导入依赖的package包/类
@Override
public String getCharacterEncoding()
{
    if (_characterEncoding == null)
        _characterEncoding = StringUtil.__ISO_8859_1;
    return _characterEncoding;
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:8,代码来源:Response.java

示例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:
                }
            }
        }
    }
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:39,代码来源:Response.java

示例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();
    }
}
 
开发者ID:Comcast,项目名称:redirector,代码行数:10,代码来源:E2EConfigLoader.java

示例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);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:11,代码来源:DefaultRestClient.java

示例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);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:14,代码来源:DefaultAnalyticsApiClient.java

示例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;
}
 
开发者ID:gaelblondelle,项目名称:PSysRoverInitialContrib,代码行数:14,代码来源:JsonRpcRequest.java

示例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);
}
 
开发者ID:AusDTO,项目名称:citizenship-appointment-server,代码行数:16,代码来源:LoginClientService.java

示例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();
}
 
开发者ID:itead,项目名称:IoTgo_Android_App,代码行数:9,代码来源:WebSocketConnectionRFC6455.java


注:本文中的org.eclipse.jetty.util.StringUtil类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。