org.jbind.message
Interface IMessage

All Known Subinterfaces:
ICompositeMessage, IConstraintViolations
All Known Implementing Classes:
AbstractMessage, CompositeMessage, ConstraintViolations

public interface IMessage

A message that can be output in several languages. A message can either be a simple message or a composite message.


Method Summary
 void addTo(ICompositeMessage aCompositeMessage)
          Adds this message as a sub message to the specified composite message.
 java.lang.String getOrigin()
           
 boolean isComposite()
          Indicates if the message is a composite message.
 boolean isEmpty()
          Checks for emptiness.
 java.util.Iterator iterSimpleMessages()
          Iterates all simple messages contained in the message.
 java.util.Iterator iterSubMessages()
          Iterates the sub-messages of this message.
 java.lang.String output(java.util.Locale aLocale)
          Outputs this message and all of its sub-messages.
 java.lang.String output(java.util.Locale aLocale, boolean anIndent, boolean anOutputContainerLines)
          Outputs this message and all of its sub-messages.
 

Method Detail

output

public java.lang.String output(java.util.Locale aLocale)
Outputs this message and all of its sub-messages.

If this message is a composite message then first a line is output for the composite and then each sub-message is output on a line of its own that is indented one tab relative to the line of the composite. This method corresponds to calling output(aLocale, true, true).

Parameters:
aLocale - (optional).
Returns:
(required).

output

public java.lang.String output(java.util.Locale aLocale,
                               boolean anIndent,
                               boolean anOutputContainerLines)
Outputs this message and all of its sub-messages.

Best efforts are undertaken that the message is output using the specified locale. However, if the message can not be output using the specified locale then another locale is used.

Parameters:
aLocale - (optional).
anIndent - Determines if sub messages are indented or not.
anOutputContainerLines - Determines if a composite message outputs a line for itself or if it outputs its sub messages only.
Returns:
(required).

isEmpty

public boolean isEmpty()
Checks for emptiness. Simple messages are always non-empty whereas a composite message is non-empty iff it contains a non-empty sub-message.

Returns:
Returns true iff this message is empty.

isComposite

public boolean isComposite()
Indicates if the message is a composite message.

Returns:
Returns true iff the message is a composite message.

iterSubMessages

public java.util.Iterator iterSubMessages()
Iterates the sub-messages of this message. Simple messages always return an empty iterator.

Returns:
(required).

iterSimpleMessages

public java.util.Iterator iterSimpleMessages()
Iterates all simple messages contained in the message.

Returns:
(required). An iterator of IMessage.

addTo

public void addTo(ICompositeMessage aCompositeMessage)
Adds this message as a sub message to the specified composite message. If this message is a composite message then it recursively adds its submessages using this method again. No entry is added for a composite message itself.

Parameters:
aCompositeMessage - (required). The composite messages to which sub messages are added.

getOrigin

public java.lang.String getOrigin()