Пример #1
1
        public void handle(PeerMessage event) {
          PeerAddress oldFriend;
          PeerAddress sender = event.getMSPeerSource();
          PeerAddress newFriend = event.getNewFriend();

          // add the sender address to the list of friends
          if (!friends.contains(sender)) {
            if (friends.size() == viewSize) {
              oldFriend = friends.get(rand.nextInt(viewSize));
              friends.remove(oldFriend);
              fdUnregister(oldFriend);
              Snapshot.removeFriend(serverPeerAddress, oldFriend);
            }

            friends.addElement(sender);
            fdRegister(sender);
            Snapshot.addFriend(serverPeerAddress, sender);
          }

          // add the received new friend from the sender to the list of friends
          if (!friends.contains(newFriend) && !serverPeerAddress.equals(newFriend)) {
            if (friends.size() == viewSize) {
              oldFriend = friends.get(rand.nextInt(viewSize));
              friends.remove(oldFriend);
              fdUnregister(oldFriend);
              Snapshot.removeFriend(serverPeerAddress, oldFriend);
            }

            friends.addElement(newFriend);
            fdRegister(newFriend);
            Snapshot.addFriend(serverPeerAddress, newFriend);
          }
        }
Пример #2
0
  public void addResidue(String name, String chain, String loc) {
    Variable var;
    if (titratableResNames.contains(name)) {
      String[] labels = resToTaut.get(name);
      // for (int i=0; i<labels.length; i++){
      //	labels[i] = labels[i]+"_"+chain+"_"+loc;
      // }
      var = new Variable(name + "_" + chain + "_" + loc, labels);
      for (String l : labels) {
        Instance vl = var.getInstance(l);
        if (tRes.contains(l)) {
          vl.setEnergy(modPka.get(l));
        } else {
          vl.setEnergy(0);
        }
      }
    } else {
      nonTitratableResNames.add(name);
      String[] label = {name};
      var = new Variable(name + "_" + chain + "_" + loc, label);
      Instance vl = var.getInstance(label[0]);
      vl.setEnergy(0);
    }

    addResidue(var);
  }
Пример #3
0
 public DVector parseLootPolicyFor(MOB mob) {
   if (mob == null) return new DVector(3);
   Vector lootPolicy =
       (!mob.isMonster())
           ? new Vector()
           : CMParms.parseCommas(CMProps.getVar(CMProps.SYSTEM_ITEMLOOTPOLICY), true);
   DVector policies = new DVector(3);
   for (int p = 0; p < lootPolicy.size(); p++) {
     String s = ((String) lootPolicy.elementAt(p)).toUpperCase().trim();
     if (s.length() == 0) continue;
     Vector compiledMask = null;
     int maskDex = s.indexOf("MASK=");
     if (maskDex >= 0) {
       s = s.substring(0, maskDex).trim();
       compiledMask =
           CMLib.masking()
               .maskCompile(((String) lootPolicy.elementAt(p)).substring(maskDex + 5).trim());
     } else compiledMask = new Vector();
     Vector parsed = CMParms.parse(s);
     int pct = 100;
     for (int x = 0; x < parsed.size(); x++)
       if (CMath.isInteger((String) parsed.elementAt(x)))
         pct = CMath.s_int((String) parsed.elementAt(x));
       else if (CMath.isPct((String) parsed.elementAt(x)))
         pct = (int) Math.round(CMath.s_pct((String) parsed.elementAt(x)) * 100.0);
     int flags = 0;
     if (parsed.contains("RUIN")) flags |= CMMiscUtils.LOOTFLAG_RUIN;
     else if (parsed.contains("LOSS")) flags |= CMMiscUtils.LOOTFLAG_LOSS;
     if (flags == 0) flags |= CMMiscUtils.LOOTFLAG_LOSS;
     if (parsed.contains("WORN")) flags |= CMMiscUtils.LOOTFLAG_WORN;
     else if (parsed.contains("UNWORN")) flags |= CMMiscUtils.LOOTFLAG_UNWORN;
     policies.addElement(Integer.valueOf(pct), Integer.valueOf(flags), compiledMask);
   }
   return policies;
 }
  /**
   * List of games containing this member.
   *
   * @param c Connection
   * @param firstGameName Game name that should be first element of list (if <tt>newConn</tt> is a
   *     member of it), or null.
   * @return The games, in no particular order (past firstGameName), or a 0-length Vector, if member
   *     isn't in any game.
   * @see #replaceMemberAllGames(StringConnection, StringConnection)
   * @since 1.1.08
   */
  public Vector memberGames(StringConnection c, final String firstGameName) {
    Vector cGames = new Vector();

    synchronized (gameData) {
      SOCGame firstGame = null;
      if (firstGameName != null) {
        firstGame = getGameData(firstGameName);
        if (firstGame != null) {
          Vector members = getMembers(firstGameName);
          if ((members != null) && members.contains(c)) cGames.addElement(firstGame);
        }
      }

      Enumeration gdEnum = getGamesData();
      while (gdEnum.hasMoreElements()) {
        SOCGame ga = (SOCGame) gdEnum.nextElement();
        if (ga == firstGame) continue;
        Vector members = getMembers(ga.getName());
        if ((members == null) || !members.contains(c)) continue;

        cGames.addElement(ga);
      }
    }

    return cGames;
  }
