//==================================================================================================
// S t a n d a r d                                                                             Java
// F i l e N a m e
//                                                                                By Bruno Bachelet
//==================================================================================================
// Copyright (c) 1999-2016
// Bruno Bachelet - bruno@nawouak.net - http://www.nawouak.net
//
// This file is part of the B++ Library. This library is free software; you can redistribute it
// and/or modify it under the terms of the GNU Library General Public License as published by the
// Free Software Foundation; either version 2 of the License, or (at your option) any later
// version.
//
// This library 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 Library General Public License for more details (http://www.gnu.org).

/*DESCRIPTION*/
/* This module provides a class that represents a file name. */

// Package //---------------------------------------------------------------------------------------
package bpp.standard;

// F i l e N a m e  Class //------------------------------------------------------------------------
/*CLASS FileName */ /* Represents a file name. */
public class FileName {
 //---------------------------------------------------------------------------------------Attributes
 protected String atName;
 //--------------------------------------------------------------------------------------Constructor
 /*METHOD FileName */ /* Builds a file name. */
 public FileName(String agName) { atName=agName; }
 //---------------------------------------------------------------------------------------------Body
 /*METHOD FileName */ /* Returns the body of the file name (i.e. the part before the last dot). */
 public String body() {
  int lcDot = (atName==null ? -1 : atName.lastIndexOf('.'));

  if (lcDot==-1) return (atName);
  return (atName.substring(0,lcDot));
 }
 //----------------------------------------------------------------------------------------Extension
 /*METHOD FileName */
 /* Returns the extension of the file name (i.e. the part after the last dot). */
 public String extension() {
  int lcDot = (atName==null ? -1 : atName.lastIndexOf('.'));

  if (lcDot==-1) return ("");
  return (atName.substring(lcDot+1,atName.length()));
 }
}

// End //-------------------------------------------------------------------------------------------