Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## main
Class ConfigurationReader

    java.lang.Object
      main.ConfigurationReader

    public class ConfigurationReader

extends java.lang.Object

Singleton class containing configuration parameters of utility. If no configuration file exists default values are used. Brief description of configuration file is provided in file configuration.dtd.

Field Summary
`int` | `DESKTOP_TYPE`
`int` | `NOTEBOOK_TYPE`
`int` | `UNKNOWN`

Method Summary
`boolean` | `configTrouble()` If fallback to default configuration parameters was necessary as result of invalid configuration file, returns true.
`java.net.InetAddress` | `getAddress()` Returns multicast address used to "broadcast" controll and supervisory messages over network.
`static ConfigurationReader` | `getCfg()` Returns object encapuslating configuration parameters.
`java.io.File` | `getDefaultConfigFile()` Returns object representation of file in which configuration reader expects configuration to be stored.
`java.io.File` | `getFolder()` Returns object representation of repository folder.
`int` | `getFragmentCount()` Returns number of fragments file will be divided into.
`int` | `getChecksumCount()` Returns number of checksums that will be calculated.
`java.net.InetAddress` | `getLocalAddress()` Returns unicast address of localhost, as in configuration user is allowed to specify unicast address used for data transfer.
`int` | `getMaskLength()` Returns number of bits used in subnet mask configured on local interface.
`int` | `getMaxBackupCount()`
`int` | `getMaxSize()` Returns maximum allowed size of repository folder in MB.
`int` | `getPort()` Returns local port number used for pupouses of network communication.
`java.lang.String` | `getRepositoryFolderPath()` Returns path to repository folder as specified in configuration.
`java.io.File` | `getSchedulerConfiguration()`
`java.net.InetSocketAddress` | `getSocketAddress()` Returns socket address of local aplication used for communication.
`int` | `getType()` Returns integer representing type of local host.
`java.lang.String[]` | `getTypeDesc()` Returns string descriptions of host types.
`void` | `readConfig(java.io.File configFile)` Reads configuration from specified file.
`static ConfigurationReader` | `readConfiguration()` Reads default configuration file.
`static ConfigurationReader` | `readConfiguration(java.io.File configFile)` Singleton factory method.
`void` | `setAddress(java.lang.String address)` Sets multicast address using which other hosts will be contacted.
`void` | `setFragments(java.lang.String fragments)` Sets number of fragments used for checksum calculations during backing up.
`void` | `setChecksums(java.lang.String checksums)` Sets number of checksums to be calculated during process of backing up.
`void` | `setMaxSize(java.lang.String size)` Sets maximum allowed size of repository folder.
`void` | `setPort(java.lang.String portString)` Sets port number to be used for networking purpouses.
`void` | `setRepositoryFolderPath(java.lang.String folder)` Sets path to repository folder.
`void` | `setType(int typeNumber)` Sets type of local host.
`boolean` | `usingDefaults()` Used to determine if default configuration values had to be loaded instead of those stored in configuration file.
`void` | `writeConfig()` Writes currently loaded config into default configuration file.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### UNKNOWN

    public final int UNKNOWN

See Also:
  Constant Field Values

### NOTEBOOK_TYPE

    public final int NOTEBOOK_TYPE

See Also:
  Constant Field Values

### DESKTOP_TYPE

    public final int DESKTOP_TYPE

See Also:
  Constant Field Values

Method Detail

### readConfiguration

    public static ConfigurationReader readConfiguration()

  Reads default configuration file. If file is invalid, or contains malformed configuration, default configuration parameters are used.

  Returns:
    container with values read from default file or default values

### readConfiguration

    public static ConfigurationReader readConfiguration(java.io.File configFile)

  Singleton factory method. If configuration has not been read yet, new configuration reader is built. If it has been read previously configuration is only updated.

  Parameters:
    `configFile` - path to configuration file
  Returns:
    Object representing configuration of application

### getCfg

    public static ConfigurationReader getCfg()

  Returns object encapuslating configuration parameters. Configuration must be initialized, i.e read, before this method is called. Prevents from using default configuration file unintentionally.

  Returns:
    container with configuration parameters.

### readConfig

    public void readConfig(java.io.File configFile)

  Reads configuration from specified file. If configuration is invalid, default values are used instead.

  Parameters:
    `configFile` - File containing configuration.

### writeConfig

    public void writeConfig()
                     throws java.io.IOException

  Writes currently loaded config into default configuration file.

  Throws:
    `java.io.IOException` - if problems occur during writing into file

