Thursday, 17 May 2012

Create search engine

In order to create search engine, follow these steps:

  1. Download pedatus-1.0-search-engine.zip
  2. Import downloaded file to engine
  3. Set schedule to run spider-amazon-category.jsb
  4. Set schedule to run spider-amazon-product.jsb

This is example of small search engine built with Pedatus and Orinus: Paesia - Micro Search Engine

Machine (Orinus API)


com.orinus.script
Class Machine

java.lang.Object
  extended by com.orinus.script.Machine

public class Machine
     
extends Object

The core public access point to the Orinus functionality.

Author:
Tran Dinh Thoai <dthoai@yahoo.com>

Method Summary
String newString(String src)
          Create new java string from javascript string.
String newString(byte[] src, String charset)
          Create new java string from javascript string.
HashMap newHashMap()
          Create new java hash map.
ArrayList newArrayList()
          Create new java array list.
Byte newByte(byte src)
          Create new java byte object.
Short newShort(short src)
          Create new java short integer object.
Integer newInteger(int src)
          Create new java integer object.
Long newLong(long src)
          Create new java long integer object.
Float newFloat(float src)
          Create new java float object.
Double newDouble(double src)
          Create new java double object.
Boolean newBoolean(boolean src)
          Create new java boolean object.
Character newCharacter(char src)
          Create new java character object.
List getKeys(Map src)
          Get keys of hash map.
URL newURL(String protocol, String host, int port, String file)
          Create new java URL object.
URL newURL(String protocol, String host, String file)
          Create new java URL object.
URL newURL(String spec)
          Create new java URL object.
URL newURL(String context, String spec)
          Create new java URL object.
SJsoup newJsoup()
          Create access point of Jsoup library.
String encodeURL(String src, String charset)
          Encode URL string.
String decodeURL(String src, String charset)
          Decode URL string.
String uniqid()
          Generate unique id.
String suniqid()
          Generate small unique id.
Date newDate()
          Create new current date object.
Date newDate(long time)
          Create new date object.
SimpleDateFormat newDateFormat(String format)
          Create date formatter.
byte[] decodeBase64(byte[] src)
          Decode base64 byte array.
byte[] encodeBase64(byte[] src)
          Encode base64 byte array.
List<Object> setToList(Set src)
          Convert set to list.
SMySQL newMySQL()
          Create access point of MySQL library.
Locale newLocale(String language)
          Create new Locale object.
Locale newLocale(String language, String country)
          Create new Locale object.
Locale newLocale(String language, String country, String variant)
          Create new Locale object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newString

public String newString(String src)
Create new java string from javascript string.

Parameters:
src - javascript string
Returns:
java string
See Also:
newString(src, charset)

newString

public String newString(byte[] src, String charset)
Create new java string from javascript string.

Parameters:
src - javascript byte array
charset - character set name
Returns:
java string
See Also:
newString(src)

newHashMap

public HashMap newHashMap()
Create new java hash map.


newArrayList

public ArrayList newArrayList()
Create new java array list.


newByte

public Byte newByte(byte src)
Create new java byte object.

Parameters:
src - javascript byte object
Returns:
java byte object

newShort

public Short newShort(short src)
Create new java short integer object.

Parameters:
src - javascript short integer object
Returns:
java short integer object

newInteger

public Integer newInteger(int src)
Create new java integer object.

Parameters:
src - javascript integer object
Returns:
java integer object

newLong

public Long newLong(long src)
Create new java long integer object.

Parameters:
src - javascript long integer object
Returns:
java long integer object

newFloat

public Float newFloat(float src)
Create new java float object.

Parameters:
src - javascript float object
Returns:
java float object

newDouble

public Double newDouble(double src)
Create new java double object.

Parameters:
src - javascript double object
Returns:
java double object

newBoolean

public Boolean newBoolean(boolean src)
Create new java boolean object.

Parameters:
src - javascript boolean object
Returns:
java boolean object

newCharacter

public Character newCharacter(char src)
Create new java character object.

Parameters:
src - javascript character object
Returns:
java character object

getKeys

