MaltParser 1.4.1

org.maltparser.core.config
Class ConfigurationDir

java.lang.Object
  extended by org.maltparser.core.config.ConfigurationDir

public class ConfigurationDir
extends Object

This class contains methods for handle the configuration directory.

Author:
Johan Hall

Field Summary
protected static int BUFFER
           
protected  File configDirectory
           
protected  int containerIndex
           
protected  String createdByMaltParserVersion
           
protected  BufferedWriter infoFile
           
protected  String name
           
protected  String type
           
protected  URL url
           
protected  File workingDirectory
           
 
Constructor Summary
ConfigurationDir(String name, String type, int containerIndex)
          Creates a new configuration directory or a configuration directory from a mco-file
ConfigurationDir(URL url)
          Creates a configuration directory from a mco-file specified by an URL.
 
Method Summary
protected  void checkConfigDirectory()
           
protected  void checkNConvertConfigVersion()
           
 void copyConfigFile(File in, File out, org.maltparser.core.config.version.Versioning versioning)
           
 String copyToConfig(File source)
          Copies a file into the configuration directory.
 String copyToConfig(String fileUrl)
           
 String copyToConfig(URL url)
           
 void createConfigDirectory()
          Creates the configuration directory
 void createConfigFile()
          Creates the malt configuration file (.mco).
protected  void createInfoFile()
           
 void deleteConfigDirectory()
          Removes the configuration directory, if it exists and it contains a .info file.
 void echoInfoFile()
          Prints the content of the configuration information file to the system logger
protected  void finalize()
           
 OutputStreamWriter getAppendOutputStreamWriter(String fileName)
          This method acts the same as getOutputStreamWriter with the difference that the writer append in the file if it already exists instead of deleting the previous content before starting to write.
 File getConfigDirectory()
          Returns a file handler object for the configuration directory
 JarEntry getConfigFileEntry(String fileName)
           
 URL getConfigFileEntryURL(String fileName)
           
 int getContainerIndex()
          Returns the option container index
 String getCreatedByMaltParserVersion()
          Returns the version number of MaltParser which created the malt configuration file (.mco)
 HashMap<String,DataFormatInstance> getDataFormatInstances()
           
 DataFormatManager getDataFormatManager()
           
 File getFile(String fileName)
          Returns a file handler object of a file within the configuration directory
 BufferedWriter getInfoFileWriter()
          Returns a writer to the configuration information file
 InputStreamReader getInputStreamReader(String fileName)
          Creates an input stream reader for reading a file within the configuration directory.
 InputStreamReader getInputStreamReader(String fileName, String charSet)
          Creates an input stream reader for reading a file within the configuration directory
 InputStreamReader getInputStreamReaderFromConfigFile(String fileName)
           
 InputStreamReader getInputStreamReaderFromConfigFileEntry(String fileName, String charSet)
           
 String getName()
          Returns the name of the configuration directory
 OutputStreamWriter getOutputStreamWriter(String fileName)
          Creates an output stream writer, where the corresponding file will be included in the configuration directory.
 OutputStreamWriter getOutputStreamWriter(String fileName, String charSet)
          Creates an output stream writer, where the corresponding file will be included in the configuration directory
 SymbolTableHandler getSymbolTables()
           
 String getType()
          Returns the type of the configuration directory
 URL getUrl()
          Returns the URL to the malt configuration file (.mco)
 File getWorkingDirectory()
          Returns a file handler object for the working directory
 void initCreatedByMaltParserVersionFromInfoFile()
           
 void initDataFormat()
           
protected  void initNameNTypeFromInfoFile(URL url)
           
 void initWorkingDirectory()
          Initialize the working directory
 void initWorkingDirectory(String pathPrefixString)
          Initialize the working directory according to the path.
protected  void setConfigDirectory(File dir)
           
 void setContainerIndex(int containerIndex)
          Sets the option container index
 void setCreatedByMaltParserVersion(String createdByMaltParserVersion)
          Sets the version number of MaltParser which created the malt configuration file (.mco)
 void setDataFormatManager(DataFormatManager dataFormatManager)
           
protected  void setName(String name)
           
 void setSymbolTables(SymbolTableHandler symbolTables)
           
protected  void setType(String type)
           
protected  void setUrl(URL url)
           
 void terminate()
          Terminates the configuration directory
 void unpackConfigFile()
          Unpacks the malt configuration file (.mco).
protected  void unpackConfigFile(JarInputStream jis)
           
 void versioning()
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BUFFER

protected static final int BUFFER
See Also:
Constant Field Values

