Пример #1
2
 /** {@inheritDoc} */
 public void putAll(Map<? extends Integer, ? extends Integer> map) {
   ensureCapacity(map.size());
   // could optimize this for cases when map instanceof THashMap
   for (Map.Entry<? extends Integer, ? extends Integer> entry : map.entrySet()) {
     this.put(entry.getKey().intValue(), entry.getValue().intValue());
   }
 }
Пример #2
1
 private Map<String, Object> query(HttpServletRequest req) {
   final Map<String, Object> map = new HashMap<>();
   for (Map.Entry<String, String[]> entry : req.getParameterMap().entrySet()) {
     map.put(entry.getKey(), entry.getValue());
   }
   return map;
 }
Пример #3
0
 public static LauncherProfiles load() throws IOException {
   System.out.println("Loading Minecraft profiles from " + DevLauncher.workingDirectory);
   try (FileReader reader = new FileReader(getFile())) {
     LauncherProfiles profiles = new LauncherProfiles();
     JsonObject e = new JsonParser().parse(reader).getAsJsonObject();
     for (Map.Entry<String, JsonElement> entry : e.entrySet()) {
       if (entry.getKey().equals("clientToken")) {
         profiles.clientToken = entry.getValue().getAsString();
       } else if (entry.getKey().equals("authenticationDatabase")) {
         JsonObject o = entry.getValue().getAsJsonObject();
         for (Map.Entry<String, JsonElement> entry1 : o.entrySet()) {
           profiles.authenticationDatabase.profiles.put(
               UUIDTypeAdapter.fromString(entry1.getKey()),
               GSON.fromJson(entry1.getValue(), OnlineProfile.class));
         }
       } else {
         profiles.everythingElse.add(entry.getKey(), entry.getValue());
       }
     }
     INSTANCE = profiles;
     return INSTANCE;
   } finally {
     if (INSTANCE == null) {
       INSTANCE = new LauncherProfiles();
     }
     INSTANCE.markLoaded();
   }
 }
Пример #4
0
  private synchronized void addNewAgent(
      int agentId,
      SocketChannel socket,
      String agentName,
      String agentIP,
      int agentPort,
      int flags) {
    if (agentIP.equals(":same")) {
      InetAddress agentAddress = socket.socket().getInetAddress();
      agentIP = agentAddress.getHostAddress();
    }

    Log.info(
        "New agent id="
            + agentId
            + " name="
            + agentName
            + " address="
            + agentIP
            + ":"
            + agentPort
            + " flags="
            + flags);
    AgentInfo agentInfo = new AgentInfo();
    agentInfo.agentId = agentId;
    agentInfo.flags = flags;
    agentInfo.socket = socket;
    agentInfo.agentName = agentName;
    agentInfo.agentIP = agentIP;
    agentInfo.agentPort = agentPort;
    agentInfo.outputBuf = new MVByteBuffer(1024);
    agentInfo.inputBuf = new MVByteBuffer(1024);
    agents.put(socket, agentInfo);

    NewAgentMessage newAgentMessage =
        new NewAgentMessage(agentId, agentName, agentIP, agentPort, flags);
    for (Map.Entry<SocketChannel, AgentInfo> entry : agents.entrySet()) {
      if (entry.getKey() == socket) continue;

      // Tell other agents about the new one
      synchronized (entry.getValue().outputBuf) {
        Message.toBytes(newAgentMessage, entry.getValue().outputBuf);
      }

      // Tell new agent about other agents
      NewAgentMessage otherAgentMessage =
          new NewAgentMessage(
              entry.getValue().agentId,
              entry.getValue().agentName,
              entry.getValue().agentIP,
              entry.getValue().agentPort,
              entry.getValue().flags);
      synchronized (agentInfo.outputBuf) {
        Message.toBytes(otherAgentMessage, agentInfo.outputBuf);
      }
    }

    messageIO.addAgent(agentInfo);
    messageIO.outputReady();
  }
