Ignore:
Timestamp:
2003-12-01T19:52:02+13:00 (20 years ago)
Author:
jmt12
Message:

Have rearranged where and how strings are feed through the Codec. After several hours work and a dozen paper trials I discovered the TEXT_TO_DOM conversion was completely pointless (DOM does it itself). Also the quotes only need to be dealt to if they are being sent to the collect.cfg file. Hopefully I've got it all going now - including using that pesky pipe character that I would rather not have to deal with. And everything seems to be ok - I tested all the dangerous characters including square brackets and amperstamp. I also tried hierarchies, and then as the piece'd'resistance I tried a hierarchies with dangerous characters. All good. I'm all about the working metadata.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/util/Codec.java

    r6051 r6069  
    3737 */
    3838public class Codec {
    39 
     39   
    4040    static final public String DECODE_PATH = "DECODE_PATH";
    41    static final public String DOM_TO_GREENSTONE = "DOM_TO_GREENSTONE";
    42    static final public String DOM_TO_TEXT = "DOM_TO_TEXT";
     41    static final public String DECODE_SQUARE_BRACKETS = "DECODE_SQUARE_BRACKETS";
     42    static final public String DOM_TO_GREENSTONE = "DOM_TO_GREENSTONE";
     43    static final public String DOM_TO_TEXT = "DOM_TO_TEXT";
    4344    static final public String ENCODE_PATH = "ENCODE_PATH";
    44    static final public String GREENSTONE_TO_DOM = "GREENSTONE_TO_DOM";
    45    static final public String GREENSTONE_TO_TEXT = "GREENSTONE_TO_TEXT";
    46    static final public String REMOVE_SQUARE_BRACKET = "REMOVE_SQUARE_BRACKET";
    47    static final public String TEXT_TO_DOM = "TEXT_TO_DOM";
    48    static final public String TEXT_TO_GREENSTONE = "TEXT_TO_GREENSTONE";
    49    static final public String TEXT_TO_SHELL_UNIX = "TEXT_TO_SHELL_UNIX";
    50    static final public String TEXT_TO_SHELL_WINDOWS = "TEXT_TO_SHELL_WINDOWS";
    51 
     45    static final public String ENCODE_SQUARE_BRACKETS = "ENCODE_SQUARE_BRACKETS";
     46    static final public String GREENSTONE_TO_DOM = "GREENSTONE_TO_DOM";
     47    static final public String GREENSTONE_TO_TEXT = "GREENSTONE_TO_TEXT";
     48    static final public String TEXT_TO_DOM = "TEXT_TO_DOM";
     49    static final public String TEXT_TO_GREENSTONE = "TEXT_TO_GREENSTONE";
     50    static final public String TEXT_TO_SHELL_UNIX = "TEXT_TO_SHELL_UNIX";
     51    static final public String TEXT_TO_SHELL_WINDOWS = "TEXT_TO_SHELL_WINDOWS";
     52   
    5253    static final private int MAX_CACHE_SIZE = 100;
    53 
     54   
    5455    static private HashMap TRANSFORMS;
    5556    static private HashMap3D CACHE;
    56 
    57 
     57   
    5858    /** Static function called to construct TRANSFORMS mappings */
    5959    static {
     
    6161
    6262    String[] decode_path = {
    63         "\\|", "\\\\"
     63        "\\|",    "\\\\",
     64        "|", "\\|"
    6465    };
    6566    TRANSFORMS.put(DECODE_PATH, decode_path);
    6667    decode_path = null;
     68
     69    // Transform text into text, but without [ and ]
     70    String[] decode_square_brackets = {
     71        "[", "\\[",
     72        "]", "\\]"
     73    };
     74    TRANSFORMS.put(DECODE_SQUARE_BRACKETS, decode_square_brackets);
     75    decode_square_brackets = null;
    6776
    6877    // Translate DOM encoded text into Greenstone encoding
     
    94103
    95104    String[] encode_path = {
     105        "\\|",  "|",
    96106        "\\\\", "\\|"
    97107    };
    98108    TRANSFORMS.put(ENCODE_PATH, encode_path);
    99109    encode_path = null;
     110
     111    // Transform text into text, but without [ and ]
     112    String[] encode_square_brackets = {
     113        "\\[", "[",
     114        "\\]", "]"
     115    };
     116    TRANSFORMS.put(ENCODE_SQUARE_BRACKETS, encode_square_brackets);
     117    encode_square_brackets = null;
    100118
    101119    // Transform Greenstone encoded text to DOM encoding
     
    125143    TRANSFORMS.put(GREENSTONE_TO_TEXT, greenstone_to_text);
    126144    greenstone_to_text = null;
    127 
    128     // Transform text into text, but without [ and ]
    129     String[] remove_square_bracket = {
    130         "\\[", "[",
    131         "\\]", "]"
    132     };
    133     TRANSFORMS.put(REMOVE_SQUARE_BRACKET, remove_square_bracket);
    134     remove_square_bracket = null;
    135145
    136146    // Transform plain html text into something that can be placed in a DOM
Note: See TracChangeset for help on using the changeset viewer.