|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.kuka.roboticsAPI.persistenceModel.XmlApplicationDataSource
public class XmlApplicationDataSource
This data source is able to load frames and tools from a Xml file.
Supported xml file format versions are 2 and 3. This data source reads data of all supported formats and converts it to the newest format.
| Field Summary | |
|---|---|
static int |
CURRENT_DATA_VERSION
This is the current data format version. |
static String |
DEFAULT_DATAFILE_NAME
This is the default config file name. |
static String |
EMPTY_DATAFILE_CONTENT
This is the xml content for an empty data file. |
static String |
ROBOTICS_API_DATA_ELEMENT_NAME
This is the xml root element name of the data file. |
| Constructor Summary | |
|---|---|
XmlApplicationDataSource()
Creates a new instance of XmlApplicationDataSource. |
|
| Method Summary | |
|---|---|
void |
addApplicationDataChangedListener(IApplicationDataChanged listener)
Registers the given listener for application data changes. |
ObjectFrame |
addFrame(ObjectFrame parent)
Creates an adds a new frame to the data source. |
void |
addFrameToTemplate(Object rootTemplate,
FrameTemplate addedTemplate)
Adds a FrameTemplate to the given TemplateElement if possible. |
void |
addFrameToTemplate(Object rootTemplate,
FrameTemplate addedTemplate,
boolean doSave)
Adds a FrameTemplate to the given TemplateElement if possible. |
void |
addObjectTemplate(TemplateElement templateElement)
Adds an object template to the data source. |
void |
addProcessDataListener(IProcessDataListener processDataListener)
Adds a the given process data listener to all existing process data elements. |
void |
addTool(ToolData tool)
Adds the given tool. |
void |
addUserData(UserData userData)
Adds the given user data. |
FrameTemplate |
applyFrameTemplateMeasurement(FrameTemplate frameTemplate,
Transformation newTransformation,
MeasurementType measurementType,
MeasurementMethod measurementMethod,
Double calculationError,
boolean doSave)
|
void |
changeFrameTransformation(ObjectFrame frameToChange,
ITransformation newTransformation)
Changes the frame that belongs to the data source. |
void |
close()
Closes the data source. |
protected void |
closeInternal()
Closes the data source. |
protected void |
dispose()
Dispose method closes file. |
void |
fileStateChanged(FileWatchState state)
Called when a file changed. |
void |
forceLoadFile()
Forces the Filewatcher to command a reload of the file. |
RoboticsAPIContext |
getContext()
Gets the context for this data source. |
URL |
getDataFile()
Gets the url of the data file used by this data source. |
String |
getErrorMessage()
|
Map<String,Object> |
getFrameParameters(String name)
Gets the writable map with the parameters of the frame with the specified name. |
String |
getName()
Gets the name of this data source. |
Collection<ToolTemplate> |
getToolTemplates()
Gets all the tool templates of the data source. |
boolean |
hasError()
Returns true if there was an exception during load. |
boolean |
isOpen()
Indicates if this data source is opened. |
boolean |
isReadOnly()
Indicates if this data source is read only. |
Collection<? extends ObjectFrame> |
loadAllFrames()
Gets all frames known to the data source. |
Collection<IProcessData> |
loadAllProcessData()
Gets all process data elements known to the data source., The process data will not be in any specific order. |
Collection<? extends TemplateElement> |
loadAllTemplates()
Gets all templates known to the data source. |
Collection<ToolData> |
loadAllToolDatas()
Gets all tool data known to the data source. |
Collection<UserData> |
loadAllUserData()
Gets all user data keys known to the data source. |
ObjectFrame |
loadFrame(String path)
Loads a frame with the specified path. |
ObjectFrame |
loadFrameById(String id)
Loads a frame with the specified unique id. |
IProcessData |
loadProcessData(String key)
Loads a process data object with the specified identifier. |
TemplateElement |
loadTemplate(String name)
Loads a template with the specified name. |
ToolData |
loadToolData(String name)
Loads tool data with the specified name. |
UserData |
loadUserData(String name)
Gets the user data stored under the given name. |
static int |
loadVersion(Document doc)
Reads the value of the version attribute from the given document. |
void |
moveFrame(AbstractFrame frameToMove,
ObjectFrame newParent)
Moves the given frame to the given new parent. |
void |
moveFrameToElement(Object source,
Object target,
FrameTemplate frameToMove)
Move the given frame element from source to target elements. |
void |
moveFrameToElement(Object source,
Object target,
FrameTemplate frameToMove,
boolean doSave)
Move the given frame element from source to target elements. |
void |
open()
Opens the data source. |
void |
open(String dataFileName)
Opens the data source with the specified data file. |
protected void |
openInternal()
Opens the data source. |
void |
persistExternalDataChanges()
Allows proper persistence handling of data changes that have been done by other classes. |
void |
removeApplicationDataChangedListener(IApplicationDataChanged listener)
Unregisters the given listener for application data changes. |
void |
removeFrame(ObjectFrame frame)
Removes the given frame. |
void |
removeFrameFromTemplate(Object rootTemplate,
FrameTemplate removedTemplate)
Removes a FrameTemplate from the given FrameTemplate if possible. |
void |
removeFrameFromTemplate(Object rootTemplate,
FrameTemplate removedTemplate,
boolean doSave)
Removes a FrameTemplate from the given FrameTemplate if possible. |
void |
removeObjectTemplate(TemplateElement templateElement)
Removes an object template from the data source. |
void |
removeTool(ToolData tool)
Removes the given tool. |
void |
removeUserData(UserData userData)
Removes the user data which belongs to the given key. |
void |
renameFrame(AbstractFrame frameToChange,
String newName)
Changes the name of the given frame to newName. |
protected FrameTemplate |
renameFrameTemplate(FrameTemplate frameElement,
String name)
Changes the name of a frame element. |
protected TemplateElement |
renameObjectTemplate(TemplateElement templateElement,
String name)
Changes the name of a template element. |
void |
renameTool(ToolData tool,
String newName)
Renames the given tool. |
void |
renameUserData(UserData userData,
String newName)
Renames the given user data. |
void |
save()
Please use RoboticsAPIApplication.getApplicationData().save() method in your Application to save the
data file. |
void |
saveFile()
Saves the current content to the data file. |
void |
saveFile(boolean silent)
Saves the current content to the data file. |
void |
setContext(RoboticsAPIContext context)
Sets the context for this data source. |
void |
setFileWatcherExecutor(ScheduledExecutorService executor)
Sets a scheduled executor to be used by the file watcher of this data source. |
void |
setParameters(com.kuka.common.ParameterSet attributes)
Initializes the data source with a set of parameters. |
String |
toString()
|
ObjectFrame |
tryLoadFrame(String path)
Loads a frame with the specified path. |
IProcessData |
tryLoadProcessData(String key)
Loads a process data object with the specified identifier. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final String ROBOTICS_API_DATA_ELEMENT_NAME
public static final int CURRENT_DATA_VERSION
public static final String DEFAULT_DATAFILE_NAME
public static final String EMPTY_DATAFILE_CONTENT
| Constructor Detail |
|---|
public XmlApplicationDataSource()
| Method Detail |
|---|
public static int loadVersion(Document doc)
doc - The document where to get the version from.
public void open()
Usually should be uses to connect to the real data source (database, file etc.)
open in interface IDataSourceprotected void openInternal()
Usually should be uses to connect to the real data source (database, file etc.)
public void open(String dataFileName)
If data source is already open it is closed first. This method is the only possibility to set a data file programatically. The data source should be in closed state to do it. To change the data file please close the data source first and then call this method.
dataFileName - name of the data file. This should either a file name resolvable through the context in which data
source is created (see setContext(), or a correct url string representation.public void close()
Closes the connection to the real data source.
close in interface IDataSourceprotected void closeInternal()
Closes the connection to the real data source.
public String getName()
getName in interface IDataSourcepublic boolean isOpen()
isOpen in interface IDataSourcepublic boolean isReadOnly()
isReadOnly in interface IDataSourcepublic Collection<? extends ObjectFrame> loadAllFrames()
The frames will not be in any specific order.
loadAllFrames in interface IApplicationDataSourcepublic ObjectFrame loadFrame(String path)
The object should always be the same unless the data source get's closed and re-opened.
loadFrame in interface IApplicationDataSourcepath - the path to the frame.
public ObjectFrame tryLoadFrame(String path)
The object should always be the same unless the data source get's closed and re-opened.
tryLoadFrame in interface IApplicationDataSourcepath - The path to the frame.
null if the frame was not found.public ObjectFrame loadFrameById(String id)
The object should always be the same unless the data source get's closed and re-opened.
loadFrameById in interface IApplicationDataSourceid - the unique id to the frame.
null if a frame with this id is unknownprotected void dispose()
public Collection<? extends TemplateElement> loadAllTemplates()
The templates will not be in any specific order.
loadAllTemplates in interface IApplicationDataSourcepublic Collection<IProcessData> loadAllProcessData()
The process data will not be in any specific order.
loadAllProcessData in interface IApplicationDataSourcepublic Collection<ToolTemplate> getToolTemplates()
getToolTemplates in interface IApplicationDataSourcepublic TemplateElement loadTemplate(String name)
The object should always be the same unless the data source get's closed and re-opened.
loadTemplate in interface IApplicationDataSourcename - The name of the template.
public Collection<ToolData> loadAllToolDatas()
The tool data will not be in any specific order.
loadAllToolDatas in interface IApplicationDataSourcepublic ToolData loadToolData(String name)
The object should always be the same unless the data source get's closed and re-opened.
loadToolData in interface IApplicationDataSourcename - The name of the tool data.
public Collection<UserData> loadAllUserData()
The user data will not be in any specific order.
loadAllUserData in interface IApplicationDataSourceIApplicationDataSource.loadUserData(String)public UserData loadUserData(String name)
loadUserData in interface IApplicationDataSourcename - The name of the user data.
public void setParameters(com.kuka.common.ParameterSet attributes)
setParameters in interface IDataSourceattributes - The parameters of the data source.public URL getDataFile()
public void fileStateChanged(FileWatchState state)
fileStateChanged in interface IFileStateListenerstate - The state of the file.public void setContext(RoboticsAPIContext context)
setContext in interface IDataSourcecontext - The context for this data source.public RoboticsAPIContext getContext()
getContext in interface IDataSource
public void renameFrame(AbstractFrame frameToChange,
String newName)
frameToChange - The frame which should be renamed.newName - The new name of the given frame.
public void moveFrame(AbstractFrame frameToMove,
ObjectFrame newParent)
frameToMove - The frame which should be moved to another parent. Could not be null.newParent - The new parent where the given frame should be moved.Could not be null.
IllegalArgumentException - if frameToMove is null, or newParent is null, or frameToMove == newParent, or parent of the
frameToMove is null, or frameToMove does not belong to the data source.public ObjectFrame addFrame(ObjectFrame parent)
addFrame in interface IApplicationDataSourceparent - The parent where the given frame should be added.
public void changeFrameTransformation(ObjectFrame frameToChange,
ITransformation newTransformation)
frameToChange - frame to change.newTransformation - new transformation to the parent.public void removeFrame(ObjectFrame frame)
frame - The frame which should be removed.
public void renameTool(ToolData tool,
String newName)
tool - The tool which should be renamed.newName - The new name of the tool.public void addTool(ToolData tool)
tool - The tool which should be added.public void removeTool(ToolData tool)
tool - The tool which should be removed.
public void renameUserData(UserData userData,
String newName)
userData - The user data which should be renamed.newName - The new name of the user data.public void addUserData(UserData userData)
userData - The user data which should be added.public void removeUserData(UserData userData)
userData - The user data which should be removed.public void save()
RoboticsAPIApplication.getApplicationData().save() method in your Application to save the
data file.
save in interface ISaveableApplicationDataSourceIApplicationData.save()public void saveFile()
public void saveFile(boolean silent)
silent - If silent is true, no application data changed event will be fired.public Map<String,Object> getFrameParameters(String name)
name - name of the frame for which the parameters are requested.
public boolean hasError()
hasError in interface ISaveableApplicationDataSourcepublic String getErrorMessage()
getErrorMessage in interface ISaveableApplicationDataSourcepublic String toString()
toString in class Objectpublic final void addApplicationDataChangedListener(IApplicationDataChanged listener)
addApplicationDataChangedListener in interface IApplicationDataSourcelistener - The listener which should be called after application data has
changed.public final void removeApplicationDataChangedListener(IApplicationDataChanged listener)
removeApplicationDataChangedListener in interface IApplicationDataSourcelistener - The registered listener which should be unregistered.
public void forceLoadFile()
throws InterruptedException
InterruptedException - is thrown if the loading could not be executed successfulpublic void persistExternalDataChanges()
public void addObjectTemplate(TemplateElement templateElement)
addObjectTemplate in interface ISaveableApplicationDataSourcetemplateElement - the template to be added
public void removeObjectTemplate(TemplateElement templateElement)
throws SAXException
templateElement - the template to be removed
SAXException - an exception in case of an validation error
protected TemplateElement renameObjectTemplate(TemplateElement templateElement,
String name)
templateElement - the template element to be changedname - the new name
protected FrameTemplate renameFrameTemplate(FrameTemplate frameElement,
String name)
frameElement - the template element to be changedname - the new name
public void addFrameToTemplate(Object rootTemplate,
FrameTemplate addedTemplate)
rootTemplate - The TemplateElement where the new FrameTemplate should be addedaddedTemplate - The FrameTemplate to be added
public void addFrameToTemplate(Object rootTemplate,
FrameTemplate addedTemplate,
boolean doSave)
rootTemplate - The TemplateElement where the new FrameTemplate should be addedaddedTemplate - The FrameTemplate to be addeddoSave - if true the data will be saved in the data source
public void removeFrameFromTemplate(Object rootTemplate,
FrameTemplate removedTemplate)
rootTemplate - The parent of the FrameTemplate that should be removedremovedTemplate - The FrameTemplate that should be removed
public void removeFrameFromTemplate(Object rootTemplate,
FrameTemplate removedTemplate,
boolean doSave)
rootTemplate - The parent of the FrameTemplate that should be removedremovedTemplate - The FrameTemplate that should be removeddoSave - if true the data will be saved in the data source
public FrameTemplate applyFrameTemplateMeasurement(FrameTemplate frameTemplate,
Transformation newTransformation,
MeasurementType measurementType,
MeasurementMethod measurementMethod,
Double calculationError,
boolean doSave)
public void moveFrameToElement(Object source,
Object target,
FrameTemplate frameToMove)
source - may be TemplateElement or FrameElementtarget - may be TemplateElement or FrameElementframeToMove - the frame to move
public void moveFrameToElement(Object source,
Object target,
FrameTemplate frameToMove,
boolean doSave)
source - may be TemplateElement or FrameElementtarget - may be TemplateElement or FrameElementframeToMove - the frame to movedoSave - true if movement should automatically be saved in data sourcepublic IProcessData loadProcessData(String key)
loadProcessData in interface IApplicationDataSourcekey - the identifier of the process data object.
public IProcessData tryLoadProcessData(String key)
tryLoadProcessData in interface IApplicationDataSourcekey - the identifier of the process data object.
null if the
process data object was not found.public void addProcessDataListener(IProcessDataListener processDataListener)
processDataListener - the listener to add to all existing process data elementspublic void setFileWatcherExecutor(ScheduledExecutorService executor)
This allows sharing one executor with several data sources aka file watchers.
executor - the scheduled executor
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||