UmlSequenceDiagramFactoryFromXml Class Reference

Inheritance diagram for UmlSequenceDiagramFactoryFromXml:

UmlSequenceDiagramFactoryInterface

List of all members.

Public Member Functions

 setXml ($strXml)
 getXml ()
 setUmlSequenceDiagram (UmlSequenceDiagram $objUmlSequenceDiagram)
 getUmlSequenceDiagram ()
 perform ()

Static Public Member Functions

static getInstance ()

Protected Member Functions

 loadActors ()
 loadMessages ()

Protected Attributes

 $objUmlSequenceDiagram
 $objXml

Static Protected Attributes

static $objInstance


Detailed Description

Factory what creates UmlSequenceDiagram based into Xml Files
Author:
Thiago Henrique Ramos da Mata <thiago.henrique.mata@gmail.com>

Definition at line 11 of file UmlSequenceDiagramFactoryFromXml.class.php.


Member Function Documentation

static getInstance (  )  [static]

Return the singleton of the UmlSequenceDiagramFactoryFromXml

Returns:
UmlSequenceDiagramFactoryFromXml

Implements UmlSequenceDiagramFactoryInterface.

Definition at line 41 of file UmlSequenceDiagramFactoryFromXml.class.php.

00042         {
00043                 if( self::$objInstance == null )
00044                 {
00045                         self::$objInstance = new UmlSequenceDiagramFactoryFromXml();
00046                 }
00047                 return self::$objInstance;
00048         }

getUmlSequenceDiagram (  ) 

get the xml sequence object

See also:
UmlSequenceDiagramFactoryInterface->getUmlSequenceDiagram()
Returns:
UmlSequenceDiagram

Implements UmlSequenceDiagramFactoryInterface.

Definition at line 97 of file UmlSequenceDiagramFactoryFromXml.class.php.

Referenced by loadActors(), loadMessages(), and perform().

00098     {
00099         return $this->objUmlSequenceDiagram;
00100     }

getXml (  ) 

Get the xml of the sequence object

See also:
UmlSequenceDiagram->objXml

UmlSequenceDiagram::setXml( string )

Parameters:
string $strXml
Returns:
SimpleXmlElement

Definition at line 73 of file UmlSequenceDiagramFactoryFromXml.class.php.

00074     {
00075         return $this->objXml;
00076     }

loadActors (  )  [protected]

Load the xml file and based on it insert a list of actors into the UmlSequenceDiagram Object

Definition at line 120 of file UmlSequenceDiagramFactoryFromXml.class.php.

References getUmlSequenceDiagram().

Referenced by perform().

00121     {
00122         $arrActors = $this->getUmlSequenceDiagram()->getActors();
00123 
00124         foreach( $this->objXml->actors->actor as $xmlActor )
00125         {
00126             $strId = (string)$xmlActor['id'];
00127             $strType = (string)$xmlActor['type'];
00128             $strName = (string)$xmlActor;
00129 
00130             $objActor = new UmlSequenceDiagramActor();
00131             $objActor->setId( $strId );
00132             $objActor->setType( $strType );
00133             $objActor->setName( $strName );
00134 
00135             $arrActors[ $objActor->getId() ] = $objActor;
00136         }
00137         $this->getUmlSequenceDiagram()->setActors( $arrActors );
00138     }

loadMessages (  )  [protected]

Load the xml file and based on it insert a list of messages into the UmlSequenceDiagram Object

Definition at line 144 of file UmlSequenceDiagramFactoryFromXml.class.php.

References getUmlSequenceDiagram().

Referenced by perform().

