galapi
Class Galax

java.lang.Object
  extended bygalapi.Galax

public class Galax
extends java.lang.Object

The Galax class contains methods needed to perform queries and to manipulate data under different representations.


Field Summary
static int Buffer_Input
           
static boolean ExternalContextItem
          Module does take an external context item
static int File_Input
           
static int Http_Input
           
static boolean NoExternalContextItem
          Module does not take an external context item
 
Constructor Summary
Galax()
           
 
Method Summary
static ProcessingContext defaultProcessingContext()
          Returns the default ProcessingContext which just contains flags for controlling debugging, printing, and the processing phases.
static ItemList evalCompiledStatement(PreparedProlog pp, Item cs)
          Given the PreparedProlog, evaluates a single compiled statement.
static PreparedProlog evalProlog(CompiledProlog compiled_prolog, ExternalContext exc)
          Evaluates the expressions for all - possibly mutually dependent - global variables.
static ItemList evalStatement(CompiledProlog c, int input_source_kind, java.lang.String input)
          Given the CompiledProlog, evaluates the XQuery statement in the string argument.
static CompiledProlog importLibraryModule(CompiledProlog compiled_prolog, int input_source_kind, java.lang.String input)
          Used to import other library modules.
static CompiledModule importMainModule(CompiledProlog compiled_prolog, boolean has_ext_ctxt_item, int input_source_kind, java.lang.String input)
          Used to import a main module defined in a file.
static void init()
          Does the initialization stuff, that is it passes program arguments to the OCaml Sys module.
static NodeList loadDocument(ProcessingContext pc, int input_source_kind, java.lang.String input)
          Loads an XML document into the Galax data model.
static CompiledProlog loadStandardLibrary(ProcessingContext pc)
          Load the standard Galax library, which contains the built-in types, namespaces, and functions.
protected static int nativeDefaultProcessingContext()
           
protected static int nativeEvalCompiledStatement(int prepared_prolog, int compiled_stmt)
           
protected static int nativeEvalProlog(int compiled_prolog, int external_context)
           
protected static int nativeEvalStatement(int c, int input_source_kind, java.lang.String input)
           
protected static int nativeImportLibraryModule(int compiled_prolog, int input_source_kind, java.lang.String input)
           
protected static int nativeImportMainModule(int compiled_prolog, boolean ext_ctxt_bool, int input_source_kind, java.lang.String input)
           
protected static int nativeLoadDocument(int pc, int input_source_kind, java.lang.String filename)
           
protected static int nativeLoadStandardLibrary(int pc)
           
protected static void nativeSerializeToFile(int pc, java.lang.String filename, int xml)
           
protected static void nativeSerializeToStdout(int pc, int xml)
           
protected static java.lang.String nativeSerializeToString(int pc, int xml)
           
static void serializeToFile(ProcessingContext pc, java.lang.String filename, ItemList xml)
          Serializes an XQuery data model value to a file
static void serializeToStdout(ProcessingContext pc, ItemList xml)
          Serializes an XQuery data model value to standard output
static java.lang.String serializeToString(ProcessingContext pc, ItemList xml)
          Serializes an XQuery data model value to a string
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

File_Input

public static final int File_Input
See Also:
Constant Field Values

Buffer_Input

public static final int Buffer_Input
See Also:
Constant Field Values

Http_Input

public static final int Http_Input
See Also:
Constant Field Values

NoExternalContextItem

public static final boolean NoExternalContextItem
Module does not take an external context item

See Also:
Constant Field Values

ExternalContextItem

public static final boolean ExternalContextItem
Module does take an external context item

See Also:
Constant Field Values
Constructor Detail

Galax

public Galax()
Method Detail

init

public static void init()
                 throws GalapiException
Does the initialization stuff, that is it passes program arguments to the OCaml Sys module.

Throws:
GalapiException

loadDocument

public static NodeList loadDocument(ProcessingContext pc,
                                    int input_source_kind,
                                    java.lang.String input)
                             throws GalapiException
Loads an XML document into the Galax data model.

Parameters:
pc - Processing context for loading document
input_source_kind - How the input XML is provided
input - The input itself (string, file, etc.)
Returns:
a list of nodes giving the Galax representation of the document
Throws:
GalapiException

serializeToString

public static java.lang.String serializeToString(ProcessingContext pc,
                                                 ItemList xml)
                                          throws GalapiException
Serializes an XQuery data model value to a string

Parameters:
xml - a collection of items representing an XML value
Returns:
a string representation of the collection of items
Throws:
GalapiException

