APIdia Launch Partner
Top Description Inners Fields Constructors Methods
com.sun.tools.javac.util

public abstract Class Name

extends Object
implements Name, PoolConstant, Comparable<Name>
Class Inheritance
All Implemented Interfaces
java.lang.Comparable, com.sun.tools.javac.jvm.PoolConstant, javax.lang.model.element.Name, java.lang.CharSequence
Known Direct Subclasses
com.sun.tools.javac.util.StringNameTable.NameImpl, com.sun.tools.javac.util.Utf8NameTable.NameImpl
Imports
com.sun.tools.javac.jvm.ClassFile, .PoolConstant, .PoolReader, com.sun.tools.javac.util.DefinedBy.Api

An abstraction for internal compiler strings.

Names are stored in a Name.Table, and are unique within that table.

This is NOT part of any supported API. If you write code that depends on this, you do so at your own risk. This code and its internal interfaces are subject to change or deletion without notice.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
Name.NameMapper<X>

Maps the Modified UTF-8 encoding of a Name to something.

public abstract static class
Name.Table

An abstraction for the hash table used to create unique Name instances.

Field Summary

Modifier and TypeField and Description
public final Name.Table
table

The Table that contains this instance.

Constructor Summary

AccessConstructor and Description
protected
Name(Name.Table
the Table that will contain this instance
table
)

Constructor.

Method Summary

Modifier and TypeMethod and Description
public Name
append(Name name)

Return the concatenation of this name and the given name.

public Name
append(char c, Name name)

Return the concatenation of this name, the given ASCII character, and the given name.

public char
charAt(int index)

Implements java.lang.CharSequence.charAt.

Returns the char value at the specified index.

public int
compareTo(Name name)

Implements java.lang.Comparable.compareTo.

Order names lexicographically.

public boolean
contentEquals(CharSequence cs)

Implements javax.lang.model.element.Name.contentEquals.

Compares this name to the specified CharSequence.

public final boolean
equals(Object obj)

Overrides java.lang.Object.equals.

Implements javax.lang.model.element.Name.equals.

Returns true if the argument represents the same name as this, and false otherwise.

public abstract void
getUtf8Bytes(byte[] buf, int off)

Write the Modified UTF-8 encoding of this name into the given buffer starting at the specified offset.

public abstract int
getUtf8Length()

Get the length of the Modified UTF-8 encoding of this name.

public abstract int
hashCode()

Redeclares javax.lang.model.element.Name.hashCode.

Overrides java.lang.Object.hashCode.

Obeys the general contract of Object.hashCode.

public boolean
isEmpty()

Overrides default java.lang.CharSequence.isEmpty.

Determine if this is the empty name.

public int
lastIndexOfAscii(char ch)

Returns last occurrence of the given ASCII character in this name, -1 if not found.

public int
length()

Implements java.lang.CharSequence.length.

Returns the length of this character sequence.

public <X> X
map(Name.NameMapper<X> mapper)

Decode this name's Modified UTF-8 encoding into something.

protected abstract boolean
nameEquals(Name that)

Subclass check for equality.

public final int
poolTag()

Implements com.sun.tools.javac.jvm.PoolConstant.poolTag.

The constant pool entry tag.

public boolean
startsWith(Name prefix)

Determine whether this name has the given Name as a prefix.

public Name
subName(int
starting character offset, inclusive
start
,
int
ending character offset, exclusive
end
)

Returns the sub-name extending between two character positions.

public Name
subName(int
starting character offset
off
)

Returns the suffix of this name starting at the given offset.

public CharSequence
subSequence(int start, int end)

Implements java.lang.CharSequence.subSequence.

Returns a CharSequence that is a subsequence of this sequence.

public abstract String
toString()

Redeclares java.lang.CharSequence.toString.

Overrides java.lang.Object.toString.

Returns a string containing the characters in this sequence in the same order as this sequence.

public byte[]
toUtf()

Return the Modified UTF-8 encoding of this name.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

tableback to summary
public final Name.Table table

The Table that contains this instance.

Constructor Detail

Nameback to summary
protected Name(Name.Table table)

Constructor.

Parameters
table:Name.Table

the Table that will contain this instance

Method Detail

appendback to summary
public Name append(Name name)

