src/share/classes/com/sun/tools/javac/parser/DocCommentScanner.java

changeset 695
3c9b64e55c5d
parent 581
f2fdd52e4e87
equal deleted inserted replaced
694:f6fe12839a8a 695:3c9b64e55c5d
1 /* 1 /*
2 * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this 7 * published by the Free Software Foundation. Oracle designates this
40 * This code and its internal interfaces are subject to change or 40 * This code and its internal interfaces are subject to change or
41 * deletion without notice.</b> 41 * deletion without notice.</b>
42 */ 42 */
43 public class DocCommentScanner extends Scanner { 43 public class DocCommentScanner extends Scanner {
44 44
45 /** A factory for creating scanners. */
46 public static class Factory extends Scanner.Factory {
47
48 public static void preRegister(final Context context) {
49 context.put(scannerFactoryKey, new Context.Factory<Scanner.Factory>() {
50 public Factory make() {
51 return new Factory(context);
52 }
53 });
54 }
55
56 /** Create a new scanner factory. */
57 protected Factory(Context context) {
58 super(context);
59 }
60
61 @Override
62 public Scanner newScanner(CharSequence input) {
63 if (input instanceof CharBuffer) {
64 return new DocCommentScanner(this, (CharBuffer)input);
65 } else {
66 char[] array = input.toString().toCharArray();
67 return newScanner(array, array.length);
68 }
69 }
70
71 @Override
72 public Scanner newScanner(char[] input, int inputLength) {
73 return new DocCommentScanner(this, input, inputLength);
74 }
75 }
76
77
78 /** Create a scanner from the input buffer. buffer must implement 45 /** Create a scanner from the input buffer. buffer must implement
79 * array() and compact(), and remaining() must be less than limit(). 46 * array() and compact(), and remaining() must be less than limit().
80 */ 47 */
81 protected DocCommentScanner(Factory fac, CharBuffer buffer) { 48 protected DocCommentScanner(ScannerFactory fac, CharBuffer buffer) {
82 super(fac, buffer); 49 super(fac, buffer);
83 } 50 }
84 51
85 /** Create a scanner from the input array. The array must have at 52 /** Create a scanner from the input array. The array must have at
86 * least a single character of extra space. 53 * least a single character of extra space.
87 */ 54 */
88 protected DocCommentScanner(Factory fac, char[] input, int inputLength) { 55 protected DocCommentScanner(ScannerFactory fac, char[] input, int inputLength) {
89 super(fac, input, inputLength); 56 super(fac, input, inputLength);
90 } 57 }
91 58
92 /** Starting position of the comment in original source 59 /** Starting position of the comment in original source
93 */ 60 */

mercurial