Пример #5
0
  public ReaderHandler(LowLevelDbAccess lowLevelDbAccess, String webDir) {

    loginInfoDb = new LoginInfo.DB(lowLevelDbAccess);
    userDb = new User.DB(lowLevelDbAccess);
    feedDb = new Feed.DB(lowLevelDbAccess);
    articleDb = new Article.DB(lowLevelDbAccess);
    readArticlesCollDb = new ReadArticlesColl.DB(lowLevelDbAccess);
    userHelpers = new UserHelpers(loginInfoDb, userDb);

    setContextPath("/");

    File warPath = new File(webDir);
    setWar(warPath.getAbsolutePath());

    if (isInJar) {
      for (Map.Entry<String, String> entry : PATH_MAPPING.entrySet()) {
        addPrebuiltJsp(entry.getKey(), "jsp." + entry.getValue().replaceAll("_", "_005f") + "_jsp");
      }
    } else {
      for (Map.Entry<String, String> entry : PATH_MAPPING.entrySet()) {
        addServlet(
            new ServletHolder(new RedirectServlet("/" + entry.getValue() + ".jsp")),
            entry.getKey());
      }
    }

    setErrorHandler(new ReaderErrorHandler());
  }
Пример #6
0
  public static void main(String[] args) throws IOException {
    PGF gr = null;
    try {
      gr =
          PGF.readPGF(
              "/home/krasimir/www.grammaticalframework.org/examples/phrasebook/Phrasebook.pgf");
    } catch (FileNotFoundException e) {
      e.printStackTrace();
      return;
    } catch (PGFError e) {
      e.printStackTrace();
      return;
    }

    Type typ = gr.getFunctionType("Bulgarian");
    System.out.println(typ.getCategory());
    System.out.println(gr.getAbstractName());
    for (Map.Entry<String, Concr> entry : gr.getLanguages().entrySet()) {
      System.out.println(
          entry.getKey() + " " + entry.getValue() + " " + entry.getValue().getName());
    }

    Concr eng = gr.getLanguages().get("SimpleEng");
    try {
      for (ExprProb ep : eng.parse(gr.getStartCat(), "persons who work with Malmö")) {
        System.out.println("[" + ep.getProb() + "] " + ep.getExpr());
      }
    } catch (ParseError e) {
      System.out.println("Parsing failed at token \"" + e.getToken() + "\"");
    }
  }
Пример #7
0
 protected void initFeatureVersions() throws PluginException.InvalidDefinition {
   if (definitionMap.containsKey(KEY_PLUGIN_FEATURE_VERSION_MAP)) {
     Map<Plugin.Feature, String> map = new HashMap<Plugin.Feature, String>();
     Map<String, String> spec =
         (Map<String, String>) definitionMap.getMap(KEY_PLUGIN_FEATURE_VERSION_MAP);
     log.debug2("features: " + spec);
     for (Map.Entry<String, String> ent : spec.entrySet()) {
       try {
         // Prefix version string with feature name to create separate
         // namespace for each feature
         String key = ent.getKey();
         map.put(Plugin.Feature.valueOf(key), key + "_" + ent.getValue());
       } catch (RuntimeException e) {
         log.warning(
             getPluginName()
                 + " set unknown feature: "
                 + ent.getKey()
                 + " to version "
                 + ent.getValue(),
             e);
         throw new PluginException.InvalidDefinition("Unknown feature: " + ent.getKey(), e);
       }
     }
     featureVersion = map;
   } else {
     featureVersion = null;
   }
 }
