| java.lang.Object xtc.util.Utilities
Utilities | final public class Utilities (Code) | | Implmentation of utilities for language processors, focusing on
handling of I/O.
author: Robert Grimm version: $Revision: 1.1 $ |
Field Summary | |
final public static int | C_ESCAPES The escape flags for C/C++ escapes. | final public static int | ESCAPE_DOUBLE Flag for using doubled escape sequences. | final public static int | ESCAPE_REGEX Flag for escaping the '[ ', '- ', and
'] ' characters. | final public static int | ESCAPE_UNICODE Flag for escaping non-printable ASCII characters using Unicode
escapes. | final public static int | FULL_ESCAPES The escape flags for Java and regex escapes. | final public static int | JAVA_ESCAPES The escape flags for Java escapes. | final public static Pattern | SPLIT The regular expression pattern used to split source code along
newlines. |
Method Summary | |
public static void | escape(char c, StringBuffer buf, int flags) Escape the specified character into the specified string buffer. | public static void | escape(String s, StringBuffer buf, int flags) Escape the specified string into the specified string buffer. | public static String | escape(char c, int flags) Escape the specified character.
Parameters: c - The character. Parameters: flags - The escape flags. | public static String | escape(String s, int flags) Escape the specified string.
Parameters: s - The string. Parameters: flags - The escape flags. | public static String | format(List l) Convert the specified list to a human-readable representation.
This method uses toString() for each element in the
specified list to generate a human-readable representation.
Parameters: l - The list. | public static void | msg(String msg, Location loc, String[] source) Print the specified (error or warning) message to the error
console. | public static void | msg(String msg, Location loc, String context, String[] source) Print the specified (error or warning) message to the error
console. | public static void | pump(Reader in, Writer out) Pump all data from the specified reader to the specified writer. | public static String | toDescription(String id) Convert the specified identifier into a human-readable
description. | public static String | unescape(String s) Unescape the specified string. | public static boolean | useDoubleEscapes(int flags) Determine whether the double escapes flag is set.
See Also: Utilities.ESCAPE_DOUBLE Parameters: flags - The escape flags. | public static boolean | useRegexEscapes(int flags) Determine whether the regex escapes flag is set.
See Also: Utilities.ESCAPE_REGEX Parameters: flags - The escape flags. | public static boolean | useUnicodeEscapes(int flags) Determine whether the Unicode escapes flag is set.
See Also: Utilities.ESCAPE_UNICODE Parameters: flags - The escape flags. |
C_ESCAPES | final public static int C_ESCAPES(Code) | | The escape flags for C/C++ escapes.
|
ESCAPE_DOUBLE | final public static int ESCAPE_DOUBLE(Code) | | Flag for using doubled escape sequences. Doubled escape
sequences will still read as an escape sequence, even if they are
included in a program source character or string.
|
ESCAPE_REGEX | final public static int ESCAPE_REGEX(Code) | | Flag for escaping the '[ ', '- ', and
'] ' characters.
|
ESCAPE_UNICODE | final public static int ESCAPE_UNICODE(Code) | | Flag for escaping non-printable ASCII characters using Unicode
escapes.
|
FULL_ESCAPES | final public static int FULL_ESCAPES(Code) | | The escape flags for Java and regex escapes.
|
JAVA_ESCAPES | final public static int JAVA_ESCAPES(Code) | | The escape flags for Java escapes.
|
SPLIT | final public static Pattern SPLIT(Code) | | The regular expression pattern used to split source code along
newlines.
|
escape | public static void escape(char c, StringBuffer buf, int flags)(Code) | | Escape the specified character into the specified string buffer.
Parameters: c - The character. Parameters: buf - The string buffer. Parameters: flags - The escape flags. |
escape | public static void escape(String s, StringBuffer buf, int flags)(Code) | | Escape the specified string into the specified string buffer.
Parameters: s - The string. Parameters: buf - The string buffer. Parameters: flags - The escape flags. |
escape | public static String escape(char c, int flags)(Code) | | Escape the specified character.
Parameters: c - The character. Parameters: flags - The escape flags. The escape character as a string. |
escape | public static String escape(String s, int flags)(Code) | | Escape the specified string.
Parameters: s - The string. Parameters: flags - The escape flags. The escaped string. |
format | public static String format(List l)(Code) | | Convert the specified list to a human-readable representation.
This method uses toString() for each element in the
specified list to generate a human-readable representation.
Parameters: l - The list. The human-readable representation. |
msg | public static void msg(String msg, Location loc, String[] source)(Code) | | Print the specified (error or warning) message to the error
console. The message is prefixed with the specified location
information and followed by the corresponding source line, with a
caret ('^ ') indicating the column.
See Also: Utilities.msg(String,Location,String,String[]) Parameters: msg - The message. Parameters: loc - The source location. Parameters: source - The source file, one line per array entry. |
msg | public static void msg(String msg, Location loc, String context, String[] source)(Code) | | Print the specified (error or warning) message to the error
console. If the specified location is non-null, the message is
prefixed with the location information. Otherwise, if the
specified context is non-null, the message is prefixed with the
context. If both the specified location and source are non-null,
the message is followed by the corresponding source line and a
caret ('^ ') to indicate the column.
Parameters: msg - The message. Parameters: loc - The source location. Parameters: context - The alternative context. Parameters: source - The source file, one line per array entry. |
pump | public static void pump(Reader in, Writer out) throws IOException(Code) | | Pump all data from the specified reader to the specified writer.
Parameters: in - The reader. Parameters: out - The writer. throws: IOException - Signals an exceptinal condition during I/O. |
toDescription | public static String toDescription(String id)(Code) | | Convert the specified identifier into a human-readable
description. This method breaks identifiers using an upper case
character for each word component into a string of space
separated lower case words.
Parameters: id - The identifier. The corresponding description. |
unescape | public static String unescape(String s)(Code) | | Unescape the specified string. This method unescapes standard
C-style escapes ('\b ', '\t ',
'\n ', '\f ', '\r ',
'\" ', '\' ', and '\\ ') as
well as Java Unicode escapes. To support regex-like character
classes, it also unescapes '\- ', '\[ ',
and '\] '.
Parameters: s - The string to unescape. The unescaped string. |
useDoubleEscapes | public static boolean useDoubleEscapes(int flags)(Code) | | Determine whether the double escapes flag is set.
See Also: Utilities.ESCAPE_DOUBLE Parameters: flags - The escape flags. true if the double escapes flag is set. |
useRegexEscapes | public static boolean useRegexEscapes(int flags)(Code) | | Determine whether the regex escapes flag is set.
See Also: Utilities.ESCAPE_REGEX Parameters: flags - The escape flags. true if the regex escape flag is set. |
useUnicodeEscapes | public static boolean useUnicodeEscapes(int flags)(Code) | | Determine whether the Unicode escapes flag is set.
See Also: Utilities.ESCAPE_UNICODE Parameters: flags - The escape flags. true if the Unicode escapes flag is set. |
|
|