1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package org.modeshape.graph.sequencer;
25
26 import java.util.Collections;
27 import java.util.HashMap;
28 import java.util.HashSet;
29 import java.util.Map;
30 import java.util.Set;
31 import net.jcip.annotations.ThreadSafe;
32 import org.modeshape.common.collection.Problems;
33 import org.modeshape.common.collection.SimpleProblems;
34 import org.modeshape.common.component.ClassLoaderFactory;
35 import org.modeshape.graph.ExecutionContext;
36 import org.modeshape.graph.SecurityContext;
37 import org.modeshape.graph.mimetype.MimeTypeDetector;
38 import org.modeshape.graph.property.Name;
39 import org.modeshape.graph.property.NamespaceRegistry;
40 import org.modeshape.graph.property.Path;
41 import org.modeshape.graph.property.Property;
42
43
44
45
46 @ThreadSafe
47 public class StreamSequencerContext extends ExecutionContext {
48
49 private final Path inputPath;
50 private final Map<Name, Property> inputPropertiesByName;
51 private final Set<Property> inputProperties;
52 private final Problems problems;
53 private final String mimeType;
54
55 public StreamSequencerContext( ExecutionContext context,
56 Path inputPath,
57 Set<Property> inputProperties,
58 String mimeType,
59 Problems problems ) {
60 super(context);
61 this.inputPath = inputPath;
62 this.inputProperties = inputProperties != null ? new HashSet<Property>(inputProperties) : new HashSet<Property>();
63 this.mimeType = mimeType;
64 this.problems = problems != null ? problems : new SimpleProblems();
65 Map<Name, Property> inputPropertiesByName = new HashMap<Name, Property>();
66 for (Property property : this.inputProperties) {
67 inputPropertiesByName.put(property.getName(), property);
68 }
69 this.inputPropertiesByName = Collections.unmodifiableMap(inputPropertiesByName);
70 }
71
72
73
74
75
76
77 public Path getInputPath() {
78 return inputPath;
79 }
80
81
82
83
84
85
86 public Set<Property> getInputProperties() {
87 return inputProperties;
88 }
89
90
91
92
93
94
95
96 public Property getInputProperty( Name name ) {
97 return inputPropertiesByName.get(name);
98 }
99
100
101
102
103
104
105 public String getMimeType() {
106 return this.mimeType;
107 }
108
109
110
111
112
113
114
115 public Problems getProblems() {
116 return this.problems;
117 }
118
119
120
121
122
123
124 @Override
125 public StreamSequencerContext with( ClassLoaderFactory classLoaderFactory ) {
126 return new StreamSequencerContext(super.with(classLoaderFactory), inputPath, inputProperties, mimeType, problems);
127 }
128
129
130
131
132
133
134 @Override
135 public StreamSequencerContext with( Map<String, String> data ) {
136 return new StreamSequencerContext(super.with(data), inputPath, inputProperties, mimeType, problems);
137 }
138
139
140
141
142
143
144 @Override
145 public StreamSequencerContext with( MimeTypeDetector mimeTypeDetector ) {
146 return new StreamSequencerContext(super.with(mimeTypeDetector), inputPath, inputProperties, mimeType, problems);
147 }
148
149
150
151
152
153
154 @Override
155 public StreamSequencerContext with( NamespaceRegistry namespaceRegistry ) {
156 return new StreamSequencerContext(super.with(namespaceRegistry), inputPath, inputProperties, mimeType, problems);
157 }
158
159
160
161
162
163
164 @Override
165 public StreamSequencerContext with( SecurityContext securityContext ) {
166 return new StreamSequencerContext(super.with(securityContext), inputPath, inputProperties, mimeType, problems);
167 }
168
169
170
171
172
173
174 @Override
175 public StreamSequencerContext with( String key,
176 String value ) {
177 return new StreamSequencerContext(super.with(key, value), inputPath, inputProperties, mimeType, problems);
178 }
179
180
181
182
183
184
185 @Override
186 public StreamSequencerContext with( String processId ) {
187 return new StreamSequencerContext(super.with(processId), inputPath, inputProperties, mimeType, problems);
188 }
189 }