/******************************************************************************* * Copyright (c) 2007, 2011 Association for Decentralized Information Management in * Industry THTH ry. * 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: * VTT Technical Research Centre of Finland - initial API and implementation *******************************************************************************/ package org.simantics.databoard.binding.reflection; import org.simantics.databoard.binding.Binding; import org.simantics.databoard.binding.FloatBinding; import org.simantics.databoard.binding.LongBinding; import org.simantics.databoard.binding.error.BindingConstructionException; import org.simantics.databoard.binding.error.BindingException; import org.simantics.databoard.type.NumberType; import org.simantics.databoard.type.RecordType; public class MyBinding extends ClassBinding { public MyBinding(RecordType type) throws BindingConstructionException { super( ClassInfo.getInfo(MyClass.class) ); this.type = type; } // @Override public Object getComponent(Object obj, int index) throws BindingException { MyClass x = (MyClass) obj; switch ( index ) { case 0: return x.field0; case 1: return x.field1; case 2: return x.field2; case 3: return x.field3; case 4: return x.field4; case 5: return x.field5; case 6: return x.field6; case 7: return x.field7; case 8: return x.field8; case 9: return x.field9; case 10: return x.field10; case 11: return x.field11; case 12: return x.field12; case 13: return x.field13; case 14: return x.field14; case 15: return x.field15; case 16: return x.field16; default: throw new BindingException("Illegal field index"); } } public Object getComponent2(Object obj, int index) throws BindingException { MyClass x = (MyClass) obj; switch ( index ) { case 0: return x.getField0(); case 1: return x.getField1(); case 2: return x.getField2(); case 3: return x.getField3(); case 4: return x.getField4(); case 5: return x.getField5(); case 6: return x.getField6(); case 7: return x.getField7(); case 8: return x.getField8(); case 9: return x.getField9(); case 10: return x.getField10(); case 11: return x.getField11(); case 12: return x.getField12(); case 13: return x.getField13(); case 14: return x.getField14(); case 15: return x.getField15(); case 16: return x.getField16(); default: throw new BindingException("Illegal field index"); } } // @Override public Object create(Object... values) throws BindingException { // return new MyClass( // (Byte) values[0], // (Integer) values[1], // (Short) values[2], // (Long) values[3], // (Float) values[4], // (Boolean) values[5], // (Double) values[6], // (NumberType) values[7], // (byte[]) values[8], // (int[]) values[9], // (short[]) values[10], // (long[]) values[11], // (float[]) values[12], // (boolean[]) values[13], // (double[]) values[14], // values[15], // (Integer) values[16] // ); return null; } public Object create2(Object... values) throws BindingException { MyClass x = new MyClass(this); setComponents(x, values); return x; } // @Override public Object createPartial() throws BindingException { return new MyClass(this); } public Object createPartial2() throws BindingException { Object values[] = new Object[15]; for (int i=0; i