configDirectory

protected File configDirectory

name

protected String name

type

protected String type

workingDirectory

protected File workingDirectory

url

protected URL url

containerIndex

protected int containerIndex

infoFile

protected BufferedWriter infoFile

createdByMaltParserVersion

protected String createdByMaltParserVersion
Constructor Detail

ConfigurationDir

public ConfigurationDir(URL url)
                 throws MaltChainedException
Creates a configuration directory from a mco-file specified by an URL.

Parameters:
url - an URL to a mco-file
Throws:
MaltChainedException

ConfigurationDir

public ConfigurationDir(String name,
                        String type,
                        int containerIndex)
                 throws MaltChainedException
Creates a new configuration directory or a configuration directory from a mco-file

Parameters:
name - the name of the configuration
type - the type of configuration
containerIndex - the container index
Throws:
MaltChainedException
Method Detail

initDataFormat

public void initDataFormat()
                    throws MaltChainedException
Throws:
MaltChainedException

getOutputStreamWriter

public OutputStreamWriter getOutputStreamWriter(String fileName,
                                                String charSet)
                                         throws MaltChainedException
Creates an output stream writer, where the corresponding file will be included in the configuration directory

Parameters:
fileName - a file name
charSet - a char set
Returns:
an output stream writer for writing to a file within the configuration directory
Throws:
MaltChainedException

getOutputStreamWriter

public OutputStreamWriter getOutputStreamWriter(String fileName)
                                         throws MaltChainedException
Creates an output stream writer, where the corresponding file will be included in the configuration directory. Uses UTF-8 for character encoding.

Parameters:
fileName - a file name
Returns:
an output stream writer for writing to a file within the configuration directory
Throws:
MaltChainedException

getAppendOutputStreamWriter

public OutputStreamWriter getAppendOutputStreamWriter(String fileName)
                                               throws MaltChainedException
This method acts the same as getOutputStreamWriter with the difference that the writer append in the file if it already exists instead of deleting the previous content before starting to write.

Parameters:
fileName - a file name
Returns:
an output stream writer for writing to a file within the configuration directory
Throws:
MaltChainedException

getInputStreamReader

public InputStreamReader getInputStreamReader(String fileName,
                                              String charSet)
                                       throws MaltChainedException
Creates an input stream reader for reading a file within the configuration directory

Parameters:
fileName - a file name
charSet - a char set
Returns:
an input stream reader for reading a file within the configuration directory
Throws:
MaltChainedException

getInputStreamReader

public InputStreamReader getInputStreamReader(String fileName)
                                       throws MaltChainedException
Creates an input stream reader for reading a file within the configuration directory. Uses UTF-8 for character encoding.

Parameters:
fileName - a file name
Returns:
an input stream reader for reading a file within the configuration directory
Throws:
MaltChainedException

getConfigFileEntry

public JarEntry getConfigFileEntry(String fileName)
                            throws MaltChainedException
Throws:
MaltChainedException

getInputStreamReaderFromConfigFileEntry

public InputStreamReader getInputStreamReaderFromConfigFileEntry(String fileName,
                                                                 String charSet)
                                                          throws MaltChainedException
Throws:
MaltChainedException

getInputStreamReaderFromConfigFile

public InputStreamReader getInputStreamReaderFromConfigFile(String fileName)
                                                     throws MaltChainedException
Throws:
MaltChainedException

getFile

public File getFile(String fileName)
             throws MaltChainedException
Returns a file handler object of a file within the configuration directory

Parameters:
fileName - a file name
Returns:
a file handler object of a file within the configuration directory
Throws:
MaltChainedException

getConfigFileEntryURL

public URL getConfigFileEntryURL(String fileName)
                          throws MaltChainedException
Throws:
MaltChainedException

copyToConfig

public String copyToConfig(File source)
                    throws MaltChainedException
Copies a file into the configuration directory.

Parameters:
source - a path to file
Throws:
MaltChainedException

copyToConfig

public String copyToConfig(String fileUrl)
                    throws MaltChainedException
Throws:
MaltChainedException

copyToConfig

public String copyToConfig(URL url)
                    throws MaltChainedException
Throws:
MaltChainedException

deleteConfigDirectory

public void deleteConfigDirectory()
                           throws MaltChainedException
Removes the configuration directory, if it exists and it contains a .info file.

Throws:
MaltChainedException

getConfigDirectory

public File getConfigDirectory()
Returns a file handler object for the configuration directory

Returns:
a file handler object for the configuration directory

