org.universAAL.ontology.reasoner.util
Class ElementModel<P extends Resource>

Package class diagram package ElementModel
java.lang.Object
  extended by org.universAAL.ontology.reasoner.util.ElementModel<P>
Type Parameters:
P - Class the be managed. Need to be a sibling of Persistent
Direct Known Subclasses:
RuleModel

public class ElementModel<P extends Resource>
extends Object

It is a pattern for the Reasoner that its elements need to be saved/loaded and added/removed/returned. To encapsulate the redundant parts this class provides the basic methods to hold object of type P during runtime and save/load them from the file-system using the capabilities of the middlewares serializer.

Author:
amarinc

Constructor Summary
ElementModel(Class<P> elementClass, MessageContentSerializer serializer, String rootPath)
          Creates a new model to manage objects of type P
 
Method Summary
 P add(P element)
           
 P getElement(P compareElement)
           
 P getElement(String uri)
           
 ArrayList<P> getElements()
           
 int getPersistentElementIndex(P element)
           
 P load(File file)
           
 void loadElements()
           
 boolean remove(P dElement)
           
 boolean save(P element)
           
 boolean saveElements()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ElementModel

public ElementModel(Class<P> elementClass,
                    MessageContentSerializer serializer,
                    String rootPath)
Creates a new model to manage objects of type P

Parameters:
elementClass - Class object of type P
serializer - serializer to be used for the classes of type P
rootPath - Absolute path to the root of the bundle-config-home (without ending "/")
Method Detail

saveElements

public boolean saveElements()

save

public boolean save(P element)

getPersistentElementIndex

public int getPersistentElementIndex(P element)

loadElements

public void loadElements()

load

public P load(File file)

add

public P add(P element)

remove

public boolean remove(P dElement)

getElement

public P getElement(String uri)

getElement

public P getElement(P compareElement)

getElements

public ArrayList<P> getElements()


Copyright © 2014 universAAL Consortium. All Rights Reserved.