Search in sources :

Example 1 with JsonParser

use of com.google.api.client.json.JsonParser in project robospice by stephanenicolas.

the class JsonObjectPersister method readCacheDataFromFile.

// ============================================================================================
// METHODS
// ============================================================================================
@Override
protected T readCacheDataFromFile(File file) throws CacheLoadingException {
    try {
        JsonParser jsonParser = jsonFactory.createJsonParser(new FileReader(file));
        T result = jsonParser.parse(getHandledClass(), null);
        jsonParser.close();
        return result;
    } catch (FileNotFoundException e) {
        // Should not occur (we test before if file exists)
        // Do not throw, file is not cached
        Ln.w("file " + file.getAbsolutePath() + " does not exists", e);
        return null;
    } catch (Exception e) {
        throw new CacheLoadingException(e);
    }
}
Also used : FileNotFoundException(java.io.FileNotFoundException) FileReader(java.io.FileReader) CacheLoadingException(com.octo.android.robospice.persistence.exception.CacheLoadingException) CacheSavingException(com.octo.android.robospice.persistence.exception.CacheSavingException) CacheCreationException(com.octo.android.robospice.persistence.exception.CacheCreationException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) CacheLoadingException(com.octo.android.robospice.persistence.exception.CacheLoadingException) JsonParser(com.google.api.client.json.JsonParser)

Aggregations

JsonParser (com.google.api.client.json.JsonParser)1 CacheCreationException (com.octo.android.robospice.persistence.exception.CacheCreationException)1 CacheLoadingException (com.octo.android.robospice.persistence.exception.CacheLoadingException)1 CacheSavingException (com.octo.android.robospice.persistence.exception.CacheSavingException)1 FileNotFoundException (java.io.FileNotFoundException)1 FileReader (java.io.FileReader)1 IOException (java.io.IOException)1