### getMaxSize

    public int getMaxSize()

  Returns maximum allowed size of repository folder in MB.

  Returns:
    maximum allowed size of repository folder in MB

### getRepositoryFolderPath

    public java.lang.String getRepositoryFolderPath()

  Returns path to repository folder as specified in configuration.

  Returns:
    path to repository folder

### getFolder

    public java.io.File getFolder()

  Returns object representation of repository folder.

  Returns:
    File object of repository folder

### getPort

    public int getPort()

  Returns local port number used for pupouses of network communication.

  Returns:
    local port number

### getSocketAddress

    public java.net.InetSocketAddress getSocketAddress()

  Returns socket address of local aplication used for communication. Socket address contains IP address and port number encapsulated in InetSocketAddress object.

  Returns:
    socket address by local instance

### getAddress

    public java.net.InetAddress getAddress()

  Returns multicast address used to "broadcast" controll and supervisory messages over network. Every client should listen on same address as other clients send their messages to address they are configured to listen to.

  Returns:
    InetAddress representing multicast controll address

### getLocalAddress

    public java.net.InetAddress getLocalAddress()

  Returns unicast address of localhost, as in configuration user is allowed to specify unicast address used for data transfer.

  Returns:
    address of this host

### getMaskLength

    public int getMaskLength()

  Returns number of bits used in subnet mask configured on local interface.

  Returns:
    length of subnet mask

### getType

    public int getType()

  Returns integer representing type of local host. Host type can be unknown, notebook or desktop. Type of host is used for calculations of reliability of local host as there is greater probility for notebooks to disconnect from network.

  Returns:
    type of host
  See Also:
    `getTypeDesc()`

### getTypeDesc

    public java.lang.String[] getTypeDesc()

  Returns string descriptions of host types. Used in configuration menus.

  Returns:
    String[] containg descriptions

### getFragmentCount

    public int getFragmentCount()

  Returns number of fragments file will be divided into.

  Returns:
    number of fragments

### getChecksumCount

    public int getChecksumCount()

  Returns number of checksums that will be calculated.

  Returns:
    number of checksums

### getSchedulerConfiguration

    public java.io.File getSchedulerConfiguration()

### usingDefaults

    public boolean usingDefaults()

  Used to determine if default configuration values had to be loaded instead of those stored in configuration file.

  Returns:
    true if and only if configuration file could not be parsed

### getDefaultConfigFile

    public java.io.File getDefaultConfigFile()

  Returns object representation of file in which configuration reader expects configuration to be stored.

  Returns:
    default File that is read for configuration values

### getMaxBackupCount

    public int getMaxBackupCount()

### setMaxSize

    public void setMaxSize(java.lang.String size)

  Sets maximum allowed size of repository folder. Minimum allowed size to be used is 100MB. Meant for reading values from configuration dialog.

  Parameters:
    `size` - value in MB which repository cannot exceed

### setRepositoryFolderPath

    public void setRepositoryFolderPath(java.lang.String folder)

  Sets path to repository folder. Meant for reading values from configuration dialog.

  Parameters:
    `folder` - path to repository folder.

### setPort

    public void setPort(java.lang.String portString)

  Sets port number to be used for networking purpouses. Only range of dynamic port numbers i.e from 49152 to 65534 can be used. Meant for reading values from configuration dialog.

  Parameters:
    `portString` -

### setAddress

    public void setAddress(java.lang.String address)

  Sets multicast address using which other hosts will be contacted. Must be multicast. Meant for reading values from configuration dialog.

  Parameters:
    `address` - String of IP address

### setType

    public void setType(int typeNumber)

  Sets type of local host. Valid values are public constants of this class. Meant for reading values from configuration dialog.

  Parameters:
    `typeNumber` -

### setFragments

    public void setFragments(java.lang.String fragments)

  Sets number of fragments used for checksum calculations during backing up. Meant for reading values from configuration dialog. Backup and Recovery classes are not required to use this value.

  Parameters:
    `fragments` - string representation of number of fragments
  See Also:
    `Backup`, `Recovery`

### setChecksums

    public void setChecksums(java.lang.String checksums)

  Sets number of checksums to be calculated during process of backing up. Meant for reading values from configuration dialog. Backup and Recovery classes are not required to use this value.

  Parameters:
    `checksums` - string representation of number of checksums
  See Also:
    `Backup`, `Recovery`

### configTrouble

    public boolean configTrouble()

  If fallback to default configuration parameters was necessary as result of invalid configuration file, returns true. If reading of configuration was succesfull and no defaults were neccessary, return false.

  Returns:
    true iff configuration file is malformed

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD