
public final class JavaIdentifier extends Object implements CharSequence, Serializable
This class provides support for parsing and normalizing text to java identifiers as specified in the Java Language Specification - Java SE 7 Edition - Chapter 3.8ff.
normalize(java.lang.String, org.jomc.model.JavaIdentifier.NormalizationMode),
parse(java.lang.String),
valueOf(java.lang.String),
Serialized Form| Modifier and Type | Class and Description |
|---|---|
static class |
JavaIdentifier.NormalizationMode
Normalization modes.
|
| Modifier and Type | Method and Description |
|---|---|
char |
charAt(int index)
Returns the
char value at a given index. |
boolean |
equals(Object o)
Tests whether some other object is equal to the object.
|
int |
hashCode()
Returns the hash-code value of the object.
|
int |
length()
Returns the length of this character sequence.
|
static JavaIdentifier |
normalize(String text,
JavaIdentifier.NormalizationMode mode)
Normalizes text from the beginning of the given string to produce a
JavaIdentifier. |
static JavaIdentifier |
parse(String text)
Parses text from the beginning of a given string to produce a
JavaIdentifier instance. |
CharSequence |
subSequence(int start,
int end)
Returns a new
CharSequence that is a subsequence of this sequence. |
String |
toString()
Returns a string containing the characters in this sequence in the same order as this sequence.
|
static JavaIdentifier |
valueOf(String text)
Parses text from the beginning of a given string to produce a
JavaIdentifier instance. |
public int length()
length in interface CharSequencechars in this sequence.public char charAt(int index)
char value at a given index.charAt in interface CharSequenceindex - The index of the char value to return.char value at index.IndexOutOfBoundsException - if index is negative or not less than the length of the sequence.public CharSequence subSequence(int start, int end)
CharSequence that is a subsequence of this sequence.subSequence in interface CharSequencestart - The start index, inclusive.end - The end index, exclusive.start up to index end - 1.IndexOutOfBoundsException - if start or end are negative, if end is greater than
the length of the sequence, or if start is greater than end.public String toString()
toString in interface CharSequencetoString in class Objectpublic int hashCode()
public static JavaIdentifier normalize(String text, JavaIdentifier.NormalizationMode mode) throws ParseException
JavaIdentifier.text - The text to normalize.mode - The normalization to apply.JavaIdentifier instance constructed by normalizing text according to mode.NullPointerException - if text or mode is null.ParseException - if normalization fails.public static JavaIdentifier parse(String text) throws ParseException
JavaIdentifier instance.text - The text to parse.JavaIdentifier instance constructed by parsing text.NullPointerException - if text is null.ParseException - if parsing fails.valueOf(java.lang.String)public static JavaIdentifier valueOf(String text) throws IllegalArgumentException
JavaIdentifier instance.
Unlike the parse(String) method, this method throws an IllegalArgumentException if parsing
fails.
text - The text to parse.JavaIdentifier instance constructed by parsing text.NullPointerException - if text is null.IllegalArgumentException - if parsing fails.parse(java.lang.String)Copyright © 2005–2014 The JOMC Project. All rights reserved.