Пример #5
0
  private void getNewNodes() {
    Vector levelNodes = new Vector();
    Vector nextLevelNodes = new Vector();
    Vector passedNodes = new Vector();
    levelNodes.add(centerNode.name);
    for (int level = 0; level <= Config.navigationDepth; level++) {
      for (Enumeration e = levelNodes.elements(); e.hasMoreElements(); ) {
        String nodeName = (String) e.nextElement();

        if (!passedNodes.contains(nodeName)) {
          passedNodes.add(nodeName);

          Node node = graph.nodeFromName(nodeName);
          if (node == null) {
            node = xmlReader.getNode(nodeName);
            graph.add(node);
          }
          node.passed = true;

          Set linkSet = node.links.keySet();
          for (Iterator it = linkSet.iterator(); it.hasNext(); ) {
            String neighbourName = (String) it.next();
            if (!passedNodes.contains(neighbourName) && !levelNodes.contains(neighbourName)) {
              nextLevelNodes.add(neighbourName);
            }
          }
        }
      }
      levelNodes = nextLevelNodes;
      nextLevelNodes = new Vector();
    }
  }
Пример #6
0
  /**
   * Returns true if the given FieldInfo is contained within this ClassInfo
   *
   * @param fieldInfo the FieldInfo to check
   * @return true if the given FieldInfo is contained within this ClassInfo
   */
  public boolean contains(final FieldInfo fieldInfo) {
    if (fieldInfo == null) {
      return false;
    }

    switch (fieldInfo.getNodeType()) {
      case XMLInfo.ATTRIBUTE_TYPE:
        if (_atts != null) {
          return _atts.contains(fieldInfo);
        }
        break;
      case XMLInfo.TEXT_TYPE:
        return (fieldInfo == _textField);
      default:
        if (_elements != null) {
          return _elements.contains(fieldInfo);
        }
        break;
    }

    // if (sourceInfo != null)
    //    return sourceInfo.contains(fieldInfo);

    return false;
  } // -- contains
Пример #7
0
  @Test
  public void testSendAllIntersesst() throws Exception {
    /*
    All should be exchanged but not direction 0
     */

    try {
      TimeUnit.SECONDS.sleep(15);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }

    bob.newsKP.sendAllIntersesst(alicepeer);
    try {
      TimeUnit.SECONDS.sleep(5);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }

    Vector allnews = bob.newsKP.getNews();
    Assert.assertTrue(allnews.contains("Supernews"));
    Assert.assertTrue(allnews.contains("Sportnews"));
    Assert.assertTrue(allnews.contains("Fussballnews"));
    Assert.assertFalse(allnews.contains("Politiknews"));
    Assert.assertFalse(allnews.contains("foo"));
  }
Пример #8
0
  /**
   * Adds the given FieldInfo to this ClassInfo
   *
   * @param fieldInfo the FieldInfo to add
   */
  public void addFieldInfo(final FieldInfo fieldInfo) {
    if (fieldInfo == null) {
      return;
    }

    fieldInfo.setDeclaringClassInfo(this);

    switch (fieldInfo.getNodeType()) {
      case XMLInfo.ATTRIBUTE_TYPE:
        if (_atts == null) {
          _atts = new Vector(3);
        }
        if (!_atts.contains(fieldInfo)) {
          _atts.addElement(fieldInfo);
        }
        break;
      case XMLInfo.TEXT_TYPE:
        _textField = fieldInfo;
        break;
      default:
        if (_elements == null) {
          _elements = new Vector(5);
        }
        if (!_elements.contains(fieldInfo)) {
          _elements.addElement(fieldInfo);
        }
        break;
    }
  } // -- addFieldInfo
