001    /**
002     * Copyright (c) 2000-2012 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.portlet.dynamicdatamapping.model.DDMStructure;
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, DDMStructure ddmStructure, Fields fields,
041                            String namespace, boolean readOnly, Locale locale)
042                    throws Exception {
043    
044                    return getDDMXSD().getHTML(
045                            pageContext, ddmStructure, fields, namespace, readOnly, locale);
046            }
047    
048            public static String getHTML(
049                            PageContext pageContext, DDMTemplate ddmTemplate, Fields fields,
050                            String namespace, boolean readOnly, Locale locale)
051                    throws Exception {
052    
053                    return getDDMXSD().getHTML(
054                            pageContext, ddmTemplate, fields, namespace, readOnly, locale);
055            }
056    
057            public static String getHTML(
058                            PageContext pageContext, String xml, Fields fields, Locale locale)
059                    throws Exception {
060    
061                    return getDDMXSD().getHTML(pageContext, xml, fields, locale);
062            }
063    
064            public static String getHTML(
065                            PageContext pageContext, String xml, Fields fields,
066                            String namespace, boolean readOnly, Locale locale)
067                    throws Exception {
068    
069                    return getDDMXSD().getHTML(
070                            pageContext, xml, fields, namespace, readOnly, locale);
071            }
072    
073            public static String getHTML(
074                            PageContext pageContext, String xml, Fields fields,
075                            String namespace, Locale locale)
076                    throws Exception {
077    
078                    return getDDMXSD().getHTML(pageContext, xml, fields, namespace, locale);
079            }
080    
081            public static String getHTML(
082                            PageContext pageContext, String xml, Locale locale)
083                    throws Exception {
084    
085                    return getDDMXSD().getHTML(pageContext, xml, locale);
086            }
087    
088            public static JSONArray getJSONArray(Document document)
089                    throws JSONException {
090    
091                    return getDDMXSD().getJSONArray(document);
092            }
093    
094            public static JSONArray getJSONArray(String xml)
095                    throws DocumentException, JSONException {
096    
097                    return getDDMXSD().getJSONArray(xml);
098            }
099    
100            public void setDDMXSD(DDMXSD ddmXSD) {
101                    _ddmXSD = ddmXSD;
102            }
103    
104            private static DDMXSD _ddmXSD;
105    
106    }