Java Code Examples for java.util.HashMap.values()

The following are Jave code examples for showing how to use values() of the java.util.HashMap class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: ctsms   File: QueryUtil.java   View Source Code Vote up 6 votes
private static void appendJoins(StringBuilder statement, HashMap<String, AssociationPath> explicitJoinsMap) {
	ArrayList<AssociationPath> joins = new ArrayList<AssociationPath>(explicitJoinsMap.values());
	Collections.sort(joins, new JoinComparator());
	Iterator<AssociationPath> it = joins.iterator();
	while (it.hasNext()) {
		AssociationPath join = it.next();
		StringBuilder joinSb = new StringBuilder(" left join ");
		joinSb.append(join.getAliasedPathString());
		joinSb.append(" as ");
		joinSb.append(join.getJoinAlias());
		statement.append(joinSb);
	}
}
 
Example 2
Project: metanome-algorithms   File: PLIBuilder.java   View Source Code Vote up 6 votes
protected static List<PositionListIndex> fetchPositionListIndexesStatic(List<HashMap<String, IntArrayList>> clusterMaps, boolean isNullEqualNull) {
	List<PositionListIndex> clustersPerAttribute = new ArrayList<>();
	for (int columnId = 0; columnId < clusterMaps.size(); columnId++) {
		List<IntArrayList> clusters = new ArrayList<>();
		HashMap<String, IntArrayList> clusterMap = clusterMaps.get(columnId);
		
		if (!isNullEqualNull)
			clusterMap.remove(null);
		
		for (IntArrayList cluster : clusterMap.values())
			if (cluster.size() > 1)
				clusters.add(cluster);
		
		clustersPerAttribute.add(new PositionListIndex(columnId, clusters));
	}
	return clustersPerAttribute;
}
 
Example 3
Project: AgentWorkbench   File: NetworkModel.java   View Source Code Vote up 6 votes
/**
 * Sets the directions of the specified NetworkComponent.
 * @param networkComponent the NetworkComponent
 */
public void setDirectionsOfNetworkComponent(NetworkComponent networkComponent) {
	
	HashMap<String, GraphEdgeDirection> edgeHash = networkComponent.getEdgeDirections();
	for (GraphEdgeDirection direction : edgeHash.values()) {
		// --- Set direction in this NetworkModel -------------------------
		this.setGraphEdgeDirection(direction);

		// ----------------------------------------------------------------
		// --- Set the direction also to the alternative NetworkModels ----
		// ----------------------------------------------------------------
		if (this.alternativeNetworkModel!=null && this.alternativeNetworkModel.size()>0) {
			for (NetworkModel altNetModel : this.alternativeNetworkModel.values()) {
				if (altNetModel.getNetworkComponent(networkComponent.getId())!=null) {
					altNetModel.setGraphEdgeDirection(direction);
				}
			}
		}
		// ----------------------------------------------------------------
	}
}
 
Example 4
Project: Ducky-Mc-Duckerson   File: StoreCS.java   View Source Code Vote up 6 votes
@Override
public void execute(Member author, User authorUser, MessageChannel channel, Message message, String parameters, Map<String, CommandStructure> commandList) {
    Guild guild = author.getGuild();
    Long guildID = guild.getIdLong();
    Long userID = author.getUser().getIdLong();
    if (hasPermission(author)) {
        HashMap<Integer, Item> storeList = itemDB.getStoreList();
        EmbedBuilder embed = new EmbedBuilder();
        embed.setTitle(localize(channel, "command.store.title"), null);
        for (Item item : storeList.values()) {
            embed.addField(localize(channel, "command.store.item", item.getLocalizedName(channel), item.getInvID()),
                localize(channel, "command.store.item_description", item.getDescription(channel), item.getCost()), true);
        }
        channel.sendMessage(embed.build()).queue();
    }
}
 
