keyandvalue.java

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

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

import java.io.PrintWriter;
import java.util.HashMap;
import org.eclipse.pde.core.ModelChangedEvent;
import com.webpump.ui.base.data.BaseObject;

/**
 * Key and Value mapping object.
 * 
 * @author luo_sa
 * @version 2.0.0 2004-2-24
 */
public class KeyAndValue extends BaseObject {
    
    /** key */
    private String m_strKey;
    
    /** value */
    private String m_strValue;
    
    private ParameterList m_objParameterList;
    
    public KeyAndValue() {
    	m_objParameterList = new ParameterList();
    }
    
    /**
     * Parse key and value mapping
     * @param key 
     * @param objHashMap
     */
    public void parse(String key,HashMap objHashMap) {
        m_strKey = key;
        m_strValue = (String) objHashMap.get((Object) key);
    }
    
    /**
     * Write this object on file
     */
    public void write(String indent, PrintWriter writer) {
        writeComments(writer);
        writer.println((m_strKey==null ? "" : m_strKey) + " = ");
        if (m_strValue == null) {
            writer.println("     " + ";");
        } else {
            String strvalue = m_strValue.replaceAll("\n", "\n     "); 
            writer.println("     " + (m_strValue == null ? "" : strvalue) +";");  
        }
       
        writer.println("\n");             
    }
    
    /**
     * Return m_strKey.
     */
    public String toString() {
        return (m_strKey == null ? "" : m_strKey);
    } 
    
    /**
     * Get m_strValue.
     * 
     * @return m_strValue
     */
    public String getValue() {
        return m_strValue;  
    }
    
    /**
     * Get m_strKey.
     * 
     * @return m_strKey
     */
    public String getKey() {
        return m_strKey;
    }
    
    /**
     * Set m_strValue.
     * 
     * @param strValue
     */   
    public void setValue(String strValue) {
        m_strValue = strValue;
        fireStructureChanged(this, ModelChangedEvent.CHANGE);
    }
    
    public void setKeyNotFire(String strKey) {
        m_strKey = strKey;
    }
    /**
     * Set m_strKey.
     * 
     * @param strKey
     */
    public void setKey(String strKey) {
        m_strKey = strKey;
        fireStructureChanged(this, ModelChangedEvent.CHANGE);
    }
    
    /**
     * Set m_strKey and m_strValue 
     * @param strKey
     * @param strValue
     */
    public void setKeyAndValue(String strKey, String strValue) {
        m_strKey = strKey;
        m_strValue = strValue;
        fireStructureChanged(this, ModelChangedEvent.CHANGE);
    }
    
    /**
     * Get the string of the KeyAndValue object
     * @return
     */
    public String getKeyAndValueString() {
        String strKeyAndValue = m_strKey + ",\"" + m_strValue + "\"" ;
        strKeyAndValue = strKeyAndValue.replaceAll("\r\n","\n");
        strKeyAndValue += "\r\n";
        return strKeyAndValue;
    }
    
    public void setParameterList(ParameterList object) {
    	m_objParameterList = object;
    }
    
    public ParameterList getParameterList() {
    	return m_objParameterList;
    }

}

⌨️ 快捷键说明

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