Ignore:
Timestamp:
2014-09-15T22:10:28+02:00 (10 years ago)
Author:
donvip
Message:

[josm_surveyor] fix #josm4867 - add timeout parameter for SetWayPointAction: positive value to customize timeout, negative or zero to disable the dialog completely

Location:
applications/editors/josm/plugins/surveyor/src
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/AutoSaveAction.java

    r29854 r30646  
    3939    }
    4040
    41     /* (non-Javadoc)
    42      * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
    43      */
     41    @Override
    4442    public void actionPerformed(ActionEvent e) {
    4543        if (e.getSource() instanceof AbstractButton) {
     
    6058            task = new AutoSaveEditLayerTimerTask(osmFilename);
    6159            gpsDataTimer.schedule(task, 5000, AUTO_SAVE_PERIOD_SEC * 1000);
    62         } else {
    63             if(gpsDataTimer != null) {
    64                 gpsDataTimer.cancel();
    65             }
     60        } else if (gpsDataTimer != null) {
     61            gpsDataTimer.cancel();
    6662        }
    67 
    68 
    6963    }
    7064}
  • applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/AutoSaveGpsLayerTimerTask.java

    r29854 r30646  
    5353    }
    5454
    55 
    56     /* (non-Javadoc)
    57      * @see java.util.TimerTask#run()
    58      */
    5955    @Override
    6056    public void run() {
    6157
    6258        try {
    63 
    6459            GpxLayer gpsLayer = LayerUtil.findGpsLayer(gpsLayerName, GpxLayer.class);
    6560            if(gpsLayer == null) {
  • applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/MetaAction.java

    r13497 r30646  
    3333     */
    3434    public MetaAction() {
    35         // TODO Auto-generated constructor stub
    3635    }
    3736
     
    4140    public MetaAction(String name) {
    4241        super(name);
    43         // TODO Auto-generated constructor stub
    4442    }
    4543
     
    6866    }
    6967
    70     /*
    71      * (non-Javadoc)
    72      *
    73      * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
    74      */
     68    @Override
    7569    public void actionPerformed(ActionEvent e) {
    7670        // check if action was called by repeating key presses too long pressed):
     
    7872        if ((time - lastActionCall) < MIN_TIME_DIFF) {
    7973            lastActionCall = time;
    80 // System.out.println("repeating key detected");
    8174            return;
    8275        }
    8376        lastActionCall = time;
    84         // System.out.println("meta action '" + super.toString() + "' called");
    8577
    8678        // toggle on/off
  • applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/SurveyorComponent.java

    r29916 r30646  
    66
    77import static org.openstreetmap.josm.tools.I18n.tr;
     8
    89import java.awt.BorderLayout;
    910import java.awt.Dimension;
     
    116117    }
    117118
    118 
    119 
    120119    public static void main(String[] args) {
    121 
    122120
    123121        // parse xml file and create component from it:
     
    160158    }
    161159
    162     /* (non-Javadoc)
    163      * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
    164      */
     160    @Override
    165161    public void propertyChange(PropertyChangeEvent evt) {
    166162        if("gpsdata".equals(evt.getPropertyName())) {
     
    171167    }
    172168
    173     /* (non-Javadoc)
    174      * @see at.dallermassl.josm.plugin.surveyor.GpsDataSource#getGpsData()
    175      */
     169    @Override
    176170    public LiveGpsData getGpsData() {
    177171        return gpsData;
    178172    }
    179 
    180173}
  • applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/SurveyorShowAction.java

    r29916 r30646  
    5050    }
    5151
    52 
    53     /* (non-Javadoc)
    54      * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
    55      */
    5652    public void actionPerformed(ActionEvent e) {
    5753        if(surveyorFrame == null) {
     
    5955
    6056            SurveyorComponent comp = createComponent();
    61 //          comp.setGridSize(3,3);
    62 //          comp.addButton(new ButtonDescription("Tunnel", "T", "images/symbols/tunnel.png", "ConsolePrinterAction", ButtonType.SINGLE));
    63 //          comp.addButton(new ButtonDescription("Bridge", "B", null, "ConsolePrinterAction", ButtonType.TOGGLE));
    64 //          comp.addButton(new ButtonDescription("Motorway", "M", null, "ConsolePrinterAction", null));
    65 //          comp.addButton(new ButtonDescription("Primary", "I", null, "ConsolePrinterAction", null));
    66 //          comp.addButton(new ButtonDescription("Secondary", "S", null, "ConsolePrinterAction", null));
    67 //          comp.addButton(new ButtonDescription("Unclassified", "U", null, "ConsolePrinterAction", null));
    68 //          comp.addButton(new ButtonDescription("Residential", "R", null,
    69 //          new SurveyorActionDescription("SetWaypointAction", new String[] {"residential", "images/reorder.png"}), null));
    70 //          comp.addButton(new ButtonDescription("Parking", "P", "images/symbols/parking.png",
    71 //          new SurveyorActionDescription("SetNodeAction", new String[] {"amenity", "parking", "createdby", "surveyor"}), null));
    7257
    7358            // add component as gps event listener:
     
    143128        }
    144129        return component;
    145 
    146130    }
    147131
     
    175159                actions.add((SurveyorActionDescription)object);
    176160            } else {
    177                 System.err.println("surveyor: unknown xml element: " + object);
     161                Main.error("surveyor: unknown xml element: " + object);
    178162            }
    179163        }
    180164        return surveyorComponent;
    181165    }
    182 
    183166}
  • applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/action/AbstractSurveyorAction.java

    r13497 r30646  
    2424    }
    2525
    26     /* (non-Javadoc)
    27      * @see at.dallermassl.josm.plugin.surveyor.SurveyorAction#setParameters(java.util.List)
    28      */
    29     //@Override
     26    @Override
    3027    public void setParameters(List<String> parameters) {
    3128        this.parameters = parameters;
    3229    }
    33 
    3430}
  • applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/action/BeepAction.java

    r13497 r30646  
    2020    int beepNumber = 1;
    2121
    22     /* (non-Javadoc)
    23      * @see at.dallermassl.josm.plugin.surveyor.SurveyorAction#actionPerformed(at.dallermassl.josm.plugin.surveyor.GpsActionEvent)
    24      */
     22    @Override
    2523    public void actionPerformed(GpsActionEvent event) {
    26      // run as a separate thread
     24        // run as a separate thread
    2725        Main.worker.execute(new Runnable() {
    2826            public void run() {
     
    3836    }
    3937
    40     /* (non-Javadoc)
    41      * @see at.dallermassl.josm.plugin.surveyor.SurveyorAction#setParameters(java.util.List)
    42      */
     38    @Override
    4339    public void setParameters(List<String> parameters) {
    4440        try {
     
    4945        }
    5046    }
    51 
    5247}
  • applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/action/ConsolePrinterAction.java

    r13497 r30646  
    1515public class ConsolePrinterAction extends AbstractSurveyorAction {
    1616
    17     /* (non-Javadoc)
    18      * @see at.dallermassl.josm.plugin.surveyor.ButtonAction#actionPerformed(at.dallermassl.josm.plugin.surveyor.GpsActionEvent, java.util.List)
    19      */
     17    @Override
    2018    public void actionPerformed(GpsActionEvent event) {
    2119        LatLon coordinates = event.getCoordinates();
     
    2321            + coordinates.lon() + " params: " + getParameters());
    2422    }
    25 
    2623}
  • applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/action/PlayAudioAction.java

    r30362 r30646  
    3232    private String audioSource = null;
    3333
    34     /* (non-Javadoc)
    35      * @see at.dallermassl.josm.plugin.surveyor.SurveyorAction#actionPerformed(at.dallermassl.josm.plugin.surveyor.GpsActionEvent)
    36      */
    37     //@Override
     34    @Override
    3835    public void actionPerformed(GpsActionEvent event) {
    3936        // run as a separate thread
     
    4340                    if(audioSource == null) {
    4441                        audioSource = getParameters().get(0);
    45                         //System.out.println("reading audio from " + audioSource);
    4642                    }
    4743                    InputStream in = new BufferedInputStream(ResourceLoader.getInputStream(audioSource));
  • applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/action/SetNodeAction.java

    r29916 r30646  
    3636    }
    3737
    38     /* (non-Javadoc)
    39      * @see at.dallermassl.josm.plugin.surveyor.SurveyorAction#setParameters(java.util.List)
    40      */
    41     //@Override
     38    @Override
    4239    public void setParameters(List<String> parameters) {
    4340        keyValues = new ArrayList<Pair<String, String>>();
     
    5754    }
    5855
    59     /* (non-Javadoc)
    60      * @see at.dallermassl.josm.plugin.surveyor.ButtonAction#actionPerformed(at.dallermassl.josm.plugin.surveyor.GpsActionEvent)
    61      */
     56    @Override
    6257    public void actionPerformed(GpsActionEvent event) {
    6358        LatLon coordinates = event.getCoordinates();
  • applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/action/SetWaypointAction.java

    r29854 r30646  
    2424import at.dallermassl.josm.plugin.surveyor.SurveyorLock;
    2525import at.dallermassl.josm.plugin.surveyor.SurveyorPlugin;
     26import at.dallermassl.josm.plugin.surveyor.action.gui.DialogClosingThread;
    2627import at.dallermassl.josm.plugin.surveyor.action.gui.WaypointDialog;
    2728import at.dallermassl.josm.plugin.surveyor.util.LayerUtil;
     
    4748    }
    4849
    49 
    50     /* (non-Javadoc)
    51      * @see at.dallermassl.josm.plugin.surveyor.ButtonAction#actionPerformed(at.dallermassl.josm.plugin.surveyor.GpsActionEvent, java.util.List)
    52      */
    5350    public void actionPerformed(GpsActionEvent event) {
    54         //System.out.println(getClass().getSimpleName() + " KOORD: " + coordinates.lat() + ", " + coordinates.lon());
    5551        String markerTitle = getParameters().get(0);
    5652        Object source = event.getSource();
     
    6258            }
    6359        }
     60       
     61        String iconName = getParameters().size() > 1 ? getParameters().get(1).trim() : null;
    6462
    65         if(dialog == null) {
    66             dialog = new WaypointDialog();
     63        long timeout = DialogClosingThread.DEFAULT_TIMEOUT;
     64        if (getParameters().size() > 2) {
     65            try {
     66                timeout = Integer.parseInt(getParameters().get(2));
     67            } catch (NumberFormatException e) {
     68                Main.error(e.getMessage());
     69            }
    6770        }
    68 
     71       
    6972        String markerText = markerTitle;
    70         String inputText = dialog.openDialog(SurveyorPlugin.getSurveyorFrame(), tr("Waypoint Description"));
    71         if(inputText != null && inputText.length() > 0) {
    72             inputText = inputText.replaceAll("<", "_"); // otherwise the gpx file is ruined
    73             markerText = markerText + " " + inputText;
     73       
     74        if (timeout > 0) {
     75            if (dialog == null) {
     76                dialog = new WaypointDialog();
     77            }
     78   
     79            String inputText = dialog.openDialog(SurveyorPlugin.getSurveyorFrame(), tr("Waypoint Description"), timeout*1000);
     80            if(inputText != null && inputText.length() > 0) {
     81                inputText = inputText.replaceAll("<", "_"); // otherwise the gpx file is ruined
     82                markerText = markerText + " " + inputText;
     83            }
    7484        }
    75 
    76         String iconName = getParameters().size() > 1 ? getParameters().get(1) : null;
    7785
    7886        // add the waypoint to the marker layer AND to the gpx layer
     
    8290        WayPoint waypoint = new WayPoint(event.getCoordinates());
    8391        waypoint.attr.put("name", markerText);
    84         if(iconName != null)
     92        if(iconName != null && !iconName.isEmpty())
    8593            waypoint.attr.put("sym", iconName);
    8694        synchronized(SurveyorLock.class) {
    87             //layer.data.add(new Marker(event.getCoordinates(), markerText, iconName));
    8895            layer.data.add(new Marker(event.getCoordinates(), markerText, iconName, null, -1.0, 0.0));
    8996            if(gpsLayer != null) {
     
    105112            if(markerLayer == null) {
    106113                // not found, add a new one
    107                 //markerLayer = new MarkerLayer(new GpxData(), MARKER_LAYER_NAME, null);
    108114                markerLayer = new MarkerLayer(new GpxData(), MARKER_LAYER_NAME, null, null);
    109115                Main.main.addLayer(markerLayer);
     
    129135        return liveGpsLayer;
    130136    }
    131 
    132137}
  • applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/action/SystemExecuteAction.java

    r13497 r30646  
    1010import java.io.InputStreamReader;
    1111
     12import org.openstreetmap.josm.Main;
     13
    1214import at.dallermassl.josm.plugin.surveyor.GpsActionEvent;
    1315
     
    1820public class SystemExecuteAction extends AbstractSurveyorAction {
    1921
    20     /* (non-Javadoc)
    21      * @see at.dallermassl.josm.plugin.surveyor.SurveyorAction#actionPerformed(at.dallermassl.josm.plugin.surveyor.GpsActionEvent, java.util.List)
    22      */
    23     //@Override
     22    @Override
    2423    public void actionPerformed(GpsActionEvent event) {
    2524        final ProcessBuilder builder = new ProcessBuilder(getParameters());
    26         //Map<String, String> environ = builder.environment();
    2725        builder.directory(new File(System.getProperty("user.home")));
    2826
    29         System.out.println("Directory : " + builder.directory());
     27        Main.debug("Directory : " + builder.directory());
    3028        Thread executionThread = new Thread() {
    3129
    32             /* (non-Javadoc)
    33              * @see java.lang.Thread#run()
    34              */
    3530            @Override
    3631            public void run() {
     
    4843                    System.out.println(getClass().getSimpleName() + "Program terminated!");
    4944                } catch (Throwable t) {
    50                     t.printStackTrace();
     45                    Main.error(t);
    5146                }
    5247            }
    53 
    5448        };
    5549        executionThread.start();
    56 //        try {
    57 //            System.in.read();
    58 //        } catch (IOException e) {
    59 //            // TODO Auto-generated catch block
    60 //            e.printStackTrace();
    61 //        }
    6250    }
    6351}
  • applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/action/gui/DialogClosingThread.java

    r13497 r30646  
    1515import javax.swing.event.DocumentListener;
    1616
     17import org.openstreetmap.josm.Main;
     18
    1719/**
    1820 * @author cdaller
     
    2022 */
    2123public class DialogClosingThread extends Thread implements KeyListener, DocumentListener {
    22     private static long DEFAULT_TIMEOUT = 5000;
     24    public static final long DEFAULT_TIMEOUT = 5000;
    2325    private JDialog dialog;
    2426    private long timeout;
     
    4446    }
    4547
    46     /* (non-Javadoc)
    47      * @see java.lang.Thread#run()
    48      */
    4948    @Override
    5049    public void run() {
     
    6665    }
    6766
    68     /* (non-Javadoc)
    69      * @see java.awt.event.KeyListener#keyPressed(java.awt.event.KeyEvent)
    70      */
    71     //@Override
     67    @Override
    7268    public void keyPressed(KeyEvent e) {
    7369        reset();
    74         System.out.println("keypressed: " + e.getKeyCode());
     70        Main.debug("keypressed: " + e.getKeyCode());
    7571    }
    7672
    77     /* (non-Javadoc)
    78      * @see java.awt.event.KeyListener#keyReleased(java.awt.event.KeyEvent)
    79      */
    80     //@Override
     73    @Override
    8174    public void keyReleased(KeyEvent e) {
    8275        reset();
    83         System.out.println("keyreleased: " + e.getKeyCode());
     76        Main.debug("keyreleased: " + e.getKeyCode());
    8477    }
    8578
    86     /* (non-Javadoc)
    87      * @see java.awt.event.KeyListener#keyTyped(java.awt.event.KeyEvent)
    88      */
    89     //@Override
     79    @Override
    9080    public void keyTyped(KeyEvent e) {
    9181        reset();
    92         System.out.println("keytyped: " + e.getKeyCode());
     82        Main.debug("keytyped: " + e.getKeyCode());
    9383    }
    9484
     
    114104    }
    115105
    116     /* (non-Javadoc)
    117      * @see javax.swing.event.DocumentListener#changedUpdate(javax.swing.event.DocumentEvent)
    118      */
    119     //@Override
     106    @Override
    120107    public void changedUpdate(DocumentEvent e) {
    121108        reset();
    122         System.out.println("changedUpdate: " + e);
     109        Main.debug("changedUpdate: " + e);
    123110    }
    124111
    125     /* (non-Javadoc)
    126      * @see javax.swing.event.DocumentListener#insertUpdate(javax.swing.event.DocumentEvent)
    127      */
    128     //@Override
     112    @Override
    129113    public void insertUpdate(DocumentEvent e) {
    130114        reset();
    131         System.out.println("insertUpdate: " + e);
     115        Main.debug("insertUpdate: " + e);
    132116    }
    133117
    134     /* (non-Javadoc)
    135      * @see javax.swing.event.DocumentListener#removeUpdate(javax.swing.event.DocumentEvent)
    136      */
    137     //@Override
     118    @Override
    138119    public void removeUpdate(DocumentEvent e) {
    139120        reset();
    140         System.out.println("removeUpdate: " + e);
     121        Main.debug("removeUpdate: " + e);
    141122    }
    142123}
  • applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/action/gui/WaypointDialog.java

    r19211 r30646  
    55package at.dallermassl.josm.plugin.surveyor.action.gui;
    66
    7 import java.awt.BorderLayout;
    87import java.beans.PropertyChangeEvent;
    98import java.beans.PropertyChangeListener;
     
    1110import javax.swing.JDialog;
    1211import javax.swing.JFrame;
    13 import javax.swing.JLabel;
    1412import javax.swing.JOptionPane;
    1513import javax.swing.JTextField;
    16 
    1714
    1815/**
     
    2219public class WaypointDialog {
    2320
    24     public String openDialog(JFrame frame, String message) {
     21    public String openDialog(JFrame frame, String message, long timeout) {
    2522
    2623        JTextField textField = new JTextField(10);
     
    2926        Object[] array = {message, textField};
    3027
    31         //Create an array specifying the number of dialog buttons
    32         //and their text.
     28        //Create an array specifying the number of dialog buttons and their text.
    3329        Object[] options = {"OK"};
    3430
     
    4137                                    options[0]);
    4238
    43 //        final JOptionPane optionPane = new JOptionPane("The only way to close this dialog is by\n"
    44 //                        + "pressing one of the following buttons.\n" + "Do you understand?",
    45 //            JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION);
    46 
    47 
    4839        final JDialog dialog = new JDialog(frame, "Enter Description", true);
    49         DialogClosingThread closer = new DialogClosingThread(dialog);
     40        DialogClosingThread closer = new DialogClosingThread(dialog, timeout);
    5041        closer.observe(textField);
    5142        dialog.setContentPane(optionPane);
     
    5748                                && (prop.equals(JOptionPane.VALUE_PROPERTY))) {
    5849                    // If you were going to check something
    59                     // before closing the window, you'd do
    60                     // it here.
     50                    // before closing the window, you'd do it here.
    6151                    dialog.setVisible(false);
    6252                }
     
    6757        dialog.setVisible(true);
    6858
    69 
    70         //System.out.println("value: " + optionPane.getValue());
    7159        return textField.getText();
    72 
    73 //        int value = ((Integer) optionPane.getValue()).intValue();
    74 //        if (value == JOptionPane.YES_OPTION) {
    75 //            System.out.println("yes");
    76 //        } else if (value == JOptionPane.NO_OPTION) {
    77 //            System.out.println("no");
    78 //        }
    79 
    8060    }
    81 
    82     public static void main(String[] args) {
    83         //1. Create the frame.
    84           JFrame frame = new JFrame("FrameDemo");
    85 
    86           //2. Optional: What happens when the frame closes?
    87           frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    88 
    89           //3. Create components and put them in the frame.
    90           //...create emptyLabel...
    91           frame.getContentPane().add(new JLabel("test"), BorderLayout.CENTER);
    92 
    93           //4. Size the frame.
    94           frame.pack();
    95           frame.setSize(600,400);
    96           frame.setLocation(0,0);
    97 
    98           //5. Show it.
    99           frame.setVisible(true);
    100           new WaypointDialog().openDialog(frame, "test");
    101       }
    10261}
  • applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/util/ResourceLoader.java

    r30362 r30646  
    3737            in = new FileInputStream(source);
    3838        }
    39         System.out.println("stream for resource is " + in);
    4039        return in;
    4140    }
  • applications/editors/josm/plugins/surveyor/src/org/dinopolis/util/io/Tokenizer.java

    r26509 r30646  
    801801      return(new_list);
    802802    }
    803 
    804 //  /**
    805 //   * Demonstrates the low level interface.
    806 //   * @param args command line arguments.
    807 //   */
    808 //  protected static void testLowLevel(String[] args)
    809 //  {
    810 //    try
    811 //    {
    812 //      String filename;
    813 //      if(args.length > 0)
    814 //        filename = args[0];
    815 //      else
    816 //        filename = "/filer/cdaller/tmp/test.csv";
    817 //
    818 //      Tokenizer tokenizer = new Tokenizer(new BufferedReader(new FileReader(filename)));
    819 ////      Tokenizer tokenizer = new Tokenizer("column1,\"quoted column2\",column3\\, with quoted comma");
    820 //      tokenizer.setDelimiter(',');
    821 ////      tokenizer.eolIsSignificant(false);
    822 //      tokenizer.respectEscapedCharacters(true);
    823 //      tokenizer.respectQuotedWords(true);
    824 //
    825 //      int token;
    826 //      while((token = tokenizer.nextToken()) != Tokenizer.EOF)
    827 //      {
    828 //        switch(token)
    829 //        {
    830 //        case Tokenizer.EOL:
    831 //          System.out.println("------------- ");
    832 //          break;
    833 //        case Tokenizer.WORD:
    834 //          System.out.println("line" +tokenizer.getLineNumber() +" word: "+tokenizer.getWord());
    835 //          break;
    836 //        case Tokenizer.QUOTED_WORD:
    837 //          System.out.println("line" +tokenizer.getLineNumber() +" quoted word: "+tokenizer.getWord());
    838 //          break;
    839 //        case Tokenizer.DELIMITER:
    840 //          System.out.println("delimiter");
    841 //          break;
    842 //        default:
    843 //          System.err.println("Unknown Token: "+token);
    844 //        }
    845 //      }
    846 //      tokenizer.close();
    847 //    }
    848 //    catch(Exception ioe)
    849 //    {
    850 //      ioe.printStackTrace();
    851 //    }
    852 //  }
    853 //
    854 //
    855 //  /**
    856 //   * Demonstration of the high level interface.
    857 //   * @param args command line arguments.
    858 //   */
    859 //  protected static void testHighLevel(String[] args)
    860 //  {
    861 //    try
    862 //    {
    863 //      String filename;
    864 //      if(args.length > 0)
    865 //        filename = args[0];
    866 //      else
    867 //        filename = "/filer/cdaller/tmp/test.csv";
    868 //
    869 //      Tokenizer tokenizer = new Tokenizer(new BufferedReader(new FileReader(filename)));
    870 ////      Tokenizer tokenizer = new Tokenizer("column1,\"quoted column2\",column3\\, with quoted comma");
    871 //      tokenizer.setDelimiter(',');
    872 ////      tokenizer.eolIsSignificant(false);
    873 //      tokenizer.respectEscapedCharacters(true);
    874 //      tokenizer.respectQuotedWords(true);
    875 //
    876 //      List list;
    877 //      while(tokenizer.hasNextLine())
    878 //      {
    879 //        list = tokenizer.nextLine();
    880 //        System.out.println("List: "+list);
    881 //        System.out.println("List w/o zero length elements: "+removeZeroLengthElements(list));
    882 //        System.out.println("--");
    883 //      }
    884 //
    885 //    }
    886 //    catch(Exception ioe)
    887 //    {
    888 //      ioe.printStackTrace();
    889 //    }
    890 //  }
    891 //
    892 //   /**
    893 //   *  Demo code for the high level interface.
    894 //   */
    895 //  protected static void testHighLevelExample()
    896 //  {
    897 //    try
    898 //    {
    899 //          // simple example, tokenizing string, no escape, but quoted
    900 //          // works:
    901 //      System.out.println("example 1");
    902 //      Tokenizer tokenizer = new Tokenizer("text,,,\"another,text\"");
    903 //      List tokens;
    904 //      while(tokenizer.hasNextLine())
    905 //      {
    906 //        tokens = tokenizer.nextLine();
    907 //        System.out.println(tokens.get(0)); // prints 'text'
    908 //        System.out.println(tokens.get(1)); // prints ''
    909 //        System.out.println(tokens.get(2)); // prints ''
    910 //        System.out.println(tokens.get(3)); // prints 'another,text'
    911 //      }
    912 //
    913 //      System.out.println("example 2");
    914 //          // simple example, tokenizing string, using escape char and
    915 //          // quoted strings:
    916 //      tokenizer = new Tokenizer("text,text with\\,comma,,\"another,text\"");
    917 //      tokenizer.respectEscapedCharacters(true);
    918 //      while(tokenizer.hasNextLine())
    919 //      {
    920 //        tokens = tokenizer.nextLine();
    921 //        System.out.println(tokens.get(0)); // prints 'text'
    922 //        System.out.println(tokens.get(1)); // prints 'text with, comma'
    923 //        System.out.println(tokens.get(2)); // prints ''
    924 //        System.out.println(tokens.get(3)); // prints 'another,text'
    925 //      }
    926 //    }
    927 //    catch(Exception ioe)
    928 //    {
    929 //      ioe.printStackTrace();
    930 //    }
    931 //  }
    932 //
    933 //  public static void main(String[] args)
    934 //  {
    935 ////    testLowLevel(args);
    936 ////    testHighLevel(args);
    937 ////    testGeonetUTF8(args);
    938 //    testHighLevelExample();
    939 //  }
    940803}
    941 
    942 
Note: See TracChangeset for help on using the changeset viewer.