コード例 #1
0
ファイル: MPopButton.java プロジェクト: timburrow/OpenVnmrJ
 /**
  * notify listeners of a popup selection
  *
  * @param popStr popup selection string
  */
 void popNotify(String popStr) {
   Enumeration en = popListeners.elements();
   for (; en.hasMoreElements(); ) {
     PopListener listener = (PopListener) en.nextElement();
     listener.popHappened(popStr);
   }
 } // popNotify()
コード例 #2
0
  // ------------------------------------------------------------------------
  // SCREEN PAINTER
  // Put some function here to paint whatever you want over the screen before and after
  // all edges and nodes have been painted.
  public void PaintScreenBefore(Graphics g) {

    Dimension d = MainClass.mainFrame.GetGraphDisplayPanel().getSize();
    NodeInfo nodeInfo;
    int x = 0;
    int y = 0;
    int step = 10;

    for (; x < d.width; x += step) {
      for (y = 0; y < d.height; y += step) {
        double val = 0;
        double sum = 0;
        double total = 0;
        double min = 10000000;
        for (Enumeration nodes = proprietaryNodeInfo.elements(); nodes.hasMoreElements(); ) {
          nodeInfo = (NodeInfo) nodes.nextElement();
          double dist = distance(x, y, nodeInfo.centerX, nodeInfo.centerY);
          if (nodeInfo.value != -1 && nodeInfo.nodeNumber.intValue() != 1) { // 121
            if (dist < min) min = dist;
            val += ((double) nodeInfo.value) / dist / dist;
            sum += (1 / dist / dist);
          }
        }
        int reading = (int) (val / sum);
        reading = reading >> 2;
        if (reading > 255) reading = 255;
        g.setColor(new Color(reading, reading, reading));
        g.fillRect(x, y, step, step);
      }
    }
  }
コード例 #3
0
ファイル: CoffeeUtensils.java プロジェクト: bbailey/ewok
 public void reloadCharClasses(CharClass oldC) {
   for (Enumeration e = CMLib.map().rooms(); e.hasMoreElements(); ) {
     Room room = (Room) e.nextElement();
     for (int i = 0; i < room.numInhabitants(); i++) {
       MOB M = room.fetchInhabitant(i);
       if (M == null) continue;
       for (int c = 0; c < M.baseCharStats().numClasses(); c++)
         if (M.baseCharStats().getMyClass(c) == oldC) {
           M.baseCharStats().setMyClasses(M.baseCharStats().getMyClassesStr());
           break;
         }
       for (int c = 0; c < M.charStats().numClasses(); c++)
         if (M.charStats().getMyClass(c) == oldC) {
           M.charStats().setMyClasses(M.charStats().getMyClassesStr());
           break;
         }
     }
     for (e = CMLib.players().players(); e.hasMoreElements(); ) {
       MOB M = (MOB) e.nextElement();
       for (int c = 0; c < M.baseCharStats().numClasses(); c++)
         if (M.baseCharStats().getMyClass(c) == oldC) {
           M.baseCharStats().setMyClasses(M.baseCharStats().getMyClassesStr());
           break;
         }
       for (int c = 0; c < M.charStats().numClasses(); c++)
         if (M.charStats().getMyClass(c) == oldC) {
           M.charStats().setMyClasses(M.charStats().getMyClassesStr());
           break;
         }
     }
   }
 }
コード例 #4
0
 /**
  * Callback when user selects menu item (find it by comparing menu id's)
  *
  * <p>Param menuId = the id of the selected item
  */
 public boolean onSelected(int menuId) {
   for (Enumeration enu = mVector.elements(); enu.hasMoreElements(); ) {
     TrayIconPopupItem item = (TrayIconPopupItem) enu.nextElement();
     if (item.onSelected(menuId)) return true;
   }
   return false;
 }
