History

My first initial commit with all of mine experimental changes.

Dmitry Kabak (userdima committed 13 years ago

Commit d37b88d1 parent 3f5b46618352 files · +2598093 −-8690Browse files

Showing the changes to java/pkg/javax/management/loading/MLetContent.java (1 of 18352 files). Show all

Unified · Split

java/pkg/javax/management/loading/MLetContent.java+239−0
@@ -0,0 +1,239 @@
1+/*
2+ * Copyright (c) 1999, 2006, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
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
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package javax.management.loading;
27+
28+
29+// java import
30+
31+import java.net.URL;
32+import java.net.MalformedURLException;
33+import java.util.Collections;
34+import java.util.List;
35+import java.util.Map;
36+
37+/**
38+ * This class represents the contents of the <CODE>MLET</CODE> tag.
39+ * It can be consulted by a subclass of {@link MLet} that overrides
40+ * the {@link MLet#check MLet.check} method.
41+ *
42+ * @since 1.6
43+ */
44+public class MLetContent {
45+
46+
47+ /**
48+ * A map of the attributes of the <CODE>MLET</CODE> tag
49+ * and their values.
50+ */
51+ private Map<String,String> attributes;
52+
53+ /**
54+ * An ordered list of the TYPE attributes that appeared in nested
55+ * &lt;PARAM&gt; tags.
56+ */
57+ private List<String> types;
58+
59+ /**
60+ * An ordered list of the VALUE attributes that appeared in nested
61+ * &lt;PARAM&gt; tags.
62+ */
63+ private List<String> values;
64+
65+ /**
66+ * The MLet text file's base URL.
67+ */
68+ private URL documentURL;
69+ /**
70+ * The base URL.
71+ */
72+ private URL baseURL;
73+
74+
75+ /**
76+ * Creates an <CODE>MLet</CODE> instance initialized with attributes read
77+ * from an <CODE>MLET</CODE> tag in an MLet text file.
78+ *
79+ * @param url The URL of the MLet text file containing the
80+ * <CODE>MLET</CODE> tag.
81+ * @param attributes A map of the attributes of the <CODE>MLET</CODE> tag.
82+ * The keys in this map are the attribute names in lowercase, for
83+ * example <code>codebase</code>. The values are the associated attribute
84+ * values.
85+ * @param types A list of the TYPE attributes that appeared in nested
86+ * &lt;PARAM&gt; tags.
87+ * @param values A list of the VALUE attributes that appeared in nested
88+ * &lt;PARAM&gt; tags.
89+ */
90+ public MLetContent(URL url, Map<String,String> attributes,
91+ List<String> types, List<String> values) {
92+ this.documentURL = url;
93+ this.attributes = Collections.unmodifiableMap(attributes);
94+ this.types = Collections.unmodifiableList(types);
95+ this.values = Collections.unmodifiableList(values);
96+
97+ // Initialize baseURL
98+ //
99+ String att = getParameter("codebase");
100+ if (att != null) {
101+ if (!att.endsWith("/")) {
102+ att += "/";
103+ }
104+ try {
105+ baseURL = new URL(documentURL, att);
106+ } catch (MalformedURLException e) {
107+ // OK : Move to next block as baseURL could not be initialized.
108+ }
109+ }
110+ if (baseURL == null) {
111+ String file = documentURL.getFile();
112+ int i = file.lastIndexOf('/');
113+ if (i >= 0 && i < file.length() - 1) {
114+ try {
115+ baseURL = new URL(documentURL, file.substring(0, i + 1));
116+ } catch (MalformedURLException e) {
117+ // OK : Move to next block as baseURL could not be initialized.
118+ }
119+ }
120+ }
121+ if (baseURL == null)
122+ baseURL = documentURL;
123+
124+ }
125+
126+ // GETTERS AND SETTERS
127+ //--------------------
128+
129+ /**
130+ * Gets the attributes of the <CODE>MLET</CODE> tag. The keys in
131+ * the returned map are the attribute names in lowercase, for
132+ * example <code>codebase</code>. The values are the associated
133+ * attribute values.
134+ * @return A map of the attributes of the <CODE>MLET</CODE> tag
135+ * and their values.
136+ */
137+ public Map<String,String> getAttributes() {
138+ return attributes;
139+ }
140+
141+ /**
142+ * Gets the MLet text file's base URL.
143+ * @return The MLet text file's base URL.
144+ */
145+ public URL getDocumentBase() {
146+ return documentURL;
147+ }
148+
149+ /**
150+ * Gets the code base URL.
151+ * @return The code base URL.
152+ */
153+ public URL getCodeBase() {
154+ return baseURL;
155+ }
156+
157+ /**
158+ * Gets the list of <CODE>.jar</CODE> files specified by the <CODE>ARCHIVE</CODE>
159+ * attribute of the <CODE>MLET</CODE> tag.
160+ * @return A comma-separated list of <CODE>.jar</CODE> file names.
161+ */
162+ public String getJarFiles() {
163+ return getParameter("archive");
164+ }
165+
166+ /**
167+ * Gets the value of the <CODE>CODE</CODE>
168+ * attribute of the <CODE>MLET</CODE> tag.
169+ * @return The value of the <CODE>CODE</CODE>
170+ * attribute of the <CODE>MLET</CODE> tag.
171+ */
172+ public String getCode() {
173+ return getParameter("code");
174+ }
175+
176+ /**
177+ * Gets the value of the <CODE>OBJECT</CODE>
178+ * attribute of the <CODE>MLET</CODE> tag.
179+ * @return The value of the <CODE>OBJECT</CODE>
180+ * attribute of the <CODE>MLET</CODE> tag.
181+ */
182+ public String getSerializedObject() {
183+ return getParameter("object");
184+ }
185+
186+ /**
187+ * Gets the value of the <CODE>NAME</CODE>
188+ * attribute of the <CODE>MLET</CODE> tag.
189+ * @return The value of the <CODE>NAME</CODE>
190+ * attribute of the <CODE>MLET</CODE> tag.
191+ */
192+ public String getName() {
193+ return getParameter("name");
194+ }
195+
196+
197+ /**
198+ * Gets the value of the <CODE>VERSION</CODE>
199+ * attribute of the <CODE>MLET</CODE> tag.
200+ * @return The value of the <CODE>VERSION</CODE>
201+ * attribute of the <CODE>MLET</CODE> tag.
202+ */
203+ public String getVersion() {
204+ return getParameter("version");
205+ }
206+
207+ /**
208+ * Gets the list of values of the <code>TYPE</code> attribute in
209+ * each nested &lt;PARAM&gt; tag within the <code>MLET</code>
210+ * tag.
211+ * @return the list of types.
212+ */
213+ public List<String> getParameterTypes() {
214+ return types;
215+ }
216+
217+ /**
218+ * Gets the list of values of the <code>VALUE</code> attribute in
219+ * each nested &lt;PARAM&gt; tag within the <code>MLET</code>
220+ * tag.
221+ * @return the list of values.
222+ */
223+ public List<String> getParameterValues() {
224+ return values;
225+ }
226+
227+ /**
228+ * Gets the value of the specified
229+ * attribute of the <CODE>MLET</CODE> tag.
230+ *
231+ * @param name A string representing the name of the attribute.
232+ * @return The value of the specified
233+ * attribute of the <CODE>MLET</CODE> tag.
234+ */
235+ private String getParameter(String name) {
236+ return attributes.get(name.toLowerCase());
237+ }
238+
239+}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t