01: /*
02: * The contents of this file are subject to the terms of the Common Development
03: * and Distribution License (the License). You may not use this file except in
04: * compliance with the License.
05: *
06: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
07: * or http://www.netbeans.org/cddl.txt.
08: *
09: * 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-2007 Sun
17: * Microsystems, Inc. All Rights Reserved.
18: */
19: package org.netbeans.modules.xslt.tmap.model.xsltmap;
20:
21: import java.util.Map;
22: import java.util.WeakHashMap;
23: import org.openide.filesystems.FileObject;
24: import org.w3c.dom.Document;
25:
26: /**
27: * Accessor for the XsltMapModel
28: * @author Vitaly Bychkov
29: * @version 1.0
30: */
31: public class XsltMapAccessor {
32:
33: private XsltMapAccessor() {
34: }
35:
36: /**
37: * If xsltMapFile is null then return null
38: * If xsltMapFile couldn't be parsed or has another
39: * structure then required for the xsltmap.xml file by specification then return null
40: *
41: * now xsltMap model should be rebuilded every time as xsltMap file has been changed
42: * @param xsltMapFile xsltmap.xml file contains neccessary xslt transforamtion use cases
43: * @return XsltMapModel correspondent to the xsltmap file
44: */
45: public static XsltMapModel getXsltMapModel(FileObject xsltMapFile) {
46: if (!isValidXsltMapFile(xsltMapFile)) {
47: return null;
48: }
49: XsltMapModel model = new XsltMapModel(xsltMapFile);
50: model.initXsltMapModel();
51: if (!model.isInitModel()) {
52: model = null;
53: }
54:
55: return model;
56: }
57:
58: public static boolean isValidXsltMapFile(FileObject xsltMapFile) {
59: return xsltMapFile != null
60: && XsltMapConst.XML.equals(xsltMapFile.getExt())
61: && XsltMapConst.XSLTMAP.equals(xsltMapFile.getName());
62: }
63:
64: }
|