1 13 14 19 package org.ejbca.util.query; 20 21 32 public class LogMatch extends BasicMatch { 33 35 public static final int MATCH_WITH_USERNAME = 0; 36 public static final int MATCH_WITH_ADMINCERTIFICATE = 1; 37 public static final int MATCH_WITH_IP = 2; 38 public static final int MATCH_WITH_SPECIALADMIN = 3; 39 public static final int MATCH_WITH_CERTIFICATE = 4; 40 public static final int MATCH_WITH_COMMENT = 5; 41 public static final int MATCH_WITH_EVENT = 6; public static final int MATCH_WITH_MODULE = 7; 43 public static final int MATCH_WITH_CA = 8; 44 45 46 static final String [] MATCH_WITH_SQLNAMES = {"username", "adminData", "adminData", "adminType" 48 , "certificateSNR", "comment", "event", "module", "caid"}; 50 51 53 63 public LogMatch(int matchwith, int matchtype, String matchvalue) 64 throws NumberFormatException { 65 this.matchwith = matchwith; 66 this.matchtype = matchtype; 67 this.matchvalue = matchvalue; 68 69 if ((matchwith == MATCH_WITH_EVENT) || (matchwith == MATCH_WITH_SPECIALADMIN)) { 72 new Integer (matchvalue); 73 } 74 } 75 76 81 public String getQueryString() { 82 String returnval = ""; 83 84 if (matchtype == BasicMatch.MATCH_TYPE_EQUALS) { 85 returnval = MATCH_WITH_SQLNAMES[matchwith] + " = '" + matchvalue + "'"; 86 } 87 88 if (matchtype == BasicMatch.MATCH_TYPE_BEGINSWITH) { 89 returnval = MATCH_WITH_SQLNAMES[matchwith] + " LIKE '" + matchvalue + "%'"; 90 } 91 92 if (matchtype == BasicMatch.MATCH_TYPE_CONTAINS) { 93 returnval = MATCH_WITH_SQLNAMES[matchwith] + " LIKE '%" + matchvalue + "%'"; 94 } 95 96 return returnval; 97 } 98 99 101 106 public boolean isLegalQuery() { 107 return !(matchvalue.trim().equals("")); 108 } 109 110 private int matchwith; 113 private int matchtype; 114 private String matchvalue; 115 } 116 | Popular Tags |