Пример #9
0
  @Override
  public boolean equals(Object obj) {
    if (this == obj) return true;

    MethodDeclaration dec = (MethodDeclaration) obj;
    if (dec != null) {
      // compare modifiers
      Vector<String> decMods = dec.get_modifiers();
      if (_modifiers != null && decMods != null) {
        for (String mod : decMods) if (!_modifiers.contains(mod)) return false;
      } else if (_modifiers == null ^ decMods == null) return false;

      // compare return types
      String decRetType = dec.get_returnType();
      if ((_returnType != null && decRetType != null && !_returnType.equals(decRetType))
          || (_returnType == null ^ decRetType == null)) return false;

      // compare names
      String decName = dec.get_name();
      if ((_name != null && decName != null && !_name.equals(decName))
          || (_name == null ^ decName == null)) return false;

      // compare parameters
      Vector<ParameterDeclaration> decParams = dec.get_params();
      if (_params != null && decParams != null) {
        for (ParameterDeclaration param : decParams) if (!_params.contains(param)) return false;
      } else if (_params == null ^ decParams == null) return false;

      return true;
    }

    return false;
  }
Пример #10
0
 public PyObject __call__(PyObject args[], String keywords[]) {
   // if(args[0].toString().endsWith(JAVA_IMPORT_PATH_ENTRY)){
   // return this;
   // }
   // System.out.println("CPythonImporter7: "+args[0]+"  "+args.length);
   // libPath = args[0].toString();
   String s = args[0].toString();
   if (knownPaths == null) {
     if (!libPaths.contains(s)) libPaths.add(s);
     return this;
   } else if (knownPaths.contains(s)) {
     if (!libPaths.contains(s)) libPaths.add(s);
     return this;
   }
   /*String suf = "."+getSystemDependendDynamicLibraryExtension();
   System.out.println(suf);
   File look = new File(args[0].toString());
   String[] ch = look.list();
   for (int i = 0; i < ch.length; ++i)
   {
   	//if (s.endsWith(suf))
   	{
   		//System.out.println("CPythonExtension handles "+args[0]);
   		//libPaths.add(args[0]);
   		//return this;
   	}
   }
   //return this;*/
   throw Py.ImportError("unable to handle");
 }
Пример #11
0
  /**
   * Suspends the thread that is currently on the processor on the specified event.
   *
   * <p>Note that the thread being suspended doesn't need to be running. It can also be waiting for
   * completion of a pagefault and be suspended on the IORB that is bringing the page in.
   *
   * <p>Thread's status must be changed to ThreadWaiting or higher, the processor set to idle, the
   * thread must be in the right waiting queue, and dispatch() must be called to give CPU control to
   * some other thread.
   *
   * @param event - event on which to suspend this thread. @OSPProject Threads
   */
  public void do_suspend(Event event) {
    // To suspend a thread, we must first figure out which state to suspend it to. As can
    // be seen from Figure 3.1, there are two candidates:

    // If the thread is running, then it is suspended to ThreadWaiting.
    if (this.getStatus() == ThreadRunning) {
      // Again steps 1-3 for changing ThreadRunning to another status.
      MMU.getPTBR().getTask().setCurrentThread(null);
      MMU.setPTBR(null);
      this.setStatus(ThreadWaiting);
    }

    // If it is already waiting, then the status is incremented
    // by 1. For instance, if the current status of the thread is ThreadWaiting then it should
    // become ThreadWaiting+1.
    else // if (this.getStatus() == ThreadWaiting) only accounted for threadWaiting not +1, +2, etc
    this.setStatus(this.getStatus() + 1); // Accounts for higher cases than +1; such as +2

    // We now must set the new thread status using the method
    // setStatus() and place it on the waiting queue to the event.
    // IF and ONLY IF it does not already exist on the queue.
    if (!(lowPriorityQueue.contains(this)) || !(highPriorityQueue.contains(this))) {
      // Move to waiting queue
      event.addThread(this);
    }

    // Finally, a new thread must be dispatched using a call to dispatch()
    dispatch();
  }