Example 5
Project: 3way_laboratorios   File: TesteHashMap.java   View Source Code Vote up 6 votes
public static void main(String[] args) {

		HashMap<Agencia, Cliente[]> hm = new HashMap<Agencia, Cliente[]>();
		// adiciona chave - agencia e valor = array Cliente
		hm.put(new Agencia("ag01"), new Cliente[] { new Cliente("Enricando Cardoso"), new Cliente("Inacio Estole"), new Cliente("Luiz Ladrum"), });
		hm.put(new Agencia("ag02"), new Cliente[] { new Cliente("Henri Cando"), new Cliente("Stolin Lu La"), new Cliente("Lara Pio"), });
		hm.put(new Agencia("ag03"), new Cliente[] { new Cliente("Sony Gando"), new Cliente("Leiro Pisto"), new Cliente("Waga Oubum Du"), });

		// imprime a colecao
		System.out.println(hm);
		// pega as chaves
		Set chaves = hm.keySet();

		// imprime as chaves
		System.out.println(chaves);

		// pega os valores
		Collection<Cliente[]> valores = hm.values();

		// imprime os valores
		for (Cliente[] cs : valores) {
			for (Cliente c : cs) {
				System.out.println(c);
			}
		}
	}
 
Example 6
Project: Customerly-Android-SDK   File: Customerly.java   View Source Code Vote up 6 votes
/**
 * @param pCompany The company of the user. The map must contain a String value with key "company_id" containing to the Company ID and a String value with key "name" containing the Company name. Can contain only String, char, int, long, float or double values.
 * @throws IllegalArgumentException is thrown if company map check fails
 */
private SetCompanyTask(@NonNull HashMap<String,Object> pCompany) throws IllegalArgumentException {
    Collection<Object> attrs = pCompany.values();
    for(Object attr : attrs) {
        if(     attr instanceof String ||
                attr instanceof Integer ||
                attr instanceof Byte ||
                attr instanceof Long ||
                attr instanceof Double ||
                attr instanceof Float ||
                attr instanceof Character ||
                attr instanceof Boolean) {
            continue;
        }
        _log("Company HashMap can contain only String, char, byte, int, long, float or double values");
        throw new IllegalArgumentException("Company HashMap can contain only String, char, byte, int, long, float or double values");
    }
    if(! pCompany.containsKey("company_id") && ! pCompany.containsKey("name")) {
        _log("Company HashMap must contain a String value with key \"company_id\" containing to the Company ID and a String value with key \"name\" containing the Company name");
        throw new IllegalArgumentException(
                "Company HashMap must contain a String value with key \"company_id\" containing to the Company ID and a String value with key \"name\" containing the Company name"
        );
    }
    this.company = new JSONObject(pCompany);
}
 
Example 7
Project: SparkSeq   File: ErrorModel.java   View Source Code Vote up 5 votes
public static int getTotalReferenceDepth(HashMap<String, ErrorModel> perLaneErrorModels) {
    int n = 0;
    for (ErrorModel e : perLaneErrorModels.values()) {
        n += e.getReferenceDepth();
    }
    return n;
}
 
Example 8
Project: AOSP-Kayboard-7.1.2   File: BinaryDictionaryGetter.java   View Source Code Vote up 5 votes
/**
 * Returns the list of cached files for a specific locale, one for each category.
 *
 * This will return exactly one file for each word list category that matches
 * the passed locale. If several files match the locale for any given category,
 * this returns the file with the closest match to the locale. For example, if
 * the passed word list is en_US, and for a category we have an en and an en_US
 * word list available, we'll return only the en_US one.
 * Thus, the list will contain as many files as there are categories.
 *
 * @param locale the locale to find the dictionary files for, as a string.
 * @param context the context on which to open the files upon.
 * @return an array of binary dictionary files, which may be empty but may not be null.
 */