コード例 #5
0
ファイル: MoquiStart.java プロジェクト: emer3/moqui
  public MoquiStart(ClassLoader parent, boolean loadWebInf) {
    super(parent);
    this.loadWebInf = loadWebInf;

    URL wrapperWarUrl = null;
    try {
      // get outer file (the war file)
      pd = getClass().getProtectionDomain();
      CodeSource cs = pd.getCodeSource();
      wrapperWarUrl = cs.getLocation();
      outerFile = new JarFile(new File(wrapperWarUrl.toURI()));

      // allow for classes in the outerFile as well
      jarFileList.add(outerFile);

      Enumeration<JarEntry> jarEntries = outerFile.entries();
      while (jarEntries.hasMoreElements()) {
        JarEntry je = jarEntries.nextElement();
        if (je.isDirectory()) continue;
        // if we aren't loading the WEB-INF files and it is one, skip it
        if (!loadWebInf && je.getName().startsWith("WEB-INF")) continue;
        // get jars, can be anywhere in the file
        String jeName = je.getName().toLowerCase();
        if (jeName.lastIndexOf(".jar") == jeName.length() - 4) {
          File file = createTempFile(je);
          jarFileList.add(new JarFile(file));
        }
      }
    } catch (Exception e) {
      System.out.println("Error loading jars in war file [" + wrapperWarUrl + "]: " + e.toString());
    }
  }
コード例 #6
0
  @Override
  public boolean tick(Tickable ticking, int tickID) {
    if (!super.tick(ticking, tickID)) return false;

    if (affected == null) return false;
    if (!(affected instanceof MOB)) return false;
    final MOB mob = (MOB) affected;
    if (mob.location().numInhabitants() == 1) return true;
    final Vector choices = new Vector();
    for (final Enumeration<Ability> a = mob.effects(); a.hasMoreElements(); ) {
      final Ability A = a.nextElement();
      if ((A != null)
          && (A.canBeUninvoked())
          && (!A.ID().equals(ID()))
          && (A.abstractQuality() == Ability.QUALITY_MALICIOUS)
          && (((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SPELL)
              || ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_PRAYER))
          && (!A.isAutoInvoked())) choices.addElement(A);
    }
    if (choices.size() == 0) return true;
    final MOB target = mob.location().fetchRandomInhabitant();
    final Ability thisOne = (Ability) choices.elementAt(CMLib.dice().roll(1, choices.size(), -1));
    if ((target == null) || (thisOne == null) || (target.fetchEffect(ID()) != null)) return true;
    if (CMLib.dice().rollPercentage() > (target.charStats().getSave(CharStats.STAT_SAVE_DISEASE))) {
      ((Ability) this.copyOf()).invoke(target, target, true, 0);
      if (target.fetchEffect(ID()) != null)
        ((Ability) thisOne.copyOf()).invoke(target, target, true, 0);
    } else spreadImmunity(target);
    return true;
  }
