MCPcopy Create free account
hub / github.com/PCGen/pcgen / createNameForAutoResize

Method createNameForAutoResize

code/src/java/pcgen/core/Equipment.java:4766–4794  ·  view source on GitHub ↗

Create a Name for the new custom piece of resized equipment. The name will be constructed by searching for the size of the equipment in its name. If found (and surrounded by '(', '/', or ')', it will be replaced. If not found, it will be added to the end surrounded by parenthesis. @param newSize

(SizeAdjustment newSize)

Source from the content-addressed store, hash-verified

4764 */
4765
4766 public String createNameForAutoResize(SizeAdjustment newSize)
4767 {
4768 // Make sure newSize is not null
4769 if (newSize == null)
4770 {
4771 return getName();
4772 }
4773
4774 String displayName = newSize.getDisplayName();
4775 String thisName = getName();
4776 String upName = thisName.toUpperCase();
4777
4778 String upThisSize = getSizeAdjustment().getDisplayName().toUpperCase();
4779
4780 int start = upName.indexOf(upThisSize);
4781 int end = start + upThisSize.length();
4782
4783 /*
4784 * if the name contains thisSize surrounded by /, ( or ) then replace
4785 * thisSize with newSize
4786 */
4787 if (start > -1 && (upName.substring(start - 1).startsWith("(") || upName.substring(start - 1).startsWith("/"))
4788 && (upName.substring(end).startsWith(")") || upName.substring(end).startsWith("/")))
4789 {
4790 return thisName.substring(0, start) + displayName + thisName.substring(end);
4791 }
4792
4793 return thisName + " (" + displayName + ")";
4794 }
4795
4796 /**
4797 * Make this item virtual i.e. one that doesn't really exist and is only

Calls 4

getNameMethod · 0.95
getSizeAdjustmentMethod · 0.95
getDisplayNameMethod · 0.65
indexOfMethod · 0.65