public List getKeys(Map src)
Get keys of hash map.

Parameters:
src - hash map
Returns:
List of keys

newURL

public URL newURL(String protocol, String host, int port, String file)
Create new java URL object.

Parameters:
protocol - protocol
host - host
port - port
file - file
Returns:
URL object
See Also:
newURL(protocol, host, file)
newURL(spec)
newURL(context, spec)

newURL

public URL newURL(String protocol, String host, String file)
Create new java URL object.

Parameters:
protocol - protocol
host - host
file - file
Returns:
URL object
See Also:
newURL(protocol, host, port, file)
newURL(spec)
newURL(context, spec)

newURL

public URL newURL(String spec)
Create new java URL object.

Parameters:
spec - spec
Returns:
URL object
See Also:
newURL(protocol, host, port, file)
newURL(protocol, host, file)
newURL(context, spec)

newURL

public URL newURL(String context, String spec)
Create new java URL object.

Parameters:
context - context
spec - spec
Returns:
URL object
See Also:
newURL(protocol, host, port, file)
newURL(protocol, host, file)
newURL(spec)

newJsoup

public SJsoup newJsoup()
Create access point of Jsoup library.

Returns:
Access point object of Jsoup library

encodeURL

public String encodeURL(String src, String charset)
Encode URL string.

Parameters:
src - source string
charset - character set name
Returns:
Encoded URL string

decodeURL

public String decodeURL(String src, String charset)
Decode URL string.

Parameters:
src - source string
charset - character set name
Returns:
Decoded URL string

uniqid

public String uniqid()
Generate unique id.

Returns:
Unique id string

suniqid

public String suniqid()
Generate small unique id.

Returns:
Small unique id string

newDate

public Date newDate()
Create new current date object.

Returns:
Current date object

newDate

public Date newDate(long time)
Create new date object.

Parameters:
time - the milliseconds since January 1, 1970, 00:00:00 GMT.
Returns:
Date object

newDateFormat

public SimpleDateFormat newDateFormat(String format)
Create date formatter.

Parameters:
format - date format
Returns:
Date formatter

decodeBase64

public byte[] decodeBase64(byte[] src)
Decode base64 byte array.

Parameters:
src - encoded base64 byte array
Returns:
Decoded base64 byte array

encodeBase64

public byte[] encodeBase64(byte[] src)
Encode base64 byte array.

Parameters:
src - decoded base64 byte array
Returns:
Encoded base64 byte array

setToList

public List<Object> setToList(Set src)
Convert set to list.

Parameters:
src - source set object
Returns:
List object

newMySQL

public SMySQL newMySQL()
Create access point of MySQL library.

Returns:
Access point object of MySQL library

newLocale

public Locale newLocale(String language)
Create new Locale object.

Parameters:
language - language
Returns:
Locale object
See Also:
newLocale(language, country)
newLocale(language, country, variant)

newLocale

public Locale newLocale(String language, String country)
Create new Locale object.

Parameters:
language - language
country - country
Returns:
Locale object
See Also:
newLocale(language)
newLocale(language, country, variant)

newLocale

public Locale newLocale(String language, String country, String variant)
Create new Locale object.

Parameters:
language - language
country - country
variant - variant
Returns:
Locale object
See Also:
newLocale(language)
newLocale(language, country)

Wednesday, 16 May 2012

Create basic script

JavaScript SandBox script file has extension of .jsb . File includes one main() function.

function main(env, args) {
  var req = args.get('request');
  var res = args.get('response');
  var root = args.get('root');
  var folder_id = args.get('folder_id');
  var folder_path = args.get('folder_path');
  var file_id = args.get('file_id');
  var file_name = args.get('file_name');

  res.setContentType('text/html');
  res.write('Root: ' + root + '
'); res.write('Folder Id: ' + folder_id + '
'); res.write('Folder Path: ' + folder_path + '
'); res.write('File Id: ' + file_id + '
'); res.write('File Name: ' + file_name + '
'); }

Tutorial of Orinus - JavaScript SandBox

Screenshots of Orinus - JavaScript SandBox