1 28 29 package com.caucho.util; 30 31 34 public class CharScanner { 35 private char []delimiters; 36 37 42 public CharScanner(String delimiters) 43 { 44 this.delimiters = delimiters.toCharArray(); 45 } 46 47 54 public char skip(CharCursor cursor) 55 { 56 char ch; 57 char []delim = delimiters; 58 int len = delim.length; 59 60 loop: 61 for (ch = cursor.current(); 62 ch != cursor.DONE; 63 ch = cursor.next()) { 64 for (int i = 0; i < len; i++) { 65 if (delim[i] == ch) 66 continue loop; 67 } 68 return ch; 69 } 70 71 return ch; 72 } 73 74 82 public char scan(CharCursor cursor, CharBuffer buf) 83 { 84 char ch; 85 char []delim = delimiters; 86 int len = delim.length; 87 88 for (ch = cursor.current(); 89 ch != cursor.DONE; 90 ch = cursor.next()) { 91 for (int i = 0; i < len; i++) { 92 if (delim[i] == ch) 93 return ch; 94 } 95 96 buf.append(ch); 97 } 98 99 return ch; 100 } 101 102 109 public char scan(CharCursor cursor) 110 { 111 char ch; 112 char []delim = delimiters; 113 int len = delim.length; 114 115 for (ch = cursor.current(); 116 ch != cursor.DONE; 117 ch = cursor.next()) { 118 for (int i = 0; i < len; i++) { 119 if (delim[i] == ch) 120 return ch; 121 } 122 } 123 124 return ch; 125 } 126 } 127 | Popular Tags |