platypus
Class UserString

java.lang.Object
  extended by platypus.UserString

public class UserString
extends java.lang.Object

Maintains a table of macros. Macros have the following properties: Strings: Begin with a $ followed by a letter or digit and then any combination of letters, digits, and _ Users can read, write, modify at will Platypus-defined strings: Begin with $_ followed by any combination of letters, digits, and _ characters To the user, Platypus-defined strings are read-only All string names are case-sentistive. Strings are defined with the [def:StringName{contents of string}] default is " " (a single space) strings cannot currently contain commands or other strings Numbers default to 0, implemented in BigDecimal, so no over/undeflow errors possible To print a string to the document, enter an asterisk before the string name: [*StringName] Note: no translation is done of the string before it's printed. Additional info: Platypus will expose its own variables as read-only macros, as indicated above.

Author:
alb

Field Summary
(package private)  java.util.TreeMap uStrings
           
 
Constructor Summary
UserString()
          Create a table for key-value pairs (both strings)
 
Method Summary
 int add(java.lang.String key, java.lang.String value)
          Add a macro to the table of user strings
 java.lang.String dumpPlatypusStrings()
          Dump all the strings defined by Platypus in the table to one long string.
 java.lang.String dumpUserStrings()
          Dump all the user-defined string to one long string.
 java.lang.String extractMacroName(java.lang.String rawString)
          Accepts a string that should start with the name of a Platypus string and returns the portion that's a legal system macro name: $PageCount Stops at the first invalid character
 java.lang.String get(java.lang.String key)
          Retrieve a string based on its key (the macro name)
 int sizeof()
          How many strings are there in the table?
 java.lang.String toString()
          Dump all the strings in the table to one long string.
 int update(java.lang.String key, java.lang.String value)
          Updates a value by deleting the current KV pair and replacing it with the new one
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

uStrings

final java.util.TreeMap uStrings
Constructor Detail

UserString

public UserString()
Create a table for key-value pairs (both strings)

Method Detail

add

public int add(java.lang.String key,
               java.lang.String value)
Add a macro to the table of user strings

Parameters:
key - the macro name
value - the macro body
Returns:
Status.OK if all went well; Status.INVALID_PARAM on error

get

public java.lang.String get(java.lang.String key)
Retrieve a string based on its key (the macro name)

Parameters:
key - the macro name
Returns:
the contents of the macro if found; otherwise, null

update

public int update(java.lang.String key,
                  java.lang.String value)
Updates a value by deleting the current KV pair and replacing it with the new one

Parameters:
key - new key
value - new data/value
Returns:
Status.OK if all OK; Status.INVALID_PARAM or Status.INVALID_NULL_PARAM on error

sizeof

public int sizeof()
How many strings are there in the table?

Returns:
number of strings

toString

public java.lang.String toString()
Dump all the strings in the table to one long string.

Overrides:
toString in class java.lang.Object
Returns:
string containing all the KV pairs, one per line, properly formatted

dumpUserStrings

public java.lang.String dumpUserStrings()
Dump all the user-defined string to one long string.

Returns:
string containing all the KV pairs, one per line, properly formatted

dumpPlatypusStrings

public java.lang.String dumpPlatypusStrings()
Dump all the strings defined by Platypus in the table to one long string.

Returns:
string containing all the KV pairs, one per line, properly formatted

extractMacroName

public java.lang.String extractMacroName(java.lang.String rawString)
Accepts a string that should start with the name of a Platypus string and returns the portion that's a legal system macro name: $PageCount Stops at the first invalid character

Parameters:
rawString - the string that should begin with a system macro name
Returns:
the actual string, or null if an error occurs


Copyright © 2006-7 Pacific Data Works LLC