Пример #12
0
  private void evaluateTriggerables(Vector tv, TreeReference anchorRef) {
    // add all cascaded triggerables to queue
    for (int i = 0; i < tv.size(); i++) {
      Triggerable t = (Triggerable) tv.elementAt(i);
      if (t.canCascade()) {
        for (int j = 0; j < t.getTargets().size(); j++) {
          TreeReference target = (TreeReference) t.getTargets().elementAt(j);
          Vector triggered = (Vector) triggerIndex.get(target);
          if (triggered != null) {
            for (int k = 0; k < triggered.size(); k++) {
              Triggerable u = (Triggerable) triggered.elementAt(k);
              if (!tv.contains(u)) tv.addElement(u);
            }
          }
        }
      }
    }

    // 'triggerables' is topologically-ordered by dependencies, so evaluate the triggerables in 'tv'
    // in the order they appear in 'triggerables'
    for (int i = 0; i < triggerables.size(); i++) {
      Triggerable t = (Triggerable) triggerables.elementAt(i);
      if (tv.contains(t)) {
        evaluateTriggerable(t, anchorRef);
      }
    }
  }
 private void setAllowedInteractionModes(int[] allowedInteractionModes) {
   // add NO_INTERACTION_MODE if not provided
   Vector vAllowedSettings = new Vector();
   vAllowedSettings.addElement(new Integer(NO_INTERACTION_MODE));
   // collect only the known interaction modes from the set of provided interaction modes
   if (allowedInteractionModes != null) {
     for (int i = 0; i < allowedInteractionModes.length; i++) {
       if (interactionModeKnown(allowedInteractionModes[i])) {
         Integer allowedInteractionMode = new Integer(allowedInteractionModes[i]);
         if (!vAllowedSettings.contains(allowedInteractionMode)) {
           vAllowedSettings.addElement(allowedInteractionMode);
         }
       }
     }
   }
   // add the current interaction mode (if not already provided)
   Integer currentInteractionMode = new Integer(this.currentInteractionMode);
   if (!vAllowedSettings.contains(currentInteractionMode)) {
     vAllowedSettings.addElement(currentInteractionMode);
   }
   // copy the content of the vector int the int[]
   this.allowedInteractionModes = new int[vAllowedSettings.size()];
   for (int i = 0; i < vAllowedSettings.size(); i++) {
     this.allowedInteractionModes[i] = ((Integer) vAllowedSettings.elementAt(i)).intValue();
   }
 }
  /** Invoked by the HTTPClient. */
  public int requestHandler(Request req, Response[] resp) throws ModuleException {
    // parse Accept-Encoding header

    int idx;
    NVPair[] hdrs = req.getHeaders();
    for (idx = 0; idx < hdrs.length; idx++)
      if (hdrs[idx].getName().equalsIgnoreCase("Accept-Encoding")) break;

    Vector pae;
    if (idx == hdrs.length) {
      hdrs = Util.resizeArray(hdrs, idx + 1);
      req.setHeaders(hdrs);
      pae = new Vector();
    } else {
      try {
        pae = Util.parseHeader(hdrs[idx].getValue());
      } catch (ParseException pe) {
        throw new ModuleException(pe.toString());
      }
    }

    // done if "*;q=1.0" present

    HttpHeaderElement all = Util.getElement(pae, "*");
    if (all != null) {
      NVPair[] params = all.getParams();
      for (idx = 0; idx < params.length; idx++)
        if (params[idx].getName().equalsIgnoreCase("q")) break;

      if (idx == params.length) // no qvalue, i.e. q=1.0
      return REQ_CONTINUE;

      if (params[idx].getValue() == null || params[idx].getValue().length() == 0)
        throw new ModuleException("Invalid q value for \"*\" in " + "Accept-Encoding header: ");

      try {
        if (Float.valueOf(params[idx].getValue()).floatValue() > 0.) return REQ_CONTINUE;
      } catch (NumberFormatException nfe) {
        throw new ModuleException(
            "Invalid q value for \"*\" in " + "Accept-Encoding header: " + nfe.getMessage());
      }
    }

    // Add gzip, deflate and compress tokens to the Accept-Encoding header

    if (!pae.contains(new HttpHeaderElement("deflate")))
      pae.addElement(new HttpHeaderElement("deflate"));
    if (!pae.contains(new HttpHeaderElement("gzip"))) pae.addElement(new HttpHeaderElement("gzip"));
    if (!pae.contains(new HttpHeaderElement("x-gzip")))
      pae.addElement(new HttpHeaderElement("x-gzip"));
    if (!pae.contains(new HttpHeaderElement("compress")))
      pae.addElement(new HttpHeaderElement("compress"));
    if (!pae.contains(new HttpHeaderElement("x-compress")))
      pae.addElement(new HttpHeaderElement("x-compress"));

    hdrs[idx] = new NVPair("Accept-Encoding", Util.assembleHeader(pae));

    return REQ_CONTINUE;
  }
 /**
  * Determine whether the directory operation contains an SftpFile
  *
  * @param f
  * @return boolean
  */
 public boolean containsFile(SftpFile f) {
   return unchangedFiles.contains(f)
       || newFiles.contains(f)
       || updatedFiles.contains(f)
       || deletedFiles.contains(f)
       || recursedDirectories.contains(f.getAbsolutePath())
       || failedTransfers.containsKey(f);
 }
 /**
  * Handles click on checkbox for a list item.
  *
  * @param chkBox Checkbox view
  * @param id Id assigned to the list item
  */
 protected void toggleCheck(CheckBox chkBox, int id) {
   if (mSelectedItems.contains(id)) {
     mSelectedItems.removeElement(id);
   } else {
     mSelectedItems.add(id);
   }
   chkBox.setChecked(mSelectedItems.contains(id));
 }
 /**
  * Determine whether the operation contains a file.
  *
  * @param f
  * @return boolean
  */
 public boolean containsFile(File f) {
   return unchangedFiles.contains(f)
       || newFiles.contains(f)
       || updatedFiles.contains(f)
       || deletedFiles.contains(f)
       || recursedDirectories.contains(f)
       || failedTransfers.containsKey(f);
 }
