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.storage.Fields;
023    
024    import java.util.Locale;
025    
026    import javax.servlet.jsp.PageContext;
027    
028    /**
029     * @author Eduardo Lundgren
030     * @author Brian Wing Shun Chan
031     */
032    public class DDMXSDUtil {
033    
034            public static DDMXSD getDDMXSD() {
035                    return _ddmXSD;
036            }
037    
038            public static String getHTML(
039                            PageContext pageContext, Document document, Locale locale)
040                    throws Exception {
041    
042                    return getDDMXSD().getHTML(pageContext, document, locale);
043            }
044    
045            public static String getHTML(
046                            PageContext pageContext, Document document, Fields fields,
047                            Locale locale)
048                    throws Exception {
049    
050                    return getDDMXSD().getHTML(pageContext, document, fields, locale);
051            }
052    
053            public static String getHTML(
054                            PageContext pageContext, Document document, Fields fields,
055                            String namespace, boolean readOnly, Locale locale)
056                    throws Exception {
057    
058                    return getDDMXSD().getHTML(
059                            pageContext, document, fields, namespace, readOnly, locale);
060            }
061    
062            public static String getHTML(
063                            PageContext pageContext, Element element, Locale locale)
064                    throws Exception {
065    
066                    return getDDMXSD().getHTML(pageContext, element, locale);
067            }
068    
069            public static String getHTML(
070                            PageContext pageContext, String xml, Locale locale)
071                    throws Exception {
072    
073                    return getDDMXSD().getHTML(pageContext, xml, locale);
074            }
075    
076            public static String getHTML(
077                            PageContext pageContext, String xml, Fields fields, Locale locale)
078                    throws Exception {
079    
080                    return getDDMXSD().getHTML(pageContext, xml, fields, locale);
081            }
082    
083            public static String getHTML(
084                            PageContext pageContext, String xml, Fields fields,
085                            String namespace, Locale locale)
086                    throws Exception {
087    
088                    return getDDMXSD().getHTML(pageContext, xml, fields, namespace, locale);
089            }
090    
091            public static String getHTML(
092                            PageContext pageContext, String xml, Fields fields,
093                            String namespace, boolean readOnly, Locale locale)
094                    throws Exception {
095    
096                    return getDDMXSD().getHTML(
097                            pageContext, xml, fields, namespace, readOnly, locale);
098            }
099    
100            public static JSONArray getJSONArray(Document document)
101                    throws JSONException {
102    
103                    return getDDMXSD().getJSONArray(document);
104            }
105    
106            public static JSONArray getJSONArray(String xml)
107                    throws DocumentException, JSONException {
108    
109                    return getDDMXSD().getJSONArray(xml);
110            }
111    
112            public void setDDMXSD(DDMXSD ddmXSD) {
113                    _ddmXSD = ddmXSD;
114            }
115    
116            private static DDMXSD _ddmXSD;
117    
118    }