try {
                OBJECT_TOSTRING = Object.class.getMethod("toString");
                OBJECT_HASHCODE = Object.class.getMethod("hashCode");
                OBJECT_EQUALS = Object.class.getMethod("equals", Object.class);
            } catch (Exception e) {
                throw new Error("Error retrieving Object.toString() method");
            }

package com.sun.jna;

import com.sun.jna.internal.ReflectionUtils;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.HashMap;
import java.util.Map;
import java.util.WeakHashMap;

/**
 * Derive from this interface for all native library definitions.
 *
 * Define an instance of your library like this:
 *

 * MyNativeLibrary INSTANCE = (MyNativeLibrary)
 *     Native.load("mylib", MyNativeLibrary.class);
 *

 *

 * By convention, method names are identical to the native names, although you
 * can map java names to different native names by providing a
 * {@link FunctionMapper} as a value for key {@link #OPTION_FUNCTION_MAPPER}
 * in the options map passed to the
 * {@link Native#load(String, Class, Map)} call.
 *

 * Although the names for structures and structure fields may be chosen
 * arbitrarily, they should correspond as closely as possible to the native
 * definitions.  The same is true for parameter names.
 *

 * This interface supports multiple, concurrent invocations of any library
 * methods on the Java side.  Check your library documentation for its
 * multi-threading requirements on the native side.  If a library is not safe
 * for simultaneous multi-threaded access, consider using
 * {@link Native#synchronizedLibrary} to prevent simultaneous multi-threaded
 * access to the native code.
 *

 * Optional fields

 * Interface options will be automatically propagated to structures defined
 * within the library provided a call to
 * {@link Native#load(String,Class,Map)} is made prior to instantiating
 * any of those structures.  One common way of ensuring this is to declare
 * an INSTANCE field in the interface which holds the
 * load result.
 *

 * OPTIONS (an instance of {@link Map}),
 * TYPE_MAPPER (an instance of {@link TypeMapper}),
 * STRUCTURE_ALIGNMENT (one of the alignment types defined in
 * {@link Structure}), and STRING_ENCODING (a {@link String}) may also
 * be defined.  If no instance of the interface has been instantiated, these
 * fields will be used to determine customization settings for structures and
 * methods defined within the interface.
 *

 *
 * @author  Todd Fast, example@nnthink.com
 * @author  Timothy Wall, example@nnthink.com
 */
public interface Library {

    /**
     * Option key for a {@link TypeMapper} for the library.
     */
    String OPTION_TYPE_MAPPER = "type-mapper";

    /**
     * Option key for a {@link FunctionMapper} for the library.
     */
    String OPTION_FUNCTION_MAPPER = "function-mapper";

    /**
     * Option key for an {@link InvocationMapper} for the library.
     */
    String OPTION_INVOCATION_MAPPER = "invocation-mapper";

    /**
     * Option key for structure alignment type ({@link Integer}), which should
     * be one of the predefined alignment types in {@link Structure}.
     */
    String OPTION_STRUCTURE_ALIGNMENT = "structure-alignment";

    /**
     *
Option key for per-library String encoding.  This affects conversions
     * between Java unicode and native (const char*) strings (as
     * arguments or Structure fields).
     *

     * Defaults to {@link Native#getDefaultStringEncoding()}.
     */
    String OPTION_STRING_ENCODING = "string-encoding";

    /**
     * Option key for a boolean flag to allow any Java class instance as a
     *        parameter.  If no type mapper is found, the object is passed as a
     *        pointer.
     *        NOTE: This is for use with raw JNI interactions via the
     *        JNIEnv data structure.
     */
    String OPTION_ALLOW_OBJECTS = "allow-objects";

    /**
     * Calling convention for the entire library.
     */
    String OPTION_CALLING_CONVENTION = "calling-convention";

    /**
     * Flags to use when opening the native library (see {@link Native#open(String,int)})
     */
    String OPTION_OPEN_FLAGS = "open-flags";

    /**
     *
Class loader to use when searching for native libraries on the
     * resource path (classpath).  If not provided the current thread's
     * context class loader is used.

     * If extracted from the resource path (i.e. bundled in a jar file), the
     * loaded library's lifespan will mirror that of the class loader, which
     * means you can use the same library in isolated contexts without
     * conflict.
     */
    String OPTION_CLASSLOADER = "classloader";

    static class Handler implements InvocationHandler {

        static final Method OBJECT_TOSTRING;

        static final Method OBJECT_HASHCODE;

        static final Method OBJECT_EQUALS;

        static {

        }

        /**
         * FunctionInfo has to be immutable to to make the object visible
         * to other threads fully initialized. This is a prerequisite for
         * using the class in the double checked locking scenario of {@link Handler#invoke(Object, Method, Object[])}
         */
        private static final class FunctionInfo {

            final InvocationHandler handler;

            final Function function;

            final boolean isVarArgs;

            final Object methodHandle;

            final Map<String, ?> options;

            final Class<?>[] parameterTypes;

            FunctionInfo(Object mh) {
                this.handler = null;
                this.function = null;
                this.isVarArgs = false;
                this.options = null;
                this.parameterTypes = null;
                this.methodHandle = mh;
            }

            FunctionInfo(InvocationHandler handler, Function function, Class<?>[] parameterTypes, boolean isVarArgs, Map<String, ?> options) {
                this.handler = handler;
                this.function = function;
                this.isVarArgs = isVarArgs;
                this.options = options;
                this.parameterTypes = parameterTypes;
                this.methodHandle = null;
            }
        }

        private final NativeLibrary nativeLibrary;

        private final Class<?> interfaceClass;

        // Library invocation options
        private final Map<String, Object> options;

        private final InvocationMapper invocationMapper;

        private final Map<Method, FunctionInfo> functions = new WeakHashMap<Method, FunctionInfo>();

        public Handler(String libname, Class<?> interfaceClass, Map<String, ?> options) {
            if (libname != null && "".equals(libname.trim())) {
                throw new IllegalArgumentException("Invalid library name \"" + libname + "\"");
            }
            if (!interfaceClass.isInterface()) {
                throw new IllegalArgumentException(libname + " does not implement an interface: " + interfaceClass.getName());
            }
            this.interfaceClass = interfaceClass;
            this.options = new HashMap<String, Object>(options);
            int callingConvention = AltCallingConvention.class.isAssignableFrom(interfaceClass) ? Function.ALT_CONVENTION : Function.C_CONVENTION;
            if (this.options.get(OPTION_CALLING_CONVENTION) == null) {
                this.options.put(OPTION_CALLING_CONVENTION, Integer.valueOf(callingConvention));
            }
            if (this.options.get(OPTION_CLASSLOADER) == null) {
                this.options.put(OPTION_CLASSLOADER, interfaceClass.getClassLoader());
            }
            this.nativeLibrary = NativeLibrary.getInstance(libname, this.options);
            invocationMapper = (InvocationMapper) this.options.get(OPTION_INVOCATION_MAPPER);
        }

        public NativeLibrary getNativeLibrary() {
            return nativeLibrary;
        }

        public String getLibraryName() {
            return nativeLibrary.getName();
        }

        public Class<?> getInterfaceClass() {
            return interfaceClass;
        }

        @Override
        public Object invoke(Object proxy, Method method, Object[] inArgs) throws Throwable {
            // Intercept Object methods
            if (OBJECT_TOSTRING.equals(method)) {
                return "Proxy interface to " + nativeLibrary;
            } else if (OBJECT_HASHCODE.equals(method)) {
                return Integer.valueOf(hashCode());
            } else if (OBJECT_EQUALS.equals(method)) {
                Object o = inArgs[0];
                if (o != null && Proxy.isProxyClass(o.getClass())) {
                    return Function.valueOf(Proxy.getInvocationHandler(o) == this);
                }
                return Boolean.FALSE;
            }
            // Using the double-checked locking pattern to speed up function calls
            FunctionInfo f = functions.get(method);
            if (f == null) {
                synchronized (functions) {
                    f = functions.get(method);
                    if (f == null) {
                        boolean isDefault = ReflectionUtils.isDefault(method);
                        if (!isDefault) {
                            boolean isVarArgs = Function.isVarArgs(method);
                            InvocationHandler handler = null;
                            if (invocationMapper != null) {
                                handler = invocationMapper.getInvocationHandler(nativeLibrary, method);
                            }
                            Function function = null;
                            Class<?>[] parameterTypes = null;
                            Map<String, Object> options = null;
                            if (handler == null) {
                                // Find the function to invoke
                                function = nativeLibrary.getFunction(method.getName(), method);
                                parameterTypes = method.getParameterTypes();
                                options = new HashMap<String, Object>(this.options);
                                options.put(Function.OPTION_INVOKING_METHOD, method);
                            }
                            f = new FunctionInfo(handler, function, parameterTypes, isVarArgs, options);
                        } else {
                            f = new FunctionInfo(ReflectionUtils.getMethodHandle(method));
                        }
                        functions.put(method, f);
                    }
                }
            }
            if (f.methodHandle != null) {
                return ReflectionUtils.invokeDefaultMethod(proxy, f.methodHandle, inArgs);
            } else {
                if (f.isVarArgs) {
                    inArgs = Function.concatenateVarArgs(inArgs);
                }
                if (f.handler != null) {
                    return f.handler.invoke(proxy, method, inArgs);
                }
                return f.function.invoke(method, f.parameterTypes, method.getReturnType(), inArgs, f.options);
            }
        }
    }
}


/*
 * Solution to Project Euler problem 57
 *
 * http://example.com
 * http://example.com
 */
import java.math.BigInteger;

public final class p057 implements EulerSolution {

{
        System.out.println(new p057().run());
    }

    private static final int LIMIT = 1000;

    public String run() {
        BigInteger n = BigInteger.ZERO;
        BigInteger d = BigInteger.ONE;
        int count = 0;
        for (int i = 0; i < LIMIT; i++) {
            BigInteger temp = d.multiply(BigInteger.valueOf(2)).add(n);
            n = d;
            d = temp;
            // Now n/d is the i'th (0-based) continued fraction approximation of sqrt(2) - 1
            if (n.add(d).toString().length() > d.toString().length())
                count++;
        }
        return Integer.toString(count);
    }
}


{
        System.out.println(new p057().run());
    }

/*
 * Solution to Project Euler problem 57
 *
 * http://example.com
 * http://example.com
 */
import java.math.BigInteger;

public final class p057 implements EulerSolution {

    public static void main(String[] args)

    private static final int LIMIT = 1000;

