org.vmguys.vmtools.ota
Class OtaUpdate

java.lang.Object
  |
  +--org.vmguys.vmtools.ota.OtaUpdate

public class OtaUpdate
extends java.lang.Object

This class generates and applies OTA update requests. If given two pieces of OTA data, it will generate an update request that will show the differences between the data. If given a piece of OTA data and an update request, it will apply the update and return the modified data.

This class operates on JDOM trees, rather than XML documents. An application using this class should parse the input XML files to create the trees, or use the result tree to generate an XML document.


Field Summary
static java.lang.String generatedVersion
           
protected  boolean replace
          The replace flag indicates the type of difference Element created by generateDiffs.
static java.lang.String schemaLocation
          The default schemaLocation value for OTA_UpdateRQ documents.
static java.lang.String tagname
          The element tag name for an OTA_UpdateRQ document.
static java.lang.String xmlns
          The default namespace for OTA documents.
 
Constructor Summary
OtaUpdate()
          Constructs an object with replace set to false so it will attempt to find the minimal differences between the trees and record them in the update request.
OtaUpdate(boolean replace)
          Constructs an object with replace set to the specified value.
 
Method Summary
 org.jdom.Element applyDiffs(org.jdom.Element original, org.jdom.Element updateRequest)
          Applies the update request to the original tree to recreate the modified tree.
 org.jdom.Element generateDiffs(org.jdom.Element original, org.jdom.Element modified, UniqueId id)
          Returns the differences between the original tree and the modified tree as an OTA update request using the current setting of replace.
 org.jdom.Element generateDiffs(org.jdom.Element original, org.jdom.Element modified, UniqueId id, boolean replace)
          Returns the differences between the original tree and the modified tree as an OTA update request using the specified value of replace.
 boolean getReplace()
          Gets the current value of replace.
 void setProgressReporter(ProgressReporter pr)
          This method sets the progress reporter.
 void setReplace(boolean replace)
          Sets replace to the specified value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

generatedVersion

public static final java.lang.String generatedVersion

tagname

public static final java.lang.String tagname
The element tag name for an OTA_UpdateRQ document.

xmlns

public static final java.lang.String xmlns
The default namespace for OTA documents.

schemaLocation

public static final java.lang.String schemaLocation
The default schemaLocation value for OTA_UpdateRQ documents.

replace

protected boolean replace

The replace flag indicates the type of difference Element created by generateDiffs.

Note: This is declared protected so the junit test programs can access it.

See Also:
generateDiffs(Element, Element, UniqueId), generateDiffs(Element, Element, UniqueId, boolean), getReplace(), setReplace(boolean)
Constructor Detail

OtaUpdate

public OtaUpdate()
Constructs an object with replace set to false so it will attempt to find the minimal differences between the trees and record them in the update request.
See Also:
replace

OtaUpdate

public OtaUpdate(boolean replace)
Constructs an object with replace set to the specified value. If false, it will attempt to find the minimal differences between the trees and record them in the update request. If true, it will generate an update request that simply contains the modified version of the tree and a replace command.
See Also:
replace
Method Detail

setReplace

public void setReplace(boolean replace)
Sets replace to the specified value. If false, it will attempt to find the minimal differences between the trees and record them in the update request. If true, it will generate an update request that simply contains the modified version of the tree and a replace command.
See Also:
replace

getReplace

public boolean getReplace()
Gets the current value of replace.
See Also:
replace

generateDiffs

public org.jdom.Element generateDiffs(org.jdom.Element original,
                                      org.jdom.Element modified,
                                      UniqueId id)
                               throws org.jdom.JDOMException

Returns the differences between the original tree and the modified tree as an OTA update request using the current setting of replace.

The content of the output depends on the setting of the replace field. If true, the update message specifies the replace operation and includes the modified tree as the replacement. If false, the message specifies combinations of insert and delete operations and includes the minimal differences between the original and modified Elements.

In either case, when this update request is applied against the original tree by applyDiffs, the result will be the modified tree.

See Also:
applyDiffs(Element, Element), replace

generateDiffs

public org.jdom.Element generateDiffs(org.jdom.Element original,
                                      org.jdom.Element modified,
                                      UniqueId id,
                                      boolean replace)
                               throws org.jdom.JDOMException
Returns the differences between the original tree and the modified tree as an OTA update request using the specified value of replace.

The content of the output depends on the setting of the replace parameter. If true, the update message specifies the replace operation and includes the modified tree as the replacement. If false, the message specifies combinations of insert and delete operations and includes the minimal differences between the original and modified Elements.

In either case, when this update request is applied against the original tree by applyDiffs, the result will be the modified tree.

The setting of the replace parameter to this method does not change the contents of the replace field in the object.

See Also:
applyDiffs(Element, Element), replace

applyDiffs

public org.jdom.Element applyDiffs(org.jdom.Element original,
                                   org.jdom.Element updateRequest)
                            throws org.jdom.JDOMException
Applies the update request to the original tree to recreate the modified tree. The tree rooted at the original element is cloned, then the updates specified in the update request are applied. The result is returned to the caller.
See Also:
generateDiffs(Element, Element, UniqueId), generateDiffs(Element, Element, UniqueId, boolean)

setProgressReporter

public void setProgressReporter(ProgressReporter pr)
This method sets the progress reporter. When generateUpdate is called, it will call the progress reporter with updates on the percentage of the operation that has been performed. This can be useful during lengthy operations to provide feedback to the user.


Copyright © 2001 VM Systems, Inc. All Rights Reserved.