Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 8b07c45a5641c4823d56d5c99570a3055001243c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/*******************************************************************************
 * Copyright (c) 2001, 2008 Oracle Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     Oracle Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.jst.jsf.common.runtime.internal.model.behavioural;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.eclipse.jst.jsf.common.runtime.internal.model.IDesigntimeAdapter;
import org.eclipse.jst.jsf.common.runtime.internal.model.component.ComponentFactory;
import org.eclipse.jst.jsf.common.runtime.internal.model.decorator.ConverterDecorator;
import org.eclipse.jst.jsf.common.runtime.internal.model.decorator.ValidatorDecorator;
import org.eclipse.jst.jsf.common.runtime.internal.model.decorator.ValueChangeListenerDecorator;

/**
 * Implementation of the IEditableValueHolderInfo
 * 
 * @author cbateman
 *
 */
public class EditableValueHolderInfo extends ValueHolderInfo implements
        IEditableValueHolderInfo, IDesigntimeAdapter
{
    /**
     * 
     */
    private static final long serialVersionUID = -2115990809157328451L;
    private static final String[]  INTERFACE = new String[] {ComponentFactory.INTERFACE_EDITABLEVALUEHOLDER};
    
    private final boolean       _localSetValue;
    private final Object        _submittedValue;
    private final String        _validator;
    private final String        _valueChangeListener;
    private final boolean       _isImmediate;
    private final boolean       _isRequired;
    private final boolean       _isValid;
    private List                _validators;
    private List                _valueChangeListeners;
    
    /**
     * @param converterDecorator
     * @param localValue
     * @param value
     * @param isImmediate
     * @param isRequired
     * @param isValid
     * @param localSetValue
     * @param submittedValue
     * @param validator
     * @param valueChangeListener
     */
    public EditableValueHolderInfo(final ConverterDecorator converterDecorator,
            final Object localValue, final Object value, final boolean isImmediate,
            final boolean isRequired, final boolean isValid, final boolean localSetValue,
            final Object submittedValue, final String validator, final String valueChangeListener) 
    {
        super(converterDecorator, localValue, value);
        _isImmediate = isImmediate;
        _isRequired = isRequired;
        _isValid = isValid;
        _localSetValue = localSetValue;
        _submittedValue = submittedValue;
        _validator = validator;
        _valueChangeListener = valueChangeListener;
    }

    public final boolean isLocalSetValue() {
        return _localSetValue;
    }

    public final Object getSubmittedValue() {
        return _submittedValue;
    }

    public final String getValidator() {
        return _validator;
    }

    public final String getValueChangeListener() {
        return _valueChangeListener;
    }

    public final boolean isImmediate() {
        return _isImmediate;
    }

    public final boolean isRequired() {
        return _isRequired;
    }

    public final boolean isValid() {
        return _isValid;
    }

    public void addValidator(final ValidatorDecorator validator) 
    {
        if (_validators == null)
        {
            _validators = new ArrayList(2);
        }
        _validators.add(validator);
    }

    public void addValueChangeListener(
            final ValueChangeListenerDecorator valueChangeListenerInfo) 
    {
        if (_valueChangeListeners == null)
        {
            _valueChangeListeners = new ArrayList(2);
        }
        _valueChangeListeners.add(valueChangeListenerInfo);
    }

    public List getValidators() {
        if (_validators == null)
        {
            return Collections.EMPTY_LIST;
        }
        
        return Collections.unmodifiableList(_validators);
    }

    public List getValueChangeListeners() {
        if (_valueChangeListeners == null)
        {
            return Collections.EMPTY_LIST;
        }
        
        return Collections.unmodifiableList(_valueChangeListeners);
    }

    public String[] getInterfaces()
    {
        return INTERFACE;
    }
}

Back to the top