public static File[] getCachedWordLists(final String locale, final Context context) {
    final File[] directoryList = DictionaryInfoUtils.getCachedDirectoryList(context);
    if (null == directoryList) return EMPTY_FILE_ARRAY;
    final HashMap<String, FileAndMatchLevel> cacheFiles = new HashMap<>();
    for (File directory : directoryList) {
        if (!directory.isDirectory()) continue;
        final String dirLocale =
                DictionaryInfoUtils.getWordListIdFromFileName(directory.getName());
        final int matchLevel = LocaleUtils.getMatchLevel(dirLocale, locale);
        if (LocaleUtils.isMatch(matchLevel)) {
            final File[] wordLists = directory.listFiles();
            if (null != wordLists) {
                for (File wordList : wordLists) {
                    final String category =
                            DictionaryInfoUtils.getCategoryFromFileName(wordList.getName());
                    final FileAndMatchLevel currentBestMatch = cacheFiles.get(category);
                    if (null == currentBestMatch || currentBestMatch.mMatchLevel < matchLevel) {
                        cacheFiles.put(category, new FileAndMatchLevel(wordList, matchLevel));
                    }
                }
            }
        }
    }
    if (cacheFiles.isEmpty()) return EMPTY_FILE_ARRAY;
    final File[] result = new File[cacheFiles.size()];
    int index = 0;
    for (final FileAndMatchLevel entry : cacheFiles.values()) {
        result[index++] = entry.mFile;
    }
    return result;
}
 
Example 9
Project: openNaEF   File: PseudoWireCommandBuilder.java   View Source Code Vote up 5 votes
private void updateLspsByDto() {
    HashMap<MvoId, RsvpLspDto> deleteSet = new HashMap<MvoId, RsvpLspDto>();
    if (this.pw != null) {
        for (RsvpLspDto lsp : this.pw.getRsvpLsps()) {
            deleteSet.put(DtoUtil.getMvoId(lsp), lsp);
        }
    }
    RsvpLspDto lsp1_ = null;
    if (lsp1 != null) {
        lsp1_ = deleteSet.get(DtoUtil.getMvoId(lsp1));
    }
    if (lsp1_ != null) {
        deleteSet.remove(DtoUtil.getMvoId(lsp1));
    }
    RsvpLspDto lsp2_ = null;
    if (lsp2 != null) {
        lsp2_ = deleteSet.get(DtoUtil.getMvoId(lsp2));
    }
    if (lsp2_ != null) {
        deleteSet.remove(DtoUtil.getMvoId(lsp2));
    }
    for (RsvpLspDto deleteLsp : deleteSet.values()) {
        InventoryBuilder.translate(cmd, CMD.UNSTACK_LOWER_NETWORK,
                CMD.ARG_LOWER, deleteLsp.getAbsoluteName());
    }
    if (lsp1_ == null && lsp1 != null) {
        InventoryBuilder.translate(cmd, CMD.STACK_LOWER_NETWORK,
                CMD.ARG_LOWER, lsp1.getAbsoluteName());
    }
    if (lsp2_ == null && lsp2 != null) {
        InventoryBuilder.translate(cmd, CMD.STACK_LOWER_NETWORK,
                CMD.ARG_LOWER, lsp2.getAbsoluteName());
    }
}
 
Example 10
Project: astrobee_android   File: MainActivity.java   View Source Code Vote up 5 votes
public void openCamera() {
    Log.d(TAG, "openCamera");

    mUiHandler.obtainMessage(WHAT_STATE, STATE_DISCOVERING, -1).sendToTarget();

    HashMap<String, UsbDevice> deviceList = mUsbManager.getDeviceList();
    Log.d(TAG, String.format("%d USB devices", deviceList.size()));

    boolean found = false;
    for (UsbDevice device : deviceList.values()) {
        // TODO(tfmorse): deal with multiple picoflexx devices
        if (isRoyaleDevice(device)) {
            Log.d(TAG, "royale device found");
            found = true;
            if (!mUsbManager.hasPermission(device)) {
                mUsbManager.requestPermission(device, mUsbPi);
            } else {
                performUsbPermissionCallback(device);
            }
            break;
        }
    }

    if (!found) {
        Log.e(TAG, "No royale device found.");
        mUiHandler.obtainMessage(WHAT_STATE, STATE_NO_CAMERA, R.string.error_no_camera)
                .sendToTarget();
    }
}
 
