1
14
15 package com.liferay.portal.kernel.lar;
16
17
22 public class PortletDataHandlerChoice extends PortletDataHandlerControl {
23
24 public PortletDataHandlerChoice(String namespace, String controlName) {
25 this(namespace, controlName, 0, _DEFAULT_CHOICES);
26 }
27
28 public PortletDataHandlerChoice(
29 String namespace, String controlName, int defaultChoice) {
30
31 this(namespace, controlName, defaultChoice, _DEFAULT_CHOICES);
32 }
33
34 public PortletDataHandlerChoice(
35 String namespace, String controlName, int defaultChoice,
36 String[] choices) {
37
38 super(namespace, controlName);
39
40 _choices = choices;
41 _defaultChoice = defaultChoice;
42 }
43
44 public String[] getChoices() {
45 if ((_choices == null) || (_choices.length < 1)) {
46 return _DEFAULT_CHOICES;
47 }
48 else {
49 return _choices;
50 }
51 }
52
53 public String getDefaultChoice() {
54 return getChoices()[getDefaultChoiceIndex()];
55 }
56
57 public int getDefaultChoiceIndex() {
58 if ((_defaultChoice < 0) || (_defaultChoice >= _choices.length)) {
59 return 0;
60 }
61 else {
62 return _defaultChoice;
63 }
64 }
65
66 private static final String[] _DEFAULT_CHOICES = new String[] {
67 "false", "true"
68 };
69
70 private String[] _choices;
71 private int _defaultChoice;
72
73 }