001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.dynamicdatamapping.util;
016    
017    import com.liferay.portal.kernel.json.JSONArray;
018    import com.liferay.portal.kernel.json.JSONException;
019    import com.liferay.portal.kernel.xml.Document;
020    import com.liferay.portal.kernel.xml.DocumentException;
021    import com.liferay.portal.kernel.xml.Element;
022    import com.liferay.portlet.dynamicdatamapping.model.DDMTemplate;
023    import com.liferay.portlet.dynamicdatamapping.storage.Fields;
024    
025    import java.util.Locale;
026    
027    import javax.servlet.jsp.PageContext;
028    
029    /**
030     * @author Eduardo Lundgren
031     * @author Brian Wing Shun Chan
032     */
033    public class DDMXSDUtil {
034    
035            public static DDMXSD getDDMXSD() {
036                    return _ddmXSD;
037            }
038    
039            public static String getHTML(
040                            PageContext pageContext, DDMTemplate ddmTemplate, Fields fields,
041                            Locale locale)
042                    throws Exception {
043    
044                    return getDDMXSD().getHTML(pageContext, ddmTemplate, fields, locale);
045            }
046    
047            public static String getHTML(
048                            PageContext pageContext, Document document, Fields fields,
049                            Locale locale)
050                    throws Exception {
051    
052                    return getDDMXSD().getHTML(pageContext, document, fields, locale);
053            }
054    
055            public static String getHTML(
056                            PageContext pageContext, Document document, Fields fields,
057                            String namespace, boolean readOnly, Locale locale)
058                    throws Exception {
059    
060                    return getDDMXSD().getHTML(
061                            pageContext, document, fields, namespace, readOnly, locale);
062            }
063    
064            public static String getHTML(
065                            PageContext pageContext, Document document, Fields fields,
066                            String namespace, String mode, boolean readOnly, Locale locale)
067                    throws Exception {
068    
069                    return getDDMXSD().getHTML(
070                            pageContext, document, fields, namespace, mode, readOnly, locale);
071            }
072    
073            public static String getHTML(
074                            PageContext pageContext, Document document, Locale locale)
075                    throws Exception {
076    
077                    return getDDMXSD().getHTML(pageContext, document, locale);
078            }
079    
080            public static String getHTML(
081                            PageContext pageContext, Element element, Locale locale)
082                    throws Exception {
083    
084                    return getDDMXSD().getHTML(pageContext, element, locale);
085            }
086    
087            public static String getHTML(
088                            PageContext pageContext, String xml, Fields fields, Locale locale)
089                    throws Exception {
090    
091                    return getDDMXSD().getHTML(pageContext, xml, fields, locale);
092            }
093    
094            public static String getHTML(
095                            PageContext pageContext, String xml, Fields fields,
096                            String namespace, boolean readOnly, Locale locale)
097                    throws Exception {
098    
099                    return getDDMXSD().getHTML(
100                            pageContext, xml, fields, namespace, readOnly, locale);
101            }
102    
103            public static String getHTML(
104                            PageContext pageContext, String xml, Fields fields,
105                            String namespace, Locale locale)
106                    throws Exception {
107    
108                    return getDDMXSD().getHTML(pageContext, xml, fields, namespace, locale);
109            }
110    
111            public static String getHTML(
112                            PageContext pageContext, String xml, Locale locale)
113                    throws Exception {
114    
115                    return getDDMXSD().getHTML(pageContext, xml, locale);
116            }
117    
118            public static JSONArray getJSONArray(Document document)
119                    throws JSONException {
120    
121                    return getDDMXSD().getJSONArray(document);
122            }
123    
124            public static JSONArray getJSONArray(String xml)
125                    throws DocumentException, JSONException {
126    
127                    return getDDMXSD().getJSONArray(xml);
128            }
129    
130            public void setDDMXSD(DDMXSD ddmXSD) {
131                    _ddmXSD = ddmXSD;
132            }
133    
134            private static DDMXSD _ddmXSD;
135    
136    }