示例#1
0
 public void bumpSong(PlaylistEntry entry) {
   if (musicList.contains(entry)) {
     // remove the entry from the queue
     musicList.remove(entry);
     musicList.push(entry);
   }
 }
  @Override
  protected boolean onAccessDenied(ServletRequest request, ServletResponse response)
      throws Exception {
    Subject subject = getSubject(request, response);
    if (!subject.isAuthenticated() && !subject.isRemembered()) {
      // 如果没有登录,直接进行之后的流程
      return true;
    }

    Session session = subject.getSession();
    // String username = (String) subject.getPrincipal();
    String account = ((ShiroUser) subject.getPrincipal()).getAccount();
    Serializable sessionId = session.getId();

    // TODO 同步控制
    Deque<Serializable> deque = cache.get(account);
    if (deque == null) {
      deque = new LinkedList<Serializable>();
      cache.put(account, deque);
    }

    // 如果队列里没有此sessionId,且用户没有被踢出;放入队列
    if (!deque.contains(sessionId) && session.getAttribute("kickout") == null) {
      deque.push(sessionId);
    }

    // 如果队列里的sessionId数超出最大会话数,开始踢人
    while (deque.size() > maxSession) {
      Serializable kickoutSessionId = null;
      if (kickoutAfter) { // 如果踢出后者
        kickoutSessionId = deque.removeFirst();
      } else { // 否则踢出前者
        kickoutSessionId = deque.removeLast();
      }
      try {
        Session kickoutSession = sessionManager.getSession(new DefaultSessionKey(kickoutSessionId));
        if (kickoutSession != null) {
          // 设置会话的kickout属性表示踢出了
          kickoutSession.setAttribute("kickout", true);
        }
      } catch (Exception e) { // ignore exception
      }
    }

    // 如果被踢出了,直接退出,重定向到踢出后的地址
    if (session.getAttribute("kickout") != null) {
      // 会话被踢出了
      try {
        subject.logout();
      } catch (Exception e) { // ignore
      }
      saveRequest(request);
      WebUtils.issueRedirect(request, response, kickoutUrl);
      return false;
    }

    return true;
  }
示例#3
0
  public PlaylistEntry remove(PlaylistEntry entry) {
    boolean success;
    PlaylistEntry removeEntry = entry;

    if (musicList.contains(entry)) {
      success = musicList.remove(entry);
    } else if (playedList.contains(entry)) {
      success = playedList.remove(entry);
    } else {
      success = false;
      Log.wtf(TAG, "Asked to remove unknown object");
    }

    if (!success) {
      removeEntry = null;
    }
    return removeEntry;
  }
  public static void main(String[] arg) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int K = Integer.parseInt(br.readLine());
    Deque<String> bag = new LinkedList<String>();
    // String str[]= br.readLine().split(" ");
    for (int i = 0; i < K; i++) bag.add(br.readLine());
    int N = Integer.parseInt(br.readLine());
    String str[] = br.readLine().split(" ");
    int l;
    for (l = N - 1; l >= 0; l--) if (!bag.contains(str[l])) break;
    for (int i = 0; i < l; i++) {
      if (bag.contains(str[i])) continue;
      else {
        System.out.print(str[i].toUpperCase().charAt(0) + ".");
      }
      // if(!bag.contains(str[N-1]))

    } // end of for
    System.out.print(str[l].toUpperCase().charAt(0));
  } // end of main
示例#5
0
  protected boolean goodSuccessor(Pos into, Pos from) {
    EntityPlayer player = Minecraft.getMinecraft().thePlayer;
    Block block = Minecraft.getMinecraft().theWorld.getBlock(into.X, into.Y, into.Z);
    int id = Block.getIdFromBlock(block);

    if (mOpen.contains(into)) return false;
    if (mClosed.contains(into)) return false;
    if (block instanceof BlockDoor && from != null && into.Y == from.Y)
      return !doorIsBlocking(into, from);
    if (!mPermeableBlockIds.contains(id)) return false;
    if (into.X > player.posX + mDepth || into.X < player.posX - mDepth) return false;
    if (into.Y > player.posY + mDepth || into.Y < player.posY - mDepth) return false;
    if (into.Z > player.posZ + mDepth || into.Z < player.posZ - mDepth) return false;

    return true;
  }
 @Override
 public boolean contains(final T element) {
   return sequence.contains(element);
 }
 @SuppressWarnings("unused")
 private boolean insideElem(String elem) {
   return elemStack.contains(elem);
 }