Debian Codegraph @

rhino/src/org/mozilla/javascript/ast/RegExpLiteral.java

raw symbols SCIP
1 /* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7 package org.mozilla.javascript.ast;
8
9 import org.mozilla.javascript.Token;
10
11 /**
12 * AST node for a RegExp literal.
13 * Node type is {@link Token#REGEXP}.<p>
14 */
15 public class RegExpLiteral extends AstNode {
16
17 private String value;
18 private String flags;
19
20 {
21 type = Token.REGEXP;
22 }
23
24 public RegExpLiteral() {
25 }
26
27 public RegExpLiteral(int pos) {
28 super(pos);
29 }
30
31 public RegExpLiteral(int pos, int len) {
32 super(pos, len);
33 }
34
35 /**
36 * Returns the regexp string without delimiters
37 */
38 public String getValue() {
39 return value;
40 }
41
42 /**
43 * Sets the regexp string without delimiters
44 * @throws IllegalArgumentException} if value is {@code null}
45 */
46 public void setValue(String value) {
47 assertNotNull(value);
48 this.value = value;
49 }
50
51 /**
52 * Returns regexp flags, {@code null} or "" if no flags specified
53 */
54 public String getFlags() {
55 return flags;
56 }
57
58 /**
59 * Sets regexp flags. Can be {@code null} or "".
60 */
61 public void setFlags(String flags) {
62 this.flags = flags;
63 }
64
65 @Override
66 public String toSource(int depth) {
67 return makeIndent(depth) + "/" + value + "/"
68 + (flags == null ? "" : flags);
69 }
70
71 /**
72 * Visits this node. There are no children to visit.
73 */
74 @Override
75 public void visit(NodeVisitor v) {
76 v.visit(this);
77 }
78 }