globalexceptions.java
来自「一个eclipse插件源代码。用于web开发」· Java 代码 · 共 189 行
JAVA
189 行
/*
* $Header: /home/cvs/WEBPUMP2.0/WebPumpIDE_Src/WebPumpIDE/src/com/webpump/ui/exception/data/GlobalExceptions.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 <global-exceptions> in "exception.xml".
*
* @author zhao_f
* @version 2.0.0 2004-2-13
*/
public class GlobalExceptions extends BaseDataObject
{
final static String INDENT = " ";
/** name of this node*/
private String m_strName=WebpumpIDEPlugin.getResourceString(MacroResource.GLOBALEXCEPTIONS_NAME);
/** a group of objects which is use to store ExceptionName 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);
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) {
writeComments(writer);
//Write "<global-exceptons>"
writer.println(indent + "<global-exceptions>");
String indent2 = indent + INDENT;
//Write Children nodes of the present node
writeChildren(indent2, vExceptions, writer);
//Write "</global-exceptions>"
writer.println(indent + "</global-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 ExceptionName
*/
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 ExceptionName
* @param objExceptionName the child node which is going to be added
*/
public void addException(ExceptionName objExceptionName)
{
vExceptions.add( objExceptionName);
objExceptionName.setInTheModel(true);
objExceptionName.setParent(this);
objExceptionName.setModel(this.getModel());
fireStructureChanged(objExceptionName, IModelChangedEvent.INSERT);
}
/**
* Delete a child node from this node, whose type is ExceptionName
* @param objExceptionName the child node which is going to be removed
*/
public void remove(ExceptionName objExceptionName)
{
vExceptions.removeElement(objExceptionName);
objExceptionName.setInTheModel(false);
fireStructureChanged(objExceptionName, ModelChangedEvent.REMOVE);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?