/** Constructor */
  public PrideInspectorContext() {
    // instantiate data access monitor
    this.dataAccessMonitor = new DataAccessMonitor();

    // data content pane cache
    this.dataContentPaneCache =
        Collections.synchronizedMap(new HashMap<DataAccessController, JComponent>());

    // data summary pane cache
    this.dataSummaryPaneCache =
        Collections.synchronizedMap(new HashMap<DataAccessController, JComponent>());

    // action map
    this.sharedActionCache =
        Collections.synchronizedMap(
            new HashMap<DataAccessController, Map<Class<? extends PrideAction>, PrideAction>>());

    // summary report tracker
    this.summaryReportTracker =
        Collections.synchronizedMap(new HashMap<DataAccessController, ListModel>());

    // by default the data source browser is invisible
    this.leftControlPaneVisible = false;

    // set the default path for opening/saving files
    this.setOpenFilePath(System.getProperty("user.dir"));
  }
 @Override
 public boolean onUnbind(final Intent intent) {
   final Map<String, DictionaryPool> oldPools = mDictionaryPools;
   mDictionaryPools = Collections.synchronizedMap(new TreeMap<String, DictionaryPool>());
   final Map<String, Dictionary> oldUserDictionaries = mUserDictionaries;
   mUserDictionaries = Collections.synchronizedMap(new TreeMap<String, Dictionary>());
   final Map<String, Dictionary> oldWhitelistDictionaries = mWhitelistDictionaries;
   mWhitelistDictionaries = Collections.synchronizedMap(new TreeMap<String, Dictionary>());
   for (DictionaryPool pool : oldPools.values()) {
     pool.close();
   }
   for (Dictionary dict : oldUserDictionaries.values()) {
     dict.close();
   }
   for (Dictionary dict : oldWhitelistDictionaries.values()) {
     dict.close();
   }
   if (null != mContactsDictionary) {
     // The synchronously loaded contacts dictionary should have been in one
     // or several pools, but it is shielded against multiple closing and it's
     // safe to call it several times.
     final SynchronouslyLoadedContactsDictionary dictToClose = mContactsDictionary;
     mContactsDictionary = null;
     dictToClose.close();
   }
   return false;
 }
 /**
  * Constructor
  *
  * @param delegator The delegator instance
  */
 public UserTransactionRegistryImpl(org.jboss.tm.usertx.UserTransactionRegistry delegator) {
   this.delegator = delegator;
   this.listeners =
       Collections.synchronizedMap(
           new HashMap<UserTransactionListener, UserTransactionListenerImpl>());
   this.providers =
       Collections.synchronizedMap(
           new HashMap<UserTransactionProvider, UserTransactionProviderImpl>());
 }
Example #4
0
 public SearchDirector(IIndexingParameters parameters) {
   logger = LogFactory.getLog(getClass());
   crawlers = Collections.synchronizedMap(new HashMap<String, ICrawler>());
   runnables = Collections.synchronizedMap(new HashMap<ICrawler, RunnableCrawler>());
   runningCrawlers = Collections.synchronizedMap(new HashMap<String, Thread>());
   idxMgr = new IndexManager(parameters);
   stopped = false;
   this.parameters = parameters;
   registerCrawlers();
   logger.info("SearchDirector created.");
 }
  private ProxyManager() {
    this.stratumAuthorizationManager = new AuthorizationManager();
    this.pools = Collections.synchronizedList(new ArrayList<Pool>());
    this.workerConnections = new CopyOnWriteArrayList<WorkerConnection>();
    this.users = Collections.synchronizedMap(new HashMap<String, User>());
    this.poolWorkerConnections =
        Collections.synchronizedMap(new HashMap<Pool, Set<WorkerConnection>>());
    this.poolSwitchingStrategyFactory = new PoolSwitchingStrategyFactory(this);

    setPoolSwitchingStrategy(ConfigurationManager.getInstance().getPoolSwitchingStrategy());
  }
