src/share/tools/ProjectCreator/MacroDefinitions.java

changeset 2577
5a4223160326
parent 2530
f3e07ceeaed9
parent 2576
76b97f73ee91
child 2578
658d198b2e04
     1.1 --- a/src/share/tools/ProjectCreator/MacroDefinitions.java	Fri Feb 25 11:42:03 2011 -0800
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,154 +0,0 @@
     1.4 -/*
     1.5 - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
     1.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 - *
     1.8 - * This code is free software; you can redistribute it and/or modify it
     1.9 - * under the terms of the GNU General Public License version 2 only, as
    1.10 - * published by the Free Software Foundation.
    1.11 - *
    1.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 - * version 2 for more details (a copy is included in the LICENSE file that
    1.16 - * accompanied this code).
    1.17 - *
    1.18 - * You should have received a copy of the GNU General Public License version
    1.19 - * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 - *
    1.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 - * or visit www.oracle.com if you need additional information or have any
    1.24 - * questions.
    1.25 - *
    1.26 - */
    1.27 -
    1.28 -import java.io.*;
    1.29 -import java.util.*;
    1.30 -
    1.31 -public class MacroDefinitions {
    1.32 -    private Vector macros;
    1.33 -
    1.34 -    public MacroDefinitions() {
    1.35 -        macros = new Vector();
    1.36 -    }
    1.37 -
    1.38 -    public void addMacro(String name, String contents) {
    1.39 -        Macro macro = new Macro();
    1.40 -        macro.name = name;
    1.41 -        macro.contents = contents;
    1.42 -        macros.add(macro);
    1.43 -    }
    1.44 -
    1.45 -    private boolean lineIsEmpty(String s) {
    1.46 -        for (int i = 0; i < s.length(); i++) {
    1.47 -            if (!Character.isWhitespace(s.charAt(i))) {
    1.48 -                return false;
    1.49 -            }
    1.50 -        }
    1.51 -        return true;
    1.52 -    }
    1.53 -
    1.54 -    public void readFrom(String fileName, boolean missingOk)
    1.55 -        throws FileNotFoundException, FileFormatException, IOException {
    1.56 -        BufferedReader reader = null;
    1.57 -        try {
    1.58 -            reader = new BufferedReader(new FileReader(fileName));
    1.59 -        } catch (FileNotFoundException e) {
    1.60 -            if (missingOk) {
    1.61 -                return;
    1.62 -            } else {
    1.63 -                throw(e);
    1.64 -            }
    1.65 -        }
    1.66 -        String line;
    1.67 -        do {
    1.68 -            line = reader.readLine();
    1.69 -            if (line != null) {
    1.70 -                // This had to be rewritten (compare to Database.java)
    1.71 -                // because the Solaris platform file has been
    1.72 -                // repurposed and now contains "macros" with spaces in
    1.73 -                // them.
    1.74 -
    1.75 -                if ((!line.startsWith("//")) &&
    1.76 -                    (!lineIsEmpty(line))) {
    1.77 -                    int nameBegin = -1;
    1.78 -                    int nameEnd = -1;
    1.79 -                    boolean gotEquals = false;
    1.80 -                    int contentsBegin = -1;
    1.81 -                    int contentsEnd = -1;
    1.82 -
    1.83 -                    int i = 0;
    1.84 -                    // Scan forward for beginning of name
    1.85 -                    while (i < line.length()) {
    1.86 -                        if (!Character.isWhitespace(line.charAt(i))) {
    1.87 -                            break;
    1.88 -                        }
    1.89 -                        i++;
    1.90 -                    }
    1.91 -                    nameBegin = i;
    1.92 -
    1.93 -                    // Scan forward for end of name
    1.94 -                    while (i < line.length()) {
    1.95 -                        if (Character.isWhitespace(line.charAt(i))) {
    1.96 -                            break;
    1.97 -                        }
    1.98 -                        i++;
    1.99 -                    }
   1.100 -                    nameEnd = i;
   1.101 -
   1.102 -                    // Scan forward for equals sign
   1.103 -                    while (i < line.length()) {
   1.104 -                        if (line.charAt(i) == '=') {
   1.105 -                            gotEquals = true;
   1.106 -                            break;
   1.107 -                        }
   1.108 -                        i++;
   1.109 -                    }
   1.110 -
   1.111 -                    // Scan forward for start of contents
   1.112 -                    i++;
   1.113 -                    while (i < line.length()) {
   1.114 -                        if (!Character.isWhitespace(line.charAt(i))) {
   1.115 -                            break;
   1.116 -                        }
   1.117 -                        i++;
   1.118 -                    }
   1.119 -                    contentsBegin = i;
   1.120 -
   1.121 -                    // Scan *backward* for end of contents
   1.122 -                    i = line.length() - 1;
   1.123 -                    while (i >= 0) {
   1.124 -                        if (!Character.isWhitespace(line.charAt(i))) {
   1.125 -                            break;
   1.126 -                        }
   1.127 -                    }
   1.128 -                    contentsEnd = i+1;
   1.129 -
   1.130 -                    // Now do consistency check
   1.131 -                    if (!((nameBegin < nameEnd) &&
   1.132 -                          (nameEnd < contentsBegin) &&
   1.133 -                          (contentsBegin < contentsEnd) &&
   1.134 -                          (gotEquals == true))) {
   1.135 -                        throw new FileFormatException(
   1.136 -                            "Expected \"macroname = value\", " +
   1.137 -                            "but found: " + line
   1.138 -                        );
   1.139 -                    }
   1.140 -
   1.141 -                    String name = line.substring(nameBegin, nameEnd);
   1.142 -                    String contents = line.substring(contentsBegin,
   1.143 -                                                     contentsEnd);
   1.144 -                    addMacro(name, contents);
   1.145 -                }
   1.146 -            }
   1.147 -        } while (line != null);
   1.148 -        reader.close();
   1.149 -    }
   1.150 -
   1.151 -    /** This returns an Iterator of Macros. You should not mutate the
   1.152 -        returned Macro objects or use the Iterator to remove
   1.153 -        macros. */
   1.154 -    public Iterator getMacros() {
   1.155 -        return macros.iterator();
   1.156 -    }
   1.157 -}

mercurial