Java Code Examples for java.util.Hashtable#values()

The following examples show how to use java.util.Hashtable#values() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ViewResponseHelper.java    From cloudstack with Apache License 2.0 6 votes vote down vote up
public static List<ImageStoreResponse> createImageStoreResponse(ImageStoreJoinVO... stores) {
    Hashtable<Long, ImageStoreResponse> vrDataList = new Hashtable<Long, ImageStoreResponse>();
    // Initialise the vrdatalist with the input data
    for (ImageStoreJoinVO vr : stores) {
        ImageStoreResponse vrData = vrDataList.get(vr.getId());
        if (vrData == null) {
            // first time encountering this vm
            vrData = ApiDBUtils.newImageStoreResponse(vr);
        } else {
            // update tags
            vrData = ApiDBUtils.fillImageStoreDetails(vrData, vr);
        }
        vrDataList.put(vr.getId(), vrData);
    }
    return new ArrayList<ImageStoreResponse>(vrDataList.values());
}
 
Example 2
Source File: SunFontManager.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public Font[] getCreatedFonts() {

        Hashtable<String,Font2D> nameTable;
        if (fontsAreRegistered) {
            nameTable = createdByFullName;
        } else if (fontsAreRegisteredPerAppContext) {
            AppContext appContext = AppContext.getAppContext();
            nameTable =
                (Hashtable<String,Font2D>)appContext.get(regFullNameKey);
        } else {
            return null;
        }

        Locale l = getSystemStartupLocale();
        synchronized (nameTable) {
            Font[] fonts = new Font[nameTable.size()];
            int i=0;
            for (Font2D font2D : nameTable.values()) {
                fonts[i++] = new Font(font2D.getFontName(l), Font.PLAIN, 1);
            }
            return fonts;
        }
    }
 
Example 3
Source File: ViewResponseHelper.java    From cosmic with Apache License 2.0 6 votes vote down vote up
public static List<DomainRouterResponse> createDomainRouterResponse(final DomainRouterJoinVO... routers) {
    final Account caller = CallContext.current().getCallingAccount();
    final Hashtable<Long, DomainRouterResponse> vrDataList = new Hashtable<>();
    // Initialise the vrdatalist with the input data
    for (final DomainRouterJoinVO vr : routers) {
        DomainRouterResponse vrData = vrDataList.get(vr.getId());
        if (vrData == null) {
            // first time encountering this vm
            vrData = ApiDBUtils.newDomainRouterResponse(vr, caller);
        } else {
            // update nics for 1 to many mapping fields
            vrData = ApiDBUtils.fillRouterDetails(vrData, vr);
        }
        vrDataList.put(vr.getId(), vrData);
    }
    return new ArrayList<>(vrDataList.values());
}
 
Example 4
Source File: SunFontManager.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public Font[] getCreatedFonts() {

        Hashtable<String,Font2D> nameTable;
        if (fontsAreRegistered) {
            nameTable = createdByFullName;
        } else if (fontsAreRegisteredPerAppContext) {
            AppContext appContext = AppContext.getAppContext();
            nameTable =
                (Hashtable<String,Font2D>)appContext.get(regFullNameKey);
        } else {
            return null;
        }

        Locale l = getSystemStartupLocale();
        synchronized (nameTable) {
            Font[] fonts = new Font[nameTable.size()];
            int i=0;
            for (Font2D font2D : nameTable.values()) {
                fonts[i++] = new Font(font2D.getFontName(l), Font.PLAIN, 1);
            }
            return fonts;
        }
    }
 
