com.xerox.jxip
Class JXip

java.lang.Object
  extended by com.xerox.jxip.JXip

public class JXip
extends java.lang.Object

The purpose of this class is to provide a Java implementation of the XIP library.


Constructor Summary
JXip()
          Constructor for the JXip object
JXip(java.lang.String[] libsArr, boolean loadingLibInJar)
          Constructor for the JXip object the libraries inside the jar are not loaded
 
Method Summary
static java.lang.String duplicateString(java.lang.String str)
          This method is used to be sured than the string created by a C++ native method will be duplicated before calling the deleteLocalJStringRef method which tell the GC to garbage this data
 java.lang.String getEnv(java.lang.String name)
          Get the value of a native environment variable
 java.lang.String getErrorMsg()
          return the error message of the previous xip function call
 java.lang.String GetVersion()
          Get version about the current XIP C++ Library used.
 void InitErrorMsg()
          Reset and clear the error message buffer
static void main(java.lang.String[] args)
           
 java.lang.String parseString(int gHandler, java.lang.String textInput, char xml, char apply_grammar)
          parse one string
 java.lang.String parseStringCharSet(int gHandler, java.lang.String textInput, java.lang.String charSet, char xml, char apply_grammar)
          parse the string: Encodes this String into a sequence of bytes using the named charset storing the result into a new byte array and parse this array.
 java.lang.String parseStringStructure(int gHandler, java.lang.String textInput, char xml, char apply_grammar)
          parse a string that contains a tree structure
 java.lang.String parseStringXml(int gHandler, java.lang.String textInput)
          Parse one String.
 java.lang.String parseStringXmlOS(int gHandler, java.lang.String input)
          Parse one String.
 java.lang.String parseStringXmlOS(int gHandler, java.lang.String input, int depth, char xml, char apply)
          Parse one String.
 void printSysInfo()
          print system info
 void setEnv(java.lang.String name, java.lang.String value)
          change the value of a native environment variable
 void XipAddFlagDisplay(int gHandler, long displayFlag, int col)
          add display flag
 java.util.Vector<java.lang.String> XipAliasList(int gHandler)
          get the list of aliases
 int XipCleanXMLAlias(int gHandler, java.lang.String alias)
          This method clean the data in memory corresponding to the xmltree
 void XipFreeGrammar(int gHandler)
           
 java.lang.String XipGetGrammarCharset(int gHandler)
          Return the encoding charset of the grammar source files
 java.util.Vector<java.lang.String> XipGetListCategories(int gHandler)
           
 java.util.Vector<java.lang.String> XipGetListDependencies(int gHandler)
           
 java.lang.String XipGetSourceCharset(int gHandler)
          Return the encoding charset of the source (FST)
 java.lang.String XipGetStringVariable(int gHandler, java.lang.String variableName)
          get a variable string value
 int XipGrammarLoading(java.lang.String grammarFileName, java.lang.String ntmFileName, java.lang.String hmmFileName, int enableXml)
          loading grammars, NTM and HMM ressources files.
 int XipGrmFile(java.lang.String grmFileName, int enableXml, boolean loadFst)
          load grammar files using a grm file
 int XipLicense(int gHandler)
          returns the number of days before the grammar licence expires
 int XipLoadGrammar(java.lang.String grammarFileName, java.lang.String ntmFileName, java.lang.String hmmFileName, int enableXml)
          loading grammars, NTM and HMM ressources files.
 int XipLoadXMLDataBase(int gHandler, java.lang.String fileName, java.lang.String alias)
          load a XML database file
 int XipParameterFile(int gHandler, java.lang.String fileName)
          load a parameter file
 int XipParseFileToFile(int gHandler, java.lang.String input, java.lang.String output, char xml, char apply)
           
 java.lang.String XipParseFileXmlOS(int gHandler, java.lang.String inputFile, int depth, char xml, char apply)
           
 int XipParseFileXMLToFile(int gHandler, java.lang.String input, java.lang.String output, int depth, char xml, char apply)
           
 int XipReloadGrammar(int gHandler, boolean reloadParameter, java.lang.String grmFileName)
          Reload a grammar
 void XipRemoveFlagDisplay(int gHandler, long displayFlag)
          remove a display flag
 void XipSetDependencyExtraction(int gHandler, boolean extraction)
           
 void XipSetDisplayMode(int gHandler, long displayMode, int col)
          select a display mode
 boolean xipSetIndentFilePathname(int gHandler, java.lang.String path)
           
 int XipSetIntVariable(int gHandler, java.lang.String variableName, int value)
          set a int variable
 int XipSetStringVariable(int gHandler, java.lang.String variableName, java.lang.String variableValue)
          set a variable
 boolean xipSetWorkingFilesPath(int gHandler, java.lang.String path)
          define the path for any output file
 boolean XipTestFlagDisplay(int gHandler, long displayFlag)
          test a display flag
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JXip