Return the concatenation of this name and the given name. The given name must come from the same table as this one.

appendback to summary
public Name append(char c, Name name)

Return the concatenation of this name, the given ASCII character, and the given name. The given name must come from the same table as this one.

charAtback to summary
public char charAt(int index)

Implements java.lang.CharSequence.charAt.

Doc from java.lang.CharSequence.charAt.

Returns the char value at the specified index. An index ranges from zero to length() - 1. The first char value of the sequence is at index zero, the next at index one, and so on, as for array indexing.

If the char value specified by the index is a surrogate, the surrogate value is returned.

The implementation in Name invokes Object#toString on this instance and then delegates to String#charAt.

Annotations
@Override
compareToback to summary
public int compareTo(Name name)

Implements java.lang.Comparable.compareTo.

Order names lexicographically.

The ordering defined by this method must match the ordering defined by the corresponding toString() values.

Annotations
@Override
See Also
String#compareTo
contentEqualsback to summary
public boolean contentEquals(CharSequence cs)

Implements javax.lang.model.element.Name.contentEquals.

Doc from javax.lang.model.element.Name.contentEquals.

Compares this name to the specified CharSequence. The result is true if and only if this name represents the same sequence of char values as the specified sequence.

The implementation in Name invokes Object#toString on this instance and then delegates to String#equals.

Annotations
@DefinedBy:LANGUAGE_MODEL
@Override
equalsback to summary
public final boolean equals(Object obj)

Overrides java.lang.Object.equals.

Implements javax.lang.model.element.Name.equals.

Doc from javax.lang.model.element.Name.equals.

Returns true if the argument represents the same name as this, and false otherwise.

Note that the identity of a Name is a function both of its content in terms of a sequence of characters as well as the implementation which created it.

Annotations
@DefinedBy:LANGUAGE_MODEL
@Override
getUtf8Bytesback to summary
public abstract void getUtf8Bytes(byte[] buf, int off)

Write the Modified UTF-8 encoding of this name into the given buffer starting at the specified offset.

getUtf8Lengthback to summary
public abstract int getUtf8Length()

Get the length of the Modified UTF-8 encoding of this name.

hashCodeback to summary
public abstract int hashCode()

Redeclares javax.lang.model.element.Name.hashCode.

Overrides java.lang.Object.hashCode.

Doc from javax.lang.model.element.Name.hashCode.

Obeys the general contract of Object.hashCode.

Annotations
@DefinedBy:LANGUAGE_MODEL
@Override
isEmptyback to summary
public boolean isEmpty()

Overrides default java.lang.CharSequence.isEmpty.

Determine if this is the empty name.

The implementation in Name compares length() to zero.

lastIndexOfAsciiback to summary
public int lastIndexOfAscii(char ch)

Returns last occurrence of the given ASCII character in this name, -1 if not found.

The implementation in Name converts this instance to String and then delegates to String#lastIndexOf(int).

lengthback to summary
public int length()

Implements java.lang.CharSequence.length.

Doc from java.lang.CharSequence.length.

Returns the length of this character sequence. The length is the number of 16-bit chars in the sequence.

Annotations
@Override
mapback to summary
public <X> X map(Name.NameMapper<X> mapper)

Decode this name's Modified UTF-8 encoding into something.

nameEqualsback to summary
protected abstract boolean nameEquals(Name that)

Subclass check for equality.

This method can assume that the given instance is the same type as this instance and is associated to the same Table.

poolTagback to summary
public final int poolTag()

Implements com.sun.tools.javac.jvm.PoolConstant.poolTag.

Doc from com.sun.tools.javac.jvm.PoolConstant.poolTag.

The constant pool entry tag.

Annotations
@Override
startsWithback to summary
public boolean startsWith(Name prefix)

Determine whether this name has the given Name as a prefix.

The implementation in Name converts this and the given instance to String and then delegates to String#startsWith.

subNameback to summary
public Name subName(int start, int end)

Returns the sub-name extending between two character positions.

The implementation in Name converts this instance to String, delegates to String#substring(int, int) and then Table#fromString.

Parameters
start:int

starting character offset, inclusive

end:int

ending character offset, exclusive

Exceptions
IndexOutOfBoundsException:
if bounds are out of range or invalid
subNameback to summary
public Name subName(int off)

