001    /**
002     * Copyright (c) 2000-present 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.io.InputStream;
022    
023    import java.util.List;
024    import java.util.Map;
025    
026    /**
027     * @author Brian Wing Shun Chan
028     */
029    public class ModelHintsUtil {
030    
031            public static String buildCustomValidatorName(String validatorName) {
032                    return getModelHints().buildCustomValidatorName(validatorName);
033            }
034    
035            public static Map<String, String> getDefaultHints(String model) {
036                    return getModelHints().getDefaultHints(model);
037            }
038    
039            public static Element getFieldsEl(String model, String field) {
040                    return getModelHints().getFieldsEl(model, field);
041            }
042    
043            public static Map<String, String> getHints(String model, String field) {
044                    return getModelHints().getHints(model, field);
045            }
046    
047            public static int getMaxLength(String model, String field) {
048                    return getModelHints().getMaxLength(model, field);
049            }
050    
051            public static ModelHints getModelHints() {
052                    PortalRuntimePermission.checkGetBeanProperty(ModelHintsUtil.class);
053    
054                    return _modelHints;
055            }
056    
057            public static List<String> getModels() {
058                    return getModelHints().getModels();
059            }
060    
061            public static Tuple getSanitizeTuple(String model, String field) {
062                    return getModelHints().getSanitizeTuple(model, field);
063            }
064    
065            public static List<Tuple> getSanitizeTuples(String model) {
066                    return getModelHints().getSanitizeTuples(model);
067            }
068    
069            public static String getType(String model, String field) {
070                    return getModelHints().getType(model, field);
071            }
072    
073            public static List<Tuple> getValidators(String model, String field) {
074                    return getModelHints().getValidators(model, field);
075            }
076    
077            public static String getValue(
078                    String model, String field, String name, String defaultValue) {
079    
080                    return getModelHints().getValue(model, field, name, defaultValue);
081            }
082    
083            public static boolean hasField(String model, String field) {
084                    return getModelHints().hasField(model, field);
085            }
086    
087            public static boolean isCustomValidator(String validatorName) {
088                    return getModelHints().isCustomValidator(validatorName);
089            }
090    
091            public static boolean isLocalized(String model, String field) {
092                    return getModelHints().isLocalized(model, field);
093            }
094    
095            public static void read(ClassLoader classLoader, InputStream inputStream)
096                    throws Exception {
097    
098                    getModelHints().read(classLoader, inputStream);
099            }
100    
101            public static void read(ClassLoader classLoader, String source)
102                    throws Exception {
103    
104                    getModelHints().read(classLoader, source);
105            }
106    
107            public static String trimString(String model, String field, String value) {
108                    return getModelHints().trimString(model, field, value);
109            }
110    
111            public void setModelHints(ModelHints modelHints) {
112                    PortalRuntimePermission.checkSetBeanProperty(getClass());
113    
114                    _modelHints = modelHints;
115            }
116    
117            private static ModelHints _modelHints;
118    
119    }