• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Strings类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.logging.log4j.util.Strings的典型用法代码示例。如果您正苦于以下问题:Java Strings类的具体用法?Java Strings怎么用?Java Strings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Strings类属于org.apache.logging.log4j.util包,在下文中一共展示了Strings类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: ElasticBulkSender

import org.apache.logging.log4j.util.Strings; //导入依赖的package包/类
public ElasticBulkSender(String user, String password, HttpHost... hosts) {
	this.user = user;
	this.password = password;
	this.hosts = hosts;
	this.restClient = RestClient.builder(hosts)
			.setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() {
				@Override
				public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
					if (!Strings.isBlank(user)) {
						CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
						credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(user, password));
		                return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
					} else {
						return httpClientBuilder;
					}
				}
	        })
			.build();
}
 
开发者ID:magrossi,项目名称:es-log4j2-appender,代码行数:20,代码来源:ElasticBulkSender.java


示例2: startRequestSender

import org.apache.logging.log4j.util.Strings; //导入依赖的package包/类
public void startRequestSender(final String index, final long filePosition, final ActionListener<Map<String, Object>> listener) {
    if (!senderNodes.isEmpty() && !senderNodes.contains(nodeName())) {
        listener.onFailure(new ElasticsearchException(nodeName() + " is not a Sender node."));
        return;
    }

    if (logger.isDebugEnabled()) {
        logger.debug("Starting RequestSender(" + index + ")");
    }
    client.prepareGet(IndexingProxyPlugin.INDEX_NAME, IndexingProxyPlugin.TYPE_NAME, index).setRefresh(true).execute(wrap(res -> {
        if (res.isExists()) {
            final Map<String, Object> source = res.getSourceAsMap();
            final String workingNodeName = (String) source.get(IndexingProxyPlugin.NODE_NAME);
            if (!Strings.isBlank(workingNodeName) && !nodeName().equals(workingNodeName)) {
                listener.onFailure(new ElasticsearchException("RequestSender is working in " + workingNodeName));
            } else {
                final Number pos = (Number) source.get(IndexingProxyPlugin.FILE_POSITION);
                final long value = pos == null ? 1 : pos.longValue();
                launchRequestSender(index, filePosition > 0 ? filePosition : value, res.getVersion(), listener);
            }
        } else {
            launchRequestSender(index, filePosition > 0 ? filePosition : 1, 0, listener);
        }
    }, listener::onFailure));
}
 
开发者ID:codelibs,项目名称:elasticsearch-indexing-proxy,代码行数:26,代码来源:IndexingProxyService.java


示例3: exec

import org.apache.logging.log4j.util.Strings; //导入依赖的package包/类
@Override
public void exec(Plugin plugin) {
    LOGGER.traceMarker("PushProcessor", "Push tags to local");

    if (!Strings.isBlank(plugin.getPluginDetail().getImage()) && !Strings
        .isBlank(plugin.getPluginDetail().getBuild())) {
        return;
    }

    try {
        // put from cache to local git workspace
        Path cachePath = gitCachePath(plugin);
        String latestGitTag = plugin.getTag();
        JGitUtil.push(cachePath, LOCAL_REMOTE, latestGitTag);
        // set currentTag latestTag
        plugin.setCurrentTag(latestGitTag);
        updatePluginStatus(plugin, INSTALLED);
    } catch (GitException e) {
        LOGGER.error("Git Push", e);
        throw new PluginException("Git Push", e);
    }
}
 
开发者ID:FlowCI,项目名称:flow-platform,代码行数:23,代码来源:PluginServiceImpl.java


示例4: apply

import org.apache.logging.log4j.util.Strings; //导入依赖的package包/类
@Override
public void apply(final SendMessage sendMessage) {
	final ImageSendPayload imageSendPayload = sendMessage.getPayloadWithType(ImageSendPayload.class);

	final String title = imageSendPayload.getTitle();
	final String imageUrl = imageSendPayload.getImageUrl();
	final String recipient = sendMessage.getRecipient().getId();

	final SendPhoto sendPhotoTelegram = new SendPhoto(recipient, imageUrl);

	if (!Strings.isBlank(title)) {
		sendPhotoTelegram.caption(title);
	}

	LOG.info("sending image {} to recipient {}", sendPhotoTelegram, recipient);
	final TelegramBot client = provideTelegramBot(sendMessage);
	client.execute(sendPhotoTelegram);
}
 
开发者ID:nitroventures,项目名称:bot4j,代码行数:19,代码来源:ImageRuleImpl.java


示例5: sendButtonElement