Example #6
0
  static {
    accountsByID = Collections.synchronizedMap(new HashMap<Integer, Account>());
    accountsByEmail = Collections.synchronizedMap(new HashMap<String, Account>());
    charactersByID = Collections.synchronizedMap(new HashMap<Integer, PlayerCharacter>());
    charactersByName = Collections.synchronizedMap(new HashMap<String, PlayerCharacter>());
    playersByID = Collections.synchronizedMap(new HashMap<Integer, ActivePlayer>());

    // TODO: Remove hardcoded account, useful for testing.
    Account daniel = new Account("d@l.com", "abcdef");
    new PlayerCharacter("Wally", daniel, CombatClass.WARRIOR);
    new PlayerCharacter("Maggie", daniel, CombatClass.MAGE);
  }
  protected AbstractAnnotationLoadingSession(
      URI defaultTargetTypeUri, URI defaultTargetSourceTypeUri) {
    this.defaultTargetTypeUri = defaultTargetTypeUri;
    this.defaultTargetSourceTypeUri = defaultTargetSourceTypeUri;

    this.studyCache = Collections.synchronizedMap(new HashMap<URI, Study>());
    this.biologicalEntityCache = Collections.synchronizedMap(new HashMap<URI, BiologicalEntity>());
    this.propertyCache = Collections.synchronizedMap(new HashMap<URI, Property>());
    this.annotationCache = Collections.synchronizedMap(new HashMap<URI, SimpleAnnotation>());

    this.messageDigest = ZoomaUtils.generateMessageDigest();
  }
Example #8
0
 /**
  * Constructs a new <code>Session</code>.
  *
  * @param changed <code>true</code> if the session has changed, <code>false</code> otherwise.
  */
 public Session(File descriptorFile, boolean changed) {
   this.descriptorFile = descriptorFile;
   this.changed = changed;
   sessionListeners = Collections.synchronizedList(new ArrayList<SessionListener>());
   sessionElementListeners = Collections.synchronizedList(new ArrayList<SessionElementListener>());
   objectSelectionChangeListeners =
       Collections.synchronizedList(new ArrayList<ObjectSelectionChangeListener>());
   descriptors = Collections.synchronizedList(new ArrayList<SessionElementDescriptor>());
   selectedObjects = new SessionElementDescriptor[0];
   pcs = new PropertyChangeSupport(this);
   clientProperties = Collections.synchronizedMap(new HashMap<String, String>());
   persistentClientProperties = Collections.synchronizedMap(new HashMap<String, String>());
 }
  public StagedMultipleSPFExecutor(Logger log, DNSAsynchLookupService service) {
    this.log = log;
    this.dnsProbe = service;

    this.responseQueue = new ResponseQueueImpl();

    this.sessions = Collections.synchronizedMap(new HashMap<Integer, SPFSession>());
    this.results = Collections.synchronizedMap(new HashMap<Integer, FutureSPFResult>());

    this.worker = new Thread(this);
    this.worker.setDaemon(true);
    this.worker.setName("SPFExecutor");
    this.worker.start();
  }
 public Builder attributes(Map<String, Object> attributes) {
   localAttributes =
       ConcurrentHashMap.class.isAssignableFrom(attributes.getClass())
           ? attributes
           : Collections.synchronizedMap(attributes);
   return this;
 }
public class MemoryCache {

  private static MemoryCache sharedCache;

  public static MemoryCache sharedCache(Context context) {
    if (sharedCache == null) {
      sharedCache = new MemoryCache();
    }
    return sharedCache;
  }

  private Map<String, SoftReference<Bitmap>> cache =
      Collections.synchronizedMap(new HashMap<String, SoftReference<Bitmap>>());

  public Bitmap get(String id) {
    if (!cache.containsKey(id)) return null;
    SoftReference<Bitmap> ref = cache.get(id);
    return ref.get();
  }

