1 // -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the GNU General Public License v3+, or later.
7 // See license.mkd for licensing and copyright information.
8 // ---------------------------------------------------------------------------
10 package cc
.squirreljme
.jvm
.manifest
;
12 import cc
.squirreljme
.runtime
.cldc
.annotation
.Exported
;
15 * This represents a key which is used in a manifest, it is case insensitive
16 * when it comes to ASCII values.
21 public final class JavaManifestKey
23 /** The used string. */
25 protected final String string
;
27 /** The actual input string. */
29 protected final String inputString
;
32 * Initializes the manifest key using the given string.
34 * @param __s The string to use for the manifest key.
35 * @throws NullPointerException On null arguments.
39 public JavaManifestKey(String __s
)
40 throws NullPointerException
44 throw new NullPointerException("NARG");
46 // Lower-case all letters
47 StringBuilder sb
= new StringBuilder();
48 for (int i
= 0, n
= __s
.length(); i
< n
; i
++)
49 sb
.append(JavaManifestKey
.__toLower(__s
.charAt(i
)));
50 this.string
= sb
.toString();
52 // Remember input string for case purposes
53 this.inputString
= __s
;
61 public boolean equals(Object __o
)
64 if (__o
instanceof JavaManifestKey
)
65 return this.__equals(((JavaManifestKey
)__o
).string
);
76 return this.string
.hashCode();
80 * Returns the input string which was passed to this key, this string
81 * cannot be used for comparative purposes and it intended to be used
82 * for case matching in the output manifest.
84 * @return The input string.
88 public String
inputString()
90 return this.inputString
;
98 public String
toString()
104 * Compares two strings checking for case insensitivity in the basic
107 * @param __b The other string to compare against.
108 * @return {@code true} if the strings are equal.
109 * @throws NullPointerException On null arguments.
112 private boolean __equals(String __b
)
113 throws NullPointerException
117 throw new NullPointerException("NARG");
120 String a
= this.string
;
126 // Would not be equal
131 for (int i
= 0; i
< na
; i
++)
132 if (JavaManifestKey
.__toLower(a
.charAt(i
)) != JavaManifestKey
133 .__toLower(__b
.charAt(i
)))
141 * Converts the specified character to lower case.
143 * @param __c The character to lower case.
144 * @return The lowercased character or {@code __c} if it cannot be
148 private static char __toLower(char __c
)
150 if (__c
>= 'A' && __c
<= 'Z')
151 return (char)('a' + (__c
- 'A'));