Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package de.swm.gwt.client.mobile.keystore.impl;
  
  import  name.pehl.piriti.json.client.JsonReader;
  import  name.pehl.piriti.json.client.JsonWriter;
  
 import java.util.List;


Encapsulates bulk operations storing objects in a HTML5 key value storage.

Author(s):
wiese.daniel
copyright (C) 2012, SWM Services GmbH
 
 public class KeyStoreOperations implements IKeyStoreOperations {
 
 	private final IStorage localStorage;
 	private final JsonReader<KeySetkeyset_reader;
 	private final JsonWriter<KeySetkeyset_writer;


Default constructor.

Parameters:
localStorage the storage instance
keyset_reader the reader for a keyset
keyset_writer the reader for a keylist
 
 	public KeyStoreOperations(IStorage localStorage, JsonReader<KeySetkeyset_reader,
 							  JsonWriter<KeySetkeyset_writer) {
 		this. = localStorage;
 		this. = keyset_reader;
 		this. = keyset_writer;
 
 	}


Reads a list of typed objects for a local storage.

Parameters:
<T> th objects class type
userID the user id (only objects stored for this user id will be retrieved)
useCase the use case id (only objects stored for this use case will be retrieved)
forClass the java type of the object to retrieve
jsonReader the jeson reader for this object class type
Returns:
list of objects or empty list
 
 	public <T> List<T> getDTOList(String userIDString useCaseClass<T> forClass, JsonReader<T> jsonReader) {
 		final String keysetAsJson = 
 				.getItem(new KeySet(forClassuserIDuseCase).createKeyCollectionKey());
 		if (keysetAsJson != null) {
 			final KeySet keySet = .read(keysetAsJson);
 			return getDTOList(keySetjsonReader);
 		} else {
 			return new ArrayList<T>();
 		}
 	}


Reads a list of typed objects for a local storage and deletes all objects after the retireval.

Parameters:
<T> th objects class type
userID the user id (only objects stored for this user id will be retrieved)
useCase the use case id (only objects stored for this use case will be retrieved)
forClass the java type of the object to retrieve
jsonReader the jeson reader for this object class type
Returns:
list of objects or empty list
 
 	public <T> List<T> getDTOListAndDeleteIt(String userIDString useCaseClass<T> forClass, JsonReader<T> jsonReader) {
 		String collectionKey = new KeySet(forClassuserIDuseCase).createKeyCollectionKey();
 		final String keysetAsJson = .getItem(collectionKey);
 		.removeItem(collectionKey);
 		if (keysetAsJson != null) {
 			final KeySet keySet = .read(keysetAsJson);
 			return getDTOListAndDeleteIt(keySetjsonReader);
 		} else {
 			return new ArrayList<T>();
 		}
 	}


Liest eine Liste von Objekten oder DTO's aus dem Local storage.

Parameters:
<T> .
keyCollection .
jsonReader .
Returns:
.
 
 	public <T> List<T> getDTOList(KeyCollection keyCollection, JsonReader<T> jsonReader) {
		final List<T> result = new ArrayList<T>();
		for (String keyToRead : keyCollection.getKeys()) {
			result.add(jsonReader.read(.getItem(keyToRead)));
		}
		return result;
	}


Removes objects implicitly stored inside the key collection from the local storage.

Parameters:
keyCollection incuding the objects to remove
	public void removeDTOList(KeyCollection keyCollection) {
		for (String keyToRemove : keyCollection.getKeys()) {
		}
	}


Liest eine Liste von Objekten oder DTO's aus dem Local storage.

Parameters:
<T> .
keyCollection .
jsonReader .
Returns:
.
	public <T> List<T> getDTOListAndDeleteIt(KeyCollection keyCollection, JsonReader<T> jsonReader) {
		final List<T> result = new ArrayList<T>();
		for (String keyToRead : keyCollection.getKeys()) {
			result.add(jsonReader.read(.getItem(keyToRead)));
		}
		return result;
	}


Aktualisert ein einzelnes DTO im local storage.

Parameters:
<T> .
toUpdate .
keySet .
oid .
jsonWriter .
	public <T> void updateDTO(T toUpdateKeySet keySetString oid, JsonWriter<T> jsonWriter) {
		final String key = keySet.createKey(oid);
		.setItem(keyjsonWriter.toJson(toUpdate));
	}


Loescht ein einzelnes DTO im local storage.

Parameters:
<T> .
oidToDelete .
keySet .
jsonWriter .
	public <T> void deleteDTO(KeySet keySetString oidToDelete, JsonWriter<T> jsonWriter) {
		final String key = keySet.createKeyForRemoval(oidToDelete);
	}


Schreibt eine liste von DTO's in den local storage oder fuehrt ein Update durch falls das objekt bereits vorhanden ist.

Parameters:
<T> .
toUpdate .
keySet .
jsonWriter .
oids die lister der internen id's
	public <T> void updateOrCreateDTOList(List<T> toUpdateKeySet keySet, JsonWriter<T> jsonWriterList<Longoids) {
		int i = 0;
		for (T type : toUpdate) {
			final String key = keySet.createKey(String.valueOf(oids.get(i)));
			.setItem(keyjsonWriter.toJson(type));
			i++;
		}
	}


Laedt einen keyset aus dem Local Storage oder erzeugt einen neuen leeren Keyset.

Parameters:
forClass der typ der zu speichernden Objekte
uuid die uuid
useCase der use case
Returns:
der keyset.
	public KeySet loadKeysetFormStoreOrCreateEmptyOne(Class<?> forClassString uuidString useCase) {
		KeySet emptyKeySet = new KeySet(forClassuuiduseCase);
		String keysetFormStoreAsJsonString = .getItem(emptyKeySet.createKeyCollectionKey());
		if (keysetFormStoreAsJsonString != null) {
			return .read(keysetFormStoreAsJsonString);
		}
		return emptyKeySet;
	}


Schreibt eine liste von beliebigen Objekten in den local storage. Es muss sichegestellt werden, dass eine eventuell vorhandene List geloescht worden ist.

Parameters:
<T> .
toUpdate .
keySet .
jsonWriter .
	public <T> void createList(List<T> toUpdateKeySet keySet, JsonWriter<T> jsonWriter) {
		int id = 0;
		for (T type : toUpdate) {
			id++;
			final String key = keySet.createKey(String.valueOf(id));
			.setItem(keyjsonWriter.toJson(type));
		}
	}
New to GrepCode? Check out our FAQ X