本文整理汇总了Java中org.apache.logging.log4j.util.Strings.isNotEmpty方法的典型用法代码示例。如果您正苦于以下问题:Java Strings.isNotEmpty方法的具体用法?Java Strings.isNotEmpty怎么用?Java Strings.isNotEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.logging.log4j.util.Strings
的用法示例。
在下文中一共展示了Strings.isNotEmpty方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toWriteConcern
import org.apache.logging.log4j.util.Strings; //导入方法依赖的package包/类
private static WriteConcern toWriteConcern(final String writeConcernConstant,
final String writeConcernConstantClassName) {
WriteConcern writeConcern;
if (Strings.isNotEmpty(writeConcernConstant)) {
if (Strings.isNotEmpty(writeConcernConstantClassName)) {
try {
final Class<?> writeConcernConstantClass = LoaderUtil.loadClass(writeConcernConstantClassName);
final Field field = writeConcernConstantClass.getField(writeConcernConstant);
writeConcern = (WriteConcern) field.get(null);
} catch (final Exception e) {
LOGGER.error("Write concern constant [{}.{}] not found, using default.",
writeConcernConstantClassName, writeConcernConstant);
writeConcern = DEFAULT_WRITE_CONCERN;
}
} else {
writeConcern = WriteConcern.valueOf(writeConcernConstant);
if (writeConcern == null) {
LOGGER.warn("Write concern constant [{}] not found, using default.", writeConcernConstant);
writeConcern = DEFAULT_WRITE_CONCERN;
}
}
} else {
writeConcern = DEFAULT_WRITE_CONCERN;
}
return writeConcern;
}
示例2: toWriteConcern
import org.apache.logging.log4j.util.Strings; //导入方法依赖的package包/类
private static WriteConcern toWriteConcern(final String writeConcernConstant,
final String writeConcernConstantClassName) {
WriteConcern writeConcern;
if (Strings.isNotEmpty(writeConcernConstant)) {
if (Strings.isNotEmpty(writeConcernConstantClassName)) {
try {
final Class<?> writeConcernConstantClass = LoaderUtil.loadClass(writeConcernConstantClassName);
final Field field = writeConcernConstantClass.getField(writeConcernConstant);
writeConcern = (WriteConcern) field.get(null);
} catch (final Exception e) {
LOGGER.error("Write concern constant [{}.{}] not found, using default.",
writeConcernConstantClassName, writeConcernConstant);
writeConcern = DEFAULT_WRITE_CONCERN;
}
} else {
writeConcern = WriteConcern.valueOf(writeConcernConstant);
if (writeConcern == null) {
LOGGER.warn("Write concern constant [{}] not found, using default.", writeConcernConstant);
writeConcern = DEFAULT_WRITE_CONCERN;
}
}
} else {
writeConcern = DEFAULT_WRITE_CONCERN;
}
return writeConcern;
}
示例3: getTitle
import org.apache.logging.log4j.util.Strings; //导入方法依赖的package包/类
@Override
public ContextObject<String> getTitle() {
AttributeValue metaTitle = getAttribute("meta_title");
ContextObject<String> title = getLabel();
if (metaTitle != null && Strings.isNotEmpty(ContextObjects.findCurrentLanguageOrGlobal(metaTitle.getValue()))) {
return metaTitle.getValue();
} else if (title != null && Strings.isNotEmpty(ContextObjects.findCurrentLanguageOrGlobal(title))) {
return title;
} else {
return null;
}
}
示例4: getMetaDescription
import org.apache.logging.log4j.util.Strings; //导入方法依赖的package包/类
@Override
public ContextObject<String> getMetaDescription() {
AttributeValue metaDescription = getAttribute("meta_description");
AttributeValue description = getAttribute("description");
if (metaDescription != null
&& Strings.isNotEmpty(ContextObjects.findCurrentLanguageOrGlobal(metaDescription.getValue()))) {
return metaDescription.getValue();
} else if (description != null
&& Strings.isNotEmpty(ContextObjects.findCurrentLanguageOrGlobal(description.getValue()))) {
return description.getValue();
} else {
return null;
}
}
示例5: startServerLogger
import org.apache.logging.log4j.util.Strings; //导入方法依赖的package包/类
/**
* Setup log4j & Start server log
*/
private void startServerLogger() {
String loggerConfig = ServerConstants.LOGGER_CONFIG_FILE;
if (Strings.isNotEmpty(loggerConfig)) {
System.setProperty(ServerConstants.LOGGER_SYSTEM_PROPERTY,
loggerConfig);
}
}
示例6: createField
import org.apache.logging.log4j.util.Strings; //导入方法依赖的package包/类
@PluginFactory
public static GelfLogField createField(@PluginConfiguration final Configuration config,
@PluginAttribute("name") String name, @PluginAttribute("literal") String literalValue,
@PluginAttribute("mdc") String mdc, @PluginAttribute("pattern") String pattern) {
final boolean isPattern = Strings.isNotEmpty(pattern);
final boolean isLiteralValue = Strings.isNotEmpty(literalValue);
final boolean isMDC = Strings.isNotEmpty(mdc);
if (Strings.isEmpty(name)) {
LOGGER.error("The name is empty");
return null;
}
if ((isPattern && isLiteralValue) || (isPattern && isMDC) || (isLiteralValue && isMDC)) {
LOGGER.error("The pattern, literal, and mdc attributes are mutually exclusive.");
return null;
}
if (isPattern) {
PatternLayout patternLayout = newBuilder().withPattern(pattern).withConfiguration(config)
.withNoConsoleNoAnsi(false).withAlwaysWriteExceptions(false).build();
return new GelfLogField(name, null, null, patternLayout);
}
return new GelfLogField(name, literalValue, mdc, null);
}
示例7: configureFields
import org.apache.logging.log4j.util.Strings; //导入方法依赖的package包/类
/**
* Configure fields (literals, MDC, layout).
*
* @param mdcGelfMessageAssembler the assembler
* @param fields static field array
* @param dynamicFieldArray dynamic field array
*/
private static void configureFields(MdcGelfMessageAssembler mdcGelfMessageAssembler, GelfLogField[] fields,
GelfDynamicMdcLogFields[] dynamicFieldArray) {
if (fields == null || fields.length == 0) {
mdcGelfMessageAssembler.addFields(LogMessageField.getDefaultMapping(Time, Severity, ThreadName, SourceClassName,
SourceMethodName, SourceLineNumber, SourceSimpleClassName, LoggerName, Marker));
return;
}
for (GelfLogField field : fields) {
if (Strings.isNotEmpty(field.getMdc())) {
mdcGelfMessageAssembler.addField(new MdcMessageField(field.getName(), field.getMdc()));
}
if (Strings.isNotEmpty(field.getLiteral())) {
mdcGelfMessageAssembler.addField(new StaticMessageField(field.getName(), field.getLiteral()));
}
if (field.getPatternLayout() != null) {
mdcGelfMessageAssembler.addField(new PatternLogMessageField(field.getName(), null, field.getPatternLayout()));
}
}
if (dynamicFieldArray != null) {
for (GelfDynamicMdcLogFields gelfDynamicMdcLogFields : dynamicFieldArray) {
mdcGelfMessageAssembler.addField(new DynamicMdcMessageField(gelfDynamicMdcLogFields.getRegex()));
}
}
}
示例8: insertObject
import org.apache.logging.log4j.util.Strings; //导入方法依赖的package包/类
@Override
public void insertObject(final NoSqlObject<Map<String, Object>> object) {
try {
final Response response = this.client.save(object.unwrap());
if (Strings.isNotEmpty(response.getError())) {
throw new AppenderLoggingException(
"Failed to write log event to CouchDB due to error: " + response.getError() + '.');
}
} catch (final Exception e) {
throw new AppenderLoggingException("Failed to write log event to CouchDB due to error: " + e.getMessage(),
e);
}
}
示例9: getConfiguration
import org.apache.logging.log4j.util.Strings; //导入方法依赖的package包/类
private Configuration getConfiguration(final LoggerContext loggerContext, final boolean isTest, final String name) {
final boolean named = Strings.isNotEmpty(name);
final ClassLoader loader = LoaderUtil.getThreadContextClassLoader();
for (final ConfigurationFactory factory : getFactories()) {
String configName;
final String prefix = isTest ? TEST_PREFIX : DEFAULT_PREFIX;
final String [] types = factory.getSupportedTypes();
if (types == null) {
continue;
}
for (final String suffix : types) {
if (suffix.equals(ALL_TYPES)) {
continue;
}
configName = named ? prefix + name + suffix : prefix + suffix;
final ConfigurationSource source = ConfigurationSource.fromResource(configName, loader);
if (source != null) {
if (!factory.isActive()) {
LOGGER.warn("Found configuration file {} for inactive ConfigurationFactory {}", configName, factory.getClass().getName());
}
return factory.getConfiguration(loggerContext, source);
}
}
}
return null;
}
示例10: discard
import org.apache.logging.log4j.util.Strings; //导入方法依赖的package包/类
boolean discard() {
if (discardIfEmpty == false) {
return false;
}
boolean foundNotEmptyValue = false;
for (final Map.Entry<String, String> entry : fields.entrySet()) {
if (Strings.isNotEmpty(entry.getValue())) {
foundNotEmptyValue = true;
break;
}
}
return !foundNotEmptyValue;
}
示例11: build
import org.apache.logging.log4j.util.Strings; //导入方法依赖的package包/类
@Override
public ColumnConfig build() {
if (Strings.isEmpty(name)) {
LOGGER.error("The column config is not valid because it does not contain a column name.");
return null;
}
final boolean isPattern = Strings.isNotEmpty(pattern);
final boolean isLiteralValue = Strings.isNotEmpty(literal);
if ((isPattern && isLiteralValue) || (isPattern && isEventTimestamp) || (isLiteralValue && isEventTimestamp)) {
LOGGER.error("The pattern, literal, and isEventTimestamp attributes are mutually exclusive.");
return null;
}
if (isEventTimestamp) {
return new ColumnConfig(name, null, null, true, false, false);
}
if (isLiteralValue) {
return new ColumnConfig(name, null, literal, false, false, false);
}
if (isPattern) {
final PatternLayout layout =
PatternLayout.newBuilder()
.withPattern(pattern)
.withConfiguration(configuration)
.withAlwaysWriteExceptions(false)
.build();
return new ColumnConfig(name, layout, null, false, isUnicode, isClob);
}
LOGGER.error("To configure a column you must specify a pattern or literal or set isEventDate to true.");
return null;
}
示例12: logMessage
import org.apache.logging.log4j.util.Strings; //导入方法依赖的package包/类
@Override
public void logMessage(final String fqcn, final Level mgsLevel, final Marker marker, final Message msg,
final Throwable throwable) {
final StringBuilder sb = new StringBuilder();
// Append date-time if so configured
if (showDateTime) {
final Date now = new Date();
String dateText;
synchronized (dateFormatter) {
dateText = dateFormatter.format(now);
}
sb.append(dateText);
sb.append(SPACE);
}
sb.append(mgsLevel.toString());
sb.append(SPACE);
if (Strings.isNotEmpty(logName)) {
sb.append(logName);
sb.append(SPACE);
}
sb.append(msg.getFormattedMessage());
if (showContextMap) {
final Map<String, String> mdc = ThreadContext.getImmutableContext();
if (mdc.size() > 0) {
sb.append(SPACE);
sb.append(mdc.toString());
sb.append(SPACE);
}
}
final Object[] params = msg.getParameters();
Throwable t;
if (throwable == null && params != null && params.length > 0
&& params[params.length - 1] instanceof Throwable) {
t = (Throwable) params[params.length - 1];
} else {
t = throwable;
}
stream.println(sb.toString());
if (t != null) {
stream.print(SPACE);
t.printStackTrace(stream);
}
}