Пример #18
0
  @Override
  public void grantAbilities(MOB mob, boolean isBorrowedClass) {
    super.grantAbilities(mob, isBorrowedClass);

    if (mob.playerStats() == null) {
      final List<AbilityMapper.AbilityMapping> V =
          CMLib.ableMapper()
              .getUpToLevelListings(ID(), mob.charStats().getClassLevel(ID()), false, false);
      for (final AbilityMapper.AbilityMapping able : V) {
        final Ability A = CMClass.getAbility(able.abilityID);
        if ((A != null)
            && ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_CHANT)
            && (!CMLib.ableMapper().getDefaultGain(ID(), true, A.ID())))
          giveMobAbility(
              mob,
              A,
              CMLib.ableMapper().getDefaultProficiency(ID(), true, A.ID()),
              CMLib.ableMapper().getDefaultParm(ID(), true, A.ID()),
              isBorrowedClass);
      }
      return;
    }

    final Vector grantable = new Vector();

    final int level = mob.charStats().getClassLevel(this);
    int numChants = 2;
    for (final Enumeration<Ability> a = CMClass.abilities(); a.hasMoreElements(); ) {
      final Ability A = a.nextElement();
      if ((CMLib.ableMapper().getQualifyingLevel(ID(), true, A.ID()) == level)
          && ((CMLib.ableMapper().getQualifyingLevel(ID(), true, A.ID()) <= 25)
              && (!CMLib.ableMapper().getSecretSkill(ID(), true, A.ID()))
              && (!CMLib.ableMapper().getDefaultGain(ID(), true, A.ID()))
              && ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_CHANT))) {
        if (!grantable.contains(A.ID())) grantable.addElement(A.ID());
      }
    }
    for (int a = 0; a < mob.numAbilities(); a++) {
      final Ability A = mob.fetchAbility(a);
      if (grantable.contains(A.ID())) {
        grantable.remove(A.ID());
        numChants--;
      }
    }
    for (int i = 0; i < numChants; i++) {
      if (grantable.size() == 0) break;
      final String AID = (String) grantable.elementAt(CMLib.dice().roll(1, grantable.size(), -1));
      if (AID != null) {
        grantable.removeElement(AID);
        giveMobAbility(
            mob,
            CMClass.getAbility(AID),
            CMLib.ableMapper().getDefaultProficiency(ID(), true, AID),
            CMLib.ableMapper().getDefaultParm(ID(), true, AID),
            isBorrowedClass);
      }
    }
  }
