| ScriptData.java |
1 /**
2 * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3 *
4 * This library is free software; you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License as published by the Free
6 * Software Foundation; either version 2.1 of the License, or (at your option)
7 * any later version.
8 *
9 * This library is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 * details.
13 */
14
15 package com.liferay.portal.servlet.taglib.aui;
16
17 import com.liferay.portal.kernel.util.StringBundler;
18 import com.liferay.portal.kernel.util.StringUtil;
19 import com.liferay.portal.kernel.util.Validator;
20
21 import java.util.Set;
22 import java.util.TreeSet;
23
24 /**
25 * <a href="ScriptData.java.html"><b><i>View Source</i></b></a>
26 *
27 * @author Brian Wing Shun Chan
28 */
29 public class ScriptData {
30
31 public void append(String content, String use) {
32 if (Validator.isNull(use)) {
33 _rawSB.append(content);
34 }
35 else {
36 _callbackSB.append("(function() {");
37 _callbackSB.append(content);
38 _callbackSB.append("})();");
39
40 String[] useArray = StringUtil.split(use);
41
42 for (int i = 0; i < useArray.length; i++) {
43 _useSet.add(useArray[i]);
44 }
45 }
46 }
47
48 public StringBundler getCallbackSB() {
49 return _callbackSB;
50 }
51
52 public StringBundler getRawSB() {
53 return _rawSB;
54 }
55
56 public Set<String> getUseSet() {
57 return _useSet;
58 }
59
60 private StringBundler _callbackSB = new StringBundler();
61 private StringBundler _rawSB = new StringBundler();
62 private Set<String> _useSet = new TreeSet<String>();
63
64 }