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

The following are Jave code examples for showing how to use values() of the java.util.Hashtable 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: jdk8u-jdk   File: SunFontManager.java   View Source Code Vote up 7 votes
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 2
Project: EvoServ   File: SGHSystem.java   View Source Code Vote up 6 votes
public int[] distFeaturesOnClients() {
    Hashtable<SGHFeature, Integer> count = new Hashtable<SGHFeature, Integer>();
    for (SGHClientApp c : clients) {
        for (SGHFeature f : c.featureSet) {
            if (!count.containsKey(f)) {
                count.put(f, 1);
            }
            else {
                count.put(f, count.get(f) + 1);
            }
        }
    }
    ArrayList<Integer> counts = new ArrayList<Integer>(count.values());
    Collections.sort(counts);
    int[] result = new int[counts.size()];
    for (int i=0; i<counts.size(); i++) result[counts.size()-i-1] = counts.get(i);
    return result;
}
 
Example 3
Project: EvoServ   File: SGHSystem.java   View Source Code Vote up 6 votes
public int[] distFeaturesOnServers() {
    Hashtable<SGHFeature, Integer> count = new Hashtable<SGHFeature, Integer>();
    for (SGHServer s : servers) {
        for (SGHFeature f : s.featureSet) {
            if (!count.containsKey(f)) {
                count.put(f, 1);
            }
            else {
                count.put(f, count.get(f) + 1);
            }
        }
    }
    ArrayList<Integer> counts = new ArrayList<Integer>(count.values());
    Collections.sort(counts);
    int[] result = new int[counts.size()];
    for (int i=0; i<counts.size(); i++) result[counts.size()-i-1] = counts.get(i);
    return result;
}
 