setConfigDirectory

protected void setConfigDirectory(File dir)

createConfigDirectory

public void createConfigDirectory()
                           throws MaltChainedException
Creates the configuration directory

Throws:
MaltChainedException

checkConfigDirectory

protected void checkConfigDirectory()
                             throws MaltChainedException
Throws:
MaltChainedException

createInfoFile

protected void createInfoFile()
                       throws MaltChainedException
Throws:
MaltChainedException

getInfoFileWriter

public BufferedWriter getInfoFileWriter()
                                 throws MaltChainedException
Returns a writer to the configuration information file

Returns:
a writer to the configuration information file
Throws:
MaltChainedException

createConfigFile

public void createConfigFile()
                      throws MaltChainedException
Creates the malt configuration file (.mco). This file is compressed.

Throws:
MaltChainedException

copyConfigFile

public void copyConfigFile(File in,
                           File out,
                           org.maltparser.core.config.version.Versioning versioning)
                    throws MaltChainedException
Throws:
MaltChainedException

initNameNTypeFromInfoFile

protected void initNameNTypeFromInfoFile(URL url)
                                  throws MaltChainedException
Throws:
MaltChainedException

echoInfoFile

public void echoInfoFile()
                  throws MaltChainedException
Prints the content of the configuration information file to the system logger

Throws:
MaltChainedException

unpackConfigFile

public void unpackConfigFile()
                      throws MaltChainedException
Unpacks the malt configuration file (.mco).

Throws:
MaltChainedException

unpackConfigFile

protected void unpackConfigFile(JarInputStream jis)
                         throws MaltChainedException
Throws:
MaltChainedException

getName

public String getName()
Returns the name of the configuration directory

Returns:
the name of the configuration directory

setName

protected void setName(String name)

getType

public String getType()
Returns the type of the configuration directory

Returns:
the type of the configuration directory

setType

protected void setType(String type)

getWorkingDirectory

public File getWorkingDirectory()
Returns a file handler object for the working directory

Returns:
a file handler object for the working directory

initWorkingDirectory

public void initWorkingDirectory()
                          throws MaltChainedException
Initialize the working directory

Throws:
MaltChainedException

initWorkingDirectory

public void initWorkingDirectory(String pathPrefixString)
                          throws MaltChainedException
Initialize the working directory according to the path. If the path is equals to "user.dir" or current directory, then the current directory will be the working directory.

Parameters:
pathPrefixString - the path to the working directory
Throws:
MaltChainedException

getUrl

public URL getUrl()
Returns the URL to the malt configuration file (.mco)

Returns:
the URL to the malt configuration file (.mco)

setUrl

protected void setUrl(URL url)

getContainerIndex

public int getContainerIndex()
Returns the option container index

Returns:
the option container index

setContainerIndex

public void setContainerIndex(int containerIndex)
Sets the option container index

Parameters:
containerIndex - a option container index

getCreatedByMaltParserVersion

public String getCreatedByMaltParserVersion()
Returns the version number of MaltParser which created the malt configuration file (.mco)

Returns:
the version number of MaltParser which created the malt configuration file (.mco)

setCreatedByMaltParserVersion

public void setCreatedByMaltParserVersion(String createdByMaltParserVersion)
Sets the version number of MaltParser which created the malt configuration file (.mco)

Parameters:
createdByMaltParserVersion - a version number of MaltParser

initCreatedByMaltParserVersionFromInfoFile

public void initCreatedByMaltParserVersionFromInfoFile()
                                                throws MaltChainedException
Throws:
MaltChainedException

versioning

public void versioning()
                throws MaltChainedException
Throws:
MaltChainedException

checkNConvertConfigVersion

protected void checkNConvertConfigVersion()
                                   throws MaltChainedException
Throws:
MaltChainedException

terminate

public void terminate()
               throws MaltChainedException
Terminates the configuration directory

Throws:
MaltChainedException

finalize

protected void finalize()
                 throws Throwable
Overrides:
finalize in class Object
Throws:
Throwable

getSymbolTables

public SymbolTableHandler getSymbolTables()

setSymbolTables

public void setSymbolTables(SymbolTableHandler symbolTables)

getDataFormatManager

public DataFormatManager getDataFormatManager()

setDataFormatManager

public void setDataFormatManager(DataFormatManager dataFormatManager)

getDataFormatInstances

public HashMap<String,DataFormatInstance> getDataFormatInstances()

MaltParser 1.4.1

Copyright 2007-2010 Johan Hall, Jens Nilsson and Joakim Nivre.