symplik.flower
Class ConsoleFileBrowser

java.lang.Object
  extended by symplik.flower.ConsoleFileBrowser

public class ConsoleFileBrowser
extends java.lang.Object

File Browser running in Console mode This class can be used in any program which requires text-based operation of selecting a file, with or without specified file extension.

 ConsoleFileBrowser cfb = new ConsoleFileBrowser();
 cfb.setFilePerPage(10);     // how many file plus directory will be shown in each page
 cfb.setShowExit(false);     // add an option [X] Exit
 cfb.setExtension("txt")     // set what file extension will be shown
 String file = cdb.selectFile();
 
The default directory is "user.dir" for the first time it is invoked. The last directory selected will be saved as system property symplik.flower.ConsoleFileBrowser.currentDirectory. Any new instance will use this value again when it starts. So, in order to set the default directory, you need to
 System.setProperty(ConsoleFileBrowser.CURR_DIR, [you dir]);
 

Version:
$Revision: 2 $
Author:
$Author: Christopher Ho $

Field Summary
private  java.lang.String action
           
private static java.lang.String ACTION_DOWN_DIR
           
private static java.lang.String ACTION_EXIT
           
private static java.lang.String ACTION_LAST_PAGE
           
private static java.lang.String ACTION_NEXT_PAGE
           
private static java.lang.String ACTION_SELECT_FILE
           
private static java.lang.String ACTION_UP_DIR
           
private  java.util.ArrayList<java.lang.String> answerKey
           
static java.lang.String CURR_DIR
           
private static java.lang.String DIR_ROOT
           
private  java.lang.String extension
           
private  int filePerPage
           
private  int pageNo
           
private  boolean showExit
           
 
Constructor Summary
ConsoleFileBrowser()
           
 
Method Summary
private  java.lang.String browser()
           
private  void downDir(java.lang.String dir)
           
private  java.lang.String getCurrDir()
           
 java.lang.String getExtension()
           
 int getFilePerPage()
           
private  int getPageNo()
           
 boolean isShowExit()
           
private  void lastPage()
           
static void main(java.lang.String[] args)
           
private  void nextPage()
           
private  java.lang.String response()
           
 java.lang.String selectFile()
           
 void setExtension(java.lang.String ext)
           
 void setFilePerPage(int filePerPage)
           
 void setShowExit(boolean showExit)
           
private  void showChoices()
           
private  void showQuestion()
           
private  void upDir()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CURR_DIR

public static final java.lang.String CURR_DIR
See Also:
Constant Field Values

DIR_ROOT

private static final java.lang.String DIR_ROOT
See Also:
Constant Field Values

ACTION_LAST_PAGE

private static final java.lang.String ACTION_LAST_PAGE
See Also:
Constant Field Values

ACTION_NEXT_PAGE

private static final java.lang.String ACTION_NEXT_PAGE
See Also:
Constant Field Values

ACTION_UP_DIR

private static final java.lang.String ACTION_UP_DIR
See Also:
Constant Field Values

ACTION_DOWN_DIR

private static final java.lang.String ACTION_DOWN_DIR
See Also:
Constant Field Values

ACTION_SELECT_FILE

private static final java.lang.String ACTION_SELECT_FILE
See Also:
Constant Field Values

ACTION_EXIT

private static final java.lang.String ACTION_EXIT
See Also:
Constant Field Values

answerKey

private java.util.ArrayList<java.lang.String> answerKey

action

private java.lang.String action

pageNo

private int pageNo

filePerPage

private int filePerPage

showExit

private boolean showExit

extension

private java.lang.String extension
Constructor Detail

ConsoleFileBrowser

public ConsoleFileBrowser()
Method Detail

main

public static void main(java.lang.String[] args)

selectFile

public java.lang.String selectFile()

browser

private java.lang.String browser()

showQuestion

private void showQuestion()

showChoices

private void showChoices()

response

private java.lang.String response()

downDir

private void downDir(java.lang.String dir)

upDir

private void upDir()

getCurrDir

private java.lang.String getCurrDir()

getPageNo

private int getPageNo()

nextPage

private void nextPage()

lastPage

private void lastPage()

setShowExit

public void setShowExit(boolean showExit)

isShowExit

public boolean isShowExit()

getExtension

public java.lang.String getExtension()

setExtension

public void setExtension(java.lang.String ext)

setFilePerPage

public void setFilePerPage(int filePerPage)

getFilePerPage

public int getFilePerPage()


Copyright © 2010 Symplik Tech. Co. Ltd. All Rights Reserved.