Java PrimerMethod Properties in Java
- By by Dirk Riehle
- April 18, 2000
Listing 6. The method "void basicComponent(int, String)"
of class StringName.
class StringName extends AbstractName {
/**
* Hold the name in a single string.
*/
public String fName;
...
/**
* Set a name component to a new value.
* @methodtype set
* @methodproperties primitive
*/
protected void basicComponent(int index, String component) {
component= maskString(component); // mask control chars
int startPos= startPosOfComponent(index);
String head= fName.substring(0, startPos);
int endPos= endPosOfComponent(index);
String tail= fName.substring(endPos, fName.length());
fName= head + component + tail; // compose new name
}
...
}