propertyinfo.java

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

JAVA
175
字号
/*
 * $Header: /home/cvs/WEBPUMP2.0/WebPumpIDE_Src/WebPumpIDE/src/com/webpump/ui/datasource/data/PropertyInfo.java,v 1.1.1.1 2004/07/01 09:07:42 wang_j Exp $
 * $Revision: 1.1.1.1 $
 * $Date: 2004/07/01 09:07:42 $
 *
 * ====================================================================
 *
 * 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.datasource.data;

import java.io.PrintWriter;
import java.util.Hashtable;
import org.eclipse.pde.core.*;
import org.w3c.dom.*;
import com.webpump.ui.base.data.BaseObject;
import com.webpump.ui.perspective.WebpumpIDEPlugin;

/**
 * Class for data object of property information.
 * 
 * @author zhang_tx
 * @version 2.0.0 2004-2-24
 */
public class PropertyInfo extends BaseObject {
    
	/** value of PropertyName */
	private String m_strParamName = "";
    
	/** value of ValueName */
	private String m_strValue = "";


    /**
     * Parse property information node
     * @param node the property information node
     * @param lineTable a Hashtable object
     */
    public void parse(Node node, Hashtable lineTable) {
		bindSourceLocation(node, lineTable);
		//get all property nodes    
		NodeList children = node.getChildNodes();
		for (int i = 0; i < children.getLength(); i++) {
			Node child = children.item(i);
			//parse property node
			parseChild(child, lineTable);
		} 
    }

	/**
	 * Parse property node and add to vInfo
	 * 
	 * @param node the property node 
	 * @param vInfo a Vector object to contain all sub data object
	 * @param lineTable a Hashtable object
	 */
	public void parseChild(Node node, Hashtable lineTable) {
		String tag = node.getNodeName().toLowerCase();
		if (tag.equals("name")) {  
			if (node.getFirstChild() != null) {
				m_strParamName = node.getFirstChild().getNodeValue().trim();                    
			}
		}
		if (tag.equals("value")) {                      
			if (node.getFirstChild() != null) {
				m_strValue = node.getFirstChild().getNodeValue().trim();                    
			}
		}
	}
	
    /**
     * Transform PropertyInfo to a string
     * 
     * @return PropertyInfoString string of PropertyInfo
     */
    public String getParamString() {
        String ParamString;
		ParamString = "   " + "   " + "<parameter>" + "\n"  
                    + "   " + "   " + "   " + "<name>" + WebpumpIDEPlugin.filterXML(m_strParamName) + "</name>" + "\n"
		            + "   " + "   " + "   " + "<value>" + WebpumpIDEPlugin.filterXML(m_strValue) + "</value>" + "\n"
		            + "   " + "   " + "<parameter>" + "\n";
        return ParamString;
    }
   
    /**
     * Get all value of property information
     * @return strReturn 
     */
    public String[] getParamInfo() {
        String[] strReturn = new String[2];
        
        strReturn[0] = m_strParamName;
        strReturn[1] = m_strValue;
        
        return strReturn;
        
    }
    
	/**
	 * Write this node in "datasource.xml"
	 * @param indent
	 * @param writer
	 */
	public void write(String indent, PrintWriter writer) {		
		writeComments(writer);
		String indent2 = indent + INDENT;
		writer.println(indent2 + "<parameter> ");
		
		String indenta = indent + INDENT + INDENT;

		writer.println(indenta + "<name>" + WebpumpIDEPlugin.filterXML(m_strParamName) + "</name>");
		writer.println(indenta + "<value>" + WebpumpIDEPlugin.filterXML(m_strValue) + "</value>");
		writer.println(indent2 + "</parameter>");
	}	    
    /**
     * Set all value of property information
     * @param strPropertyInfo 
     */
    public void setPropertyInfo(String[] strPropertyInfo) {
        m_strParamName = strPropertyInfo[0];
        m_strValue = strPropertyInfo[1];
        //  fire structure of the data model changed 
        fireStructureChanged(this, ModelChangedEvent.CHANGE);
       
    }

	/**
	 * add this PropertyInfo data to the model
	 * @param strPropertyInfo 
	 */
	public void addParamInfo(String[] strParamInfo) {
		m_strParamName = strParamInfo[0];
		m_strValue = strParamInfo[1];
		//  fire structure of the data model changed 
		fireStructureChanged(this, ModelChangedEvent.INSERT);
       
	}
    
	/**
	 * Get the value of property value
	 * @return strReturn 
	 */
    public String getValue(){
    	return m_strValue;
    }
    
	/**
	 * Get the value of property name
	 * @return strReturn 
	 */
    public String getName(){
    	return m_strParamName;
    }
    
	/**
	 * Get the value of property name
	 * @return strReturn 
	 */
    public String toString(){
    	return m_strParamName;
    }
    
}

⌨️ 快捷键说明

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