Пример #8
0
  private static InputStream generateSoundsJSON() throws IOException {
    OpenSecurity.logger.info(
        Minecraft.getMinecraft().mcDataDir + "\\mods\\OpenSecurity\\sounds\\alarms\\");

    JsonObject root = new JsonObject();
    for (Map.Entry<String, String> entry : sound_map.entrySet()) {
      JsonObject event = new JsonObject();
      event.addProperty("category", "master"); // put under the "record" category for sound options
      JsonArray sounds = new JsonArray(); // array of sounds (will only ever be one)
      JsonObject sound =
          new JsonObject(); // sound object (instead of primitive to use 'stream' flag)
      sound.addProperty(
          "name",
          new File(".")
              + "\\mods\\OpenSecurity\\sounds\\alarms\\"
              + entry.getValue().substring(0, entry.getValue().lastIndexOf('.'))); // path to file
      sound.addProperty("stream", false); // prevents lag for large files
      sounds.add(sound);
      event.add("sounds", sounds);
      root.add(
          entry.getValue().substring(0, entry.getValue().lastIndexOf('.')),
          event); // event name (same as name sent to ItemCustomRecord)
    }
    // System.out.println(new Gson().toJson(root));
    return new ByteArrayInputStream(new Gson().toJson(root).getBytes());
  }
Пример #9
0
  /**
   * create the info string; assumes that no values are null
   *
   * @param infoFields a map of info fields
   * @throws IOException for writer
   */
  private void writeInfoString(Map<String, String> infoFields) throws IOException {
    if (infoFields.isEmpty()) {
      mWriter.write(VCFConstants.EMPTY_INFO_FIELD);
      return;
    }

    boolean isFirst = true;
    for (Map.Entry<String, String> entry : infoFields.entrySet()) {
      if (isFirst) isFirst = false;
      else mWriter.write(VCFConstants.INFO_FIELD_SEPARATOR);

      String key = entry.getKey();
      mWriter.write(key);

      if (!entry.getValue().equals("")) {
        VCFInfoHeaderLine metaData = mHeader.getInfoHeaderLine(key);
        if (metaData == null
            || metaData.getCountType() != VCFHeaderLineCount.INTEGER
            || metaData.getCount() != 0) {
          mWriter.write("=");
          mWriter.write(entry.getValue());
        }
      }
    }
  }
    public boolean equals(Object o) {
      if (!(o instanceof Map.Entry)) return false;
      Map.Entry<?, ?> e = (Map.Entry<?, ?>) o;

      return (key == null ? e.getKey() == null : key.equals(e.getKey()))
          && (value == null ? e.getValue() == null : value.equals(e.getValue()));
    }
Пример #11
0
 private void exportAttributes(Map<String, Object> attrMap) {
   for (Map.Entry<String, Object> e : attrMap.entrySet()) {
     if (e.getKey().equals(WikiPage.CHANGENOTE))
       exportProperty("wiki:changeNote", (String) e.getValue(), STRING);
     else exportProperty(e.getKey(), e.getValue().toString(), STRING);
   }
 }
  private void exportParameters() {
    synchronized (exported_parameters) {
      if (!exported_parameters_dirty) {

        return;
      }

      exported_parameters_dirty = false;

      try {
        TreeMap<String, String> tm = new TreeMap<String, String>();

        Set<String> exported_keys = new HashSet<String>();

        for (String[] entry : exported_parameters.values()) {

          String key = entry[0];
          String value = entry[1];

          exported_keys.add(key);

          if (value != null) {

            tm.put(key, value);
          }
        }

        for (Map.Entry<String, String> entry : imported_parameters.entrySet()) {

          String key = entry.getKey();

          if (!exported_keys.contains(key)) {

            tm.put(key, entry.getValue());
          }
        }

        File parent_dir = new File(SystemProperties.getUserPath());

        File props = new File(parent_dir, "exported_params.properties");

        PrintWriter pw =
            new PrintWriter(new OutputStreamWriter(new FileOutputStream(props), "UTF-8"));

        try {
          for (Map.Entry<String, String> entry : tm.entrySet()) {

            pw.println(entry.getKey() + "=" + entry.getValue());
          }

        } finally {

          pw.close();
        }
      } catch (Throwable e) {

        e.printStackTrace();
      }
    }
  }