  public void put(String id, Bitmap bitmap) {
    cache.put(id, new SoftReference<Bitmap>(bitmap));
  }

  public void clear() {
    cache.clear();
  }
}
Example #12
0
 private static void registerDefaultProviders() {
   if (providers == null || defaultProvider == null) {
     // 不使用硬编码包名字符串的方式,重命名包名时常常忘记
     String packageName = FilePath.class.getPackage().getName() + ".";
     Map<String, FilePath> map = Collections.synchronizedMap(New.<String, FilePath>hashMap());
     for (String c :
         new String[] {
           "FilePathDisk",
           "FilePathMem",
           "FilePathMemLZF",
           "FilePathNioMem",
           "FilePathNioMemLZF",
           "FilePathSplit",
           "FilePathNio",
           "FilePathNioMapped",
           "FilePathZip"
         }) {
       try {
         FilePath p = (FilePath) Class.forName(packageName + c).newInstance();
         map.put(p.getScheme(), p);
         if (defaultProvider == null) {
           defaultProvider = p;
         }
       } catch (Exception e) {
         // ignore - the files may be excluded in purpose
       }
     }
     providers = map;
   }
 }
 /**
  * constructor
  *
  * @param context image context
  */
 public ReflectionImageLoader(Context context) {
   this.context = context;
   fileCache = new FileCache(context);
   executorService = Executors.newFixedThreadPool(5);
   memoryCache = new MemoryCache();
   imageViews = Collections.synchronizedMap(new WeakHashMap<ImageView, String>());
 }
Example #14
0
 private static void registerDefaultProviders() {
   if (providers == null || defaultProvider == null) {
     Map<String, FilePath> map = Collections.synchronizedMap(New.<String, FilePath>hashMap());
     // 默认是org.h2.store.fs.FilePathDisk, 所以这里不包含它
     // 但是少了org.h2.store.fs.FilePathRec、org.h2.mvstore.cache.FilePathCache
     // 不过org.h2.store.fs.FilePathRec是通过org.h2.store.fs.FilePath.register(FilePath)这个方法注册
     // 见org.h2.store.fs.FilePathRec.register(),
     // 在org.h2.engine.ConnectionInfo.ConnectionInfo(String, Properties)调用它了
     for (String c :
         new String[] {
           "org.h2.store.fs.FilePathDisk",
           "org.h2.store.fs.FilePathMem",
           "org.h2.store.fs.FilePathMemLZF",
           "org.h2.store.fs.FilePathNioMem",
           "org.h2.store.fs.FilePathNioMemLZF",
           "org.h2.store.fs.FilePathSplit",
           "org.h2.store.fs.FilePathNio",
           "org.h2.store.fs.FilePathNioMapped",
           "org.h2.store.fs.FilePathZip"
         }) {
       try {
         FilePath p = (FilePath) Class.forName(c).newInstance();
         map.put(p.getScheme(), p);
         if (defaultProvider == null) {
           defaultProvider = p;
         }
       } catch (Exception e) {
         // ignore - the files may be excluded in purpose
       }
     }
     providers = map;
   }
 }
  private Scene createScene() {
    lock.lock();
    try {
      final CategoryAxis xAxis = new CategoryAxis();
      final NumberAxis yAxis = new NumberAxis();
      //            yAxis.setUpperBound(500);
      //            yAxis.setAutoRanging(false);
      final BarChart<String, Number> bc = new BarChart<>(xAxis, yAxis);
      bc.setTitle("Communication - " + this.algStr);
      xAxis.setLabel("Time (t)");
      yAxis.setLabel("Messages (m)");

      XYChart.Series series1 = new XYChart.Series();
      series1.setName("Messages sent to UAVs at time t of simulation");

      ChartDatastore chartDatastore = new ChartDatastore();
      Map<Integer, Integer> gData =
          (inforSharingAlg == CC_StaticInitConfig.BROADCAST_INFOSHARE)
              ? chartDatastore.getMessagesPerSecondData_broadcast()
              : chartDatastore.getMessagesPerSecondData_register();
      Map<Integer, Integer> gDataSync = Collections.synchronizedMap(gData);
      for (Integer t : gDataSync.keySet()) {
        series1.getData().add(new XYChart.Data(String.valueOf(t), gData.get(t)));
      }

      bc.getData().addAll(series1);
      bc.setAnimated(false);
      Scene scene = new Scene(bc, 800, 600);
      return scene;
    } finally {
      lock.unlock();
    }
  }
