| 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() {" + content + "})();");
37
38 String[] useArray = StringUtil.split(use);
39
40 for (int i = 0; i < useArray.length; i++) {
41 _useSet.add(useArray[i]);
42 }
43 }
44 }
45
46 public StringBundler getCallbackSB() {
47 return _callbackSB;
48 }
49
50 public StringBundler getRawSB() {
51 return _rawSB;
52 }
53
54 public Set<String> getUseSet() {
55 return _useSet;
56 }
57
58 private StringBundler _callbackSB = new StringBundler();
59 private StringBundler _rawSB = new StringBundler();
60 private Set<String> _useSet = new TreeSet<String>();
61
62 }