webMethods Broker Administration Java API
Version 9.5.1.0.171 091713

COM.activesw.api.client
Class BrokerFormat

java.lang.Object
  extended by COM.activesw.api.client.BrokerFormat

public class BrokerFormat
extends java.lang.Object

String formatting functions. The string can reference values from an Object (currently only supports BrokerEvent). See also BrokerEvent.toFormattedString(...). Event fields can be referenced in the format string by a $ character followed by the fully qualified event field name. The name is terminated by the first space character following the $ character, or it can be enclosed in curly braces: $foo ${foo} $struct.sequence[3].field a${foo}b Optionally, a format specifier can be appended to each field name with a ':': $foo:x ${foo:x} The following formatting options are supported:

   :s - sinqle quoting. Enclose the value in <'>, and escape
        single quotes in the value with a <\>
   :d - double quotes. Enclose the value in <">, and escape double quotes
        in the value with <\>
   :q - SQL quoting. Like :s, but escape with <'>
   :v - Bind variable mode. Primarly intended for use with databases,
        Replace the reference with a proper bind variable placeholder.
        Default is Oracle style, as in :v0, :v1, :v2. Can be changed to
        use  with the setFormatMode() call.
   :c - numeric. Use value as numeric value. If value is non-numeric, any
        non-numeric portions will be discarded. I.e. if the value is
        "123X", only "123" will be used in the result.
   :###x - Specify a minimum field length together with one of the options
        above, i.e. <:5d> will print a value of  as <'AB   '>.
 
'\' can be used to escape the following character outside of variable names. To get a '$' character into the result, escape it with a '\', i.e. \\\a\$foo will be returned as \a$foo


Field Summary
protected static char modeV
           
 
Constructor Summary
BrokerFormat(java.lang.String format_string)
          Constructor.
 
Method Summary
static java.lang.String assemble(BrokerEvent event, java.util.Vector tokens)
          Assemble a string from the tokens, replacing references with values from the event.
static java.lang.String assemble(BrokerEvent event, java.util.Vector tokens, java.util.Locale locale)
          Assemble a string from the tokens, replacing references with values from the event.
static java.lang.String assemble(java.util.Vector tokens)
          Assemble a string from the tokens, without an event reference.
 java.lang.String format()
          Return formatted string, without event data.
 java.lang.String format(BrokerEvent event)
          Return formatted string, using for resolving all event field references.
 java.lang.String format(BrokerEvent event, java.util.Locale locale)
          Return formatted string, using for resolving all event field references.
static java.lang.String format(BrokerEvent event, java.lang.String format_string)
          Format an event using a format string.
static java.lang.String format(BrokerEvent event, java.lang.String format_string, java.util.Locale locale)
          Format an event using a format string.
 java.lang.String formatBindVariable(int index, java.lang.StringBuffer place_holder_name)
          Returns the name of the bind variable at token in .
 int getTokenCount()
          Returns the number of tokens.
 java.lang.String getTokenValue(int t)
          Return the value of a token.
 boolean isReferenceToken(int t)
          Checks if a token is a reference to an event field.
static java.util.Vector<COM.activesw.api.client.BrokerFormatToken> preparse(java.lang.String format_string)
          Take a string, and break it up into a list of tokens.
static boolean setFormatMode(java.lang.String format_option, java.lang.String mode)
          set the mode for a format option (see above).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

modeV

protected static char modeV
Constructor Detail

BrokerFormat

public BrokerFormat(java.lang.String format_string)
Constructor. Parse the format string into a series of tokens

Parameters:
format_string -
Throws:
...
Method Detail

getTokenCount

public int getTokenCount()
Returns the number of tokens.

Returns:
number of tokens

isReferenceToken

public boolean isReferenceToken(int t)
Checks if a token is a reference to an event field.

Parameters:
t - token number
Returns:
true if token references an event field, or false if it is a fixed string

getTokenValue

public java.lang.String getTokenValue(int t)
Return the value of a token. The value is either a fixed string, or the name of an event field (see isReferenceToken()).