Example 5
Source File: ViewResponseHelper.java    From cloudstack with Apache License 2.0 6 votes vote down vote up
public static List<DomainRouterResponse> createDomainRouterResponse(DomainRouterJoinVO... routers) {
    Account caller = CallContext.current().getCallingAccount();
    Hashtable<Long, DomainRouterResponse> vrDataList = new Hashtable<Long, DomainRouterResponse>();
    // Initialise the vrdatalist with the input data
    for (DomainRouterJoinVO vr : routers) {
        DomainRouterResponse vrData = vrDataList.get(vr.getId());
        if (vrData == null) {
            // first time encountering this vm
            vrData = ApiDBUtils.newDomainRouterResponse(vr, caller);
        } else {
            // update nics for 1 to many mapping fields
            vrData = ApiDBUtils.fillRouterDetails(vrData, vr);
        }
        vrDataList.put(vr.getId(), vrData);
    }
    return new ArrayList<DomainRouterResponse>(vrDataList.values());
}
 
Example 6
Source File: SunFontManager.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public Font[] getCreatedFonts() {

        Hashtable<String,Font2D> nameTable;
        if (fontsAreRegistered) {
            nameTable = createdByFullName;
        } else if (fontsAreRegisteredPerAppContext) {
            AppContext appContext = AppContext.getAppContext();
            nameTable =
                (Hashtable<String,Font2D>)appContext.get(regFullNameKey);
        } else {
            return null;
        }

        Locale l = getSystemStartupLocale();
        synchronized (nameTable) {
            Font[] fonts = new Font[nameTable.size()];
            int i=0;
            for (Font2D font2D : nameTable.values()) {
                fonts[i++] = new Font(font2D.getFontName(l), Font.PLAIN, 1);
            }
            return fonts;
        }
    }
 
Example 7
Source File: ViewResponseHelper.java    From cosmic with Apache License 2.0 6 votes vote down vote up
public static List<HostForMigrationResponse> createHostForMigrationResponse(final EnumSet<HostDetails> details, final HostJoinVO... hosts) {
    final Hashtable<Long, HostForMigrationResponse> vrDataList = new Hashtable<>();
    // Initialise the vrdatalist with the input data
    for (final HostJoinVO vr : hosts) {
        HostForMigrationResponse vrData = vrDataList.get(vr.getId());
        if (vrData == null) {
            // first time encountering this vm
            vrData = ApiDBUtils.newHostForMigrationResponse(vr, details);
        } else {
            // update tags
            vrData = ApiDBUtils.fillHostForMigrationDetails(vrData, vr);
        }
        vrDataList.put(vr.getId(), vrData);
    }
    return new ArrayList<>(vrDataList.values());
}
 
Example 8
Source File: ViewResponseHelper.java    From cloudstack with Apache License 2.0 6 votes vote down vote up
public static List<StoragePoolResponse> createStoragePoolForMigrationResponse(StoragePoolJoinVO... pools) {
    Hashtable<Long, StoragePoolResponse> vrDataList = new Hashtable<Long, StoragePoolResponse>();
    // Initialise the vrdatalist with the input data
    for (StoragePoolJoinVO vr : pools) {
        StoragePoolResponse vrData = vrDataList.get(vr.getId());
        if (vrData == null) {
            // first time encountering this vm
            vrData = ApiDBUtils.newStoragePoolForMigrationResponse(vr);
        } else {
            // update tags
            vrData = ApiDBUtils.fillStoragePoolForMigrationDetails(vrData, vr);
        }
        vrDataList.put(vr.getId(), vrData);
    }
    return new ArrayList<StoragePoolResponse>(vrDataList.values());
}
 
Example 9
Source File: SunFontManager.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public Font[] getCreatedFonts() {

        Hashtable<String,Font2D> nameTable;
        if (fontsAreRegistered) {
            nameTable = createdByFullName;
        } else if (fontsAreRegisteredPerAppContext) {
            AppContext appContext = AppContext.getAppContext();
            nameTable =
                (Hashtable<String,Font2D>)appContext.get(regFullNameKey);
        } else {
            return null;
        }

        Locale l = getSystemStartupLocale();
        synchronized (nameTable) {
            Font[] fonts = new Font[nameTable.size()];
            int i=0;
            for (Font2D font2D : nameTable.values()) {
                fonts[i++] = new Font(font2D.getFontName(l), Font.PLAIN, 1);
            }
            return fonts;
        }
    }
 
