public boolean setName(int ordinal, String name) throws IndexOutOfBoundsException {

		StackComponentWrapper comp = getComponent(ordinal);
		String fieldName = comp.getFieldName();

		if (name != null) {
			name = name.trim();
			if (name.length() == 0 || isDefaultName(name)) {
				name = null;
			}
		}

		if (SystemUtilities.isEqual(name, fieldName)) {
			return false;
		}

		if (!canDefineComponent(comp.getDataType(), comp.getLength(), name, comp.getComment())) {
			// NOTE: It is unclear if we should clear component here if it previously existed
			clearComponent(ordinal);
		}
		else if (comp.isUndefined()) {
			comp = replace(comp.getOrdinal(), DataType.DEFAULT, 1, name, null);
		}
		else {
			try {
				comp.dtc.setFieldName(name);
			}
			catch (DuplicateNameException e) {
				// FIXME: Inconsistent API / how should names be validated and on which methods?
				return false;
			}
		}
		return true;
	}
Sets the name of the component at the specified ordinal.

@param ordinal the ordinal
@param name the new name. Null indicates the default name.
@return true if name change was successful, else false
@throws IndexOutOfBoundsException if specified ordinal is out of range
@throws IllegalArgumentException if name is invalid
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/stackeditor/StackFrameDataType.java