Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package de.agilecoders.wicket.logging;
  
  
  import static com.google.common.base.Strings.nullToEmpty;

An ILogCleaner is responsible for cleaning log messages.

Author(s):
miha
 
 public interface ILogCleaner {

    
cleans a given string

Parameters:
value the value to clean
Returns:
cleaned value as string
 
     String clean(final String value);

    
cleans a given path string

Parameters:
value the value to clean
Returns:
cleaned value as string
 
     String toCleanPath(final String value);

    
cleans a given StringValue

Parameters:
value the value to clean
Returns:
cleaned value as string
 
     String clean(final StringValue value);

    
cleans a given path as StringValue

Parameters:
value the value to clean
Returns:
cleaned value as string
 
     String toCleanPath(final StringValue value);

    
Default implementation of ILogCleaner that removes line breaks and tabs and it transforms absolute paths to relative.
 
     public static class DefaultLogCleaner implements ILogCleaner {
 
         @Override
         public String clean(String value) {
             return nullToEmpty(value).replaceAll("[\t\n\r]""").trim();
         }
 
         @Override
         public String clean(StringValue value) {
             return clean(value.toString(""));
         }
 
         @Override
         public String toCleanPath(StringValue value) {
             return toCleanPath(value.toString("/"));
         }
 
         @Override
         public String toCleanPath(String value) {
             return Url.parse(clean(value), .).toString(..);
         }
     }

    
A special log cleaner that doesn't clean anything and only returns given values
 
     public static class NoOpLogCleaner implements ILogCleaner {
 
         @Override
         public String clean(String value) {
             return value;
         }
 
         @Override
         public String toCleanPath(String value) {
             return value;
         }
 
         @Override
         public String clean(StringValue value) {
             return value.toString();
         }
 
         @Override
         public String toCleanPath(StringValue value) {
             return value.toString();
         }
    }
New to GrepCode? Check out our FAQ X