Changeset 5877


Ignore:
Timestamp:
2003-11-18T15:32:46+13:00 (20 years ago)
Author:
jmt12
Message:

Introduced two new codec transforms to correctly handle path information

Location:
trunk/gli/src/org/greenstone/gatherer
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/gui/MetaEditPane.java

    r5809 r5877  
    233233      this.element = element;
    234234      // Transform the raw text to be GREENSTONE and DOM compatible - as that will be its next destination immediately after being added to the value model
    235       this.value = Codec.transform(value, Codec.REMOVE_SQUARE_BRACKET);
     235      this.value = Codec.transform(value, Codec.ENCODE_PATH);
     236      this.value = Codec.transform(this.value, Codec.REMOVE_SQUARE_BRACKET);
    236237      this.value = Codec.transform(this.value, Codec.TEXT_TO_DOM);
    237238       }
     
    11981199        TreePath path = tree.getSelectionPath();
    11991200        GValueNode node = (GValueNode) path.getLastPathComponent();
    1200         setSelectedValue(node.getFullPath(false));
     1201        setSelectedValue(node.getFullPath(true));
    12011202        }
    12021203    }
  • trunk/gli/src/org/greenstone/gatherer/util/Codec.java

    r5835 r5877  
    3838public class Codec {
    3939
     40    static final public String DECODE_PATH = "DECODE_PATH";
    4041   static final public String DOM_TO_GREENSTONE = "DOM_TO_GREENSTONE";
    4142   static final public String DOM_TO_TEXT = "DOM_TO_TEXT";
     43    static final public String ENCODE_PATH = "ENCODE_PATH";
    4244   static final public String GREENSTONE_TO_DOM = "GREENSTONE_TO_DOM";
    4345   static final public String GREENSTONE_TO_TEXT = "GREENSTONE_TO_TEXT";
     
    5860    TRANSFORMS = new HashMap();
    5961
     62    String[] decode_path = {
     63        "\\|", "\\\\"
     64    };
     65    TRANSFORMS.put(DECODE_PATH, decode_path);
     66    decode_path = null;
     67
    6068    // Translate DOM encoded text into Greenstone encoding
    6169    String[] dom_to_greenstone = {
     
    6472        "&lt;", "<",
    6573        "&quot;", "\\\\\"",
    66         "&amp;", "&",
    67         "\\|", "\\\\"
     74        "&amp;", "&"
    6875    };
    6976    //  removed "\n", "\\\\n", - config files are allowed new lines
     
    8188       "&lt;", "<",
    8289       "&quot;", "\"",
    83        "&amp;", "&",
    84        "\\|", "\\\\"
     90       "&amp;", "&"
    8591    };
    8692    TRANSFORMS.put(DOM_TO_TEXT, dom_to_text);
    8793    dom_to_text = null;
     94
     95    String[] encode_path = {
     96        "\\\\", "\\|"
     97    };
     98    TRANSFORMS.put(ENCODE_PATH, encode_path);
     99    encode_path = null;
    88100
    89101    // Transform Greenstone encoded text to DOM encoding
     
    93105        ">", "&gt;",
    94106        "\\\\\"", "&quot;",
    95         "\\\\\'", "&apos;",
    96         "\\\\", "\\|"
     107        "\\\\\'", "&apos;"
    97108    };
    98109    // removed"\\\\n", "\n", added "\\\\", "\\|"
     
    109120        "&#091;", "\\[",
    110121        "&#093;", "\\]"
    111        
    112122    };
    113123    // removed    "\\\\n", "\n", "\\|", "\\\\"
     
    130140        ">", "&gt;",
    131141        "\"", "&quot;",
    132         "\'", "&apos;",
    133         "\\\\", "\\|",
     142        "\'", "&apos;"
    134143    };
    135144    TRANSFORMS.put(TEXT_TO_DOM, text_to_dom);
     
    171180
    172181    static public String transform(String raw, String transform) {
    173     ///ystem.err.println("transforming "+transform);
     182    ///ystem.err.println("Transforming by "+transform+":\n" + raw);
    174183    String processed = (String) CACHE.get(transform, raw);
    175184    if(processed == null) {
     
    183192        }
    184193        }
    185         ///atherer.println("*** Transform: " + transform + " ***");
    186         ///atherer.println("*** Raw      : '" + raw + "'");
    187         ///atherer.println("*** Processed: '" + processed + "'");
     194        //Gatherer.println("\n*** Transform: " + transform + " ***");
     195        //Gatherer.println("*** Raw      : '" + raw + "'");
     196        //Gatherer.println("*** Processed: '" + processed + "'");
    188197        // If cache is at maximum size, empty it and start again
    189198        if(CACHE.size() == MAX_CACHE_SIZE) {
  • trunk/gli/src/org/greenstone/gatherer/valuetree/GValueNode.java

    r5805 r5877  
    192192    }
    193193    if(as_text) {
    194         return Codec.transform(path.toString(), Codec.GREENSTONE_TO_TEXT);
     194        String temp = Codec.transform(path.toString(), Codec.GREENSTONE_TO_TEXT);
     195        return Codec.transform(temp, Codec.DECODE_PATH);
    195196    }
    196197    else {
     
    339340    if(name.equals("Subject")) {
    340341       result = MSMUtils.getValue(element);
     342       result = Codec.transform(result, Codec.DECODE_PATH);
    341343       switch(decode_type) {
    342344          case GValueNode.GREENSTONE:
Note: See TracChangeset for help on using the changeset viewer.