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