View Javadoc
1   package org.metricshub.jawk.jrt;
2   
3   /*-
4    * ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲
5    * Jawk
6    * ჻჻჻჻჻჻
7    * Copyright (C) 2006 - 2025 MetricsHub
8    * ჻჻჻჻჻჻
9    * This program is free software: you can redistribute it and/or modify
10   * it under the terms of the GNU Lesser General Public License as
11   * published by the Free Software Foundation, either version 3 of the
12   * License, or (at your option) any later version.
13   *
14   * This program is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17   * GNU General Lesser Public License for more details.
18   *
19   * You should have received a copy of the GNU General Lesser Public
20   * License along with this program.  If not, see
21   * <http://www.gnu.org/licenses/lgpl-3.0.html>.
22   * ╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱
23   */
24  
25  /**
26   * The AWK Variable Manager.
27   * It provides getter/setter methods for global AWK variables.
28   * Its purpose is to expose a variable management interface to
29   * the JRT, even though the implementation is provided by
30   * the AWK script at script compile-time.
31   * <p>
32   * The getters/setters here do not access <strong>all</strong>
33   * special AWK variables, such as <code>RSTART</code>
34   * and <code>ENVIRON</code>. That's because these variables
35   * are not referred to within the JRT.
36   *
37   * @see JRT
38   * @author Danny Daglas
39   */
40  public interface VariableManager {
41  	/**
42  	 * <p>
43  	 * getARGC.
44  	 * </p>
45  	 *
46  	 * @return the contents of the ARGC variable.
47  	 */
48  	Object getARGC();
49  
50  	/**
51  	 * <p>
52  	 * getARGV.
53  	 * </p>
54  	 *
55  	 * @return the contents of the ARGV variable.
56  	 */
57  	Object getARGV();
58  
59  	/**
60  	 * <p>
61  	 * getCONVFMT.
62  	 * </p>
63  	 *
64  	 * @return the contents of the CONVFMT variable.
65  	 */
66  	Object getCONVFMT();
67  
68  	/**
69  	 * <p>
70  	 * getFS.
71  	 * </p>
72  	 *
73  	 * @return the contents of the FS variable.
74  	 */
75  	Object getFS();
76  
77  	/**
78  	 * <p>
79  	 * getRS.
80  	 * </p>
81  	 *
82  	 * @return the contents of the RS variable.
83  	 */
84  	Object getRS();
85  
86  	/**
87  	 * <p>
88  	 * getOFS.
89  	 * </p>
90  	 *
91  	 * @return the contents of the OFS variable.
92  	 */
93  	Object getOFS();
94  
95  	/**
96  	 * <p>
97  	 * getORS.
98  	 * </p>
99  	 *
100 	 * @return the contents of the ORS variable.
101 	 */
102 	Object getORS();
103 
104 	/**
105 	 * <p>
106 	 * getSUBSEP.
107 	 * </p>
108 	 *
109 	 * @return the contents of the SUBSEP variable.
110 	 */
111 	Object getSUBSEP();
112 
113 	/**
114 	 * Set the contents of the FILENAME variable.
115 	 *
116 	 * @param fileName File name
117 	 */
118 	void setFILENAME(String fileName);
119 
120 	/**
121 	 * Set the contents of the NF variable.
122 	 *
123 	 * @param newNf Value for NF
124 	 */
125 	void setNF(Integer newNf);
126 
127 	/**
128 	 * Increases the NR variable by 1.
129 	 */
130 	void incNR();
131 
132 	/**
133 	 * Increases the FNR variable by 1.
134 	 */
135 	void incFNR();
136 
137 	/**
138 	 * Resets the FNR variable to 0.
139 	 */
140 	void resetFNR();
141 
142 	/**
143 	 * Set the contents of a user-defined AWK
144 	 * variable. Used when processing
145 	 * <em>name=value</em> command-line arguments
146 	 * (either via -v or via ARGV).
147 	 *
148 	 * @param name The AWK variable name.
149 	 * @param value The new contents of the variable.
150 	 */
151 	void assignVariable(String name, Object value);
152 }