import org.apache.logging.log4j.util.Strings; //导入依赖的package包/类
protected void sendButtonElement(final SendMessage sendMessage, final String recipient,
		final ListSendElement listSendElement) {
	final AbstractSendButton abstractButton = listSendElement.getButton();
	final List<InlineKeyboardButton> buttonList = new ArrayList<InlineKeyboardButton>();

	buttonList.add(telegramSendInlineKeyboardFactory.createInlineKeyboard(abstractButton));
	InlineKeyboardButton[] inlineKeyboardButtons = new InlineKeyboardButton[buttonList.size()];
	inlineKeyboardButtons = buttonList.toArray(inlineKeyboardButtons);
	final InlineKeyboardMarkup inlineKeyboardMarkup = new InlineKeyboardMarkup(inlineKeyboardButtons);

	String title = listSendElement.getTitle();

	if (Strings.isBlank(title)) {
		title = "undefined title of buttonSendPayload";
	}

	final String boldTitle = "*" + title + "*";
	final com.pengrad.telegrambot.request.SendMessage sendMessageTelegram = new com.pengrad.telegrambot.request.SendMessage(
			recipient, boldTitle).replyMarkup(inlineKeyboardMarkup).parseMode(ParseMode.Markdown);
	super.execute(sendMessage, sendMessageTelegram, recipient);
}
 
开发者ID:nitroventures,项目名称:bot4j,代码行数:22,代码来源:ListRuleImpl.java


示例6: apply

import org.apache.logging.log4j.util.Strings; //导入依赖的package包/类
@Override
public void apply(final SendMessage sendMessage) {
	final VideoSendPayload videoSendPayload = sendMessage.getPayloadWithType(VideoSendPayload.class);

	final String title = videoSendPayload.getTitle();
	final String videoUrl = videoSendPayload.getVideoUrl();
	final String recipient = sendMessage.getRecipient().getId();

	final SendVideo sendVideoTelegram = new SendVideo(recipient, videoUrl);

	if (!Strings.isBlank(title)) {
		sendVideoTelegram.caption(title);
	}

	LOG.info("sending video {} to recipient {}", sendVideoTelegram, recipient);
	final TelegramBot client = provideTelegramBot(sendMessage);
	client.execute(sendVideoTelegram);
}
 
开发者ID:nitroventures,项目名称:bot4j,代码行数:19,代码来源:VideoRuleImpl.java


示例7: apply

import org.apache.logging.log4j.util.Strings; //导入依赖的package包/类
@Override
public void apply(final SendMessage sendMessage) {
	final ButtonsSendPayload buttonsSendPayload = sendMessage.getPayloadWithType(ButtonsSendPayload.class);
	final List<InlineKeyboardButton> buttonList = new ArrayList<InlineKeyboardButton>();

	for (final AbstractSendButton button : buttonsSendPayload.getButtons()) {
		buttonList.add(telegramSendInlineKeyboardFactory.createInlineKeyboard(button));
	}

	InlineKeyboardButton[] inlineKeyboardButtons = new InlineKeyboardButton[buttonList.size()];
	inlineKeyboardButtons = buttonList.toArray(inlineKeyboardButtons);
	final InlineKeyboardMarkup inlineKeyboardMarkup = new InlineKeyboardMarkup(inlineKeyboardButtons);

	String title = buttonsSendPayload.getTitle();

	if (Strings.isBlank(title)) {
		title = "undefined title of buttonSendPayload";
	}

	final String boldTitle = "*" + title + "*";
	final String recipient = sendMessage.getRecipient().getId();

	final com.pengrad.telegrambot.request.SendMessage sendMessageTelegram = new com.pengrad.telegrambot.request.SendMessage(
			recipient, boldTitle).replyMarkup(inlineKeyboardMarkup).parseMode(ParseMode.Markdown);
	super.execute(sendMessage, sendMessageTelegram, recipient);
}
 
开发者ID:nitroventures,项目名称:bot4j,代码行数:27,代码来源:ButtonsRuleImpl.java


示例8: checkAddresseeFields

import org.apache.logging.log4j.util.Strings; //导入依赖的package包/类
private static void checkAddresseeFields(@NotNull final String sample, @NotNull final CenterData center) {
    final List<String> missingFields = Lists.newArrayList();
    if (getPI(sample, center).isEmpty()) {
        missingFields.add("PI");
    }
    if (center.addressName().isEmpty()) {
        missingFields.add("name");
    }
    if (center.addressZip().isEmpty()) {
        missingFields.add("zip");
    }
    if (center.addressCity().isEmpty()) {
        missingFields.add("city");
    }
    if (!missingFields.isEmpty()) {
        LOGGER.warn("Some address fields (" + Strings.join(missingFields, ',') + ") are missing.");
    }
}
 
