Java 类weka.core.xml.XMLBasicSerialization 实例源码

项目:repo.kmeanspp.silhouette_score    文件:XMLFileBasedMetaStore.java   
@Override
public synchronized void storeEntry(String storeName, String name,
  Object toStore) throws IOException {
  establishStoreHome();
  Map<String, File> store = m_stores.get(storeName);
  if (store == null) {
    createStore(storeName);
    store = new LinkedHashMap<String, File>();
    m_stores.put(storeName, store);
  }

  File loc =
    new File(m_storeHome.toString() + File.separator + storeName, name);
  store.put(name, loc);
  try {
    lockStore();
    XMLBasicSerialization serializer = new XMLBasicSerialization();
    serializer.write(loc, toStore);
  } catch (Exception ex) {
    throw new IOException(ex);
  } finally {
    unlockStore();
  }
}
项目:umple    文件:XMLFileBasedKFMetaStore.java   
@Override
public synchronized void storeEntry(String storeName, String name,
  Object toStore) throws IOException {
  establishStoreHome();
  Map<String, File> store = m_stores.get(storeName);
  if (store == null) {
    createStore(storeName);
    store = new LinkedHashMap<String, File>();
    m_stores.put(storeName, store);
  }

  File loc =
    new File(m_storeHome.toString() + File.separator + storeName, name);
  store.put(name, loc);
  try {
    lockStore();
    XMLBasicSerialization serializer = new XMLBasicSerialization();
    serializer.write(loc, toStore);
  } catch (Exception ex) {
    throw new IOException(ex);
  } finally {
    unlockStore();
  }
}
项目:repo.kmeanspp.silhouette_score    文件:XMLFileBasedMetaStore.java   
@Override
public Object getEntry(String storeName, String name, Class<?> clazz)
  throws IOException {
  establishStoreHome();

  Map<String, File> store = m_stores.get(storeName);

  if (store != null) {
    if (store.containsKey(name)) {
      File toLoad = store.get(name);

      try {
        lockStore();
        XMLBasicSerialization deserializer = new XMLBasicSerialization();
        Object loaded = deserializer.read(toLoad);

        if (loaded.getClass().equals(clazz)) {
          throw new IOException("Deserialized entry ("
            + loaded.getClass().getName() + ") was not "
            + "the expected class: " + clazz.getName());
        }

        return loaded;
      } catch (Exception ex) {
        throw new IOException(ex);
      } finally {
        unlockStore();
      }
    }
  }

  return null;
}
项目:umple    文件:XMLFileBasedKFMetaStore.java   
@Override
public Object getEntry(String storeName, String name, Class<?> clazz)
  throws IOException {
  establishStoreHome();

  Map<String, File> store = m_stores.get(storeName);

  if (store != null) {
    if (store.containsKey(name)) {
      File toLoad = store.get(name);

      try {
        lockStore();
        XMLBasicSerialization deserializer = new XMLBasicSerialization();
        Object loaded = deserializer.read(toLoad);

        if (loaded.getClass().equals(clazz)) {
          throw new IOException("Deserialized entry ("
            + loaded.getClass().getName() + ") was not "
            + "the expected class: " + clazz.getName());
        }

        return loaded;
      } catch (Exception ex) {
        throw new IOException(ex);
      } finally {
        unlockStore();
      }
    }
  }

  return null;
}