Changeset 7530


Ignore:
Timestamp:
2004-06-02T12:00:03+12:00 (20 years ago)
Author:
kjdon
Message:

hacked this so that it reads in attribute values that contain spaces - if the value starts with ' and doesn't end with ' then read in tokens until it does.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/shell/GShellElement.java

    r6388 r7530  
    2929import java.util.StringTokenizer;
    3030import org.greenstone.gatherer.util.StaticStrings;
     31
    3132/** This class wraps around a pseudo-XML message we have recieved from an external script, and allows access to the element name, attributes etc via method calls. */
    3233public class GShellElement {
     
    3536    private String element_name;
    3637    /** Create a new element around the message string. The string is expected to start with < and end with > */
     38    /** this is a hack - why aren't we using proper XML parsing?? */
    3739    public GShellElement(String message) {
    3840    // Remove the angle brackets
     
    6264            attribute_value = attribute_value.substring(0, attribute_value.length() - 1);
    6365        }
    64         // We may have to strip ' marks off value
    65         if(attribute_value.startsWith(StaticStrings.SINGLE_QUOTE_CHARACTER) && attribute_value.endsWith(StaticStrings.SINGLE_QUOTE_CHARACTER)) {
    66             attribute_value = attribute_value.substring(1, attribute_value.length() - 1);
     66        // We may have to strip ' marks off value - if it starts with ' and doesn't end with ' we read in more tokens until we get an ending '
     67        if(attribute_value.startsWith(StaticStrings.SINGLE_QUOTE_CHARACTER)) {
     68            while (!attribute_value.endsWith(StaticStrings.SINGLE_QUOTE_CHARACTER) && tokenizer.hasMoreTokens()) {
     69            attribute_value += " "+tokenizer.nextToken();
     70            }
     71            if (attribute_value.endsWith(StaticStrings.SINGLE_QUOTE_CHARACTER)) {
     72            attribute_value = attribute_value.substring(1, attribute_value.length() - 1);
     73            }
    6774        }
    6875        if(attributes == null) {
Note: See TracChangeset for help on using the changeset viewer.