1 /*******************************************************************************
2 * Copyright (c) 2010 Association for Decentralized Information Management in
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
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.databoard.accessor;
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;
20 * Accessor to a Record.
22 * @author Toni Kalajainen <toni.kalajainen@vtt.fi>
24 public interface RecordAccessor extends Accessor {
27 * Get the number of fields in the record
30 * @throws AccessorException
32 int count() throws AccessorException;
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)}.
39 * @return accessor to the field
40 * @throws AccessorConstructionException
42 <T extends Accessor> T getFieldAccessor(int index) throws AccessorConstructionException;
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)}.
49 * @return accessor to the field
50 * @throws AccessorConstructionException
52 <T extends Accessor> T getFieldAccessor(String fieldName) throws AccessorConstructionException;
57 * Note, use RecordAccessor#type().getComponentIndex( fieldName ) to get index. <p>
59 * @param index field index
60 * @return the value of the field
61 * @throws AccessorException
63 Object getFieldValue(int index, Binding fieldBinding) throws AccessorException;
68 * Note, use RecordAccessor#type().getComponentIndex( fieldName ) to get index. <p>
71 * @return the value of the field
72 * @throws AccessorException
74 Object getFieldValue(String fieldName, Binding fieldBinding) throws AccessorException;
79 * Writing the current value again may not emit an event. This is implementation
82 * @param index field index
85 * @throws AccessorException
87 void setFieldValue(int index, Binding fieldBinding, Object value) throws AccessorException;
92 * Writing the current value again may not emit an event. This is implementation
98 * @throws AccessorException
100 void setFieldValue(String fieldName, Binding fieldBinding, Object value) throws AccessorException;