Example 11
Project: xcc   File: TypeFinder.java   View Source Code Vote up 5 votes
public void run(Module m)
{
    // Get types for type definition in Module.
    HashMap<String, Type> st = m.getTypeSymbolTable();
    for (Type ty : st.values())
        incorperateType(ty);

    // Get the type of GlobalVariable.
    for (GlobalVariable gv : m.getGlobalVariableList())
    {
        incorperateType(gv.getType());
        if (gv.hasInitializer())
            incorperateValue(gv.getInitializer());
    }

    // Get types from functions.
    for (Function f : m.getFunctionList())
    {
        for (BasicBlock bb : f.getBasicBlockList())
        {
            for (Instruction inst:bb)
            {
                incorperateType(inst.getType());
                for (int i = 0, e = inst.getNumOfOperands(); i != e; i++)
                {
                    incorperateValue(inst.operand(i));
                }
            }
        }
    }
}
 
Example 12
Project: kafka-0.11.0.0-src-with-comment   File: TopicAdminTest.java   View Source Code Vote up 5 votes
private Cluster createCluster(int numNodes) {
    HashMap<Integer, Node> nodes = new HashMap<>();
    for (int i = 0; i != numNodes; ++i) {
        nodes.put(i, new Node(i, "localhost", 8121 + i));
    }
    Cluster cluster = new Cluster("mockClusterId", nodes.values(),
            Collections.<PartitionInfo>emptySet(), Collections.<String>emptySet(),
            Collections.<String>emptySet(), nodes.get(0));
    return cluster;
}
 
Example 13
Project: hadoop   File: FSImageTestUtil.java   View Source Code Vote up 5 votes
/**
 * Given a list of directories, assert that any files that are named
 * the same thing have the same contents. For example, if a file
 * named "fsimage_1" shows up in more than one directory, then it must
 * be the same.
 * @throws Exception 
 */
public static void assertParallelFilesAreIdentical(List<File> dirs,
    Set<String> ignoredFileNames) throws Exception {
  HashMap<String, List<File>> groupedByName = new HashMap<String, List<File>>();
  for (File dir : dirs) {
    for (File f : dir.listFiles()) {
      if (ignoredFileNames.contains(f.getName())) {
        continue;
      }
      
      List<File> fileList = groupedByName.get(f.getName());
      if (fileList == null) {
        fileList = new ArrayList<File>();
        groupedByName.put(f.getName(), fileList);
      }
      fileList.add(f);
    }
  }
  
  for (List<File> sameNameList : groupedByName.values()) {
    if (sameNameList.get(0).isDirectory()) {
      // recurse
      assertParallelFilesAreIdentical(sameNameList, ignoredFileNames);
    } else {
      if ("VERSION".equals(sameNameList.get(0).getName())) {
        assertPropertiesFilesSame(sameNameList.toArray(new File[0]));
      } else {
        assertFileContentsSame(sameNameList.toArray(new File[0]));
      }
    }
  }  
}
 
Example 14
Project: OasisLight-ServerManager   File: ShutDownTask.java   View Source Code Vote up 5 votes
@Override
public void run() {
    Main.getServerStateUpdaterTask().interrupt();
    Main.getServerCommandSchedulerTask().interrupt();
    Main.getServerFileCommunicatorTask().close();
    if (Main.getMonitorTask() != null) {
        Main.getMonitorTask().interrupt();
    }
    //End all server threads
    HashMap<String, Server> serverList = Storage.getServerList();
    synchronized (serverList) {
        for (Server s : serverList.values()) {
            s.endCurrentThread();
            s.endBackupThread();
        }
    }
    try {
        Main.getServerCommandSchedulerTask().join();
        Main.getServerStateUpdaterTask().join();
        Main.getServerFileCommunicatorTask().join();
        if (Main.getMonitorTask() != null) {
            Main.getMonitorTask().join();
        }
    } catch (InterruptedException e) {
        Printer.printError("ShutdownTask", "Shutting down task has been interrupted", e);
    }
    Printer.printBackgroundInfo("ShutdownTask", "The program has shutdown.");
    Printer.close();
}
 
