ucot.input
Class SimpleInputAdapter

java.lang.Object
  extended by ucot.ModuleProperties
      extended by ucot.input.SimpleInputAdapter
All Implemented Interfaces:
InputInterface, ModulePropertyInterface

public class SimpleInputAdapter
extends ModuleProperties
implements InputInterface

Input adapter for the simple input format. Reads usecases that are stored in this format:

 
 
 [name]
 Name of the usecase is here
 [id]
 Id of the usecase (must be unique within file, it is discarded after loading) 
 [steps]
 Steps separated with linebreak. Step can have a sub-usecase, it is marked with (usecaseid) after the steps description and "."-character.
 [end]
 Use case ends with [end] tag, another usecase can begin with [name] element now
 
 

Author:
pajumasu & vevijopi

Field Summary
static java.lang.String name
           
 
Fields inherited from class ucot.ModuleProperties
properties, propertiesURL
 
Constructor Summary
SimpleInputAdapter()
           
 
Method Summary
 void applyProperties()
          Applies current properties for the module.
 boolean canRead(java.net.URL url)
          Tests if this adapter can read the file.
 java.lang.String getName()
          Returns the name of this adapter
 java.util.Properties loadDefaultProperties()
          Method which returns the factory default properties for the module.
private  UseCaseStep parseStep(java.lang.String line)
          Parses usecase step from given line.
 UseCaseCollection read(java.net.URL url)
          Reads usecase collection from URL.
 UseCase readUseCase(java.io.BufferedReader reader, java.net.URL url)
          Reads a single usecase from given reader, sets it's url to given one
 void readUseCases(java.io.BufferedReader reader, UseCaseCollection collection, java.net.URL url)
          Reads usecases from given reader, stores them to given collection and sets their url to given one.
 java.lang.String toString()
          Returns inputs name as a String
 
Methods inherited from class ucot.ModuleProperties
getProperties, loadProperties, saveProperties, setProperties
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ucot.ModulePropertyInterface
getProperties, loadProperties, saveProperties, setProperties
 

Field Detail

name

public static final java.lang.String name
See Also:
Constant Field Values
Constructor Detail

SimpleInputAdapter

public SimpleInputAdapter()
Method Detail

getName

public java.lang.String getName()

Returns the name of this adapter

Returns:
name of this adapter

read

public UseCaseCollection read(java.net.URL url)
                       throws java.io.IOException
Description copied from interface: InputInterface

Reads usecase collection from URL.

Specified by:
read in interface InputInterface
Parameters:
url - URL where input is loaded from
Returns:
Steps read from the input
Throws:
java.io.IOException

readUseCases

public void readUseCases(java.io.BufferedReader reader,
                         UseCaseCollection collection,
                         java.net.URL url)
                  throws java.io.IOException

Reads usecases from given reader, stores them to given collection and sets their url to given one.

Parameters:
reader - reader for the inputstream
collection - where all found usecases are stored
url - url for the usecase
Throws:
java.io.IOException

readUseCase

public UseCase readUseCase(java.io.BufferedReader reader,
                           java.net.URL url)
                    throws java.io.IOException

Reads a single usecase from given reader, sets it's url to given one

Parameters:
reader - reader to read usecases with
url - url for the usecases
Returns:
read new usecase or null if error encountered
Throws:
java.io.IOException

parseStep

private UseCaseStep parseStep(java.lang.String line)

Parses usecase step from given line. Also stores relation id

Parameters:
line -
Returns:
parsed usecasestep

canRead

public boolean canRead(java.net.URL url)

Tests if this adapter can read the file. For now, only test is that the file ends with ".txt"

Specified by:
canRead in interface InputInterface
Parameters:
url - url of the file to test
Returns:
true if this adapter can read the file

toString

public java.lang.String toString()
Description copied from interface: InputInterface

Returns inputs name as a String

Specified by:
toString in interface InputInterface
Overrides:
toString in class java.lang.Object
Returns:
name of this input

loadDefaultProperties

public java.util.Properties loadDefaultProperties()
Description copied from interface: ModulePropertyInterface

Method which returns the factory default properties for the module.

Specified by:
loadDefaultProperties in interface ModulePropertyInterface
Overrides:
loadDefaultProperties in class ModuleProperties
Returns:
Default properties.
See Also:
ModulePropertyInterface.loadDefaultProperties()

applyProperties

public void applyProperties()
                     throws BadPropertyValueException
Description copied from interface: ModulePropertyInterface

Applies current properties for the module.

Specified by:
applyProperties in interface ModulePropertyInterface
Overrides:
applyProperties in class ModuleProperties
Throws:
BadPropertyValueException - In this case exception is thrown only if either the given parser or heuristic does not exist.
See Also:
ModulePropertyInterface.applyProperties()