use of java.beans.XMLDecoder in project wcomponents by BorderTech.
the class SimplePicker method loadRecentList.
/**
* Retrieves the list of recently selected examples from a file on the file system.
*
* @return the list of recently used examples.
*/
private List loadRecentList() {
try {
InputStream in = new BufferedInputStream(new FileInputStream(RECENT_FILE_NAME));
XMLDecoder d = new XMLDecoder(in);
Object result = d.readObject();
d.close();
return (List) result;
} catch (FileNotFoundException ex) {
// This is ok, it's probably the first time the picker has been used.
return new ArrayList();
}
}
use of java.beans.XMLDecoder in project BiglyBT by BiglySoftware.
the class UserManagerXMLPersist method doLoad.
@Override
public void doLoad(InputStream in, Map usersMap) {
XMLDecoder decoder = new XMLDecoder(in);
UserManagerConfig managerConfig = (UserManagerConfig) decoder.readObject();
for (Iterator iter = managerConfig.getUsers().iterator(); iter.hasNext(); ) {
UserProfile user = (UserProfile) iter.next();
usersMap.put(user.getUsername().toLowerCase(), user);
}
System.out.println("UserManager: registered " + usersMap.size() + " users");
decoder.close();
}
use of java.beans.XMLDecoder in project epp.mpc by eclipse.
the class MarketplaceInfo method load.
/**
* This method is only public for testing purposes. Do not override or call directly.
*
* @noreference This method is not intended to be referenced by clients.
* @nooverride This method is not intended to be re-implemented or extended by clients.
*/
public MarketplaceInfo load() {
RegistryFile registryFile = createRegistryFile();
File loadFile = registryFile.load();
if (loadFile != null && loadFile.canRead()) {
synchronized (MarketplaceInfo.class) {
try {
final InputStream in = new BufferedInputStream(new FileInputStream(loadFile));
try {
XMLDecoder decoder = new XMLDecoder(in);
Object object = decoder.readObject();
decoder.close();
return (MarketplaceInfo) object;
} finally {
in.close();
}
} catch (Throwable t) {
// ignore, fallback
IStatus status = new Status(IStatus.WARNING, MarketplaceClientUi.BUNDLE_ID, Messages.MarketplaceInfo_LoadError, t);
MarketplaceClientUi.getLog().log(status);
// try to delete broken file
loadFile.delete();
}
}
}
return null;
}
use of java.beans.XMLDecoder in project compss by bsc-wdc.
the class Serializer method deserializeXML.
/**
* Reads a XML-serialized object from a byte array
*
* @param data
* containing the serialized object
* @return the object read from the data
*/
private static Object deserializeXML(byte[] data) throws IOException, ClassNotFoundException {
ByteArrayInputStream bis = new ByteArrayInputStream(data);
XMLDecoder d = null;
try {
d = new XMLDecoder(new BufferedInputStream(bis));
return d.readObject();
} finally {
if (d != null) {
d.close();
}
try {
bis.close();
} catch (IOException ex) {
// ignore close exception
}
}
}
use of java.beans.XMLDecoder in project whole by wholeplatform.
the class BeansPersistenceKit method doReadModel.
protected IEntity doReadModel(IPersistenceProvider pp) throws Exception {
// TODO cannot use getEncoding()
XMLDecoder decoder = new XMLDecoder(new BufferedInputStream(pp.getInputStream()) {
@Override
public void close() throws IOException {
}
}, null, new ExceptionListener() {
public void exceptionThrown(Exception e) {
// do nothing
}
}, ReflectionFactory.getPlatformClassLoader());
IEntity model = (IEntity) decoder.readObject();
decoder.close();
return model;
}
Aggregations