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
.suite
;
12 import cc
.squirreljme
.runtime
.cldc
.util
.StringUtils
;
15 * This represents the name of an API.
19 public final class APIName
20 implements Comparable
<APIName
>
22 /** The name of the API. */
23 protected final String string
;
26 * Initializes the API name from the given string.
28 * @param __n The name of the API.
29 * @throws InvalidSuiteException If the suite is not valid.
30 * @throws NullPointerException On null arguments.
33 public APIName(String __n
)
34 throws InvalidSuiteException
, NullPointerException
37 throw new NullPointerException("NARG");
39 // Force all APIs to be uppercase
40 __n
= StringUtils
.toUpperCaseNoLocale(__n
);
42 // {@squirreljme.error DG01 An illegal character was
43 // specified in the API name. (The API name)}
44 if (StringUtils
.firstIndex("\0\r\n:;", __n
) >= 0)
45 throw new InvalidSuiteException(String
.format("DG01 %s", __n
));
47 // {@squirreljme.error DG02 API name cannot be blank.}
48 if (__n
.length() <= 0)
49 throw new InvalidSuiteException("DG02");
59 public int compareTo(APIName __o
)
61 return this.string
.compareTo(__o
.string
);
69 public boolean equals(Object __o
)
74 if (!(__o
instanceof APIName
))
77 return this.string
.equals(((APIName
)__o
).string
);
87 return this.string
.hashCode();
95 public String
toString()