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