Package jade.tools.sl

Class SLFormatter


  • public class SLFormatter
    extends Object
    Holder for static methods to format messages.
    Version:
    1.0
    Author:
    Craig Sayers, Hewlett Packard Labs, Palo Alto.
    • Constructor Detail

      • SLFormatter

        public SLFormatter()
        Default constructor.
    • Method Detail

      • format

        public static String format​(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​(String[] args)
        Main routine is helpful for debugging. It asks for an SL expression and then prints the result of calling SLFormatter.format.