    public String run() {
        BigInteger n = BigInteger.ZERO;
        BigInteger d = BigInteger.ONE;
        int count = 0;
        for (int i = 0; i < LIMIT; i++) {
            BigInteger temp = d.multiply(BigInteger.valueOf(2)).add(n);
            n = d;
            d = temp;
            // Now n/d is the i'th (0-based) continued fraction approximation of sqrt(2) - 1
            if (n.add(d).toString().length() > d.toString().length())
                count++;
        }
        return Integer.toString(count);
    }
}


/*
 * Solution to Project Euler problem 57
 *
 * http://example.com
 * http://example.com
 */
import java.math.BigInteger;

public final class p057 implements EulerSolution {

    public static void main(String[] args) {
        System.out.println(new p057().run());
    }

    private static final int LIMIT = 1000;

    public String run() {
        BigInteger n = BigInteger.ZERO;
        BigInteger d

        int count = 0;
        for (int i = 0; i < LIMIT; i++) {
            BigInteger temp = d.multiply(BigInteger.valueOf(2)).add(n);
            n = d;
            d = temp;
            // Now n/d is the i'th (0-based) continued fraction approximation of sqrt(2) - 1
            if (n.add(d).toString().length() > d.toString().length())
                count++;
        }
        return Integer.toString(count);
    }
}


for (int i = 0; i < LIMIT; i++) {
            BigInteger temp = d.multiply(BigInteger.valueOf(2)).add(n);
            n = d;
            d = temp;
            // Now n/d is the i'th (0-based) continued fraction approximation of sqrt(2) - 1
            if (n.add(d).toString().length() > d.toString().length())
                count++;
        }

/*
 * Solution to Project Euler problem 57
 *
 * http://example.com
 * http://example.com
 */
import java.math.BigInteger;

public final class p057 implements EulerSolution {

    public static void main(String[] args) {
        System.out.println(new p057().run());
    }

    private static final int LIMIT = 1000;

    public String run() {
        BigInteger n = BigInteger.ZERO;
        BigInteger d = BigInteger.ONE;
        int count = 0;

        return Integer.toString(count);
    }
}


package com.android.server.wifi.grs.requestremote;

import android.provider.Settings;
import android.util.Log;
import com.android.server.wifi.grs.GrsCallBack;
import com.android.server.wifi.grs.utils.ContextUtil;
import java.util.concurrent.Callable;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

public class RequestController {

    private static final String CAPTIVE_PORTAL_REQUEST_TIME = "captive_portal_request_time";

    private static final int DEFAULT_TIME = 0;

    private static final int SILENT_PERIOD = 300000;

    private static final String TAG = "RequestController";

    private static volatile RequestController sInstance;

    private final Object mLock = new Object();

    /* access modifiers changed from: private */
    public ExecutorService taskExecutor = Executors.newCachedThreadPool();

    public static synchronized RequestController getInstance() {
        RequestController requestController;
        synchronized (RequestController.class) {
            if (sInstance == null) {
                sInstance = new RequestController();
            }
            requestController = sInstance;
        }
        return requestController;
    }

    /* access modifiers changed from: private */
    public GrsResponse getSyncServicesUrls() {
        synchronized (this.mLock) {
            if (System.currentTimeMillis() - Long.valueOf(Settings.Global.getLong(ContextUtil.getContext().getContentResolver(), CAPTIVE_PORTAL_REQUEST_TIME, 0)).longValue() < 300000) {
                Log.d(TAG, "cancel this request because the last request is initiated less than 5 mins ago");
                return null;
            }
            Settings.Global.putLong(ContextUtil.getContext().getContentResolver(), CAPTIVE_PORTAL_REQUEST_TIME, System.currentTimeMillis());
            Future<GrsResponse> future = this.taskExecutor.submit(new Callable<GrsResponse>() {

                // java.util.concurrent.Callable
                @Override
                public GrsResponse call() {
                    return new GrsRequest().submitExcutorTaskWithTimeout(RequestController.this.taskExecutor);
                }
            });
            try {
                return future.get();
            } catch (CancellationException e) {
                Log.d(TAG, "when check result, find CancellationException, check others");
                return null;
            } catch (ExecutionException e2) {
                Log.d(TAG, "when check result, find ExecutionException, check others");
                return null;
            } catch (InterruptedException e3) {
                Log.d(TAG, "when check result, find InterruptedException, check others");
                return null;
            }
        }
    }

    public void getAsyncServicesUrls(final GrsCallBack grsCallBack) {
        this.taskExecutor.submit(new Runnable() {

{
                RequestController requestController = RequestController.this;
                requestController.doCallBack(requestController.getSyncServicesUrls(), grsCallBack);
            }
        });
    }

    /* access modifiers changed from: private */
    public void doCallBack(GrsResponse grsResponse, GrsCallBack grsCallBack) {
        if (grsCallBack == null) {
            return;
        }
        if (grsResponse == null) {
            Log.d(TAG, "GrsResponse is null");
            grsCallBack.onFailure();
            return;
        }
        Log.d(TAG, "GrsResponse is not null");
        grsCallBack.onResponse(grsResponse);
    }
}


{
                RequestController requestController = RequestController.this;
                requestController.doCallBack(requestController.getSyncServicesUrls(), grsCallBack);
            }

package com.android.server.wifi.grs.requestremote;

import android.provider.Settings;
import android.util.Log;
import com.android.server.wifi.grs.GrsCallBack;
import com.android.server.wifi.grs.utils.ContextUtil;
import java.util.concurrent.Callable;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

public class RequestController {

    private static final String CAPTIVE_PORTAL_REQUEST_TIME = "captive_portal_request_time";

    private static final int DEFAULT_TIME = 0;

    private static final int SILENT_PERIOD = 300000;

    private static final String TAG = "RequestController";

    private static volatile RequestController sInstance;

    private final Object mLock = new Object();

    /* access modifiers changed from: private */
    public ExecutorService taskExecutor = Executors.newCachedThreadPool();

    public static synchronized RequestController getInstance() {
        RequestController requestController;
        synchronized (RequestController.class) {
            if (sInstance == null) {
                sInstance = new RequestController();
            }
            requestController = sInstance;
        }
        return requestController;
    }

    /* access modifiers changed from: private */
    public GrsResponse getSyncServicesUrls() {
        synchronized (this.mLock) {
            if (System.currentTimeMillis() - Long.valueOf(Settings.Global.getLong(ContextUtil.getContext().getContentResolver(), CAPTIVE_PORTAL_REQUEST_TIME, 0)).longValue() < 300000) {
                Log.d(TAG, "cancel this request because the last request is initiated less than 5 mins ago");
                return null;
            }
            Settings.Global.putLong(ContextUtil.getContext().getContentResolver(), CAPTIVE_PORTAL_REQUEST_TIME, System.currentTimeMillis());
            Future<GrsResponse> future = this.taskExecutor.submit(new Callable<GrsResponse>() {

                // java.util.concurrent.Callable
                @Override
                public GrsResponse call() {
                    return new GrsRequest().submitExcutorTaskWithTimeout(RequestController.this.taskExecutor);
                }
            });
            try {
                return future.get();
            } catch (CancellationException e) {
                Log.d(TAG, "when check result, find CancellationException, check others");
                return null;
            } catch (ExecutionException e2) {
                Log.d(TAG, "when check result, find ExecutionException, check others");
                return null;
            } catch (InterruptedException e3) {
                Log.d(TAG, "when check result, find InterruptedException, check others");
                return null;
            }
        }
    }

    public void getAsyncServicesUrls(final GrsCallBack grsCallBack) {
        this.taskExecutor.submit(new Runnable() {

            public void run()

        });
    }

    /* access modifiers changed from: private */
    public void doCallBack(GrsResponse grsResponse, GrsCallBack grsCallBack) {
        if (grsCallBack == null) {
            return;
        }
        if (grsResponse == null) {
            Log.d(TAG, "GrsResponse is null");
            grsCallBack.onFailure();
            return;
        }
        Log.d(TAG, "GrsResponse is not null");
        grsCallBack.onResponse(grsResponse);
    }
}


package com.android.server.wifi.grs.requestremote;

import android.provider.Settings;
import android.util.Log;
import com.android.server.wifi.grs.GrsCallBack;
import com.android.server.wifi.grs.utils.ContextUtil;
import java.util.concurrent.Callable;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

public class RequestController {

    private static final String CAPTIVE_PORTAL_REQUEST_TIME = "captive_portal_request_time";

    private static final int DEFAULT_TIME = 0;

    private static final int SILENT_PERIOD = 300000;

    private static final String TAG = "RequestController";

    private static volatile RequestController sInstance;

    private final Object mLock = new Object();

    /* access modifiers changed from: private */
    public ExecutorService taskExecutor = Executors.newCachedThreadPool();

    public static synchronized RequestController getInstance() {
        RequestController r

        synchronized (RequestController.class) {
            if (sInstance == null) {
                sInstance = new RequestController();
            }
            requestController = sInstance;
        }
        return requestController;
    }

    /* access modifiers changed from: private */
    public GrsResponse getSyncServicesUrls() {
        synchronized (this.mLock) {
            if (System.currentTimeMillis() - Long.valueOf(Settings.Global.getLong(ContextUtil.getContext().getContentResolver(), CAPTIVE_PORTAL_REQUEST_TIME, 0)).longValue() < 300000) {
                Log.d(TAG, "cancel this request because the last request is initiated less than 5 mins ago");
                return null;
            }
            Settings.Global.putLong(ContextUtil.getContext().getContentResolver(), CAPTIVE_PORTAL_REQUEST_TIME, System.currentTimeMillis());
            Future<GrsResponse> future = this.taskExecutor.submit(new Callable<GrsResponse>() {

                // java.util.concurrent.Callable
                @Override
                public GrsResponse call() {
                    return new GrsRequest().submitExcutorTaskWithTimeout(RequestController.this.taskExecutor);
                }
            });
            try {
                return future.get();
            } catch (CancellationException e) {
                Log.d(TAG, "when check result, find CancellationException, check others");
                return null;
            } catch (ExecutionException e2) {
                Log.d(TAG, "when check result, find ExecutionException, check others");
                return null;
            } catch (InterruptedException e3) {
                Log.d(TAG, "when check result, find InterruptedException, check others");
                return null;
            }
        }
    }

    public void getAsyncServicesUrls(final GrsCallBack grsCallBack) {
        this.taskExecutor.submit(new Runnable() {

            public void run() {
                RequestController requestController = RequestController.this;
                requestController.doCallBack(requestController.getSyncServicesUrls(), grsCallBack);
            }
        });
    }

    /* access modifiers changed from: private */
    public void doCallBack(GrsResponse grsResponse, GrsCallBack grsCallBack) {
        if (grsCallBack == null) {
            return;
        }
        if (grsResponse == null) {
            Log.d(TAG, "GrsResponse is null");
            grsCallBack.onFailure();
            return;
        }
        Log.d(TAG, "GrsResponse is not null");
        grsCallBack.onResponse(grsResponse);
    }
}


