<commit_before>package jwebform.env;


// holds pointers to the web-env. (request, response, session, maybe headers...)
public class Env {
	private final Request request;
	private final SessionGet sessionGet;
	private final SessionSet sessionSet;
	
	final static SessionGet EMPTY_SESSION_GET = t -> "";
	final static SessionSet EMPTY_SESSION_SET = (k,v) -> {};
	
	public Env(Request request) {
		this(request, EMPTY_SESSION_GET, EMPTY_SESSION_SET);
	}

	public Env(Request request, SessionGet sessionGet, SessionSet sessionSet) {
		this.request = request;
		this.sessionGet = sessionGet;
		this.sessionSet = sessionSet;
	}

	public Request getRequest() {
		return request;
	}

	public SessionGet getSessionGet() {
		return sessionGet;
	}

	public SessionSet getSessionSet() {
		return sessionSet;
	}

	public void ensureSessionAvail() {
		if (getSessionGet() == EMPTY_SESSION_GET || getSessionSet() == EMPTY_SESSION_SET) {
			throw new SessionMissingException();
		}
	}
	
	 public class SessionMissingException extends RuntimeException {
		    private static final long serialVersionUID = 1L;

		    public SessionMissingException() {
		      super(
		          "Session data missing in Env. \nPlease provide sessionGet() and sessionSet() in Env!\n\n...This is needed for XSRF-Protection."
		              + "\n\nExample: \nnew Env(requestParamName -> request.getParameter(requestParamName),	// Request"
		              + "\nsessionParamName -> request.getSession().getAttribute(sessionParamName), // SessionGet"
		              + "\n(sessionParamName, value) -> request.getSession().setAttribute(sessionParamName, value) // SessionSet"
		              + "\n);");
		    }
		  }

}
<commit_msg>new helper for preparation of transparently handling form-id<commit_after>package jwebform.env;


// holds pointers to the web-env. (request, response, session, maybe headers...)
public class Env {
	private final Request request;
	private final SessionGet sessionGet;
	private final SessionSet sessionSet;
	
	final static SessionGet EMPTY_SESSION_GET = t -> "";
	final static SessionSet EMPTY_SESSION_SET = (k,v) -> {};
	
	public Env(Request request) {
		this(request, EMPTY_SESSION_GET, EMPTY_SESSION_SET);
	}

	public Env(Request request, SessionGet sessionGet, SessionSet sessionSet) {
		this.request = request;
		this.sessionGet = sessionGet;
		this.sessionSet = sessionSet;
	}

	public Request getRequest() {
		return request;
	}

	public Env cloneWithFormIdPrefix(String formId) {
		return new Env(p -> request.getParameter(p), sessionGet, sessionSet); 
	}
	
	public SessionGet getSessionGet() {
		return sessionGet;
	}

	public SessionSet getSessionSet() {
		return sessionSet;
	}

	public void ensureSessionAvail() {
		if (getSessionGet() == EMPTY_SESSION_GET || getSessionSet() == EMPTY_SESSION_SET) {
			throw new SessionMissingException();
		}
	}
	
	 public class SessionMissingException extends RuntimeException {
		    private static final long serialVersionUID = 1L;

		    public SessionMissingException() {
		      super(
		          "Session data missing in Env. \nPlease provide sessionGet() and sessionSet() in Env!\n\n...This is needed for XSRF-Protection."
		              + "\n\nExample: \nnew Env(requestParamName -> request.getParameter(requestParamName),	// Request"
		              + "\nsessionParamName -> request.getSession().getAttribute(sessionParamName), // SessionGet"
		              + "\n(sessionParamName, value) -> request.getSession().setAttribute(sessionParamName, value) // SessionSet"
		              + "\n);");
		    }
		  }

}

{'fraction_non_alphanumeric': 0.1047164514317799, 'fraction_numerical': 0.0005614823133071309, 'mean_word_length': 3.5855855855855854, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4111407', 'n_tokens_mistral': 1092, 'n_tokens_neox': 999, 'n_words': 269}