Java PrimerMethod Properties in Java

Listing 8. The "Name contextName()" method of AbstractName.


/**
 * Return context name of Name object.
 * @methodtype get
 */
public Name contextName() throws InvalidIndexException {
	int nc= noComponents()-1;
[1]	assertIsValidIndex(nc);

	if (nc == 0) {
[2]		return newName("");

	}

	StringBuffer sb= new StringBuffer();
	for (int i= 0; i < nc; i++) { 
[3]		sb.append(basicComponent(i));
[4]		sb.append(delimiterChar());

	}
	sb.setLength(sb.length()-1);
[5]	return newName(sb.toString());
}

Upcoming Training Events

0 AM
Visual Studio Live! San Diego
September 8-12, 2025
Live! 360 Orlando
November 16-21, 2025
Cloud & Containers Live! Orlando
November 16-21, 2025
Data Platform Live! Orlando
November 16-21, 2025
Visual Studio Live! Orlando
November 16-21, 2025