home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / VCAFE.3.0A / Main.bin / VisualProject.java < prev    next >
Text File  |  1998-11-11  |  24KB  |  615 lines

  1. /*
  2.  * Copyright 1998 Symantec Corporation, All Rights Reserved.
  3.  */
  4.  
  5. package com.symantec.itools.vcafe.openapi;
  6.  
  7. import com.symantec.itools.vcafe.openapi.options.ProjectOptionSet;
  8. import com.symantec.itools.vcafe.openapi.dtreflect.DTClass;
  9. import com.symantec.itools.vcafe.openapi.dtreflect.DTListener;
  10.  
  11. import java.io.File;
  12. import java.util.Enumeration;
  13. import java.net.URL;
  14.  
  15. /**
  16.  * The API used to represent and access a Visual Cafe project.
  17.  *
  18.  * To get a <code>VisualProject</code> to work with, use one of the following <code>VisualCafe</code> methods:<ul style=circle>
  19.  * <li><code>getProjects()</code> to get all open projects,
  20.  * <li><code>getTargetProject()</code> to get the currently active project,
  21.  * <li><code>getProject()</code> to get an open project with a given name,
  22.  * <li><code>openProject()</code> to open a project,
  23.  * <li><code>createProject()</code> to create a new project,
  24.  * <li><code>createEmptyProject()</code> to create a new empty project, or
  25.  * <li><code>createDefaultProject()</code> to create a new project from the default project template.
  26.  * </ul>
  27.  *
  28.  * The implementation of all of <code>VisualProject</code>'s abstract methods first calls
  29.  * checkValidity().  Any method could therefore throw an <code>InvalidVisualProjectException</code>.
  30.  * This exception extends <code>RuntimeException</code>, so doesn't have to be explicity declared or
  31.  * caught.  A <code>VisualProject</code> can become invalid if it is closed, and the corresponding
  32.  * <code>ProjectListener</code> message is ignored, for example.
  33.  *
  34.  * @see VisualCafe
  35.  * @see VisualCafe#getProjects
  36.  * @see VisualCafe#getTargetProject
  37.  * @see VisualCafe#getProject
  38.  * @see VisualCafe#openProject
  39.  * @see VisualCafe#createProject
  40.  * @see VisualCafe#createEmptyProject
  41.  * @see VisualCafe#createDefaultProject
  42.  *
  43.  * @author Symantec Internet Tools Division
  44.  * @version 1.0
  45.  * @since VCafe 3.0
  46.  */
  47. public abstract class VisualProject
  48. {
  49.  
  50.     /**
  51.      * Gets the name of the project.
  52.      *
  53.      * @return        name of the project.
  54.      */
  55.     public abstract String getProjectName();
  56.  
  57.  
  58.     /**
  59.      * Gets the built project's document base.
  60.      *
  61.      * @return        the document base for this project's executable.
  62.      */
  63.     public abstract URL getDocumentBase() throws java.net.MalformedURLException;
  64.  
  65.  
  66.     /**
  67.      * Gets the <code>File</code> associated with this <code>VisualProject</code> file.
  68.      * @return this <code>VisualProject</code>'s <code>File</code>.
  69.      */
  70.     public abstract File getFile();
  71.  
  72.  
  73.     /**
  74.      * Mark this <code>VisualProject</code>'s contents modified.
  75.      * This can be useful if you save persistent attributes in response to
  76.      * <code>ProjectListener.aboutToSaveProject()</code>.
  77.      * @see ProjectListener#aboutToSaveProject
  78.      */
  79.     public abstract void setModified();
  80.  
  81.     /**
  82.      * Saves this <code>VisualProject</code>.
  83.      */
  84.     public abstract void save();
  85.  
  86.     /**
  87.      * Saves this <code>VisualProject</code> to a new name.
  88.      * @param newFile where to save this <code>VisualProject</code>.
  89.      */
  90.     public abstract void saveAs(File newFile);
  91.  
  92.     /**
  93.      * Closes this <code>VisualProject</code>.
  94.      */
  95.     public abstract void close();
  96.  
  97.  
  98.     /**
  99.      * Gets the class that allows access to this project's <code>VisualObjects</code>.
  100.      *
  101.      * @return        this project's object library
  102.      * @see VisualRepository
  103.      */
  104.     public abstract VisualRepository getObjectLibrary();
  105.  
  106.     /**
  107.      * Get the <code>Attributes</code> object that allows project-related named value storage.
  108.      *
  109.      * The values stored in the returned <code>Attributes</code> object are assoicated with this
  110.      * specific <code>VisualProject</code>, not with the Visual Cafe program in general.  To create
  111.      * global name values (not specific to any one project), use <code>VisualCafe</code>'s
  112.      * <code>getAttributes</code> method.
  113.      * @return this project's <code>Attributes</code> storage object.
  114.      * @see ProjectInputStream
  115.      * @see Attributes
  116.      */
  117.     public abstract Attributes getAttributes();
  118.  
  119.     /**
  120.      * Gets the <code>ClassLoader</code> for objects/classes in this project.
  121.      *
  122.      * @return        this project's <code>ClassLoader</code>.
  123.      */
  124.     public abstract ClassLoader getClassLoader();
  125.  
  126.     /**
  127.      * Gets this project's 'type'.  More specific than the project's target type.
  128.      * @return the project's type.
  129.      * @see symantec.itools.projecttemplates.ProjectTemplateInterface;
  130.      * @see com.symantec.itools.vcafe.openapi.options.ProjectOptions#getTargetType
  131.      */
  132.     public abstract int getProjectType();
  133.  
  134.     /**
  135.      * Sets this project's 'type'.  More specific than the project's target type.  The Target Type
  136.      * is updated in all of the project's option sets (Debug and Final).
  137.      * @param projectType the project's new type.
  138.      * @see symantec.itools.projecttemplates.ProjectTemplateInterface;
  139.      * @see com.symantec.itools.vcafe.openapi.options.ProjectOptions#getTargetType
  140.      */
  141.     public abstract void setProjectType(int projectType);
  142.  
  143.     /**
  144.      * Gets this project's options.
  145.      * The returned <code>ProjectOptionSet</code> allows access to the options for this project.
  146.      *
  147.      * @return        the project's options.
  148.      * @see com.symantec.itools.vcafe.openapi.options.ProjectOptionSet
  149.      */
  150.     public abstract ProjectOptionSet getOptionSet();
  151.  
  152.  
  153.     /**
  154.      * Gets the class that allows access to this project's build commands.
  155.      * @return        this project's <code>BuildManager</code>
  156.      * @see BuildManager
  157.      */
  158.     public abstract BuildManager getBuildManager();
  159.  
  160.  
  161.     /**
  162.      * Builds the project and runs the resulting program.
  163.      * The debugger is <i>not</i> used to run the program.
  164.      * @see BuildManager#build
  165.      */
  166.     public abstract void execute();
  167.  
  168.     /**
  169.      * Builds the project and runs the resulting program under the debugger.
  170.      * @see BuildManager#build
  171.      */
  172.     public abstract void runInDebugger();
  173.  
  174.  
  175.     /**
  176.      * Gets the Design-Time Reflection <code>DTClass</code> object associated with the class
  177.      * with the given string name.
  178.      * @param className the name of a class in the project to find a design-time reflection class for.
  179.      * @return a <code>DTClass</code> object for the class.
  180.      */
  181.     public abstract DTClass getDTClassObject(String className);
  182.  
  183.     /**
  184.      * Parses the files in the project.  Only outdated files are parsed.  This causes
  185.      * the project's Design-Time Reflection classes to be updated.
  186.      */
  187.     public abstract void parseOutstandingFiles();
  188.  
  189.     /**
  190.      * Tells this project to suspend the background parsing of <code>DTClass</code> information.
  191.      * @param bringUpToDate if <code>true</code>, make sure the state of the <code>DTClass</code> information is
  192.      *                        brought up to date before suspending the parser.
  193.      * This method <b>must</b> be matched by a call to <code>resumeBackgroundParser()</code>.
  194.      * example usage:<code>
  195.      *        visualProject.suspendBackgroundParser(false);
  196.      *        try {
  197.      *            ...
  198.      *            ... lots of processing here that causes parsing ...
  199.      *            ...
  200.      *        } finally {
  201.      *            visualProject.resumeBackgroundParser(true);
  202.      *        }</code>
  203.      */
  204.     public abstract void suspendBackgroundParser(boolean bringUpToDate);
  205.  
  206.     /**
  207.      * Tells the project that it can resume the background parsing of <code>DTClass</code> information.
  208.      * @param bringUpToDate if true, update the <code>DTClass</code> information.
  209.      */
  210.     public abstract void resumeBackgroundParser(boolean bringUpToDate);
  211.  
  212.  
  213.     /**
  214.      * Gets all of the files in this project.
  215.      * An array is returned containing all of the files.  If there are no files in the project, a
  216.      * zero-length array is returned.
  217.      *
  218.      * @return    array of <code>ProjectFile</code> objects
  219.      * @see #getProjectFiles(int)
  220.      * @see #getProjectFile(String)
  221.      * @see #getProjectFile(int)
  222.      * @see    ProjectFile
  223.      */
  224.     public abstract ProjectFile[] getProjectFiles();
  225.  
  226.  
  227.     /**
  228.      * Gets all of the files in this project added by the specified source.
  229.      * An array is returned containing all of the added files.  If there are no files, a
  230.      * zero-length array is returned.
  231.      * @param    addedBy the source that added the file to the project, is a mask containing any of:<ul type=circle>
  232.      * <li>USER_ADDED - files added by the user.
  233.      * <li>COMPILER_ADDED - files added by the compiler.
  234.      * <li>PARSER_ADDED - files added by the parser.
  235.      * <li>UNKNOWN_ADDED - files added by an unknown source.
  236.      * <li>SHARED_DATABASE_ADDED - files added by the database.
  237.      * <li>ERAD_WIZARD_ADDED - the file was added by one of the ERAD wizards.
  238.      * <li>ALL_FILE_ADDED - files added by any source.
  239.      * </ul>
  240.      * @return    array of <code>ProjectFile</code> objects
  241.      * @see    #getProjectFiles()
  242.      * @see #getProjectFile(String)
  243.      * @see #getProjectFile(int)
  244.      * @see    ProjectFile
  245.      * @see    ProjectFile#getFileAddedBy
  246.      */
  247.     public abstract ProjectFile[] getProjectFiles(int addedBy);
  248.  
  249.  
  250.     /**
  251.      * Gets a <code>ProjectFile</code> that corresponds to the file with the given name.
  252.      * If the file isn't in this project, <code>null</code> is returned.
  253.      * @param    fileName the name of the desired file.
  254.      * @return    a <code>ProjectFile</code> object, or <code>null</code> if not found.
  255.      * @see    #getProjectFiles()
  256.      * @see #getProjectFile(int)
  257.      * @see    ProjectFile
  258.      */
  259.     public abstract ProjectFile getProjectFile(String fileName);
  260.  
  261.     /**
  262.      * Gets a <code>ProjectFile</code> that corresponds to the file id.
  263.      * If the file isn't in this project, <code>null</code> is returned.
  264.      * @param    projectFileId the id of the desired file.
  265.      * @return    a <code>ProjectFile</code> object, or <code>null</code> if not found.
  266.      * @see    #getProjectFiles()
  267.      * @see #getProjectFile(String)
  268.      * @see    ProjectFile
  269.      */
  270.     public abstract ProjectFile getProjectFile(int projectFileID);
  271.  
  272.  
  273.     /**
  274.      * Adds a [relative, ProjectFile.USER_ADDED, ENABLE_RAD_DEFAULT, UPDATE_PROJECT_BEANS_NO] file to this <code>VisualProject</code>.
  275.      * @param file    file to be added.
  276.      * @return        the resultant <code>ProjectFile</code> object.
  277.      * @exception    IllegalArgumentException if the file doesn't exist or is a diretory.
  278.      * @see    ProjectFile
  279.      */
  280.     public abstract ProjectFile addFile(File file);
  281.  
  282.         /**
  283.          * An <code>addFile</code> "enableRAD" value indicating the file should added with RAD enabled.
  284.          * @see #addFile(String, boolean, int, int)
  285.          */
  286.         public static final int ENABLE_RAD_ON        = 0;
  287.         /**
  288.          * An <code>addFile</code> "enableRAD" value indicating the file should added with RAD disabled.
  289.          * @see #addFile(String, boolean, int, int)
  290.          */
  291.         public static final int ENABLE_RAD_OFF        = 1;
  292.         /**
  293.          * An <code>addFile</code> "enableRAD" value indicating the file should added with RAD set to the default
  294.          * value for the project.
  295.          * @see #addFile(String, boolean, int, int)
  296.          */
  297.         public static final int ENABLE_RAD_DEFAULT    = 2;
  298.  
  299.         /**
  300.          * An <code>addFile</code> "updateProjectBeans" value indicating that after the file is added, project beans should be
  301.          * updated.
  302.          * @see #addFile(String, boolean, int, int)
  303.          */
  304.         public static final int UPDATE_PROJECT_BEANS_YES    = 0;
  305.         /**
  306.          * An <code>addFile</code> "updateProjectBeans" value indicating that after the file is added, project beans should be
  307.          * NOT be updated.
  308.          * @see #addFile(String, boolean, int, int)
  309.          */
  310.         public static final int UPDATE_PROJECT_BEANS_NO        = 1;
  311.         /**
  312.          * An <code>addFile</code> "updateProjectBeans" value indicating that after the file is added, the user should be prompted
  313.          * about updating project beans.
  314.          * @see #addFile(String, boolean, int, int)
  315.          */
  316.         public static final int UPDATE_PROJECT_BEANS_ASK    = 2;
  317.  
  318.     /**
  319.      * Adds a [ProjectFile.USER_ADDED] file to this <code>VisualProject</code>.
  320.      * @param fileName                the name of the file to be added.
  321.      * @param makeRelative            option to make the file relative to the project or not.
  322.      * @param enableRAD                should RAD be turned on for this file. Can be one of ENABLE_RAD_ON, ENABLE_RAD_OFF
  323.      *                                or ENABLE_RAD_DEFAULT.
  324.      * @param updateProjectBeans    should local beans be updated after this file is added.  Can be one of UPDATE_PROJECT_BEANS_YES,
  325.      *                                UPDATE_PROJECT_BEANS_NO, or UPDATE_PROJECT_BEANS_ASK.
  326.      * @return                      the resultant <code>ProjectFile</code> object.
  327.      * @exception    IllegalArgumentException if the file doesn't exist or is a diretory.
  328.      * @see    ProjectFile
  329.      */
  330.     public abstract ProjectFile addFile(String fileName, boolean makeRelative, int enableRAD, int updateProjectBeans);
  331.  
  332.     /**
  333.      * Adds a [ENABLE_RAD_DEFAULT, UPDATE_PROJECT_BEANS_NO] file to this <code>VisualProject</code>.
  334.      *
  335.      * @param fileName      name of the file to be added.
  336.      * @param addedBy       who is adding this file.
  337.      * @param makeRelative  option to make the file relative to the project or not.
  338.      * @return              the resultant <code>ProjectFile</code> object.
  339.      * @exception    IllegalArgumentException if the file doesn't exist or is a diretory.
  340.      * @see    ProjectFile
  341.      */
  342.     public abstract ProjectFile addFile(String fileName, int addedBy, boolean makeRelative);
  343.  
  344.     /**
  345.      * Removes a <code>ProjectFile</code> from this project.
  346.      * @param file the <code>ProjectFile</code> to remove.
  347.      * @see ProjectFile
  348.      */
  349.     public abstract void removeFile(ProjectFile file);
  350.  
  351.     /**
  352.      * Removes a <code>ProjectFile</code> from this project.
  353.      * @param file the File to remove.
  354.      * @exception IllegalArgumentException if the file doesn't exist, is a directory, or isn't
  355.      * part of this project.
  356.      */
  357.     public abstract void removeFile(File file);
  358.  
  359.     /**
  360.      * Renames a file in this project.  The new file name must be fully qualified.
  361.      * This method optionally overwrites any existing file with the same new name.
  362.      * The old file with the original name is deleted.
  363.      *
  364.      * @param file        the <code>ProjectFile</code> that will be renamed.
  365.      * @param newName    the new fully qualified name for this file.
  366.      * @param replace    <code>true</code> to overwrite any file that might already have the new name.
  367.      */
  368.     public abstract void renameFile(ProjectFile file, String newName, boolean replace);
  369.  
  370.     /**
  371.      * Creates a file in this <code>VisualProject</code>.  The file will be created relative to the project's
  372.      * location.
  373.      *
  374.      * @param fileName        the name of the new <code>ProjectFile</code>.
  375.      * @param contents        the text contents to put in this file.
  376.      * @param enableRAD        should RAD be turned on for this file.
  377.      * @return              the resultant <code>ProjectFile</code> object.
  378.      * @see    ProjectFile
  379.      */
  380.     public abstract ProjectFile createFile(String fileName, String contents, int enableRAD);
  381.  
  382.     /**
  383.      * Creates a file in this <code>VisualProject</code>.  The file will be created relative to the project's
  384.      * location.
  385.      *
  386.      * @param fileName        the name of the new <code>ProjectFile</code>.
  387.      * @param contents        the binary contents to put in this file.
  388.      * @param enableRAD        should RAD be turned on for this file.
  389.      * @return              the resultant <code>ProjectFile</code> object.
  390.      * @see    ProjectFile
  391.      */
  392.     public abstract ProjectFile createFile(String fileName, byte[] contents, int enableRAD);
  393.  
  394.     /**
  395.      * This method triggers the <code>aboutToChangeProjectEntries()</code> message to be
  396.      * sent to all <code>ProjectListeners</code> registered to this project.
  397.      *
  398.      * @see ProjectListener#aboutToChangeProjectEntries
  399.      * @see #doneChangingProjectEntries
  400.      */
  401.     public abstract void aboutToChangeProjectEntries();
  402.  
  403.     /**
  404.      * This method triggers the <code>doneChangingProjectEntries()</code> message to be
  405.      * sent to all <code>ProjectListeners</code> registered to this project.
  406.      *
  407.      * @see ProjectListener#doneChangingProjectEntries
  408.      * @see #aboutToChangeProjectEntries
  409.      */
  410.     public abstract void doneChangingProjectEntries();
  411.  
  412.     /**
  413.      * Forces all of the project's local beans to be updated.
  414.      */
  415.     public abstract void updateProjectBeans();
  416.     
  417.  
  418.         /**
  419.          * Indicates the "Objects" tab is selected in the project window.
  420.          * @see #getSelectedTab
  421.          */
  422.         public static final int OBJECTS_TAB = 0;
  423.         /**
  424.          * Indicates the "Packages" tab is selected in the project window.
  425.          * @see #getSelectedTab
  426.          */
  427.         public static final int PACKAGES_TAB = 1;
  428.         /**
  429.          * Indicates the "Files" tab is selected in the project window.
  430.          * @see #getSelectedTab
  431.          */
  432.         public static final int FILES_TAB = 2;
  433.  
  434.     /**
  435.      * Determines which tab is selected in the project window.
  436.      * @return an integer that identifies the selected tab, one of:<ul type=circle>
  437.      * <li>OBJECTS_TAB - the "Objects" tab is selected,
  438.      * <li>PACKAGES_TAB - the "Packages" tab is selected, or
  439.      * <li>FILES_TAB - the "Files" tab is selected
  440.      * </ul>
  441.      * @see #setSelectedTab
  442.      */
  443.     public abstract int getSelectedTab();
  444.  
  445.     /**
  446.      * Selects the tab in the project window.
  447.      * @param selectedTab an integer that identifies the selected tab, one of:<ul type=circle>
  448.      * <li>OBJECTS_TAB - the "Objects" tab is selected,
  449.      * <li>PACKAGES_TAB - the "Packages" tab is selected, or
  450.      * <li>FILES_TAB - the "Files" tab is selected
  451.      * </ul>
  452.      * @see #getSelectedTab
  453.      */
  454.     public abstract void setSelectedTab(int selectedTab);
  455.  
  456.     /**
  457.      * Gets a list of the selected objects in this project window.
  458.      * If no objects are selected a zero-length array is returned.
  459.      * @return an array of selected <code>VisualObject</code> objects.
  460.      */
  461.     public abstract VisualObject[] getSelectedObjects();
  462.  
  463.     /**
  464.      * Get a list of the selected files in this project window.
  465.      * If no files are selected a zero-length array is returned.
  466.      * @return an array of selected <code>ProjectFile</code> objects.
  467.      */
  468.     public abstract ProjectFile[] getSelectedFiles();
  469.  
  470.     /**
  471.      * Add a listener to this project.
  472.      * Changes to this project are broadcast to the listeners registered with it.
  473.      * To be notified of changes, a plug-in implements the <code>ProjectListener</code> interface, then calls
  474.      * this method to place itself on the notification list.  When this <code>VisualProject</code> changes, the
  475.      * appropriate listener method is called.
  476.      * @param listener the object that receives notifications of changes to this project.
  477.      *
  478.      * @see ProjectListener
  479.      * @see    #removeProjectListener
  480.      */
  481.     public abstract void addProjectListener(ProjectListener projectListener);
  482.  
  483.     /**
  484.      * Remove a listener from this project.  Stops the listener from receiving notifications of
  485.      * changes to this project.
  486.      * @param listener the object that was receiving notifications.
  487.      *
  488.      * @see ProjectListener
  489.      * @see    #addProjectListener
  490.      */
  491.     public abstract void removeProjectListener(ProjectListener projectListener);
  492.  
  493.     /**
  494.      * Add a <code>DTListener</code> to this project.
  495.      * Changes to this project's Design-Time Reflection classes are broadcast to the listeners registered with it.
  496.      * To be notified of changes, a plug-in implements the <code>com.symantec.itools.vcafe.openapi.dtreflect.DTListener</code>
  497.      * interface, then calls  this method to place itself on the notification list.  When this <code>VisualProject</code>'s
  498.      * Design-Time Reflection information changes, the listener is called.
  499.      *
  500.      * @param listener the object that receives notifications
  501.      * @see #removeDTListener
  502.      * @see VisualCafe#addDTListener
  503.      * @see com.symantec.itools.vcafe.openapi.dtreflect.DTListener
  504.      */
  505.     public abstract void addDTListener(DTListener listener);
  506.  
  507.     /**
  508.      * Remove a <code>DTListener</code> from this project.  Stops the listener from receiving notifications of
  509.      * changes to this project's Design-Time Reflection classes.
  510.      *
  511.      * @param listener the object that was receiving notifications
  512.      * @see #addDTListener
  513.      * @see VisualCafe#removeDTListener
  514.      * @see com.symantec.itools.vcafe.openapi.dtreflect.DTListener
  515.      */
  516.     public abstract void removeDTListener(DTListener listener);
  517.  
  518.     /**
  519.      * Creates a new interaction and opens an editor to edit it.
  520.      *
  521.      * <p>The method returns before editing begins. There is no guarantee that
  522.      * an interaction involving the objects specified will result, e.g., the
  523.      * user may cancel the interaction or specify other from and to objects.
  524.      * If called while the wizard is running (not likely because the wizard
  525.      * is modal, but possible) the wizard will queue the request to be performed
  526.      * after the current session is completed.
  527.      *
  528.      * @param   from    the <code>VisualObject</code> that fires the event; must not be <code>null</code>.
  529.      * @param   to      the <code>VisualObject</code> that is affected by the interaction;
  530.      *                  may be <code>null</code>.
  531.      */
  532.     public abstract void createNewInteraction(VisualObject from, VisualObject to);
  533.  
  534.     /**
  535.      * Create a new interaction and open an editor to edit it.
  536.      *
  537.      * <p>Same as above except sets the interaction editor preference based on
  538.      * the preferEditor argument. The editor preference applies to all subsequent
  539.      * createNewInteraction calls without the third argument, in any project.
  540.      *
  541.      * @param   from        the <code>VisualObject</code> that fires the event; must not be <code>null</code>.
  542.      * @param   to          the <code>VisualObject</code> that is affected by the interaction;
  543.      *                      may be <code>null</code>.
  544.      * @param   useEditor   <code>true</code> if the interaction editor is to be used,
  545.      *                      <code>false</code> if the interaction wizard is to be used.
  546.      */
  547.     public abstract void createNewInteraction(VisualObject from, VisualObject to, boolean useEditor);
  548.  
  549.  
  550.     /**
  551.      * Determines if this <code>VisualProject</code> corresponds to a valid project in Visual Cafe.
  552.      * @return <code>true</code> if so, <code>false</code> otherwise.
  553.      * @see #checkValidity
  554.      */
  555.     public abstract boolean isValid();
  556.  
  557.     /**
  558.      * Checks that this <code>VisualProject</code> corresponds to a valid project in Visual Cafe.
  559.      * Note that the implementation of all of <code>VisualProject</code>'s abstract methods first call
  560.      * checkValidity().  Any method could therefore throw an <code>InvalidVisualProjectException</code>.
  561.      * @exception com.symantec.itools.vcafe.openapi.InvalidVisualProjectException
  562.      * when the VisualProject has been closed, for example.
  563.      */
  564.     public void checkValidity() throws InvalidVisualProjectException {
  565.         if (!isValid()) throw new InvalidVisualProjectException();
  566.     }
  567.  
  568.  
  569.     /**
  570.      * Gets a <code>String</code> that represents this object.
  571.      * @return the <code>String</code>,
  572.      */
  573.     public String toString() {
  574.         if (!isValid()) return "invalid VisualProject: " + super.toString();
  575.         return "VisualProject[" + getProjectName() + "]";
  576.     }
  577.  
  578.     /**
  579.      * ObjectInputStream with getProject() method for streaming
  580.      * in objects that require a project to instantiate themselves.
  581.      * A VisualProject's Persistent Attributes are retrieved using a ProjectInputStream
  582.      *     (via VisualProject.getAttributes().getPersistentAttributeValue(Class, String)),
  583.      * so that your Serialized attribute can reconstitute itself in its readObject() using
  584.      * the project's information.
  585.      *
  586.      */
  587.     public class ProjectInputStream extends java.io.ObjectInputStream
  588.     {
  589.         public ProjectInputStream(java.io.InputStream in) throws java.io.IOException {
  590.             super(in);
  591.             try {
  592.                 enableResolveObject(true);
  593.             } catch (Exception e) {
  594.                 System.err.println("ERROR IN PROJECTINPUT STREAM");
  595.                 e.printStackTrace();
  596.             }
  597.         }
  598.         public VisualProject getProject() {
  599.             return VisualProject.this;
  600.         }
  601.         protected Object resolveObject(Object obj)
  602.         {
  603.             if (obj != null && obj instanceof DTClass) {
  604.                 DTClass clazz = (DTClass) obj;
  605.                 if (clazz.isPrimitive()) {
  606.                     DTClass replacement = DTClass.getPrimitiveClass(clazz.getName());
  607.                     if (replacement != null)
  608.                         return replacement;
  609.                 }
  610.             }
  611.             return obj;
  612.         }
  613.     }
  614. }
  615.