Algernon Software

org.algernon.app.j2p
Class Advice

java.lang.Object
  extended byorg.algernon.app.j2p.Advice

public class Advice
extends Object

Advice reads and writes advice files, as well as transforming slot and class names upon request. Lines that begin with a '#' are ignored. Example entries:

 PREFIX SLOT ALL   ...
 SUFFIX SLOT ALL   ...
 PREFIX SLOT name  ...
 SUFFIX SLOT name  ...
 CAPITALIZE SLOT ALL
 UPPERCASE SLOT ALL
 LOWERCASE SLOT ALL
 CAPITALIZE SLOT name
 UPPERCASE SLOT name
 LOWERCASE SLOT name
 REPLACE SLOT name  newname
 IGNORE SLOT name 

 PREFIX CLASS ALL   ...
 SUFFIX CLASS ALL   ...
 PREFIX CLASS name  ...
 SUFFIX CLASS name  ...
 CLASS CAPITALIZE  ALL
 UPPERCASE CLASS ALL
 LOWERCASE CLASS ALL
 CAPITALIZE CLASS name
 UPPERCASE CLASS name
 LOWERCASE CLASS name
 REPLACE CLASS name  newname
 IGNORE CLASS name


Field Summary
(package private)  String f_adviceFile
           
(package private)  HashMap f_ClassCapitalize
           
(package private)  HashMap f_ClassIgnore
           
(package private)  HashMap f_ClassLowercase
           
(package private)  HashMap f_ClassPrefixes
           
(package private)  HashMap f_ClassReplacements
           
(package private)  HashMap f_ClassSuffixes
           
(package private)  HashMap f_ClassUppercase
           
(package private)  boolean f_globalClassCapitalize
           
(package private)  boolean f_globalClassLowercase
           
(package private)  String f_globalClassPrefix
           
(package private)  String f_globalClassSuffix
           
(package private)  boolean f_globalClassUppercase
           
(package private)  boolean f_globalSlotCapitalize
           
(package private)  boolean f_globalSlotLowercase
           
(package private)  String f_globalSlotPrefix
           
(package private)  String f_globalSlotSuffix
           
(package private)  boolean f_globalSlotUppercase
           
(package private)  HashMap f_SlotCapitalize
           
(package private)  HashMap f_SlotIgnore
           
(package private)  HashMap f_SlotLowercase
           
(package private)  HashMap f_SlotPrefixes
           
(package private)  HashMap f_SlotReplacements
           
(package private)  HashMap f_SlotSuffixes
           
(package private)  HashMap f_SlotUppercase
           
 
Constructor Summary
Advice()
          Creates a new advice with default values.
Advice(String adviceFile)
          Creates a new set of advice from the given file.
 
Method Summary
 void deleteEntry(String command, String type, String frameName, String replacement)
          Deletes an entry from the advice list.
 String getAdviceString()
          Dumps all the advice into a string.
private  String getClassPrefix(String className)
           
private  String getClassReplacement(String className)
           
private  String getClassSuffix(String className)
           
private  String getSlotPrefix(String slotName)
           
private  String getSlotReplacement(String slotName)
           
private  String getSlotSuffix(String slotName)
           
 void processAdviceCommand(String command, String type, String frameName, String replacement)
          Processes and stores the advice.
 void readAdviceFile(String adviceFileName)
          Reads advice from a file.
 void save(String filename)
          Saves the advice to a file.
 boolean shouldIgnoreClass(String className)
          Returns true if the advice file said that this class should be ignored.
 boolean shouldIgnoreSlot(String className)
          Returns true if the advice file said that this slot should be ignored.
 Vector toVectors()
          Returns a vector of vectors containing the advice information
 String transformClassName(String className)
          Transforms a class name into the canonical form, given advice.
 String transformSlotName(String slotName)
          Transforms a slot name into the canonical form, given advice.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

f_globalClassPrefix

String f_globalClassPrefix

f_globalClassSuffix

String f_globalClassSuffix

f_globalSlotPrefix

String f_globalSlotPrefix

f_globalSlotSuffix

String f_globalSlotSuffix

