Home | Arachnophilia | Documentation |     Share This Page
The Java Custom Class Interface
Arachnophilia is © Copyright 2015, P. Lutus.

Arachnophilia is CareWare

Using system macros, Arachnophilia can interface with external Java classes written by the user or provided by third parties. This essentially means any imaginable function can be added to Arachnophilia.

Here is how to proceed:

This is the general idea, and most programmers will have no problems at all. But, just for an example, we'll invoke a sample Java class that is included with Arachnophilia.

Here is a listing of the test class (Copy the block below to create your own content):

 * Created on Oct 26, 2009 12:06:55 PM

/* TestClass is meant to demonstrate the use
 * of Arachnophilia's custom class launcher feature.
 * Just compile this class in place, create
 * a macro that looks like this:
 * "[RunCustomClassDoc:CustomClasses/TestClass]",
 * load a suitable document, and activate the macro.

package CustomClasses;

import java.util.*;

public class TestClass {
   // this is a generic, minimal global search & replace method
   private String searchReplace(String data,String find,String replace)
      StringBuffer sb = new StringBuffer();
      int a = 0,b;
      int findLength = find.length();
      while((b = data.indexOf(find,a)) != -1) {
         a = b + findLength;
      if(a < data.length()) {
      return sb.toString();
   // this is the default method that custom classes
   // must have to work with Arachnophilia's class
   // launcher feature unless a specific method name
   // is provided
   public String processString(String s)
      String result = "Hello! This is an example of Java Custom Class Interfacing!\n\n"
      + "You sent over this:\n"
      + "\"" + s + "\"\n"
      + "Here it is all uppercase:\n"
      + "\"" + s.toUpperCase() + "\"\n"
      + "Here it is all lowercase:\n"
      + "\"" + s.toLowerCase() + "\"\n"
      + "Here it is with a global change:\n"
      + "\"" + searchReplace(s,"a","(A)") + "\"\n";
      return result;
   // this is another method to show the ability to choose
   // any method by name
   public String reallyBoringMethod(String s)
      return "On " + new Date() + ", you invoked this really boring Java method.";


This test class has already been created and compiled, and should be in your user directory under a subdirectory named "CustomClasses." Let's see if it is. :)

Open a new text document and type something into it. Here's our example text:
This is a test phrase.
Now find the menu item Programming ... Custom Class Demo and click it. The macro behind this menu item has this content by default:

This macro means "Find a Java class in a subdirectory of the Arachnophilia user directory named "CustomClasses," find a class there named 'TestClass,' and run a method called 'ProcessString' with the current document's contents as its argument."

Here is the outcome for our example sentence:

Hello! This is an example of Java Custom Class Interfacing!
You sent over this:
"This is a test phrase."
Here it is all uppercase:
Here it is all lowercase:
"this is a test phrase."
Here it is with a global change:
"This is (A) test phr(A)se."

If the macro is invoked as above, it will assume the existence of a public method called "ProcessString," and it will tell you if it cannot find it. If you want to use a different method name, simply provide the name, like this:


It happens there is a method with this name in our test class, and if invoked it will return (something resembling):

On Fri Mar 08 21:58:27 PST 2002, you invoked this really boring Java method.

Custom classes created by the user can be located anywhere in the user's Arachnophilia directory or subdirectories, and there can be any number of methods with any names in the classes. The only requirements are that the package identifier be the same as the above listing ("CustomClasses") and that the methods be public and receive and return a String.


Home | Arachnophilia | Documentation |     Share This Page