Class JSUtils
java.lang.Object
com.webmethods.caf.faces.render.util.JSUtils
Helper functions for rendering JavaScript.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Extensible class for serializing objects to json. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Pattern
Regex which matches legal javascript identifiers.Current and future javascript reserved words.static SimpleDateFormat
Formats a date to conform to rfc3339 (like "2000-07-04T07:00:00.000Z").protected static JSUtils.JSONSerializer
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
Creates an ascii javascript identifier out of the specifed string.static String
identifier
(String s) Creates a javascript identifier out of the specifed string.static boolean
jsonProperties
(Appendable b, Map<String, Object> properties, Collection<String> skip, Map<String, String> remap) Creates list of json property name:value pairs.static String
jsonProperties
(Map<String, Object> properties, Collection<String> skip, Map<String, String> remap) Creates list of json property name:value pairs.static void
jsonProperty
(Appendable b, String name, Object value) Creates a json property name:value pair.static String
jsonProperty
(String name, Object value) Creates a json property name:value pair.static void
jsonPropertyName
(Appendable b, Object o) Writes the specified json property name (ie "foo:" or "'foo bar':").static String
Escapes string for printing as a javascript string.
-
Field Details
-
JS_IDENTIFIER
Regex which matches legal javascript identifiers. -
RFC3339_DATE_FORMAT
Formats a date to conform to rfc3339 (like "2000-07-04T07:00:00.000Z"). -
JS_RESERVED
Current and future javascript reserved words. -
s_jsonSerializer
-
-
Constructor Details
-
JSUtils
public JSUtils()
-
-
Method Details
-
quote
Escapes string for printing as a javascript string.- Returns:
- Escaped string. Never null.
-
identifier
Creates a javascript identifier out of the specifed string. Beginning with JavaScript 1.5 (mozilla 1.0, ie 5.0), unicode letters can be used as identifiers.- Returns:
- Legal javascript identifier. Never null.
-
asciiIdentifier
Creates an ascii javascript identifier out of the specifed string.- Returns:
- Legal javascript identifier, containing only alphanumeric ascii chars. Never null.
-
jsonProperty
Creates a json property name:value pair. For example, name="foo", value="bar" returns "foo:'bar'"; name="foot baal", value=12 returns "'foot baal':12". -
jsonProperty
Creates a json property name:value pair. For example, name="foo", value="bar" returns "foo:'bar'"; name="foot baal", value=12 returns "'foot baal':12".- Throws:
IOException
-
jsonPropertyName
Writes the specified json property name (ie "foo:" or "'foo bar':").- Throws:
IOException
-
jsonProperties
public static String jsonProperties(Map<String, Object> properties, Collection<String> skip, Map<String, String> remap) Creates list of json property name:value pairs.- Parameters:
properties
- Properties to output to json.skip
- Property names to skip. May be null.remap
- Property names to remap. May be null.
-
jsonProperties
public static boolean jsonProperties(Appendable b, Map<String, Object> properties, Collection<String> skip, Map<String, throws IOExceptionString> remap) Creates list of json property name:value pairs.- Parameters:
properties
- Properties to output to json.skip
- Property names to skip. May be null.remap
- Property names to remap. May be null.- Throws:
IOException
-