public JXip()
     throws java.lang.Exception
Constructor for the JXip object

Throws:
java.lang.Exception

JXip

public JXip(java.lang.String[] libsArr,
            boolean loadingLibInJar)
     throws java.lang.Exception
Constructor for the JXip object the libraries inside the jar are not loaded

Parameters:
libsArr - array of dynamic libraries to load
loadingLibInJar - if true the dynamic libraries inside the jar will be also loaded, otherwise they are not loaded
Throws:
java.lang.Exception
Method Detail

duplicateString

public static java.lang.String duplicateString(java.lang.String str)
This method is used to be sured than the string created by a C++ native method will be duplicated before calling the deleteLocalJStringRef method which tell the GC to garbage this data

Parameters:
str -
Returns:

setEnv

public void setEnv(java.lang.String name,
                   java.lang.String value)
            throws java.lang.Exception
change the value of a native environment variable

Parameters:
name - the environment variable name
value - The new value
Throws:
java.lang.Exception

getEnv

public java.lang.String getEnv(java.lang.String name)
                        throws java.lang.Exception
Get the value of a native environment variable

Parameters:
name - The environment variable name.
Returns:
The environment variable value
Throws:
java.lang.Exception

XipGrmFile

public int XipGrmFile(java.lang.String grmFileName,
                      int enableXml,
                      boolean loadFst)
               throws java.lang.Exception
load grammar files using a grm file

Parameters:
grmFileName - the grm file name
enableXml - when set to one, this parameter tells XIP that the input complies with the XIP XML DTD
loadFst - if true loads the FST otherwise parse only the grammar file without loading FST
Returns:
a handler to a grammar or -1 if error
Throws:
java.lang.Exception

XipLoadGrammar

public int XipLoadGrammar(java.lang.String grammarFileName,
                          java.lang.String ntmFileName,
                          java.lang.String hmmFileName,
                          int enableXml)
                   throws java.lang.Exception
loading grammars, NTM and HMM ressources files.

Parameters:
grammarFileName - the grammar file name (.../english.xip)
ntmFileName - the NTM script file name(.../ntmscript)
hmmFileName - the HMM file name
enableXml - When set to one , this parameter tells XIP that the input complies with the XIP XML DTD
Returns:
a handler to the grammar.
Throws:
java.lang.Exception

XipGrammarLoading

public int XipGrammarLoading(java.lang.String grammarFileName,
                             java.lang.String ntmFileName,
                             java.lang.String hmmFileName,
                             int enableXml)
                      throws java.lang.Exception
loading grammars, NTM and HMM ressources files. ressources files assuming that the input files fit with the XIP XML DTD specifications.

Parameters:
grammarFileName - the grammar file name (.../english.xip)
ntmFileName - the NTM script file name(.../ntmscript)
hmmFileName - the HMM file name
enableXml - When set to one , this parameter tells XIP that the input complies with the XIP XML DTD
Returns:
a handler to the grammar.
Throws:
java.lang.Exception

XipReloadGrammar

public int XipReloadGrammar(int gHandler,
                            boolean reloadParameter,
                            java.lang.String grmFileName)
                     throws java.lang.Exception
Reload a grammar

Parameters:
gHandler - the handler to the grammar to reload
reloadParameter - if true then the paramter files will be reloaded otherwise they will be not reloaded
grmFileName - the grm file of the grammar to reload
Returns:
a handler to the grammar.
Throws:
java.lang.Exception

XipCleanXMLAlias

public int XipCleanXMLAlias(int gHandler,
                            java.lang.String alias)
                     throws java.lang.Exception
This method clean the data in memory corresponding to the xmltree

Parameters:
gHandler - the handler to the grammar to reload
alias - the alias
Returns:
return -1 if error, 0 otherwise
Throws:
java.lang.Exception

XipSetIntVariable

public int XipSetIntVariable(int gHandler,
                             java.lang.String variableName,
                             int value)
                      throws java.lang.Exception
set a int variable

Parameters:
gHandler - a handler to the grammar.
variableName - the variable name
value -
Returns:
return -1 if error, 0 otherwise
Throws:
java.lang.Exception

XipSetStringVariable

public int XipSetStringVariable(int gHandler,
                                java.lang.String variableName,
                                java.lang.String variableValue)
                         throws java.lang.Exception
set a variable