Example #16
0
 static {
   TreeMap v = new TreeMap();
   v.put("WshRunning", WshRunning);
   v.put("WshFinished", WshFinished);
   v.put("WshFailed", WshFailed);
   values = Collections.synchronizedMap(Collections.unmodifiableMap(v));
 }
  public ExternalAccessControlManager(
      NamespaceRegistry namespaceRegistry,
      ExternalSessionImpl session,
      ExternalDataSource dataSource) {

    this.session = session;
    this.workspaceName = session.getWorkspace().getName();
    this.aclReadOnly =
        dataSource instanceof ExternalDataSource.AccessControllable
            || dataSource instanceof ExternalDataSource.SupportPrivileges;
    this.writable = dataSource instanceof ExternalDataSource.Writable;
    this.supportPrivileges = dataSource instanceof ExternalDataSource.SupportPrivileges;
    this.rootUserName = JahiaUserManagerService.getInstance().getRootUserName();
    this.dataSource = dataSource;

    this.pathPermissionCache =
        Collections.synchronizedMap(
            new LRUMap(SettingsBean.getInstance().getAccessManagerPathPermissionCacheMaxSize()));
    this.jahiaPrincipal =
        new JahiaPrincipal(
            session.getUserID(),
            session.getRealm(),
            session.getUserID().startsWith(JahiaLoginModule.SYSTEM),
            JahiaLoginModule.GUEST.equals(session.getUserID()));
    try {
      registry = new JahiaPrivilegeRegistry(namespaceRegistry);
      this.modifyAccessControlPrivilege =
          registry.getPrivilege("jcr:modifyAccessControl", workspaceName);
      this.writePrivilege = registry.getPrivilege("jcr:write", workspaceName);
    } catch (RepositoryException e) {
      throw new JahiaRuntimeException(e);
    }
  }
/**
 * Announce常量
 *
 * @author yj
 */
public final class AnnounceConstants {

  /** 私有构造 */
  private AnnounceConstants() {}

  /** 显示最新常量:1-最新 */
  public static final String NEW = "1";

  /** 显示最新常量:0-旧的 */
  public static final String OLD = "0";

  /** 显示类型常量:1-滚动 */
  public static final String SHOETYPE = "1";

  /** 显示类型常量:0-弹出 */
  public static final String UNSHOETYPE = "0";

  /** 显示类型常量Map */
  public static final Map<String, String> SHOUTYPE_MAP =
      Collections.synchronizedMap(new LinkedHashMap<String, String>());

  static {
    SHOUTYPE_MAP.put(SHOETYPE, "滚动");
    SHOUTYPE_MAP.put(UNSHOETYPE, "弹出");
  }
}
public class InterceptorRegistry {

  private static Map<Class<?>, Set<Object>> interceptors =
      Collections.synchronizedMap(new HashMap<Class<?>, Set<Object>>());

  public static <T extends Interceptor> void register(Class<T> type, T instance) {
    if (type == null) throw new IllegalArgumentException("Type may not be null");
    if (instance == null) throw new IllegalArgumentException("Instance may not be null");
    if (!interceptors.containsKey(type)) {
      interceptors.put(type, Collections.synchronizedSet(new HashSet<Object>()));
    }
    interceptors.get(type).add(instance);
  }

  @SuppressWarnings("unchecked")
  public static <T extends Interceptor> Set<T> getInstances(Class<T> type) {
    if (interceptors.containsKey(type)) {
      return ((Set<T>) interceptors.get(type));
    } else {
      return Collections.emptySet();
    }
  }