Пример #19
0
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;

    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;

    final boolean success = proficiencyCheck(mob, 0, auto);
    if (success) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              null,
              this,
              verbalCastCode(mob, null, auto),
              auto
                  ? ""
                  : L("^S<S-NAME> @x1 for knowledge of the lower law here.^?", prayWord(mob)));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        final Area O = CMLib.law().getLegalObject(mob.location());
        final LegalBehavior B = CMLib.law().getLegalBehavior(mob.location());
        if ((B == null) || (O == null)) mob.tell(L("No lower law is established here."));
        else {
          final Law L = B.legalInfo(O);
          final Vector<String> crimes = new Vector<String>();
          possiblyAddLaw(L, crimes, "TRESPASSING");
          possiblyAddLaw(L, crimes, "ASSAULT");
          possiblyAddLaw(L, crimes, "MURDER");
          possiblyAddLaw(L, crimes, "NUDITY");
          possiblyAddLaw(L, crimes, "ARMED");
          possiblyAddLaw(L, crimes, "RESISTINGARREST");
          possiblyAddLaw(L, crimes, "PROPERTYROB");
          for (final String key : L.abilityCrimes().keySet())
            if (key.startsWith("$")) crimes.add(key.substring(1));
          if (L.taxLaws().containsKey("TAXEVASION"))
            crimes.add(((String[]) L.taxLaws().get("TAXEVASION"))[Law.BIT_CRIMENAME]);
          for (int x = 0; x < L.bannedSubstances().size(); x++) {
            final String name = L.bannedBits().get(x)[Law.BIT_CRIMENAME];
            if (!crimes.contains(name)) crimes.add(name);
          }
          for (int x = 0; x < L.otherCrimes().size(); x++) {
            final String name = L.otherBits().get(x)[Law.BIT_CRIMENAME];
            if (!crimes.contains(name)) crimes.add(name);
          }
          mob.tell(
              L(
                  "The following lower crimes are divinely revealed to you: @x1.",
                  CMLib.english().toEnglishStringList(crimes.toArray(new String[0]))));
        }
      }
    } else
      beneficialWordsFizzle(mob, null, L("<S-NAME> @x1, but nothing is revealed.", prayWord(mob)));

    return success;
  }
Пример #20
0
  /**
   * Adds an owner. Only owners can modify ACL contents. The caller principal must be an owner of
   * the ACL in order to invoke this method. That is, only an owner can add another owner. The
   * initial owner is configured at ACL construction time.
   *
   * @param caller the principal invoking this method. It must be an owner of the ACL.
   * @param owner the owner that should be added to the list of owners.
   * @return true if successful, false if owner is already an owner.
   * @exception NotOwnerException if the caller principal is not an owner of the ACL.
   */
  public boolean addOwner(Principal caller, Principal owner) throws NotOwnerException {
    if (!ownerList.contains(caller)) throw new NotOwnerException();

    if (ownerList.contains(owner)) {
      return false;
    } else {
      ownerList.addElement(owner);
      return true;
    }
  }
  private void getWordsFromPages()
      throws URISyntaxException, UnsafeContentTypeException, IOException {
    // Content-XXXXXXX.html pages only, because they contain all the contents
    // and their respective URIs won't change over time
    InputStream filterInput = null;
    OutputStream filterOutput = null;
    ArrayBucket input = null;
    NullBucket output = null;
    for (final Content content : new FlogFactory(flog).getContentsTreeMap(false).values()) {
      NullFilterCallback nullFC = new NullFilterCallback();
      input =
          new ArrayBucket(
              ContentSyntax.parseSomeString(content.getContent(), content.getContentSyntax())
                  .getBytes("UTF-8"));
      output = new NullBucket();
      filterInput = input.getInputStream();
      filterOutput = output.getOutputStream();
      ContentFilter.filter(
          filterInput,
          filterOutput,
          "text/html",
          new URI("http://whocares.co:12345/"),
          nullFC,
          null,
          null);
      filterInput.close();
      filterOutput.close();
      input.free();
      output.free();
      final String cURI = "Content-" + content.getID() + ".html";
      this.pageIDs.add(cURI);
      final int pageID = this.pageIDs.indexOf(cURI);
      for (String w : nullFC.words.keySet()) {
        if (!this.ourWords.containsKey(w)) {
          this.ourWords.put(w, new HashMap<Integer, Vector<Long>>());
        }
        final HashMap<Integer, Vector<Long>> container = this.ourWords.get(w);
        if (!container.containsKey(pageID)) {
          container.put(pageID, new Vector<Long>());
        }
        final Vector<Long> subContainer = container.get(pageID);
        for (Long position : nullFC.words.get(w)) {
          if (!subContainer.contains(position)) {
            subContainer.add(position);
          }
        }

        final Byte firstMD5 = Byte.valueOf(DataFormatter.getMD5(w).substring(0, 1), 16);
        final Vector<String> md5Container = this.wordsByMD5.get(firstMD5);
        if (!md5Container.contains(w)) {
          md5Container.add(w);
        }
      }
    }
  }