开发者ID:hartwigmedical,项目名称:hmftools,代码行数:19,代码来源:CenterModel.java


示例9: canGenerateConsequenceString

import org.apache.logging.log4j.util.Strings; //导入依赖的package包/类
@Test
public void canGenerateConsequenceString() {
    final VariantAnnotation noConsequences = VariantAnnotationTest.createVariantAnnotationBuilder().build();
    assertEquals(Strings.EMPTY, noConsequences.consequenceString());

    final VariantAnnotation oneConsequence = createVariantAnnotationBuilder(VariantConsequence.MISSENSE_VARIANT).build();
    assertEquals(VariantConsequence.MISSENSE_VARIANT.readableSequenceOntologyTerm(), oneConsequence.consequenceString());

    final VariantAnnotation twoConsequences =
            createVariantAnnotationBuilder(VariantConsequence.MISSENSE_VARIANT, VariantConsequence.INFRAME_DELETION).build();
    assertTrue(twoConsequences.consequenceString().contains(VariantConsequence.MISSENSE_VARIANT.readableSequenceOntologyTerm()));
    assertTrue(twoConsequences.consequenceString().contains(VariantConsequence.INFRAME_DELETION.readableSequenceOntologyTerm()));

    final VariantAnnotation twoConsequencesIgnoreOne =
            createVariantAnnotationBuilder(VariantConsequence.MISSENSE_VARIANT, VariantConsequence.OTHER).build();
    assertEquals(VariantConsequence.MISSENSE_VARIANT.readableSequenceOntologyTerm(), twoConsequencesIgnoreOne.consequenceString());
}
 
开发者ID:hartwigmedical,项目名称:hmftools,代码行数:18,代码来源:VariantAnnotationTest.java


示例10: createVariantAnnotationBuilder

import org.apache.logging.log4j.util.Strings; //导入依赖的package包/类
@NotNull
public static ImmutableVariantAnnotation.Builder createVariantAnnotationBuilder(@NotNull VariantConsequence... consequences) {
    return ImmutableVariantAnnotation.builder()
            .allele(Strings.EMPTY)
            .severity(Strings.EMPTY)
            .gene(Strings.EMPTY)
            .geneID(Strings.EMPTY)
            .featureType(Strings.EMPTY)
            .featureID(Strings.EMPTY)
            .transcriptBioType(Strings.EMPTY)
            .rank(Strings.EMPTY)
            .hgvsCoding(Strings.EMPTY)
            .hgvsProtein(Strings.EMPTY)
            .cDNAPosAndLength(Strings.EMPTY)
            .cdsPosAndLength(Strings.EMPTY)
            .aaPosAndLength(Strings.EMPTY)
            .distance(Strings.EMPTY)
            .addition(Strings.EMPTY)
            .consequences(Lists.newArrayList(consequences));
}
 
开发者ID:hartwigmedical,项目名称:hmftools,代码行数:21,代码来源:VariantAnnotationTest.java


示例11: postToSendTransactionEthereum

import org.apache.logging.log4j.util.Strings; //导入依赖的package包/类
public static String postToSendTransactionEthereum(String url, String sender, String receiver, String amount)
        throws IOException {

    try {
        String params = String.format("{\"jsonrpc\":\"2.0\"," +
                "\"method\":\"eth_sendTransaction\",\"params\":[{\"from\":\"%s\",\"to\":\"%s\"," +
                        "\"value\":\"%s\"}],\"id\":%s}",
                sender, receiver, amount, id);
        String responseString = httpHelper.request(url, params, RequestType.POST);
        ObjectMapper mapper = new ObjectMapper();
        JsonNode responseJson = mapper.readTree(responseString);
        return responseJson.get("result").textValue();
    } catch (Exception e) {
        log.error("Cannot run post method for sending transactions in Ethereum", e);
    }

    return Strings.EMPTY;
}
 
开发者ID:dsx-tech,项目名称:blockchain-benchmarking,代码行数:19,代码来源:JSONRPCHelper.java


示例12: postToSendMessageEthereum