Пример #13
0
  ///////////
  // Methods//
  ///////////
  public void createServerFile(
      HashMap<String, DataObj> dataObjsMap, HashMap<String, PageObj> pageObjsMap) {
    // Copy files over
    try {
      FileUtils.copyFile(sourceConfig, new File("Output/config.js"));
    } catch (IOException e) {
      System.out.println("Error copying over config file for");
      System.out.println(e);
    }
    out.write(genDbConnection());
    // For each data object, get object by ID
    Iterator it = dataObjsMap.entrySet().iterator();
    while (it.hasNext()) {
      Map.Entry one = (Map.Entry) it.next();
      DataObj curDataObj = (DataObj) one.getValue();
      String name = curDataObj.getName();
      out.write("\n /* " + name + ": CRUD GET, DELETE, UPDATE, POST BY ID*/\n");
      out.write(genGetById(curDataObj));
      out.write(genDelById(curDataObj));
      out.write(genUpdateById(curDataObj));
      out.write(genAdd(curDataObj));
    }
    // Hack to get a necessary API call for OAuth stuff
    out.write(
        genGetByPageParam(
            null,
            new Section(
                "View",
                new ArrayList<String>(Arrays.asList(new String[] {"OAuthID"})),
                new ArrayList<String>(Arrays.asList(new String[] {"User"}))),
            dataObjsMap));

    // For each page, generate the calls necessery to make
    // the view/create params work
    it = pageObjsMap.entrySet().iterator();
    while (it.hasNext()) {
      Map.Entry one = (Map.Entry) it.next();
      PageObj curPageObj = (PageObj) one.getValue();
      String name = curPageObj.getName();
      out.write("\n /* " + name + ": CRUD GET,DELETE,UPDATE,POST *NOT* BY ID */\n");
      List<Section> sections = curPageObj.getSections();
      for (Section section : sections) {
        switch ((Section.Type) section.getType()) {
          case VIEW:
            out.write(genGetByPageParam(curPageObj, section, dataObjsMap));
            break;
          case CREATE:
            // out.write(genPostByPageParam(curPageObj, section));
            break;
          case MODIFY:
            break;
          case DELETE:
            break;
        }
      }
    }
    out.write(genServerListen());
  }
    public boolean equals(Object o) {
      if (!(o instanceof Map.Entry)) {
        return false;
      }

      Map.Entry e = (Map.Entry) o;
      Object v = value.get();
      return (key == e.getKey()) && ((v == null) ? (e.getValue() == null) : v.equals(e.getValue()));
    }
 /** Destructor. */
 public void remove() {
   for (Iterator<Map.Entry<Long, WImage>> it_it = this.grid_.entrySet().iterator();
       it_it.hasNext(); ) {
     Map.Entry<Long, WImage> it = it_it.next();
     ;
     if (it.getValue() != null) it.getValue().remove();
   }
   super.remove();
 }
Пример #16
0
  public void innerExecute() throws IOException, JerializerException {
    // first arg - schema dir, second arg - dest dir
    // TODO write schemas

    File schemas = new File(schemaDir);
    assert schemas.isDirectory() && schemas.canRead();

    File dest = new File(destDir);
    assert !dest.exists();
    dest.mkdir();
    assert dest.isDirectory() && dest.canWrite();

    Set<Klass> genKlasses = new TreeSet<Klass>();

    JsonParser parser = new JsonParser();
    for (File schema : schemas.listFiles()) {
      BufferedReader reader = new BufferedReader(new FileReader(schema));
      JThing thing = parser.parse(reader);
      System.out.println(thing);
      String rootString = schemas.toURI().toString();
      if (!rootString.endsWith("/")) rootString = rootString + "/";
      String klassName =
          KlassContext.capitalize(schema.toURI().toString().substring(rootString.length()));
      String packageName = basePackage + "." + klassName.toLowerCase();

      GenWritable writable = parseSchemaThing(klassName, packageName, thing);

      Map<String, String> m = writable.makeClassToTextMap();

      final File dir = new File(destDir + "/" + klassName.toLowerCase());
      dir.mkdirs();
      for (Map.Entry<String, String> entry : m.entrySet()) {
        final String fullClass = entry.getKey();
        final String contents = entry.getValue();
        final String relName = fullClass.substring(fullClass.lastIndexOf(".") + 1) + ".java";
        final File f = new File(dir, relName);
        FileWriter writer = new FileWriter(f);
        BufferedWriter bufferedWriter = new BufferedWriter(writer);
        bufferedWriter.write(contents, 0, contents.length());
        bufferedWriter.close();
      }

      genKlasses.add(new Klass(klassName, packageName));
    }

    RegistryGen registryGen =
        new RegistryGen(new Klass("GenschemaRegistryFactory", basePackage), genKlasses);
    final File g = new File(destDir + "/GenschemaRegistryFactory.java");
    for (Map.Entry<String, String> entry : registryGen.makeClassToTextMap().entrySet()) {
      final String contents = entry.getValue();
      FileWriter writer = new FileWriter(g);
      BufferedWriter bufferedWriter = new BufferedWriter(writer);
      bufferedWriter.write(contents, 0, contents.length());
      bufferedWriter.close();
      break;
    }
  }
