All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ingenias.editor.persistence.ObjectSave Maven / Gradle / Ivy


/** 
 * Copyright (C) 2010  Jorge J. Gomez-Sanz
 * 
 * 
 * This file is part of the INGENME tool. INGENME is an open source meta-editor
 * which produces customized editors for user-defined modeling languages
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation version 3 of the License
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see 
 **/
 
package ingenias.editor.persistence;
import java.lang.reflect.*;
import javax.swing.tree.*;
import org.apache.xerces.parsers.DOMParser;
import org.xml.sax.InputSource;

import java.awt.Color;
import java.awt.Point;
import java.awt.Rectangle;
import java.io.OutputStreamWriter;
import java.io.*;
import javax.swing.tree.DefaultMutableTreeNode;
import java.util.*;
import java.util.Map;
import java.util.Hashtable;
import java.util.ArrayList;
import javax.xml.parsers.*;

import org.jgraph.JGraph;
import org.jgraph.graph.*;
import org.w3c.dom.*;
import org.w3c.dom.Document;
import org.w3c.dom.DOMImplementation;

import ingenias.editor.entities.*;
import ingenias.exception.*;
import ingenias.editor.cell.*;
import ingenias.editor.*;

public class ObjectSave extends ObjectSaveAbs{

  public void saveObject(ingenias.editor.entities.Entity en, OutputStreamWriter os) throws
      IOException {
    String _name1 = ingenias.editor.entities.Entity.encodeutf8Text(en.getId());
    os.write( "\n");
    Enumeration enumeration = null;

    
        if (en instanceof ingenias.editor.entities.PropertyField){
          ingenias.editor.entities.PropertyField nen=(ingenias.editor.entities.PropertyField)en;
	  String _name;
          
          _name=ingenias.editor.entities.Entity.encodeutf8Text("WrappedType");
          os.write("\n");
          if (nen.getWrappedType()!=null)
           saveObject(nen.getWrappedType(),os);
          os.write("\n");
          
          
        }
        
        if (en instanceof ingenias.editor.entities.MetaObjectTypeWrapper){
          ingenias.editor.entities.MetaObjectTypeWrapper nen=(ingenias.editor.entities.MetaObjectTypeWrapper)en;
	  String _name;
          
          _name=ingenias.editor.entities.Entity.encodeutf8Text("MetaObjectType");
          os.write("\n");
          if (nen.getMetaObjectType()!=null)
           saveObject(nen.getMetaObjectType(),os);
          os.write("\n");
          
          
        }
        
        if (en instanceof ingenias.editor.entities.MetaDiagram){
          ingenias.editor.entities.MetaDiagram nen=(ingenias.editor.entities.MetaDiagram)en;
	  String _name;
          
          _name=ingenias.editor.entities.Entity.encodeutf8Text("BasicRepresentations");
          os.write("\n");
          if (nen.getBasicRepresentations()!=null)
           saveObject(nen.getBasicRepresentations(),os);
          os.write("\n");
          
          
          os.write("\n");
             enumeration=nen.getPreferredOrderElements();
          while (enumeration.hasMoreElements()){
            ingenias.editor.entities.Entity next=(ingenias.editor.entities.Entity)enumeration.nextElement();
           saveObject(next,os);
          }
          os.write("\n");
          
          os.write("\n");
             enumeration=nen.getPropertiesElements();
          while (enumeration.hasMoreElements()){
            ingenias.editor.entities.Entity next=(ingenias.editor.entities.Entity)enumeration.nextElement();
           saveObject(next,os);
          }
          os.write("\n");
          
        }
        
        if (en instanceof ingenias.editor.entities.ExternalTypeWrapper){
          ingenias.editor.entities.ExternalTypeWrapper nen=(ingenias.editor.entities.ExternalTypeWrapper)en;
	  String _name;
          
          
          os.write("\n");
             enumeration=nen.getDefaultValuesElements();
          while (enumeration.hasMoreElements()){
            ingenias.editor.entities.Entity next=(ingenias.editor.entities.Entity)enumeration.nextElement();
           saveObject(next,os);
          }
          os.write("\n");
          
        }
        
        if (en instanceof ingenias.editor.entities.MetaRelationship){
          ingenias.editor.entities.MetaRelationship nen=(ingenias.editor.entities.MetaRelationship)en;
	  String _name;
          
          _name=ingenias.editor.entities.Entity.encodeutf8Text("BasicRepresentations");
          os.write("\n");
          if (nen.getBasicRepresentations()!=null)
           saveObject(nen.getBasicRepresentations(),os);
          os.write("\n");
          
          
          os.write("\n");
             enumeration=nen.getPreferredOrderElements();
          while (enumeration.hasMoreElements()){
            ingenias.editor.entities.Entity next=(ingenias.editor.entities.Entity)enumeration.nextElement();
           saveObject(next,os);
          }
          os.write("\n");
          
          os.write("\n");
             enumeration=nen.getPropertiesElements();
          while (enumeration.hasMoreElements()){
            ingenias.editor.entities.Entity next=(ingenias.editor.entities.Entity)enumeration.nextElement();
           saveObject(next,os);
          }
          os.write("\n");
          
          os.write("\n");
             enumeration=nen.getVisualRepresentationsElements();
          while (enumeration.hasMoreElements()){
            ingenias.editor.entities.Entity next=(ingenias.editor.entities.Entity)enumeration.nextElement();
           saveObject(next,os);
          }
          os.write("\n");
          
        }
        
        if (en instanceof ingenias.editor.entities.DefaultValue){
          ingenias.editor.entities.DefaultValue nen=(ingenias.editor.entities.DefaultValue)en;
	  String _name;
          
          
        }
        
        if (en instanceof ingenias.editor.entities.PropertyOrder){
          ingenias.editor.entities.PropertyOrder nen=(ingenias.editor.entities.PropertyOrder)en;
	  String _name;
          
          _name=ingenias.editor.entities.Entity.encodeutf8Text("Property");
          os.write("\n");
          if (nen.getProperty()!=null)
           saveObject(nen.getProperty(),os);
          os.write("\n");
          
          
        }
        
        if (en instanceof ingenias.editor.entities.Documentation){
          ingenias.editor.entities.Documentation nen=(ingenias.editor.entities.Documentation)en;
	  String _name;
          
          
        }
        
        if (en instanceof ingenias.editor.entities.PreferredOrder){
          ingenias.editor.entities.PreferredOrder nen=(ingenias.editor.entities.PreferredOrder)en;
	  String _name;
          
          
          os.write("\n");
             enumeration=nen.getPreferredOrderElements();
          while (enumeration.hasMoreElements()){
            ingenias.editor.entities.Entity next=(ingenias.editor.entities.Entity)enumeration.nextElement();
           saveObject(next,os);
          }
          os.write("\n");
          
        }
        
        if (en instanceof ingenias.editor.entities.MetaObject){
          ingenias.editor.entities.MetaObject nen=(ingenias.editor.entities.MetaObject)en;
	  String _name;
          
          _name=ingenias.editor.entities.Entity.encodeutf8Text("Keyfield");
          os.write("\n");
          if (nen.getKeyfield()!=null)
           saveObject(nen.getKeyfield(),os);
          os.write("\n");
          
          _name=ingenias.editor.entities.Entity.encodeutf8Text("BasicRepresentations");
          os.write("\n");
          if (nen.getBasicRepresentations()!=null)
           saveObject(nen.getBasicRepresentations(),os);
          os.write("\n");
          
          
          os.write("\n");
             enumeration=nen.getVisualRepresentationsElements();
          while (enumeration.hasMoreElements()){
            ingenias.editor.entities.Entity next=(ingenias.editor.entities.Entity)enumeration.nextElement();
           saveObject(next,os);
          }
          os.write("\n");
          
          os.write("\n");
             enumeration=nen.getPropertiesElements();
          while (enumeration.hasMoreElements()){
            ingenias.editor.entities.Entity next=(ingenias.editor.entities.Entity)enumeration.nextElement();
           saveObject(next,os);
          }
          os.write("\n");
          
          os.write("\n");
             enumeration=nen.getPreferredOrderElements();
          while (enumeration.hasMoreElements()){
            ingenias.editor.entities.Entity next=(ingenias.editor.entities.Entity)enumeration.nextElement();
           saveObject(next,os);
          }
          os.write("\n");
          
        }
        
        if (en instanceof ingenias.editor.entities.BasicRepresentation){
          ingenias.editor.entities.BasicRepresentation nen=(ingenias.editor.entities.BasicRepresentation)en;
	  String _name;
          
          
        }
        
        if (en instanceof ingenias.editor.entities.VisualRepresentation){
          ingenias.editor.entities.VisualRepresentation nen=(ingenias.editor.entities.VisualRepresentation)en;
	  String _name;
          
          
        }
        
        if (en instanceof ingenias.editor.entities.TypeWrapper){
          ingenias.editor.entities.TypeWrapper nen=(ingenias.editor.entities.TypeWrapper)en;
	  String _name;
          
          
        }
        
        if (en instanceof ingenias.editor.entities.UMLComment){
          ingenias.editor.entities.UMLComment nen=(ingenias.editor.entities.UMLComment)en;
	  String _name;
          
          
        }
        
        if (en instanceof ingenias.editor.entities.MetaRole){
          ingenias.editor.entities.MetaRole nen=(ingenias.editor.entities.MetaRole)en;
	  String _name;
          
          
          os.write("\n");
             enumeration=nen.getPreferredOrderElements();
          while (enumeration.hasMoreElements()){
            ingenias.editor.entities.Entity next=(ingenias.editor.entities.Entity)enumeration.nextElement();
           saveObject(next,os);
          }
          os.write("\n");
          
          os.write("\n");
             enumeration=nen.getPropertiesElements();
          while (enumeration.hasMoreElements()){
            ingenias.editor.entities.Entity next=(ingenias.editor.entities.Entity)enumeration.nextElement();
           saveObject(next,os);
          }
          os.write("\n");
          
          os.write("\n");
             enumeration=nen.getValidPlayersElements();
          while (enumeration.hasMoreElements()){
            ingenias.editor.entities.Entity next=(ingenias.editor.entities.Entity)enumeration.nextElement();
           saveObject(next,os);
          }
          os.write("\n");
          
        }
        
        if (en instanceof ingenias.editor.entities.MetaDiagramTypeWrapper){
          ingenias.editor.entities.MetaDiagramTypeWrapper nen=(ingenias.editor.entities.MetaDiagramTypeWrapper)en;
	  String _name;
          
          _name=ingenias.editor.entities.Entity.encodeutf8Text("MetaDiagramType");
          os.write("\n");
          if (nen.getMetaDiagramType()!=null)
           saveObject(nen.getMetaDiagramType(),os);
          os.write("\n");
          
          
        }
        

        
         if (en.getClass().equals(ingenias.editor.entities.MetamodelDataEntity.class)){
          ingenias.editor.entities.MetamodelDataEntity nen=(ingenias.editor.entities.MetamodelDataEntity)en;
	 String _name;
	
          
        }
        

        
         if (en.getClass().equals(ingenias.editor.entities.Contains.class)){
          ingenias.editor.entities.Contains nen=(ingenias.editor.entities.Contains)en;
          
          
        }
        
         if (en.getClass().equals(ingenias.editor.entities.IsDocumentedBy.class)){
          ingenias.editor.entities.IsDocumentedBy nen=(ingenias.editor.entities.IsDocumentedBy)en;
          
          
        }
        
         if (en.getClass().equals(ingenias.editor.entities.PropsOrderedAs.class)){
          ingenias.editor.entities.PropsOrderedAs nen=(ingenias.editor.entities.PropsOrderedAs)en;
          
          
        }
        
         if (en.getClass().equals(ingenias.editor.entities.VisualizedAs.class)){
          ingenias.editor.entities.VisualizedAs nen=(ingenias.editor.entities.VisualizedAs)en;
          
          
        }
        
         if (en.getClass().equals(ingenias.editor.entities.HasMO.class)){
          ingenias.editor.entities.HasMO nen=(ingenias.editor.entities.HasMO)en;
          
          
        }
        
         if (en.getClass().equals(ingenias.editor.entities.AssociationEnd.class)){
          ingenias.editor.entities.AssociationEnd nen=(ingenias.editor.entities.AssociationEnd)en;
          
          
        }
        
         if (en.getClass().equals(ingenias.editor.entities.PlayedBy.class)){
          ingenias.editor.entities.PlayedBy nen=(ingenias.editor.entities.PlayedBy)en;
          
          
        }
        
         if (en.getClass().equals(ingenias.editor.entities.BinaryRel.class)){
          ingenias.editor.entities.BinaryRel nen=(ingenias.editor.entities.BinaryRel)en;
          
          os.write("\n");
          if (nen.getBasicRepresentations()!=null)
           saveObject(nen.getBasicRepresentations(),os);
          os.write("\n");
          
          
            os.write("\n");
             enumeration=nen.getPreferredOrderElements();
          while (enumeration.hasMoreElements()){
            ingenias.editor.entities.Entity next=(ingenias.editor.entities.Entity)enumeration.nextElement();
           saveObject(next,os);
          }
            os.write("\n");
          
            os.write("\n");
             enumeration=nen.getPropertiesElements();
          while (enumeration.hasMoreElements()){
            ingenias.editor.entities.Entity next=(ingenias.editor.entities.Entity)enumeration.nextElement();
           saveObject(next,os);
          }
            os.write("\n");
          
            os.write("\n");
             enumeration=nen.getVisualRepresentationsElements();
          while (enumeration.hasMoreElements()){
            ingenias.editor.entities.Entity next=(ingenias.editor.entities.Entity)enumeration.nextElement();
           saveObject(next,os);
          }
            os.write("\n");
          
        }
        
         if (en.getClass().equals(ingenias.editor.entities.InheritsR.class)){
          ingenias.editor.entities.InheritsR nen=(ingenias.editor.entities.InheritsR)en;
          
          
        }
        
         if (en.getClass().equals(ingenias.editor.entities.UMLAnnotatedElement.class)){
          ingenias.editor.entities.UMLAnnotatedElement nen=(ingenias.editor.entities.UMLAnnotatedElement)en;
          
          
        }
        
         if (en.getClass().equals(ingenias.editor.entities.InheritsO.class)){
          ingenias.editor.entities.InheritsO nen=(ingenias.editor.entities.InheritsO)en;
          
          
        }
        
         if (en.getClass().equals(ingenias.editor.entities.Has.class)){
          ingenias.editor.entities.Has nen=(ingenias.editor.entities.Has)en;
          
          
        }
        



    Hashtable ht = new Hashtable();
    en.toMap(ht);
    saveMap(ht, os);
    os.write( "\n");
  }



 

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy