actionexception.java
来自「一个eclipse插件源代码。用于web开发」· Java 代码 · 共 192 行
JAVA
192 行
/*
* $Header: /home/cvs/WEBPUMP2.0/WebPumpIDE_Src/WebPumpIDE/src/com/webpump/ui/exception/data/ActionException.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.WebpumpIDEPlugin;
/**
* Class for defining the data structure of the child node <action> in "exception.xml".
*
* @author zhao_f
* @version 2.0.0 2004-2-13
*/
public class ActionException extends BaseDataObject
{
final static String INDENT = " ";
/** name of this node*/
private String m_strAction;
/** a group of objects which is use to store ExceptionName of this node's children*/
private Vector vExceptions = new Vector();
/**
* 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);
//Get the name attribute of this node
m_strAction = getNodeAttribute(node,"name");
//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);
parseName(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 parseName(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")) {
ExceptionName objExceptionName = new ExceptionName();
objExceptionName.setModel(getModel());
objExceptionName.setParent(this);
objExceptionName.setInTheModel(true);
//parse the child node in ExceptionName
objExceptionName.parse(node,lineTable);
objExceptionName.setInTheModel(true);
//store the node in the VInfo object group
vInfo.add(objExceptionName);
}
}
/**
* 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) {
if (vExceptions.size()>0)
{
writeComments(writer);
String indent2 = indent + INDENT;
String indenta = indent + INDENT + INDENT;
//Write "<action" first
writer.print(indent + "<action");
//Write "name" and its value if it has one
writeIfDefined(" ", writer, "name", WebpumpIDEPlugin.filterXML(m_strAction));
//Write ">"
writer.println(">");
//Write Children nodes of the present node
writeChildren(indenta, vExceptions, writer);
//Write "</action>"
writer.println(indent + "</action>");
}
}
/**
* Return the children nodes which have been stored in vExceptions
*/
public Object[] getChild()
{
return (BaseObject[]) vExceptions.toArray(
new BaseObject[vExceptions.size()]);
}
/**
* Return all the Exceptions in this node
*/
public Vector getActionException()
{
return vExceptions;
}
/**
* Return the name of this node
*/
public String toString()
{
return m_strAction;
}
/**
* Add a new Exception to this node
* @param objExceptionName the ExceptionName child node which is going to be added to the present node
*/
public void addException(ExceptionName objExceptionName)
{
//Add the ExceptionName node in vExceptions object group first
vExceptions.add( objExceptionName);
//Register the new node in the data model
objExceptionName.setInTheModel(true);
objExceptionName.setParent(this);
objExceptionName.setModel(this.getModel());
fireStructureChanged(objExceptionName, IModelChangedEvent.INSERT);
}
/**
* Remove an ExceptionName child node from the present node
* @param objExceptionName the ExceptionName child node which is going to be deleted
*/
public void remove(ExceptionName objExceptionName)
{
//Remove the ExceptionName child node from the vExceptions object group first
vExceptions.removeElement(objExceptionName);
//Delete the record of the node from the data model
objExceptionName.setInTheModel(false);
fireStructureChanged(objExceptionName, ModelChangedEvent.REMOVE);
}
public void setActionName(String strActionName)
{
m_strAction = strActionName;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?