KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > persistence > unit > PersistenceCatalog


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
21 package org.netbeans.modules.j2ee.persistence.unit;
22
23 import java.awt.Image JavaDoc;
24 import java.beans.PropertyChangeListener JavaDoc;
25 import java.io.IOException JavaDoc;
26 import java.util.ArrayList JavaDoc;
27 import java.util.Iterator JavaDoc;
28 import java.util.List JavaDoc;
29 import org.netbeans.modules.xml.catalog.spi.CatalogDescriptor;
30 import org.netbeans.modules.xml.catalog.spi.CatalogListener;
31 import org.netbeans.modules.xml.catalog.spi.CatalogReader;
32 import org.xml.sax.InputSource JavaDoc;
33 import org.xml.sax.SAXException JavaDoc;
34 import org.openide.util.NbBundle;
35 import org.openide.util.Utilities;
36
37 /**
38  * Catalog for persistence related schemas.
39  *
40  * @author Erno Mononen
41  */

42 public class PersistenceCatalog implements CatalogReader, CatalogDescriptor, org.xml.sax.EntityResolver JavaDoc {
43     
44     private static final String JavaDoc PERSISTENCE_1_0_XSD = "persistence_1_0.xsd"; // NOI18N
45
private static final String JavaDoc PERSISTENCE_1_0_URL = "nbres:org/netbeans/modules/j2ee/persistence/dd/resources/persistence_1_0.dtd"; // NOI18N
46
private static final String JavaDoc PERSISTENCE_1_0 = "http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"; // NOI18N
47
private static final String JavaDoc PERSISTENCE_1_0_ID = "SCHEMA:" + PERSISTENCE_1_0; // NOI18N
48

49     public PersistenceCatalog() {
50     }
51     
52     public InputSource JavaDoc resolveEntity(String JavaDoc publicId, String JavaDoc systemId) throws SAXException JavaDoc, IOException JavaDoc {
53         if (PERSISTENCE_1_0.equals(systemId)){
54             return new org.xml.sax.InputSource JavaDoc(PERSISTENCE_1_0_URL);
55         }
56         if (systemId != null && systemId.endsWith(PERSISTENCE_1_0_XSD)){
57             return new org.xml.sax.InputSource JavaDoc(PERSISTENCE_1_0_URL);
58         }
59         return null;
60     }
61     
62     public Iterator JavaDoc getPublicIDs() {
63         List JavaDoc<String JavaDoc> list = new ArrayList JavaDoc<String JavaDoc>();
64         list.add(PERSISTENCE_1_0_ID);
65         return list.iterator();
66     }
67     
68     public void refresh() {
69     }
70     
71     public String JavaDoc getSystemID(String JavaDoc publicId) {
72         if (PERSISTENCE_1_0_ID.equals(publicId)){
73             return PERSISTENCE_1_0_URL;
74         }
75         return null;
76     }
77     
78     public String JavaDoc resolveURI(String JavaDoc name) {
79         return null;
80     }
81     
82     public String JavaDoc resolvePublic(String JavaDoc publicId) {
83         return null;
84     }
85     
86     public void addCatalogListener(CatalogListener l) {
87     }
88     
89     public void removeCatalogListener(CatalogListener l) {
90     }
91     
92     public Image JavaDoc getIcon(int type) {
93         return Utilities.loadImage("org/netbeans/modules/j2ee/persistence/dd/resources/persistenceCatalog.gif"); // NOI18N
94
}
95     
96     public String JavaDoc getDisplayName() {
97         return NbBundle.getMessage(PersistenceCatalog.class, "LBL_PersistenceCatalog");
98     }
99     
100     public String JavaDoc getShortDescription() {
101         return NbBundle.getMessage(PersistenceCatalog.class, "DESC_PersistenceCatalog");
102     }
103     
104     public void addPropertyChangeListener(PropertyChangeListener JavaDoc l) {
105     }
106     
107     public void removePropertyChangeListener(PropertyChangeListener JavaDoc l) {
108     }
109     
110 }
111
Popular Tags