Example 10
Source File: ViewResponseHelper.java    From cosmic with Apache License 2.0 6 votes vote down vote up
public static List<ProjectResponse> createProjectResponse(final ProjectJoinVO... projects) {
    final Hashtable<Long, ProjectResponse> prjDataList = new Hashtable<>();
    // Initialise the prjdatalist with the input data
    for (final ProjectJoinVO p : projects) {
        ProjectResponse pData = prjDataList.get(p.getId());
        if (pData == null) {
            // first time encountering this vm
            pData = ApiDBUtils.newProjectResponse(p);
        } else {
            // update those  1 to many mapping fields
            pData = ApiDBUtils.fillProjectDetails(pData, p);
        }
        prjDataList.put(p.getId(), pData);
    }
    return new ArrayList<>(prjDataList.values());
}
 
Example 11
Source File: ViewResponseHelper.java    From cosmic with Apache License 2.0 6 votes vote down vote up
public static List<ImageStoreResponse> createImageStoreResponse(final ImageStoreJoinVO... stores) {
    final Hashtable<Long, ImageStoreResponse> vrDataList = new Hashtable<>();
    // Initialise the vrdatalist with the input data
    for (final ImageStoreJoinVO vr : stores) {
        ImageStoreResponse vrData = vrDataList.get(vr.getId());
        if (vrData == null) {
            // first time encountering this vm
            vrData = ApiDBUtils.newImageStoreResponse(vr);
        } else {
            // update tags
            vrData = ApiDBUtils.fillImageStoreDetails(vrData, vr);
        }
        vrDataList.put(vr.getId(), vrData);
    }
    return new ArrayList<>(vrDataList.values());
}
 
Example 12
Source File: ChatAllHistoryActivity.java    From school_shop with MIT License 5 votes vote down vote up
/**
	 * 获取所有会话
	 * 
	 * @param context
	 * @return
+	 */
	private List<EMConversation> loadConversationsWithRecentChat() {
		// 获取所有会话,包括陌生人
		Hashtable<String, EMConversation> conversations = EMChatManager.getInstance().getAllConversations();
		// 过滤掉messages size为0的conversation
		/**
		 * 如果在排序过程中有新消息收到,lastMsgTime会发生变化
		 * 影响排序过程,Collection.sort会产生异常
		 * 保证Conversation在Sort过程中最后一条消息的时间不变 
		 * 避免并发问题
		 */
		List<Pair<Long, EMConversation>> sortList = new ArrayList<Pair<Long, EMConversation>>();
		synchronized (conversations) {
			for (EMConversation conversation : conversations.values()) {
				if (conversation.getAllMessages().size() != 0) {
					sortList.add(new Pair<Long, EMConversation>(conversation.getLastMessage().getMsgTime(), conversation));
				}
			}
		}
		try {
			// Internal is TimSort algorithm, has bug
			sortConversationByLastChatTime(sortList);
		} catch (Exception e) {
			e.printStackTrace();
		}
		List<EMConversation> list = new ArrayList<EMConversation>();
		for (Pair<Long, EMConversation> sortItem : sortList) {
			list.add(sortItem.second);
		}
		return list;
	}
 
Example 13
Source File: EaseConversationListFragment.java    From monolog-android with MIT License 5 votes vote down vote up
/**
 * 获取会话列表
 *
 * @return
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    +    */
protected List<EMConversation> loadConversationList(){
    // 获取所有会话,包括陌生人
    Hashtable<String, EMConversation> conversations = EMChatManager.getInstance().getAllConversations();
    // 过滤掉messages size为0的conversation
    /**
     * 如果在排序过程中有新消息收到,lastMsgTime会发生变化
     * 影响排序过程,Collection.sort会产生异常
     * 保证Conversation在Sort过程中最后一条消息的时间不变 
     * 避免并发问题
     */
    List<Pair<Long, EMConversation>> sortList = new ArrayList<Pair<Long, EMConversation>>();
    synchronized (conversations) {
        for (EMConversation conversation : conversations.values()) {
            if (conversation.getAllMessages().size() != 0) {
                //if(conversation.getType() != EMConversationType.ChatRoom){
                    sortList.add(new Pair<Long, EMConversation>(conversation.getLastMessage().getMsgTime(), conversation));
                //}
            }
        }
    }
    try {
        // Internal is TimSort algorithm, has bug
        sortConversationByLastChatTime(sortList);
    } catch (Exception e) {
        e.printStackTrace();
    }
    List<EMConversation> list = new ArrayList<EMConversation>();
    for (Pair<Long, EMConversation> sortItem : sortList) {
        list.add(sortItem.second);
    }
    return list;
}
 
