package Analyze.Filter ; import java.awt.*; import java.util.Locale ; import java.util.Vector ; //============================================================================== /** * Super class for all FilterInterface filters; defaults provide * left-to-right outputs for the default locale.

* * At the minimum, derived classes must *

 *  1. Overide the Name, Description and AlphabetSize variables.
 *  2. Provide a getVector() method.
 *  
* to meet the FilterInterface requirements. */ //============================================================================== public class FilterCore { public Frame F ; public String Name = "Unnamed" ; public String Description = "No description." ; public int AlphabetSize = 0 ; public boolean Prunable = false ; // Input characteristics for tuples public String InputFontName = "Courier" ; public Locale InputLocale = Locale.getDefault() ; // Output characteristics in XML files public String Style = "font-family:Courier New;font-size:16; font-weight:bold" ; public String Alignment = "left" ; public String Direction = "ltr" ; public byte[] Input ; // Input byte array. public int Length ; //----------------------------------------------------------------------------- /** * Super class for all FilterInterface filters; defaults provide * left-to-right outputs for the default locale. */ public FilterCore(){} //----------------------------------------------------------------------------- /** * Sets the program Frame. * * @param F Frame to put warning messages or controls in. */ public void setFrame(Frame F){ this.F = F ; } //----------------------------------------------------------------------------- /** * Gets the XML parameter align (alignment) for the output Objects ("left"). * * @return String giving the alignment, i.e. "left" for left or * "right" for right. */ public String getAlignment(){ return Alignment ; } //----------------------------------------------------------------------------- /** * Gets the alphabet size of the output Objects, * 0 for a non-alphabetic filter (0). * * @return int gving the alphabet size. */ public int getAlphabetSize(){ return AlphabetSize ; } //----------------------------------------------------------------------------- /** * Gets a description of the filter ("No description"). * * @return String describing the filter in detail. */ public String getDescription(){ return Description ; } //----------------------------------------------------------------------------- /** * Gets the XML parameter dir (direction) for the output Objects ("rtl"). ** * @return String giving the direction, i.e. "ltr" for left-to-right or * "rtl" for right-to-left". */ public String getDirection() { return Direction ; } //----------------------------------------------------------------------------- /** * Gets the font name for typed input text ("Courier"). * * For the usual font, return any Component.getFont() ; * * @return String giving font name for typed input text. */ public String getInputFontName(){ return InputFontName ; } //----------------------------------------------------------------------------- /** * Gets the locale (language, country, and variant) for * typed input text (Locale.getDefault()). * * If the text is from the usual locale, return Locale.getDefault(). * * @return Locale giving the desired input Locale. */ public Locale getInputLocale(){ return InputLocale ; } //----------------------------------------------------------------------------- /** * Gets the name of the filter("Unnamed"). * * @return String giving the name of the filter. */ public String getName() { return Name ; } //----------------------------------------------------------------------------- /** * Gets the position, represented as a String, from the Object[] produced by * the filter (Text.Index). * * Filter output objects do NOT need to contain position data. For them, this * method can be set to be: * *

*    return Integer.toString(Text) + "." + Integer.toString(Index) ;   
*
* * @param Data Object[] of Vectors giving Objects. * @param Text int index of Data Vector containing the text. * @param Index int giving position of Object within Data Vector. * @return String giving position from Data[Index] */ public String getPosition( Object[] Data, int Text, int Index ) { return Integer.toString(Text) + "." + Integer.toString(Index) ; } //----------------------------------------------------------------------------- /** * Gets the XML parameter style for the output Objects * ("font-family:Courier New;font-size:16; font-weight:bold"). * * @return String giving the style, i.e. "font-family:Ezra SIL;font-size:20", * can be set to "" for usual style. */ public String getStyle() { return Style; } //----------------------------------------------------------------------------- /** * Indicates if the filtered text is prunable (false). * * In general, alphabets are NOT prunable, words are prunable. * * @return boolean indicating if filtered text is prunable. */ public boolean isPrunable(){ return Prunable ; } //----------------------------------------------------------------------------- /** * Sets the input byte array. * * @param InputArray byte[] giving input byte array. * @param Length int giving number of bytes in InputArray. */ public void setArray(byte[] InputArray, int Length){ this.Input = InputArray ; this.Length = Length ; return ; } //----------------------------------------------------------------------------- // end of class } //============================================================================== //==============================================================================