Package de.danet.an.util

Examples of de.danet.an.util.SegmentedMap


     */
    public void getAllResources() throws Exception {
  ResourceBundle bundle
      = ResourceBundle.getBundle("util.I18nTest", Locale.GERMANY);
  ResourceBundleAsMap rbm = new ResourceBundleAsMap(bundle);
  SegmentedMap segmap = new SegmentedMap(rbm);

  // Make sure that german property file is used
  assertTrue(bundle.getLocale().toString().equals("de"));
  int i = segmap.size();
  // Verfiy that all entries have been found
  assertTrue(i==21);
    }
View Full Code Here


  resultList.addAll(Arrays.asList(resultKeys));
 
  ResourceBundle bundle
      = ResourceBundle.getBundle("util.I18nTest", Locale.GERMANY);
  ResourceBundleAsMap rbm = new ResourceBundleAsMap(bundle);
  SegmentedMap segmap = new SegmentedMap(rbm);
  Set myKeySet = segmap.keySet("danet.oss");
  int i = 0;
  assertTrue(myKeySet.containsAll(resultList));
  i = myKeySet.size();
  // Verfiy that all entries have been found
  assertTrue(i==resultKeys.length);
View Full Code Here

  resultList.addAll(Arrays.asList(resultKeys));

  ResourceBundle bundle
      = ResourceBundle.getBundle("util.I18nTest", Locale.GERMANY);
  ResourceBundleAsMap rbm = new ResourceBundleAsMap(bundle);
  SegmentedMap segmap = new SegmentedMap(rbm);
  int i = 0;
  Set myKeySet = segmap.keySet("danet.oss.an");
  assertTrue(myKeySet.containsAll(resultList));
  i = myKeySet.size();
  // Verfiy that all entries have been found
  assertTrue(i==resultKeys.length);
    }
View Full Code Here

  resultList.addAll(Arrays.asList(resultKeys));

  ResourceBundle bundle
      = ResourceBundle.getBundle("util.I18nTest", Locale.GERMANY);
  ResourceBundleAsMap rbm = new ResourceBundleAsMap(bundle);
  SegmentedMap segmap = new SegmentedMap(rbm);
  int i = 0;
  Set myKeySet = segmap.keySet("telekom");
  assertTrue(myKeySet.containsAll(resultList));
  i = myKeySet.size();
  // Verfiy that all entries have been found
  assertTrue(i==resultKeys.length);
    }
View Full Code Here

     */
    public void getKeysOfEmptyPath() throws Exception {
  ResourceBundle bundle
      = ResourceBundle.getBundle("util.I18nTest", Locale.GERMANY);
  ResourceBundleAsMap rbm = new ResourceBundleAsMap(bundle);
  SegmentedMap segmap = new SegmentedMap(rbm);
  int i = 0;
  Set myKeySet = segmap.keySet();
  i = myKeySet.size();
  // Verfiy that all entries have been found
  assertTrue(i==21);
    }
View Full Code Here

     */
    public void getValues() throws Exception {
  ResourceBundle bundle
      = ResourceBundle.getBundle("util.I18nTest", Locale.GERMANY);
  ResourceBundleAsMap rbm = new ResourceBundleAsMap(bundle);
  SegmentedMap segmap = new SegmentedMap(rbm);

  // oss.an has its own PKW resource
  assertTrue(segmap.get("danet.oss.an.poolPKW").equals("DA-AN 964"));
  // oss.sm uses the PKW resource of oss
  assertTrue(segmap.get("danet.oss.sm.poolPKW").equals("DA-OS 137"));
  // bss.bs uses the PKW resource of danet
  assertTrue(segmap.get("danet.bss.bs.poolPKW").equals("DA-NET 123"));
  // everybody uses danet
  assertTrue(segmap.get("danet.oss.an.danet").equals("Danet GmbH"));
  boolean notFound = false;
  Object value = segmap.get("telekom.poolPKW");
  if ( (value == null)
       && !segmap.containsKey("telekom.poolPKW") ) {
      notFound = true;
  }
  assertTrue(notFound);
    }
View Full Code Here

     */
    public void testKeyListCache() throws Exception {
  ResourceBundle bundle
      = ResourceBundle.getBundle("util.I18nTest", Locale.GERMANY);
  ResourceBundleAsMap rbm = new ResourceBundleAsMap(bundle);
  SegmentedMap segmap = new SegmentedMap(rbm);
  Set keyList1 = segmap.keySet("telekom");
  Set keyList2 = segmap.keySet("telekom");
  Set keyList3 = segmap.keySet("danet");
  Set keyList4 = segmap.keySet("telekom.t-data");
  // Verfiy that keylist1 matches keylist2
  assertTrue(keyList1.equals(keyList2));
  // Verfiy that keylist1 doesn't match keylist3
  assertTrue(!(keyList1.equals(keyList3)));
  // Verfiy that keylist1 doesn't match keylist4
View Full Code Here

     */
    public void testValueCache() throws Exception {
  ResourceBundle bundle
      = ResourceBundle.getBundle("util.I18nTest", Locale.GERMANY);
  ResourceBundleAsMap rbm = new ResourceBundleAsMap(bundle);
  SegmentedMap segmap = new SegmentedMap(rbm);

  String pkw1 = (String)segmap.get("danet.oss.sm.poolPKW");
  String pkw2 = (String)segmap.get("danet.oss.poolPKW");
  String pkw3 = (String)segmap.get("danet.oss.sm.poolPKW");
  assertTrue(pkw1.equals(pkw2));
  assertTrue(pkw1 == pkw3);
    }
View Full Code Here

    private static Map mapMap = new HashMap ();

    private static SegmentedMap getMap (String baseName, Locale loc) {
  String key = baseName + "@" + loc.toString();
  synchronized (mapMap) {
      SegmentedMap res = (SegmentedMap)mapMap.get (key);
      if (res != null) {
    return res;
      }
      ResourceBundle bundle = ResourceBundle.getBundle
    (baseName, Locale.getDefault(),
     Thread.currentThread().getContextClassLoader());
      res = new SegmentedMap (new ResourceBundleAsMap (bundle));
      mapMap.put (key, res);
      return res;
  }
    }
View Full Code Here

                String segment) {
  // Get new document fragment
  DocumentFragment frag = doc.createDocumentFragment();

  // Create mapping entries
  SegmentedMap map = getMap (baseName, Locale.getDefault());
  for (Iterator i = map.keySet (segment).iterator(); i.hasNext();) {
      String key = (String)i.next();
      Element mapping = doc.createElement("mapping");
      // Remove segment name + "." from path
      mapping.setAttribute("key", key.substring(segment.length()+1) );
      mapping.appendChild(doc.createTextNode ((String)map.get(key)));
      frag.appendChild(mapping);
  }
  return frag;
 
    }
View Full Code Here

TOP

Related Classes of de.danet.an.util.SegmentedMap

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.