Пример #17
0
 public Map.Entry<Region, Double> getMaxFromHashMap(HashMap<Region, Double> input) {
   Map.Entry<Region, Double> maxEntry = null;
   for (Map.Entry<Region, Double> entry : input.entrySet()) {
     if (maxEntry == null || entry.getValue() > maxEntry.getValue()) {
       maxEntry = entry;
     }
   }
   return maxEntry;
 }
 /**
  * Regenerates and redraws the image pieces.
  *
  * <p>This method invalidates all current grid images, and recreates them.
  */
 public void redrawAll() {
   for (Iterator<Map.Entry<Long, WImage>> it_it = this.grid_.entrySet().iterator();
       it_it.hasNext(); ) {
     Map.Entry<Long, WImage> it = it_it.next();
     ;
     if (it.getValue() != null) it.getValue().remove();
   }
   this.grid_.clear();
   this.generateGridItems(this.currentX_, this.currentY_);
 }
Пример #19
0
 public static void flushAllControlledWriters() {
   for (Iterator<Map.Entry<String, ControlledBufferWriter>> iterator =
           writers.entrySet().iterator();
       iterator.hasNext(); ) {
     Map.Entry<String, ControlledBufferWriter> next = iterator.next();
     //            System.out.println(next.getKey());
     if (next.getValue().isClose()) {
       iterator.remove();
     } else {
       next.getValue().flush2();
     }
   }
 }
 public String printCategoryDistribution(SortedMap<Integer, Double> categoryDistribution) {
   StringBuilder scoreValues = new StringBuilder();
   LOG.debug("output category distribution:");
   scoreValues.append("scores<-c(");
   for (Map.Entry<Integer, Double> score : categoryDistribution.entrySet()) {
     String name = treeCache.getNameById(score.getKey(), String.valueOf(score.getKey()));
     LOG.debug(name + "\t\t" + score.getValue() + "\t" + treeCache.getDepth(score.getKey()));
     if (scoreValues.length() > 10) {
       scoreValues.append(", ");
     }
     scoreValues.append(score.getValue());
   }
   scoreValues.append(")");
   return scoreValues.toString();
 }
 /** entrySet contains all pairs */
 public void testDescendingEntrySet() {
   ConcurrentNavigableMap map = dmap5();
   Set s = map.entrySet();
   assertEquals(5, s.size());
   Iterator it = s.iterator();
   while (it.hasNext()) {
     Map.Entry e = (Map.Entry) it.next();
     assertTrue(
         (e.getKey().equals(m1) && e.getValue().equals("A"))
             || (e.getKey().equals(m2) && e.getValue().equals("B"))
             || (e.getKey().equals(m3) && e.getValue().equals("C"))
             || (e.getKey().equals(m4) && e.getValue().equals("D"))
             || (e.getKey().equals(m5) && e.getValue().equals("E")));
   }
 }
 /** entrySet contains all pairs */
 public void testEntrySet() {
   ConcurrentNavigableMap map = map5();
   Set s = map.entrySet();
   assertEquals(5, s.size());
   Iterator it = s.iterator();
   while (it.hasNext()) {
     Map.Entry e = (Map.Entry) it.next();
     assertTrue(
         (e.getKey().equals(one) && e.getValue().equals("A"))
             || (e.getKey().equals(two) && e.getValue().equals("B"))
             || (e.getKey().equals(three) && e.getValue().equals("C"))
             || (e.getKey().equals(four) && e.getValue().equals("D"))
             || (e.getKey().equals(five) && e.getValue().equals("E")));
   }
 }
