<commit_before>/*
// Licensed to <NAME> under one or more contributor license
// agreements. See the NOTICE file distributed with this work for
// additional information regarding copyright ownership.
//
// <NAME> licenses this file to you under the Apache License,
// Version 2.0 (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at:
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
*/
package org.eigenbase.util;

import java.awt.Toolkit;
import java.io.*;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.math.*;
import java.net.*;
import java.nio.charset.*;
import java.sql.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.jar.*;
import java.util.logging.*;
import java.util.regex.*;

import net.hydromatic.linq4j.Ord;

import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableMap;

/**
 * Miscellaneous utility functions.
 */
public class Util {
  private Util() {}

  //~ Static fields/initializers ---------------------------------------------

  /**
   * Name of the system property that controls whether the AWT work-around is
   * enabled. This workaround allows Farrago to load its native libraries
   * despite a conflict with AWT and allows applications that use AWT to
   * function normally.
   *
   * @see #loadLibrary(String)
   */
  public static final String AWT_WORKAROUND_PROPERTY =
      "org.eigenbase.util.AWT_WORKAROUND";

  /**
   * System-dependent newline character.
   */
  public static final String LINE_SEPARATOR =
      System.getProperty("line.separator");

  /**
   * System-dependent file separator, for example, "/" or "\."
   */
  public static final String FILE_SEPARATOR =
      System.getProperty("file.separator");

  /**
   * Datetime format string for generating a timestamp string to be used as
   * part of a filename. Conforms to SimpleDateFormat conventions.
   */
  public static final String FILE_TIMESTAMP_FORMAT = "yyyy-MM-dd_HH_mm_ss";

  private static boolean driversLoaded = false;

  /**
   * Regular expression for a valid java identifier which contains no
   * underscores and can therefore be returned intact by {@link #toJavaId}.
   */
  private static final Pattern JAVA_ID_PATTERN =
      Pattern.compile("[a-zA-Z_$][a-zA-Z0-9$]*");

  /**
   * @see #loadLibrary(String)
   */
  private static Toolkit awtToolkit;

  /**
   * Maps classes to the map of their enum values. Uses a weak map so that
   * classes are not prevented from being unloaded.
   */
  private static final LoadingCache<Class, Map<String, Enum>> ENUM_CONSTANTS =
      CacheBuilder.<Class, Map<String, Enum>>newBuilder()
          .weakKeys()
          .build(
              new CacheLoader<Class, Map<String, Enum>>() {
                @Override
                public Map<String, Enum> load(Class clazz) {
                  //noinspection unchecked
                  return enumConstants(clazz);
                }
              });

  public static final String[] SPACES = {
    "",
    " ",
    "  ",
    "   ",
    "    ",
    "     ",
    "      ",
    "       ",
    "        ",
  };

  //~ Methods ----------------------------------------------------------------

  /**
   * Does nothing with its argument. Call this method when you have a value<commit_msg>Fix compile error on JDK 1.6.<commit_after>/*
// Licensed to <NAME> under one or more contributor license
// agreements. See the NOTICE file distributed with this work for
// additional information regarding copyright ownership.
//
// <NAME> licenses this file to you under the Apache License,
// Version 2.0 (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at:
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
*/
package org.eigenbase.util;

import java.awt.Toolkit;
import java.io.*;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.math.*;
import java.net.*;
import java.nio.charset.*;
import java.sql.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.jar.*;
import java.util.logging.*;
import java.util.regex.*;

import net.hydromatic.linq4j.Ord;

import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableMap;

/**
 * Miscellaneous utility functions.
 */
public class Util {
  private Util() {}

  //~ Static fields/initializers ---------------------------------------------

  /**
   * Name of the system property that controls whether the AWT work-around is
   * enabled. This workaround allows Farrago to load its native libraries
   * despite a conflict with AWT and allows applications that use AWT to
   * function normally.
   *
   * @see #loadLibrary(String)
   */
  public static final String AWT_WORKAROUND_PROPERTY =
      "org.eigenbase.util.AWT_WORKAROUND";

  /**
   * System-dependent newline character.
   */
  public static final String LINE_SEPARATOR =
      System.getProperty("line.separator");

  /**
   * System-dependent file separator, for example, "/" or "\."
   */
  public static final String FILE_SEPARATOR =
      System.getProperty("file.separator");

  /**
   * Datetime format string for generating a timestamp string to be used as
   * part of a filename. Conforms to SimpleDateFormat conventions.
   */
  public static final String FILE_TIMESTAMP_FORMAT = "yyyy-MM-dd_HH_mm_ss";

  private static boolean driversLoaded = false;

  /**
   * Regular expression for a valid java identifier which contains no
   * underscores and can therefore be returned intact by {@link #toJavaId}.
   */
  private static final Pattern JAVA_ID_PATTERN =
      Pattern.compile("[a-zA-Z_$][a-zA-Z0-9$]*");

  /**
   * @see #loadLibrary(String)
   */
  private static Toolkit awtToolkit;

  /**
   * Maps classes to the map of their enum values. Uses a weak map so that
   * classes are not prevented from being unloaded.
   */
  private static final LoadingCache<Class, Map<String, Enum>> ENUM_CONSTANTS =
      CacheBuilder.newBuilder()
          .weakKeys()
          .build(
              new CacheLoader<Class, Map<String, Enum>>() {
                @Override
                public Map<String, Enum> load(Class clazz) {
                  //noinspection unchecked
                  return enumConstants(clazz);
                }
              });

  public static final String[] SPACES = {
    "",
    " ",
    "  ",
    "   ",
    "    ",
    "     ",
    "      ",
    "       ",
    "        ",
  };

  //~ Methods ----------------------------------------------------------------

  /**
   * Does nothing with its argument. Call this method when you have a value
{'fraction_non_alphanumeric': 0.13096179183135706, 'fraction_numerical': 0.002108036890645586, 'mean_word_length': 2.5538389513108615, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '246073', 'n_tokens_mistral': 2101, 'n_tokens_neox': 2032, 'n_words': 708}