Commit | Line | Data |
---|---|---|
1d7e62f9 GB |
1 | /******************************************************************************* |
2 | * Copyright (c) 2014 École Polytechnique de Montréal | |
3 | * | |
4 | * All rights reserved. This program and the accompanying materials are | |
5 | * made available under the terms of the Eclipse Public License v1.0 which | |
6 | * accompanies this distribution, and is available at | |
7 | * http://www.eclipse.org/legal/epl-v10.html | |
8 | * | |
9 | * Contributors: | |
10 | * Geneviève Bastien - Initial API and implementation | |
11 | *******************************************************************************/ | |
12 | ||
2bdf0193 | 13 | package org.eclipse.tracecompass.tmf.analysis.xml.core.model.readonly; |
1d7e62f9 GB |
14 | |
15 | import java.util.List; | |
16 | ||
3a5f73a1 | 17 | import org.eclipse.jdt.annotation.NonNull; |
12685851 | 18 | import org.eclipse.jdt.annotation.Nullable; |
2bdf0193 AM |
19 | import org.eclipse.tracecompass.tmf.analysis.xml.core.model.ITmfXmlModelFactory; |
20 | import org.eclipse.tracecompass.tmf.analysis.xml.core.model.ITmfXmlStateAttribute; | |
21 | import org.eclipse.tracecompass.tmf.analysis.xml.core.model.ITmfXmlStateValue; | |
3a5f73a1 | 22 | import org.eclipse.tracecompass.tmf.analysis.xml.core.model.TmfXmlAction; |
2bdf0193 AM |
23 | import org.eclipse.tracecompass.tmf.analysis.xml.core.model.TmfXmlCondition; |
24 | import org.eclipse.tracecompass.tmf.analysis.xml.core.model.TmfXmlEventHandler; | |
3a5f73a1 | 25 | import org.eclipse.tracecompass.tmf.analysis.xml.core.model.TmfXmlFsm; |
2bdf0193 | 26 | import org.eclipse.tracecompass.tmf.analysis.xml.core.model.TmfXmlLocation; |
3a5f73a1 JCK |
27 | import org.eclipse.tracecompass.tmf.analysis.xml.core.model.TmfXmlPatternEventHandler; |
28 | import org.eclipse.tracecompass.tmf.analysis.xml.core.model.TmfXmlPatternSegmentBuilder; | |
29 | import org.eclipse.tracecompass.tmf.analysis.xml.core.model.TmfXmlState; | |
2bdf0193 | 30 | import org.eclipse.tracecompass.tmf.analysis.xml.core.model.TmfXmlStateChange; |
3a5f73a1 JCK |
31 | import org.eclipse.tracecompass.tmf.analysis.xml.core.model.TmfXmlStateTransition; |
32 | import org.eclipse.tracecompass.tmf.analysis.xml.core.model.TmfXmlTransitionValidator; | |
33 | import org.eclipse.tracecompass.tmf.analysis.xml.core.model.TmfXmlTimestampCondition; | |
2bdf0193 | 34 | import org.eclipse.tracecompass.tmf.analysis.xml.core.module.IXmlStateSystemContainer; |
1d7e62f9 GB |
35 | import org.w3c.dom.Element; |
36 | ||
37 | /** | |
b1ebf44e | 38 | * Concrete factory for XML model elements in read only mode |
1d7e62f9 GB |
39 | * |
40 | * @author Geneviève Bastien | |
41 | */ | |
b1ebf44e | 42 | public class TmfXmlReadOnlyModelFactory implements ITmfXmlModelFactory { |
1d7e62f9 | 43 | |
12685851 | 44 | private static @Nullable ITmfXmlModelFactory fInstance = null; |
1d7e62f9 GB |
45 | |
46 | /** | |
47 | * Get the instance of this model creator | |
48 | * | |
c42ec905 | 49 | * @return The {@link TmfXmlReadOnlyModelFactory} instance |
1d7e62f9 | 50 | */ |
1d7e62f9 GB |
51 | public static synchronized ITmfXmlModelFactory getInstance() { |
52 | ITmfXmlModelFactory instance = fInstance; | |
53 | if (instance == null) { | |
b1ebf44e | 54 | instance = new TmfXmlReadOnlyModelFactory(); |
1d7e62f9 GB |
55 | fInstance = instance; |
56 | } | |
57 | return instance; | |
58 | } | |
59 | ||
60 | @Override | |
61 | public ITmfXmlStateAttribute createStateAttribute(Element attribute, IXmlStateSystemContainer container) { | |
b1ebf44e | 62 | return new TmfXmlReadOnlyStateAttribute(this, attribute, container); |
1d7e62f9 GB |
63 | } |
64 | ||
65 | @Override | |
66 | public ITmfXmlStateValue createStateValue(Element node, IXmlStateSystemContainer container, List<ITmfXmlStateAttribute> attributes) { | |
b1ebf44e | 67 | return new TmfXmlReadOnlyStateValue(this, node, container, attributes); |
1d7e62f9 GB |
68 | } |
69 | ||
70 | @Override | |
71 | public ITmfXmlStateValue createStateValue(Element node, IXmlStateSystemContainer container, String eventField) { | |
b1ebf44e | 72 | return new TmfXmlReadOnlyStateValue(this, node, container, eventField); |
1d7e62f9 GB |
73 | } |
74 | ||
75 | @Override | |
76 | public TmfXmlCondition createCondition(Element node, IXmlStateSystemContainer container) { | |
3a5f73a1 | 77 | return TmfXmlCondition.create(this, node, container); |
1d7e62f9 GB |
78 | } |
79 | ||
80 | @Override | |
81 | public TmfXmlEventHandler createEventHandler(Element node, IXmlStateSystemContainer container) { | |
82 | return new TmfXmlEventHandler(this, node, container); | |
83 | } | |
84 | ||
85 | @Override | |
86 | public TmfXmlStateChange createStateChange(Element node, IXmlStateSystemContainer container) { | |
87 | return new TmfXmlStateChange(this, node, container); | |
88 | } | |
89 | ||
90 | @Override | |
91 | public TmfXmlLocation createLocation(Element node, IXmlStateSystemContainer container) { | |
92 | return new TmfXmlLocation(this, node, container); | |
93 | } | |
94 | ||
3a5f73a1 JCK |
95 | /** |
96 | * @since 2.0 | |
97 | */ | |
98 | @Override | |
99 | public TmfXmlPatternEventHandler createPatternEventHandler(Element node, IXmlStateSystemContainer container) { | |
100 | return new TmfXmlPatternEventHandler(this, node, container); | |
101 | } | |
102 | ||
103 | /** | |
104 | * @since 2.0 | |
105 | */ | |
106 | @Override | |
107 | public TmfXmlTransitionValidator createTransitionValidator(Element node, IXmlStateSystemContainer container) { | |
108 | return new TmfXmlTransitionValidator(this, node, container); | |
109 | } | |
110 | ||
111 | /** | |
112 | * @since 2.0 | |
113 | */ | |
114 | @Override | |
115 | public TmfXmlAction createAction(Element node, IXmlStateSystemContainer container) { | |
116 | return new TmfXmlAction(this, node, container); | |
117 | } | |
118 | ||
119 | /** | |
120 | * @since 2.0 | |
121 | */ | |
122 | @Override | |
123 | public TmfXmlFsm createFsm(Element node, IXmlStateSystemContainer container) { | |
124 | return TmfXmlFsm.create(this, node, container); | |
125 | } | |
126 | ||
127 | /** | |
128 | * @since 2.0 | |
129 | */ | |
130 | @Override | |
131 | public @NonNull TmfXmlState createState(Element node, IXmlStateSystemContainer container, @Nullable TmfXmlState parent) { | |
132 | return TmfXmlState.create(this, node, container, parent); | |
133 | } | |
134 | ||
135 | /** | |
136 | * @since 2.0 | |
137 | */ | |
138 | @Override | |
139 | public TmfXmlStateTransition createStateTransition(Element node, IXmlStateSystemContainer container) { | |
140 | return new TmfXmlStateTransition(this, node, container); | |
141 | } | |
142 | ||
143 | /** | |
144 | * @since 2.0 | |
145 | */ | |
146 | @Override | |
147 | public TmfXmlTimestampCondition createTimestampsCondition(Element node, IXmlStateSystemContainer container) { | |
148 | return new TmfXmlTimestampCondition(this, node, container); | |
149 | } | |
150 | ||
151 | /** | |
152 | * @since 2.0 | |
153 | */ | |
154 | @Override | |
155 | public TmfXmlPatternSegmentBuilder createPatternSegmentBuilder(Element node, IXmlStateSystemContainer container) { | |
156 | return new TmfXmlPatternSegmentBuilder(this, node, container); | |
157 | } | |
1d7e62f9 | 158 | } |