Parameters:
gHandler - a handler to the grammar.
variableName - the variable name
variableValue - the variable value
Returns:
return -1 if error, 0 otherwise
Throws:
java.lang.Exception

XipGetStringVariable

public java.lang.String XipGetStringVariable(int gHandler,
                                             java.lang.String variableName)
                                      throws java.lang.Exception
get a variable string value

Parameters:
gHandler - a handler to the grammar.
variableName - the variable name
Returns:
Throws:
java.lang.Exception

XipLoadXMLDataBase

public int XipLoadXMLDataBase(int gHandler,
                              java.lang.String fileName,
                              java.lang.String alias)
                       throws java.lang.Exception
load a XML database file

Parameters:
gHandler - a handler to the grammar.
fileName - the XML database file
alias - the alias name to associate with the database file
Returns:
return -1 if error, 0 otherwise
Throws:
java.lang.Exception

XipAliasList

public java.util.Vector<java.lang.String> XipAliasList(int gHandler)
                                                throws java.lang.Exception
get the list of aliases

Parameters:
gHandler - a handler to the grammar.
Returns:
a Vector of alias name (String)
Throws:
java.lang.Exception

XipParameterFile

public int XipParameterFile(int gHandler,
                            java.lang.String fileName)
                     throws java.lang.Exception
load a parameter file

Parameters:
gHandler - a handler to a grammar
fileName - a parameter file name
Returns:
return -1 if error, 0 otherwise
Throws:
java.lang.Exception

XipSetDisplayMode

public void XipSetDisplayMode(int gHandler,
                              long displayMode,
                              int col)
                       throws java.lang.Exception
select a display mode

Parameters:
gHandler - a handler to a grammar
displayMode - the display mode value
col - number of char by line
Throws:
java.lang.Exception

XipAddFlagDisplay

public void XipAddFlagDisplay(int gHandler,
                              long displayFlag,
                              int col)
                       throws java.lang.Exception
add display flag

Parameters:
gHandler - a handler to a grammar
displayFlag - the display flag
col - number of char by line
Throws:
java.lang.Exception

XipRemoveFlagDisplay

public void XipRemoveFlagDisplay(int gHandler,
                                 long displayFlag)
                          throws java.lang.Exception
remove a display flag

Parameters:
gHandler - a handler to a grammar
displayFlag - the display flag
Throws:
java.lang.Exception

XipTestFlagDisplay

public boolean XipTestFlagDisplay(int gHandler,
                                  long displayFlag)
                           throws java.lang.Exception
test a display flag

Parameters:
gHandler - a handler to a grammar
displayFlag - the display flag
Returns:
true or false
Throws:
java.lang.Exception

GetVersion

public java.lang.String GetVersion()
                            throws java.lang.Exception
Get version about the current XIP C++ Library used.

Returns:
The version value
Throws:
java.lang.Exception

XipLicense

public int XipLicense(int gHandler)
               throws java.lang.Exception
returns the number of days before the grammar licence expires

Parameters:
gHandler - a handler to a grammar
Returns:
number of days
Throws:
java.lang.Exception

parseString

public java.lang.String parseString(int gHandler,
                                    java.lang.String textInput,
                                    char xml,
                                    char apply_grammar)
                             throws java.lang.Exception
parse one string

Parameters:
gHandler - a handler to a grammar
textInput - string to parse
xml - XML_NONE=0, XML_OUTPUT=1,XML_INSERT=2
apply_grammar -
Returns:
Throws:
java.lang.Exception

parseStringStructure

public java.lang.String parseStringStructure(int gHandler,
                                             java.lang.String textInput,
                                             char xml,
                                             char apply_grammar)
                                      throws java.lang.Exception
parse a string that contains a tree structure

Parameters:
gHandler - a handler to a grammar
textInput - structure string to parse
xml - XML_NONE=0, XML_OUTPUT=1,XML_INSERT=2
apply_grammar -
Returns:
Throws:
java.lang.Exception

parseStringXml

public java.lang.String parseStringXml(int gHandler,
                                       java.lang.String textInput)
                                throws java.lang.Exception
Parse one String.

Parameters:
gHandler - a handler to a grammar
textInput - String to parse.
Returns:
Throws:
java.lang.Exception

parseStringCharSet

public java.lang.String parseStringCharSet(int gHandler,
                                           java.lang.String textInput,
                                           java.lang.String charSet,
                                           char xml,
                                           char apply_grammar)
                                    throws java.lang.Exception
parse the string: Encodes this String into a sequence of bytes using the named charset storing the result into a new byte array and parse this array.