  public static <T extends Interceptor> void deregister(T instance) {
    interceptors.get(instance.getClass()).remove(instance);
  }

  public static void clear() {
    interceptors.clear();
  }
}
  @Test
  @Ignore("Intended for use during development only")
  public void shouldBeFasterThanSynchronizedMap() throws Exception {
    Map<Integer, WeakReference<String>> synchronizedMap =
        Collections.synchronizedMap(new WeakHashMap<Integer, WeakReference<String>>());
    StopWatch mapTime =
        timeMultiThreaded(
            "SynchronizedMap",
            synchronizedMap,
            new ValueFactory<WeakReference<String>>() {

              @Override
              public WeakReference<String> newValue(int v) {
                return new WeakReference<String>(String.valueOf(v));
              }
            });
    System.out.println(mapTime.prettyPrint());

    this.map.setDisableTestHooks(true);
    StopWatch cacheTime =
        timeMultiThreaded(
            "WeakConcurrentCache",
            this.map,
            new ValueFactory<String>() {

              @Override
              public String newValue(int v) {
                return String.valueOf(v);
              }
            });
    System.out.println(cacheTime.prettyPrint());

    // We should be at least 4 time faster
    assertThat(cacheTime.getTotalTimeSeconds(), is(lessThan(mapTime.getTotalTimeSeconds() / 4.0)));
  }
  static {
    /*
     * We use a synchronized map because it will be filled by using a
     * lazy strategy.
     */
    parameters = Collections.synchronizedMap(new HashMap<Object, Object>());
    try {
      /* Read property file (if exists).*/
      Class<ConfigurationParametersManager> configurationParametersManagerClass =
          ConfigurationParametersManager.class;
      ClassLoader classLoader = configurationParametersManagerClass.getClassLoader();
      InputStream inputStream = classLoader.getResourceAsStream(CONFIGURATION_FILE);
      Properties properties = new Properties();
      properties.load(inputStream);
      inputStream.close();

      /* We have been able to read the file. */
      usesJNDI = false;
      parameters.putAll(properties);

      System.out.println("*** Using '" + CONFIGURATION_FILE + "' file for configuration ***");
    } catch (Exception e) {
      /* We have not been able to read the file. */
      usesJNDI = true;
    }
  }
/**
 * hbase中表存在信息;
 *
 * @author penglong
 */
public class HbaseTableExistence {

  private static Logger LOG = LoggerFactory.getLogger(MysqlCommonTableDao.class);

  public static final Map<String, Boolean> tableExistenceMap =
      Collections.synchronizedMap(new HashMap<String, Boolean>());

  static {
    initTableExistenceInfo();
  }

  /** 初始化表存在信息; */
  private static void initTableExistenceInfo() {
    try {
      List<String> lst = HbaseClient.listTableExist();
      for (String tablename : lst) {
        tableExistenceMap.put(tablename.toUpperCase(), Boolean.TRUE);
      }
    } catch (Throwable e) {
      LOG.info("初始化表的存在信息失败:", e);
    }
  }

