]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.message/src/org/simantics/message/internal/MessageDataSchemeExtension.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.message / src / org / simantics / message / internal / MessageDataSchemeExtension.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in 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.message.internal;
13
14 import org.eclipse.core.runtime.CoreException;
15 import org.eclipse.core.runtime.IConfigurationElement;
16 import org.simantics.message.IMessageDataSchemeExtension;
17 import org.simantics.message.IMessageSchemeHandler;
18 import org.simantics.message.IReferenceSerializer;
19
20 /**
21  * @author Tuukka Lehtonen
22  */
23 public class MessageDataSchemeExtension implements IMessageDataSchemeExtension {
24
25     private final IConfigurationElement schemeElement;
26     private final String                id;
27     private final String                scheme;
28     private final String                description;
29     private IConfigurationElement       handlerElement;
30
31     public MessageDataSchemeExtension(IConfigurationElement el, String id, String scheme, String description) {
32         this.schemeElement = el;
33         this.id = id;
34         this.scheme = scheme;
35         this.description = description;
36     }
37
38     public IConfigurationElement getSchemeElement() {
39         return schemeElement;
40     }
41
42     public IConfigurationElement getHandlerElement() {
43         return handlerElement;
44     }
45
46     public void setHandlerElement(IConfigurationElement handlerElement) {
47         this.handlerElement = handlerElement;
48     }
49
50     /* (non-Javadoc)
51      * @see org.simantics.message.IMessageDataSchemeExtension#getId()
52      */
53     public String getId() {
54         return id;
55     }
56
57     /* (non-Javadoc)
58      * @see org.simantics.message.IMessageDataSchemeExtension#getScheme()
59      */
60     public String getScheme() {
61         return scheme;
62     }
63
64     /* (non-Javadoc)
65      * @see org.simantics.message.IMessageDataSchemeExtension#getDescription()
66      */
67     public String getDescription() {
68         return description;
69     }
70
71     /* (non-Javadoc)
72      * @see org.simantics.message.IMessageDataSchemeExtension#getHandler()
73      */
74     public IMessageSchemeHandler getHandler() {
75         if (handlerElement == null)
76             return null;
77
78         try {
79             return (IMessageSchemeHandler) handlerElement.createExecutableExtension("handler");
80         } catch (CoreException e) {
81             throw new RuntimeException(e);
82         }
83     }
84
85     /* (non-Javadoc)
86      * @see org.simantics.message.IMessageDataSchemeExtension#getSerializer()
87      */
88     public IReferenceSerializer getSerializer() {
89         try {
90             return (IReferenceSerializer) schemeElement.createExecutableExtension("serializer");
91         } catch (CoreException e) {
92             throw new RuntimeException(e);
93         }
94     }
95
96 }