allexception.java

来自「一个eclipse插件源代码。用于web开发」· Java 代码 · 共 191 行

JAVA
191
字号
/*
 * $Header: /home/cvs/WEBPUMP2.0/WebPumpIDE_Src/WebPumpIDE/src/com/webpump/ui/exception/data/AllException.java,v 1.1.1.1 2004/07/01 09:07:45 wang_j Exp $
 * $Revision: 1.1.1.1 $
 * $Date: 2004/07/01 09:07:45 $
 *
 * ====================================================================
 *
 * The NanJing HopeRun(IT-FOREST) Software License, Version 2.0.0
 *
 * Copyright 2003-2004 by NanJing HopeRun(IT-FOREST) Information System Co., Ltd, CHINA and
 *                        IT Forest Corporation
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * HopeRun(IT-FOREST) Information System Co., Ltd, CHINA and IT Forest Corporation.
 * You shall not disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into with
 * HopeRun(IT-FOREST) Information System Co., Ltd, CHINA and IT Forest Corporation.
 */
 
package com.webpump.ui.exception.data;

import java.util.Hashtable;
import java.util.Vector;
import java.io.PrintWriter;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.pde.core.*;
import org.w3c.dom.*;

import com.webpump.ui.base.data.*;
import com.webpump.ui.perspective.MacroResource;
import com.webpump.ui.perspective.WebpumpIDEPlugin;

/**
 * Class for defining the data structure of the child node <exceptions> in "exception.xml".
 * 
 * @author zhao_f
 * @version 2.0.0 2004-2-13
 */
public class AllException extends BaseDataObject
{
	final static String INDENT = "   ";
	
	/** name of this node*/	
	private String m_strName=WebpumpIDEPlugin.getResourceString(MacroResource.ALLEXCEPTION_NAME);
	
	/** a group of objects which is use to store ExceptionInfo of this node's children*/
	private Vector vExceptions;
	
	/**
	 * Parse the given node by searching all its children repeatingly and parsing each of them respectively
	 * @param node the node which is going to be parsed
	 * @param lineTable
	 */
	public void parse(Node node, Hashtable lineTable)  {
		bindSourceLocation(node, lineTable);
		
        //Parse all the Children of this node
		if (vExceptions==null) vExceptions = new Vector();
		NodeList children = node.getChildNodes();
		for (int i = 0; i < children.getLength(); i++) {
			Node child = children.item(i);
			parseInfo(child,vExceptions,lineTable);
		}
		addComments(node);				
	}
	
	/**
	 * Parse the children nodes got from the method above
	 * @param node the node whihch is going to be parsed
	 * @param vInfo a group of objects which is used to store the children nodes
	 * @param lineTable
	 */
	protected void parseInfo(Node node,Vector vInfo, Hashtable lineTable)  
	{
        //Get the tag of the given node
		String tag = node.getNodeName().toLowerCase();
		
		//Identify whether the tag of the node is "exception" and handle it accordingly
		if (tag.equals("exception")) {			
			
			ExceptionInfo objExceptionInfo = new ExceptionInfo();
			objExceptionInfo.setModel(getModel());
			objExceptionInfo.setParent(this); 		
			objExceptionInfo.setInTheModel(true);
			//Parse the child node in ExceptionInfo	
			objExceptionInfo.parse(node,lineTable);
			objExceptionInfo.setInTheModel(true);
			//Store the node in the VInfo object group
			vInfo.add(objExceptionInfo);
		}
	}
		
	/**
	 * Restore the Property
     * @param name
	 * @param oldValue
	 * @param newValue
	 */
	public void restoreProperty(String name, Object oldValue, Object newValue)
		throws CoreException {
		super.restoreProperty(name, oldValue, newValue);
	}
	
	/**
	 * Write this node in "exception.xml"
	 * @param indent
	 * @param writer
	 */
	public void write(String indent, PrintWriter writer) {
		writeComments(writer);
		String indent2 = indent + INDENT;
		String indenta = indent + INDENT + INDENT;
		
		//Write "<exceptions>"
		writer.println(indent + "<exceptions> ");
		//Write Children nodes of the present node
		writeChildren(indent2, vExceptions, writer);
		//Write "</exceptions>"
		writer.println(indent + "</exceptions>");
	}
	
	/**
	 * Write all children nodes of the present node
	 * @param indent
	 * @param children
	 * @param writer
	 */
	protected void writeChildren(
		String indent,
		Vector children,
		PrintWriter writer) {
		//Search all the children nodes of the present node and write each of them using their own write method	
		for (int i = 0; i < children.size(); i++) {
			IWritable writable = (IWritable) children.get(i);
			writable.write(indent, writer);
		}
	}
	
	/**
	 * Return the children nodes which have been stored in vExceptions
	 */
	public Object[] getChild()
	{
		if (vExceptions==null)
			return new BaseObject[0];		
		return (BaseObject[]) vExceptions.toArray(
					new BaseObject[vExceptions.size()]);
	}
	
	/**
	 * Get the children nodes of this node, which is ExceptionInfo
	 */
	public Vector getActionException()
	{
		return vExceptions;
	}
	
	/**
	 * Return the name of this node
	 */
	public String toString()
	{
		return m_strName;
	}
	
	/**
	 * Add a new child node to this node, whose type is ExceptionInfo
	 * @param objExceptionInfo the child node which is going to be added
	 */
	public void addException(ExceptionInfo objExceptionInfo)
	{
			vExceptions.add( objExceptionInfo);
			objExceptionInfo.setInTheModel(true);
			objExceptionInfo.setParent(this);
			objExceptionInfo.setModel(this.getModel());		
			fireStructureChanged(objExceptionInfo, IModelChangedEvent.INSERT);
	}
	
	/**
	 * Delete a child node from this node, whose type is ExceptionInfo
	 * @param objExceptionInfo the child node which is going to be removed
	 */
	public void remove(ExceptionInfo objExceptionInfo)
	{
			vExceptions.removeElement(objExceptionInfo);
			objExceptionInfo.setInTheModel(false);
			fireStructureChanged(objExceptionInfo, ModelChangedEvent.REMOVE);
	}	
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?