Example 4
Project: OpenJSharp   File: SunFontManager.java   View Source Code Vote up 6 votes
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
Project: openjdk-jdk10   File: SunFontManager.java   View Source Code Vote up 6 votes
public TreeMap<String, String> getCreatedFontFamilyNames() {

        Hashtable<String,FontFamily> familyTable;
        if (fontsAreRegistered) {
            familyTable = createdByFamilyName;
        } else if (fontsAreRegisteredPerAppContext) {
            AppContext appContext = AppContext.getAppContext();
            @SuppressWarnings("unchecked")
            Hashtable<String,FontFamily> tmp =
                (Hashtable<String,FontFamily>)appContext.get(regFamilyKey);
            familyTable = tmp;
        } 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 6
Project: openjdk-jdk10   File: SunFontManager.java   View Source Code Vote up 6 votes
public Font[] getCreatedFonts() {

        Hashtable<String,Font2D> nameTable;
        if (fontsAreRegistered) {
            nameTable = createdByFullName;
        } else if (fontsAreRegisteredPerAppContext) {
            AppContext appContext = AppContext.getAppContext();
            @SuppressWarnings("unchecked")
            Hashtable<String,Font2D> tmp =
                (Hashtable<String,Font2D>)appContext.get(regFullNameKey);
            nameTable = tmp;
        } 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
Project: sumo   File: Font.java   View Source Code Vote up 5 votes
/**
 * Unbinds all character pixmaps of this font.
 */
public void dispose() 
{
	Hashtable<ITexture, ITexture> set = new Hashtable<ITexture, ITexture>();
	
	for(Pixmap p: texHashMap.values())
		set.put(p.getTexture(), p.getTexture());
	
	for(ITexture t: set.values())
		t.dispose();
}
 
Example 8
Project: javaide   File: GetCollectionOfValuesFromHashtableExample.java   View Source Code Vote up 5 votes
public static void main(String[] args) {

    //create Hashtable object
    Hashtable ht = new Hashtable();

    //add key value pairs to Hashtable
    ht.put("1", "One");
    ht.put("2", "Two");
    ht.put("3", "Three");

    /*
      get Collection of values contained in Hashtable using
      Collection values() method of Hashtable class
    */

    Collection c = ht.values();

    System.out.println("Values of Collection created from Hashtable are :");
    //iterate through the collection
    Iterator itr = c.iterator();
    while (itr.hasNext()) System.out.println(itr.next());

    /*
       Please note that resultant Collection object is backed by the Hashtable.
       Any value that is removed from Collection will also be removed from
       original Hashtable object. The same is not the case with the element
       addition.
    */

    //remove One from collection
    c.remove("One");

    //print values of original values of Hashtable
    System.out.println("Hashtable values after removal from Collection are :");
    Enumeration e = ht.elements();
    while (e.hasMoreElements()) System.out.println(e.nextElement());
  }
 
Example 9
Project: OpenJSharp   File: SunFontManager.java   View Source Code Vote up 5 votes
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 10
Project: jdk8u-jdk   File: SunFontManager.java   View Source Code Vote up 5 votes
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 11
Project: aos-MediaLib   File: TagsFactory.java   View Source Code Vote up 4 votes
public static List<MovieTags> buildMovieFromCursor(Cursor cur) {
    Hashtable<Long, MovieTags> tags = new Hashtable<Long, MovieTags>();
    if(DBG) Log.d(TAG, "Building MovieTags from Cursor");
    if(!cur.moveToFirst())
        return null;
    do {
        Long id = Long.valueOf(getLongCol(cur, ScraperStore.Movie.ID));
        String name = getStringCol(cur, ScraperStore.Movie.NAME);
        float rating = getFloatCol(cur, ScraperStore.Movie.RATING);
        int year = getIntCol(cur, ScraperStore.Movie.YEAR);
        String plot = getStringCol(cur, ScraperStore.Movie.PLOT);
        String cover = getStringCol(cur, ScraperStore.Movie.COVER);
        String actorName = getStringCol(cur, ScraperStore.Movie.Actor.NAME);
        String role = getStringCol(cur, ScraperStore.Movie.Actor.ROLE);
        String director = getStringCol(cur, ScraperStore.Movie.Director.NAME);
        String genre = getStringCol(cur, ScraperStore.Movie.Genre.NAME);
        String studio = getStringCol(cur, ScraperStore.Movie.Studio.NAME);

        String backdropUrl = getStringCol(cur, ScraperStore.Movie.BACKDROP_URL);
        String backdropPath = getStringCol(cur, ScraperStore.Movie.BACKDROP);

        MovieTags tag = tags.get(id);
        if(tag == null) {
            tag = new MovieTags();
            tags.put(id, tag);
        }
        tag.setId(id.longValue());
        tag.setTitle(name);
        if(rating >= 0)
            tag.setRating(rating);
        if(year >= 0)
            tag.setYear(year);
        tag.setPlot(plot);

        if(cover != null)
            tag.setCover(new File(cover));

        tag.addActorIfAbsent(actorName, role);
        tag.addDirectorIfAbsent(director);
        tag.addGenreIfAbsent(genre);
        tag.addStudioIfAbsent(studio);

        if(backdropUrl != null && backdropPath != null) {
            ScraperImage image = new ScraperImage(Type.MOVIE_BACKDROP, null);
            image.setLargeUrl(backdropUrl);
            image.setLargeFile(backdropPath);
            tag.setBackdrops(image.asList());
        }

    } while(cur.moveToNext());
    return new ArrayList<MovieTags>(tags.values());
}
 
Example 12
Project: aos-MediaLib   File: TagsFactory.java   View Source Code Vote up 4 votes
public static List<ShowTags> buildShowFromCursor(Cursor cur) {
    Hashtable<Long, ShowTags> tags = new Hashtable<Long, ShowTags>();
    if(DBG) Log.d(TAG, "Building ShowTags from Cursor");
    if(!cur.moveToFirst())
        return null;
    do {
        Long id = Long.valueOf(getLongCol(cur, ScraperStore.Show.ID));
        String name = getStringCol(cur, ScraperStore.Show.NAME);
        float rating = getFloatCol(cur, ScraperStore.Show.RATING);
        long premiered = getLongCol(cur, ScraperStore.Show.PREMIERED);
        String plot = getStringCol(cur, ScraperStore.Show.PLOT);
        String cover = getStringCol(cur, ScraperStore.Show.COVER);
        String actorName = getStringCol(cur, ScraperStore.Show.Actor.NAME);
        String role = getStringCol(cur, ScraperStore.Show.Actor.ROLE);
        String director = getStringCol(cur, ScraperStore.Show.Director.NAME);
        String genre = getStringCol(cur, ScraperStore.Show.Genre.NAME);
        String studio = getStringCol(cur, ScraperStore.Show.Studio.NAME);

        String backdropUrl = getStringCol(cur, ScraperStore.Show.BACKDROP_URL);
        String backdropPath = getStringCol(cur, ScraperStore.Show.BACKDROP);

        ShowTags tag = tags.get(id);
        if(tag == null) {
            tag = new ShowTags();
            tags.put(id, tag);
        }
        tag.setTitle(name);
        tag.setId(id.longValue());
        if(rating >= 0)
            tag.setRating(rating);
        if(premiered >= 0)
            tag.setPremiered(premiered);
        tag.setPlot(plot);

        if(cover != null)
            tag.setCover(new File(cover));

        tag.addActorIfAbsent(actorName, role);
        tag.addDirectorIfAbsent(director);
        tag.addGenreIfAbsent(genre);
        tag.addStudioIfAbsent(studio);

        if(backdropUrl != null && backdropPath != null) {
            ScraperImage image = new ScraperImage(Type.SHOW_BACKDROP, null);
            image.setLargeUrl(backdropUrl);
            image.setLargeFile(backdropPath);
            tag.setBackdrops(image.asList());
        }
    } while(cur.moveToNext());
    return new ArrayList<ShowTags>(tags.values());
}
 
Example 13
Project: aos-MediaLib   File: TagsFactory.java   View Source Code Vote up 4 votes
public static List<EpisodeTags> buildEpisodeFromCursor(Cursor cur) {
    Hashtable<Long, EpisodeTags> tags = new Hashtable<Long, EpisodeTags>();
    if(DBG) Log.d(TAG, "Building MovieTags from Cursor");
    if(!cur.moveToFirst())
        return null;
    do {
        Long id = Long.valueOf(getLongCol(cur, ScraperStore.Episode.ID));
        String name = getStringCol(cur, ScraperStore.Episode.NAME);
        float rating = getFloatCol(cur, ScraperStore.Episode.RATING);
        long aired = getLongCol(cur, ScraperStore.Episode.AIRED);
        String plot = getStringCol(cur, ScraperStore.Episode.PLOT);
        int season = getIntCol(cur, ScraperStore.Episode.SEASON);
        int number = getIntCol(cur, ScraperStore.Episode.NUMBER);
        long show = getLongCol(cur, ScraperStore.Episode.SHOW);
        String actorName = getStringCol(cur, ScraperStore.Episode.Actor.NAME);
        String role = getStringCol(cur, ScraperStore.Episode.Actor.ROLE);
        String director = getStringCol(cur, ScraperStore.Episode.Director.NAME);
        String cover = getStringCol(cur, ScraperStore.Episode.COVER);

        EpisodeTags tag = tags.get(id);
        if(tag == null) {
            tag = new EpisodeTags();
            tags.put(id, tag);
        }
        tag.setId(id.longValue());
        tag.setTitle(name);
        if(rating >= 0)
            tag.setRating(rating);
        if(aired >= 0)
            tag.setAired(aired);
        tag.setPlot(plot);
        tag.setSeason(season);
        tag.setEpisode(number);
        tag.setShowId(show);
        tag.addActorIfAbsent(actorName, role);
        tag.addDirectorIfAbsent(director);

        if(cover != null)
            tag.setCover(new File(cover));

    } while(cur.moveToNext());
    return new ArrayList<EpisodeTags>(tags.values());
}