001package gudusoft.gsqlparser.dlineage.comment;
002
003import java.util.ArrayList;
004import java.util.Collections;
005import java.util.List;
006import javax.xml.bind.annotation.*;
007
008/**
009 * Versioned, scalar-only snapshot of SQL comment occurrences and their owners.
010 * Offsets are zero-based UTF-16 half-open ranges; lines and columns are one-based.
011 * IDs are local to the containing dataflow document. Instances have no mutable public API.
012 */
013@XmlAccessorType(XmlAccessType.FIELD)
014public final class CommentBindingBundle {
015    @XmlAttribute
016    private int version = 1;
017    @XmlAttribute
018    private String bindingRulesVersion = "1";
019    @XmlAttribute
020    String state = "complete";
021    @XmlElementWrapper(name="supportedHostKinds") @XmlElement(name="kind")
022    List<String> supportedHostKinds = new ArrayList<String>();
023    @XmlElementWrapper(name="sourceUnits") @XmlElement(name="sourceUnit")
024    List<SourceUnit> sourceUnits = new ArrayList<SourceUnit>();
025    @XmlElementWrapper(name="comments") @XmlElement(name="comment")
026    List<Comment> comments = new ArrayList<Comment>();
027    @XmlElementWrapper(name="hosts") @XmlElement(name="host")
028    List<Host> hosts = new ArrayList<Host>();
029    @XmlElementWrapper(name="bindings") @XmlElement(name="binding")
030    List<Binding> bindings = new ArrayList<Binding>();
031    @XmlElementWrapper(name="coverage") @XmlElement(name="entry")
032    List<Coverage> coverage = new ArrayList<Coverage>();
033    @XmlElementWrapper(name="diagnostics") @XmlElement(name="diagnostic")
034    List<Diagnostic> diagnostics = new ArrayList<Diagnostic>();
035    Limits limits;
036    public CommentBindingBundle() {}
037    public int getVersion() { return version; }
038    public String getBindingRulesVersion() { return bindingRulesVersion; }
039    public String getState() { return state; }
040    public List<String> getSupportedHostKinds() { return Collections.unmodifiableList(supportedHostKinds); }
041    public List<SourceUnit> getSourceUnits() { return Collections.unmodifiableList(sourceUnits); }
042    public List<Comment> getComments() { return Collections.unmodifiableList(comments); }
043    public List<Host> getHosts() { return Collections.unmodifiableList(hosts); }
044    public List<Binding> getBindings() { return Collections.unmodifiableList(bindings); }
045    public List<Coverage> getCoverage() { return Collections.unmodifiableList(coverage); }
046    public List<Diagnostic> getDiagnostics() { return Collections.unmodifiableList(diagnostics); }
047    public Limits getLimits() { return limits; }
048
049    @XmlAccessorType(XmlAccessType.FIELD)
050    public static final class SourceUnit {
051        @XmlAttribute
052        String id;
053        @XmlAttribute
054        int inputOrdinal;
055        @XmlAttribute
056        String vendor;
057        @XmlAttribute
058        String contentDigest;
059        @XmlAttribute
060        String originKind;
061        @XmlAttribute
062        String fileName;
063        public SourceUnit() {}
064        SourceUnit(String id, int inputOrdinal, String vendor, String contentDigest, String originKind, String fileName) {
065            this.id = id;
066            this.inputOrdinal = inputOrdinal;
067            this.vendor = vendor;
068            this.contentDigest = contentDigest;
069            this.originKind = originKind;
070            this.fileName = fileName;
071        }
072        public String getId() { return id; }
073        public int getInputOrdinal() { return inputOrdinal; }
074        public String getVendor() { return vendor; }
075        public String getContentDigest() { return contentDigest; }
076        public String getOriginKind() { return originKind; }
077        public String getFileName() { return fileName; }
078    }
079
080    @XmlAccessorType(XmlAccessType.FIELD)
081    public static final class Range {
082        @XmlAttribute
083        int startOffset;
084        @XmlAttribute
085        int endOffset;
086        @XmlAttribute
087        int startLine;
088        @XmlAttribute
089        int startColumn;
090        @XmlAttribute
091        int endLine;
092        @XmlAttribute
093        int endColumn;
094        public Range() {}
095        Range(int start, int end, int startLine, int startColumn, int endLine, int endColumn) {
096            this.startOffset = start;
097            this.endOffset = end;
098            this.startLine = startLine;
099            this.startColumn = startColumn;
100            this.endLine = endLine;
101            this.endColumn = endColumn;
102        }
103        public int getStartOffset() { return startOffset; }
104        public int getEndOffset() { return endOffset; }
105        public int getStartLine() { return startLine; }
106        public int getStartColumn() { return startColumn; }
107        public int getEndLine() { return endLine; }
108        public int getEndColumn() { return endColumn; }
109    }
110
111    @XmlAccessorType(XmlAccessType.FIELD)
112    public static final class Comment {
113        @XmlAttribute
114        String id;
115        @XmlAttribute
116        String sourceUnitId;
117        Range range;
118        @XmlAttribute
119        String lexicalKind;
120        String raw;
121        @XmlAttribute
122        String rawEncoding;
123        @XmlAttribute
124        int originalLength;
125        @XmlAttribute
126        boolean rawTruncated;
127        public Comment() {}
128        Comment(String id, String sourceUnitId, Range range, String lexicalKind, String raw, String rawEncoding, int originalLength, boolean rawTruncated) {
129            this.id = id;
130            this.sourceUnitId = sourceUnitId;
131            this.range = range;
132            this.lexicalKind = lexicalKind;
133            this.raw = raw;
134            this.rawEncoding = rawEncoding;
135            this.originalLength = originalLength;
136            this.rawTruncated = rawTruncated;
137        }
138        public String getId() { return id; }
139        public String getSourceUnitId() { return sourceUnitId; }
140        public Range getRange() { return range; }
141        public String getLexicalKind() { return lexicalKind; }
142        public String getRaw() { return raw; }
143        public String getRawEncoding() { return rawEncoding; }
144        public int getOriginalLength() { return originalLength; }
145        public boolean isRawTruncated() { return rawTruncated; }
146    }
147
148    @XmlAccessorType(XmlAccessType.FIELD)
149    public static final class Target {
150        @XmlAttribute
151        String space;
152        @XmlAttribute
153        String id;
154        @XmlAttribute
155        String parentId;
156        public Target() {}
157        Target(String space, String id, String parentId) {
158            this.space = space;
159            this.id = id;
160            this.parentId = parentId;
161        }
162        public String getSpace() { return space; }
163        public String getId() { return id; }
164        public String getParentId() { return parentId; }
165    }
166
167    @XmlAccessorType(XmlAccessType.FIELD)
168    public static final class Host {
169        @XmlAttribute
170        String id;
171        @XmlAttribute
172        String sourceUnitId;
173        @XmlAttribute
174        String kind;
175        @XmlAttribute
176        String syntaxKind;
177        Range range;
178        Range nameRange;
179        @XmlAttribute
180        String queryBlockId;
181        @XmlAttribute
182        String parentHostId;
183        @XmlAttribute
184        int ordinal;
185        @XmlAttribute
186        String bindingState;
187        @XmlElementWrapper(name="targets") @XmlElement(name="target")
188        List<Target> targets = new ArrayList<Target>();
189        @XmlAttribute
190        String processId;
191        @XmlAttribute
192        String procedureId;
193        public Host() {}
194        Host(String id, String sourceUnitId, String kind, String syntaxKind, Range range, Range nameRange, String queryBlockId, String parentHostId, int ordinal, String bindingState, List<Target> targets, String processId, String procedureId) {
195            this.id = id;
196            this.sourceUnitId = sourceUnitId;
197            this.kind = kind;
198            this.syntaxKind = syntaxKind;
199            this.range = range;
200            this.nameRange = nameRange;
201            this.queryBlockId = queryBlockId;
202            this.parentHostId = parentHostId;
203            this.ordinal = ordinal;
204            this.bindingState = bindingState;
205            this.targets = new ArrayList<Target>(targets);
206            this.processId = processId;
207            this.procedureId = procedureId;
208        }
209        public String getId() { return id; }
210        public String getSourceUnitId() { return sourceUnitId; }
211        public String getKind() { return kind; }
212        public String getSyntaxKind() { return syntaxKind; }
213        public Range getRange() { return range; }
214        public Range getNameRange() { return nameRange; }
215        public String getQueryBlockId() { return queryBlockId; }
216        public String getParentHostId() { return parentHostId; }
217        public int getOrdinal() { return ordinal; }
218        public String getBindingState() { return bindingState; }
219        public List<Target> getTargets() { return Collections.unmodifiableList(targets); }
220        public String getProcessId() { return processId; }
221        public String getProcedureId() { return procedureId; }
222    }
223
224    @XmlAccessorType(XmlAccessType.FIELD)
225    public static final class Binding {
226        @XmlAttribute
227        String commentId;
228        @XmlAttribute
229        String hostId;
230        @XmlAttribute
231        String placement;
232        @XmlAttribute
233        String ruleId;
234        public Binding() {}
235        Binding(String commentId, String hostId, String placement, String ruleId) {
236            this.commentId = commentId;
237            this.hostId = hostId;
238            this.placement = placement;
239            this.ruleId = ruleId;
240        }
241        public String getCommentId() { return commentId; }
242        public String getHostId() { return hostId; }
243        public String getPlacement() { return placement; }
244        public String getRuleId() { return ruleId; }
245    }
246
247    @XmlAccessorType(XmlAccessType.FIELD)
248    public static final class Coverage {
249        @XmlAttribute
250        String sourceUnitId;
251        @XmlAttribute
252        String hostKind;
253        @XmlAttribute
254        String state;
255        public Coverage() {}
256        Coverage(String sourceUnitId, String hostKind, String state) {
257            this.sourceUnitId = sourceUnitId;
258            this.hostKind = hostKind;
259            this.state = state;
260        }
261        public String getSourceUnitId() { return sourceUnitId; }
262        public String getHostKind() { return hostKind; }
263        public String getState() { return state; }
264    }
265
266    @XmlAccessorType(XmlAccessType.FIELD)
267    public static final class Diagnostic {
268        @XmlAttribute
269        String code;
270        @XmlAttribute
271        String sourceUnitId;
272        @XmlAttribute
273        String commentId;
274        @XmlAttribute
275        String hostId;
276        public Diagnostic() {}
277        Diagnostic(String code, String sourceUnitId, String commentId, String hostId) {
278            this.code = code;
279            this.sourceUnitId = sourceUnitId;
280            this.commentId = commentId;
281            this.hostId = hostId;
282        }
283        public String getCode() { return code; }
284        public String getSourceUnitId() { return sourceUnitId; }
285        public String getCommentId() { return commentId; }
286        public String getHostId() { return hostId; }
287    }
288
289    @XmlAccessorType(XmlAccessType.FIELD)
290    public static final class Limits {
291        @XmlAttribute
292        int maxRawLength;
293        @XmlAttribute
294        int maxCommentsPerSourceUnit;
295        @XmlAttribute
296        int maxTotalRawLength;
297        public Limits() {}
298        Limits(int maxRawLength, int maxCommentsPerSourceUnit, int maxTotalRawLength) {
299            this.maxRawLength = maxRawLength;
300            this.maxCommentsPerSourceUnit = maxCommentsPerSourceUnit;
301            this.maxTotalRawLength = maxTotalRawLength;
302        }
303        public int getMaxRawLength() { return maxRawLength; }
304        public int getMaxCommentsPerSourceUnit() { return maxCommentsPerSourceUnit; }
305        public int getMaxTotalRawLength() { return maxTotalRawLength; }
306    }
307}