f_globalClassCapitalize

boolean f_globalClassCapitalize

f_globalSlotCapitalize

boolean f_globalSlotCapitalize

f_globalClassLowercase

boolean f_globalClassLowercase

f_globalSlotLowercase

boolean f_globalSlotLowercase

f_globalClassUppercase

boolean f_globalClassUppercase

f_globalSlotUppercase

boolean f_globalSlotUppercase

f_ClassReplacements

HashMap f_ClassReplacements

f_ClassPrefixes

HashMap f_ClassPrefixes

f_ClassSuffixes

HashMap f_ClassSuffixes

f_ClassCapitalize

HashMap f_ClassCapitalize

f_ClassLowercase

HashMap f_ClassLowercase

f_ClassUppercase

HashMap f_ClassUppercase

f_SlotReplacements

HashMap f_SlotReplacements

f_SlotPrefixes

HashMap f_SlotPrefixes

f_SlotSuffixes

HashMap f_SlotSuffixes

f_SlotCapitalize

HashMap f_SlotCapitalize

f_SlotLowercase

HashMap f_SlotLowercase

f_SlotUppercase

HashMap f_SlotUppercase

f_ClassIgnore

HashMap f_ClassIgnore

f_SlotIgnore

HashMap f_SlotIgnore

f_adviceFile

String f_adviceFile
Constructor Detail

Advice

public Advice()
Creates a new advice with default values.


Advice

public Advice(String adviceFile)
Creates a new set of advice from the given file.

Parameters:
adviceFile -
Method Detail

readAdviceFile

public void readAdviceFile(String adviceFileName)
Reads advice from a file. Any pre-existing advice will be removed before the advice file is read.


processAdviceCommand

public void processAdviceCommand(String command,
                                 String type,
                                 String frameName,
                                 String replacement)
Processes and stores the advice.

Parameters:
type - Must be SLOT or CLASS, but is not case-sensitive.
frameName - Either ALL (uppercase) or the name of a frame (case-sensitive).
command - Not case-sensitive. Must be PREFIX, SUFFIX, CAPITALIZE, LOWERCASE, UPPERCASE or REPLACE
replacement - Case-sensitive. The new name for the slot or class, in a REPLACE command.

getAdviceString

public String getAdviceString()
Dumps all the advice into a string.


transformClassName

public String transformClassName(String className)
Transforms a class name into the canonical form, given advice. Applies a substitution (replace) rule, if any. If no substitution rule exists, then applies capitalization rules, then applies global suffix and prefix, unless they are overridden by a personalized suffix and prefix.


transformSlotName

public String transformSlotName(String slotName)
Transforms a slot name into the canonical form, given advice. First applies capitalization rules, then applies global suffix and prefix, unless they are overridden by a personalized suffix and prefix.


getClassReplacement

private String getClassReplacement(String className)

getClassPrefix

private String getClassPrefix(String className)

getClassSuffix

private String getClassSuffix(String className)

getSlotReplacement

private String getSlotReplacement(String slotName)

getSlotPrefix

private String getSlotPrefix(String slotName)

getSlotSuffix

private String getSlotSuffix(String slotName)

shouldIgnoreClass

public boolean shouldIgnoreClass(String className)
Returns true if the advice file said that this class should be ignored.

Parameters:
className -

shouldIgnoreSlot

public boolean shouldIgnoreSlot(String className)
Returns true if the advice file said that this slot should be ignored.

Parameters:
className -

toVectors

public Vector toVectors()
Returns a vector of vectors containing the advice information

Returns:
a vector of 3-4 element vectors.

save

public void save(String filename)
          throws IOException
Saves the advice to a file.

Parameters:
filename -
Throws:
IOException

deleteEntry

public void deleteEntry(String command,
                        String type,
                        String frameName,
                        String replacement)
Deletes an entry from the advice list.

Parameters:
command - A string giving the command: IGNORE, CAPITALIZE, etc.
type - A string containing CLASS or SLOT.
frameName - The name of a class.
replacement - Replacement name, when the command is REPLACE. Send in null otherwise.

Algernon Software