Пример #22
0
 protected StringBuilder getAbilities(
     MOB viewerM, MOB ableM, Vector ofTypes, int mask, boolean addQualLine, int maxLevel) {
   final int COL_LEN1 = ListingLibrary.ColFixer.fixColWidth(3.0, viewerM);
   final int COL_LEN2 = ListingLibrary.ColFixer.fixColWidth(18.0, viewerM);
   final int COL_LEN3 = ListingLibrary.ColFixer.fixColWidth(19.0, viewerM);
   int highestLevel = 0;
   final int lowestLevel = ableM.phyStats().level() + 1;
   final StringBuilder msg = new StringBuilder("");
   for (final Enumeration<Ability> a = ableM.allAbilities(); a.hasMoreElements(); ) {
     final Ability A = a.nextElement();
     int level = CMLib.ableMapper().qualifyingLevel(ableM, A);
     if (level < 0) level = 0;
     if ((A != null)
         && (level > highestLevel)
         && (level < lowestLevel)
         && (ofTypes.contains(Integer.valueOf(A.classificationCode() & mask))))
       highestLevel = level;
   }
   if ((maxLevel >= 0) && (maxLevel < highestLevel)) highestLevel = maxLevel;
   for (int l = 0; l <= highestLevel; l++) {
     final StringBuilder thisLine = new StringBuilder("");
     int col = 0;
     for (final Enumeration<Ability> a = ableM.allAbilities(); a.hasMoreElements(); ) {
       final Ability A = a.nextElement();
       int level = CMLib.ableMapper().qualifyingLevel(ableM, A);
       if (level < 0) level = 0;
       if ((A != null)
           && (level == l)
           && (ofTypes.contains(Integer.valueOf(A.classificationCode() & mask)))) {
         if (thisLine.length() == 0) thisLine.append("\n\rLevel ^!" + l + "^?:\n\r");
         if ((++col) > 3) {
           thisLine.append("\n\r");
           col = 1;
         }
         thisLine.append(
             "^N[^H"
                 + CMStrings.padRight(Integer.toString(A.proficiency()), COL_LEN1)
                 + "%^?]^N"
                 + " " // +(A.isAutoInvoked()?"^H.^N":" ")
                 + CMStrings.padRight(
                     "^<HELP^>" + A.name() + "^</HELP^>", (col == 3) ? COL_LEN2 : COL_LEN3));
       }
     }
     if (thisLine.length() > 0) msg.append(thisLine);
   }
   if (msg.length() == 0) msg.append(L("^!None!^?"));
   else if (addQualLine)
     msg.append(
         L(
             "\n\r\n\rUse QUALIFY to see additional skills you can GAIN.")); // ^H.^N =
                                                                             // passive/auto-invoked."));
   return msg;
 }
  private static Vector actionsVector(String actions) {
    Vector v = new Vector();
    StringTokenizer t = new StringTokenizer(actions.toUpperCase(), ",");
    while (t.hasMoreTokens()) {
      String action = t.nextToken().trim();
      v.add(action.toLowerCase());
    }

    if (v.contains(SCHEDULE_ACTION) && !v.contains(LIFECYCLE_ACTION)) v.add(LIFECYCLE_ACTION);

    return v;
  }
Пример #24
0
  public String composition() {
    String comp = "";
    if (trail != null) {
      String t = trail.toString();
      final int[] counts = new int[stuff.length];
      int x = t.indexOf(';');
      while (x >= 0) {
        final int q = CMath.s_int(t.substring(0, x));
        t = t.substring(x + 1);
        if (q >= 0) {
          for (int i = 0; i < stuff.length; i++) {
            if (CMath.s_int(stuff[i][0]) == q) counts[i]++;
          }
        }
        x = t.indexOf(';');
      }
      int wa = -1;
      for (int i = 0; i < stuff.length; i++)
        if (CMath.s_int(stuff[i][0]) == CMMsg.TYP_WEAPONATTACK) {
          wa = i;
          break;
        }

      if (wa >= 0) counts[wa] = counts[wa] / 25;

      final Vector<Integer> V = new Vector<Integer>();
      while (V.size() < counts.length) {
        int high = -1;
        int which = -1;
        for (int i = 0; i < counts.length; i++) {
          if ((counts[i] > high) && (!V.contains(Integer.valueOf(i)))) {
            high = counts[i];
            which = i;
          }
        }
        if (which >= 0) V.addElement(Integer.valueOf(which));
      }
      final Vector<Integer> V2 = new Vector<Integer>();
      for (int i = 0; i < 3; i++) {
        final Integer ref = V.elementAt(i);
        Integer which = null;
        while ((which == null) || (V2.contains(which))) {
          final Integer w = V.elementAt(CMLib.dice().roll(1, V.size(), -1));
          if (counts[w.intValue()] == counts[ref.intValue()]) which = w;
        }
        V2.addElement(which);
        comp += which.intValue() + ";" + counts[which.intValue()] + ";";
      }
    }
    return comp;
  }
