]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.databoard/src/org/simantics/databoard/accessor/UnionAccessor.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.databoard / src / org / simantics / databoard / accessor / UnionAccessor.java
1 /*******************************************************************************
2  *  Copyright (c) 2010 Association for Decentralized Information Management in
3  *  Industry THTH ry.
4  *  All rights reserved. This program and the accompanying materials
5  *  are made available under the terms of the Eclipse Public License v1.0
6  *  which accompanies this distribution, and is available at
7  *  http://www.eclipse.org/legal/epl-v10.html
8  *
9  *  Contributors:
10  *      VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.databoard.accessor;
13
14 import org.simantics.databoard.accessor.error.AccessorConstructionException;
15 import org.simantics.databoard.accessor.error.AccessorException;
16 import org.simantics.databoard.binding.Binding;
17 import org.simantics.databoard.binding.error.BindingException;
18 import org.simantics.databoard.type.UnionType;
19
20 public interface UnionAccessor extends Accessor {
21         
22         /**
23          * Get the number of tag types
24          * 
25          * @return the number of tag types
26          * @throws AccessorException
27          */
28         int count() throws AccessorException;
29         
30         /**
31          * Get the union tag index
32          * 
33          * @return tag index
34          * @throws AccessorException
35          */
36         int getTag() throws AccessorException;
37         
38         /**
39          * Get an accessor to the component value.
40          * The accessor becomes invalid if a new value is assigned. 
41          * 
42          * @return accessor to the value
43          * @throws AccessorConstructionException 
44          */
45         <T extends Accessor> T getComponentAccessor() throws AccessorConstructionException;
46         
47         /**
48          * Get the value
49          *  
50          * @param componentBinding component binding
51          * @return value
52          * @throws AccessorException
53          */
54         Object getComponentValue(Binding componentBinding) throws AccessorException; 
55         
56         /**
57          * Set a new Union value.
58          * 
59          * If the tag-type changes and there is an accessor to the previous value, 
60          * it becomes invalid.
61          * 
62          * @param unionBinding
63          * @param newUnion
64          * @throws BindingException binding error
65          * @throws UnsupportedOperationException cannot set a new value
66          */
67         void setValue(Binding unionBinding, Object newUnion) throws AccessorException;  
68         
69         /**
70          * Set a new component value. The argument newValue may be captured or copied.
71          * 
72          * @param tag
73          * @param componentBinding
74          * @param componentValue
75          * @throws AccessorException
76          */
77         void setComponentValue(int tag, Binding componentBinding, Object componentValue) throws AccessorException;
78         
79         UnionType type();
80         
81 }
82