Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package de.agilecoders.wicket.logging;
  
A ClientSideLogObject represents a log message that was created on client side.

Author(s):
miha
 
 public class ClientSideLogObject {
 
     private final StringValue lvl;
     private final StringValue message;
     private final StringValue timestamp;
     private final StringValue stacktrace;
     private final int index;
     private final StringValue line;
     private final StringValue file;

    
Construct.

Parameters:
lvl the log level as org.apache.wicket.util.string.StringValue
message the message as org.apache.wicket.util.string.StringValue
timestamp the timestamp as org.apache.wicket.util.string.StringValue in UTC format.
file the file that has thrown this error
line the line in file that has thrown this error
stacktrace the client side stacktrace
index the parameter index that was used on client side to generate this log object
 
     public ClientSideLogObject(String lvlString messageString timestampString fileString line,
                                String stacktraceint index) {
         this(StringValue.valueOf(lvl), StringValue.valueOf(message), StringValue.valueOf(timestamp),
              StringValue.valueOf(file), StringValue.valueOf(line), StringValue.valueOf(stacktrace), index);
     }

    
Construct.

Parameters:
lvl the log level as org.apache.wicket.util.string.StringValue
message the message as org.apache.wicket.util.string.StringValue
timestamp the timestamp as org.apache.wicket.util.string.StringValue in UTC format.
file the file that has thrown this error
line the line in file that has thrown this error
stacktrace the client side stacktrace as org.apache.wicket.util.string.StringValue
index the param index
 
     public ClientSideLogObject(StringValue lvlStringValue messageStringValue timestamp,
                                StringValue fileStringValue lineStringValue stacktraceint index) {
         this. = lvl;
         this. = message;
         this. = timestamp;
         this. = stacktrace;
         this. = index;
         this. = file;
         this. = line;
     }

    

Returns:
parameter index
 
     public int index() {
         return ;
     }

    

Returns:
log level as string or "error" if not valid
 
     public String level() {
         return .toString("error");
     }

    

Returns:
stacktrace or empty string if non is set
 
     public String stacktrace() {
         return .toString("");
     }


    

Returns:
the file that has thrown this error
 
     public String file() {
         return .toString("");
     }


    

Returns:
the line in file that has thrown this error
 
     public String line() {
         return .toString("");
     }

    

Returns:
log message or default message if invalid
 
    public String message() {
    }

    

Returns:
timestamp as string or default timestamp if invalid
    public String timestamp() {
    }
    @Override
    public String toString() {
        return String.format("[%s | %s] %s %s"timestamp(), level(), fileAndLine(), message());
    }
    private String fileAndLine() {
        if (file().isEmpty()) {
            return "";
        } else if (line().isEmpty()) {
            return file() + ":";
        } else {
            return file() + ":" + line() + ":";
        }
    }
    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        ClientSideLogObject logObject = (ClientSideLogObjecto;
        if ( != null ? !.equals(logObject.lvl) : logObject.lvl != null) {
            return false;
        }
        if ( != null ? !.equals(logObject.message) : logObject.message != null) {
            return false;
        }
        if ( != null ? !.equals(logObject.stacktrace) : logObject.stacktrace != null) {
            return false;
        }
        if ( != null ? !.equals(logObject.file) : logObject.file != null) {
            return false;
        }
        if ( != null ? !.equals(logObject.line) : logObject.line != null) {
            return false;
        }
        if ( != null ? !.equals(logObject.timestamp) : logObject.timestamp != null) {
            return false;
        }
        return true;
    }
    @Override
    public int hashCode() {
        int result =  != null ? .hashCode() : 0;
        result = 31 * result + ( != null ? .hashCode() : 0);
        result = 31 * result + ( != null ? .hashCode() : 0);
        result = 31 * result + ( != null ? .hashCode() : 0);
        result = 31 * result + ( != null ? .hashCode() : 0);
        result = 31 * result + ( != null ? .hashCode() : 0);
        return result;
    }

    

Returns:
TRUE, if all values are set
    public boolean isValid() {
        return !.isEmpty() && !.isEmpty() && !.isEmpty();
    }
New to GrepCode? Check out our FAQ X