  public static void main(String[] args) {
    System.out.println(JSON.toJSONString(MysqlTableExistence.tableExistenceMap));
  }
}
Example #23
0
 static {
   TreeMap<String, Object> v = new TreeMap<String, Object>();
   v.put("xlParamTypeUnknown", xlParamTypeUnknown);
   v.put("xlParamTypeChar", xlParamTypeChar);
   v.put("xlParamTypeNumeric", xlParamTypeNumeric);
   v.put("xlParamTypeDecimal", xlParamTypeDecimal);
   v.put("xlParamTypeInteger", xlParamTypeInteger);
   v.put("xlParamTypeSmallInt", xlParamTypeSmallInt);
   v.put("xlParamTypeFloat", xlParamTypeFloat);
   v.put("xlParamTypeReal", xlParamTypeReal);
   v.put("xlParamTypeDouble", xlParamTypeDouble);
   v.put("xlParamTypeVarChar", xlParamTypeVarChar);
   v.put("xlParamTypeDate", xlParamTypeDate);
   v.put("xlParamTypeTime", xlParamTypeTime);
   v.put("xlParamTypeTimestamp", xlParamTypeTimestamp);
   v.put("xlParamTypeLongVarChar", xlParamTypeLongVarChar);
   v.put("xlParamTypeBinary", xlParamTypeBinary);
   v.put("xlParamTypeVarBinary", xlParamTypeVarBinary);
   v.put("xlParamTypeLongVarBinary", xlParamTypeLongVarBinary);
   v.put("xlParamTypeBigInt", xlParamTypeBigInt);
   v.put("xlParamTypeTinyInt", xlParamTypeTinyInt);
   v.put("xlParamTypeBit", xlParamTypeBit);
   v.put("xlParamTypeWChar", xlParamTypeWChar);
   values = Collections.synchronizedMap(Collections.unmodifiableMap(v));
 }
/** @author Aleksa Vukotic */
public class InPlaceEventCollector {
  private Map<String, MarketDataEvent> store =
      Collections.synchronizedMap(new HashMap<String, MarketDataEvent>());

  private final Object keyPropertyName;

  public InPlaceEventCollector(Object keyPropertyName) {
    this.keyPropertyName = keyPropertyName;
  }

  public void collect(EventBean[] eventBeans) throws RuntimeException {
    for (EventBean eventBean : eventBeans) {
      addEvent(eventBean);
    }
  }

  private synchronized void addEvent(EventBean eventBean) {
    String key = eventBean.get(keyPropertyName.toString()).toString();
    MarketDataEvent marketDataEvent = new MarketDataEvent();
    marketDataEvent.setSymbol(key);
    marketDataEvent.setPrice(new Double(eventBean.get("avg(price)").toString()));
    marketDataEvent.setAsk(new Double(eventBean.get("avg(ask)").toString()));
    marketDataEvent.setBid(new Double(eventBean.get("avg(bid)").toString()));

    store.put(key, marketDataEvent);
  }

  public Map<String, MarketDataEvent> getStore() {
    return store;
  }
}
Example #25
0
 public PreventionManager() {
   demoPrevs = new LRUMap(MAXITEMS);
   mShell = new HashMap<String, LRUMap>(1);
   mShell.put(PREVS, demoPrevs);
   mShell = Collections.synchronizedMap(mShell);
   pf = PreventionDS.getInstance();
 }
Example #26
0
 static {
   TreeMap<String, Object> v = new TreeMap<String, Object>();
   v.put("xlLinkInfoOLELinks", xlLinkInfoOLELinks);
   v.put("xlLinkInfoPublishers", xlLinkInfoPublishers);
   v.put("xlLinkInfoSubscribers", xlLinkInfoSubscribers);
   values = Collections.synchronizedMap(Collections.unmodifiableMap(v));
 }
 public void init(final ServletContext context, final Map<String, String> paras) {
   _startTime = new Date();
   _context = context;
   _sipFactory = (SipFactory) context.getAttribute(ServletContextConstants.SIP_FACTORY);
   _mrcpFactory = (MrcpFactory) context.getAttribute(ServletContextConstants.MRCP_FACTORY);
   _appJarUrl =
       _context.getRealPath("/")
           + "WEB-INF"
           + File.separator
           + "lib"
           + File.separator
           + "tropo.jar";
   _cache = Collections.synchronizedMap(new WeakHashMap<Object, Application>());
   _tmx = ManagementFactory.getThreadMXBean();
   _mmx = ManagementFactory.getMemoryMXBean();
   try {
     _tropoBuildDate = Utils.getManifestAttribute(_appJarUrl, "Build-Date");
   } catch (final IOException t) {
     LOG.error(t.toString(), t);
     _tropoBuildDate = "Unknown";
   }
   try {
     _tropoVersionNo = Utils.getManifestAttribute(_appJarUrl, "Version-No");
   } catch (final IOException t) {
     LOG.error(t.toString(), t);
     _tropoVersionNo = "Unknown";
   }
   try {
     _tropoBuildNo = Utils.getManifestAttribute(_appJarUrl, "Build-No");
   } catch (final IOException t) {
     LOG.error(t.toString(), t);
     _tropoBuildNo = "Unknown";
   }
   LOG.info(toString() + " / " + getVersionNo() + " / " + getBuildNo());
 }