Parameters:
t - token number
Returns:
value of the token

format

public java.lang.String format()
Return formatted string, without event data. Event field values will be formatted for the US English locale.

Returns:
formatted string

format

public java.lang.String format(BrokerEvent event)
                        throws BrokerException
Return formatted string, using for resolving all event field references. Event field values will be formatted for the US English locale.

Parameters:
event - the event for the data
Returns:
the formatted string
Throws:
BrokerException

format

public java.lang.String format(BrokerEvent event,
                               java.util.Locale locale)
                        throws BrokerException
Return formatted string, using for resolving all event field references. Event field values will be formatted for the specified locale.

Parameters:
event - the event for the data
locale - determines format of field value output
Returns:
the formatted string
Throws:
BrokerException

setFormatMode

public static boolean setFormatMode(java.lang.String format_option,
                                    java.lang.String mode)
set the mode for a format option (see above). These options can currently be configured: v - ':' (as in :v0, :v1) or '?' Date formatting can be affected by setting the mode to one of these: - BrokerDate -> use BrokerDate.toString() - DateFormat -> Use java.text.DateFormat to format dates Returns true if a valid mode was set. Returns false if format_option or mode are not valid values.


format

public static java.lang.String format(BrokerEvent event,
                                      java.lang.String format_string)
                               throws BrokerException
Format an event using a format string. Equivalent to format(event, format_string, java.util.Locale.US)

Parameters:
event - the event for the data
format_string - the format string
Returns:
the formatted string
Throws:
BrokerException

format

public static java.lang.String format(BrokerEvent event,
                                      java.lang.String format_string,
                                      java.util.Locale locale)
                               throws BrokerException
Format an event using a format string. Event field values will be formatted for the specified locale.

Parameters:
event - the event for the data
format_string - the format string
locale - determines formatting of field values
Returns:
the formatted string
Throws:
BrokerException

preparse

public static java.util.Vector<COM.activesw.api.client.BrokerFormatToken> preparse(java.lang.String format_string)
Take a string, and break it up into a list of tokens. Deprecated - consider using new BrokerFormat(format_string) instead. Returns null if format_string is null.


assemble

public static java.lang.String assemble(BrokerEvent event,
                                        java.util.Vector tokens)
                                 throws BrokerException
Assemble a string from the tokens, replacing references with values from the event. Field values will be formatted for the US English locale. Equivalent to assemble(event,tokens,java.util.Locale.US) Deprecated - consider using format() method instead

Throws:
BrokerFieldNotFoundException - If a field is referenced in the format string that is not in the event.
BrokerInvalidTypeException - If a field is not of a type supported by the string formatter.
BrokerException

assemble

public static java.lang.String assemble(BrokerEvent event,
                                        java.util.Vector tokens,
                                        java.util.Locale locale)
                                 throws BrokerException
Assemble a string from the tokens, replacing references with values from the event. Field values will be formatted for the specified locale. Deprecated - consider using format() method instead

Throws:
BrokerFieldNotFoundException - If a field is referenced in the format string that is not in the event.
BrokerInvalidTypeException - If a field is not of a type supported by the string formatter.
BrokerException

assemble

public static java.lang.String assemble(java.util.Vector tokens)
Assemble a string from the tokens, without an event reference. Event field values will be formatted for the US English locale. Deprecated - consider using format() method instead


formatBindVariable

public java.lang.String formatBindVariable(int index,
                                           java.lang.StringBuffer place_holder_name)
Returns the name of the bind variable at token in . Returns null if there is no bind variable at that position, or if the index is not valid. If place_holder_name is not null, it will be set to a string that represents the place holder in the statement (i.e. ":v0" or "?").


webMethods Broker Administration Java API
Version 9.5.1.0.171 091713


Copyright © 2001 - 2013 Software AG Darmstadt, Germany and/or Software AG USA, Inc., Reston, VA, United States of America, and/or their suppliers.