net.sf.sdedit.diagram
Interface DiagramDataProvider

All Known Implementing Classes:
TextHandler

public interface DiagramDataProvider

A DiagramDataProvider reads object and message specifications from some source and creates Lifeline and MessageData representations from them.

It should be used in such a way:

 
 DiagramDataProvider provider = new ...;
 while (provider.advance()) {
   Lifeline lifeline = provider.nextObject();
   // do something with the lifeline
 }
 
 while (provider.advance()) {
   String comment = provider.openComment();
   if (comment != null) {
     // handle the comment, if you are interested
     continue;
   }
   if (provider.closeComment()) {
     // the comment most recently returned by openComment() is
     // closed, so react to it, if you are interested
     continue;
   }
   
   MessageData data = provider.nextMessage();
   // do something with the message data
 }
 

Author:
Markus Strauch

Method Summary
 boolean advance()
          Advances to the next data specification in the current section and returns true if there is one.
 boolean closeFragment()
          Returns true if the last fragment returned by openFragment() is to be closed now (so it is a comment on the messages that were read between the last time openFragment() did not return null and now.
 String[] getDescription()
          Returns an array of strings to be used as a description of the diagram.
 Pair<Lifeline,Integer> getEventAssociation()
          Returns a pair consisting of a lifeline and the number of a description if the description is to be associated to the lifeline at the current position.
 String getFragmentSeparator()
          If the following messages belong to a new section of the most recently opened fragment, this method returns the title of the section, otherwise null
 Note getNote()
          If at the current position in the data a note is specified, returns it, otherwise null.
 Object getState()
          Gets the current state of the provider.
 String getTitle()
          Returns the diagram's title or null, if no title is defined
 MessageData nextMessage()
          Returns the next MessageData object specifying a message appearing on the diagram.
 Lifeline nextObject()
          Returns the next Lifeline object specifying an object or actor appearing on the diagram.
 String openFragment()
          If at the current position in the data the beginning of a fragment is specified, the title of the fragment is returned, otherwise null.
 void setDiagram(Diagram diagram)
          Sets the diagram that uses this DiagramDataProvider.
 

Method Detail

getTitle

String getTitle()
Returns the diagram's title or null, if no title is defined

Returns:
the diagram's title or null, if no title is defined

getDescription

String[] getDescription()
Returns an array of strings to be used as a description of the diagram.

Returns:
an array of strings to be used as a description of the diagram

advance

boolean advance()
Advances to the next data specification in the current section and returns true if there is one. If the current section is the object section and this method returns false, the provider advances to the message section.

Returns:
true if there is more data specified in the current section

nextObject

Lifeline nextObject()
                    throws SyntaxError
Returns the next Lifeline object specifying an object or actor appearing on the diagram.

Returns:
the next Lifeline object specifying an object or actor appearing on the diagram or null if there is not another object specified
Throws:
SyntaxError - if the object is specified syntactically wrong

nextMessage

MessageData nextMessage()
                        throws SyntaxError
Returns the next MessageData object specifying a message appearing on the diagram.

Returns:
next MessageData object specifying a message appearing on the diagram, or null if there is no more message specified
Throws:
SyntaxError - if the message is specified syntactically wrong

getState

Object getState()
Gets the current state of the provider. The state depends on how far it has advanced when reading the data.

Returns:
the current state of the provider or null if the provider does not provide information about its state

openFragment

String openFragment()
If at the current position in the data the beginning of a fragment is specified, the title of the fragment is returned, otherwise null.

Returns:
a fragment title, if one is specified currently, otherwise null

closeFragment

boolean closeFragment()
Returns true if the last fragment returned by openFragment() is to be closed now (so it is a comment on the messages that were read between the last time openFragment() did not return null and now.

Returns:
true if the last comment returned by openFragment() is to be closed now

getNote

Note getNote()
             throws SyntaxError
If at the current position in the data a note is specified, returns it, otherwise null.

Returns:
a note, if one is specified at the current position, otherwise null
Throws:
SyntaxError

setDiagram

void setDiagram(Diagram diagram)
Sets the diagram that uses this DiagramDataProvider.

Parameters:
diagram - the diagram that uses this DiagramDataProvider

getEventAssociation

Pair<Lifeline,Integer> getEventAssociation()
                                           throws SyntaxError
Returns a pair consisting of a lifeline and the number of a description if the description is to be associated to the lifeline at the current position.

Returns:
a pair as described or null if no such association is currently specified
Throws:
SyntaxError

getFragmentSeparator

String getFragmentSeparator()
If the following messages belong to a new section of the most recently opened fragment, this method returns the title of the section, otherwise null

Returns:
the title of a fragment section or null


Copyright © 2011. All Rights Reserved.