Пример #23
0
  /**
   * Prints the given map with nice line breaks.
   *
   * @param out the stream to print to
   * @param key the key that maps to the map in some other map
   * @param map the map to print
   */
  public static synchronized void debugPrint(PrintStream out, Object key, Map map) {
    debugPrintIndent(out);
    out.println(key + " = ");

    debugPrintIndent(out);
    out.println("{");
    ++debugIndent;

    for (Iterator iter = map.entrySet().iterator(); iter.hasNext(); ) {
      Map.Entry entry = (Map.Entry) iter.next();
      String childKey = (String) entry.getKey();
      Object childValue = entry.getValue();
      if (childValue instanceof Map) {
        verbosePrint(out, childKey, (Map) childValue);
      } else {
        debugPrintIndent(out);

        String typeName = (childValue != null) ? childValue.getClass().getName() : null;

        out.println(childKey + " = " + childValue + " class: " + typeName);
      }
    }
    --debugIndent;
    debugPrintIndent(out);
    out.println("}");
  }
Пример #24
0
  static void itTest4(Map s, int size, int pos) {
    IdentityHashMap seen = new IdentityHashMap(size);
    reallyAssert(s.size() == size);
    int sum = 0;
    timer.start("Iter XEntry            ", size);
    Iterator it = s.entrySet().iterator();
    Object k = null;
    Object v = null;
    for (int i = 0; i < size - pos; ++i) {
      Map.Entry x = (Map.Entry) (it.next());
      k = x.getKey();
      v = x.getValue();
      seen.put(k, k);
      if (x != MISSING) ++sum;
    }
    reallyAssert(s.containsKey(k));
    it.remove();
    reallyAssert(!s.containsKey(k));
    while (it.hasNext()) {
      Map.Entry x = (Map.Entry) (it.next());
      Object k2 = x.getKey();
      seen.put(k2, k2);
      if (x != MISSING) ++sum;
    }

    reallyAssert(s.size() == size - 1);
    s.put(k, v);
    reallyAssert(seen.size() == size);
    timer.finish();
    reallyAssert(sum == size);
    reallyAssert(s.size() == size);
  }
  /**
   * Compares the specified Object with this Map for equality, as per the definition in the Map
   * interface.
   *
   * @param o object to be compared for equality with this hashtable
   * @return true if the specified Object is equal to this Map
   * @see Map#equals(Object)
   * @since 1.2
   */
  public synchronized boolean equals(Object o) {
    if (o == this) return true;

    if (!(o instanceof Map)) return false;
    Map<?, ?> t = (Map<?, ?>) o;
    if (t.size() != size()) return false;

    try {
      for (Map.Entry<K, V> e : entrySet()) {
        K key = e.getKey();
        V value = e.getValue();
        if (value == null) {
          if (!(t.get(key) == null && t.containsKey(key))) return false;
        } else {
          if (!value.equals(t.get(key))) return false;
        }
      }
    } catch (ClassCastException unused) {
      return false;
    } catch (NullPointerException unused) {
      return false;
    }

    return true;
  }
Пример #26
0
 /* Retorna um Map com os utilizadores existentes no sistema */
 public HashMap<String, User> getUsers() {
   HashMap<String, User> r = new HashMap<>();
   for (Map.Entry<String, User> entry : users.entrySet()) {
     r.put(entry.getKey(), entry.getValue());
   }
   return r;
 }