import org.apache.logging.log4j.util.Strings; //导入依赖的package包/类
public static String postToSendMessageEthereum(String url, String sender, String receiver, String message, String amount)
        throws IOException {
    try {
        String params = String.format("{\"jsonrpc\":\"2.0\"," +
                        "\"method\":\"eth_sendTransaction\",\"params\":[{\"from\":\"%s\",\"to\":\"%s\"," +
                        "\"value\":\"%s\", \"data\":\"%s\"}],\"id\":%s}",
                sender, receiver, amount, "0x" + Hex.encodeHexString(message.getBytes()), id);

        String responseString = httpHelper.request(url, params, RequestType.POST);
        ObjectMapper mapper = new ObjectMapper();
        JsonNode responseJson = mapper.readTree(responseString);
        return responseJson.get("result").textValue();
    } catch (Exception e) {
        log.error("Cannot run post method for sending transactions in Ethereum", e);
    }

    return Strings.EMPTY;
}
 
开发者ID:dsx-tech,项目名称:blockchain-benchmarking,代码行数:19,代码来源:JSONRPCHelper.java


示例13: findClientImpl

import org.apache.logging.log4j.util.Strings; //导入依赖的package包/类
public static Client findClientImpl(final String httpClientImpl) {
       Client client = null;
if (Strings.isEmpty(httpClientImpl)) {
    for (String s : Arrays.asList("be.olsson.slackappender.client.OkHttp2Client", "be.olsson.slackappender.client.OkHttp3Client")) {
	client = getClientImpl(s);
	if (client != null) {
	    break;
	}
    }
    if (client == null) {
	throw new IllegalArgumentException("Didn't find any working " + Client.class.getName() + " implementation called " + httpClientImpl);
    }
} else {
    client = getClientImpl(httpClientImpl);
    if (client == null) {
	throw new IllegalArgumentException("Didn't find any working " + Client.class.getName() + " implementation called " + httpClientImpl);
    }
}
return client;
   }
 
开发者ID:tobias-,项目名称:slack-appender,代码行数:21,代码来源:SlackAppender.java


示例14: getRecentHostEntries

import org.apache.logging.log4j.util.Strings; //导入依赖的package包/类
/**
 * Gets the recent host entries.
 *
 * @param maxNumItems
 *            the max num items
 * @return the recent host entries
 */
public Collection<HostEntry> getRecentHostEntries(int maxNumItems) {
	synchronized (this) {
		Collection<HostEntry> items = new LinkedList<HostEntry>();
		Iterator<TimedEntry> i = this.historyTimedSet.iterator();
		Set<String> hosts = new HashSet<String>();
		while (i.hasNext()) {
			TimedEntry entry = i.next();
			String host = entry.url.getHost();
			if (Strings.isBlank(host) && !hosts.contains(host)) {

				hosts.add(host);
				if (hosts.size() >= maxNumItems) {
					break;
				}
			
				items.add(new HostEntry(host, entry.timestamp));
			}
		}
		return items;
	}
}
 
开发者ID:oswetto,项目名称:LoboEvolution,代码行数:29,代码来源:BaseHistory.java


示例15: doCompareParseTree

import org.apache.logging.log4j.util.Strings; //导入依赖的package包/类
protected void doCompareParseTree(final File treeFile, final StartRuleContext startRule,
		final VisualBasic6Parser parser) throws IOException {

	final String treeFileData = FileUtils.readFileToString(treeFile);

	if (!Strings.isBlank(treeFileData)) {
		LOG.info("Comparing parse tree with file {}.", treeFile.getName());

		final String inputFileTree = Trees.toStringTree(startRule, parser);
		final String cleanedInputFileTree = io.proleap.vb6.util.StringUtils.cleanFileTree(inputFileTree);
		final String cleanedTreeFileData = io.proleap.vb6.util.StringUtils.cleanFileTree(treeFileData);

		assertEquals(cleanedTreeFileData, cleanedInputFileTree);
	} else {
		LOG.info("Ignoring empty parse tree file {}.", treeFile.getName());
	}
}
 
开发者ID:uwol,项目名称:vb6parser,代码行数:18,代码来源:VbParseTestRunnerImpl.java


示例16: StructuredDataId

import org.apache.logging.log4j.util.Strings; //导入依赖的package包/类
/**
 * A Constructor that helps conformance to RFC 5424.
 *
 * @param name The name portion of the id.
 * @param enterpriseNumber The enterprise number.
 * @param required The list of keys that are required for this id.
 * @param optional The list of keys that are optional for this id.
 * @param maxLength The maximum length of the StructuredData Id key.
 * @since 2.9
 */
