⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 context.java

📁 导出ORACLE数据库对象DDL语句的程序
💻 JAVA
字号:
/*
 * 创建日期 2005-4-27
 *  作 者   liug
 */
package com.icbc.util;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Vector;


/**
 * @author liug
 * @time    14:50:45
 */
public class Context {

	private String name;

	private Context parent = null;

	private HashMap childrens = new HashMap(5);

	private Vector elements = new Vector(1);

    private static Context rootContext;
	
		
	public Context(String name){
	    this.name = name;
	}
    /**
     * @return 返回 name。
     */
    public String getName() {
        return name;        
    }
    /**
     * @param name 要设置的 name。
     */
    public void setName(String name) {
        this.name = name;
    }
    /**
     * @return 返回 parent。
     */
    public Context getParent() {
        return parent;
    }
    /**
     * @param parent 要设置的 parent。
     */
    public void setParent(Context parent) {
        this.parent = parent;
    }
    /**
     * @return 返回 parentCtxName。
     */
    public String getParentCtxName() {
        return parent.getName();
    }
    /**
     * @return 返回 dataCollection。
     */
    public Vector elements() {
        return elements;
    }
    /** 
     * @param name 
     * @return 返回context中的值
     * @throws CTEObjectNotFoundException
     */
    public Object getTagElement() {
        return elements.get(0);
    }
    
    /** 
     * @param key 
     * @param value
     * @throws CTEObjectNotFoundException
     */
    
    public void setTagElement(Object value) {
        elements.add(0,value);
    }
    
    public void addChild(Context context){
        childrens.put(context.getName(),context);
    }
    
	public static void reset() {
	    getRoot().prune();
	}

    
	/**
	 * 释放此Context节点的资源
	 * @Creation date: (2002-1-17 13:37:37)
	 */
	public void prune() {
	    if(childrens!=null){
	        Iterator iterator = childrens.keySet().iterator();
	       while(iterator.hasNext()){	           	
					Context aContext = (Context) iterator.next();
					aContext.prune();
				}
			}
			unchain();
		
	}
	
	/**
	 * 断开节点和父节点的链接
	 * @Creation date: (2002-1-16 14:33:10)
	 * @exception com.icbc.ecte.base.CTEInvalidRequestException The exception description.
	 * @exception com.icbc.ecte.base.CTEObjectNotFoundException The exception description.
	 */
	public void unchain(){
		if (getChildren() != null && getChildren().size() != 0) {
//			throw new CTEInvalidRequestException(
//				"Can not unchain context "
//					+ getName()
//					+ " from the context hierarchy."
//					+ " It have children.");
		}
		if (getParent() != null) {
			getParent().removeChild(this);
			setParent(null);
		}
		if (isRoot()) {
			setRoot(null);
		}
	}
	
	/**
	 * 判断此节点是否为根节点.
	 * @Creation date: (2002-1-14 11:20:07)
	 * @return boolean
	 */
	public boolean isRoot() {
		if (getRoot() != null) {
			return this == getRoot();
		} else {
			return false;
		}
	}
	
	/**
	 * 设定结点的根节点
	 * @param context com.icbc.cte.base.Context
	 */
	public void setRoot(Context context) {
		rootContext = context;
	}
	
	/**
	 * 取Context树的根节点
	 * @return com.icbc.cte.base.Context
	 */
	public static Context getRoot() {
		return rootContext;
	}
	
    /**
     * @return 返回 childrens。
     */
    public HashMap getChildren() {
        return childrens;
    }
    
    public void removeChild(Context child){
		this.childrens.remove(child);    
    }
}

⌨️ 快捷键说明

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