博文

目前显示的是 一月, 2013的博文

Proxy Pattern & AOP in JavaScript

Proxy Pattern & AOP in JavaScript To implement a proxy pattern in JavaScript, enabling the basics of aspect-oriented Programming(AOP) function test(){   console.log(this,"It is a test."); } (function(){   var toProxy = test;   test = function(){     console.log( this, "proxied" ,arguments );     return toProxy.apply( this );   }; } )(); test(); //Window test.html proxied [ ] //Window test.html It is a test.

JSON(JavaScript Object Notation)

It was said that there are only three basic data structure primitives: mappings (hashes/dictionaries), sequences (arrays/lists) and scalars (strings/numbers). The scalar represents strings, integers, dates, and other atomic data types. JSON defines all the data structures: 1. Sequences (arrays/lists) and Scalars (strings/numbers), separated by , (comma). 2. Mappings (hashes/dictionaries) are the name/value pairs, uses the format name : (colon) value. 3. Set of name/value pairs, set enclosed by a pair of curly braces {} , then begins with { (left brace) and ends with } (right brace). 4. Set of Sequences (arrays/lists) and Scalars (strings/numbers), set begins with [ (left bracket) and ends with ] (right bracket). For Example: An array is an ordered collection of values. An array begins with [ (left bracket) and ends with ] (right bracket). * JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy f...

DocumentBuilder

public class test{ /** * parse test.xml * @return TextContent of a node. */ public String getTextContent() throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); String sPath = this.getClass().getResource("/") .getPath() + File.separator + "test.xml"; Document document = builder.parse(sPath); NodeList nodeList = document.getElementsByTagName("test"); Node node = nodeList.item(0); return node.getTextContent(); } } jsp <% DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setIgnoringElementContentWhitespace(true); DocumentBuilder db = dbf.newDocumentBuilder(); Document doc = db.parse(pageContext.getServletContext().getResourceAsStream("/xml/test.xml")); doc.normalize(); NodeList Xs = doc.getElementsByTagName("X"); String x = Xs.item(0).getFirstChild().getNo...

转:JAVA解析XML,DTD验证问题

JAVA解析XML,DTD验证问题 来自:http://blog.csdn.net/hailanzhijia/article/details/6004947 问题提出 : 解析ejb-jar.xml,出现在网络连不上的情况下,解析失败的情况。 问题分析: 我们使用的是DOM进行XML的解析的:             DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();             DocumentBuilder builder = factory.newDocumentBuilder();             //位置点             Document doc = builder.parse(file); 由于ejb-jar.xml中,有 <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd"> 在解析的时候,会从网络http://java.sun.com/dtd/ejb-jar_2_0.dtd中抓紧DTD文件,进行验证,如果网络不通,那么就会出现解析失败。 首先,DocumentBuilderFactory.newInstance()创建DocumentBuilderFactory实现类的对象,它会通过一下方式来查找实现类: 1.在系统环境变量中(System.getProperties())中查找 key=javax.xml.parsers.DocumentBuilderFactory 2.如果1没有找到,则找java....

德.摩根De Morgan 和香农Shannon定理

图片

2013-01-01 the First day

图片
2013-01-01 the First day.