jade.tools.sl
Class SLFormatter

java.lang.Object
  |
  +--jade.tools.sl.SLFormatter

public class SLFormatter
extends java.lang.Object

Holder for static methods to format messages.

Author:
Craig Sayers, Hewlett Packard Labs, Palo Alto.

Constructor Summary
SLFormatter()
           
 
Method Summary
static java.lang.String format(java.lang.String s)
          Formats an ACL/SL string.
static void main(java.lang.String[] args)
          Main routine is helpful for debugging.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SLFormatter

public SLFormatter()
Method Detail

format

public static java.lang.String format(java.lang.String s)
Formats an ACL/SL string. This takes an input string, formats it (adding new-lines and spaces in an attempt to improve readability), and returns the result. The formatted output is similar to that used for the examples in the FIPA SL spec. The formatter attempts to keep short expressions on one line, while indenting longer expressions to show the structure. As an example, the result of:
    System.out.println(SLFormatter.format("(vehicle :color red :max-speed 100 :owner (Person :name Luis :nationality Potuguese))"));
 
is the output
  (vehicle
    :color red
    :max-speed 100
    :owner
      (Person
        :name Luis
        :nationality Portuguese))
 
Usually, the input string will come from a call to ACLMessage.getContent(), for example if you have an ACLMessage called msg, you can print formatted content:
    System.out.println(SLFormatter.format(msg.getContent());
 
Since text ACL messages follow an SL style, you can also use this function to format entire messages by formatting the return value from msg.toString().
Parameters:
s - ACL/SL string to be formatted
Returns:
formatted result string

main

public static void main(java.lang.String[] args)
Main routine is helpful for debugging. It asks for an SL expression and then prints the result of calling SLFormatter.format.