Debian Codegraph @

src/com/google/debugging/sourcemap/SourceMapSection.java

raw symbols SCIP
1 /*
2 * Copyright 2011 The Closure Compiler Authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package com.google.debugging.sourcemap;
18
19 /**
20 * A class representing a partial source map.
21 * @author [email protected] (John Lenz)
22 */
23 public class SourceMapSection {
24
25 /**
26 * A URL for a valid source map file that represents a section of a generate
27 * source file such as when multiple files are concatenated together.
28 */
29 private final String value;
30 private final int line;
31 private final int column;
32 private final SectionType type;
33
34 public static enum SectionType {
35 URL,
36 MAP
37 }
38
39 /**
40 * @param sectionUrl The URL for the partial source map
41 * @param line The number of lines into the file where the represented section
42 * starts.
43 * @param column The number of characters into the line where the represented
44 * section starts.
45 * @deprecated
46 */
47 @Deprecated
48 public SourceMapSection(String sectionUrl, int line, int column) {
49 this.type = SectionType.URL;
50 this.value = sectionUrl;
51 this.line = line;
52 this.column = column;
53 }
54
55 private SourceMapSection(
56 SectionType type, String value, int line, int column) {
57 this.type = type;
58 this.value = value;
59 this.line = line;
60 this.column = column;
61 }
62
63 public static SourceMapSection forMap(String value, int line, int column) {
64 return new SourceMapSection(SectionType.MAP, value, line, column);
65 }
66
67 public static SourceMapSection forURL(String value, int line, int column) {
68 return new SourceMapSection(SectionType.URL, value, line, column);
69 }
70
71 public SectionType getSectionType() {
72 return this.type;
73 }
74
75 /**
76 * @return the name of the map
77 * @deprecated
78 */
79 @Deprecated
80 public String getSectionUrl() {
81 assert(type.equals(SectionType.URL));
82 return value;
83 }
84
85 /**
86 * @return the value that represents the map for this section.
87 */
88 public String getSectionValue() {
89 return value;
90 }
91
92 /**
93 * @return the starting line for this section
94 */
95 public int getLine() {
96 return line;
97 }
98
99 /**
100 * @return the column for this section
101 */
102 public int getColumn() {
103 return column;
104 }
105 }