Ignore:
Timestamp:
2003-12-02T17:15:47+13:00 (20 years ago)
Author:
jmt12
Message:

Moved the special folder 'shortcuts' from collection based to shared for the installation of gli. This caused some added fun when it turned out one of the workspace tree refreshes was blocking the AWTEvent thread, despite me putting tests in place to stop that from happening. It had never reared its ugly head before, as there were never any shortcut collections being mapped when a collection had been closed, or when GLI was exiting before.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/collection/Collection.java

    r6051 r6086  
    6262 */
    6363public class Collection {
    64     /** A reference to the BuildOptions. */
    65     public BuildOptions build_options;
    66     /** A reference to the Collection Design Manager. */
    67     public CollectionDesignManager cdm;
    68     /** A reference to the Greenstone Directory Metadata Manager. */
    69     public GDMManager gdm;
    70     /** A reference to the Metadata Set Manager. */
    71     public MetadataSetManager msm;
    72     /** <i>true</i> if the currently loaded collection has been saved since the last significant change, <i>false</i> otherwise. */
    73     private boolean saved = false;
    74     /** The document around which this collection class is based. */
    75     private Document document;
    76     /** The file the collection is in (the file may not actually exist, such in the case of a legacy collection)! */
    77     private File file;
    78    /** The name of the argument element. */
    79    static final private String ARGUMENT = "Argument";
    80    static final private String BASE_COLLECTION = "base_collection";
    81     /** The name of the build element. */
    82     static final private String BUILD = "Build";
    83     /** The name of the build config element. */
    84     static final private String BUILD_CONFIG = "BuildConfig";
    85     /** The name of the collection xml template. */
    86     static final private String COLLECTION_XML_TEMPLATE = "xml/template.col";
    87     /** The name of the directory mappings element. */
    88     static final private String DIRECTORY_MAPPINGS = "DirectoryMappings";
    89     /** The name of the file attribute. */
    90     static final private String FILE = "file";
    91     /** The name of the import element. */
    92     static final private String IMPORT = "Import";
    93     /** The name of the imported attribute. */
    94     static final private String IMPORTED = "imported";
    95     /** The name of the mapping element. */
    96     static final private String MAPPING = "Mapping";
    97     /** The name of the name attribute. */
    98     static final private String NAME = "name";
    99     /** The name of the true value. */
    100     static final private String TRUE = "true";
    101     /** Constructor. */
    102     public Collection(File collection_xml) {
    103         this.file = collection_xml;
    104         // Try to load this collections details.
    105         document = Utility.parse(collection_xml, false);
    106         // If that fails load the default settings for a collection.
    107         if(document == null) {
    108             document = Utility.parse(COLLECTION_XML_TEMPLATE, true);
    109         }
    110         // Point the Configuration class at our gatherer config arguments.
    111         Gatherer.config.setCollectionConfiguration(document);
    112         // Finally create all of the child managers that are directly dependant on a collection
    113         build_options = new BuildOptions(getBuildValues(), getImportValues());
    114     }
    115 
    116     /** Add a special directory mapping. */
    117     public boolean addDirectoryMapping(String name, File file) {
    118     boolean result = false;
    119     try {
    120         Element document_element = document.getDocumentElement();
    121         Element directory_mappings_element = (Element) MSMUtils.getNodeFromNamed(document_element, DIRECTORY_MAPPINGS);
    122                 // Ensure the name isn't already in use.
    123         boolean found = false;
    124         NodeList mappings = directory_mappings_element.getElementsByTagName(MAPPING);
    125         for(int i = 0; !found && i < mappings.getLength(); i++) {
    126         Element mapping_element = (Element) mappings.item(i);
    127         if(mapping_element.getAttribute(NAME).equalsIgnoreCase(name)) {
    128             found = true;
    129         }
    130         mapping_element = null;
    131         }
    132         // Otherwise add the mapping.
    133         if(!found) {
    134         Element mapping_element = document.createElement(MAPPING);
    135         mapping_element.setAttribute(NAME, name);
    136         mapping_element.setAttribute(FILE, file.toString());
    137         directory_mappings_element.appendChild(mapping_element);
    138         result = true;
    139         mapping_element = null;
    140         }
    141         mappings = null;
    142         directory_mappings_element = null;
    143         document_element = null;
    144         saved = false;
    145     }
    146     catch (Exception error) {
    147         Gatherer.printStackTrace(error);
    148     }
    149     return result;
    150     }
    151 
    152     /** Destructor.
    153      * @see org.greenstone.gatherer.collection.CollectionModel */
    154     public void destroy() {
     64    /** A reference to the BuildOptions. */
     65    public BuildOptions build_options;
     66    /** A reference to the Collection Design Manager. */
     67    public CollectionDesignManager cdm;
     68    /** A reference to the Greenstone Directory Metadata Manager. */
     69    public GDMManager gdm;
     70    /** A reference to the Metadata Set Manager. */
     71    public MetadataSetManager msm;
     72    /** <i>true</i> if the currently loaded collection has been saved since the last significant change, <i>false</i> otherwise. */
     73    private boolean saved = false;
     74    /** The document around which this collection class is based. */
     75    private Document document;
     76    /** The file the collection is in (the file may not actually exist, such in the case of a legacy collection)! */
     77    private File file;
     78    /** The name of the argument element. */
     79    static final private String ARGUMENT = "Argument";
     80    static final private String BASE_COLLECTION = "base_collection";
     81    /** The name of the build element. */
     82    static final private String BUILD = "Build";
     83    /** The name of the build config element. */
     84    static final private String BUILD_CONFIG = "BuildConfig";
     85    /** The name of the collection xml template. */
     86    static final private String COLLECTION_XML_TEMPLATE = "xml/template.col";
     87    /** The name of the import element. */
     88    static final private String IMPORT = "Import";
     89    /** The name of the imported attribute. */
     90    static final private String IMPORTED = "imported";
     91
     92    /** Constructor. */
     93    public Collection(File collection_xml) {
     94    this.file = collection_xml;
     95    // Try to load this collections details.
     96    document = Utility.parse(collection_xml, false);
     97    // If that fails load the default settings for a collection.
     98    if(document == null) {
     99        document = Utility.parse(COLLECTION_XML_TEMPLATE, true);
     100    }
     101    // Point the Configuration class at our gatherer config arguments.
     102    Gatherer.config.setCollectionConfiguration(document);
     103    // Finally create all of the child managers that are directly dependant on a collection
     104    build_options = new BuildOptions(getBuildValues(), getImportValues());
     105    }
     106   
     107    /** Destructor.
     108     * @see org.greenstone.gatherer.collection.CollectionModel */
     109    public void destroy() {
    155110    cdm.destroy();
    156111    gdm.destroy();
     
    161116    gdm = null;
    162117    msm = null;
    163     }
    164 
    165    /** Determine the path to the base collection.
    166     * @return the path as a String
    167     */
    168    public String getBaseCollection() {
    169       return getString(BASE_COLLECTION);
    170    }
    171 
    172     /** Determine the number of documents and folders in this collection. */
    173     public int getCount() {
     118    }
     119   
     120    /** Determine the path to the base collection.
     121     * @return the path as a String
     122     */
     123    public String getBaseCollection() {
     124    return getString(BASE_COLLECTION);
     125    }
     126   
     127    /** Determine the number of documents and folders in this collection. */
     128    public int getCount() {
    174129    return getCount((TreeNode)Gatherer.c_man.getRecordSet().getRoot(), true, true);
    175     }
    176 
    177     /** Calculates the number of documents in this collection. */
    178     public int getDocumentCount() {
     130    }
     131   
     132    /** Calculates the number of documents in this collection. */
     133    public int getDocumentCount() {
    179134    return getCount((TreeNode)Gatherer.c_man.getRecordSet().getRoot(), false, true);
    180     }
    181 
    182     /** Retrieve the description of this collection.
    183      * @return a String
    184      */
    185     public String getDescription() {
    186         if(cdm == null) {
    187             return StaticStrings.EMPTY_STR;
    188         }
    189         CollectionMeta collection_extra_collectionmeta = cdm.collectionmeta_manager.getMetadatum(StaticStrings.COLLECTIONMETADATA_COLLECTIONEXTRA_STR);
    190         return collection_extra_collectionmeta.getValue(CollectionMeta.TEXT);
    191     }
    192 
    193     /** Retrieve the special directory mappings associated with this collection.
    194      * @return A <strong>HashMap</strong> containing mappings from names to directories.
    195      */
    196     public HashMap getDirectoryMappings() {
    197         HashMap special_directories = new HashMap();
    198         try {
    199             Element document_element = document.getDocumentElement();
    200             Element directory_mappings_element = (Element) MSMUtils.getNodeFromNamed(document_element, DIRECTORY_MAPPINGS);
    201             // Ensure the name isn't already in use.
    202             boolean found = false;
    203             NodeList mappings = directory_mappings_element.getElementsByTagName(MAPPING);
    204             for(int i = 0; !found && i < mappings.getLength(); i++) {
    205                 Element mapping_element = (Element) mappings.item(i);
    206                 String name = mapping_element.getAttribute(NAME);
    207                 File file = new File(mapping_element.getAttribute(FILE));
    208                 special_directories.put(name, file);
    209                 file = null;
    210                 name = null;
    211                 mapping_element = null;
    212             }
    213             mappings = null;
    214             directory_mappings_element = null;
    215             document_element = null;
    216         }
    217         catch(Exception error) {
    218             Gatherer.printStackTrace(error);
    219         }
    220         return special_directories;
    221     }
    222     /** Retrieve the authors email for this collection.
    223      * @return The email as a <strong>String</strong>.
    224      */
    225     public String getEmail() {
    226         if(cdm == null) {
    227             return StaticStrings.EMPTY_STR;
    228         }
    229         CollectionMeta creator_collectionmeta = new CollectionMeta(CollectionDesignManager.collect_config.getCreator());
    230         return creator_collectionmeta.getValue(CollectionMeta.TEXT);
    231     }
    232 
    233     /** Retrieve the short name for this collection.
    234      * @return The name as a <strong>String</strong>.
    235      */
    236     public String getName() {
    237         return file.getParentFile().getName();
    238     }
    239 
    240     /** Determine if this collection has been saved since the last major change.
    241      * @return <i>true</i> if it has been saved recently, <i>false</i> otherwise.
    242      */
    243     public boolean getSaved() {
    244         return saved;
    245     }
    246 
    247     /** Retrieve the title of this collection.
    248      * @return The title as a <strong>String</strong>.
    249      */
    250     public String getTitle() {
    251         if(cdm == null) {
    252             return StaticStrings.EMPTY_STR;
    253         }
    254         CollectionMeta collection_name_collectionmeta = cdm.collectionmeta_manager.getMetadatum(StaticStrings.COLLECTIONMETADATA_COLLECTIONNAME_STR);
    255         return collection_name_collectionmeta.getValue(CollectionMeta.TEXT);
    256     }
    257     /** Remove a previously defined special directory mapping.
    258      * @param name The name of the mapping to remove as a <strong>String</strong>.
    259      * @return The <strong>File</strong> of the mapping removed.
    260      */
    261     public File removeDirectoryMapping(String name) {
    262         File file = null;
    263         try {
    264             Element document_element = document.getDocumentElement();
    265             Element directory_mappings_element = (Element) MSMUtils.getNodeFromNamed(document_element, DIRECTORY_MAPPINGS);
    266             // Ensure the name isn't already in use.
    267             boolean found = false;
    268             NodeList mappings = directory_mappings_element.getElementsByTagName(MAPPING);
    269             for(int i = 0; !found && i < mappings.getLength(); i++) {
    270                 Element mapping_element = (Element) mappings.item(i);
    271                 if(mapping_element.getAttribute(NAME).equalsIgnoreCase(name)) {
    272                     file = new File(MSMUtils.getValue(mapping_element));
    273                     directory_mappings_element.removeChild(mapping_element);
    274                     found = true;
    275                 }
    276                 mapping_element = null;
    277             }
    278             mappings = null;
    279             directory_mappings_element = null;
    280             document_element = null;
    281             saved = false;
    282         }
    283         catch(Exception error) {
    284             Gatherer.printStackTrace(error);
    285         }
    286         return file;
    287     }
    288     /** Save this xml document to the given file. */
    289     public void save() {
     135    }
     136   
     137    /** Retrieve the description of this collection.
     138     * @return a String
     139     */
     140    public String getDescription() {
     141    if(cdm == null) {
     142        return StaticStrings.EMPTY_STR;
     143    }
     144    CollectionMeta collection_extra_collectionmeta = cdm.collectionmeta_manager.getMetadatum(StaticStrings.COLLECTIONMETADATA_COLLECTIONEXTRA_STR);
     145    return collection_extra_collectionmeta.getValue(CollectionMeta.TEXT);
     146    }
     147   
     148    /** Retrieve the authors email for this collection.
     149     * @return The email as a <strong>String</strong>.
     150     */
     151    public String getEmail() {
     152    if(cdm == null) {
     153        return StaticStrings.EMPTY_STR;
     154    }
     155    CollectionMeta creator_collectionmeta = new CollectionMeta(CollectionDesignManager.collect_config.getCreator());
     156    return creator_collectionmeta.getValue(CollectionMeta.TEXT);
     157    }
     158   
     159    /** Retrieve the short name for this collection.
     160     * @return The name as a <strong>String</strong>.
     161     */
     162    public String getName() {
     163    return file.getParentFile().getName();
     164    }
     165   
     166    /** Determine if this collection has been saved since the last major change.
     167     * @return <i>true</i> if it has been saved recently, <i>false</i> otherwise.
     168     */
     169    public boolean getSaved() {
     170    return saved;
     171    }
     172   
     173    /** Retrieve the title of this collection.
     174     * @return The title as a <strong>String</strong>.
     175     */
     176    public String getTitle() {
     177    if(cdm == null) {
     178        return StaticStrings.EMPTY_STR;
     179    }
     180    CollectionMeta collection_name_collectionmeta = cdm.collectionmeta_manager.getMetadatum(StaticStrings.COLLECTIONMETADATA_COLLECTIONNAME_STR);
     181    return collection_name_collectionmeta.getValue(CollectionMeta.TEXT);
     182    }
     183
     184    /** Save this xml document to the given file. */
     185    public void save() {
    290186    Utility.export(document, file);
    291     }
    292 
    293    public void setBaseCollection(String base_collection) {
    294       set(BASE_COLLECTION, base_collection);
    295    }
    296 
    297     /** Set the value of imported to the given value.
    298     * @param value The new value for imported, <i>true</i> if the collection has been imported successfully, <i>false</i> otherwise.
    299     */
    300     public void setImported(boolean value) {
     187    }
     188
     189    public void setBaseCollection(String base_collection) {
     190    set(BASE_COLLECTION, base_collection);
     191    }
     192   
     193    /** Set the value of imported to the given value.
     194    * @param value The new value for imported, <i>true</i> if the collection has been imported successfully, <i>false</i> otherwise.
     195    */
     196    public void setImported(boolean value) {
    301197    set(IMPORTED, value);
    302198    saved = false;
    303     }
    304     /** Set the value of saved to the given value.
    305      * @param value The new value for saved, <i>true</i> if the collection has been saved recently, <i>false</i> otherwise.
    306      */
    307     public void setSaved(boolean value) {
     199    }
     200
     201    /** Set the value of saved to the given value.
     202     * @param value The new value for saved, <i>true</i> if the collection has been saved recently, <i>false</i> otherwise.
     203     */
     204    public void setSaved(boolean value) {
    308205    saved = value;
    309     }
    310     /** Set the value of title to the given value.
    311      * @param title The new <strong>String</strong> title.
    312      */
    313     public void setTitle(String title) {
    314         if(cdm != null) {
    315             CollectionMeta collection_name_collectionmeta = cdm.collectionmeta_manager.getMetadatum(StaticStrings.COLLECTIONMETADATA_COLLECTIONNAME_STR);
    316             collection_name_collectionmeta.setValue(title);
    317         }
    318     }
    319     /** Method called to return a textual representation of a class, which in this case is the collections title.
    320      * @return A <strong>String</strong> containing the collections title.
    321      */
    322     public String toString() {
    323         return getTitle();
    324     }
    325     /** Get the value of a collection argument. */
    326     private boolean get(String name) {
     206    }
     207
     208    /** Set the value of title to the given value.
     209     * @param title The new <strong>String</strong> title.
     210     */
     211    public void setTitle(String title) {
     212    if(cdm != null) {
     213        CollectionMeta collection_name_collectionmeta = cdm.collectionmeta_manager.getMetadatum(StaticStrings.COLLECTIONMETADATA_COLLECTIONNAME_STR);
     214        collection_name_collectionmeta.setValue(title);
     215    }
     216    }
     217
     218    /** Method called to return a textual representation of a class, which in this case is the collections title.
     219     * @return A <strong>String</strong> containing the collections title.
     220     */
     221    public String toString() {
     222    return getTitle();
     223    }
     224   
     225    /** Get the value of a collection argument. */
     226    private boolean get(String name) {
    327227    boolean result = false;
    328228    try {
    329         Element document_element = document.getDocumentElement();
    330         NodeList arguments = document_element.getElementsByTagName(ARGUMENT);
    331         boolean found = false;
    332         for(int i = 0; !found && i < arguments.getLength(); i++) {
     229        Element document_element = document.getDocumentElement();
     230        NodeList arguments = document_element.getElementsByTagName(ARGUMENT);
     231        boolean found = false;
     232        for(int i = 0; !found && i < arguments.getLength(); i++) {
    333233        Element argument_element = (Element) arguments.item(i);
    334234        if(argument_element.getParentNode() == document_element) {
    335             if(argument_element.getAttribute(NAME).equalsIgnoreCase(name)) {
     235            if(argument_element.getAttribute(StaticStrings.NAME_ATTRIBUTE).equalsIgnoreCase(name)) {
    336236            String value = MSMUtils.getValue(argument_element);
    337             if(value.equalsIgnoreCase(TRUE)) {
    338                 result = true;
     237            if(value.equalsIgnoreCase(StaticStrings.TRUE_STR)) {
     238                result = true;
    339239            }
    340240            found = true;
    341241            value = null;
    342             }
     242            }
    343243        }
    344244        argument_element = null;
    345         }
    346         arguments = null;
    347         document_element = null;
    348     }
    349     catch (Exception error) {
    350         Gatherer.printStackTrace(error);
     245        }
     246        arguments = null;
     247        document_element = null;
     248    }
     249    catch (Exception error) {
     250        Gatherer.printStackTrace(error);
    351251    }
    352252    return result;
    353     }
    354 
    355     /** Get the value of a collection argument. */
    356     private String getString(String name) {
     253    }
     254   
     255    /** Get the value of a collection argument. */
     256    private String getString(String name) {
    357257    String result = "";
    358258    try {
    359         Element document_element = document.getDocumentElement();
    360         NodeList arguments = document_element.getElementsByTagName(ARGUMENT);
    361         boolean found = false;
    362         for(int i = 0; !found && i < arguments.getLength(); i++) {
     259        Element document_element = document.getDocumentElement();
     260        NodeList arguments = document_element.getElementsByTagName(ARGUMENT);
     261        boolean found = false;
     262        for(int i = 0; !found && i < arguments.getLength(); i++) {
    363263        Element argument_element = (Element) arguments.item(i);
    364264        if(argument_element.getParentNode() == document_element) {
    365             if(argument_element.getAttribute(NAME).equalsIgnoreCase(name)) {
     265            if(argument_element.getAttribute(StaticStrings.NAME_ATTRIBUTE).equalsIgnoreCase(name)) {
    366266            result = MSMUtils.getValue(argument_element);
    367267            found = true;
    368             }
     268            }
    369269        }
    370270        argument_element = null;
    371         }
    372         arguments = null;
    373         document_element = null;
    374     }
    375     catch (Exception error) {
    376         Gatherer.printStackTrace(error);
     271        }
     272        arguments = null;
     273        document_element = null;
     274    }
     275    catch (Exception error) {
     276        Gatherer.printStackTrace(error);
    377277    }
    378278    return result;
    379     }
    380 
    381     /** Method to retrieve the current build options associated with this Collection. */
    382     private Element getBuildValues() {
     279    }
     280   
     281    /** Method to retrieve the current build options associated with this Collection. */
     282    private Element getBuildValues() {
    383283    Element build_values_element = null;
    384284    try {
    385         Element document_element = document.getDocumentElement();
    386         Element build_config_element = (Element) MSMUtils.getNodeFromNamed(document_element, BUILD_CONFIG);
    387         build_values_element = (Element) MSMUtils.getNodeFromNamed(build_config_element, BUILD);
    388         build_config_element = null;
    389         document_element = null;
    390     }
    391     catch (Exception error) {
    392         Gatherer.printStackTrace(error);
     285        Element document_element = document.getDocumentElement();
     286        Element build_config_element = (Element) MSMUtils.getNodeFromNamed(document_element, BUILD_CONFIG);
     287        build_values_element = (Element) MSMUtils.getNodeFromNamed(build_config_element, BUILD);
     288        build_config_element = null;
     289        document_element = null;
     290    }
     291    catch (Exception error) {
     292        Gatherer.printStackTrace(error);
    393293    }
    394294    return build_values_element;
    395     }
    396 
    397     /** Count either documents or folders, depending on the state of the given boolean. */
    398     private int getCount(TreeNode node, boolean count_folders, boolean count_files) {
     295    }
     296   
     297    /** Count either documents or folders, depending on the state of the given boolean. */
     298    private int getCount(TreeNode node, boolean count_folders, boolean count_files) {
    399299    int count = 0;
    400300    File file = ((FileNode)node).getFile();
    401301    if(file.isFile() && count_files) {
    402         count++;
     302        count++;
    403303    }
    404304    else if(file.isDirectory() && count_folders) {
    405         count++;
     305        count++;
    406306    }
    407307    for(int i = 0; i < node.getChildCount(); i++) {
    408         count = count + getCount(node.getChildAt(i), count_folders, count_files);
     308        count = count + getCount(node.getChildAt(i), count_folders, count_files);
    409309    }
    410310    return count;
    411     }
    412 
    413     /** Method to retrieve the current import options associated with this Collection. */
    414     public Element getImportValues() {
     311    }
     312   
     313    /** Method to retrieve the current import options associated with this Collection. */
     314    public Element getImportValues() {
    415315    Element import_values_element = null;
    416316    try {
    417         Element document_element = document.getDocumentElement();
    418         Element build_config_element = (Element) MSMUtils.getNodeFromNamed(document_element, BUILD_CONFIG);
    419         import_values_element = (Element) MSMUtils.getNodeFromNamed(build_config_element, IMPORT);
    420         build_config_element = null;
    421         document_element = null;
    422     }
    423     catch (Exception error) {
    424         Gatherer.printStackTrace(error);
     317        Element document_element = document.getDocumentElement();
     318        Element build_config_element = (Element) MSMUtils.getNodeFromNamed(document_element, BUILD_CONFIG);
     319        import_values_element = (Element) MSMUtils.getNodeFromNamed(build_config_element, IMPORT);
     320        build_config_element = null;
     321        document_element = null;
     322    }
     323    catch (Exception error) {
     324        Gatherer.printStackTrace(error);
    425325    }
    426326    return import_values_element;
    427     }
    428 
    429    /** Set the value of a collection argument. */
    430    private void set(String name, boolean value) {
    431       set(name, (value ? StaticStrings.TRUE_STR : StaticStrings.FALSE_STR));
    432    }
    433 
    434    private void set(String name, String value) {
    435       try {
    436      Element document_element = document.getDocumentElement();
    437      NodeList arguments = document_element.getElementsByTagName(ARGUMENT);
    438      boolean found = false;
    439      for(int i = 0; !found && i < arguments.getLength(); i++) {
     327    }
     328   
     329    /** Set the value of a collection argument. */
     330    private void set(String name, boolean value) {
     331    set(name, (value ? StaticStrings.TRUE_STR : StaticStrings.FALSE_STR));
     332    }
     333   
     334    private void set(String name, String value) {
     335    try {
     336        Element document_element = document.getDocumentElement();
     337        NodeList arguments = document_element.getElementsByTagName(ARGUMENT);
     338        boolean found = false;
     339        for(int i = 0; !found && i < arguments.getLength(); i++) {
    440340        Element argument_element = (Element) arguments.item(i);
    441341        if(argument_element.getParentNode() == document_element) {
    442            if(argument_element.getAttribute(NAME).equalsIgnoreCase(name)) {
    443           // Strip any current value nodes.
    444           while(argument_element.hasChildNodes()) {
    445              argument_element.removeChild(argument_element.getFirstChild());
    446           }
    447           // Append new value
    448           argument_element.appendChild(document.createTextNode(value));
    449           found = true;
    450            }
     342            if(argument_element.getAttribute(StaticStrings.NAME_ATTRIBUTE).equalsIgnoreCase(name)) {
     343            // Strip any current value nodes.
     344            while(argument_element.hasChildNodes()) {
     345                argument_element.removeChild(argument_element.getFirstChild());
     346            }
     347            // Append new value
     348            argument_element.appendChild(document.createTextNode(value));
     349            found = true;
     350            }
    451351        }
    452352        argument_element = null;
    453      }
    454      // Append it
    455      if(!found) {
     353        }
     354        // Append it
     355        if(!found) {
    456356        Element argument_element = document.createElement(ARGUMENT);
    457         argument_element.setAttribute(NAME, name);
     357        argument_element.setAttribute(StaticStrings.NAME_ATTRIBUTE, name);
    458358        argument_element.appendChild(document.createTextNode(value));
    459359        document_element.appendChild(argument_element);
    460360        argument_element = null;
    461      }
    462      arguments = null;
    463      document_element = null;
    464       }
    465       catch (Exception error) {
    466      Gatherer.printStackTrace(error);
    467       }
    468    }
     361        }
     362        arguments = null;
     363        document_element = null;
     364    }
     365    catch (Exception error) {
     366        Gatherer.printStackTrace(error);
     367    }
     368    }
    469369}
Note: See TracChangeset for help on using the changeset viewer.