Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package de.agilecoders.wicket.logging;
  
  
  import java.util.HashSet;
  import java.util.Set;

An IParamValueExtractor extracts key/values and parses given org.apache.wicket.request.IRequestParameters.

Author(s):
miha
 
 public interface IParamValueExtractor {

    
parses given parameters

Parameters:
params the parameters to parse
Returns:
result that contains all log messages and the client information
 
     Result parse(IRequestParameters params);

    
Default implementation of IParamValueExtractor
 
     public static final class DefaultParamValueExtractor implements IParamValueExtractor {
 
         @Override
         public Result parse(IRequestParameters params) {
             final Set<ClientSideLogObjectlogObjects = new HashSet<>();
             final ClientInfos clientInfos = new ClientInfos();
 
             for (final String paramName : params.getParameterNames()) {
                 final String realParamName = extractRealParamName(paramName);
 
                 switch (realParamName) {
                     case .:
                     case .:
                     case .:
                         final int index = extractIndex(paramName);
 
                         if (index > -1) {
                             logObjects.add(new ClientSideLogObject(params.getParameterValue(. + . + index),
                                                                    params.getParameterValue(. + . + index),
                                                                    params.getParameterValue(. + . + index)));
                         }
                         break;
 
                     case .:
                     case .:
                     case .:
                     case .:
                         clientInfos.put(paramNameparams.getParameterValue(paramName).toString(.));
                 }
             }
 
             return new Result(logObjectsclientInfos);
         }
 
         private int extractIndex(String paramName) {
             final int index = paramName.indexOf(.);
 
             if (index > -1) {
                 return Integer.parseInt(paramName.substring(index + 1));
             } else {
                 return -1;
             }
         }
 
         private String extractRealParamName(final String paramName) {
             final int index = paramName.indexOf(.);
             if (index >= 0) {
                 return paramName.substring(0, index);
             }
 
             return paramName;
         }
     }

    
 
     public static final class Result {
         private final Iterable<ClientSideLogObjectlogObjects;
         private final ClientInfos clientInfos;

        
Construct.

Parameters:
logObjects all log messages
clientInfos the client information
 
         public Result(Iterable<ClientSideLogObjectlogObjectsClientInfos clientInfos) {
             this. = logObjects;
             this. = clientInfos;
         }

        

Returns:
the client information
        public ClientInfos clientInfos() { return ; }

        

Returns:
all log messages
        public Iterable<ClientSideLogObjectlogObjects() { return ; }
    }
New to GrepCode? Check out our FAQ X