Example 15
Project: Achtbaan   File: attractie.java   View Source Code Vote up 5 votes
public void remove__A()
{
	for(HashMap<Integer, ArmorStand> car : cars.values())
	{
		for(ArmorStand as : car.values())
		{
			as.remove();
		}
	}
}
 
Example 16
Project: Ducky-Mc-Duckerson   File: ListUserInvCS.java   View Source Code Vote up 5 votes
private void sendUserInv(Member member, MessageChannel channel, String prefix, Color color, Member requestedBy) {
    EmbedBuilder embed = new EmbedBuilder();
    Long guildID = member.getGuild().getIdLong();
    Long userID = member.getUser().getIdLong();
    UserProfile up;

    try {
        up = dbMan.getUserProfile(guildID, userID);
        HashMap<Long, Item> inv = up.getInv();

        embed.setColor(color);
        embed.setAuthor(localize(channel, "command.inv.title", member.getEffectiveName()), null, member.getUser().getAvatarUrl());
        if (inv.isEmpty()) {
            embed.addField(localize(channel, "command.inc.inventory"), localize(channel, "command.inv.empty"), false);
        } else {
            for (Item item : inv.values()) {
                embed.addField(localize(channel, "command.inv.item", item.getLocalizedName(channel), item.getItemID()), item.getDescription(channel), true);
            }
        }

        if (requestedBy != null)
            embed.addField("", localize(channel, "command.inv.requested_by", member.getEffectiveName(), requestedBy.getEffectiveName()), false);
        embed.setFooter(localize(channel, "command.inv.usage", prefix + commandName), null);
        embed.setTimestamp(Instant.now());

        embed.setThumbnail(member.getUser().getAvatarUrl());
        channel.sendMessage(embed.build()).queue();
    } catch (SQLException e) {
        e.printStackTrace();
    }
}
 
Example 17
Project: Customerly-Android-SDK   File: Customerly.java   View Source Code Vote up 5 votes
/**
 * Optionally you can specify the user company
 * @param pCompany The company of the user. The map must contain a String value with key "company_id" containing to the Company ID and a String value with key "name" containing the Company name. Can contain only String, char, int, long, float or double values
 * @return The Task itself for method chaining
 * @throws IllegalArgumentException if the company map check fails
 */
@CheckResult @NonNull public RegisterUserTask company(@Nullable HashMap<String,Object> pCompany) throws IllegalArgumentException{
    if(pCompany != null) {
        Collection<Object> attrs = pCompany.values();
        for(Object attr : attrs) {
            if(     attr instanceof String ||
                    attr instanceof Integer ||
                    attr instanceof Byte ||
                    attr instanceof Long ||
                    attr instanceof Double ||
                    attr instanceof Float ||
                    attr instanceof Character ||
                    attr instanceof Boolean) {
                continue;
            }
            _log("Company HashMap can contain only String, char, byte, int, long, float or double values");
            throw new IllegalArgumentException("Company HashMap can contain only String, char, byte, int, long, float or double values");
        }
        if(! pCompany.containsKey("company_id") && ! pCompany.containsKey("name")) {
            _log("Company HashMap must contain a String value with key \"company_id\" containing to the Company ID and a String value with key \"name\" containing the Company name");
            throw new IllegalArgumentException(
                    "Company HashMap must contain a String value with key \"company_id\" containing to the Company ID and a String value with key \"name\" containing the Company name"
            );
        }
        this.company = new JSONObject(pCompany);
    } else {
        this.company = null;
    }
    return this;
}
 
Example 18
Project: hacker-rank   File: Bear_And_Steady_Gene.java   View Source Code Vote up 5 votes
public static boolean fun(HashMap<Character,Integer> hm)
{
	for(int i : hm.values())
	{
		if(i > n/4)
			return false;
	}
	return true;
}
 
Example 19
Project: AndroidPhoneContacts   File: ContactsFetchManager.java   View Source Code Vote up 4 votes
/**
 * Populate contact array with provided data
 * @param mappedContactLabeledList LabelData
 */
