<commit_before>package org.bsc.rhino;

import org.mozilla.javascript.Context;
import org.mozilla.javascript.Scriptable;

/**
 * Created by softphone on 03/07/14.
 */
public final class RhinoContext {

    public class Result<T> {

        private final T result;

        Result(T result) {
            this.result = result;
        }

        public RhinoContext context() {
            return  RhinoContext.this;
        }

        public Result<T> exit() {
            context().exit();
            return this;
        }

        public T result() {
            return result;
        }

    }
    private Context cx;

    protected RhinoContext() {
        this(null);
    }
    protected RhinoContext(Context cx) {
        this.cx = cx;
    }

    public static RhinoContext enter() {

        return new RhinoContext(Context.enter());

    }
    public static RhinoContext current() {

        return new RhinoContext( Context.getCurrentContext());
    }


    public void exit() {
        if( cx!= null ) {
            cx.removeThreadLocal(Scriptable.class.getName());<commit_msg>generic improvements<commit_after>package org.bsc.rhino;

import org.mozilla.javascript.Context;
import org.mozilla.javascript.Scriptable;

/**
 * Created by softphone on 03/07/14.
 */
public final class RhinoContext {

    public class Result<T> {

        private final T result;

        Result(T result) {
            this.result = result;
        }

        public RhinoContext context() {
            return  RhinoContext.this;
        }

        public Result<T> exit() {
            context().exit();
            return this;
        }

        public T result() {
            return result;
        }

    }

    private Context cx;

    protected RhinoContext(Context cx) {
        this.cx = cx;
    }

    public static RhinoContext enter() {

        return new RhinoContext(Context.enter());

    }
    public static RhinoContext current() {

        return new RhinoContext( Context.getCurrentContext());
    }

    public Context getUnderlyingContext() {
        return cx;
    }

    public void exit() {
        if( cx!= null ) {
            cx.removeThreadLocal(Scriptable.class.getName());
{'fraction_non_alphanumeric': 0.10018214936247723, 'fraction_numerical': 0.00546448087431694, 'mean_word_length': 1.9176626826029217, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '5324200', 'n_tokens_mistral': 626, 'n_tokens_neox': 586, 'n_words': 152}