public void doCallBack(GrsResponse grsResponse, GrsCallBack grsCallBack) {
        if (grsCallBack == null) {
            return;
        }
        if (grsResponse == null) {
            Log.d(TAG, "GrsResponse is null");
            grsCallBack.onFailure();
            return;
        }
        Log.d(TAG, "GrsResponse is not null");
        grsCallBack.onResponse(grsResponse);
    }

package com.android.server.wifi.grs.requestremote;

import android.provider.Settings;
import android.util.Log;
import com.android.server.wifi.grs.GrsCallBack;
import com.android.server.wifi.grs.utils.ContextUtil;
import java.util.concurrent.Callable;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

public class RequestController {

    private static final String CAPTIVE_PORTAL_REQUEST_TIME = "captive_portal_request_time";

    private static final int DEFAULT_TIME = 0;

    private static final int SILENT_PERIOD = 300000;

    private static final String TAG = "RequestController";

    private static volatile RequestController sInstance;

    private final Object mLock = new Object();

    /* access modifiers changed from: private */
    public ExecutorService taskExecutor = Executors.newCachedThreadPool();

    public static synchronized RequestController getInstance() {
        RequestController requestController;
        synchronized (RequestController.class) {
            if (sInstance == null) {
                sInstance = new RequestController();
            }
            requestController = sInstance;
        }
        return requestController;
    }

    /* access modifiers changed from: private */
    public GrsResponse getSyncServicesUrls() {
        synchronized (this.mLock) {
            if (System.currentTimeMillis() - Long.valueOf(Settings.Global.getLong(ContextUtil.getContext().getContentResolver(), CAPTIVE_PORTAL_REQUEST_TIME, 0)).longValue() < 300000) {
                Log.d(TAG, "cancel this request because the last request is initiated less than 5 mins ago");
                return null;
            }
            Settings.Global.putLong(ContextUtil.getContext().getContentResolver(), CAPTIVE_PORTAL_REQUEST_TIME, System.currentTimeMillis());
            Future<GrsResponse> future = this.taskExecutor.submit(new Callable<GrsResponse>() {

                // java.util.concurrent.Callable
                @Override
                public GrsResponse call() {
                    return new GrsRequest().submitExcutorTaskWithTimeout(RequestController.this.taskExecutor);
                }
            });
            try {
                return future.get();
            } catch (CancellationException e) {
                Log.d(TAG, "when check result, find CancellationException, check others");
                return null;
            } catch (ExecutionException e2) {
                Log.d(TAG, "when check result, find ExecutionException, check others");
                return null;
            } catch (InterruptedException e3) {
                Log.d(TAG, "when check result, find InterruptedException, check others");
                return null;
            }
        }
    }

    public void getAsyncServicesUrls(final GrsCallBack grsCallBack) {
        this.taskExecutor.submit(new Runnable() {

            public void run() {
                RequestController requestController = RequestController.this;
                requestController.doCallBack(requestController.getSyncServicesUrls(), grsCallBack);
            }
        });
    }

    /* access modifiers changed from: private */


@Test
    public void goldenTest0() throws Exception

// test: fixedlook
package de.jflex.testcase.fixed_look;

import de.jflex.testing.testsuite.golden.AbstractGoldenTest;
import de.jflex.testing.testsuite.golden.GoldenInOutFilePair;
import de.jflex.util.scanner.ScannerFactory;
import java.io.File;
import org.junit.Test;

/**
 * test fixed length lookahead, e.g. r1 / "some text"
 *
 *
Note: This test was generated from {@code jflex-testsuite-maven-plugin} test cases. The test
 * relies on golden files for testing, expecting the scanner to output logs on the {@code
 * System.out}. Please migrate to proper unit tests, as describe in
 * //javatest/jflex/testcase.
 */
// TODO Migrate this test to proper unit tests.
public class FixedlookGoldenTest extends AbstractGoldenTest {

    /**
     * Creates a scanner conforming to the {@code fixedlook.flex} specification.
     */
    private final ScannerFactory<Fixedlook> scannerFactory = ScannerFactory.of(Fixedlook::new);

    private final File testRuntimeDir = new File("javatests/de/jflex/testcase/fixed_look");

{
        GoldenInOutFilePair golden = new GoldenInOutFilePair(new File(testRuntimeDir, "fixedlook-0.input"), new File(testRuntimeDir, "fixedlook-0.output"));
        compareSystemOutWith(golden);
        Fixedlook scanner = scannerFactory.createScannerForFile(golden.inputFile);
        while (!scanner.yyatEOF()) {
            System.out.println(scanner.yylex());
        }
    }

    @Test
    public void goldenTest1() throws Exception {
        GoldenInOutFilePair golden = new GoldenInOutFilePair(new File(testRuntimeDir, "fixedlook-1.input"), new File(testRuntimeDir, "fixedlook-1.output"));
        compareSystemOutWith(golden);
        Fixedlook scanner = scannerFactory.createScannerForFile(golden.inputFile);
        while (!scanner.yyatEOF()) {
            System.out.println(scanner.yylex());
        }
    }

    @Test
    public void goldenTest2() throws Exception {
        GoldenInOutFilePair golden = new GoldenInOutFilePair(new File(testRuntimeDir, "fixedlook-2.input"), new File(testRuntimeDir, "fixedlook-2.output"));
        compareSystemOutWith(golden);
        Fixedlook scanner = scannerFactory.createScannerForFile(golden.inputFile);
        while (!scanner.yyatEOF()) {
            System.out.println(scanner.yylex());
        }
    }

    @Test
    public void goldenTest3() throws Exception {
        GoldenInOutFilePair golden = new GoldenInOutFilePair(new File(testRuntimeDir, "fixedlook-3.input"), new File(testRuntimeDir, "fixedlook-3.output"));
        compareSystemOutWith(golden);
        Fixedlook scanner = scannerFactory.createScannerForFile(golden.inputFile);
        while (!scanner.yyatEOF()) {
            System.out.println(scanner.yylex());
        }
    }
}


{
        GoldenInOutFilePair golden = new GoldenInOutFilePair(new File(testRuntimeDir, "fixedlook-2.input"), new File(testRuntimeDir, "fixedlook-2.output"));
        compareSystemOutWith(golden);
        Fixedlook scanner = scannerFactory.createScannerForFile(golden.inputFile);
        while (!scanner.yyatEOF()) {
            System.out.println(scanner.yylex());
        }
    }

// test: fixedlook
package de.jflex.testcase.fixed_look;

import de.jflex.testing.testsuite.golden.AbstractGoldenTest;
import de.jflex.testing.testsuite.golden.GoldenInOutFilePair;
import de.jflex.util.scanner.ScannerFactory;
import java.io.File;
import org.junit.Test;

/**
 * test fixed length lookahead, e.g. r1 / "some text"
 *
 *
Note: This test was generated from {@code jflex-testsuite-maven-plugin} test cases. The test
 * relies on golden files for testing, expecting the scanner to output logs on the {@code
 * System.out}. Please migrate to proper unit tests, as describe in
 * //javatest/jflex/testcase.
 */
// TODO Migrate this test to proper unit tests.
public class FixedlookGoldenTest extends AbstractGoldenTest {

    /**
     * Creates a scanner conforming to the {@code fixedlook.flex} specification.
     */
    private final ScannerFactory<Fixedlook> scannerFactory = ScannerFactory.of(Fixedlook::new);

    private final File testRuntimeDir = new File("javatests/de/jflex/testcase/fixed_look");

    @Test
    public void goldenTest0() throws Exception {
        GoldenInOutFilePair golden = new GoldenInOutFilePair(new File(testRuntimeDir, "fixedlook-0.input"), new File(testRuntimeDir, "fixedlook-0.output"));
        compareSystemOutWith(golden);
        Fixedlook scanner = scannerFactory.createScannerForFile(golden.inputFile);
        while (!scanner.yyatEOF()) {
            System.out.println(scanner.yylex());
        }
    }

    @Test
    public void goldenTest1() throws Exception {
        GoldenInOutFilePair golden = new GoldenInOutFilePair(new File(testRuntimeDir, "fixedlook-1.input"), new File(testRuntimeDir, "fixedlook-1.output"));
        compareSystemOutWith(golden);
        Fixedlook scanner = scannerFactory.createScannerForFile(golden.inputFile);
        while (!scanner.yyatEOF()) {
            System.out.println(scanner.yylex());
        }
    }

    @Test
    public void goldenTest2() throws Exception

    @Test
    public void goldenTest3() throws Exception {
        GoldenInOutFilePair golden = new GoldenInOutFilePair(new File(testRuntimeDir, "fixedlook-3.input"), new File(testRuntimeDir, "fixedlook-3.output"));
        compareSystemOutWith(golden);
        Fixedlook scanner = scannerFactory.createScannerForFile(golden.inputFile);
        while (!scanner.yyatEOF()) {
            System.out.println(scanner.yylex());
        }
    }
}


// test: fixedlook
package de.jflex.testcase.fixed_look;

import de.jflex.testing.testsuite.golden.AbstractGoldenTest;
import de.jflex.testing.testsuite.golden.GoldenInOutFilePair;
import de.jflex.util.scanner.ScannerFactory;
import java.io.File;
import org.junit.Test;

/**
 * test fixed length lookahead, e.g. r1 / "some text"
 *
 *
Note: This test was generated from {@code jflex-testsuite-maven-plugin} test cases. The test
 * relies on golden files for testing, expecting the scanner to output logs on the {@code
 * System.out}. Please migrate to proper unit tests, as describe in
 * //javatest/jflex/testcase.
 */
// TODO Migrate this test to proper unit tests.
public class FixedlookGoldenTest extends AbstractGoldenTest {

    /**
     * Creates a scanner conforming to the {@code fixedlook.flex} specification.
     */
    private final ScannerFactory<Fixedlook> scannerFactory = ScannerFactory.of(Fixedlook::new);

    private final File testRuntimeDir = new File("javatests/de/jflex/testcase/fixed_look");

    @Test
    public void goldenTest0() throws Exception {
        GoldenInOutFilePair golden = new GoldenInOutFilePair(new File(testRuntimeDir, "fixedlook-0.input"), new File(testRuntimeDir, "fixedlook-0.output"));
        compareSystemOutWith(golden);
        Fixedlook scanner = scannerFactory.createScannerForFile(golden.inputFile);
        while (!scanner.yyatEOF()) {
            System.out.println(scanner.yylex());
        }
    }