serializeToStdout

public static void serializeToStdout(ProcessingContext pc,
                                     ItemList xml)
                              throws GalapiException
Serializes an XQuery data model value to standard output

Parameters:
xml - a collection of items representing an XML value
Throws:
GalapiException

serializeToFile

public static void serializeToFile(ProcessingContext pc,
                                   java.lang.String filename,
                                   ItemList xml)
                            throws GalapiException
Serializes an XQuery data model value to a file

Parameters:
filename - the name of the output file to be produced
xml - a collection of items representing an XML value
Throws:
GalapiException

defaultProcessingContext

public static ProcessingContext defaultProcessingContext()
                                                  throws GalapiException
Returns the default ProcessingContext which just contains flags for controlling debugging, printing, and the processing phases.

Throws:
GalapiException

loadStandardLibrary

public static CompiledProlog loadStandardLibrary(ProcessingContext pc)
                                          throws GalapiException
Load the standard Galax library, which contains the built-in types, namespaces, and functions.

Throws:
GalapiException

importLibraryModule

public static CompiledProlog importLibraryModule(CompiledProlog compiled_prolog,
                                                 int input_source_kind,
                                                 java.lang.String input)
                                          throws GalapiException
Used to import other library modules.

Returns:
the CompiledProlog argument extended with the module in the string filename argument.
Throws:
GalapiException

importMainModule

public static CompiledModule importMainModule(CompiledProlog compiled_prolog,
                                              boolean has_ext_ctxt_item,
                                              int input_source_kind,
                                              java.lang.String input)
                                       throws GalapiException
Used to import a main module defined in a file.

Parameters:
has_ext_ctxt_item - True, if the main module expects the context item to be provided by the external environment.
input_source_kind - Specifies whether main module is in file, string buffer or HTTP URL.
Returns:
the CompiledModule argument contains a compiled prolog and an ItemList containing statements to evaluate.
Throws:
GalapiException
See Also:
CompiledModule

evalProlog

public static PreparedProlog evalProlog(CompiledProlog compiled_prolog,
                                        ExternalContext exc)
                                 throws GalapiException
Evaluates the expressions for all - possibly mutually dependent - global variables.

It must be called before the other evalXXX functions.

Parameters:
compiled_prolog - a context obtained with one of the methods from this class
Returns:
a new context in which the expressions are evaluated
Throws:
GalapiException

evalStatement

public static ItemList evalStatement(CompiledProlog c,
                                     int input_source_kind,
                                     java.lang.String input)
                              throws GalapiException
Given the CompiledProlog, evaluates the XQuery statement in the string argument.

Returns:
if the statement is an XQuery expression, returns a list of items, otherwise if the statement is an XQuery update, returns an empty list because update statements have side effects on the data model store, but do not return values.
Throws:
GalapiException

evalCompiledStatement

public static ItemList evalCompiledStatement(PreparedProlog pp,
                                             Item cs)
                                      throws GalapiException
Given the PreparedProlog, evaluates a single compiled statement.

Returns:
an XSquery sequence representing the result of this evaluation
Throws:
GalapiException

nativeLoadDocument

protected static int nativeLoadDocument(int pc,
                                        int input_source_kind,
                                        java.lang.String filename)

nativeSerializeToString

protected static java.lang.String nativeSerializeToString(int pc,
                                                          int xml)

nativeSerializeToStdout

protected static void nativeSerializeToStdout(int pc,
                                              int xml)

nativeSerializeToFile

protected static void nativeSerializeToFile(int pc,
                                            java.lang.String filename,
                                            int xml)

nativeDefaultProcessingContext

protected static int nativeDefaultProcessingContext()

nativeLoadStandardLibrary

protected static int nativeLoadStandardLibrary(int pc)

nativeImportLibraryModule

protected static int nativeImportLibraryModule(int compiled_prolog,
                                               int input_source_kind,
                                               java.lang.String input)

nativeImportMainModule

protected static int nativeImportMainModule(int compiled_prolog,
                                            boolean ext_ctxt_bool,
                                            int input_source_kind,
                                            java.lang.String input)

nativeEvalProlog

protected static int nativeEvalProlog(int compiled_prolog,
                                      int external_context)

nativeEvalStatement

protected static int nativeEvalStatement(int c,
                                         int input_source_kind,
                                         java.lang.String input)

nativeEvalCompiledStatement

protected static int nativeEvalCompiledStatement(int prepared_prolog,
                                                 int compiled_stmt)