PropertySet½Ì³Ì 2.Memory¡¢map¡¢XML·½Ê½
¡¡¡¡inkfishÔ´´£¬ÇëÎðÉÌÒµÐÔÖÊתÔØ£¬×ªÔØÇë×¢Ã÷À´Ô´£¨http://blog.csdn.net/inkfish
£©¡£
¡¡¡¡PropertySet£¨À´Ô´£ºhttp://blog.csdn.net/inkfish£©
ÊÇÓÉopensymphony×éÖ¯¿ª·¢µÄµÄÒ»¸ö¿ªÔ´ÏîÄ¿£¬µ«ÊÇÄǸöÏîÄ¿ÎĵµÉÙ£¬³¤Ê±¼äûÓиüУ¬¹Ù·½Îĵµ´íÎóÆæ¶à£¬ËùÒÔÏÖÔÚÔÚÏîÄ¿ÖÐʹÓò¢²»¹ã·º¡£µ«Õâ²¢²»·Á°PropertySet³ÉΪһ¸öÓÅÐãµÄkey-value³Ö¾Ã»¯Ä£¿é£¬µ±Ç°£¬PropertySet¿ÉÒÔ˵ÒѾ¹»Óá£ÕâÀïÎÒÕûÀíÊéдÁËPropertySetµÄÎĵµ¡££¨À´Ô´£ºhttp://blog.csdn.net/inkfish£©
¡¡¡¡PropertySet×îÈÝÒ×ʹÓúÍÉÏÊÖµÄÊÇmemory·½Ê½£¬×î³£ÓõÄÊÇxml¡¢JDBC£¬ÁíÍâHibernate¡¢EJBÊǽϳ£Óõķ½Ê½¡£ÕâÀïÑ¡Ôñ½éÉÜmemory¡¢map¡¢XML·½Ê½¡££¨À´Ô´£ºhttp://blog.csdn.net/inkfish£©
1.Demo
PropertySetDemo.java
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.HashMap;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import com.opensymphony.module.propertyset.PropertySet;
import com.opensymphony.module.propertyset.PropertySetManager;
import com.opensymphony.module.propertyset.xml.XMLPropertySet;
public class PropertySetDemo {
public static void main(String[] args) throws Exception {
PropertySetDemo demo = new PropertySetDemo();
demo.mapPsDemo();
demo.memoryPsDemo();
demo.xmlPsDemo();
}
public void memoryPsDemo() {
System.out.println(StringUtils.center("Memory PropertySet Demo", 80, '*'));
//memoryÊÇÅäÖÃÎļþÖж¨ÒåµÄ£º<propertyset name="memory" class="com.opensymphony.module.propertyset.memory.MemoryPropertySet"/>
PropertySet ps = PropertySetManager.getInstance("memory", null);
ps.setBoolean("BooleanPS", true);
ps.setString("name", "Tom");
System.out.println(ps.getBoolean("BooleanPS"));
System.out.println(ps.getString("name"));
System.out.println(StringUtils.repeat("*", 80));
}
public void mapPsDemo() {
System.out.println(StringUtils.center("Map PropertySet Demo", 80, '*'));
@Sup
Ïà¹ØÎĵµ£º
3£©¶ÁÈ¡¡¢²éÕÒ
µ±ÄãÊÖÍ·ÓÐÒ»¸öxmlÎļþºó£¬¿ÉÒÔʹÓÃXmlDocument.Load()·½·¨½«Æä¼ÓÔؽøÀ´ÒԱ㴦Àí£¬ËùÒÔ“¶ÁÈ¡”ûÓÐʲô¿É˵µÄ¡£¶ø“²éÕÒ”²Ù×÷ÍùÍùÉæ¼°XPath£¬ÕâÀïÖ»ÊÇÎÒÈÏΪµÄ±È½Ï³£Óõ½µÄ²éÕÒ²Ù×÷£¬XPathÕâÍæÒâʵÔÚÊǺÜÇ¿´óºÜ±©Á¦¡£
»ØÍ·¿´Ê¾ÀýÎĵµxmlsample.xml£¬ÎÒÃÇ¿ÉÄÜÓöµ½ÕâÑùµÄÐèÇó£ ......
public class yzzSerialize
{
private yzzSerialize()
{ }
private static yzzCache cache = new yzzCache();
public static T GetfromXml<T>(string xmlpath, T t)
{
using (FileStream fs = new FileStream(xmlpath, FileMode.Open, FileAcces ......
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
SAXReader reader = new SAXReader();
try {
Document doc = reader.read("ParserSQL.xml");
&n ......
/// <summary>
/// Ö§³ÖXMLÐòÁл¯µÄ·ºÐÍ Dictionary
/// </summary>
/// <typeparam name="TKey"></typeparam>
/// <typeparam name="TValue"></typeparam>
[XmlRoot("SerializableDictionary")]
public class SerializableDictionary<TKey, TValue& ......