Location: PHPKode > projects > Entier Studio > entierstudio/framework/xmi.explorer.php
<?php
/**
 * Entier Studio
 *
 * LICENSE
 *
 *	Copyright 2006 Entier Studio team.
 *
 *	Licensed under the Apache License, Version 2.0 (the "License");
 *	you may not use this file except in compliance with the License.
 *	You may obtain a copy of the License at
 *
 *		http://www.apache.org/licenses/LICENSE-2.0
 *
 *	Unless required by applicable law or agreed to in writing, software
 *	distributed under the License is distributed on an "AS IS" BASIS,
 *	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *	See the License for the specific language governing permissions and
 *	limitations under the License.
 *
 * @package    entier.framework
 * @copyright  Copyright (c) 2006 Entier Studio team. All rights reserved.
 * @version	   $Id: xmi.explorer.php 81 2008-01-17 23:08:21Z yannromefort $
 */
//-----------------------------------------------------------------------------
//	namespace
if (!defined("DefXMIExplorer")) {
    //-------------------------------------------------------------------------
    //	Define
    define("DefXMIExplorer", "1");
    //-------------------------------------------------------------------------
    //	Include
    @require_once (FRAMEWORK_DIR . "xml.explorer.php");
    @require_once (FRAMEWORK_DIR . "uml.model.element.php");
    //-------------------------------------------------------------------------
    //	Class
    class XMIExplorer extends XMLExplorer {
        //---------------------------------------------------------------------
        //	Attributes
        
        /**
         * Parse Foundation.Core.Namespace.ownedElement
         * @var	boolean
         */
        var $m_TreeNode = -1;
        /**
         * Parse Foundation.Core.ModelElement.namespace
         * @var	boolean
         */
        var $m_LinkNode = false;
        /**
         * Parse Element uuid
         * @var	string
         */
        var $m_TempUuid = "";
        //-----------------------------------------------------------------------------
        //	Constructor
        
        /**
         *
         * @param	string	host
         * @param	string	port
         * @param	string	user
         * @param	string	pass
         * @param	string	base
         */
        function XMIExplorer($hostName = "", $hostPort = 0, $userName = "", $passWord = "", $dataBase = "") {
            //
            parent::XMLExplorer($hostName, $hostPort, $userName, $passWord, $dataBase);
        }
        //-----------------------------------------------------------------------------
        //	Methods
        //
        //	private parser interface
        //
        
        /**
         *
         * @param	object
         * @param	string
         * @param	array
         *
         */
        function startElement($parser, $name, $attrs) {
            //
            switch ($name) {
                case "Model_Management.Model":
                    //
                    if ($this->m_LinkNode == false) {
                        $this->m_TempType = "model";
                        $this->m_TempUuid = $attrs["xmi.id"];
                    }
                    //
                    
                break;
                case "Model_Management.Package":
                case "Model_Management.Subsystem":
                    //
                    if ($this->m_LinkNode == false) {
                        $this->m_TempType = "package";
                        $this->m_TempUuid = $attrs["xmi.id"];
                    }
                    //
                    
                break;
                case "Foundation.Core.Class":
                    //
                    if ($this->m_LinkNode == false) {
                        $this->m_TempType = "class";
                        $this->m_TempUuid = $attrs["xmi.id"];
                    }
                    //
                    
                break;
                case "Foundation.Core.Attribute":
                    //
                    $this->m_TempType = "attribute";
                    //
                    
                break;
                case "Foundation.Core.Operation":
                    //
                    $this->m_TempType = "operation";
                    //
                    
                break;
                case "Foundation.Core.DataType":
                    //
                    $this->m_TempType = "datatype";
                    //
                    
                break;
                case "Foundation.Core.ModelElement.name":
                    //
                    $this->m_NameNode = true;
                    //
                    
                break;
                case "Foundation.Core.Namespace.ownedElement":
                    //
                    if ($this->m_TreeNode > -1) $this->m_TreeNode++;
                    //
                    break;
                case "Foundation.Core.ModelElement.namespace":
                    //
                    $this->m_LinkNode = true;
                    //
                    break;
                default:
                    //
                    $this->m_TempType = "";
                    //
                    break;
                }
        }
        /**
         *
         * @param	object
         * @param	string
         *
         */
        function endElement($parser, $name) {
            //
            switch ($name) {
                case "Foundation.Core.ModelElement.name":
                    //
                    $this->m_NameNode = false;
                    //
                    
                break;
                case "Foundation.Core.ModelElement.namespace":
                    //
                    $this->m_LinkNode = false;
                    //
                    
                break;
                case "Foundation.Core.Namespace.ownedElement":
                    //
                    if ($this->m_TreeNode == 1) $this->m_TreeNode = -1;
                    if ($this->m_TreeNode > 1) $this->m_TreeNode--;
                    //
                    break;
                }
            }
            /**
             *
             * @param	object
             * @param	string
             *
             */
            function characterData($parser, $data) {
                //
                if ($this->m_NameNode == false) return;
                //
                $this->m_TempName = $data;
                //
                if ($this->m_TreeNode != 1) {
                    if ($this->m_TreeNode == -1) {
                        //
                        if ($this->m_TempType == $this->m_typeName) {
                            //
                            $path = @explode("/", $this->m_nodeName);
                            $leng = count($path);
                            if ($leng > 0) $name = $path[$leng-1];
                            else $name = $this->m_nodeName;
                            //
                            if ($data == $name) {
                                //
                                $this->m_TreeNode = 0;
                            }
                        }
                    }
                    //
                    return;
                }
                //
                switch ($this->m_typeName) {
                    case "model":
                        //
                        $model = $this->m_nodeName;
                        //
                        switch ($this->m_TempType) {
                            case "package":
                                //
                                $this->m_elements[$this->m_TempUuid] = new UMLModelElement($data, $this->m_TempType, 1, $model . "/" . $data);
                            break;
                            case "class":
                                //
                                $this->m_elements[$this->m_TempUuid] = new UMLModelElement($data, $this->m_TempType, 2, $model . "/" . $data);
                            break;
                        }
                        //
                        
                    break;
                    case "package":
                        //
                        $package = $this->m_nodeName;
                        //
                        switch ($this->m_TempType) {
                            case "package":
                                //
                                $this->m_elements[$this->m_TempUuid] = new UMLModelElement($data, $this->m_TempType, 1, $package . "/" . $data);
                                //
                                
                            break;
                            case "class":
                                //
                                $this->m_elements[$this->m_TempUuid] = new UMLModelElement($data, $this->m_TempType, 2, $package . "/" . $data);
                                //
                                
                            break;
                        }
                        //
                        
                    break;
                    case "class":
                        //
                        $class = $this->m_nodeName;
                        //
                        switch ($this->m_TempType) {
                            case "attribute":
                            case "operation":
                                //
                                $this->m_elements[$this->m_TempUuid] = new UMLModelElement($data, $this->m_TempType, 3, $class . "/" . $data);
                                //
                                
                            break;
                        }
                        //
                        
                    break;
                }
            }
        };
        //	Class XMIExplorer
        //-----------------------------------------------------------------------------
        
    }
    //	namespace
    //--------------------------------------------------------------------------
    
?>
Return current item: Entier Studio