Example #28
0
public class LocaleUtils {

  private static final Pattern UNDER_LINE_PATTERN = Pattern.compile("_");

  private static final int LOCALE_CACHE_SIZE = 10000;

  private static final Map<String, Locale> LOCALE_CACHE =
      Collections.synchronizedMap(
          new LinkedHashMap<String, Locale>() {
            private static final long serialVersionUID = 1377741378297004026L;

            @Override
            protected boolean removeEldestEntry(Entry<String, Locale> eldest) {
              return size() > LOCALE_CACHE_SIZE;
            }
          });

  public static String appendLocale(String name, Locale locale) {
    if (locale == null) {
      return name;
    }
    int i = name.lastIndexOf('.');
    return i < 0
        ? name + "_" + locale.toString()
        : name.substring(0, i) + "_" + locale.toString() + name.substring(i);
  }

  public static Locale getParentLocale(Locale locale) {
    if (locale == null) {
      return null;
    }
    String name = locale.toString();
    int i = name.lastIndexOf('_');
    if (i > 0) {
      return getLocale(name.substring(0, i));
    }
    return null;
  }

  public static Locale getLocale(String name) {
    if (name == null || name.length() == 0) {
      return null;
    }
    Locale locale = LOCALE_CACHE.get(name);
    if (locale == null) {
      String[] parts = UNDER_LINE_PATTERN.split(name);
      if (parts.length > 2) {
        locale = new Locale(parts[0], parts[1], parts[2]);
        LOCALE_CACHE.put(name, locale);
      } else if (parts.length > 1) {
        locale = new Locale(parts[0], parts[1]);
        LOCALE_CACHE.put(name, locale);
      } else if (parts.length > 0) {
        locale = new Locale(parts[0]);
        LOCALE_CACHE.put(name, locale);
      }
    }
    return locale;
  }
}
 static {
   TreeMap<String, Object> v = new TreeMap<String, Object>();
   v.put("wdBalloonPrintOrientationAuto", wdBalloonPrintOrientationAuto);
   v.put("wdBalloonPrintOrientationPreserve", wdBalloonPrintOrientationPreserve);
   v.put("wdBalloonPrintOrientationForceLandscape", wdBalloonPrintOrientationForceLandscape);
   values = Collections.synchronizedMap(Collections.unmodifiableMap(v));
 }
/** MemoryCache is responsible for caching the Bitmap to optimize the performance of ListView. */
public class MemoryCache {
  private Map<String, SoftReference<Bitmap>> cache =
      Collections.synchronizedMap(new HashMap<String, SoftReference<Bitmap>>(10));

  /**
   * Returns the Bitmap associated with given key url.
   *
   * @param id url of bitmap.
   * @return Bitmap associated with the url.
   */
  public Bitmap get(String id) {
    if (!cache.containsKey(id)) {
      return null;
    }
    SoftReference<Bitmap> ref = cache.get(id);
    return ref.get();
  }

  /**
   * Put the bitmap to cache with url as a key.
   *
   * @param id url of bitmap.
   * @param bitmap Bitmap downloaded from url.
   */
  public void put(String id, Bitmap bitmap) {
    cache.put(id, new SoftReference<>(bitmap));
  }

  /** Clears the bitmap cache. */
  public void clear() {
    cache.clear();
  }
}