/* ==================================================================== Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for Additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ /* ================================================================ * About NPOI * Author: Tony Qu * Author's email: tonyqus (at) gmail.com * Author's Blog: tonyqus.wordpress.com.cn (wp.tonyqus.cn) * HomePage: http://www.codeplex.com/npoi * Contributors: * * ==============================================================*/ using System; using System.Text; using System.IO; using System.Collections; namespace HH.WMS.Utils.NPOI.Util.Collections { /// /// This class comes from Java /// public class Properties { private Hashtable _col; private const string whiteSpaceChars = " \t\r\n\f"; private const string keyValueSeparators = "=: \t\r\n\f"; private const string strictKeyValueSeparators = "=:"; /// /// Initializes a new instance of the class. /// public Properties() { _col = new Hashtable(); } /// /// Removes the specified key. /// /// The key. /// public string Remove(string key) { string retval = (string)_col[key]; _col.Remove(key); return retval; } /// /// Gets the enumerator. /// /// public IEnumerator GetEnumerator() { return _col.GetEnumerator(); } /// /// Determines whether the specified key contains key. /// /// The key. /// /// true if the specified key contains key; otherwise, false. /// public bool ContainsKey(string key) { return _col.ContainsKey(key); } /// /// Adds the specified key. /// /// The key. /// The value. public virtual void Add(string key, string value) { _col[key] = value; } public void AddAll(Properties col) { foreach (string itm in col.Keys) { _col[itm] = col[itm]; } } /// /// Gets the count. /// /// The count. public int Count { get { return _col.Count; } } /// /// Gets or sets the with the specified key. /// /// public virtual string this[string key] { get { return (string)_col[key]; } set { _col[key] = value; } } /// /// Gets the keys. /// /// The keys. public ICollection Keys { get { return _col.Keys; } } /// /// Clears this instance. /// public void Clear() { _col.Clear(); } /// /// Loads the specified in stream. /// /// The in stream. public void Load(Stream inStream) { StreamReader inp = new StreamReader(inStream, Encoding.GetEncoding(1252)); while (true) { // Get next line String line = inp.ReadLine(); if (line == null) return; if (line.Length > 0) { // Find start of key int len = line.Length; int keyStart; for (keyStart=0; keyStart /// Loads the convert. /// /// The string. /// /// /// Converts encoded \uxxxx to unicode chars /// and changes special saved chars to their original forms /// private String LoadConvert(String theString) { char aChar; int len = theString.Length; StringBuilder outBuffer = new StringBuilder(len); for (int x=0; x /// Continues the line. /// /// The line. /// private bool ContinueLine(String line) { int slashCount = 0; int index = line.Length - 1; while ((index >= 0) && (line[index--] == '\\')) slashCount++; return (slashCount % 2 == 1); } } }