001/*
002 * Version 0.70 01/04/2002
003 *
004 * Visit my url for update: http://www.geocities.com/beapetrovicova/
005 * 
006 * jFtp was developed by Bea Petrovicova <beapetrovicova@yahoo.com>.
007 * The design and implementation of jFtp are available for royalty-free 
008 * adoption and use. This software is provided 'as is' without any 
009 * guarantees. Copyright is retained by Bea Petrovicova. Redistribution 
010 * of any part of jFtp or any derivative works must include this notice.
011 * 
012 */  
013
014package cz.dhl.ftp;
015
016import cz.dhl.ui.CoConsole;
017import java.io.IOException;
018
019/**
020 * Maintains FTP client settings & context.
021 * 
022 * @Version 0.70 01/04/2002
023 * @author Bea Petrovicova <beapetrovicova@yahoo.com>  
024 * @see Ftp
025 */
026public class FtpContext extends FtpSetting
027{
028   private String textfilter[] = {".TXT", 
029                                  ".HTM", ".HTML", ".SHTML", 
030                                  ".CSS", ".JS", ".PL", ".PHP",
031                                  ".H", ".C", ".HPP", ".CPP", ".JAVA",
032                                  ".SQL", ".4GL",
033                                  ".BAT", ".SH", ".AWK"};
034   private CoConsole console = new CoConsole()
035   {  public void print(String message) 
036         { System.out.println(message); } };
037
038   FtpContext() {}
039
040   /** Sets array of strings representing text-file extensions.
041    * @param textfilter must be array of uppercase strings with a leading '.' sign; 
042    * example: { ".TXT", ".HTM", ".HTML", etc ... };
043      default settings is quite flexible */
044   public void setTextFilter(String textfilter[]) 
045      { this.textfilter= textfilter; }
046   
047   /** Sets array of strings representing text-file extensions.
048    * @return array of uppercase strings with a leading '.' sign; 
049    * example: { ".TXT", ".HTM", ".HTML", etc ... } */
050   public String[] getTextFilter() 
051      { return textfilter; }
052   
053   /** Sets output console.
054    * @see cz.dhl.ui.CoConsole */
055   synchronized public void setConsole(CoConsole console)
056      { this.console = console; }
057
058   /** Gets output console.
059    * @see cz.dhl.ui.CoConsole */
060   synchronized public CoConsole getConsole()
061      { return console; }
062   
063   /** Prints message line to output console. */
064   public synchronized void printlog(String message)
065   {  if(console != null)
066         console.print(message);
067   }
068
069   /** Prints object to standard output. */
070   public void printerr(Exception exception)
071   {  System.out.println("Thread: " + Thread.currentThread().getName()); 
072      System.out.println("Exception:"); 
073      exception.printStackTrace();
074   } 
075}