gate.util.ant.packager
Class GappModel

java.lang.Object
  extended by gate.util.ant.packager.GappModel

public class GappModel
extends Object


Constructor Summary
GappModel(URL gappFileURL)
           
GappModel(URL gappFileURL, URL gateHomeURL)
          Create a GappModel for a GAPP file.
 
Method Summary
 void finish()
          Finish up processing of the gapp file ready for writing.
 org.jdom.Document getGappDocument()
          Get the JDOM Document representing this GAPP file.
 URL getGappFileURL()
          Get the URL at which the GAPP file resides.
 Set<URL> getPluginURLs()
          Get the plugin URLs that are referenced by relative paths in this GAPP file.
 Set<URL> getResourceURLs()
          Get the resource URLs that are referenced by relative paths in this GAPP file.
 void setGappFileURL(URL gappFileURL)
          Set the URL at which the GAPP file resides.
 void updatePathForURL(URL originalURL, URL newURL, boolean makeRelative)
          Update the modelled content of the GAPP file to replace any relative paths referring to originalURL with those pointing to newURL.
 void write()
          Write out the (possibly modified) GAPP file to its new location.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GappModel

public GappModel(URL gappFileURL)
See Also:
GappModel(URL,URL)

GappModel

public GappModel(URL gappFileURL,
                 URL gateHomeURL)
Create a GappModel for a GAPP file.

Parameters:
gappFileURL - the URL of the GAPP file to model.
gateHomeURL - the URL against which $gatehome$ relative paths should be resolved. This may be null if you are sure that the GAPP you are packaging does not contain any $gatehome$ paths. If no gateHomeURL is provided but the application does contain a $gatehome$ path, a GateRuntimeException will be thrown.
Method Detail

getGappFileURL

public URL getGappFileURL()
Get the URL at which the GAPP file resides.

Returns:
the gappFileURL

setGappFileURL

public void setGappFileURL(URL gappFileURL)
Set the URL at which the GAPP file resides. When this GappModel is constructed this will be the URL from which the file is loaded, but this should be changed if you wish to write the updated GAPP to another location.

Parameters:
gappFileURL - the gappFileURL to set

getGappDocument

public org.jdom.Document getGappDocument()
Get the JDOM Document representing this GAPP file.

Returns:
the document

getPluginURLs

public Set<URL> getPluginURLs()
Get the plugin URLs that are referenced by relative paths in this GAPP file.

Returns:
the set of URLs.

getResourceURLs

public Set<URL> getResourceURLs()
Get the resource URLs that are referenced by relative paths in this GAPP file.

Returns:
the set of URLs.

updatePathForURL

public void updatePathForURL(URL originalURL,
                             URL newURL,
                             boolean makeRelative)
Update the modelled content of the GAPP file to replace any relative paths referring to originalURL with those pointing to newURL. If makeRelative is true, the new path will be relativized against the current gappFileURL, so you should call setGappFileURL(java.net.URL) with the URL at which the file will ultimately be saved before calling this method. If makeRelative is false the new URL will be used directly as an absolute URL (so to replace a relative path with the absolute URL to the same file you can call updatePathForURL(u, u, false)).

Parameters:
originalURL - The original URL whose references are to be replaced.
newURL - the replacement URL.
makeRelative - should we relativize the newURL before use?

finish

public void finish()
Finish up processing of the gapp file ready for writing.


write

public void write()
           throws IOException
Write out the (possibly modified) GAPP file to its new location.

Throws:
IOException - if an I/O error occurs.