01: package org.drools.eclipse.flow.common.datatype;
02:
03: /*
04: * Copyright 2005 JBoss Inc
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */
18:
19: import org.drools.eclipse.flow.common.datatype.impl.DataTypeRegistryImpl;
20: import org.drools.eclipse.flow.common.view.datatype.editor.impl.BooleanEditor;
21: import org.drools.eclipse.flow.common.view.datatype.editor.impl.EmptyEditor;
22: import org.drools.eclipse.flow.common.view.datatype.editor.impl.IntegerEditor;
23: import org.drools.ruleflow.common.datatype.DataTypeFactory;
24: import org.drools.ruleflow.common.datatype.impl.InstanceDataTypeFactory;
25: import org.drools.ruleflow.common.datatype.impl.type.BooleanDataType;
26: import org.drools.ruleflow.common.datatype.impl.type.FloatDataType;
27: import org.drools.ruleflow.common.datatype.impl.type.IntegerDataType;
28: import org.drools.ruleflow.common.datatype.impl.type.StringDataType;
29: import org.drools.ruleflow.common.datatype.impl.type.UndefinedDataType;
30:
31: import sun.beans.editors.FloatEditor;
32: import sun.beans.editors.StringEditor;
33:
34: /**
35: * Default datatype registry containing default datatypes.
36: *
37: * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris Verlaenen</a>
38: */
39: public class DefaultDataTypeRegistry {
40:
41: private static final DataTypeRegistry variableDataTypeRegistry = new DataTypeRegistryImpl();
42:
43: private DefaultDataTypeRegistry() {
44: }
45:
46: static {
47: registerVariableDataType(UndefinedDataType.class,
48: new InstanceDataTypeFactory(UndefinedDataType.class),
49: "Undefined", EmptyEditor.class, EmptyEditor.class);
50: registerVariableDataType(BooleanDataType.class,
51: new InstanceDataTypeFactory(BooleanDataType.class),
52: "Boolean", BooleanEditor.class, EmptyEditor.class);
53: registerVariableDataType(IntegerDataType.class,
54: new InstanceDataTypeFactory(IntegerDataType.class),
55: "Integer", IntegerEditor.class, EmptyEditor.class);
56: registerVariableDataType(FloatDataType.class,
57: new InstanceDataTypeFactory(FloatDataType.class),
58: "Float", FloatEditor.class, EmptyEditor.class);
59: registerVariableDataType(StringDataType.class,
60: new InstanceDataTypeFactory(StringDataType.class),
61: "String", StringEditor.class, EmptyEditor.class);
62: }
63:
64: public static void registerVariableDataType(Class type,
65: DataTypeFactory dataTypeFactory, String name,
66: Class valueEditorClass, Class dataTypeEditorClass) {
67: variableDataTypeRegistry.registerDataType(type,
68: dataTypeFactory, name, valueEditorClass,
69: dataTypeEditorClass);
70: }
71:
72: public static DataTypeRegistry getInstance() {
73: return variableDataTypeRegistry;
74: }
75:
76: }
|