Parameters:
gHandler - a handler to a grammar
textInput - string to parse
xml - XML_NONE=0, XML_OUTPUT=1,XML_INSERT=2
apply_grammar -
charSet - iso-8859-1, utf-8, ...
Returns:
Throws:
java.lang.Exception

XipParseFileXmlOS

public java.lang.String XipParseFileXmlOS(int gHandler,
                                          java.lang.String inputFile,
                                          int depth,
                                          char xml,
                                          char apply)
                                   throws java.lang.Exception
Parameters:
gHandler - a handler to a grammar
inputFile -
depth -
xml -
apply -
Returns:
Throws:
java.lang.Exception

parseStringXmlOS

public java.lang.String parseStringXmlOS(int gHandler,
                                         java.lang.String input,
                                         int depth,
                                         char xml,
                                         char apply)
                                  throws java.lang.Exception
Parse one String.

Parameters:
gHandler - a handler to a grammar a handler to a grammar
input - text to parse
depth -
xml - XML_NONE=0, XML_OUTPUT=1,XML_INSERT=2
apply -
Returns:
Throws:
java.lang.Exception

parseStringXmlOS

public java.lang.String parseStringXmlOS(int gHandler,
                                         java.lang.String input)
                                  throws java.lang.Exception
Parse one String. depth is set to 1, xml is set to XML_INSERT, and apply is set to APPLY_GRAMMAR

Parameters:
gHandler - a handler to a grammar
input - text to parse
Returns:
String A XML result as a String.
Throws:
java.lang.Exception

XipSetDependencyExtraction

public void XipSetDependencyExtraction(int gHandler,
                                       boolean extraction)
                                throws java.lang.Exception
Parameters:
gHandler - a handler to a grammar
extraction -
Throws:
java.lang.Exception

XipFreeGrammar

public void XipFreeGrammar(int gHandler)
                    throws java.lang.Exception
Parameters:
gHandler - a handler to a grammar
Throws:
java.lang.Exception

XipParseFileToFile

public int XipParseFileToFile(int gHandler,
                              java.lang.String input,
                              java.lang.String output,
                              char xml,
                              char apply)
                       throws java.lang.Exception
Parameters:
gHandler - a handler to a grammar
output -
xml -
apply -
input -
Returns:
Throws:
java.lang.Exception

XipParseFileXMLToFile

public int XipParseFileXMLToFile(int gHandler,
                                 java.lang.String input,
                                 java.lang.String output,
                                 int depth,
                                 char xml,
                                 char apply)
                          throws java.lang.Exception
Parameters:
gHandler - a handler to a grammar
output -
depth -
xml -
apply -
input -
Returns:
Throws:
java.lang.Exception

XipGetListCategories

public java.util.Vector<java.lang.String> XipGetListCategories(int gHandler)
                                                        throws java.lang.Exception
Throws:
java.lang.Exception

XipGetListDependencies

public java.util.Vector<java.lang.String> XipGetListDependencies(int gHandler)
                                                          throws java.lang.Exception
Throws:
java.lang.Exception

InitErrorMsg

public void InitErrorMsg()
Reset and clear the error message buffer


XipGetSourceCharset

public java.lang.String XipGetSourceCharset(int gHandler)
                                     throws java.lang.Exception
Return the encoding charset of the source (FST)

Parameters:
gHandler - Grammar handler
Returns:
the encoding charset: "UTF8_ENCODING" | "LATIN_ENCODING"
Throws:
java.lang.Exception

XipGetGrammarCharset

public java.lang.String XipGetGrammarCharset(int gHandler)
                                      throws java.lang.Exception
Return the encoding charset of the grammar source files

Parameters:
gHandler - Grammar handler
Returns:
the encoding charset: "UTF8_ENCODING" | "LATIN_ENCODING"
Throws:
java.lang.Exception

getErrorMsg

public java.lang.String getErrorMsg()
return the error message of the previous xip function call

Returns:
The errorMsg value

xipSetIndentFilePathname

public boolean xipSetIndentFilePathname(int gHandler,
                                        java.lang.String path)
                                 throws java.lang.Exception
Parameters:
gHandler - a handler to a grammar
path - Indent File Pathname
Returns:
true if ok, false if error
Throws:
java.lang.Exception

xipSetWorkingFilesPath

public boolean xipSetWorkingFilesPath(int gHandler,
                                      java.lang.String path)
                               throws java.lang.Exception
define the path for any output file

Parameters:
gHandler - a handler to a grammar
path - the Path for any output file
Returns:
true if ok, false if error
Throws:
java.lang.Exception

printSysInfo

public void printSysInfo()
print system info


main

public static void main(java.lang.String[] args)
Parameters:
args -


Copyright © 2008 Xerox All Rights Reserved.