Пример #25
0
  /**
   * Deletes an owner. If this is the last owner in the ACL, an exception is raised.
   *
   * <p>The caller principal must be an owner of the ACL in order to invoke this method.
   *
   * @param caller the principal invoking this method. It must be an owner of the ACL.
   * @param owner the owner to be removed from the list of owners.
   * @return true if successful, false if owner is already an owner.
   * @exception NotOwnerException if the caller principal is not an owner of the ACL.
   * @exception LastOwnerException if there is only one owner left, so that deleteOwner would leave
   *     the ACL owner-less.
   */
  public boolean deleteOwner(Principal caller, Principal owner)
      throws NotOwnerException, LastOwnerException {

    if (!ownerList.contains(caller)) throw new NotOwnerException();

    if (!ownerList.contains(owner)) {
      return false;
    } else {
      if (ownerList.size() == 1) throw new LastOwnerException();

      ownerList.removeElement(owner);
      return true;
    }
  }
Пример #26
0
  /** implemented. */
  public void test_propertyNames() {
    th.checkPoint("propertyNames()java.util.Enumeration");
    Properties p = new Properties();
    try {
      p.load(bin);
    } catch (Exception e) {
    }

    Enumeration en = p.propertyNames();
    Enumeration ek = p.keys();
    boolean ok = true;
    Vector v = new Vector();
    Enumeration ek2 = p.keys();
    while (ek2.hasMoreElements()) {
      v.add(ek2.nextElement());
    }
    while (ek.hasMoreElements() && en.hasMoreElements()) {
      ek.nextElement();
      Object next = en.nextElement();
      if (!v.contains(next)) {
        ok = false;
        th.debug(next + " not in " + v);
      }
    }
    th.check(ok, "all elements are the same");
    th.check(
        !ek.hasMoreElements() && !en.hasMoreElements(), "make sure both enumerations are empty");
    p = new Properties(defProps);
    resetStreams();
    try {
      p.load(bin);
    } catch (Exception e) {
    }
    v.add("Smart");
    v.add("animal");
    en = p.propertyNames();
    ok = true;
    Object o;
    while (en.hasMoreElements()) {
      o = en.nextElement();
      if (v.contains(o)) v.removeElement(o);
      else {
        ok = false;
        th.debug("got extra element: " + o);
      }
    }
    th.check(ok, "see if no double were generated");
    th.check(v.isEmpty(), "check if all names were mentioned -- got:" + v);
  }
Пример #27
0
  @Override
  public void visitLabel(Label arg0) {
    if (removingMethodBody()) {
      return;
    }

    if (allStartingTryCatchingBlockLabels != null
        && allStartingTryCatchingBlockLabels.contains(arg0)) {
      ++tryCatchDepth;
    } else if (allEndingTryCatchingBlockLabels != null
        && allEndingTryCatchingBlockLabels.contains(arg0)) {
      --tryCatchDepth;
    }
    super.visitLabel(arg0);
  }
Пример #28
0
  /**
   * Returns a vector with column names of the dataset, listed in "list". If a column cannot be
   * found or the list is empty the ones from the default list are returned.
   *
   * @param list comma-separated list of attribute names
   * @param defaultList the default list of attribute names
   * @param inst the instances to get the attribute names from
   * @return a vector containing attribute names
   */
  protected Vector determineColumnNames(String list, String defaultList, Instances inst) {
    Vector result;
    Vector atts;
    StringTokenizer tok;
    int i;
    String item;

    // get attribute names
    atts = new Vector();
    for (i = 0; i < inst.numAttributes(); i++) atts.add(inst.attribute(i).name().toLowerCase());

    // process list
    result = new Vector();
    tok = new StringTokenizer(list, ",");
    while (tok.hasMoreTokens()) {
      item = tok.nextToken().toLowerCase();
      if (atts.contains(item)) {
        result.add(item);
      } else {
        result.clear();
        break;
      }
    }

    // do we have to return defaults?
    if (result.size() == 0) {
      tok = new StringTokenizer(defaultList, ",");
      while (tok.hasMoreTokens()) result.add(tok.nextToken().toLowerCase());
    }

    return result;
  }
Пример #29
0
 public void removeConnectionListener(NCCPConnection.ConnectionListener l) {
   if (listeners.contains(l)) {
     // ExpCoordinator.printer.print(new String("NCCPConnection.removeConnectionListener to " +
     // toString()), 2);
     listeners.remove(l);
   }
 }
Пример #30
0
 public void addConnectionListener(NCCPConnection.ConnectionListener l) {
   if (!listeners.contains(l)) {
     ExpCoordinator.printer.print(
         new String("NCCPConnection.addConnectionListener to " + toString()), 6);
     listeners.add(l);
   }
 }