datasourceproperty.java

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

JAVA
186
字号
/*
 * $Header: /home/cvs/WEBPUMP2.0/WebPumpIDE_Src/WebPumpIDE/src/com/webpump/ui/datasource/data/DataSourceProperty.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.Node;
import com.webpump.ui.base.data.BaseDataObject;
import com.webpump.ui.perspective.WebpumpIDEPlugin;

/**
 * Class for data object of a html page .
 * 
 * @author zhang_tx
 * @version 2.0.0 2004-2-24
 */
public class DataSourceProperty extends BaseDataObject {
    
    /**type of the datasource */ 
    private String m_strSourceType = "";
    
    private String m_strName = "";
    
    private String m_strAuthor = "";
    
	String[] strPropertyInfo = new String[2];
	
    /**
     * Parse the DataSource node
     * 
     * @param node the DataSource node 
     * @param lineTable a Hashtable object
     */
    public void parse(Node node, Hashtable lineTable)  {
        bindSourceLocation(node, lineTable);
        //get the type of the datasource 
		m_strName = getNodeAttribute(node, "name");
		m_strAuthor = getNodeAttribute(node, "auth");  
        m_strSourceType = getNodeAttribute(node, "type");                    
    }  
    
    /**
     * Transform DataSource to a string
     * 
     * @return DataSourceString string of DataSource
     */
    public String getDataSourcePropertyString() {
        String DataSourcePropertyString;
		DataSourcePropertyString = "   " + "<Resource name = " + "\"" + WebpumpIDEPlugin.filterXML(m_strName) 
                                 + "\" auth = " + "\"" + WebpumpIDEPlugin.filterXML(m_strAuthor) 
                                 + "\" type = " + "\"" + WebpumpIDEPlugin.filterXML(m_strSourceType) + "\"" + "/>" + "\n";
        return DataSourcePropertyString;
    }
    
    
    
    /**
     * Get the type of the datasource
     * 
     * @return m_strSourceType the type of the datasource
     */
    public String toString() {
        return m_strSourceType==null?"":m_strSourceType;
    }   

    
    /**
     * Remove a Property data object form DataSource data object
     * @param objPropertyInfo the Property info data object which will be removed form DataSource data object
     */
    
    public void write(String indent, PrintWriter writer){
		writeComments(writer);
		writer.print(indent + "<Resource name");
		writeIfDefined(" ", writer, "name", WebpumpIDEPlugin.filterXML(m_strName));
		writeIfDefined(" ", writer, "auth", WebpumpIDEPlugin.filterXML(m_strAuthor));	
		writeIfDefined(" ", writer, "type", WebpumpIDEPlugin.filterXML(m_strSourceType));	
		writer.println("/>");
    }
	
	/**
	 * set the type of the datasource
	 * 
	 * @param newtype    the new type for the datasource
	 */
	public void setType(String newtype){
		m_strSourceType = newtype;
		fireStructureChanged(this, IModelChangedEvent.CHANGE);
	}

	/**
	 * @return
	 */
	public String getAuthor() {
		return m_strAuthor;
	}

	/**
	 * @return
	 */
	public String getName() {
		return m_strName;
	}

	/**
	 * @return
	 */
	public String getSourceType() {
		return m_strSourceType;
	}
	
	/**
	 * Set all value of property information
	 * @param strPropertyInfo 
	 */
	public void setSourceInfo(String[] strPropertyInfo) {
		m_strName = strPropertyInfo[0];
		m_strAuthor = strPropertyInfo[1];
		m_strSourceType = strPropertyInfo[2];
		//  fire structure of the data model changed 
		fireStructureChanged(this, ModelChangedEvent.CHANGE);
       
	}

	/**
	 * add this PropertyInfo data to the model
	 * @param strPropertyInfo 
	 */
	public void addSourceInfo(String[] strPropertyInfo) {
		m_strName = strPropertyInfo[0];
		m_strAuthor = strPropertyInfo[1];
		m_strSourceType = strPropertyInfo[2];
		//  fire structure of the data model changed 
		fireStructureChanged(this, ModelChangedEvent.INSERT);
       
	}
	
	/**
	 * Get all value of property information
	 * @return strReturn 
	 */
	public String[] getSourceInfo() {
		String[] strReturn = new String[3];
		strReturn[0] = m_strName;
		strReturn[1] = m_strAuthor;
		strReturn[2] = m_strSourceType;
		return strReturn;
        
	}
	/**
	 * @param string
	 */
	public void setName(String string) {
		m_strName = string;
		fireStructureChanged(this, IModelChangedEvent.CHANGE);
	}

	/**
	 * @param string
	 */
	public void setAuthor(String string) {
		m_strAuthor = string;
		fireStructureChanged(this, IModelChangedEvent.CHANGE);
	}

}

⌨️ 快捷键说明

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