Class JSObject
java.lang.Object
com.amalgamasimulation.desktop.html.js.JSObject
- All Implemented Interfaces:
JSConvertable
The JSObject class represents a JavaScript object that can be converted to a
JSON-like string. It implements the
JSConvertable interface, allowing
it to be used in contexts where JavaScript objects are required.- Author:
- Alexey Glazyrin
-
Field Summary
Fields inherited from interface com.amalgamasimulation.desktop.html.js.JSConvertable
NULL, UNDEFINED -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionRetrieves the value associated with the specified path.booleanisEmpty()put(String path, JSConvertable value) Adds a key-value pair to the JavaScript object.put(String path, JSConvertable value, boolean ifNotExists) Adds a key-value pair to the JavaScript object.toJS()Converts the JavaScript object to a JSON-like string representation.
-
Constructor Details
-
JSObject
public JSObject()
-
-
Method Details
-
put
Adds a key-value pair to the JavaScript object.- Parameters:
path- the path to the key (e.g., "chart.type")value- the value to associate with the keyifNotExists- if true, the value is only added if the key does not already exist- Returns:
- this JSObject instance for method chaining
-
put
Adds a key-value pair to the JavaScript object.- Parameters:
path- the path to the key (e.g., "chart.type")value- the value to associate with the key- Returns:
- this JSObject instance for method chaining
-
getByPath
Retrieves the value associated with the specified path.- Parameters:
path- the path to the key (e.g., "chart.type")- Returns:
- the value associated with the path, or null if the path does not exist
-
isEmpty
public boolean isEmpty() -
toJS
Converts the JavaScript object to a JSON-like string representation.- Specified by:
toJSin interfaceJSConvertable- Returns:
- the JSON-like string representation of the object
-