00145     {
00146         $arrMessages = $this->getUmlSequenceDiagram()->getMessages();
00147         $arrActors = $this->getUmlSequenceDiagram()->getActors();
00148 
00149         foreach( $this->objXml->messages->message as $xmlMessage )
00150         {
00151             $strFrom    = (string)$xmlMessage[ 'from' ];
00152             $strTo      = (string)$xmlMessage[ 'to' ];
00153             $strType    = (string) $xmlMessage[ 'type' ];
00154             $strText = (string) $xmlMessage[ 'text' ];
00155 
00156             $objMessage = new UmlSequenceDiagramMessage();
00157             $objMessage->setType( $strType );
00158             $objMessage->setText( $strText );
00159 
00160            if( !array_key_exists( $strFrom , $arrActors ) )
00161             {
00162                 throw new Exception( ' Actor From ' . $strFrom . ' not Found ' );
00163             }
00164             $objMessage->setActorFrom( $arrActors[ $strFrom ] );
00165 
00166            if( !array_key_exists( $strTo , $arrActors ) )
00167             {
00168                 throw new Exception( ' Actor To ' . $strTo . ' not Found ' );
00169             }
00170             $objMessage->setActorTo( $arrActors[ $strTo ] );
00171 
00172             if( isset( $xmlMessage->values->value ) )
00173             foreach( $xmlMessage->values->value as $xmlValue )
00174             {
00175                 $strName = (string)$xmlValue['name'];
00176                 $strValue = (string)$xmlValue['value'];
00177                 $objValue = new UmlSequenceDiagramValue();
00178                 $objValue->setName( $strName );
00179                 $objValue->setValue( $strValue );
00180 
00181                 $objMessage->addValue( $objValue );
00182             }
00183 
00184             $arrMessages[] = $objMessage;
00185         }
00186         $this->getUmlSequenceDiagram()->setMessages( $arrMessages );
00187     }

perform (  ) 

create a UmlSequenceDiagram based into its configurations

See also:
UmlSequenceDiagramFactoryInterface->perform()
Returns:
UmlSequenceDiagram

Implements UmlSequenceDiagramFactoryInterface.

Definition at line 108 of file UmlSequenceDiagramFactoryFromXml.class.php.

References getUmlSequenceDiagram(), loadActors(), loadMessages(), and setUmlSequenceDiagram().

00109     {
00110         $this->setUmlSequenceDiagram( new UmlSequenceDiagram() );
00111         $this->loadActors();
00112         $this->loadMessages();
00113         return $this->getUmlSequenceDiagram();
00114     }

setUmlSequenceDiagram ( UmlSequenceDiagram objUmlSequenceDiagram  ) 

set the xml sequence object

See also:
UmlSequenceDiagramFactoryInterface->setUmlSequenceDiagram( UmlSequenceDiagram )
Parameters:
$objUmlSequenceDiagram 
Returns:
UmlSequenceDiagramFactoryFromXml me

Implements UmlSequenceDiagramFactoryInterface.

Definition at line 85 of file UmlSequenceDiagramFactoryFromXml.class.php.

Referenced by perform().

00086     {
00087         $this->objUmlSequenceDiagram = $objUmlSequenceDiagram;
00088         return $this;
00089     }

setXml ( strXml  ) 

Set the xml of the sequence object

See also:
UmlSequenceDiagram->objXml

UmlSequenceDiagram::getXml()

Parameters:
string $strXml
Returns:
UmlSequenceDiagramFactoryFromXml me

Definition at line 59 of file UmlSequenceDiagramFactoryFromXml.class.php.

References $strXml.

00060     {
00061         $this->objXml = simplexml_load_string( $strXml );
00062         return $this;
00063     }


Member Data Documentation

$objInstance [static, protected]

Singleton of the UmlSequenceDiagramFactoryFromXml

See also:
UmlSequenceDiagramFactoryInterface::$objInstance
UmlSequenceDiagramFactoryFromXml

Definition at line 19 of file UmlSequenceDiagramFactoryFromXml.class.php.

$objUmlSequenceDiagram [protected]

Xml Sequence Object in factory

See also:
UmlSequenceDiagramFactoryInterface->objUmlSequenceDiagram
UmlSequenceDiagram

Definition at line 27 of file UmlSequenceDiagramFactoryFromXml.class.php.

$objXml [protected]

Simple Xml Element used to access information from a xml

SimpleXmlElement

Definition at line 34 of file UmlSequenceDiagramFactoryFromXml.class.php.


The documentation for this class was generated from the following file:

Generated on Thu Feb 3 03:55:04 2011 for CodeToDiagram by  doxygen 1.5.9