Returns the suffix of this name starting at the given offset.

The implementation in Name converts this instance to String, delegates to String#substring(int), and then to Table#fromString.

Parameters
off:int

starting character offset

Exceptions
IndexOutOfBoundsException:
if off is out of range or invalid
subSequenceback to summary
public CharSequence subSequence(int start, int end)

Implements java.lang.CharSequence.subSequence.

Doc from java.lang.CharSequence.subSequence.

Returns a CharSequence that is a subsequence of this sequence. The subsequence starts with the char value at the specified index and ends with the char value at index end - 1. The length (in chars) of the returned sequence is end - start, so if start == end then an empty sequence is returned.

The implementation in Name invokes Object#toString on this instance and then delegates to String#subSequence.

Annotations
@Override
toStringback to summary
public abstract String toString()

Redeclares java.lang.CharSequence.toString.

Overrides java.lang.Object.toString.

Doc from java.lang.CharSequence.toString.

Returns a string containing the characters in this sequence in the same order as this sequence. The length of the string will be the length of this sequence.

Annotations
@Override
toUtfback to summary
public byte[] toUtf()

Return the Modified UTF-8 encoding of this name.

The implementation in Name populates a new byte array of length getUtf8Length with data from getUtf8Bytes.

com.sun.tools.javac.util back to summary

public Interface Name.NameMapper<X>

Annotations
@FunctionalInterface

Maps the Modified UTF-8 encoding of a Name to something.

Method Summary

Modifier and TypeMethod and Description
public X
map(byte[] bytes, int offset, int len)

Method Detail

mapback to summary
public X map(byte[] bytes, int offset, int len)
com.sun.tools.javac.util back to summary

public abstract Class Name.Table

extends Object
Class Inheritance
Known Direct Subclasses
com.sun.tools.javac.util.StringNameTable, com.sun.tools.javac.util.Utf8NameTable

An abstraction for the hash table used to create unique Name instances.

Field Summary

Modifier and TypeField and Description
public final Names
names

Standard name table.

Constructor Summary

AccessConstructor and Description
protected
Table(Names names)

Method Summary

Modifier and TypeMethod and Description
public abstract void
dispose()

Release any resources used by this table.

public abstract Name

Returns:

the corresponding Name
fromChars
(char[] cs, int
starting offset
off
,
int
number of characters
len
)

Get the unique Name corresponding to the given characters.

public Name
fromString(String
character string
s
)

Get the unique Name corresponding to the given string.

public Name

Returns:

the corresponding Name
fromUtf
(byte[] cs)

Get the unique Name corresponding to the given Modified UTF-8 encoding.

public abstract Name

Returns:

the corresponding Name
fromUtf
(byte[] cs, int start, int
number of bytes
len
,
Convert.Validation validation)

Get the unique Name corresponding to the given Modified UTF-8 encoding.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

namesback to summary
public final Names names

Standard name table.

Constructor Detail

Tableback to summary
protected Table(Names names)

Method Detail

disposeback to summary
public abstract void dispose()

Release any resources used by this table.

fromCharsback to summary
public abstract Name fromChars(char[] cs, int off, int len)

Get the unique Name corresponding to the given characters.

Parameters
off:int

starting offset

len:int

number of characters

Returns:Name

the corresponding Name

fromStringback to summary
public Name fromString(String s)

Get the unique Name corresponding to the given string.

The implementation in Table delegates to String#toCharArray and then fromChars.

Parameters
s:String

character string

fromUtfback to summary
public Name fromUtf(byte[] cs) throws InvalidUtfException

Get the unique Name corresponding to the given Modified UTF-8 encoding.

The implementation in Table delegates to fromUtf(byte[], int, int).

Returns:Name

the corresponding Name

Exceptions
IllegalArgumentException:
if the data is not valid Modified UTF-8
fromUtfback to summary
public abstract Name fromUtf(byte[] cs, int start, int len, Convert.Validation validation) throws InvalidUtfException

Get the unique Name corresponding to the given Modified UTF-8 encoding.

Parameters
len:int

number of bytes

Returns:Name

the corresponding Name

Exceptions
InvalidUtfException:
if invalid Modified UTF-8 is encountered
IllegalArgumentException:
if the data is not valid Modified UTF-8