コード例 #1
0
 public void add(String clientIp, String query, int type, String answer) {
   DoubleKeyMap<String, Integer, String> stringIntegerStringDoubleKeyMap = container.get(clientIp);
   if (stringIntegerStringDoubleKeyMap == null) {
     stringIntegerStringDoubleKeyMap =
         new DoubleKeyMap<String, Integer, String>(ConcurrentHashMap.class);
     container.put(clientIp, stringIntegerStringDoubleKeyMap);
   }
   stringIntegerStringDoubleKeyMap.put(query, type, answer);
 }
コード例 #2
0
 /*
  * (non-Javadoc)
  *
  * @see
  * us.codecraft.blackhole.answer.AnswerProvider#getAnswer(java.lang.String,
  * int)
  */
 @Override
 public String getAnswer(String query, int type) {
   String ip = RequestContext.getClientIp();
   DoubleKeyMap<String, Integer, String> stringIntegerStringDoubleKeyMap = container.get(ip);
   if (stringIntegerStringDoubleKeyMap == null) {
     return null;
   }
   return stringIntegerStringDoubleKeyMap.get(query, type);
 }