KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > tax > dom > Wrapper


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.tax.dom;
21
22 import org.w3c.dom.*;
23 import org.netbeans.tax.*;
24
25 /**
26  *
27  * @author Petr Kuzel
28  */

29 public class Wrapper {
30
31
32     public static Attr wrap(TreeAttribute attr) {
33         return new AttrImpl(attr);
34     }
35
36     public static Element wrap(TreeElement element) {
37         return new ElementImpl(element);
38     }
39
40     public static Text wrap(TreeText text) {
41         return new TextImpl(text);
42     }
43
44     public static Document wrap(TreeDocumentRoot document) {
45         return new DocumentImpl(document);
46     }
47     
48     public static DocumentType wrap(TreeDocumentType documentType) {
49         return new DocumentTypeImpl(documentType);
50     }
51     
52     public static Comment wrap(TreeComment comment) {
53         return new CommentImpl(comment);
54     }
55     
56     static NodeList wrap(TreeObjectList list) {
57         return new NodeListImpl(list);
58     }
59     
60     static NamedNodeMap wrap(TreeNamedObjectMap map) {
61         return new NamedNodeMapImpl(map);
62     }
63     
64     public static Node wrap(TreeObject object) {
65         if (object == null) return null;
66         if (object instanceof TreeAttribute) {
67             return wrap((TreeAttribute) object);
68         } else if (object instanceof TreeElement) {
69             return wrap((TreeElement) object);
70         } else if (object instanceof TreeText) {
71             return wrap((TreeText) object);
72         } else if (object instanceof TreeDocumentRoot) {
73             return wrap((TreeDocumentRoot) object);
74         } else if (object instanceof TreeDocumentType) {
75             return wrap((TreeDocumentType) object);
76         } else if (object instanceof TreeComment) {
77             return wrap((TreeComment) object);
78         } else {
79             throw new RuntimeException JavaDoc("Cannot wrap: " + object.getClass());
80         }
81     }
82 }
83
Popular Tags