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
;
13 * This represents a key which is used in a manifest, it is case insensitive
14 * when it comes to ASCII values.
18 public final class JavaManifestKey
20 /** The used string. */
21 protected final String string
;
23 /** The actual input string. */
24 protected final String inputString
;
27 * Initializes the manifest key using the given string.
29 * @param __s The string to use for the manifest key.
30 * @throws NullPointerException On null arguments.
33 public JavaManifestKey(String __s
)
34 throws NullPointerException
38 throw new NullPointerException("NARG");
40 // Lower-case all letters
41 StringBuilder sb
= new StringBuilder();
42 for (int i
= 0, n
= __s
.length(); i
< n
; i
++)
43 sb
.append(JavaManifestKey
.__toLower(__s
.charAt(i
)));
44 this.string
= sb
.toString();
46 // Remember input string for case purposes
47 this.inputString
= __s
;
55 public boolean equals(Object __o
)
58 if (__o
instanceof JavaManifestKey
)
59 return this.__equals(((JavaManifestKey
)__o
).string
);
70 return this.string
.hashCode();
74 * Returns the input string which was passed to this key, this string
75 * cannot be used for comparative purposes and it intended to be used
76 * for case matching in the output manifest.
78 * @return The input string.
81 public String
inputString()
83 return this.inputString
;
91 public String
toString()
97 * Compares two strings checking for case insensitivity in the basic
100 * @param __b The other string to compare against.
101 * @return {@code true} if the strings are equal.
102 * @throws NullPointerException On null arguments.
105 private boolean __equals(String __b
)
106 throws NullPointerException
110 throw new NullPointerException("NARG");
113 String a
= this.string
;
119 // Would not be equal
124 for (int i
= 0; i
< na
; i
++)
125 if (JavaManifestKey
.__toLower(a
.charAt(i
)) != JavaManifestKey
126 .__toLower(__b
.charAt(i
)))
134 * Converts the specified character to lower case.
136 * @param __c The character to lower case.
137 * @return The lowercased character or {@code __c} if it cannot be
141 private static char __toLower(char __c
)
143 if (__c
>= 'A' && __c
<= 'Z')
144 return (char)('a' + (__c
- 'A'));