55 } |
55 } |
56 |
56 |
57 final Log log; |
57 final Log log; |
58 final Names names; |
58 final Names names; |
59 final Source source; |
59 final Source source; |
60 final Keywords keywords; |
60 final Tokens tokens; |
61 |
61 |
62 /** Create a new scanner factory. */ |
62 /** Create a new scanner factory. */ |
63 protected ScannerFactory(Context context) { |
63 protected ScannerFactory(Context context) { |
64 context.put(scannerFactoryKey, this); |
64 context.put(scannerFactoryKey, this); |
65 this.log = Log.instance(context); |
65 this.log = Log.instance(context); |
66 this.names = Names.instance(context); |
66 this.names = Names.instance(context); |
67 this.source = Source.instance(context); |
67 this.source = Source.instance(context); |
68 this.keywords = Keywords.instance(context); |
68 this.tokens = Tokens.instance(context); |
69 } |
69 } |
70 |
70 |
71 public Scanner newScanner(CharSequence input, boolean keepDocComments) { |
71 public Scanner newScanner(CharSequence input, boolean keepDocComments) { |
72 if (input instanceof CharBuffer) { |
72 if (input instanceof CharBuffer) { |
73 CharBuffer buf = (CharBuffer) input; |
73 CharBuffer buf = (CharBuffer) input; |
74 if (keepDocComments) |
74 if (keepDocComments) |
75 return new DocCommentScanner(this, buf); |
75 return new Scanner(this, new JavadocTokenizer(this, buf)); |
76 else |
76 else |
77 return new Scanner(this, buf); |
77 return new Scanner(this, buf); |
78 } else { |
78 } else { |
79 char[] array = input.toString().toCharArray(); |
79 char[] array = input.toString().toCharArray(); |
80 return newScanner(array, array.length, keepDocComments); |
80 return newScanner(array, array.length, keepDocComments); |
81 } |
81 } |
82 } |
82 } |
83 |
83 |
84 public Scanner newScanner(char[] input, int inputLength, boolean keepDocComments) { |
84 public Scanner newScanner(char[] input, int inputLength, boolean keepDocComments) { |
85 if (keepDocComments) |
85 if (keepDocComments) |
86 return new DocCommentScanner(this, input, inputLength); |
86 return new Scanner(this, new JavadocTokenizer(this, input, inputLength)); |
87 else |
87 else |
88 return new Scanner(this, input, inputLength); |
88 return new Scanner(this, input, inputLength); |
89 } |
89 } |
90 } |
90 } |