Exemplo n.º 1
0
  public CompositeMap loadByURL(String url) throws IOException, SAXException {

    if (!getCacheEnabled()) return loadByURL_NC(url);
    CompositeMap m = getCachedMap(url);
    if (m == null) {
      m = loadByURL_NC(url);
      saveCachedMap(url, m);
    }
    return (CompositeMap) m.clone();
  }
Exemplo n.º 2
0
 public CompositeMap loadFromClassPath(String full_name, String file_ext)
     throws IOException, SAXException {
   if (!mCacheEnabled || mCache == null) return loadFromClassPath_NC(full_name, file_ext);
   String name = full_name + '#' + file_ext;
   CompositeMap m = (CompositeMap) mCache.getValue(name);
   if (m == null) {
     m = loadFromClassPath_NC(full_name, file_ext);
     saveCachedMap(name, m);
   }
   return (CompositeMap) m.clone();
 }
Exemplo n.º 3
0
  public CompositeMap loadByFullFilePath(String file_name) throws IOException, SAXException {

    if (!getCacheEnabled()) return loadByFullFilePath_NC(file_name);
    CompositeMap m = getCachedMap(file_name);
    if (m == null) {
      m = loadByFullFilePath_NC(file_name);
      saveCachedMap(file_name, m);
    }
    return (CompositeMap) m.clone();
    // return m;
  }
Exemplo n.º 4
0
 public CompositeMap loadByFullFilePath_NC(String file_name) throws IOException, SAXException {
   FileInputStream fis = null;
   try {
     fis = new FileInputStream(file_name);
     CompositeMap map = parse(fis);
     map.setSourceFile(new File(file_name));
     return map;
   } finally {
     if (fis != null) fis.close();
   }
 }
Exemplo n.º 5
0
 CompositeMap parse(InputStream stream) throws IOException, SAXException {
   CompositeMapParser p = new CompositeMapParser(this);
   CompositeMap m = p.parseStream(stream);
   if (mSupportFileMerge) {
     String base_file = m.getString(KEY_BASE_FILE);
     if (base_file != null && m.getChilds() != null) {
       CompositeMap base = load(base_file);
       CompositeMap merged = ElementModifier.process(m.getChilds(), base);
       return merged;
     }
   }
   return m;
 }
Exemplo n.º 6
0
 protected void saveCachedMap(Object key, CompositeMap map) {
   if (mCache != null && map != null) mCache.setValue(key, map);
   if (mSourceFileManager != null) {
     File source = map.getSourceFile();
     if (source != null) {
       ISourceFile sf = mSourceFileManager.addSourceFile(source);
       sf.addUpdateListener(new CachedSourceFileCleaner(mCache, key));
     }
   }
 }