Пример #1
0
 /** Gets a copy of this variable. */
 Term copy(AbstractMap vMap, AbstractMap substMap) {
   Var v;
   Object temp = vMap.get(this);
   if (temp == null) {
     v =
         new Var(
             null,
             Var.PROGRESSIVE,
             vMap.size(),
             timestamp); // name,Var.PROGRESSIVE,vMap.size(),timestamp);
     vMap.put(this, v);
   } else {
     v = (Var) temp;
   }
   Term t = getTerm();
   if (t instanceof Var) {
     Object tt = substMap.get(t);
     if (tt == null) {
       substMap.put(t, v);
       v.link = null;
     } else {
       v.link = (tt != v) ? (Var) tt : null;
     }
   }
   if (t instanceof Struct) {
     v.link = t.copy(vMap, substMap);
   }
   if (t instanceof Number) v.link = t;
   return v;
 }
Пример #2
0
 /**
  * Gets a copy of this variable.
  *
  * <p>if the variable is not present in the list passed as argument, a copy of this variable is
  * returned and added to the list. If instead a variable with the same time identifier is found in
  * the list, then the variable in the list is returned.
  */
 Term copy(AbstractMap vMap, int idExecCtx) {
   Term tt = getTerm();
   if (tt == this) {
     Var v = (Var) (vMap.get(this));
     if (v == null) {
       // No occurence of v before
       v = new Var(name, idExecCtx, 0, timestamp);
       vMap.put(this, v);
     }
     return v;
   } else {
     return tt.copy(vMap, idExecCtx);
   }
 }
Пример #3
0
  private void joinChat() {
    String userColor;

    sessionService.addOnSessionDestroyedListener(callback);

    defaultSessionTimeout = httpSession.getMaxInactiveInterval();
    httpSession.setMaxInactiveInterval(0);
    lastActivityTime = System.currentTimeMillis();

    String username = ((User) authToken.getPrincipal()).getUsername();
    LOG.debug("joinChat() user: "******"USER", username);

    int userNb = usersLoggedIn.incrementAndGet();
    // If a user is active more than once, give him the same color:
    if (userColorMap.containsKey(username)) {
      userColor = userColorMap.get(username);
    } else {
      userColor = PEER_COLORS[userNb % PEER_COLOR_NB];
      userColorMap.put(username, userColor);
    }

    thisSession.getUserProperties().put("COLOR", userColor);

    Message joinMsg = new Message();
    joinMsg.TYPE = "JOIN";
    joinMsg.SUBTYPE = "JOIN";
    joinMsg.USER_LIST = buildUserList(true);
    joinMsg.STATS_MSG = userNb + " User" + (userNb > 1 ? "s " : " ") + "online!";

    sendMessage(joinMsg);

    Message infoMsg = new Message();
    infoMsg.TYPE = "INFO";
    infoMsg.SUBTYPE = "JOIN";
    infoMsg.INFO_MSG = username + " has entered the building";
    infoMsg.STATS_MSG = userNb + " User" + (userNb > 1 ? "s " : " ") + "online!";
    infoMsg.USER_LIST = buildUserList(true);

    broadcastMessage(infoMsg, false);
  }
Пример #4
0
 public static AbstractMap<String, String> parser(Object params) throws JSONException {
   AbstractMap<String, String> localParams = new HashMap<>();
   if (params != "") {
     JSONObject json = new JSONObject(params.toString());
     Iterator<String> iter = json.keys();
     while (iter.hasNext()) {
       String key = iter.next();
       try {
         Object value = json.get(key);
         localParams.put(key, value.toString());
       } catch (JSONException e) {
         exceptionMessages.put(
             "parser",
             "There has been a problem parsing your custom values (params, request headers or tests).");
       }
     }
   }
   return localParams;
 }
Пример #5
0
 /**
  * {@inheritDoc}
  *
  * <p>This implementation iterates through {@code map}'s entry set, calling {@code put()} for
  * each.
  */
 public void putAll(Map<? extends K, ? extends V> map) {
   for (Map.Entry<? extends K, ? extends V> entry : map.entrySet()) {
     put(entry.getKey(), entry.getValue());
   }
 }
 /**
  * Replaces all unquantified variables with the unique copy stored as a value of the given map;
  * also instantiates all quantified variables and stores them in the given map.
  *
  * @param m The map in which to find unique copies of the variables.
  */
 public void consolidateVariables(java.util.AbstractMap m) {
   variableMap = m;
   if (m.containsKey(left)) left = (FirstOrderVariable) m.get(left);
   else m.put(left, left);
 }