/** * Makes a substitution within the working document, replacing the position of the * {@link WorkingDocument} from startIndex to endIndex with the given replacement * {@link CharSequence}. * <p> * The value of {@link #position} is updated to point to the start of the replacement * afterwards. * <p> * The given {@link SourceContext} provides optional contextual information about where * the substitution came from, if required. */ private ErrorToken makeSubstitutionAndRewind(final int startIndex, final int endIndex, final CharSequence replacement) throws SnuggleParseException { int expansionLimit = sessionContext.getConfiguration().getExpansionLimit(); if (expansionLimit>0 && workingDocument.getSubstitutionDepth(startIndex) >= expansionLimit) { /* Fail: Substitution limit exceeded (avoids infinite recursion) */ return createError(CoreErrorCode.TTEU00, startIndex, endIndex, Integer.valueOf(expansionLimit)); } workingDocument.substitute(startIndex, endIndex, replacement); position = startIndex; return null; }
/** * Makes a substitution within the working document, replacing the position of the * {@link WorkingDocument} from startIndex to endIndex with the given replacement * {@link CharSequence}. * <p> * The value of {@link #position} is updated to point to the start of the replacement * afterwards. * <p> * The given {@link SourceContext} provides optional contextual information about where * the substitution came from, if required. */ private ErrorToken makeSubstitutionAndRewind(final int startIndex, final int endIndex, final CharSequence replacement) throws SnuggleParseException { int expansionLimit = sessionContext.getConfiguration().getExpansionLimit(); if (expansionLimit>0 && workingDocument.getSubstitutionDepth(startIndex) >= expansionLimit) { /* Fail: Substitution limit exceeded (avoids infinite recursion) */ return createError(CoreErrorCode.TTEU00, startIndex, endIndex, Integer.valueOf(expansionLimit)); } workingDocument.substitute(startIndex, endIndex, replacement); position = startIndex; return null; }
/** * Makes a substitution within the working document, replacing the position of the * {@link WorkingDocument} from startIndex to endIndex with the given replacement * {@link CharSequence}. * <p> * The value of {@link #position} is updated to point to the start of the replacement * afterwards. * <p> * The given {@link SourceContext} provides optional contextual information about where * the substitution came from, if required. */ private ErrorToken makeSubstitutionAndRewind(final int startIndex, final int endIndex, final CharSequence replacement) throws SnuggleParseException { int expansionLimit = sessionContext.getConfiguration().getExpansionLimit(); if (expansionLimit>0 && workingDocument.getSubstitutionDepth(startIndex) >= expansionLimit) { /* Fail: Substitution limit exceeded (avoids infinite recursion) */ return createError(CoreErrorCode.TTEU00, startIndex, endIndex, Integer.valueOf(expansionLimit)); } workingDocument.substitute(startIndex, endIndex, replacement); position = startIndex; return null; }