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

changeset 695
3c9b64e55c5d
parent 674
584365f256a7
child 752
03177f49411d
     1.1 --- a/src/share/classes/com/sun/tools/javac/parser/Scanner.java	Mon Sep 27 14:05:33 2010 -0700
     1.2 +++ b/src/share/classes/com/sun/tools/javac/parser/Scanner.java	Mon Sep 27 14:20:39 2010 -0700
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -47,48 +47,6 @@
    1.11  
    1.12      private static boolean scannerDebug = false;
    1.13  
    1.14 -    /** A factory for creating scanners. */
    1.15 -    public static class Factory {
    1.16 -        /** The context key for the scanner factory. */
    1.17 -        public static final Context.Key<Scanner.Factory> scannerFactoryKey =
    1.18 -            new Context.Key<Scanner.Factory>();
    1.19 -
    1.20 -        /** Get the Factory instance for this context. */
    1.21 -        public static Factory instance(Context context) {
    1.22 -            Factory instance = context.get(scannerFactoryKey);
    1.23 -            if (instance == null)
    1.24 -                instance = new Factory(context);
    1.25 -            return instance;
    1.26 -        }
    1.27 -
    1.28 -        final Log log;
    1.29 -        final Names names;
    1.30 -        final Source source;
    1.31 -        final Keywords keywords;
    1.32 -
    1.33 -        /** Create a new scanner factory. */
    1.34 -        protected Factory(Context context) {
    1.35 -            context.put(scannerFactoryKey, this);
    1.36 -            this.log = Log.instance(context);
    1.37 -            this.names = Names.instance(context);
    1.38 -            this.source = Source.instance(context);
    1.39 -            this.keywords = Keywords.instance(context);
    1.40 -        }
    1.41 -
    1.42 -        public Scanner newScanner(CharSequence input) {
    1.43 -            if (input instanceof CharBuffer) {
    1.44 -                return new Scanner(this, (CharBuffer)input);
    1.45 -            } else {
    1.46 -                char[] array = input.toString().toCharArray();
    1.47 -                return newScanner(array, array.length);
    1.48 -            }
    1.49 -        }
    1.50 -
    1.51 -        public Scanner newScanner(char[] input, int inputLength) {
    1.52 -            return new Scanner(this, input, inputLength);
    1.53 -        }
    1.54 -    }
    1.55 -
    1.56      /* Output variables; set by nextToken():
    1.57       */
    1.58  
    1.59 @@ -177,7 +135,7 @@
    1.60      private final Keywords keywords;
    1.61  
    1.62      /** Common code for constructors. */
    1.63 -    private Scanner(Factory fac) {
    1.64 +    private Scanner(ScannerFactory fac) {
    1.65          log = fac.log;
    1.66          names = fac.names;
    1.67          keywords = fac.keywords;
    1.68 @@ -201,7 +159,7 @@
    1.69      /** Create a scanner from the input buffer.  buffer must implement
    1.70       *  array() and compact(), and remaining() must be less than limit().
    1.71       */
    1.72 -    protected Scanner(Factory fac, CharBuffer buffer) {
    1.73 +    protected Scanner(ScannerFactory fac, CharBuffer buffer) {
    1.74          this(fac, JavacFileManager.toArray(buffer), buffer.limit());
    1.75      }
    1.76  
    1.77 @@ -216,7 +174,7 @@
    1.78       * @param inputLength the size of the input.
    1.79       * Must be positive and less than or equal to input.length.
    1.80       */
    1.81 -    protected Scanner(Factory fac, char[] input, int inputLength) {
    1.82 +    protected Scanner(ScannerFactory fac, char[] input, int inputLength) {
    1.83          this(fac);
    1.84          eofPos = inputLength;
    1.85          if (inputLength == input.length) {

mercurial