jdk/src/share/classes/javax/management/loading/MLetParser.java
author rriggs
Tue, 12 Nov 2013 14:03:28 -0500
changeset 21656 d4c777ccb1db
parent 5506 202f599c92aa
child 23010 6dadb192ad81
permissions -rw-r--r--
8028014: Doclint warning/error cleanup in javax.management Summary: Improve generated html by fixing doclint warnings Reviewed-by: sla, jbachorik
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
     2
 * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package javax.management.loading;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import static com.sun.jmx.defaults.JmxProperties.MLET_LOGGER;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.io.BufferedReader;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.io.File;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.io.InputStreamReader;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.io.Reader;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.net.URL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.net.URLConnection;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.util.ArrayList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.util.HashMap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import java.util.List;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import java.util.Map;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import java.util.logging.Level;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * This class is used for parsing URLs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
class MLetParser {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
  * ------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
  *   PRIVATE VARIABLES
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
  * ------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     * The current character
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    private int c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * Tag to parse.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    private static String tag = "mlet";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
  /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
  * ------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
  *   CONSTRUCTORS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
  * ------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * Create an MLet parser object
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    public MLetParser() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * ------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     *   PUBLIC METHODS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * ------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * Scan spaces.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    public void skipSpace(Reader in) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        while ((c >= 0) && ((c == ' ') || (c == '\t') || (c == '\n') || (c == '\r'))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
            c = in.read();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * Scan identifier
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    public String scanIdentifier(Reader in) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        StringBuilder buf = new StringBuilder();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        while (true) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
            if (((c >= 'a') && (c <= 'z')) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
                ((c >= 'A') && (c <= 'Z')) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
                ((c >= '0') && (c <= '9')) || (c == '_')) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
                buf.append((char)c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
                c = in.read();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
                return buf.toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * Scan tag
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    public Map<String,String> scanTag(Reader in) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        Map<String,String> atts = new HashMap<String,String>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        skipSpace(in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        while (c >= 0 && c != '>') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
            if (c == '<')
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
                throw new IOException("Missing '>' in tag");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
            String att = scanIdentifier(in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
            String val = "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
            skipSpace(in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
            if (c == '=') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
                int quote = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
                c = in.read();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
                skipSpace(in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
                if ((c == '\'') || (c == '\"')) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
                    quote = c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
                    c = in.read();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
                StringBuilder buf = new StringBuilder();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
                while ((c > 0) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
                       (((quote < 0) && (c != ' ') && (c != '\t') &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                         (c != '\n') && (c != '\r') && (c != '>'))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
                        || ((quote >= 0) && (c != quote)))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
                    buf.append((char)c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
                    c = in.read();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
                if (c == quote) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
                    c = in.read();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
                skipSpace(in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
                val = buf.toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
            atts.put(att.toLowerCase(), val);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
            skipSpace(in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        return atts;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    /**
21656
d4c777ccb1db 8028014: Doclint warning/error cleanup in javax.management
rriggs
parents: 5506
diff changeset
   152
     * Scan an html file for {@literal <mlet>} tags.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    public List<MLetContent> parse(URL url) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        String mth = "parse";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        // Warning Messages
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        String requiresTypeWarning = "<arg type=... value=...> tag requires type parameter.";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        String requiresValueWarning = "<arg type=... value=...> tag requires value parameter.";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        String paramOutsideWarning = "<arg> tag outside <mlet> ... </mlet>.";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        String requiresCodeWarning = "<mlet> tag requires either code or object parameter.";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        String requiresJarsWarning = "<mlet> tag requires archive parameter.";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        URLConnection conn;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        conn = url.openConnection();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        Reader in = new BufferedReader(new InputStreamReader(conn.getInputStream(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
                                                             "UTF-8"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        // The original URL may have been redirected - this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        // sets it to whatever URL/codebase we ended up getting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        url = conn.getURL();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        List<MLetContent> mlets = new ArrayList<MLetContent>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        Map<String,String> atts = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        List<String> types = new ArrayList<String>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        List<String> values = new ArrayList<String>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        // debug("parse","*** Parsing " + url );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        while(true) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
            c = in.read();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
            if (c == -1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
            if (c == '<') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
                c = in.read();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
                if (c == '/') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
                    c = in.read();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
                    String nm = scanIdentifier(in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
                    if (c != '>')
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
                        throw new IOException("Missing '>' in tag");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
                    if (nm.equalsIgnoreCase(tag)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
                        if (atts != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                            mlets.add(new MLetContent(url, atts, types, values));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
                        atts = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                        types = new ArrayList<String>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                        values = new ArrayList<String>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
                    String nm = scanIdentifier(in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
                    if (nm.equalsIgnoreCase("arg")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
                        Map<String,String> t = scanTag(in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
                        String att = t.get("type");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
                        if (att == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
                            MLET_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
                                    MLetParser.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
                                    mth, requiresTypeWarning);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
                            throw new IOException(requiresTypeWarning);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
                        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
                            if (atts != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
                                types.add(att);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
                            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
                                MLET_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
                                        MLetParser.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
                                        mth, paramOutsideWarning);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
                                throw new IOException(paramOutsideWarning);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
                        String val = t.get("value");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
                        if (val == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
                            MLET_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
                                    MLetParser.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
                                    mth, requiresValueWarning);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                            throw new IOException(requiresValueWarning);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
                        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
                            if (atts != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
                                values.add(val);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
                            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
                                MLET_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
                                        MLetParser.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
                                        mth, paramOutsideWarning);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
                                throw new IOException(paramOutsideWarning);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
                        if (nm.equalsIgnoreCase(tag)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
                            atts = scanTag(in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
                            if (atts.get("code") == null && atts.get("object") == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
                                MLET_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
                                        MLetParser.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
                                        mth, requiresCodeWarning);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
                                throw new IOException(requiresCodeWarning);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
                            if (atts.get("archive") == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
                                MLET_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
                                        MLetParser.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
                                        mth, requiresJarsWarning);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
                                throw new IOException(requiresJarsWarning);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        in.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        return mlets;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     * Parse the document pointed by the URL urlname
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    public List<MLetContent> parseURL(String urlname) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
        // Parse the document
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        //
526
61ba2d5ea9da 6701459: Synchronization bug pattern found in javax.management.relation.RelationService
emcmanus
parents: 2
diff changeset
   266
        URL url;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        if (urlname.indexOf(':') <= 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
            String userDir = System.getProperty("user.dir");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
            String prot;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
            if (userDir.charAt(0) == '/' ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
                userDir.charAt(0) == File.separatorChar) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
                prot = "file:";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
                prot = "file:/";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
            url =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
                new URL(prot + userDir.replace(File.separatorChar, '/') + "/");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
            url = new URL(url, urlname);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
            url = new URL(urlname);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        // Return list of parsed MLets
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        return parse(url);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
}