private HashMap<ContactQueryType, LinkedHashSet<ContactInfo>> extractContactsMap(HashMap<String
        , LinkedHashSet<LabeledData>> mappedContactLabeledList) {
    String name = null;

    HashMap<ContactQueryType, LinkedHashSet<ContactInfo>> contacts = new HashMap<>();
    //Create a map for register ContactQueryType
    for (ContactQueryType contactQueryType : ContactQueryType.values()) {
        contacts.put(contactQueryType, new LinkedHashSet<ContactInfo>());
    }

    LinkedHashSet<ContactInfo> combinedEmail = contacts.get(ContactQueryType.COMBINED_EMAIL);
    LinkedHashSet<ContactInfo> combinedNumbers = contacts.get(ContactQueryType.COMBINED_PHONE);
    LinkedHashSet<ContactInfo> multipleNumbers = contacts.get(ContactQueryType.MULTIPLE_PHONE);
    LinkedHashSet<ContactInfo> multipleEmail = contacts.get(ContactQueryType.MULTIPLE_EMAIL);
    LinkedHashSet<ContactInfo> combinedContactInfos = contacts.get(ContactQueryType.COMBINED_EMAIL_PHONE);
    LinkedHashSet<ContactInfo> allPhoneEmail = contacts.get(ContactQueryType.ALL_PHONE_EMAIL);

    for (LinkedHashSet<LabeledData> labelDataList : mappedContactLabeledList.values()) {
        //A single contact info is extract from here
        ArrayList<LabeledData> emailOnlyData = new ArrayList<>();
        ArrayList<LabeledData> numberOnlyData = new ArrayList<>();

        for (LabeledData labeledData : labelDataList) {
            name = TextUtils.isEmpty(labeledData.mName) ? name : labeledData.mName;
            ContactInfo contactInfo = new ContactInfo(labeledData.mName, null, null);
            switch (labeledData.mDataType) {
                case EMAIL:
                    emailOnlyData.add(labeledData);
                    contactInfo.setEmailId(labeledData.mData);
                    contactInfo.setLabel(labeledData.mLabel);

                    //Add the label data for single entity in contact info
                    contactInfo.setLabeledDataList(labeledData);
                    allPhoneEmail.add(contactInfo);
                    multipleEmail.add(contactInfo);
                    break;
                case NUMBER:
                    numberOnlyData.add(labeledData);
                    contactInfo.setPhoneNumber(labeledData.mData);
                    contactInfo.setLabel(labeledData.mLabel);

                    //Add the label data for single entity in contact info
                    contactInfo.setLabeledDataList(labeledData);
                    allPhoneEmail.add(contactInfo);
                    multipleNumbers.add(contactInfo);
                    break;
            }
        }
        //Populate only email with collection in combined email contact info
        if (!emailOnlyData.isEmpty()) {
            ContactInfo combinedEmailInfo = new ContactInfo(name, null, null);
            combinedEmailInfo.setLabeledDataList(new ArrayList<>(emailOnlyData));
            combinedEmail.add(combinedEmailInfo);
        }

        //Populate only number with collection in combined number contact info
        if (!numberOnlyData.isEmpty()) {
            ContactInfo combinedNumberInfo = new ContactInfo(name, null, null);
            combinedNumberInfo.setLabeledDataList(new ArrayList<>(numberOnlyData));
            combinedNumbers.add(combinedNumberInfo);
        }

        //Populate number and email combined data in combined contact info
        ContactInfo combinedContactInfo = new ContactInfo(name, null, null);
        combinedContactInfo.setLabeledDataList(new ArrayList<>(labelDataList));
        combinedContactInfos.add(combinedContactInfo);
        //A single contact related data updation complete here
    }

    return contacts;
}
 
Example 20
Project: Dronology   File: FlightZoneView.java   View Source Code Vote up 4 votes
public void constructBases(int baseCount) throws FlightZoneException{
	baseManager = new BaseManager(5);
	HashMap<String,DroneBase> droneBases = baseManager.getBases();
	for (DroneBase base: droneBases.values()) 
	    root.getChildren().add(base.getCircle());	    
}