Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /* ************************************************************************
 #
 #  DivConq
 #
 #  http://divconq.com/
 #
 #  Copyright:
 #    Copyright 2014 eTimeline, LLC. All rights reserved.
 #
#  License:
#    See the license.txt file in the project's top-level directory for details.
#  Authors:
#    * Andy White
************************************************************************ */
package divconq.script.mutator;
public class Substring implements IOperator {
	public void operation(StackEntry stackXElement codeStruct dest) {
		int from = (intstack.intFromElement(code"From", 0); 
		int to = (intstack.intFromElement(code"To", 0); 
		int length = (intstack.intFromElement(code"Length", 0); 
		if (dest instanceof StringStruct) {
			StringStruct idest = (StringStruct)dest;
			String val = idest.getValue();
			if (StringUtil.isEmpty(val))
				return;
			if (to > 0) 
				idest.setValue(val.substring(fromto));
			else if (length > 0) 
				idest.setValue(val.substring(fromfrom + length));
			else
				idest.setValue(val.substring(from));
			..println("Using override Substring!");
		}
		stack.resume();
	}
New to GrepCode? Check out our FAQ X