
prompto.prompto.pec Maven / Gradle / Ivy
define Any as native category with attributes id and text, and bindings:
define category bindings as:
Java: prompto.value.Any
C#: prompto.value.Any
Python2: Any from module: prompto.value.Any
Python3: Any from module: prompto.value.Any
JavaScript: Any from module: prompto/value/Any.js
and methods:
define id as getter doing:
Java: return System.identityHashCode(self);
C#: return System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(self);
Python2: return id(self)
Python3: return id(self)
JavaScript: return self.id;
define text as getter doing:
Java: return self.toString();
C#: return self.ToString();
Python2: return str(self)
Python3: return str(self)
JavaScript: return self.toString();
define Attribute as native category with attribute name, and bindings:
define category bindings as:
Java: prompto.declaration.AttributeDeclaration
C#: prompto.declaration.AttributeDeclaration
Python2: AttributeDeclaration from module: prompto.declaration.AttributeDeclaration
Python3: AttributeDeclaration from module: prompto.declaration.AttributeDeclaration
JavaScript: AttributeDeclaration from module: prompto/declaration/AttributeDeclaration.js
define findAttribute as native method receiving name returning Attribute doing:
Java: return $context.findAttribute(name);
C#: return $context.findAttribute(name);
Python2: return $context.findAttribute(name)
Python3: return $context.findAttribute(name)
JavaScript: return $context.findAttribute(name);
define getAllAttributes as native method returning Attribute[] doing:
Java: return $context.getAllAttributes();
C#: return $context.getAllAttributes();
Python2: return $context.getAllAttributes()
Python3: return $context.getAllAttributes()
JavaScript: return $context.getAllAttributes();
define "findAttribute id" as test method doing:
a = findAttribute "id"
and verifying:
a is an Attribute
a.name = "id"
define "findAttribute name" as test method doing:
a = findAttribute "name"
and verifying:
a is an Attribute
a.name = "name"
define "findAttribute text" as test method doing:
a = findAttribute "text"
and verifying:
a is an Attribute
a.name = "text"
define "at least 3 items getAllAttributes" as test method doing:
l = getAllAttributes
and verifying:
l is an Attribute[]
l.count >= 3
// runtime reference of any object
define id as Any attribute
// database reference of stored object
define dbId as Any attribute
// any object has a text attribute, used for display
define text as storable Text attribute with value and words index
// many objects have a name, it is not unique
define name as storable Text attribute with key and value index
// many objects have a description, it is not unique
define description as storable Text attribute with words index
// many objects have a version, it is not unique
define version as storable Text attribute
// many objects have a user, it is not unique
define user as storable Text attribute with key and value index
// many objects have an image, it is not unique
define image as storable Image attribute
// many events have a timeStamp
define timeStamp as storable DateTime attribute
// urls, files and fragments have a path
define path as Text attribute
// external text sources have an encoding such as "UTF-8"
define encoding as Text attribute
define Error as enumerated category with attributes name and text, and symbols:
DIVIDE_BY_ZERO with "Divide by zero!" as text
INDEX_OUT_OF_RANGE with "Index out of range!" as text
NULL_REFERENCE with "Null reference!" as text
NOT_MUTABLE with "Not a mutable object!" as text
NOT_STORABLE with "Not a storable object!" as text
READ_WRITE with "Read/write failed!" as text
define DecimalConstant as enumerated Decimal with symbols:
PI with 3.14159265358979323846 as value
E with 2.7182818284590452354 as value
define now as native method returning DateTime doing:
Java: return prompto.intrinsic.PromptoDateTime.now();
C#: return System.DateTimeOffset.Now;
Python2: return datetime.utcnow() from module: datetime
Python3: return datetime.utcnow() from module: datetime
JavaScript: return new Date();
define "now is a DateTime" as test method doing:
a = now
and verifying:
a is a DateTime
define Buffer as native resource with attribute text, and bindings:
define category bindings as:
Java: prompto.io.Buffer
C#: prompto.io.Buffer
Python2: Buffer from module: prompto.io.Buffer
Python3: Buffer from module: prompto.io.Buffer
JavaScript: Buffer from module: prompto/io/Buffer.js
define "writes to Buffer" as test method doing:
content = ""
with buffer = Buffer, do:
write "some content" to buffer
write "other content" to buffer
content = buffer.text
and verifying:
"some content" in content
"other content" in content
define Writer as native category with bindings:
define category bindings as:
Java: java.io.PrintStream
C#: System.IO.TextWriter
Python2: StringIO from module: StringIO
Python3: StringIO from module: io
JavaScript: writer from module: prompto/io/io.js
define stdout as native method returning Writer doing:
Java: return System.out;
C#: return System.Console.Out;
Python2: return stdout from module: sys
Python3: return stdout from module: sys
JavaScript: return stdout; from module: prompto/io/io.js
define stderr as native method returning Writer doing:
Java: return System.err;
C#: return System.Console.Error;
Python2: return stderr from module: sys
Python3: return stderr from module: sys
JavaScript: return stderr; from module: prompto/io/io.js
define printNative as native method receiving any value and Writer writer doing:
Java: writer.print(value);
C#: writer.Write(value);
Python2: print(objects=str(value), end="", file=writer)
Python3: print(objects=str(value), end="", file=writer)
JavaScript: writer.write(value.toString());
define print as method receiving any value doing:
writer = invoke: stdout
printNative value with writer as writer
define printLine as method receiving any value doing:
writer = invoke: stdout
value = "" + value + "\n"
printNative value with writer as writer
define PrintWriter as category with attribute text, and methods:
define print as method receiving any value doing:
if text is nothing:
text = "" + value
else:
text = text + value
define print as method receiving any value and any writer doing:
if writer is a PrintWriter:
writer.print with value as value
else:
printNative value with writer as writer
define printLine as method receiving any value and any writer doing:
print value with writer as writer
print '\n' with writer as writer
define "print a text" as test method doing:
w = mutable PrintWriter
print "Hello" with w as writer
print " John" with w as writer
and verifying:
w.text = "Hello John"
define "print an integer" as test method doing:
w = mutable PrintWriter
print 12345 with w as writer
and verifying:
w.text = "12345"
define "printLine a text" as test method doing:
w = mutable PrintWriter
print "Hello" with w as writer
printLine " John" with w as writer
and verifying:
w.text = "Hello John\n"
define "printLine an integer" as test method doing:
w = mutable PrintWriter
printLine 12345 with w as writer
and verifying:
w.text = "12345\n"
define htmlEncode as native method receiving Text value returning Text doing:
Java: return prompto.internet.Html.encode(value);
C#: return System.Net.WebUtility.HtmlEncode(value);
Python2: return escape(value) from module: cgi
Python3: return escape(value) from module: html
JavaScript: return Encoder.htmlEncode(value); from module: prompto/internet/Html.js
define htmlDecode as native method receiving Text value returning Text doing:
Java: return prompto.internet.Html.decode(value);
C#: return System.Net.WebUtility.HtmlDecode(value);
Python2: return HTMLParser().unescape(value) from module: HTMLParser
Python3: return unescape(value) from module: html.parser
JavaScript: return Encoder.htmlDecode(value); from module: prompto/internet/Html.js
define "encode Html entity" as test method doing:
encoded = htmlEncode ""
and verifying:
encoded = "<ab>"
define "decode Html entity" as test method doing:
encoded = htmlDecode "<ab>"
and verifying:
encoded = ""
define "decode Html charcode" as test method doing:
encoded = htmlDecode "a'b"
and verifying:
encoded = "a'b"
define getHttpUser as native method returning Text doing:
Java: return prompto.server.Server.getHttpUser();
C#: return prompto.server.Server.getHttpUser();
Python2: return getHttpUser() from module: prompto.server.Server
Python3: return getHttpUser() from module: prompto.server.Server
JavaScript: return getHttpUser(); from module: prompto/server/Server.js
define getHttpSession as native method returning Document doing:
Java: return prompto.server.Server.getHttpSession();
C#: return prompto.server.Server.getHttpSession();
Python2: return getHttpSession() from module: prompto.server.Server
Python3: return getHttpSession() from module: prompto.server.Server
JavaScript: return getHttpSession(); from module: prompto/server/Server.js
define Url as native resource with attributes path and encoding, and bindings:
define category bindings as:
Java: prompto.internet.Url
C#: prompto.internet.Url
Python2: Url from module: prompto.internet.Url
Python3: Url from module: prompto.internet.Url
JavaScript: Url from module: prompto/internet/Url.js
define "reads from www.html5rocks.com" as test method doing:
// need a cross-domain enabled page for browser testing
content = read from Url with "https://www.html5rocks.com/en/" as path
and verifying:
content contains "HTML5 Rocks"
define iterateCsv as native method receiving text, Text{} columnNames = nothing, Character separator = ',', Character quote = '"' returning Iterator doing:
Java: return prompto.reader.CSVReader.iterator(text, columnNames, separator, quote);
C#: return prompto.reader.CSVReader.iterator(text, columnNames, separator, quote);
Python2: return csvIterate(text, columnNames, separator, quote) from module: prompto.reader.CSVReader
Python3: return csvIterate(text, columnNames, separator, quote) from module: prompto.reader.CSVReader
JavaScript: return csvIterate(text, columnNames, separator, quote); from module: prompto/reader/CSVReader.js
define readCsv as native method receiving text, Text{} columnNames = nothing, Character separator = ',', Character quote = '"' returning Document[] doing:
Java: return prompto.reader.CSVReader.read(text, columnNames, separator, quote);
C#: return prompto.reader.CSVReader.read(text, columnNames, separator, quote);
Python2: return csvRead(text, columnNames, separator, quote) from module: prompto.reader.CSVReader
Python3: return csvRead(text, columnNames, separator, quote) from module: prompto.reader.CSVReader
JavaScript: return csvRead(text, columnNames, separator, quote); from module: prompto/reader/CSVReader.js
define "reads from csv text" as test method doing:
docs = readCsv with "id,name\n1,John\n2,Riou\\, Sylvie\n" as text
and verifying:
docs.count = 2
docs[1].id = "1"
docs[1].name = "John"
docs[2].id = "2"
docs[2].name = "Riou, Sylvie"
define "iterates from csv text" as test method doing:
iterCsv = iterateCsv with "id,name\n1,John\n2,Riou\\, Sylvie\n" as text
docs = [] as Document[]
for each doc in iterCsv:
docs = docs + [doc]
and verifying:
docs.count = 2
docs[1].id = "1"
docs[1].name = "John"
docs[2].id = "2"
docs[2].name = "Riou, Sylvie"
define "maps csv headers" as test method doing:
names = { "Code" : "id", "Name" : "name" }
docs = readCsv with "Code,Name\n1,John\n2,Riou\\, Sylvie\n" as text and names as columnNames
and verifying:
docs.count = 2
docs[1].id = "1"
docs[1].name = "John"
docs[2].id = "2"
docs[2].name = "Riou, Sylvie"
© 2015 - 2025 Weber Informatics LLC | Privacy Policy