]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.databoard/src/org/simantics/databoard/accessor/RecordAccessor.java
Added addFirst/After/Before + remove SCL functions for Ordered Sets
[simantics/platform.git] / bundles / org.simantics.databoard / src / org / simantics / databoard / accessor / RecordAccessor.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.type.RecordType;
18
19 /**
20  * Accessor to a Record.
21  *
22  * @author Toni Kalajainen <toni.kalajainen@vtt.fi>
23  */
24 public interface RecordAccessor extends Accessor {
25
26         /**
27          * Get the number of fields in the record
28          * 
29          * @return field count
30          * @throws AccessorException
31          */
32         int count() throws AccessorException;
33
34         /**
35          * Get an accessor to a field. The return value becomes invalid if a new 
36          * value is assigned with {@link #setFieldValue(int, Binding, Object)}.
37          * 
38          * @param index
39          * @return accessor to the field
40          * @throws AccessorConstructionException 
41          */
42         <T extends Accessor> T getFieldAccessor(int index) throws AccessorConstructionException;
43
44         /**
45          * Get an accessor to a field. The return value becomes invalid if a new 
46          * value is assigned with {@link #setFieldValue(int, Binding, Object)}.
47          * 
48          * @param fieldName
49          * @return accessor to the field
50          * @throws AccessorConstructionException 
51          */
52         <T extends Accessor> T getFieldAccessor(String fieldName) throws AccessorConstructionException;
53         
54         /**
55          * Get field value.
56          * 
57          * Note, use RecordAccessor#type().getComponentIndex( fieldName ) to get index. <p>
58          * 
59          * @param index field index
60          * @return the value of the field
61          * @throws AccessorException
62          */
63         Object getFieldValue(int index, Binding fieldBinding) throws AccessorException;
64         
65         /**
66          * Get field value.
67          * 
68          * Note, use RecordAccessor#type().getComponentIndex( fieldName ) to get index. <p>
69          * 
70          * @param fieldName 
71          * @return the value of the field
72          * @throws AccessorException
73          */
74         Object getFieldValue(String fieldName, Binding fieldBinding) throws AccessorException;
75                 
76         /**
77          * Set field value. 
78          *  
79          * Writing the current value again may not emit an event. This is implementation
80          * specific. <p>
81          * 
82          * @param index field index
83          * @param fieldBinding 
84          * @param value
85          * @throws AccessorException
86          */
87         void setFieldValue(int index, Binding fieldBinding, Object value) throws AccessorException;
88
89         /**
90          * Set field value. 
91          *  
92          * Writing the current value again may not emit an event. This is implementation
93          * specific. <p>
94          * 
95          * @param fieldName
96          * @param fieldBinding 
97          * @param value
98          * @throws AccessorException
99          */
100         void setFieldValue(String fieldName, Binding fieldBinding, Object value) throws AccessorException;
101         
102         RecordType type();
103         
104 }
105