Пример #27
0
  /**
   * Compares the specified Object with this Map for equality, as per the definition in the Map
   * interface.
   *
   * @param o object to be compared for equality with this hashtable
   * @return true if the specified Object is equal to this Map
   * @see Map#equals(Object)
   * @since 1.2
   */
  public synchronized boolean equals(Object o) {
    if (o == this) return true;

    if (!(o instanceof Map)) return false;
    Map<K, V> t = (Map<K, V>) o;
    if (t.size() != size()) return false;

    try {
      Iterator<Map.Entry<K, V>> i = entrySet().iterator();
      while (i.hasNext()) {
        Map.Entry<K, V> e = i.next();
        K key = e.getKey();
        V value = e.getValue();
        if (value == null) {
          if (!(t.get(key) == null && t.containsKey(key))) return false;
        } else {
          if (!value.equals(t.get(key))) return false;
        }
      }
    } catch (ClassCastException unused) {
      return false;
    } catch (NullPointerException unused) {
      return false;
    }

    return true;
  }
Пример #28
0
 public static void main(String[] args) {
   try {
     if (args.length == 1) {
       URL url = new URL(args[0]);
       System.out.println("Content-Type: " + url.openConnection().getContentType());
       // 				Vector links = extractLinks(url);
       // 				for (int n = 0; n < links.size(); n++) {
       // 					System.out.println((String) links.elementAt(n));
       // 				}
       Set links = extractLinksWithText(url).entrySet();
       Iterator it = links.iterator();
       while (it.hasNext()) {
         Map.Entry en = (Map.Entry) it.next();
         String strLink = (String) en.getKey();
         String strText = (String) en.getValue();
         System.out.println(strLink + " \"" + strText + "\" ");
       }
       return;
     } else if (args.length == 2) {
       writeURLtoFile(new URL(args[0]), args[1]);
       return;
     }
   } catch (Exception e) {
     System.err.println("An error occured: ");
     e.printStackTrace();
     // 			System.err.println(e.toString());
   }
   System.err.println("Usage: java SaveURL <url> [<file>]");
   System.err.println("Saves a URL to a file.");
   System.err.println("If no file is given, extracts hyperlinks on url to console.");
 }
Пример #29
0
  public static void testDetermineMergeParticipantsAndMergeCoords4() {
    Address a = Util.createRandomAddress(),
        b = Util.createRandomAddress(),
        c = Util.createRandomAddress(),
        d = Util.createRandomAddress();
    org.jgroups.util.UUID.add(a, "A");
    org.jgroups.util.UUID.add(b, "B");
    org.jgroups.util.UUID.add(c, "C");
    org.jgroups.util.UUID.add(d, "D");

    View v1 = View.create(a, 1, a, b);
    View v2 = View.create(c, 1, c, d);

    Map<Address, View> map = new HashMap<>();
    map.put(a, v1);
    map.put(b, v1);
    map.put(d, v2);

    StringBuilder sb = new StringBuilder("map:\n");
    for (Map.Entry<Address, View> entry : map.entrySet())
      sb.append(entry.getKey() + ": " + entry.getValue() + "\n");
    System.out.println(sb);

    Collection<Address> merge_participants = Util.determineMergeParticipants(map);
    System.out.println("merge_participants = " + merge_participants);
    assert merge_participants.size() == 3;
    assert merge_participants.contains(a)
        && merge_participants.contains(c)
        && merge_participants.contains(d);

    Collection<Address> merge_coords = Util.determineMergeCoords(map);
    System.out.println("merge_coords = " + merge_coords);
    assert merge_coords.size() == 2;
    assert merge_coords.contains(a) && merge_coords.contains(c);
  }
Пример #30
0
 public void writeFoundWordsFile() throws IOException {
   PrintWriter pw = new PrintWriter(new FileWriter("src\\LW_5\\output2.txt"));
   for (Map.Entry entry : wordsNumStr.entrySet()) {
     pw.println("Word : " + entry.getKey() + ", String number : " + entry.getValue());
   }
   pw.close();
 }