本文整理汇总了Java中org.apache.logging.log4j.core.helpers.Strings类的典型用法代码示例。如果您正苦于以下问题:Java Strings类的具体用法?Java Strings怎么用?Java Strings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Strings类属于org.apache.logging.log4j.core.helpers包,在下文中一共展示了Strings类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convertToEntityAttribute
import org.apache.logging.log4j.core.helpers.Strings; //导入依赖的package包/类
@Override
public ThreadContext.ContextStack convertToEntityAttribute(final String s) {
if (Strings.isEmpty(s)) {
return null;
}
List<String> list;
try {
list = ContextMapJsonAttributeConverter.OBJECT_MAPPER.readValue(s, new TypeReference<List<String>>() { });
} catch (final IOException e) {
throw new PersistenceException("Failed to convert JSON string to list for stack.", e);
}
final DefaultThreadContextStack result = new DefaultThreadContextStack(true);
result.addAll(list);
return result;
}
示例2: createConnectionSource
import org.apache.logging.log4j.core.helpers.Strings; //导入依赖的package包/类
/**
* Factory method for creating a connection source within the plugin manager.
*
* @param jndiName The full JNDI path where the data source is bound. Should start with java:/comp/env or
* environment-equivalent.
* @return the created connection source.
*/
@PluginFactory
public static DataSourceConnectionSource createConnectionSource(@PluginAttribute("jndiName") final String jndiName) {
if (Strings.isEmpty(jndiName)) {
LOGGER.error("No JNDI name provided.");
return null;
}
try {
final InitialContext context = new InitialContext();
final DataSource dataSource = (DataSource) context.lookup(jndiName);
if (dataSource == null) {
LOGGER.error("No data source found with JNDI name [" + jndiName + "].");
return null;
}
return new DataSourceConnectionSource(jndiName, dataSource);
} catch (final NamingException e) {
LOGGER.error(e.getMessage(), e);
return null;
}
}
示例3: ticketsLoaded
import org.apache.logging.log4j.core.helpers.Strings; //导入依赖的package包/类
@Override
public void ticketsLoaded(final List<ForgeChunkManager.Ticket> tickets, final World world) {
if(world.provider.getDimension() != ModDimensions.CUBE_ID)return;
PlayerCubeChunkLoaderManager.dirty = true;
final HashMap<GameProfile, ForgeChunkManager.Ticket> cache = new HashMap<GameProfile, ForgeChunkManager.Ticket>();
PlayerCubeChunkLoaderManager.playerTickets = cache;
for (final ForgeChunkManager.Ticket ticket : tickets) {
final NBTTagCompound modData = ticket.getModData();
GameProfile profile = null;
final String name = modData.getString("Name");
UUID uuid = null;
if (modData.hasKey("UUIDL")) {
uuid = new UUID(modData.getLong("UUIDU"), modData.getLong("UUIDL"));
}
if (Strings.isEmpty(name)) {
profile = null;
}
else profile = new GameProfile(uuid, name);
cache.put(profile, ticket);
final int[] x = modData.getIntArray("x");
final int[] z = modData.getIntArray("z");
if (x.length == z.length) {
for (int i = 0; i < x.length; ++i) {
ForgeChunkManager.forceChunk(ticket, new ChunkPos(x[i], z[i]));
}
}
}
}
示例4: getManager
import org.apache.logging.log4j.core.helpers.Strings; //导入依赖的package包/类
/**
* Returns a FlumeAvroManager.
* @param name The name of the manager.
* @param agents The agents to use.
* @param properties Properties to pass to the Manager.
* @param batchSize The number of events to include in a batch.
* @param retries The number of times to retry connecting before giving up.
* @param connectionTimeout The amount of time to wait to establish a connection.
* @param requestTimeout The amount of time to wait for a response to a request.
* @param delay Amount of time to delay before delivering a batch.
* @param dataDir The location of the Berkeley database.
* @return A FlumeAvroManager.
*/
public static FlumePersistentManager getManager(final String name, final Agent[] agents,
final Property[] properties, int batchSize, final int retries,
final int connectionTimeout, final int requestTimeout,
final int delay, final int lockTimeoutRetryCount,
final String dataDir) {
if (agents == null || agents.length == 0) {
throw new IllegalArgumentException("At least one agent is required");
}
if (batchSize <= 0) {
batchSize = 1;
}
final String dataDirectory = Strings.isEmpty(dataDir) ? DEFAULT_DATA_DIR : dataDir;
final StringBuilder sb = new StringBuilder("FlumePersistent[");
boolean first = true;
for (final Agent agent : agents) {
if (!first) {
sb.append(",");
}
sb.append(agent.getHost()).append(":").append(agent.getPort());
first = false;
}
sb.append("]");
sb.append(" ").append(dataDirectory);
return getManager(sb.toString(), factory, new FactoryData(name, agents, batchSize, retries,
connectionTimeout, requestTimeout, delay, lockTimeoutRetryCount, dataDir, properties));
}
示例5: charSetMatcher
import org.apache.logging.log4j.core.helpers.Strings; //导入依赖的package包/类
/**
* Constructor that creates a matcher from a string representing a set of characters.
*
* @param chars the characters to match, null or empty matches nothing
* @return a new Matcher for the given characters
*/
public static StrMatcher charSetMatcher(final String chars) {
if (Strings.isEmpty(chars)) {
return NONE_MATCHER;
}
if (chars.length() == 1) {
return new CharMatcher(chars.charAt(0));
}
return new CharSetMatcher(chars.toCharArray());
}
示例6: stringMatcher
import org.apache.logging.log4j.core.helpers.Strings; //导入依赖的package包/类
/**
* Constructor that creates a matcher from a string.
*
* @param str the string to match, null or empty matches nothing
* @return a new Matcher for the given String
*/
public static StrMatcher stringMatcher(final String str) {
if (Strings.isEmpty(str)) {
return NONE_MATCHER;
}
return new StringMatcher(str);
}
示例7: getSocketManager
import org.apache.logging.log4j.core.helpers.Strings; //导入依赖的package包/类
public static TLSSocketManager getSocketManager(final SSLConfiguration sslConfig, final String host, int port,
int delay, final boolean immediateFail, final Layout layout ) {
if (Strings.isEmpty(host)) {
throw new IllegalArgumentException("A host name is required");
}
if (port <= 0) {
port = DEFAULT_PORT;
}
if (delay == 0) {
delay = DEFAULT_RECONNECTION_DELAY;
}
return (TLSSocketManager) getManager("TLS:" + host + ":" + port,
new TLSFactoryData(sslConfig, host, port, delay, immediateFail, layout), FACTORY);
}
示例8: getSocketManager
import org.apache.logging.log4j.core.helpers.Strings; //导入依赖的package包/类
/**
* Obtain a TCPSocketManager.
* @param host The host to connect to.
* @param port The port on the host.
* @param delay The interval to pause between retries.
* @return A TCPSocketManager.
*/
public static TCPSocketManager getSocketManager(final String host, int port, int delay,
final boolean immediateFail, final Layout<? extends Serializable> layout ) {
if (Strings.isEmpty(host)) {
throw new IllegalArgumentException("A host name is required");
}
if (port <= 0) {
port = DEFAULT_PORT;
}
if (delay == 0) {
delay = DEFAULT_RECONNECTION_DELAY;
}
return (TCPSocketManager) getManager("TCP:" + host + ":" + port,
new FactoryData(host, port, delay, immediateFail, layout), FACTORY);
}
示例9: getSocketManager
import org.apache.logging.log4j.core.helpers.Strings; //导入依赖的package包/类
/**
* Obtain a SocketManager.
* @param host The host to connect to.
* @param port The port on the host.
* @param layout The layout.
* @return A DatagramSocketManager.
*/
public static DatagramSocketManager getSocketManager(final String host, final int port, final Layout<? extends Serializable> layout) {
if (Strings.isEmpty(host)) {
throw new IllegalArgumentException("A host name is required");
}
if (port <= 0) {
throw new IllegalArgumentException("A port value is required");
}
return (DatagramSocketManager) getManager("UDP:" + host + ":" + port, new FactoryData(host, port, layout),
FACTORY);
}
示例10: convertToEntityAttribute
import org.apache.logging.log4j.core.helpers.Strings; //导入依赖的package包/类
@Override
public StackTraceElement convertToEntityAttribute(final String s) {
if (Strings.isEmpty(s)) {
return null;
}
return StackTraceElementAttributeConverter.convertString(s);
}
示例11: convertToEntityAttribute
import org.apache.logging.log4j.core.helpers.Strings; //导入依赖的package包/类
@Override
public Message convertToEntityAttribute(final String s) {
if (Strings.isEmpty(s)) {
return null;
}
return LOGGER.getMessageFactory().newMessage(s);
}
示例12: convertToEntityAttribute
import org.apache.logging.log4j.core.helpers.Strings; //导入依赖的package包/类
@Override
public Marker convertToEntityAttribute(final String s) {
if (Strings.isEmpty(s)) {
return null;
}
final int bracket = s.indexOf("[");
return bracket < 1 ? MarkerManager.getMarker(s) : MarkerManager.getMarker(s.substring(0, bracket));
}
示例13: convertToEntityAttribute
import org.apache.logging.log4j.core.helpers.Strings; //导入依赖的package包/类
@Override
public Throwable convertToEntityAttribute(final String s) {
if (Strings.isEmpty(s)) {
return null;
}
final List<String> lines = Arrays.asList(s.split("(\n|\r\n)"));
return this.convertString(lines.listIterator(), false);
}
示例14: convertToEntityAttribute
import org.apache.logging.log4j.core.helpers.Strings; //导入依赖的package包/类
@Override
public Map<String, String> convertToEntityAttribute(final String s) {
if (Strings.isEmpty(s)) {
return null;
}
try {
return OBJECT_MAPPER.readValue(s, new TypeReference<Map<String, String>>() { });
} catch (final IOException e) {
throw new PersistenceException("Failed to convert JSON string to map.", e);
}
}
示例15: createConnectionSource
import org.apache.logging.log4j.core.helpers.Strings; //导入依赖的package包/类
/**
* Factory method for creating a connection source within the plugin manager.
*
* @param url The JDBC URL to use to connect to the logging database. A driver that can accept this URL must be on
* the classpath.
* @param username The username with which to log in to the database, if applicable.
* @param password The password with which to log in to the database, if applicable.
* @return the created connection source.
*/
@PluginFactory
public static DriverManagerConnectionSource createConnectionSource(
@PluginAttribute("url") final String url,
@PluginAttribute("username") String username,
@PluginAttribute("password") String password) {
if (Strings.isEmpty(url)) {
LOGGER.error("No JDBC URL specified for the database.");
return null;
}
Driver driver;
try {
driver = DriverManager.getDriver(url);
} catch (final SQLException e) {
LOGGER.error("No matching driver found for database URL [" + url + "].", e);
return null;
}
if (driver == null) {
LOGGER.error("No matching driver found for database URL [" + url + "].");
return null;
}
if (username == null || username.trim().isEmpty()) {
username = null;
password = null;
}
return new DriverManagerConnectionSource(url, username, password);
}