public class JavaScript.PtolemyJavaScript
extends org.mozilla.javascript.ScriptableObject
Constructor and Description |
---|
PtolemyJavaScript() |
Modifier and Type | Method and Description |
---|---|
void |
alert(java.lang.String message)
Alert the user with a message.
|
void |
clearTimeout(java.lang.Integer handle)
Clear the timeout with the specified handle, if it has not already executed.
|
void |
error(java.lang.String message)
Throw an IllegalActionException with the specified message.
|
java.lang.Object |
get(org.mozilla.javascript.NativeJavaObject portWrapper,
java.lang.Double channel)
Get buffered inputs for a given input port.
|
java.lang.String |
getClassName() |
java.lang.String |
httpRequest(java.lang.String url,
java.lang.String method,
org.mozilla.javascript.NativeObject properties,
java.lang.String body,
java.lang.Integer timeout)
Make the specified HTTP request.
|
java.lang.String |
localHostAddress()
Return the local host IP address as a string.
|
java.lang.String |
openBrowser(java.lang.String url)
Open a new tab in the default system browser.
|
void |
print(java.lang.String message)
Print a message to standard out.
|
java.lang.String |
readProtectedURL(java.lang.String url,
java.lang.String accessToken)
Open a URL of web service that is protected by OAuth 2.0.
|
java.lang.String |
readURL(java.lang.String url)
Read the specified URL and return its contents.
|
java.lang.String |
requestAccess(java.lang.String providerName,
java.lang.String clientId,
java.lang.String clientSecret,
java.lang.String redirectUrl,
java.lang.String authCode)
Uses an Authorization code to retrieve an Access code.
|
java.lang.String |
requestAuth(java.lang.String providerName,
java.lang.String clientId,
java.lang.String redirectUrl,
java.lang.Boolean openBrowser)
Request an OAuth 2.0 authorization token.
|
void |
send(java.lang.Object data,
org.mozilla.javascript.NativeJavaObject portWrapper,
java.lang.Double channel)
Send outputs via an output port.
|
java.lang.Integer |
setTimeout(org.mozilla.javascript.Function function,
java.lang.Integer time)
After the specified amount of time (in milliseconds), invoke the specified function.
|
void |
socketX(java.lang.String url,
org.mozilla.javascript.NativeObject query,
org.mozilla.javascript.NativeJavaObject portWrapper)
Deprecated.
Pending a better design.
|
java.lang.Object |
valueOf(org.mozilla.javascript.NativeJavaObject paramWrapper)
Get parameter values.
|
applyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkPropertyChange, checkPropertyDefinition, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, equivalentValues, get, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getDefaultValue, getFunctionPrototype, getGetterOrSetter, getIds, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getPropertyIds, getPrototype, getSlot, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, has, has, hasInstance, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, preventExtensions, put, put, putConst, putConstProperty, putProperty, putProperty, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setGetterOrSetter, setParentScope, setPrototype, size
public void alert(java.lang.String message)
message
- The messagepublic void clearTimeout(java.lang.Integer handle)
handle
- The timeout handle.setTimeout(Function, Integer)
public void error(java.lang.String message) throws IllegalActionException
message
- The specified message.IllegalActionException
- Always thrown.public java.lang.Object get(org.mozilla.javascript.NativeJavaObject portWrapper, java.lang.Double channel)
portWrapper
- A JavaScript wrapper for a Port.channel
- A channel number, or NaN to use the default (0).public java.lang.String getClassName()
getClassName
in interface org.mozilla.javascript.Scriptable
getClassName
in class org.mozilla.javascript.ScriptableObject
public java.lang.String httpRequest(java.lang.String url, java.lang.String method, org.mozilla.javascript.NativeObject properties, java.lang.String body, java.lang.Integer timeout) throws java.io.IOException
httpRequest("http://ptolemy.org", "GET", null, "", 1000);which specifies a URL to read, the method for the read, no properties, no text to send, and a timeout of one second.
url
- The URL to which to make the request.method
- One of OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, or CONNECT.properties
- The HTTP property to set for the connection, or null to not
give any. For example: ['Content-Type':'application/x-www-form-urlencoded']body
- The body of the request, or null if none.timeout
- The timeout for a connection or a read, in milliseconds, or 0 to have no timeout.java.io.IOException
- If the request fails.public java.lang.String localHostAddress() throws java.net.UnknownHostException, java.lang.SecurityException
java.net.UnknownHostException
- If the local host is not known.java.lang.SecurityException
- If this actor is in restricted mode.@Deprecated public void socketX(java.lang.String url, org.mozilla.javascript.NativeObject query, org.mozilla.javascript.NativeJavaObject portWrapper) throws java.net.MalformedURLException
NOTE: This is a temporary placeholder method! This will go away. Please do not use it.
url
- The URL of the WebSocket connectionquery
- The queryportWrapper
- The port wrapperjava.net.MalformedURLException
- If the URL is malformed.public void print(java.lang.String message)
message
- The message to be printedpublic java.lang.String readURL(java.lang.String url) throws java.io.IOException
url
- The URL to read.java.io.IOException
- If the specified URL can't be read (that is, a response code
was received that is not in the range 100 to 399.public void send(java.lang.Object data, org.mozilla.javascript.NativeJavaObject portWrapper, java.lang.Double channel)
data
- The data to send via the port.portWrapper
- A JavaScript wrapper for a Port.channel
- A channel number, or NaN to use the default (0).public java.lang.Integer setTimeout(org.mozilla.javascript.Function function, java.lang.Integer time) throws IllegalActionException
If the model stops executing before the timeout period elapses, then the specified function will not be invoked.
function
- The function to invoke.time
- The time in milliseconds.IllegalActionException
- If the director cannot respect the time request.public java.lang.Object valueOf(org.mozilla.javascript.NativeJavaObject paramWrapper)
paramWrapper
- A JavaScript wrapper for a Variable.public java.lang.String requestAuth(java.lang.String providerName, java.lang.String clientId, java.lang.String redirectUrl, java.lang.Boolean openBrowser) throws IllegalActionException
providerName
- References an internally stored end point URL for popular OAuth providers like Google,
Twitter, Facebook, etc.clientId
- This identifies the application that accesses a resource. Usually, client ids are issued
after registering an application via a developer console at a resource provider.redirectUrl
- After completion of the authorization request this URL is used to redirect the browser.openBrowser
- Indicates, if the method should invoke the system's default browser to enable the user
to login to the server in order to grant access, or if the script handles this on its own.IllegalActionException
public java.lang.String requestAccess(java.lang.String providerName, java.lang.String clientId, java.lang.String clientSecret, java.lang.String redirectUrl, java.lang.String authCode) throws IllegalActionException
providerName
- The name of the provider, for example "google".clientId
- The clientID.clientSecret
- The client passwordredirectUrl
- The URL to which to redirect.authCode
- The authorization code issued by the Authorization server.IllegalActionException
public java.lang.String readProtectedURL(java.lang.String url, java.lang.String accessToken) throws IllegalActionException
url
- The protected URL on a Resource server. Usually this is some kind of RESTful API.accessToken
- The code used to prove access authorization to the Resource server.IllegalActionException
public java.lang.String openBrowser(java.lang.String url) throws IllegalActionException
url
- The URL that the browser shall retrieve.IllegalActionException
- If the browser is not found