Example 14
Source File: SunFontManager.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public TreeMap<String, String> getCreatedFontFamilyNames() {

        Hashtable<String,FontFamily> familyTable;
        if (fontsAreRegistered) {
            familyTable = createdByFamilyName;
        } else if (fontsAreRegisteredPerAppContext) {
            AppContext appContext = AppContext.getAppContext();
            familyTable =
                (Hashtable<String,FontFamily>)appContext.get(regFamilyKey);
        } else {
            return null;
        }

        Locale l = getSystemStartupLocale();
        synchronized (familyTable) {
            TreeMap<String, String> map = new TreeMap<String, String>();
            for (FontFamily f : familyTable.values()) {
                Font2D font2D = f.getFont(Font.PLAIN);
                if (font2D == null) {
                    font2D = f.getClosestStyle(Font.PLAIN);
                }
                String name = font2D.getFamilyName(l);
                map.put(name.toLowerCase(l), name);
            }
            return map;
        }
    }
 
Example 15
Source File: SunFontManager.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public TreeMap<String, String> getCreatedFontFamilyNames() {

        Hashtable<String,FontFamily> familyTable;
        if (fontsAreRegistered) {
            familyTable = createdByFamilyName;
        } else if (fontsAreRegisteredPerAppContext) {
            AppContext appContext = AppContext.getAppContext();
            familyTable =
                (Hashtable<String,FontFamily>)appContext.get(regFamilyKey);
        } else {
            return null;
        }

        Locale l = getSystemStartupLocale();
        synchronized (familyTable) {
            TreeMap<String, String> map = new TreeMap<String, String>();
            for (FontFamily f : familyTable.values()) {
                Font2D font2D = f.getFont(Font.PLAIN);
                if (font2D == null) {
                    font2D = f.getClosestStyle(Font.PLAIN);
                }
                String name = font2D.getFamilyName(l);
                map.put(name.toLowerCase(l), name);
            }
            return map;
        }
    }
 
Example 16
Source File: Validator.java    From Hidden-Markov-Model with MIT License 5 votes vote down vote up
public boolean summationIsOne(Hashtable<String, Double> list) {
    double sum = 0.0;

    for (double item : list.values()) {
        sum += item;
    }

    return sum == 1.0;
}
 
Example 17
Source File: ViewResponseHelper.java    From cosmic with Apache License 2.0 5 votes vote down vote up
public static List<VolumeResponse> createVolumeResponse(final ResponseView view, final VolumeJoinVO... volumes) {
    final Hashtable<Long, VolumeResponse> vrDataList = new Hashtable<>();
    for (final VolumeJoinVO vr : volumes) {
        VolumeResponse vrData = vrDataList.get(vr.getId());
        if (vrData == null) {
            // first time encountering this volume
            vrData = ApiDBUtils.newVolumeResponse(view, vr);
        } else {
            // update tags
            vrData = ApiDBUtils.fillVolumeDetails(view, vrData, vr);
        }
        vrDataList.put(vr.getId(), vrData);
    }
    return new ArrayList<>(vrDataList.values());
}
 
