sk.baka.ambient.commons
Class TagFormatter

java.lang.Object
  extended by sk.baka.ambient.commons.TagFormatter

public final class TagFormatter
extends Object

Formats tags to a string. The following tags are supported:

If you surround a portion of text that contains a token (or a group) with curly braces, that section will be hidden if all contained tokens and/or groups are empty.

This object is not thread-safe.

Author:
Martin Vysny

Field Summary
 String formatString
          The format string.
 
Constructor Summary
TagFormatter(String formatString)
          Creates new formatter and compiles the format string.
 
Method Summary
 void format(StringBuilder builder, TrackMetadataBean bean, boolean collapse)
          Formats given track and appends it into given string builder.
 String format(TrackMetadataBean bean)
          Formats given track.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

formatString

public final String formatString
The format string.

Constructor Detail

TagFormatter

public TagFormatter(String formatString)
             throws ParseException
Creates new formatter and compiles the format string.

Parameters:
formatString - the string
Throws:
ParseException - if we failed to parse the format string.
Method Detail

format

public void format(StringBuilder builder,
                   TrackMetadataBean bean,
                   boolean collapse)
Formats given track and appends it into given string builder.

Parameters:
builder - the builder to append the formatted track to.
bean - the track to format
collapse - if true then the formatter will collapse when all tags/groups are empty.

format

public String format(TrackMetadataBean bean)
Formats given track.

Parameters:
bean - the track to format
Returns:
never-null formatted string.

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2007-2008. All Rights Reserved.