configparser.java

来自「中国移动 provision MISC1.6 接口」· Java 代码 · 共 68 行

JAVA
68
字号
package cmd.db;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2005</p>
 *
 * <p>Company:新太互动 </p>
 *
 * @author 罗永雄
 * @version 1.21
 */

import java.util.Hashtable;
import java.util.Properties;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2002</p>
 * <p>Company: </p>
 * @author unascribed
 * @version 1.0
 */

public class ConfigParser  extends DefaultHandler
{
  private Properties props;
  private String currentSet;
  private String currentName;
  private StringBuffer currentValue;

  public ConfigParser()
  {
    currentValue = new StringBuffer();
    props = new Properties();
  }

  public Properties getProps()
  {
    return props;
  }

  public void startElement(String uri, String localName, String qName, Attributes attributes)
      throws SAXException
  {
    currentValue.delete(0, currentValue.length());
    currentName = qName;
  }

  public void characters(char ch[], int start, int length)
      throws SAXException
  {
    currentValue.append(ch, start, length);
  }

  public void endElement(String uri, String localName, String qName)
      throws SAXException
  {
    props.put(qName, currentValue.toString().trim());
  }
}

⌨️ 快捷键说明

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