<commit_before>/**
 * com.mckoi.appcore.FileName  Oct 25, 2012
 *
 * Mckoi Database Software ( http://www.mckoi.com/ )
 * Copyright (C) 2000 - 2012  Diehl and Associates, Inc.
 *
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 3 as published by
 * the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License version 3
 * along with this program.  If not, see ( http://www.gnu.org/licenses/ ) or
 * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA  02111-1307, USA.
 *
 * Change Log:
 *
 *
 */

package com.mckoi.odb.util;

import java.net.URI;
import java.net.URISyntaxException;

/**
 * A universal reference to an object (a file or directory) in a file system
 * (represented by a repository id). A file name will follow one of the
 * formats below;
 * <pre>
 *  /[repository id]/[path]/[file name]
 *  /[repository id]/[path]/
 *  /[repository id]/[file name]
 *  /[repository id]/
 * </pre>
 * <p>
 * A directory will always be represented by a name that ends with a '/'
 * (although, a name that doesn't end with a '/' may also be a directory). If
 * the name starts with a '/' it means the reference is ABSOLUTE, otherwise
 * the reference is RELATIVE. A relative name must be resolved before it can
 * be access.
 *
 * @author <NAME>
 */

public class FileName {

  /**
   * The file identifier string.
   */
  private final String file;
  
  /**
   * Constructor.
   */
  public FileName(String file) {
    if (file == null) throw new NullPointerException();
    this.file = file;
  }

  /**
   * Constructor.
   */
  public FileName(String repository_id, String path_file) {

    if (path_file == null) throw new NullPointerException();
    if (repository_id == null) throw new NullPointerException();
    if (repository_id.length() < 1) throw new IllegalArgumentException();

    if (path_file.length() > 0 && !path_file.startsWith("/")) {
      throw new RuntimeException("'path_file' must be absolute");
    }

    StringBuilder b = new StringBuilder();
    b.append("/");
    b.append(repository_id);
    b.append(path_file);

    this.file = b.toString();
  }

  /**<commit_msg>FileName PREVIOUS_DIR and CURRENT_DIR statics.<commit_after>/**
 * com.mckoi.appcore.FileName  Oct 25, 2012
 *
 * Mckoi Database Software ( http://www.mckoi.com/ )
 * Copyright (C) 2000 - 2012  <NAME> Associates, Inc.
 *
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 3 as published by
 * the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License version 3
 * along with this program.  If not, see ( http://www.gnu.org/licenses/ ) or
 * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA  02111-1307, USA.
 *
 * Change Log:
 *
 *
 */

package com.mckoi.odb.util;

import java.net.URI;
import java.net.URISyntaxException;

/**
 * A universal reference to an object (a file or directory) in a file system
 * (represented by a repository id). A file name will follow one of the
 * formats below;
 * <pre>
 *  /[repository id]/[path]/[file name]
 *  /[repository id]/[path]/
 *  /[repository id]/[file name]
 *  /[repository id]/
 * </pre>
 * <p>
 * A directory will always be represented by a name that ends with a '/'
 * (although, a name that doesn't end with a '/' may also be a directory). If
 * the name starts with a '/' it means the reference is ABSOLUTE, otherwise
 * the reference is RELATIVE. A relative name must be resolved before it can
 * be access.
 *
 * @author <NAME>
 */

public class FileName {

  /**
   * The file identifier string.
   */
  private final String file;

  /**
   * The previous directory.
   */
  public static final FileName PREVIOUS_DIR = new FileName("../");

  /**
   * The current directory.
   */
  public static final FileName CURRENT_DIR = new FileName("./");

  /**
   * Constructor.
   */
  public FileName(String file) {
    if (file == null) throw new NullPointerException();
    this.file = file;
  }

  /**
   * Constructor.
   */
  public FileName(String repository_id, String path_file) {

    if (path_file == null) throw new NullPointerException();
    if (repository_id == null) throw new NullPointerException();
    if (repository_id.length() < 1) throw new IllegalArgumentException();

    if (path_file.length() > 0 && !path_file.startsWith("/")) {
      throw new RuntimeException("'path_file' must be absolute");
    }

    StringBuilder b = new StringBuilder();
    b.append("/");
    b.append(repository_id);
    b.append(path_file);

    this.file = b.toString();
  }

  /**
{'fraction_non_alphanumeric': 0.11400342010260307, 'fraction_numerical': 0.012160364810944329, 'mean_word_length': 3.1579778830963665, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '2359366', 'n_tokens_mistral': 1619, 'n_tokens_neox': 1521, 'n_words': 615}