Changeset 30646 in osm for applications/editors/josm/plugins/surveyor/src/org
- Timestamp:
- 2014-09-15T22:10:28+02:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/surveyor/src/org/dinopolis/util/io/Tokenizer.java
r26509 r30646 801 801 return(new_list); 802 802 } 803 804 // /**805 // * Demonstrates the low level interface.806 // * @param args command line arguments.807 // */808 // protected static void testLowLevel(String[] args)809 // {810 // try811 // {812 // String filename;813 // if(args.length > 0)814 // filename = args[0];815 // else816 // 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 // try862 // {863 // String filename;864 // if(args.length > 0)865 // filename = args[0];866 // else867 // 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 // try898 // {899 // // simple example, tokenizing string, no escape, but quoted900 // // 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 and915 // // 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 // }940 803 } 941 942
Note:
See TracChangeset
for help on using the changeset viewer.