FileDocCategorySizeDatePackage
BidiMapExample.javaAPI DocExample2083Wed May 18 09:38:58 BST 2005com.discursive.jccook.collections.bidi

BidiMapExample

public class BidiMapExample extends Object

Fields Summary
private org.apache.commons.collections.BidiMap
countryCodes
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)


	     
		BidiMapExample example = new BidiMapExample();
		example.start();
	
private voidpopulateCountryCodes()

		countryCodes.put("to","Tonga");
		countryCodes.put("tr","Turkey");
		countryCodes.put("tv","Tuvalu");
		countryCodes.put("tz","Tanzania");
		countryCodes.put("ua","Ukraine");
		countryCodes.put("ug","Uganda");
		countryCodes.put("uk","United Kingdom");
		countryCodes.put("um","USA Minor Outlying Islands");
		countryCodes.put("us","United States");
		countryCodes.put("uy","Uruguay");
	
private voidstart()

		populateCountryCodes();
		
		String countryName = (String) countryCodes.get( "tr" );
		System.out.println( "Country Name for code 'tr': " + countryName );

		String countryCode = (String) countryCodes.inverseBidiMap().get("Uruguay");
		System.out.println( "Country Code for name 'Uruguay': " + countryCode );
			
		countryCode = (String) countryCodes.getKey("Ukraine");
		System.out.println( "Country Code for name 'Ukraine': " + countryCode );