1 package net.sourceforge.jenesis4java; 2 3 /* 4 * #%L 5 * Jenesis 4 Java Code Generator 6 * %% 7 * Copyright (C) 2000 - 2015 jenesis4java 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 * #L% 23 */ 24 25 /** 26 * Copyright (C) 2008, 2010 Richard van Nieuwenhoven - ritchie [at] gmx [dot] at 27 * Copyright (C) 2000, 2001 Paul Cody Johnston - pcj@inxar.org <br> 28 * This file is part of Jenesis4java. Jenesis4java is free software: you can 29 * redistribute it and/or modify it under the terms of the GNU Lesser General 30 * Public License as published by the Free Software Foundation, either version 3 31 * of the License, or (at your option) any later version.<br> 32 * Jenesis4java is distributed in the hope that it will be useful, but WITHOUT 33 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 34 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 35 * details.<br> 36 * You should have received a copy of the GNU Lesser General Public License 37 * along with Jenesis4java. If not, see <http://www.gnu.org/licenses/>. 38 */ 39 /** 40 * {@code Expression} subinterface for freeform expressions. The freeform 41 * expression is a very general container expression for (hopefully) exceptional 42 * instances in which it the api is too difficult or cumbersome and one needs to 43 * inject a source code directly. This structure simply copies the text given in 44 * setCode. No semicolon is appended. 45 */ 46 public interface Freeform extends Expression { 47 48 /** 49 * Decrements the tab and calls newLine() 50 */ 51 Freeform dedentLine(); 52 53 /** 54 * Gets the code for this expression. 55 */ 56 String getCode(); 57 58 /** 59 * Returns the current number of indentation levels. 60 */ 61 int getIndentNumber(); 62 63 /** 64 * Increments the tab and calls newLine() 65 */ 66 Freeform indentLine(); 67 68 /** 69 * Returns true if no characters have been written since the last call of 70 * newLine(). 71 */ 72 boolean isLineNew(); 73 74 /** 75 * Adds a the newLine string according to 76 * <CODE>System.getProperty("line.separator")</CODE> and the line is padded 77 * with the n tab characters where n is the number returned by 78 * {@code getIndentNumber()}. 79 */ 80 Freeform newLine(); 81 82 /** 83 * Resets the tab counter to zero and calls the newLine() method. 84 */ 85 Freeform resetLine(); 86 87 /** 88 * Sets the code for this expression. 89 */ 90 Freeform setCode(String code); 91 92 /** 93 * Writes a single space. 94 */ 95 Freeform space(); 96 97 /** 98 * Writes a boolean. 99 */ 100 Freeform write(boolean b); 101 102 /** 103 * Writes a single character. 104 */ 105 Freeform write(char c); 106 107 /** 108 * Writes an array of characters. 109 */ 110 Freeform write(char[] chars); 111 112 /** 113 * Writes a double. 114 */ 115 Freeform write(double d); 116 117 /** 118 * Writes a float. 119 */ 120 Freeform write(float f); 121 122 /** 123 * Writes an integer. 124 */ 125 Freeform write(int i); 126 127 /** 128 * Writes an object. 129 */ 130 Freeform write(Object o); 131 132 /** 133 * Writes each element of the given object array. 134 */ 135 Freeform write(Object[] ao); 136 137 /** 138 * Writes a string. 139 */ 140 Freeform write(String s); 141 }