icltermcache.java

来自「SRI international 发布的OAA框架软件」· Java 代码 · 共 57 行

JAVA
57
字号
package com.sri.oaa2.icl;
import java.util.HashMap;

public class IclTermCache 
{
  public static HashMap cacheMap = new HashMap();

  public static IclTerm get(String s) 
  {
    synchronized(cacheMap) {
      if(cacheMap.containsKey(s)) {
        IclTerm t = (IclTerm)cacheMap.get(s);
        t = ToReadOnly.getInstance().from(t, false);
        AnonNumberer.getInstance().renumber(t);
        t = ToReadOnly.getInstance().from(t, true);
        return t;
      }
      else {
        IclTerm t;
        try {
          t = IclTerm.fromString(s);
        }
        catch(Exception e) {
          RuntimeException re = new RuntimeException(e.toString());
          re.fillInStackTrace();
          throw re;
        }
        cacheMap.put(s, t);
        return t;
      }
    }
  }

  public static IclTerm getNoAnon(String s) 
  {
    synchronized(cacheMap) {
      if(cacheMap.containsKey(s)) {
        IclTerm t = (IclTerm)cacheMap.get(s);
        return t;
      }
      else {
        IclTerm t;
        try {
          t = IclTerm.fromString(s);
        }
        catch(Exception e) {
          RuntimeException re = new RuntimeException(e.toString());
          re.fillInStackTrace();
          throw re;
        }
        cacheMap.put(s, t);
        return t;
      }
    }
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?