@Override public String[] unparse(LoadContext context, LoadInfo info) { String formula = info.getLoadModifierFormula(); if (formula == null) { return null; } return new String[] {formula}; }
@Override protected ParseResult parseTokenWithSeparator(LoadContext context, LoadInfo info, String value) { int pipeLoc = value.indexOf('|'); if (pipeLoc == -1) { return new ParseResult.Fail(getTokenName() + " requires a pipe, found : " + value, context); } if (pipeLoc != value.lastIndexOf('|')) { return new ParseResult.Fail( getTokenName() + " requires only one pipe, found : " + value, context); } String sizeName = value.substring(0, pipeLoc); String multiplierString = value.substring(pipeLoc + 1); CDOMSingleRef<SizeAdjustment> size = context.getReferenceContext().getCDOMReference(SizeAdjustment.class, sizeName); /* * TODO Any way to handle the situation of the sizeName being * misspelled, etc? (old system did just first character) */ try { BigDecimal multiplier = new BigDecimal(multiplierString); if (multiplier.compareTo(BigDecimal.ZERO) <= 0) { return new ParseResult.Fail( getTokenName() + " requires a positive multiplier : " + multiplierString + " in value: " + value, context); } info.addSizeAdjustment(size, multiplier); } catch (NumberFormatException nfe) { return new ParseResult.Fail( getTokenName() + " misunderstood multiplier : " + multiplierString + " in value: " + value, context); } return ParseResult.SUCCESS; }
@Override protected ParseResult parseNonEmptyToken(LoadContext context, LoadInfo info, String value) { info.setLoadModifierFormula(value); return ParseResult.SUCCESS; }
@Override public boolean process(LoadContext context, LoadInfo info) { info.resolveSizeAdjustmentMap(); return true; }