    @Test
    public void goldenTest1() throws Exception {
        GoldenInOutFilePair golden = new GoldenInOutFilePair(new File(testRuntimeDir, "fixedlook-1.input"), new File(testRuntimeDir, "fixedlook-1.output"));
        compareSystemOutWith(golden);
        Fixedlook sca

        while (!scanner.yyatEOF()) {
            System.out.println(scanner.yylex());
        }
    }

    @Test
    public void goldenTest2() throws Exception {
        GoldenInOutFilePair golden = new GoldenInOutFilePair(new File(testRuntimeDir, "fixedlook-2.input"), new File(testRuntimeDir, "fixedlook-2.output"));
        compareSystemOutWith(golden);
        Fixedlook scanner = scannerFactory.createScannerForFile(golden.inputFile);
        while (!scanner.yyatEOF()) {
            System.out.println(scanner.yylex());
        }
    }

    @Test
    public void goldenTest3() throws Exception {
        GoldenInOutFilePair golden = new GoldenInOutFilePair(new File(testRuntimeDir, "fixedlook-3.input"), new File(testRuntimeDir, "fixedlook-3.output"));
        compareSystemOutWith(golden);
        Fixedlook scanner = scannerFactory.createScannerForFile(golden.inputFile);
        while (!scanner.yyatEOF()) {
            System.out.println(scanner.yylex());
        }
    }
}


// test: fixedlook
package de.jflex.testcase.fixed_look;

import de.jflex.testing.testsuite.golden.AbstractGoldenTest;
import de.jflex.testing.testsuite.golden.GoldenInOutFilePair;
import de.jflex.util.scanner.ScannerFactory;
import java.io.File;
import org.junit.Test;

/**
 * test fixed length lookahead, e.g. r1 / "some text"
 *
 *
Note: This test was generated from {@code jflex-testsuite-maven-plugin} test cases. The test
 * relies on golden files for testing, expecting the scanner to output logs on the {@code
 * System.out}. Please migrate to proper unit tests, as describe in
 * //javatest/jflex/testcase.
 */
// TODO Migrate this test to proper unit tests.
public class FixedlookGoldenTest extends AbstractGoldenTest {

    /**
     * Creates a scanner conforming to the {@code fixedlook.flex} specification.
     */
    private final ScannerFactory<Fixedlook> scannerFactory = ScannerFactory.of(Fixedlook::new);

    private final File testRuntimeDir = new File("javatests/de/jflex/testcase/fixed_look");

    @Test
    public void goldenTest0() throws Exception {
        GoldenInOutFilePair golden = new GoldenInOutFilePair(new File(testRuntimeDir, "fixedlook-0.input"), new File(testRuntimeDir, "fixedlook-0.output"));
        compareSystemOutWith(golden);
        Fixedlook scanner = scannerFactory.createScannerForFile(golden.inputFile);
        while (!scanner.yyatEOF()) {
            System.out.println(scanner.yylex());
        }
    }

    @Test
    public void goldenTest1() throws Exception {
        GoldenInOutFilePair golden = new GoldenInOutFilePair(new File(testRuntimeDir, "fixedlook-1.input"), new File(testRuntimeDir, "fixedlook-1.output"));
        compareSystemOutWith(golden);
        Fixedlook scanner = scannerFactory.createScannerForFile(golden.inputFile);
        while (!scanner.yyatEOF()) {
            System.out.println(scanner.yylex());
        }
    }

    @Test
    public void goldenTest2() throws Exception {
        GoldenInOutFilePair golden = new GoldenInOutFilePair(new File(testRuntimeDir, "fixedlook-2.input"), new File(testRuntimeDir, "fixedlook-2.output"));
        compareSystemOutWith(golden);
        Fixedlook scanner = scannerFactory.createScannerForFile(golden.inputFile);
        while (!scanner.yyatEOF()) {
            System.out.println(scanner.yylex());
        }
    }

