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/gui/MetaEditPane.java

    r6051 r6069  
    231231       private String value = null;
    232232
    233        private AppendMetadataTask(ElementWrapper element, String value) {
     233       private AppendMetadataTask(ElementWrapper element, String raw_value) {
    234234      this.element = element;
     235      this.value = raw_value;
    235236      // 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
    236       this.value = Codec.transform(value, Codec.ENCODE_PATH);
    237       this.value = Codec.transform(this.value, Codec.REMOVE_SQUARE_BRACKET);
    238       this.value = Codec.transform(this.value, Codec.TEXT_TO_DOM);
     237      //this.value = /odec.transform(value, /odec.ENCODE_PATH);
     238      //this.value = /odec.transform(this.value, /odec.REMOVE_SQUARE_BRACKET);
     239      //this.value = /odec.transform(this.value, /odec.TEXT_TO_DOM);
    239240       }
    240241
     
    267268       private String value;
    268269
    269     private UpdateMetadataTask(ElementWrapper element, String value) {
     270    private UpdateMetadataTask(ElementWrapper element, String raw_value) {
    270271      this.element = element;
     272      this.value = raw_value;
    271273      // Transform the raw text to be DOM compatible - as that will be its next destination immediately after being added to the value model
    272       this.value = Codec.transform(value, Codec.REMOVE_SQUARE_BRACKET);
    273       this.value = Codec.transform(this.value, Codec.TEXT_TO_DOM);
     274      //this.value = /odec.transform(value, /odec.REMOVE_SQUARE_BRACKET);
     275      //this.value = /odec.transform(this.value, /odec.TEXT_TO_DOM);
    274276    }
    275277
     
    11031105        JPanel value_field_pane = new JPanel();
    11041106        TransformCharacterTextField value_init = new TransformCharacterTextField();
    1105         value_init.replaceCharacter(StaticStrings.PIPE_CHAR, StaticStrings.FORWARDSLASH_CHAR);
     1107        //value_init.replaceCharacter(StaticStrings.PIPE_CHAR, StaticStrings.FORWARDSLASH_CHAR);
    11061108        value = value_init;
    11071109        value_init = null;
     
    11891191
    11901192    public String getSelectedValue() {
    1191         return Codec.transform(Codec.transformUnicode(value.getText()), Codec.TEXT_TO_GREENSTONE);
     1193        //return /odec.transform(/odec.transformUnicode(value.getText()), /odec.TEXT_TO_GREENSTONE);
     1194        String raw_value = value.getText();
     1195        raw_value = Codec.transformUnicode(raw_value);
     1196        raw_value = Codec.transform(raw_value, Codec.ENCODE_PATH);
     1197        raw_value = Codec.transform(raw_value, Codec.ENCODE_SQUARE_BRACKETS);
     1198        return raw_value;
    11921199    }
    11931200
     
    12561263        // Setting the text of the field causes the DocumentListener to be notified, and
    12571264        //   updating the tree is handled there (DocumentListenerImpl::validate())
    1258         ///ystem.err.println("Setting selected value to: " + val);
    12591265        if (!card_showing.equals(NONE)) {
     1266        // Decode val
     1267        //System.err.println("Before transforms: " + val);
     1268        //val = Codec.transform(val, Codec.DECODE_SQUARE_BRACKETS);
     1269        //val = Codec.transform(val, Codec.DECODE_PATH);
     1270        //System.err.println("Setting selected value to: " + val);
    12601271        manual_text_edit_event = val.equals("");  // Set to false unless val == ""
    1261         value.setText(Codec.transform(val, Codec.GREENSTONE_TO_TEXT));
     1272        value.setText(val); ///odec.transform(val, /odec.GREENSTONE_TO_TEXT));
    12621273        value.setCaretPosition(0);
    12631274        manual_text_edit_event = true;
     
    12691280    private TreePath getClosestPath(String val)
    12701281    {
     1282        System.err.println("Select closest path to: " + val);
    12711283        // Start at the root of the tree
    12721284        GValueNode tree_node = (GValueNode) tree.getModel().getRoot();
    12731285
    1274         // Hierarchical values are separated using '\'
    1275         PatternTokenizer tokenizer = new PatternTokenizer(val, "\\");  // StaticStrings.PIPE_STR);
     1286        // Hierarchical values are separated using '|'
     1287        PatternTokenizer tokenizer = new PatternTokenizer(val, StaticStrings.PIPE_STR);
    12761288        while (tokenizer.hasMoreTokens()) {
    12771289        String token = tokenizer.nextToken();
     
    13361348            TreePath path = tree.getSelectionPath();
    13371349            GValueNode node = (GValueNode) path.getLastPathComponent();
    1338             value.setText(node.getFullPath(true));
     1350            String val = node.getFullPath(true);
     1351            System.err.println("Setting value to: " + val);
     1352            value.setText(val);
     1353            val = null;
    13391354            }
    13401355        }
     
    13741389        private void validate()
    13751390        {
    1376         String value_text = Codec.transform(getSelectedValue(), Codec.TEXT_TO_DOM);
     1391        String value_text = getSelectedValue(); ///odec.transform(getSelectedValue(), /odec.TEXT_TO_DOM);
    13771392        ///ystem.err.println("\n(Validate) Value text: " + value_text);
    13781393
Note: See TracChangeset for help on using the changeset viewer.