insensa.optionfilechanger
Class CCopy

java.lang.Object
  extended by insensa.optionfilechanger.AbstractOptionFileChanger
      extended by insensa.optionfilechanger.CCopy
All Implemented Interfaces:
OptionFileChanger, java.lang.Runnable

public class CCopy
extends AbstractOptionFileChanger


Field Summary
private  java.lang.String description
           
private  boolean overwrite
           
 
Fields inherited from class insensa.optionfilechanger.AbstractOptionFileChanger
errorMessage, id, oldFileName, oldFilePath, oldRasterFile, processStatus, used, workerStatus, XML_ATTR_ID, XML_ATTR_OLD_NAME, XML_ATTR_OLD_PATH, XML_ATTR_USED, XML_ELEMENT_SOURCEFILE
 
Constructor Summary
CCopy()
           
 
Method Summary
 boolean checkApproval(CRasterFileInformation rasterFile)
          Here you can check if it is correct to add this OptionFileChanger to this rasterFile.
 org.jdom.Element getOptionElement()
          Creates a new Element object that contains all Information that should be saved in a configuration file.
 java.lang.String getOptionName()
          Returns the name of the OptionFileChanger.
 int getUsableCount()
           
 void setOptionAttributes(org.jdom.Element eOption)
          Sets all attributes that are saved in the configuration file.
 java.lang.String toString()
           
 void write()
          This method will be executed from the ThreadPool
There are several steps that must be followed:
Get actual file
.
 
Methods inherited from class insensa.optionfilechanger.AbstractOptionFileChanger
getActualFile, getData, getErrorMessage, getId, getInfoDependencies, getOldFileRelativeFilePath, getTemporaryFileName, isPublic, isUsed, run, saveRasterFile, setId, setOldRasterFile, setWorkerStatus, solveDependencies
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

description

private java.lang.String description

overwrite

private boolean overwrite
Constructor Detail

CCopy

public CCopy()
Method Detail

checkApproval

public boolean checkApproval(CRasterFileInformation rasterFile)
Description copied from interface: OptionFileChanger
Here you can check if it is correct to add this OptionFileChanger to this rasterFile.

Specified by:
checkApproval in interface OptionFileChanger
Overrides:
checkApproval in class AbstractOptionFileChanger
Returns:
See Also:
AbstractOptionFileChanger.checkApproval(insensa.CRasterFileInformation)

getOptionElement

public org.jdom.Element getOptionElement()
Description copied from interface: OptionFileChanger
Creates a new Element object that contains all Information that should be saved in a configuration file.

The configuration file is a xml file that will be saved in the "infos" directory. jdom is used to generate the file. An Element will be represented as a XML Tag in the created file

First you have to create a new Element with the name of the optionFileChanger.
This name must be the same name as you defined in the extensions.xml file
If you inherited and defined the method getOptionName correctly, you can use this function to get the name.

Example:
 Element optionElement = new Element(this.getOptionName());
 
There are TWO attributes which should ALWAYS be saved, the status of the execution (Therefore the same boolean expression that should be used in the method isUsed) and the id of the current optionFileChanger.
Both variables (used and id) are defined in

Specified by:
getOptionElement in interface OptionFileChanger
Overrides:
getOptionElement in class AbstractOptionFileChanger
Returns:
Element with all contents that should be saved in the Configuration File AbstractOptionFileChanger.
The Integer variable id is used internally and just have to be saved and reloaded by the plugin.

Example: Assuming that used is the boolean expression
 optionElement.setAttribute("used",Boolean.toString(used));
 
Besides the used state, you can save what ever you want and it is possible to use the complex methods that jdom gives you. For example: creating subElements (child XML tags)

Note: It is strongly recommended that you define a final variable for every key you need.
The keys used here are also required in the method insensa.optionfilechanger.OptionFileChanger.setInfos and it can be fatal to use wrong keys
 private final string XML_ATTR_USED = "used";
 
See Also:
OptionFileChanger.getOptionElement()

getOptionName

public java.lang.String getOptionName()
Description copied from interface: OptionFileChanger
Returns the name of the OptionFileChanger.

This MUST be the same name as defined in the extensions.xml or in EOption

Returns:
the name of the OptionFileChanger
See Also:
OptionFileChanger.getOptionName()

getUsableCount

public int getUsableCount()
Returns:
maximum number of unused objects that can be appended to a file
See Also:
OptionFileChanger.getUsableCount()

setOptionAttributes

public void setOptionAttributes(org.jdom.Element eOption)
                         throws java.io.IOException
Description copied from interface: OptionFileChanger
Sets all attributes that are saved in the configuration file.

This method is the counterpart of getOptionElement.

Specified by:
setOptionAttributes in interface OptionFileChanger
Overrides:
setOptionAttributes in class AbstractOptionFileChanger
Parameters:
eOption - the jdom.Element which holds the attributes
Throws:
java.io.IOException - eOption holds all information that was saved.
The information that should ALWAYS stored in the configuration is the status of the execution and the id of the optionFileChanger
Example:
 
 Attribute attrUsed = element.getAttribute(XML_ATTR_USED);
 Attribute attrID = element.getAttribute(XML_ATTR_ID);
 if(attrUsed==null || attrID==null)
 throw new IOException("one ore more necessary attributes cannot be found");
 try
 {
 used=attrUsed.getBooleanValue();
 id=attrID.getIntegerValue();
 }catch (DataConversionException e)
 {
 throw new IOException(e);
 }
 
 
See Also:
OptionFileChanger.setOptionAttributes(org.jdom.Element)

toString

public java.lang.String toString()
Overrides:
toString in class AbstractOptionFileChanger
See Also:
AbstractOptionFileChanger.toString()

write

public void write()
           throws java.io.IOException,
                  org.jdom.JDOMException,
                  CRasterFileException
Description copied from interface: OptionFileChanger
This method will be executed from the ThreadPool
There are several steps that must be followed:
  1. Get actual file
    .

    Throws:
    java.io.IOException
    org.jdom.JDOMException
    CRasterFileException