コード例 #7
0
  public static Map<String, String> readProperties(InputStream inputStream) {
    Map<String, String> propertiesMap = null;
    try {
      propertiesMap = new LinkedHashMap<String, String>();

      Properties properties = new Properties();
      properties.load(inputStream);

      Enumeration<?> enumeration = properties.propertyNames();
      while (enumeration.hasMoreElements()) {
        String key = (String) enumeration.nextElement();
        String value = (String) properties.get(key);
        propertiesMap.put(key, value);
      }
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    } finally {
      if (inputStream != null) {
        try {
          inputStream.close();
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
    }
    return propertiesMap;
  }
コード例 #8
0
ファイル: LoginServlet.java プロジェクト: Gravezappa/cafe
  @Override
  public void doPost(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
    resp.setContentType(TEXT_HTML);
    Enumeration<String> parameterNames = req.getParameterNames();
    Map<String, String> params = new HashMap<>();
    while (parameterNames.hasMoreElements()) {
      String current = parameterNames.nextElement();
      params.put(current, req.getParameter(current));
    }

    if (params.get(LOGIN) != null) {
      UserDto userDto = userController.getByLogin(params.get(EMAIL));
      User user = userDto.getUser();
      if (user == null || !user.getPassword().equals(params.get(PASSWORD))) {
        req.setAttribute(LOGIN_FAILED, true);
      } else {
        HttpSession session = req.getSession(true);
        session.setAttribute(USER, user);
      }
    }
    if (params.get(REGISTER) != null) {
      resp.sendRedirect("/cafe/register");
    } else {
      if (params.get(LOGOUT) != null) {
        HttpSession session = req.getSession(true);
        session.removeAttribute(USER);
        session.removeAttribute(ORDER);
      }
      RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(MAIN_JSP);
      dispatcher.forward(req, resp);
    }
  }
コード例 #9
0
ファイル: JDRUtils.java プロジェクト: esprayer/EMPPlatform
  /**
   * 判断相等
   *
   * @param params0
   * @param params1
   * @return
   */
  public static boolean equals(Hashtable params0, Hashtable params1) {
    // 相等,包括均为空
    if (params0 == null && params1 == null) {
      return true;
    }
    // 非空
    if (params0 == null || params1 == null) {
      return false;
    }

    if (params0.size() != params1.size()) {
      return false;
    }
    // 键和值相等
    for (Enumeration e = params0.keys(); e.hasMoreElements(); ) {
      String key0 = (String) e.nextElement();
      String val0 = (String) params0.get(key0);

      if (params1.containsKey(key0)) {
        String val1 = (String) params1.get(key0);
        if (!val0.equals(val1)) {
          return false;
        }
      } else {
        return false;
      }
    }
    return true;
  }
コード例 #10
0
ファイル: HTDemo.java プロジェクト: DenisKipchakbaev/Schildt
  public static void main(String args[]) {
    Hashtable<String, Double> balance = new Hashtable<String, Double>();

    Enumeration<String> names;
    String str;
    double bal;

    balance.put("John Doe", 3434.34);
    balance.put("Tom Smith", 123.22);
    balance.put("Jane Baker", 1378.00);
    balance.put("Tod Hall", 99.22);
    balance.put("Ralph Smith", -19.08);

    // Show all balances in hashtable.
    names = balance.keys();
    while (names.hasMoreElements()) {
      str = names.nextElement();
      System.out.println(str + ": " + balance.get(str));
    }

    System.out.println();

    // Deposit 1,000 into John Doe's account.
    bal = balance.get("John Doe");
    balance.put("John Doe", bal + 1000);
    System.out.println("John Doe's new balance: " + balance.get("John Doe"));
  }
コード例 #11
0
  /*
   * Return a view sending all params from a request
   *
   * @param request HttpServletRequest to send to the view
   * @param viewname String with the view name to load
   * @return ModelAndView return a view with viewname
   */
  public static ModelAndView buildViewParams(HttpServletRequest request, String viewname) {

    Map<String, Object> map = new HashMap<String, Object>();

    ModelAndView mav = new ModelAndView(viewname, map);

    Enumeration<String> parameterNames = request.getParameterNames();

    while (parameterNames.hasMoreElements()) {
      String paramName = parameterNames.nextElement();

      // if the request var is a Array
      if ((request.getParameterValues(paramName).getClass().isArray())
          // if Array size is more than 1
          && (request.getParameterValues(paramName).length > 1)) {
        map.put(paramName, Arrays.toString(request.getParameterValues(paramName)));
      } else
        // if the request var is a simple var
        map.put(paramName, request.getParameter(paramName));
    }

    mav.addAllObjects(map);

    // return view
    return mav;
  }
コード例 #12
0
  /**
   * Returns a Set of Strings containing the names of all available algorithms or types for the
   * specified Java cryptographic service (e.g., Signature, MessageDigest, Cipher, Mac, KeyStore).
   * Returns an empty Set if there is no provider that supports the specified service or if
   * serviceName is null. For a complete list of Java cryptographic services, please see the <a
   * href="../../../guide/security/CryptoSpec.html">Java Cryptography Architecture API Specification
   * &amp; Reference</a>. Note: the returned set is immutable.
   *
   * @param serviceName the name of the Java cryptographic service (e.g., Signature, MessageDigest,
   *     Cipher, Mac, KeyStore). Note: this parameter is case-insensitive.
   * @return a Set of Strings containing the names of all available algorithms or types for the
   *     specified Java cryptographic service or an empty set if no provider supports the specified
   *     service.
   * @since 1.4
   */
  public static Set<String> getAlgorithms(String serviceName) {

    if ((serviceName == null) || (serviceName.length() == 0) || (serviceName.endsWith("."))) {
      return Collections.EMPTY_SET;
    }

    HashSet result = new HashSet();
    Provider[] providers = Security.getProviders();

    for (int i = 0; i < providers.length; i++) {
      // Check the keys for each provider.
      for (Enumeration e = providers[i].keys(); e.hasMoreElements(); ) {
        String currentKey = ((String) e.nextElement()).toUpperCase();
        if (currentKey.startsWith(serviceName.toUpperCase())) {
          // We should skip the currentKey if it contains a
          // whitespace. The reason is: such an entry in the
          // provider property contains attributes for the
          // implementation of an algorithm. We are only interested
          // in entries which lead to the implementation
          // classes.
          if (currentKey.indexOf(" ") < 0) {
            result.add(currentKey.substring(serviceName.length() + 1));
          }
        }
      }
    }
    return Collections.unmodifiableSet(result);
  }
コード例 #13
0
  /**
   * Looks up providers, and returns the property (and its associated provider) mapping the key, if
   * any. The order in which the providers are looked up is the provider-preference order, as
   * specificed in the security properties file.
   */
  private static ProviderProperty getProviderProperty(String key) {
    ProviderProperty entry = null;

    List providers = Providers.getProviderList().providers();
    for (int i = 0; i < providers.size(); i++) {

      String matchKey = null;
      Provider prov = (Provider) providers.get(i);
      String prop = prov.getProperty(key);

      if (prop == null) {
        // Is there a match if we do a case-insensitive property name
        // comparison? Let's try ...
        for (Enumeration e = prov.keys(); e.hasMoreElements() && prop == null; ) {
          matchKey = (String) e.nextElement();
          if (key.equalsIgnoreCase(matchKey)) {
            prop = prov.getProperty(matchKey);
            break;
          }
        }
      }

      if (prop != null) {
        ProviderProperty newEntry = new ProviderProperty();
        newEntry.className = prop;
        newEntry.provider = prov;
        return newEntry;
      }
    }

    return entry;
  }
コード例 #14
0
  /** Opens the Serial port with the baud and port_name given */
  public boolean OpenSerial(int baud, String port) {
    CommPortIdentifier portId = null;
    Enumeration portEnum = CommPortIdentifier.getPortIdentifiers();

    while (portEnum.hasMoreElements()) {
      CommPortIdentifier currPortId = (CommPortIdentifier) portEnum.nextElement();
      if (currPortId.getName().equals(port)) {
        portId = currPortId;
        break;
      }
    }

    if (portId == null) {
      System.err.println("Can not open serial port");
      return false;
    }

    try {
      serialPort = (SerialPort) portId.open(this.getClass().getName(), 2000);

      serialPort.setSerialPortParams(
          baud, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);

      input = serialPort.getInputStream();
      output = serialPort.getOutputStream();

      serialPort.addEventListener(this);
      serialPort.notifyOnDataAvailable(true);
      Thread.sleep(1500);
    } catch (Exception e) {
      return false;
    }

    return true;
  }
コード例 #15
0
ファイル: DecisionTree.java プロジェクト: rptiwari/LAITS
  public void updateNodeName(String oldName, String newName) {
    // Update in the whole Tree
    if (!oldName.isEmpty() && !newName.isEmpty()) {

      Enumeration en = root.depthFirstEnumeration();

      while (en.hasMoreElements()) {
        DecisionTreeNode node = (DecisionTreeNode) en.nextElement();
        if (node.nodeName.compareTo(oldName) == 0) {
          node.nodeName = newName;
        }
      }
    }

    // Update in the added Node List
    ArrayList<String> nodesToBeAdded = new ArrayList<String>(addedNodes);
    addedNodes.clear();

    for (String node : nodesToBeAdded) {
      String[] arr = node.split(":");
      if (arr[1].compareTo(oldName) == 0) {
        addedNodes.add(arr[0] + ":" + newName + ":" + arr[2]);
      } else {
        addedNodes.add(node);
      }
    }

    // Update in the correctNode list
    correctNodes.put(newName, correctNodes.get(oldName));
    correctNodes.remove(oldName);
  }
コード例 #16
0
ファイル: JDRUtils.java プロジェクト: esprayer/EMPPlatform
  /** 打开查询结果 */
  public static String[] openQuery(Hashtable params) {

    JParamObject PO = new JParamObject();

    for (Enumeration e = params.keys(); e.hasMoreElements(); ) {
      String key = (String) e.nextElement();
      String val = (String) params.get(key);
      PO.SetValueByParamName(key, val);
    }
    String[] queryResult = new String[2];
    JResponseObject RO =
        (JResponseObject)
            JActiveDComDM.AbstractDataActiveFramework.InvokeObjectMethod(
                "DataReport", "OpenQuery", PO, "");
    String XMLStr = (String) RO.ResponseObject;
    if (RO != null && RO.ResponseObject != null) {
      XMLStr = (String) RO.ResponseObject;
      JXMLBaseObject XMLObj = new JXMLBaseObject(XMLStr);
      Element queryElmt = XMLObj.GetElementByName("Query");
      // 格式
      queryResult[0] = queryElmt.getAttributeValue("QueryFormat");
      // 数据
      queryResult[0] = queryElmt.getAttributeValue("QueryData");
    }
    return queryResult;
  }
コード例 #17
0
ファイル: MonitorFilter.java プロジェクト: Rikatouka/net.jxta
  /** {@inheritDoc} */
  public void initializeFrom(Element element) throws DocumentSerializationException {
    for (Enumeration e = element.getChildren(); e.hasMoreElements(); ) {
      Element serviceElement = (TextElement) e.nextElement();
      String tagName = (String) serviceElement.getKey();

      if (tagName.equals("service")) {
        try {
          ModuleClassID moduleClassID =
              (ModuleClassID)
                  IDFactory.fromURI(
                      new URI(
                          DocumentSerializableUtilities.getString(
                              serviceElement, "moduleClassID", "ERROR")));

          try {
            ServiceMonitorFilter serviceMonitorFilter =
                MonitorResources.createServiceMonitorFilter(moduleClassID);
            serviceMonitorFilter.init(moduleClassID);
            Element serviceMonitorFilterElement =
                DocumentSerializableUtilities.getChildElement(serviceElement, "serviceFilter");
            serviceMonitorFilter.initializeFrom(serviceMonitorFilterElement);
            serviceMonitorFilters.put(moduleClassID, serviceMonitorFilter);
          } catch (Exception ex) {
            if (unknownModuleClassIDs == null) unknownModuleClassIDs = new LinkedList();

            unknownModuleClassIDs.add(moduleClassID);
          }
        } catch (URISyntaxException jex) {
          throw new DocumentSerializationException("Can't get ModuleClassID", jex);
        }
      }
    }
  }
コード例 #18
0
  protected final void loadChildren(DynamicNode node) throws DbException {
    if (node.hasLoaded() || node.isLeaf()) return;
    node.setHasLoaded();
    Object userObject = node.getUserObject();
    if (userObject == ROOT) return;
    SrVector children = new SrVector(10);
    boolean isSorted = true;
    DbObject dbParent = null;
    if (userObject == DB_RAM) {
      Db[] dbs = Db.getDbs();
      for (int i = 0; i < dbs.length; i++) {
        if (dbs[i] instanceof DbRAM) insertProjects(children, dbs[i]);
      }
    } else if (userObject instanceof Db) {
      insertProjects(children, (Db) userObject);
    } else {
      dbParent = (DbObject) userObject;
      dbParent.getDb().beginTrans(Db.READ_TRANS);
      insertComponents(children, dbParent);
      isSorted = childrenAreSorted(dbParent);
      dbParent.getDb().commitTrans();
    }

    if (isSorted) {
      children.sort(getComparator(dbParent));
    }

    ArrayList groupNodeList = new ArrayList();
    DynamicNode groupNode = null;
    Enumeration enumeration = children.elements();
    while (enumeration.hasMoreElements()) {
      DynamicNode childNode = (DynamicNode) enumeration.nextElement();
      GroupParams group = childNode.getGroupParams();
      if (group.name == null) {
        node.add(childNode);
      } else {
        if (groupNode == null) {
          groupNode = createGroupNode(group);
          node.add(groupNode);
          groupNodeList.add(groupNode);
        } else if (!groupNode.toString().equals(group.name)) {
          boolean groupFound = false;
          for (int i = 0; i < groupNodeList.size(); i++) {
            groupNode = (DynamicNode) groupNodeList.get(i);
            if (groupNode.toString().equals(group.name)) {
              groupFound = true;
              break;
            }
          }
          if (!groupFound) {
            groupNode = createGroupNode(group);
            node.add(groupNode);
            groupNodeList.add(groupNode);
          }
        }
        groupNode.add(childNode);
      }
    }
    groupNodeList.clear();
  }
コード例 #19
0
  protected void unpackComponents() throws IOException, FileNotFoundException {
    File applicationPackage = new File(getApplication().getPackageResourcePath());
    File componentsDir = new File(sGREDir, "components");
    if (componentsDir.lastModified() == applicationPackage.lastModified()) return;

    componentsDir.mkdir();
    componentsDir.setLastModified(applicationPackage.lastModified());

    GeckoAppShell.killAnyZombies();

    ZipFile zip = new ZipFile(applicationPackage);

    byte[] buf = new byte[32768];
    try {
      if (unpackFile(zip, buf, null, "removed-files")) removeFiles();
    } catch (Exception ex) {
      // This file may not be there, so just log any errors and move on
      Log.w(LOG_FILE_NAME, "error removing files", ex);
    }

    // copy any .xpi file into an extensions/ directory
    Enumeration<? extends ZipEntry> zipEntries = zip.entries();
    while (zipEntries.hasMoreElements()) {
      ZipEntry entry = zipEntries.nextElement();
      if (entry.getName().startsWith("extensions/") && entry.getName().endsWith(".xpi")) {
        Log.i("GeckoAppJava", "installing extension : " + entry.getName());
        unpackFile(zip, buf, entry, entry.getName());
      }
    }
  }
コード例 #20
0
  /**
   * 扫描包
   *
   * @param basePackage 基础包
   * @param recursive 是否递归搜索子包
   */
  public Set<Class<?>> getPackageAllClasses(String basePackage, boolean recursive) {
    Set<Class<?>> classes = new LinkedHashSet<Class<?>>();
    String packageName = basePackage;
    if (packageName.endsWith(".")) {
      packageName = packageName.substring(0, packageName.lastIndexOf('.'));
    }
    String package2Path = packageName.replace('.', '/');

    Enumeration<URL> dirs;
    try {
      dirs = Thread.currentThread().getContextClassLoader().getResources(package2Path);
      while (dirs.hasMoreElements()) {
        URL url = dirs.nextElement();
        String protocol = url.getProtocol();
        if ("file".equals(protocol)) {
          logger.info("扫描file类型的class文件....");
          String filePath = URLDecoder.decode(url.getFile(), "UTF-8");
          doScanPackageClassesByFile(classes, packageName, filePath, recursive);
        } else if ("jar".equals(protocol)) {
          logger.info("扫描jar文件中的类....");
          doScanPackageClassesByJar(packageName, url, recursive, classes);
        }
      }
    } catch (IOException e) {
      logger.error("IOException error:", e);
    }

    return classes;
  }
コード例 #21
0
  protected PermissionCollection getPermissions(CodeSource codeSource) {
    PermissionCollection perms;
    try {
      try {
        perms = super.getPermissions(codeSource);
      } catch (SecurityException e) {
        // We lied about our CodeSource and that makes URLClassLoader unhappy.
        perms = new Permissions();
      }

      ProtectionDomain myDomain =
          AccessController.doPrivileged(
              new PrivilegedAction<ProtectionDomain>() {
                public ProtectionDomain run() {
                  return getClass().getProtectionDomain();
                }
              });
      PermissionCollection myPerms = myDomain.getPermissions();
      if (myPerms != null) {
        for (Enumeration<Permission> elements = myPerms.elements(); elements.hasMoreElements(); ) {
          perms.add(elements.nextElement());
        }
      }
    } catch (Throwable e) {
      // We lied about our CodeSource and that makes URLClassLoader unhappy.
      perms = new Permissions();
    }
    perms.setReadOnly();
    return perms;
  }
コード例 #22
0
  @Override
  public boolean tick(Tickable ticking, int tickID) {
    super.tick(ticking, tickID);

    if (anyWetWeather(lastWeather)) {
      if (ticking instanceof Room) {
        final Room R = (Room) ticking;
        final Area A = R.getArea();
        if ((!anyWetWeather(A.getClimateObj().weatherType(R)))
            && (!dryWeather(A.getClimateObj().weatherType(R)))
            && (CMLib.dice().rollPercentage() < pct()))
          makePuddle(R, lastWeather, A.getClimateObj().weatherType(R));
      } else if (ticking instanceof Area) {
        final Area A = (Area) ticking;
        if ((!anyWetWeather(A.getClimateObj().weatherType(null)))
            && (!dryWeather(A.getClimateObj().weatherType(null)))) {
          for (final Enumeration<Room> e = A.getProperMap(); e.hasMoreElements(); ) {
            final Room R = e.nextElement();
            if (((R.domainType() & Room.INDOORS) == 0)
                && (R.domainType() != Room.DOMAIN_OUTDOORS_AIR)
                && (!CMLib.flags().isWateryRoom(R))
                && (CMLib.dice().rollPercentage() < pct()))
              makePuddle(R, lastWeather, A.getClimateObj().weatherType(null));
          }
        }
      }
    }

    if (ticking instanceof Room)
      lastWeather = ((Room) ticking).getArea().getClimateObj().weatherType((Room) ticking);
    else if (ticking instanceof Area)
      lastWeather = ((Area) ticking).getClimateObj().weatherType(null);
    return true;
  }
コード例 #23
0
ファイル: GJVoidDepthFirst.java プロジェクト: pradeep90/POPL
 public void visit(NodeSequence n, A argu) {
   int _count = 0;
   for (Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) {
     e.nextElement().accept(this, argu);
     _count++;
   }
 }
コード例 #24
0
ファイル: Song_Ode.java プロジェクト: bozimmerman/CoffeeMud
  @Override
  public boolean tick(Tickable ticking, int tickID) {
    final MOB mob = (MOB) affected;
    if (mob == null) return false;
    if (song == null) {
      if ((whom == null)
          || (commonRoomSet == null)
          || (!commonRoomSet.contains(whom.location()))
          || (CMLib.flags().isSleeping(invoker))
          || (!CMLib.flags().canBeSeenBy(whom, invoker))) return unsingMe(mob, null);
    }

    if ((whom != null)
        && (song != null)
        && (affected == invoker())
        && (CMLib.dice().rollPercentage() < 10)) {
      final Hashtable<Integer, Integer> H = getSongBenefits(song);
      final Vector<Integer> V = new Vector<Integer>();
      for (final Enumeration<Integer> e = H.keys(); e.hasMoreElements(); )
        V.addElement(e.nextElement());
      final Integer I = V.elementAt(CMLib.dice().roll(1, V.size(), -1));
      final String[] chk = stuff[I.intValue()];
      invoker()
          .location()
          .show(invoker(), this, whom, CMMsg.MSG_SPEAK, L("<S-NAME> sing(s) '@x1'.", chk[3]));
    }

    if (!super.tick(ticking, tickID)) return false;

    return true;
  }
コード例 #25
0
ファイル: MoquiStart.java プロジェクト: emer3/moqui
 /** @see java.lang.ClassLoader#findResources(java.lang.String) */
 @Override
 public Enumeration<URL> findResources(String resourceName) throws IOException {
   String webInfResourceName = "WEB-INF/classes/" + resourceName;
   List<URL> urlList = new ArrayList<URL>();
   int jarFileListSize = jarFileList.size();
   for (int i = 0; i < jarFileListSize; i++) {
     JarFile jarFile = jarFileList.get(i);
     JarEntry jarEntry = jarFile.getJarEntry(resourceName);
     // to better support war format, look for the resourceName in the WEB-INF/classes directory
     if (loadWebInf && jarEntry == null) jarEntry = jarFile.getJarEntry(webInfResourceName);
     if (jarEntry != null) {
       try {
         String jarFileName = jarFile.getName();
         if (jarFileName.contains("\\")) jarFileName = jarFileName.replace('\\', '/');
         urlList.add(new URL("jar:file:" + jarFileName + "!/" + jarEntry));
       } catch (MalformedURLException e) {
         System.out.println(
             "Error making URL for ["
                 + resourceName
                 + "] in jar ["
                 + jarFile
                 + "] in war file ["
                 + outerFile
                 + "]: "
                 + e.toString());
       }
     }
   }
   // add all resources found in parent loader too
   Enumeration<URL> superResources = super.findResources(resourceName);
   while (superResources.hasMoreElements()) urlList.add(superResources.nextElement());
   return Collections.enumeration(urlList);
 }
コード例 #26
0
ファイル: UDP.java プロジェクト: NZDIS/jgroups
  /**
   * Processes a packet read from either the multicast or unicast socket. Needs to be synchronized
   * because mcast or unicast socket reads can be concurrent
   */
  void handleIncomingUdpPacket(byte[] data) {
    ByteArrayInputStream inp_stream;
    ObjectInputStream inp;
    Message msg = null;
    List l; // used if bundling is enabled

    try {
      // skip the first n bytes (default: 4), this is the version info
      inp_stream = new ByteArrayInputStream(data, VERSION_LENGTH, data.length - VERSION_LENGTH);
      inp = new ObjectInputStream(inp_stream);
      if (enable_bundling) {
        l = new List();
        l.readExternal(inp);
        for (Enumeration en = l.elements(); en.hasMoreElements(); ) {
          msg = (Message) en.nextElement();
          try {
            handleMessage(msg);
          } catch (Throwable t) {
            Trace.error("UDP.handleIncomingUdpPacket()", "failure: " + t.toString());
          }
        }
      } else {
        msg = new Message();
        msg.readExternal(inp);
        handleMessage(msg);
      }
    } catch (Throwable e) {
      Trace.error("UDP.handleIncomingUdpPacket()", "exception=" + Trace.getStackTrace(e));
    }
  }
コード例 #27
0
 protected void finished() {
   logger.log(LogService.LOG_DEBUG, "Here is OcdHandler():finished()"); // $NON-NLS-1$
   if (!_isParsedDataValid) return;
   if (_ad_vector.size() == 0) {
     // Schema defines at least one AD is required.
     _isParsedDataValid = false;
     logger.log(
         LogService.LOG_ERROR,
         NLS.bind(
             MetaTypeMsg.MISSING_ELEMENT,
             new Object[] {
               AD,
               OCD,
               elementId,
               _dp_url,
               _dp_bundle.getBundleId(),
               _dp_bundle.getSymbolicName()
             }));
     return;
   }
   // OCD gets all parsed ADs.
   Enumeration<AttributeDefinitionImpl> adKey = _ad_vector.elements();
   while (adKey.hasMoreElements()) {
     AttributeDefinitionImpl ad = adKey.nextElement();
     _ocd.addAttributeDefinition(ad, ad._isRequired);
   }
   _ocd.setIcons(icons);
   _parent_OCDs_hashtable.put(_refID, _ocd);
 }
コード例 #28
0
 public static <T> List<T> toList(Enumeration<? extends T> things) {
   AbstractList<T> list = new ArrayList<T>();
   while (things.hasMoreElements()) {
     list.add(things.nextElement());
   }
   return list;
 }
コード例 #29
0
  public void initializeClass() {
    super.initializeClass();
    CMLib.ableMapper().addCharAbilityMapping(ID(), 1, "Skill_Spellcraft", 50, true);
    CMLib.ableMapper().addCharAbilityMapping(ID(), 1, "Skill_ScrollCopy", 100, true);
    CMLib.ableMapper().addCharAbilityMapping(ID(), 1, "Spell_Scribe", 75, true);
    CMLib.ableMapper().addCharAbilityMapping(ID(), 1, "Papermaking", 75, true);
    CMLib.ableMapper().addCharAbilityMapping(ID(), 1, "Spell_ReadMagic", 100, true);

    CMLib.ableMapper().addCharAbilityMapping(ID(), 1, "Spell_MagicMissile", false);
    CMLib.ableMapper().addCharAbilityMapping(ID(), 1, "Spell_ResistMagicMissiles", false);
    CMLib.ableMapper().addCharAbilityMapping(ID(), 1, "Spell_Shield", false);
    CMLib.ableMapper().addCharAbilityMapping(ID(), 1, "Spell_IronGrip", false);

    for (Enumeration a = CMClass.abilities(); a.hasMoreElements(); ) {
      Ability A = (Ability) a.nextElement();
      if ((A != null) && ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SPELL)) {
        int level = CMLib.ableMapper().getQualifyingLevel(ID(), true, A.ID());
        if (level > 0) {
          AbilityMapper.AbilityMapping able = CMLib.ableMapper().getAbleMap(ID(), A.ID());
          if ((able != null) && (!CMLib.ableMapper().getDefaultGain(ID(), true, A.ID()))) {
            able.costOverrides =
                new Integer[] {
                  Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0)
                };
            able.defaultProficiency = 100;
          }
        }
      }
    }
  }
コード例 #30
0
  protected void doPost(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
    String pathInfo = req.getPathInfo();

    if (pathInfo.equals("/")) {
      HttpSession session = req.getSession();
      if (session == null) {
        resp.setStatus(401);
        return;
      }
      String username = (String) session.getAttribute("username");
      if (username == null) {
        resp.setStatus(401);
        return;
      }

      Map userMap = loadUserSettingsMap(username);
      if (userMap == null) {
        resp.setStatus(401);
        return;
      }
      Enumeration parameterNames = req.getParameterNames();
      while (parameterNames.hasMoreElements()) {
        String parameterName = (String) parameterNames.nextElement();
        userMap.put(parameterName, req.getParameter(parameterName));
      }
      saveUserSettingsMap(username, userMap);
      return;
    }

    super.doPost(req, resp);
  }