Example 18
Source File: SunFontManager.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public TreeMap<String, String> getCreatedFontFamilyNames() {

        Hashtable<String,FontFamily> familyTable;
        if (fontsAreRegistered) {
            familyTable = createdByFamilyName;
        } else if (fontsAreRegisteredPerAppContext) {
            AppContext appContext = AppContext.getAppContext();
            familyTable =
                (Hashtable<String,FontFamily>)appContext.get(regFamilyKey);
        } else {
            return null;
        }

        Locale l = getSystemStartupLocale();
        synchronized (familyTable) {
            TreeMap<String, String> map = new TreeMap<String, String>();
            for (FontFamily f : familyTable.values()) {
                Font2D font2D = f.getFont(Font.PLAIN);
                if (font2D == null) {
                    font2D = f.getClosestStyle(Font.PLAIN);
                }
                String name = font2D.getFamilyName(l);
                map.put(name.toLowerCase(l), name);
            }
            return map;
        }
    }
 
Example 19
Source File: FragmentCoversation.java    From FanXin-based-HuanXin with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 获取所有会话
 * 
 * @param context
 * @return +
 */
private List<EMConversation> loadConversationsWithRecentChat() {
    // 获取所有会话,包括陌生人
    Hashtable<String, EMConversation> conversations = EMChatManager
            .getInstance().getAllConversations();

    List<EMConversation> list = new ArrayList<EMConversation>();
    List<EMConversation> topList1 = new ArrayList<EMConversation>();

    // 置顶列表再刷新一次

    // 过滤掉messages seize为0的conversation
    for (EMConversation conversation : conversations.values()) {

        if (conversation.getAllMessages().size() != 0) {
            // 不在置顶列表里面
            if (!topMap.containsKey(conversation.getUserName())) {
                list.add(conversation);
            } else {
                // 在置顶列表里面
                topList1.add(conversation);
            }
            //
            // for(EMMessage msg:conversation.getAllMessages()){
            // if(msg.getFrom().equals("admin")){
            // try {
            // Log.e("type--->>",msg.getStringAttribute("type"));
            // Log.e("groupid--->>",msg.getStringAttribute("groupid"));
            // } catch (EaseMobException e) {
            // // TODO Auto-generated catch block
            // e.printStackTrace();
            // }
            // }
            //
            // }

        }

    }
    top_list.clear();
    top_list.addAll(topList1);
    // 排序
    sortConversationByLastChatTime(list);
    sortConversationByLastChatTime(top_list);
    return list;
}
 
Example 20
Source File: TablePainter.java    From weblaf with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Returns whether or not table is language-sensitive.
 *
 * @return {@code true} if table is language-sensitive, {@code false} otherwise
 */
protected boolean isLanguageSensitive ()
{
    boolean sensitive = false;
    if ( component instanceof LanguageSensitive ||
            component.getModel () instanceof LanguageSensitive )
    {
        // Either table or its model is language-sensitive
        sensitive = true;
    }
    else
    {
        // Checking whether or not one of table column renderers is language-sensitive
        final TableColumnModel columnModel = component.getColumnModel ();
        for ( int i = 0; i < columnModel.getColumnCount (); i++ )
        {
            if ( columnModel.getColumn ( i ).getCellRenderer () instanceof LanguageSensitive )
            {
                sensitive = true;
                break;
            }
        }
        if ( !sensitive )
        {
            // Checking whether or not one of table default renderers is language-sensitive
            final Hashtable defaultRenderers = ReflectUtils.getFieldValueSafely ( component, "defaultRenderersByColumnClass" );
            if ( defaultRenderers != null )
            {
                for ( final Object renderer : defaultRenderers.values () )
                {
                    if ( renderer instanceof LanguageSensitive )
                    {
                        sensitive = true;
                        break;
                    }
                }
            }
            if ( !sensitive )
            {
                // Checking whether or not table data is language-sensitive
                final TableModel model = component.getModel ();
                for ( int row = 0; row < model.getRowCount (); row++ )
                {
                    for ( int col = 0; col < model.getColumnCount (); col++ )
                    {
                        if ( model.getValueAt ( row, col ) instanceof LanguageSensitive )
                        {
                            sensitive = true;
                            break;
                        }
                    }
                    if ( sensitive )
                    {
                        break;
                    }
                }
            }
        }
    }
    return sensitive;
}