1 37 package org.ungoverned.oscar.ldap; 38 39 import java.io.IOException ; 40 import java.io.Reader ; 41 42 public class LdapLexer { 43 44 static final int EOF = -1; 45 static final int NOCHAR = 0; 47 public static final String WHITESPACE = " \t\n\r"; 48 49 Reader reader = null; 50 51 int nextChar = NOCHAR; 53 public LdapLexer() {} 54 55 public LdapLexer(Reader r) 56 { 57 setReader(r); 58 charno = 1; 59 } 60 61 public void setReader(Reader r) 62 { 63 reader = r; 64 } 65 66 70 71 public int get() throws IOException { 73 if(nextChar == NOCHAR) return readChar(); 74 int c = nextChar; 75 nextChar = NOCHAR; 76 return c; 77 } 78 79 public int peek() throws IOException 80 { 81 if(nextChar == NOCHAR) { 82 nextChar = readChar(); 83 } 84 return nextChar; 85 } 86 87 void skipwhitespace() throws IOException 88 { 89 while(WHITESPACE.indexOf(peek()) >= 0) get(); 90 } 91 92 public int getnw() throws IOException { skipwhitespace(); 95 return get(); 96 } 97 98 public int peeknw() throws IOException { skipwhitespace(); 101 return peek(); 102 } 103 104 106 108 int charno; 110 public int charno() {return charno;} 111 112 int readChar() throws IOException 113 { 114 charno++; 115 return reader.read(); 116 } 117 118 } 119 | Popular Tags |