    @Test
    public void goldenTest3() throws Exception {
        GoldenInOutFilePair golden = new GoldenInOutFilePair(new File(testRuntimeDir, "fixedlook-3.input"), new File(testRuntimeDir, "fixedlook-3.output"));
        compareSystemOutWith(golden);
        Fixedlook scanner = scannerFactory.createScannerForFile(golden.inputFile);


package edu.stanford.nlp.ie.crf;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Properties;
import edu.stanford.nlp.util.PropertiesUtils;
import edu.stanford.nlp.util.StringUtils;
import edu.stanford.nlp.util.Timing;

public class TestThreadedCRFClassifier {

    TestThreadedCRFClassifier(Properties props) {
        inputEncoding = props.getProperty("inputEncoding", "UTF-8");
    }

    // number of threads to run the first specified classifier under
    private static final int DEFAULT_SIM_THREADS = 3;

    private static final int DEFAULT_MULTIPLE_THREADS = 2;

    private final String inputEncoding;

    static CRFClassifier loadClassifier(String loadPath, Properties props) {
        CRFClassifier crf = new CRFClassifier(props);
        crf.loadClassifierNoExceptions(loadPath, props);
        return crf;
    }

    String runClassifier(CRFClassifier crf, String testFile) {
        try {
            ByteArrayOutputStream output = new ByteArrayOutputStream();
            crf.classifyAndWriteAnswers(testFile, output, crf.makeReaderAndWriter(), true);
            return output.toString(inputEncoding);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    class CRFThread extends Thread {

        private final CRFClassifier crf;

        private final String filename;

        private final String threadName;

        private String resultsString = "";

        public String getResultsString() {
            return resultsString;
        }

        CRFThread(CRFClassifier crf, String filename, String threadName) {
            this.crf = crf;
            this.filename = filename;
            this.threadName = threadName;
        }

        @Override
        public void run() {
            Timing t = new Timing();
            resultsString = runClassifier(crf, filename);
            long millis = t.stop();
            System.out.println("Thread " + threadName + " took " + millis + "ms to tag file " + filename);
        }
    }

    /**
     * Sample command line:
     * <br>
     * java -mx4g edu.stanford.nlp.ie.crf.TestThreadedCRFClassifier
     * -crf1 ../stanford-releases/stanford-ner-models/hgc_175m_600.ser.gz
     * -crf2 ../stanford-releases/stanford-ner-models/dewac_175m_600.ser.gz
     * -testFile ../data/german-ner/deu.testa -inputEncoding iso-8859-1
     */
    public static void main(String[] args) {
        try {
            System.setOut(new PrintStream(System.out, true, "UTF-8"));
            System.setErr(new PrintStream(System.err, true, "UTF-8"));
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
        runTest(StringUtils.argsToProperties(args));
    }

    static public void runTest(Properties props) {
        TestThreadedCRFClassifier test = new TestThreadedCRFClassifier(props);
        test.runThreadedTest(props);
    }

{
        // TODO: check params
        final String testFile = props.getProperty("testFile");
        ArrayList<String> baseResults = new ArrayList<>();
        ArrayList<String> modelNames = new ArrayList<>();
        ArrayList<CRFClassifier> classifiers = new ArrayList<>();
        for (int i = 1; props.getProperty("crf" + Integer.toString(i)) != null; ++i) {
            String model = props.getProperty("crf" + Integer.toString(i));
            CRFClassifier crf = loadClassifier(model, props);
            System.out.println("Loaded model " + model);
            modelNames.add(model);
            classifiers.add(crf);
            String results = runClassifier(crf, testFile);
            // must run twice to account for "transductive learning"
            results = runClassifier(crf, testFile);
            baseResults.add(results);
            System.out.println("Stored base results for " + model + "; length " + results.length());
        }
        // test to make sure loading and running multiple classifiers
        // hasn't messed with previous results
        for (int i = 0; i < classifiers.size(); ++i) {
            CRFClassifier crf = classifiers.get(i);
            String model = modelNames.get(i);
            String base = baseResults.get(i);
            String repeated = runClassifier(crf, testFile);
            if (!base.equals(repeated)) {
                throw new RuntimeException("Repeated unthreaded results " + "not the same for " + model + " run on file " + testFile);
            }
        }
        // test the first classifier in several simultaneous threads
        int numThreads = PropertiesUtils.getInt(props, "simThreads", DEFAULT_SIM_THREADS);
        ArrayList<CRFThread> threads = new ArrayList<>();
        for (int i = 0; i < numThreads; ++i) {
            threads.add(new CRFThread(classifiers.get(0), testFile, "Simultaneous-" + i));
        }
        for (int i = 0; i < numThreads; ++i) {
            threads.get(i).start();
        }
        for (int i = 0; i < numThreads; ++i) {
            try {
                threads.get(i).join();
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            if (baseResults.get(0).equals(threads.get(i).getResultsString())) {
                System.out.println("Yay!");
            } else {
                throw new RuntimeException("Results not equal when running " + modelNames.get(0) + " under " + numThreads + " simultaneous threads");
            }
        }
        // test multiple classifiers (if given) in multiple threads each
        if (classifiers.size() > 1) {
            numThreads = PropertiesUtils.getInt(props, "multipleThreads", DEFAULT_MULTIPLE_THREADS);
            threads = new ArrayList<CRFThread>();
            for (int i = 0; i < numThreads * classifiers.size(); ++i) {
                int classifierNum = i % classifiers.size();
                int repeatNum = i / classifiers.size();
                threads.add(new CRFThread(classifiers.get(classifierNum), testFile, ("Simultaneous-" + classifierNum + "-" + repeatNum)));
            }
            for (CRFThread thread : threads) {
                thread.start();
            }
            for (int i = 0; i < threads.size(); ++i) {
                int classifierNum = i % classifiers.size();
                int repeatNum = i / classifiers.size();
                try {
                    threads.get(i).join();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                String base = baseResults.get(classifierNum);
                String threadResults = threads.get(i).getResultsString();
                if (base.equals(threadResults)) {
                    System.out.println("Yay!");
                } else {
                    throw new RuntimeException("Results not equal when running " + modelNames.get(classifierNum) + " under " + numThreads + " threads with " + classifiers.size() + " total classifiers");
                }
            }
        }
        // if no exceptions thrown, great success
        System.out.println("Everything worked!");
    }
}


{
        try {
            ByteArrayOutputStream output = new ByteArrayOutputStream();
            crf.classifyAndWriteAnswers(testFile, output, crf.makeReaderAndWriter(), true);
            return output.toString(inputEncoding);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

package edu.stanford.nlp.ie.crf;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Properties;
import edu.stanford.nlp.util.PropertiesUtils;
import edu.stanford.nlp.util.StringUtils;
import edu.stanford.nlp.util.Timing;

public class TestThreadedCRFClassifier {

    TestThreadedCRFClassifier(Properties props) {
        inputEncoding = props.getProperty("inputEncoding", "UTF-8");
    }

    // number of threads to run the first specified classifier under
    private static final int DEFAULT_SIM_THREADS = 3;

    private static final int DEFAULT_MULTIPLE_THREADS = 2;

    private final String inputEncoding;

    static CRFClassifier loadClassifier(String loadPath, Properties props) {
        CRFClassifier crf = new CRFClassifier(props);
        crf.loadClassifierNoExceptions(loadPath, props);
        return crf;
    }

    String runClassifier(CRFClassifier crf, String testFile)

    class CRFThread extends Thread {

        private final CRFClassifier crf;

        private final String filename;

        private final String threadName;

        private String resultsString = "";

        public String getResultsString() {
            return resultsString;
        }

        CRFThread(CRFClassifier crf, String filename, String threadName) {
            this.crf = crf;
            this.filename = filename;
            this.threadName = threadName;
        }

        @Override
        public void run() {
            Timing t = new Timing();
            resultsString = runClassifier(crf, filename);
            long millis = t.stop();
            System.out.println("Thread " + threadName + " took " + millis + "ms to tag file " + filename);
        }
    }

    /**
     * Sample command line:
     * <br>
     * java -mx4g edu.stanford.nlp.ie.crf.TestThreadedCRFClassifier
     * -crf1 ../stanford-releases/stanford-ner-models/hgc_175m_600.ser.gz
     * -crf2 ../stanford-releases/stanford-ner-models/dewac_175m_600.ser.gz
     * -testFile ../data/german-ner/deu.testa -inputEncoding iso-8859-1
     */
    public static void main(String[] args) {
        try {
            System.setOut(new PrintStream(System.out, true, "UTF-8"));
            System.setErr(new PrintStream(System.err, true, "UTF-8"));
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
        runTest(StringUtils.argsToProperties(args));
    }

    static public void runTest(Properties props) {
        TestThreadedCRFClassifier test = new TestThreadedCRFClassifier(props);
        test.runThreadedTest(props);
    }

    void runThreadedTest(Properties props) {
        // TODO: check params
        final String testFile = props.getProperty("testFile");
        ArrayList<String> baseResults = new ArrayList<>();
        ArrayList<String> modelNames = new ArrayList<>();
        ArrayList<CRFClassifier> classifiers = new ArrayList<>();
        for (int i = 1; props.getProperty("crf" + Integer.toString(i)) != null; ++i) {
            String model = props.getProperty("crf" + Integer.toString(i));
            CRFClassifier crf = loadClassifier(model, props);
            System.out.println("Loaded model " + model);
            modelNames.add(model);
            classifiers.add(crf);
            String results = runClassifier(crf, testFile);
            // must run twice to account for "transductive learning"
            results = runClassifier(crf, testFile);
            baseResults.add(results);
            System.out.println("Stored base results for " + model + "; length " + results.length());
        }
        // test to make sure loading and running multiple classifiers
        // hasn't messed with previous results
        for (int i = 0; i < classifiers.size(); ++i) {
            CRFClassifier crf = classifiers.get(i);
            String model = modelNames.get(i);
            String base = baseResults.get(i);
            String repeated = runClassifier(crf, testFile);
            if (!base.equals(repeated)) {
                throw new RuntimeException("Repeated unthreaded results " + "not the same for " + model + " run on file " + testFile);
            }
        }
        // test the first classifier in several simultaneous threads
        int numThreads = PropertiesUtils.getInt(props, "simThreads", DEFAULT_SIM_THREADS);
        ArrayList<CRFThread> threads = new ArrayList<>();
        for (int i = 0; i < numThreads; ++i) {
            threads.add(new CRFThread(classifiers.get(0), testFile, "Simultaneous-" + i));
        }
        for (int i = 0; i < numThreads; ++i) {
            threads.get(i).start();
        }
        for (int i = 0; i < numThreads; ++i) {
            try {
                threads.get(i).join();
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            if (baseResults.get(0).equals(threads.get(i).getResultsString())) {
                System.out.println("Yay!");
            } else {
                throw new RuntimeException("Results not equal when running " + modelNames.get(0) + " under " + numThreads + " simultaneous threads");
            }
        }
        // test multiple classifiers (if given) in multiple threads each
        if (classifiers.size() > 1) {
            numThreads = PropertiesUtils.getInt(props, "multipleThreads", DEFAULT_MULTIPLE_THREADS);
            threads = new ArrayList<CRFThread>();
            for (int i = 0; i < numThreads * classifiers.size(); ++i) {
                int classifierNum = i % classifiers.size();
                int repeatNum = i / classifiers.size();
                threads.add(new CRFThread(classifiers.get(classifierNum), testFile, ("Simultaneous-" + classifierNum + "-" + repeatNum)));
            }
            for (CRFThread thread : threads) {
                thread.start();
            }
            for (int i = 0; i < threads.size(); ++i) {
                int classifierNum = i % classifiers.size();
                int repeatNum = i / classifiers.size();
                try {
                    threads.get(i).join();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                String base = baseResults.get(classifierNum);
                String threadResults = threads.get(i).getResultsString();
                if (base.equals(threadResults)) {
                    System.out.println("Yay!");
                } else {
                    throw new RuntimeException("Results not equal when running " + modelNames.get(classifierNum) + " under " + numThreads + " threads with " + classifiers.size() + " total classifiers");
                }
            }
        }
        // if no exceptions thrown, great success
        System.out.println("Everything worked!");
    }
}


package edu.stanford.nlp.ie.crf;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Properties;
import edu.stanford.nlp.util.PropertiesUtils;
import edu.stanford.nlp.util.StringUtils;
import edu.stanford.nlp.util.Timing;

public class TestThreadedCRFClassifier {

    TestThreadedCRFClassifier(Properties props) {
        inputEncoding = props.getProperty("inputEncoding", "UTF-8");
    }

    // number of threads to run the first specified classifier under
    private static final int DEFAULT_SIM_THREADS = 3;

    private static final int DEFAULT_MULTIPLE_THREADS = 2;

    private final String inputEncoding;

    static CRFClassifier loadClassifier(String loadPath, Properties props) {
        CRFClassifier crf = new CRFClassifier(props);
        crf.loadClassifierNoExceptions(loadPath, props);
        return crf;
    }

    String runClassifier(CRFClassifier crf, String testFile) {
        try {
            ByteArrayOutputStream output = new ByteArrayOutputStream();
            crf.classifyAndWriteAnswers(testFile, output, crf.makeReaderAndWriter(), true);
            return output.toString(inputEncoding);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    class CRFThread extends Thread {

        private final CRFClassifier crf;

        private final String filename;

        private final String threadName;

        private String resultsString = "";

        public String getResultsString() {
            return resultsString;
        }

        CRFThread(CRFClassifier crf, String filename, String threadName) {
            this.crf = crf;
            this.filename = filename;
            this.threadName = threadName;
        }

        @Override
        public void run() {
            Timing t = new Timing();
            resultsString = runClassifier(crf, filename);
            long millis = t.stop();
            System.out.println("Thread " + threadName + " took " + millis + "ms to tag file " + filename);
        }
    }

    /**
     * Sample command line:
     * <br>
     * java -mx4g edu.stanford.nlp.ie.crf.TestThreadedCRFClassifier
     * -crf1 ../stanford-releases/stanford-ner-models/hgc_175m_600.ser.gz
     * -crf2 ../stanford-releases/stanford-ner-models/dewac_175m_600.ser.gz
     * -testFile ../data/german-ner/deu.testa -inputEncoding iso-8859-1
     */
    public static void main(String[] args) {
        try {
            System.setOut(new PrintStream(System.out, true, "UTF-8"));
            System.setErr(new PrintStream(System.err, true, "UTF-8"));
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
        runTest(StringUtils.argsToProperties(args));
    }

    static public void runTest(Properties props) {
        TestThreadedCRFClassifier test = new TestThreadedCRFClassifier(props);
        test.runThreadedTest(props);
    }

    void runThreadedTest(Properties props) {
        // TODO: check params
        final String testFile = props.getProperty("testFile");
        ArrayList<String> baseResults = new ArrayList<>();
        ArrayList<String> modelNames = new ArrayList<>();
        ArrayList<CRFClassifier> classifiers = new ArrayList<>();
        for (int i = 1; props.getProperty("crf" + Integer.toString(i)) != null; ++i) {
            String model = props.getProperty("crf" + Integer.toString(i));
            CRFClassifier crf = loadClassifier(model, props);
            System.out.println("Loaded model " + model);
            modelNames.add(model);
            classifiers.add(crf);
            String results = runClassifier(crf, testFile);
            // must run twice to account for "transductive learning"
            results = runClassifier(crf, testFile);
            baseResults.add(results);
            System.out.println("Stored base results for " + model + "; length " + results.length());
        }
        // test to make sure loading and running multiple classifiers
        // hasn't messed with previous results
        for (int i = 0; i < classifiers.size(); ++i) {
            CRFClassifier crf = classifiers.get(i);
            String model = modelNames.get(i);
            String base = baseResults.get(i);
            String repeated = runClassifier(crf, testFile);
            if (!base.equals(repeated)) {
                throw new RuntimeException("Repeated unthreaded results " + "not the same for " + model + " run on file " + testFile);
            }
        }
        // test the first classifier in several simultaneous threads
        int numThreads = PropertiesUtils.getInt(props, "simThreads", DEFAULT_SIM_THREADS);
        ArrayList<CRFThread> threads = new ArrayList<>();
        for (int i = 0; i < numThreads; ++i) {
            threads.add(new CRFThread(classifiers.get(0), testFile, "Simultaneous-" + i));
        }
        for (int i = 0; i < numThreads; ++i) {
            threads.get(i).start();
        }
        for (int i = 0; i < numThreads; ++i) {
            try {
                threads.get(i).join();
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            if (baseResults.get(0).equals(threads.get(i).getResultsString())) {
                System.out.println("Yay!");
            } else {
                throw new RuntimeException("Results not equal when running " + modelNames.get(0) + " under " + numThreads + " simultaneous threads");
            }
        }
        // test multiple classifiers (if given) in multiple threads each
        if (classifiers.size() > 1) {
            numThreads = PropertiesUtils.getInt(props, "multipleThreads", DEFAULT_MULTIPLE_THREADS);
            threads = new ArrayList<CRFThread>();
            for (int i = 0; i < numThreads * classifiers.size(); ++i) {
                int classifierNum = i % classifiers.size();
                int repeatNum = i / classifiers.size();
                threads.add(new CRFThread(classifiers.get(classifierNum), testFile, ("Simultaneous-" + classifierNum + "-" + repeatNum)));
            }
            for (CRFThread thread : threads) {
                thread.start();
            }
            for (int i = 0; i < threads.size(); ++i) {
                int classifierNum = i % classifiers.size();
                int repeatNum = i / classifiers.size();
                try {
                    threads.get(i).join();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                String base = baseResults.get(classifierNum);
                String threadResults = threads.get(i).getResultsString();
                if (base.equals(threadResults)) {
                    System.out.println("Yay!");
                } else {
                    throw new RuntimeException("Results not equal when running " + modelNames.get(classifierNum) + " under " + numThreads + " threads with " + classifiers.size() + " total classifiers");
                }
            }
        }
        // if no exceptions thrown, great success
        Syste


public static void main(String[] args) {
        try {
            System.setOut(new PrintStream(System.out, true, "UTF-8"));
            System.setErr(new PrintStream(System.err, true, "UTF-8"));
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
        runTest(StringUtils.argsToProperties(args));
    }

package edu.stanford.nlp.ie.crf;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Properties;
import edu.stanford.nlp.util.PropertiesUtils;
import edu.stanford.nlp.util.StringUtils;
import edu.stanford.nlp.util.Timing;

public class TestThreadedCRFClassifier {

    TestThreadedCRFClassifier(Properties props) {
        inputEncoding = props.getProperty("inputEncoding", "UTF-8");
    }

    // number of threads to run the first specified classifier under
    private static final int DEFAULT_SIM_THREADS = 3;

    private static final int DEFAULT_MULTIPLE_THREADS = 2;

    private final String inputEncoding;

    static CRFClassifier loadClassifier(String loadPath, Properties props) {
        CRFClassifier crf = new CRFClassifier(props);
        crf.loadClassifierNoExceptions(loadPath, props);
        return crf;
    }

    String runClassifier(CRFClassifier crf, String testFile) {
        try {
            ByteArrayOutputStream output = new ByteArrayOutputStream();
            crf.classifyAndWriteAnswers(testFile, output, crf.makeReaderAndWriter(), true);
            return output.toString(inputEncoding);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    class CRFThread extends Thread {

        private final CRFClassifier crf;

        private final String filename;

        private final String threadName;

        private String resultsString = "";

        public String getResultsString() {
            return resultsString;
        }

        CRFThread(CRFClassifier crf, String filename, String threadName) {
            this.crf = crf;
            this.filename = filename;
            this.threadName = threadName;
        }

        @Override
        public void run() {
            Timing t = new Timing();
            resultsString = runClassifier(crf, filename);
            long millis = t.stop();
            System.out.println("Thread " + threadName + " took " + millis + "ms to tag file " + filename);
        }
    }

    /**
     * Sample command line:
     * <br>
     * java -mx4g edu.stanford.nlp.ie.crf.TestThreadedCRFClassifier
     * -crf1 ../stanford-releases/stanford-ner-models/hgc_175m_600.ser.gz
     * -crf2 ../stanford-releases/stanford-ner-models/dewac_175m_600.ser.gz
     * -testFile ../data/german-ner/deu.testa -inputEncoding iso-8859-1
     */

    static public void runTest(Properties props) {
        TestThreadedCRFClassifier test = new TestThreadedCRFClassifier(props);
        test.runThreadedTest(props);
    }

    void runThreadedTest(Properties props) {
        // TODO: check params
        final String testFile = props.getProperty("testFile");
        ArrayList<String> baseResults = new ArrayList<>();
        ArrayList<String> modelNames = new ArrayList<>();
        ArrayList<CRFClassifier> classifiers = new ArrayList<>();
        for (int i = 1; props.getProperty("crf" + Integer.toString(i)) != null; ++i) {
            String model = props.getProperty("crf" + Integer.toString(i));
            CRFClassifier crf = loadClassifier(model, props);
            System.out.println("Loaded model " + model);
            modelNames.add(model);
            classifiers.add(crf);
            String results = runClassifier(crf, testFile);
            // must run twice to account for "transductive learning"
            results = runClassifier(crf, testFile);
            baseResults.add(results);
            System.out.println("Stored base results for " + model + "; length " + results.length());
        }
        // test to make sure loading and running multiple classifiers
        // hasn't messed with previous results
        for (int i = 0; i < classifiers.size(); ++i) {
            CRFClassifier crf = classifiers.get(i);
            String model = modelNames.get(i);
            String base = baseResults.get(i);
            String repeated = runClassifier(crf, testFile);
            if (!base.equals(repeated)) {
                throw new RuntimeException("Repeated unthreaded results " + "not the same for " + model + " run on file " + testFile);
            }
        }
        // test the first classifier in several simultaneous threads
        int numThreads = PropertiesUtils.getInt(props, "simThreads", DEFAULT_SIM_THREADS);
        ArrayList<CRFThread> threads = new ArrayList<>();
        for (int i = 0; i < numThreads; ++i) {
            threads.add(new CRFThread(classifiers.get(0), testFile, "Simultaneous-" + i));
        }
        for (int i = 0; i < numThreads; ++i) {
            threads.get(i).start();
        }
        for (int i = 0; i < numThreads; ++i) {
            try {
                threads.get(i).join();
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            if (baseResults.get(0).equals(threads.get(i).getResultsString())) {
                System.out.println("Yay!");
            } else {
                throw new RuntimeException("Results not equal when running " + modelNames.get(0) + " under " + numThreads + " simultaneous threads");
            }
        }
        // test multiple classifiers (if given) in multiple threads each
        if (classifiers.size() > 1) {
            numThreads = PropertiesUtils.getInt(props, "multipleThreads", DEFAULT_MULTIPLE_THREADS);
            threads = new ArrayList<CRFThread>();
            for (int i = 0; i < numThreads * classifiers.size(); ++i) {
                int classifierNum = i % classifiers.size();
                int repeatNum = i / classifiers.size();
                threads.add(new CRFThread(classifiers.get(classifierNum), testFile, ("Simultaneous-" + classifierNum + "-" + repeatNum)));
            }
            for (CRFThread thread : threads) {
                thread.start();
            }
            for (int i = 0; i < threads.size(); ++i) {
                int classifierNum = i % classifiers.size();
                int repeatNum = i / classifiers.size();
                try {
                    threads.get(i).join();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                String base = baseResults.get(classifierNum);
                String threadResults = threads.get(i).getResultsString();
                if (base.equals(threadResults)) {
                    System.out.println("Yay!");
                } else {
                    throw new RuntimeException("Results not equal when running " + modelNames.get(classifierNum) + " under " + numThreads + " threads with " + classifiers.size() + " total classifiers");
                }
            }
        }
        // if no exceptions thrown, great success
        System.out.println("Everything worked!");
    }
}


for (int i = 0; i < numThreads * classifiers.size(); ++i) {
                int classifierNum = i % classifiers.size();
                int repeatNum = i / classifiers.size();
                threads.add(new CRFThread(classifiers.get(classifierNum), testFile, ("Simultaneous-" + classifierNum + "-" + repeatNum)));
            }

package edu.stanford.nlp.ie.crf;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Properties;
import edu.stanford.nlp.util.PropertiesUtils;
import edu.stanford.nlp.util.StringUtils;
import edu.stanford.nlp.util.Timing;

public class TestThreadedCRFClassifier {

    TestThreadedCRFClassifier(Properties props) {
        inputEncoding = props.getProperty("inputEncoding", "UTF-8");
    }

    // number of threads to run the first specified classifier under
    private static final int DEFAULT_SIM_THREADS = 3;

    private static final int DEFAULT_MULTIPLE_THREADS = 2;

    private final String inputEncoding;

    static CRFClassifier loadClassifier(String loadPath, Properties props) {
        CRFClassifier crf = new CRFClassifier(props);
        crf.loadClassifierNoExceptions(loadPath, props);
        return crf;
    }

    String runClassifier(CRFClassifier crf, String testFile) {
        try {
            ByteArrayOutputStream output = new ByteArrayOutputStream();
            crf.classifyAndWriteAnswers(testFile, output, crf.makeReaderAndWriter(), true);
            return output.toString(inputEncoding);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    class CRFThread extends Thread {

        private final CRFClassifier crf;

        private final String filename;

        private final String threadName;

        private String resultsString = "";

        public String getResultsString() {
            return resultsString;
        }

        CRFThread(CRFClassifier crf, String filename, String threadName) {
            this.crf = crf;
            this.filename = filename;
            this.threadName = threadName;
        }

        @Override
        public void run() {
            Timing t = new Timing();
            resultsString = runClassifier(crf, filename);
            long millis = t.stop();
            System.out.println("Thread " + threadName + " took " + millis + "ms to tag file " + filename);
        }
    }

    /**
     * Sample command line:
     * <br>
     * java -mx4g edu.stanford.nlp.ie.crf.TestThreadedCRFClassifier
     * -crf1 ../stanford-releases/stanford-ner-models/hgc_175m_600.ser.gz
     * -crf2 ../stanford-releases/stanford-ner-models/dewac_175m_600.ser.gz
     * -testFile ../data/german-ner/deu.testa -inputEncoding iso-8859-1
     */
    public static void main(String[] args) {
        try {
            System.setOut(new PrintStream(System.out, true, "UTF-8"));
            System.setErr(new PrintStream(System.err, true, "UTF-8"));
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
        runTest(StringUtils.argsToProperties(args));
    }

    static public void runTest(Properties props) {
        TestThreadedCRFClassifier test = new TestThreadedCRFClassifier(props);
        test.runThreadedTest(props);
    }

    void runThreadedTest(Properties props) {
        // TODO: check params
        final String testFile = props.getProperty("testFile");
        ArrayList<String> baseResults = new ArrayList<>();
        ArrayList<String> modelNames = new ArrayList<>();
        ArrayList<CRFClassifier> classifiers = new ArrayList<>();
        for (int i = 1; props.getProperty("crf" + Integer.toString(i)) != null; ++i) {
            String model = props.getProperty("crf" + Integer.toString(i));
            CRFClassifier crf = loadClassifier(model, props);
            System.out.println("Loaded model " + model);
            modelNames.add(model);
            classifiers.add(crf);
            String results = runClassifier(crf, testFile);
            // must run twice to account for "transductive learning"
            results = runClassifier(crf, testFile);
            baseResults.add(results);
            System.out.println("Stored base results for " + model + "; length " + results.length());
        }
        // test to make sure loading and running multiple classifiers
        // hasn't messed with previous results
        for (int i = 0; i < classifiers.size(); ++i) {
            CRFClassifier crf = classifiers.get(i);
            String model = modelNames.get(i);
            String base = baseResults.get(i);
            String repeated = runClassifier(crf, testFile);
            if (!base.equals(repeated)) {
                throw new RuntimeException("Repeated unthreaded results " + "not the same for " + model + " run on file " + testFile);
            }
        }
        // test the first classifier in several simultaneous threads
        int numThreads = PropertiesUtils.getInt(props, "simThreads", DEFAULT_SIM_THREADS);
        ArrayList<CRFThread> threads = new ArrayList<>();
        for (int i = 0; i < numThreads; ++i) {
            threads.add(new CRFThread(classifiers.get(0), testFile, "Simultaneous-" + i));
        }
        for (int i = 0; i < numThreads; ++i) {
            threads.get(i).start();
        }
        for (int i = 0; i < numThreads; ++i) {
            try {
                threads.get(i).join();
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            if (baseResults.get(0).equals(threads.get(i).getResultsString())) {
                System.out.println("Yay!");
            } else {
                throw new RuntimeException("Results not equal when running " + modelNames.get(0) + " under " + numThreads + " simultaneous threads");
            }
        }
        // test multiple classifiers (if given) in multiple threads each
        if (classifiers.size() > 1) {
            numThreads = PropertiesUtils.getInt(props, "multipleThreads", DEFAULT_MULTIPLE_THREADS);
            threads = new ArrayList<CRFThread>();

            for (CRFThread thread : threads) {
                thread.start();
            }
            for (int i = 0; i < threads.size(); ++i) {
                int classifierNum = i % classifiers.size();
                int repeatNum = i / classifiers.size();
                try {
                    threads.get(i).join();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                String base = baseResults.get(classifierNum);
                String threadResults = threads.get(i).getResultsString();
                if (base.equals(threadResults)) {
                    System.out.println("Yay!");
                } else {
                    throw new RuntimeException("Results not equal when running " + modelNames.get(classifierNum) + " under " + numThreads + " threads with " + classifiers.size() + " total classifiers");
                }
            }
        }
        // if no exceptions thrown, great success
        System.out.println("Everything worked!");
    }
}


package edu.stanford.nlp.ie.crf;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Properties;
import edu.stanford.nlp.util.PropertiesUtils;
import edu.stanford.nlp.util.StringUtils;
import edu.stanford.nlp.util.Timing;

public class TestThreadedCRFClassifier {

    TestThreadedCRFClassifier(Properties props) {
        inputEncoding = props.getProperty("inputEncoding", "UTF-8");
    }

    // number of threads to run the first specified classifier under
    private static final int DEFAULT_SIM_THREADS = 3;

    private static final int DEFAULT_MULTIPLE_THREADS = 2;

    private final String inputEncoding;

    static CRFClassifier loadClassifier(String loadPath, Properties props) {
        CRFClassifier crf = new CRFClassifier(props);
        crf.loadClassifierNoExceptions(loadPath, props);
        return crf;
    }

    String runClassifier(CRFClassifier crf, String testFile) {
        try {
            ByteArrayOutputStream output = new ByteArrayOutputStream();
            crf.classifyAndWriteAnswers(testFile, output, crf.makeReaderAndWriter(), true);
            return output.toString(inputEncoding);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    class CRFThread extends Thread {

        private final CRFClassifier crf;

        private final String filename;

        private final String threadName;

        private String resultsString = "";

        public String getResultsString() {
            return resultsString;
        }

        CRFThread(CRFClassifier crf, String filename, String threadName) {
            this.crf = crf;
            this.filename = filename;
            this.threadName = threadName;
        }

        @Override
        public void run() {
            Timing t = new Timing();
            resultsString = runClassifier(crf, filename);
            long millis = t.stop();
            System.out.println("Thread " + threadName + " took " + millis + "ms to tag file " + filename);
        }
    }

    /**
     * Sample command line:
     * <br>
     * java -mx4g edu.stanford.nlp.ie.crf.TestThreadedCRFClassifier
     * -crf1 ../stanford-releases/stanford-ner-models/hgc_175m_600.ser.gz
     * -crf2 ../stanford-releases/stanford-ner-models/dewac_175m_600.ser.gz
     * -testFile ../data/german-ner/deu.testa -inputEncoding iso-8859-1
     */
    public static void main(String[] args) {
        try {
            System.setOut(new PrintStream(System.out, true, "UTF-8"));
            System.setErr(new PrintStream(System.err, true, "UTF-8"));
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
        runTest(StringUtils.argsToProperties(args));
    }

    static public void runTest(Properties props) {
        TestThreadedCRFClassifier test = new TestThreadedCRFClassifier(props);
        test.runThreadedTest(props);
    }

    void runThreadedTest(Properties props) {
        // TODO: check params
        final String testFile = props.getProperty("testFile");
        ArrayList<String> baseResults = new ArrayList<>();
        ArrayList<String> modelNames = new ArrayList<>();
        ArrayList<CRFClassifier> classifiers = new ArrayList<>();
        for (int i = 1; props.getProperty("crf" + Integer.toString(i)) != null; ++i) {
            String model = props.getProperty("crf" + Integer.toString(i));
            CRFClassifier crf = loadClassifier(model, props);
            System.out.println("Loaded model " + model);
            modelNames.add(model);
            classifiers.add(crf);
            String results = runClassifier(crf, testFile);
            // must run twice to account for "transductive learning"
            results = runClassifier(crf, testFile);
            baseResults.add(results);
            System.out.println("Stored base results for " + model + "; length " + results.length());
        }
        // test to make sure loading and running multiple classifiers
        // hasn't messed with previous results
        for (int i = 0; i < classifiers.size(); ++i) {
            CRFClassifier crf = classifiers.get(i);
            String model = modelNames.get(i);
            String base = baseResults.get(i);
            String repeated = runClassifier(crf, testFile);
            if (!base.equals(repeated)) {
                throw new RuntimeException("Repeated unthreaded results " + "not the same for " + model + " run on file " + testFile);
            }
        }
        // test the first classifier in several simultaneous threads
        int numThreads = PropertiesUtils.getInt(props, "simThreads", DEFAULT_SIM_THREADS);
        ArrayList<CRFThread> threads = new ArrayList<>();
        for (int i = 0; i < numThreads; ++i) {
            threads.add(new CRFThread(classifiers.get(0), testFile, "Simultaneous-" + i));
        }
        for (int i = 0; i < numThreads; ++i) {
            threads.get(i).start();
        }
        for (int i = 0; i < numThreads; ++i) {

            if (baseResults.get(0).equals(threads.get(i).getResultsString())) {
                System.out.println("Yay!");
            } else {
                throw new RuntimeException("Results not equal when running " + modelNames.get(0) + " under " + numThreads + " simultaneous threads");
            }
        }
        // test multiple classifiers (if given) in multiple threads each
        if (classifiers.size() > 1) {
            numThreads = PropertiesUtils.getInt(props, "multipleThreads", DEFAULT_MULTIPLE_THREADS);
            threads = new ArrayList<CRFThread>();
            for (int i = 0; i < numThreads * classifiers.size(); ++i) {
                int classifierNum = i % classifiers.size();
                int repeatNum = i / classifiers.size();
                threads.add(new CRFThread(classifiers.get(classifierNum), testFile, ("Simultaneous-" + classifierNum + "-" + repeatNum)));
            }
            for (CRFThread thread : threads) {
                thread.start();
            }
            for (int i = 0; i < threads.size(); ++i) {
                int classifierNum = i % classifiers.size();
                int repeatNum = i / classifiers.size();
                try {
                    threads.get(i).join();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                String base = baseResults.get(classifierNum);
                String threadResults = threads.get(i).getResultsString();
                if (base.equals(threadResults)) {
                    System.out.println("Yay!");
                } else {
                    throw new RuntimeException("Results not equal when running " + modelNames.get(classifierNum) + " under " + numThreads + " threads with " + classifiers.size() + " total classifiers");
                }
            }
        }
        // if no exceptions thrown, great success
        System.out.println("Everything worked!");
    }
}


package com.journaldev.array;

public class StringToStringArray {

    /**
     * This class shows how to convert String to String Array in java
     * @param args
     */


package com.journaldev.array;

public class StringToStringArray {

    /**
     * This class shows how to convert String to String Array in java
     * @param args
     */
    public static void main(String[] args)


public static void main(String[] args) {
    }


package arc.math;

/**
 * Track properties of a stream of float values. The properties (total value, minimum, etc) are updated as values are
 * {@link #put(float)} into the stream.
 * @author xoppa
 */
public class FloatCounter {

    /**
     * Provides access to the WindowedMean if any (can be null)
     */
    public final WindowedMean mean;

    /**
     * The amount of values added
     */
    public int count;

    /**
     * The sum of all values
     */
    public float total;

    /**
     * The smallest value
     */
    public float min;

    /**
     * The largest value
     */
    public float max;

    /**
     * The average value (total / count)
     */
    public float average;

    /**
     * The latest raw value
     */
    public float latest;

    /**
     * The current windowed mean value
     */
    public float value;

    /**
     * Construct a new FloatCounter
     * @param windowSize The size of the mean window or 1 or below to not use a windowed mean.
     */
    public FloatCounter(int windowSize) {
        mean = (windowSize > 1) ? new WindowedMean(windowSize) : null;
        reset();
    }

    /**
     * Add a value and update all fields.
     * @param value The value to add
     */
    public void put(float value) {
        latest = value;
        total += value;
        count++;
        average = total / count;
        if (mean != null) {
            mean.add(value);
            this.value = mean.mean();
        } else
            this.value = latest;
        if (mean == null || mean.hasEnoughData()) {
            if (this.value < min)
                min = this.value;
            if (this.value > max)
                max = this.value;
        }
    }

    /**
     * Reset all values to their default value.
     */

{
        count = 0;
        total = 0f;
        min = Float.MAX_VALUE;
        max = Float.MIN_VALUE;
        average = 0f;
        latest = 0f;
        value = 0f;
        if (mean != null)
            mean.clear();
    }
}


{
        latest = value;
        total += value;
        count++;
        average = total / count;
        if (mean != null) {
            mean.add(value);
            this.value = mean.mean();
        } else
            this.value = latest;
        if (mean == null || mean.hasEnoughData()) {
            if (this.value < min)
                min = this.value;
            if (this.value > max)
                max = this.value;
        }
    }

package arc.math;

/**
 * Track properties of a stream of float values. The properties (total value, minimum, etc) are updated as values are
 * {@link #put(float)} into the stream.
 * @author xoppa
 */
public class FloatCounter {

    /**
     * Provides access to the WindowedMean if any (can be null)
     */
    public final WindowedMean mean;

    /**
     * The amount of values added
     */
    public int count;

    /**
     * The sum of all values
     */
    public float total;

    /**
     * The smallest value
     */
    public float min;

    /**
     * The largest value
     */
    public float max;

    /**
     * The average value (total / count)
     */
    public float average;

    /**
     * The latest raw value
     */
    public float latest;

    /**
     * The current windowed mean value
     */
    public float value;

    /**
     * Construct a new FloatCounter
     * @param windowSize The size of the mean window or 1 or below to not use a windowed mean.
     */
    public FloatCounter(int windowSize) {
        mean = (windowSize > 1) ? new WindowedMean(windowSize) : null;
        reset();
    }

    /**
     * Add a value and update all fields.
     * @param value The value to add
     */
    public void put(float value)

    /**
     * Reset all values to their default value.
     */
    public void reset() {
        count = 0;
        total = 0f;
        min = Float.MAX_VALUE;
        max = Float.MIN_VALUE;
        average = 0f;
        latest = 0f;
        value = 0f;
        if (mean != null)
            mean.clear();
    }
}


package arc.math;

/**
 * Track properties of a stream of float values. The properties (total value, minimum, etc) are updated as values are
 * {@link #put(float)} into the stream.
 * @author xoppa
 */
public class FloatCounter {

    /**
     * Provides access to the WindowedMean if any (can be null)
     */
    public final WindowedMean mean;

    /**
     * The amount of values added
     */
    public int count;

    /**
     * The sum of all values
     */
    public float total;

    /**
     * The smallest value
     */
    public float min;

    /**
     * The largest value
     */
    public float max;

    /**
     * The average value (total / count)
     */
    public float average;

    /**
     * The latest raw value
     */
    public float latest;

    /**
     * The current windowed mean value
     */
    public float value;

    /**
     * Construct a new FloatCounter
     * @param windowSize The size of the mean window or 1 or below to not use a windowed mean.
     */
    public FloatCounter(int windowSize) {
        mean = (windowSize > 1) ? new WindowedMean(windowSize) : null;
        reset();
    }

    /**
     * Add a value and update all fields.
     * @param value The value to add
     */
    public void put(float value) {
        latest = value;
        total += value;
        count++;
        average = total / count;
        if (mean != null) {
            mean.add(value);
            this.value = mean.mean();
        } else
            this.value = latest;
        if (mean == null || mean.hasEnoughData()) {
            if (this.value < min)
                min = this.value;
            if (this.value > max)
                max = this.value;
        }
    }

    /**
     * Reset all values to their default value.
     */
    public void reset() {
        count = 0;
        total = 0f;
        min = Float.MAX_VALUE;
        max = Float.MIN_VALUE;
        average = 0f

        latest = 0f;
        value = 0f;
        if (mean != null)
            mean.clear();
    }
}


public void put(float value) {
        latest = value;
        total += value;
        count++;
        average = total / count;
        if (mean != null) {
            mean.add(value);
            this.value = mean.mean();
        } else
            this.value = latest;
        if (mean == null || mean.hasEnoughData()) {
            if (this.value < min)
                min = this.value;
            if (this.value > max)
                max = this.value;
        }
    }

package arc.math;

/**
 * Track properties of a stream of float values. The properties (total value, minimum, etc) are updated as values are
 * {@link #put(float)} into the stream.
 * @author xoppa
 */
public class FloatCounter {

    /**
     * Provides access to the WindowedMean if any (can be null)
     */
    public final WindowedMean mean;

    /**
     * The amount of values added
     */
    public int count;

    /**
     * The sum of all values
     */
    public float total;

    /**
     * The smallest value
     */
    public float min;

    /**
     * The largest value
     */
    public float max;

    /**
     * The average value (total / count)
     */
    public float average;

    /**
     * The latest raw value
     */
    public float latest;

    /**
     * The current windowed mean value
     */
    public float value;

    /**
     * Construct a new FloatCounter
     * @param windowSize The size of the mean window or 1 or below to not use a windowed mean.
     */
    public FloatCounter(int windowSize) {
        mean = (windowSize > 1) ? new WindowedMean(windowSize) : null;
        reset();
    }

    /**
     * Add a value and update all fields.
     * @param value The value to add
     */


/**
 * ****************************************************************************
 *
 *  Contributors:
 *    Christoph Kulla - Initial API and implementation
 * *****************************************************************************
 */
package org.eclipse.xtext.ui.editor.hover.html;

import org.eclipse.core.runtime.Assert;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.internal.text.html.BrowserInformationControlInput;
import org.eclipse.jface.viewers.ILabelProvider;

// Clone from JavadocBrowserInformationControlInput. Following changes have been made:
// - Changed type of fElement from IJavaElement to EObject.
// - Removed fLeadingImageWidth, leading images are not yet supported by the XtextHtmlHover
// - getInputName requires an labelProvider to retrieve the EObjects name.
public class XtextBrowserInformationControlInput extends BrowserInformationControlInput {

    private final EObject fElement;

    private final String fHtml;

    private final ILabelProvider fLabelProvider;

    /**
     * Creates a new browser information control input.
     *
     * @param previous
     *            previous input, or null if none available
     * @param element
     *            the element, or null if none available
     * @param html
     *            HTML contents, must not be null
     * @param labelProvider
     *            used to determinate the input name {@link #getInputName()}.
     */
    public XtextBrowserInformationControlInput(XtextBrowserInformationControlInput previous, EObject element, String html, ILabelProvider labelProvider) {
        super(previous);
        Assert.isNotNull(html);
        fElement = element;
        fHtml = html;
        fLabelProvider = labelProvider;
    }

    @Override
    public int getLeadingImageWidth() {
        return 16;
    }

    public EObject getElement() {
        return fElement;
    }

{
        return fHtml;
    }

    @Override
    public Object getInputElement() {
        return fElement;
    }

    @Override
    public String getInputName() {
        if (fLabelProvider == null)
            return "no label provider";
        return fLabelProvider.getText(fElement);
    }
}


/**
 * ****************************************************************************
 *
 *  Contributors:
 *    Christoph Kulla - Initial API and implementation
 * *****************************************************************************
 */
package org.eclipse.xtext.ui.editor.hover.html;

import org.eclipse.core.runtime.Assert;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.internal.text.html.BrowserInformationControlInput;
import org.eclipse.jface.viewers.ILabelProvider;

// Clone from JavadocBrowserInformationControlInput. Following changes have been made:
// - Changed type of fElement from IJavaElement to EObject.
// - Removed fLeadingImageWidth, leading images are not yet supported by the XtextHtmlHover
// - getInputName requires an labelProvider to retrieve the EObjects name.
public class XtextBrowserInformationControlInput extends BrowserInformationControlInput {

    private final EObject fElement;

    private final String fHtml;

    private final ILabelProvider fLabelProvider;

    /**
     * Creates a new browser information control input.
     *
     * @param previous
     *            previous input, or null if none available
     * @param element
     *            the element, or null if none available
     * @param html
     *            HTML contents, must not be null
     * @param labelProvider
     *            used to determinate the input name {@link #getInputName()}.
     */
    public XtextBrowserInformationControlInput(XtextBrowserInformationControlInput previous, EObject element, String html, ILabelProvider labelProvider) {
        super(previous);
        Assert.isNotNull(html);
        fElement = element;
        fHtml = html;
        fLabelProvider = labelProvider;
    }

    @Override
    public int getLeadingImageWidth()

    public EObject getElement() {
        return fElement;
    }

    @Override
    public String getHtml() {
        return fHtml;
    }

    @Override
    public Object getInputElement() {
        return fElement;
    }

    @Override
    public String getInputName() {
        if (fLabelProvider == null)
            return "no label provider";
        return fLabelProvider.getText(fElement);
    }
}


/**
 * ****************************************************************************
 *
 *  Contributors:
 *    Christoph Kulla - Initial API and implementation
 * *****************************************************************************
 */
package org.eclipse.xtext.ui.editor.hover.html;

import org.eclipse.core.runtime.Assert;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.internal.text.html.BrowserInformationControlInput;
import org.eclipse.jface.viewers.ILabelProvider;

// Clone from JavadocBrowserInformationControlInput. Following changes have been made:
// - Changed type of fElement from IJavaElement to EObject.
// - Removed fLeadingImageWidth, leading images are not yet supported by the XtextHtmlHover
// - getInputName requires an labelProvider to retrieve the EObjects name.
public class XtextBrowserInformationControlInput extends BrowserInformationControlInput {

    private final EObject fElement;

    private final String fHtml;

    private final ILabelProvider fLabelProvider;

    /**
     * Creates a new browser information control input.
     *
     * @param previous
     *            previous input, or null if none available
     * @param element
     *            the element, or null if none available
     * @param html
     *            HTML contents, must not be null
     * @param labelProvider
     *            used to determinate the input name {@link #getInputName()}.
     */
    public XtextBrowserInformationControlInput(XtextBrowserInformationControlInput previous, EObject element, String html, ILabelProvider labelProvider) {
        super(previous);
        Assert.isNotNull(html);
        fElement = element;
        fHtml = html;
        fLabelProvider = labelProvider;
    }

    @Override
    public int getLeadingImageWidth() {
        return 16;
    }

    public EObject getElement() {
        return fElement;
    }

    @Override
    public String getHtml() {
        return fHtml;
    }

    @Override
    public Object getInputElement() {
        return f

    }

    @Override
    public String getInputName() {
        if (fLabelProvider == null)
            return "no label provider";
        return fLabelProvider.getText(fElement);
    }
}


@Override
    protected Problem getProblem(RequiredObjectRelationshipException requiredObjectRelationshipException)

package com.liferay.object.rest.internal.jaxrs.exception.mapper;

import com.liferay.object.exception.RequiredObjectRelationshipException;
import com.liferay.portal.vulcan.jaxrs.exception.mapper.BaseExceptionMapper;
import com.liferay.portal.vulcan.jaxrs.exception.mapper.Problem;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.Provider;

/**
 * @author Marco Leo
 */
@Provider
public class RequiredObjectRelationshipExceptionMapper extends BaseExceptionMapper<RequiredObjectRelationshipException> {

{
        return new Problem(Response.Status.BAD_REQUEST, requiredObjectRelationshipException.getMessage());
    }
}


{
        return new Problem(Response.Status.BAD_REQUEST, requiredObjectRelationshipException.getMessage());
    }

package com.liferay.object.rest.internal.jaxrs.exception.mapper;

import com.liferay.object.exception.RequiredObjectRelationshipException;
import com.liferay.portal.vulcan.jaxrs.exception.mapper.BaseExceptionMapper;
import com.liferay.portal.vulcan.jaxrs.exception.mapper.Problem;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.Provider;

/**
 * @author Marco Leo
 */
@Provider
public class RequiredObjectRelationshipExceptionMapper extends BaseExceptionMapper<RequiredObjectRelationshipException> {

    @Override
    protected Problem getProblem(RequiredObjectRelationshipException requiredObjectRelationshipException)