public StructuredDataId(final String name, final int enterpriseNumber, final String[] required,
        final String[] optional, final int maxLength) {
    if (name == null) {
        throw new IllegalArgumentException("No structured id name was supplied");
    }
    if (name.contains(AT_SIGN)) {
        throw new IllegalArgumentException("Structured id name cannot contain an " + Strings.quote(AT_SIGN));
    }
    if (enterpriseNumber <= 0) {
        throw new IllegalArgumentException("No enterprise number was supplied");
    }
    this.name = name;
    this.enterpriseNumber = enterpriseNumber;
    final String id = name + AT_SIGN + enterpriseNumber;
    if (maxLength > 0 && id.length() > maxLength) {
        throw new IllegalArgumentException("Length of id exceeds maximum of " + maxLength + " characters: " + id);
    }
    this.required = required;
    this.optional = optional;
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:31,代码来源:StructuredDataId.java


示例17: testHostname

import org.apache.logging.log4j.util.Strings; //导入依赖的package包/类
@Test
public void testHostname() {
    final org.apache.logging.log4j.Logger testLogger = context.getLogger("org.apache.logging.log4j.hosttest");
    testLogger.debug("Hello, {}", "World");
    final List<String> msgs = host.getMessages();
    assertThat(msgs, hasSize(1));
    String expected = NetUtils.getLocalHostname() + Strings.LINE_SEPARATOR;
    assertThat(msgs.get(0), endsWith(expected));
    assertNotNull("No Host FileAppender file name", hostFile.getFileName());
    expected = "target/" + NetUtils.getLocalHostname() + ".log";
    String name = hostFile.getFileName();
    assertEquals("Incorrect HostFile FileAppender file name - expected " + expected + " actual - " + name, name,
        expected);
    name = hostFile.getFilePattern();
    assertNotNull("No file pattern", name);
    expected = "target/" + NetUtils.getLocalHostname() + "-%d{MM-dd-yyyy}-%i.log";
    assertEquals("Incorrect HostFile FileAppender file pattern - expected " + expected + " actual - " + name, name,
        expected);

}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:21,代码来源:HostNameTest.java


示例18: entryMsg

import org.apache.logging.log4j.util.Strings; //导入依赖的package包/类
protected EntryMessage entryMsg(final String format, final Object... params) {
    final int count = params == null ? 0 : params.length;
    if (count == 0) {
        if (Strings.isEmpty(format)) {
            return flowMessageFactory.newEntryMessage(null);
        }
        return flowMessageFactory.newEntryMessage(new SimpleMessage(format));
    }
    if (format != null) {
        return flowMessageFactory.newEntryMessage(new ParameterizedMessage(format, params));
    }
    final StringBuilder sb = new StringBuilder();
    sb.append("params(");
    for (int i = 0; i < count; i++) {
        if (i > 0) {
            sb.append(", ");
        }
        final Object parm = params[i];
        sb.append(parm instanceof Message ? ((Message) parm).getFormattedMessage() : String.valueOf(parm));
    }
    sb.append(')');
    return flowMessageFactory.newEntryMessage(new SimpleMessage(sb));
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:24,代码来源:AbstractLogger.java


示例19: pop

import org.apache.logging.log4j.util.Strings; //导入依赖的package包/类
@Override
public String pop() {
    if (!useStack) {
        return Strings.EMPTY;
    }
    final MutableThreadContextStack values = STACK.get();
    if (values == null || values.size() == 0) {
        // Like version 1.2
        return Strings.EMPTY;
    }
    final MutableThreadContextStack copy = (MutableThreadContextStack) values.copy();
    final String result = copy.pop();
    copy.freeze();
    STACK.set(copy);
    return result;
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:17,代码来源:DefaultThreadContextStack.java


示例20: testReplacement

import org.apache.logging.log4j.util.Strings; //导入依赖的package包/类
@Test
public void testReplacement() {
    logger.error(this.getClass().getName());
    List<String> msgs = app.getMessages();
    assertNotNull(msgs);
    assertEquals("Incorrect number of messages. Should be 1 is " + msgs.size(), 1, msgs.size());
    assertTrue("Replacement failed - expected ending " + EXPECTED + " Actual " + msgs.get(0),
        msgs.get(0).endsWith(EXPECTED));
    app.clear();
    ThreadContext.put("MyKey", "Apache");
    logger.error("This is a test for ${ctx:MyKey}");
    msgs = app.getMessages();
    assertNotNull(msgs);
    assertEquals("Incorrect number of messages. Should be 1 is " + msgs.size(), 1, msgs.size());
    assertEquals("LoggerTest This is a test for Apache" + Strings.LINE_SEPARATOR, msgs.get(0));
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:17,代码来源:RegexReplacementTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java INVOKEVIRTUAL类代码示例发布时间:2022-05-21
下一篇:
Java GeoApiContext类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap