001    /**
002     * Copyright (c) 2000-2013 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.portal.model;
016    
017    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
018    import com.liferay.portal.kernel.util.Tuple;
019    import com.liferay.portal.kernel.xml.Element;
020    
021    import java.util.List;
022    import java.util.Map;
023    
024    /**
025     * @author Brian Wing Shun Chan
026     */
027    public class ModelHintsUtil {
028    
029            public static String buildCustomValidatorName(String validatorName) {
030                    return getModelHints().buildCustomValidatorName(validatorName);
031            }
032    
033            public static Map<String, String> getDefaultHints(String model) {
034                    return getModelHints().getDefaultHints(model);
035            }
036    
037            public static Element getFieldsEl(String model, String field) {
038                    return getModelHints().getFieldsEl(model, field);
039            }
040    
041            public static Map<String, String> getHints(String model, String field) {
042                    return getModelHints().getHints(model, field);
043            }
044    
045            public static int getMaxLength(String model, String field) {
046                    return getModelHints().getMaxLength(model, field);
047            }
048    
049            public static ModelHints getModelHints() {
050                    PortalRuntimePermission.checkGetBeanProperty(ModelHintsUtil.class);
051    
052                    return _modelHints;
053            }
054    
055            public static List<String> getModels() {
056                    return getModelHints().getModels();
057            }
058    
059            public static Tuple getSanitizeTuple(String model, String field) {
060                    return getModelHints().getSanitizeTuple(model, field);
061            }
062    
063            public static List<Tuple> getSanitizeTuples(String model) {
064                    return getModelHints().getSanitizeTuples(model);
065            }
066    
067            public static String getType(String model, String field) {
068                    return getModelHints().getType(model, field);
069            }
070    
071            public static List<Tuple> getValidators(String model, String field) {
072                    return getModelHints().getValidators(model, field);
073            }
074    
075            public static boolean isCustomValidator(String validatorName) {
076                    return getModelHints().isCustomValidator(validatorName);
077            }
078    
079            public static boolean isLocalized(String model, String field) {
080                    return getModelHints().isLocalized(model, field);
081            }
082    
083            public static void read(ClassLoader classLoader, String source)
084                    throws Exception {
085    
086                    getModelHints().read(classLoader, source);
087            }
088    
089            public static String trimString(String model, String field, String value) {
090                    return getModelHints().trimString(model, field, value);
091            }
092    
093            public void setModelHints(ModelHints modelHints) {
094                    PortalRuntimePermission.checkSetBeanProperty(getClass());
095    
096                    _modelHints = modelHints;
097            }
098    
099            private static ModelHints _modelHints;
100    
101    }