Changeset 4558


Ignore:
Timestamp:
2003-06-11T13:43:34+12:00 (21 years ago)
Author:
kjdon
Message:

have a new toStringConfig method that returns the config file format - metadata should not have the ex. namespace, also changed one part to use StringBuffer instead of string

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/cdm/Argument.java

    r4366 r4558  
    5454import java.util.Iterator;
    5555import java.util.HashMap;
     56import org.greenstone.gatherer.msm.MSMUtils;
     57import org.greenstone.gatherer.util.Utility;
    5658/** This class contains all the details about a single argument that can be passed to this plugin, including option lists if the parameters are restricted.
    5759 * @author John Thompson, Greenstone Digital Library, University of Waikato
     
    359361        return "-" + name;
    360362    case METADATUM:
    361         String text = "-" + name + " ";
     363        StringBuffer text = new StringBuffer("-");
     364        text.append(name);
     365        text.append(" ");
    362366        for(int i = 0; i < values.size(); i++) {
    363         text = text + values.get(i).toString();
     367        text.append(values.get(i).toString());
    364368        if(i < values.size() - 1) {
    365             text = text + ",";
     369            text.append(",");
    366370        }
    367371        }
    368         return text;
     372        return text.toString();
     373    case STRING:
     374        // we need to put quotes if they are not there
     375        if (value.indexOf(' ') != -1 && value.indexOf('"')==-1) {
     376        // if there is a space and we haven't got any quotes
     377        return "-" + name + " \"" + value + "\"";
     378        } // otherwise it will stuff up but I cant be bothered doing this properly
    369379    default:
    370380        return "-" + name + " " + value;
    371381    }
    372382    }
     383
     384    public String toStringConfig() {
     385    switch(type) {
     386    case METADATA:
     387        if (value != null) {
     388        String temp_value = value;
     389       
     390        if (temp_value.startsWith(Utility.EXTRACTED_METADATA_NAMESPACE+MSMUtils.NS_SEP)) {
     391           
     392            temp_value = temp_value.substring(temp_value.indexOf(MSMUtils.NS_SEP)+1);
     393        }
     394        return "-" + name + " " + temp_value;
     395        }
     396        return "-" + name;
     397    case METADATUM:
     398        StringBuffer text = new StringBuffer("-");
     399        text.append(name);
     400        text.append(" ");
     401        for(int i = 0; i < values.size(); i++) {
     402        String temp_value = values.get(i).toString();
     403        if (temp_value.startsWith(Utility.EXTRACTED_METADATA_NAMESPACE+MSMUtils.NS_SEP)) {
     404           
     405            temp_value = temp_value.substring(temp_value.indexOf(MSMUtils.NS_SEP)+1);
     406        }
     407        text.append(temp_value);
     408        if(i < values.size() - 1) {
     409            text.append(",");
     410        }
     411        }
     412        return text.toString();
     413    default:
     414        return toString();
     415    }
     416    }
     417   
    373418}
    374419
Note: See TracChangeset for help on using the changeset viewer.