ucot.input
Class ProcessMlInputAdapter

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

public class ProcessMlInputAdapter
extends ModuleProperties
implements InputInterface

This InputInterface reads ProcessMl-files and parses usecases from them. References to sub-usecase is stored to usecase's steps. If sub-usecase has no references to it, it is currently discarded.

Author:
vevijopi

Field Summary
 
Fields inherited from class ucot.ModuleProperties
properties, propertiesURL
 
Constructor Summary
ProcessMlInputAdapter()
           
 
Method Summary
 void applyProperties()
          Applies current properties for the module.
 boolean canRead(java.net.URL url)
          Tests if this adapter can read the file.
private  org.w3c.dom.Element getCorrectAbstraction(org.w3c.dom.NodeList abstractions)
          Goes throguh a nodelist containing "abstraction"-named elements and returns the one which has level 0
 java.util.Properties loadDefaultProperties()
          Method which returns the factory default properties for the module.
static void main(java.lang.String[] args)
          Test program used while programming this class
private  void ParseInstanceDetails(org.w3c.dom.Element processInstance, UseCase usecase)
          Parses processInstance's id and adds it to usecase, also checks if this usecase is a subusecase
private  UseCaseStep ParseStep(org.w3c.dom.Node node)
          Parses usecase step from given node and returns it, or null if acceptable one wasn't found
private  boolean ParseSteps(UseCase usecase, org.w3c.dom.NodeList steps)
          Parses steps from given nodelist, stores them to given usecase
 void printNodeList(org.w3c.dom.NodeList a)
          Prints a nodelist, for testing purposes nly..
 UseCaseCollection read(java.net.URL url)
          Parses given usecase.
 java.lang.String toString()
          returns inputs name
 
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
 

Constructor Detail

ProcessMlInputAdapter

public ProcessMlInputAdapter()
Method Detail

read

public UseCaseCollection read(java.net.URL url)
                       throws java.io.IOException
Description copied from interface: InputInterface
Parses given usecase. Stores Parsed data to given ParsedData object.

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

getCorrectAbstraction

private org.w3c.dom.Element getCorrectAbstraction(org.w3c.dom.NodeList abstractions)
Goes throguh a nodelist containing "abstraction"-named elements and returns the one which has level 0

Parameters:
abstractions - list of elements with the name abstraction (from processml)
Returns:
abstraction-element with level 0, or null if none found

ParseSteps

private boolean ParseSteps(UseCase usecase,
                           org.w3c.dom.NodeList steps)
Parses steps from given nodelist, stores them to given usecase

Parameters:
usecase - where steps are stored
steps - nodelist containing the "step"-elements
Returns:
true if everything went ok

ParseStep

private UseCaseStep ParseStep(org.w3c.dom.Node node)
Parses usecase step from given node and returns it, or null if acceptable one wasn't found

Parameters:
node - xml-element that contains a step
Returns:
parsed usecasestep or null

ParseInstanceDetails

private void ParseInstanceDetails(org.w3c.dom.Element processInstance,
                                  UseCase usecase)
Parses processInstance's id and adds it to usecase, also checks if this usecase is a subusecase

Parameters:
processInstance - xml-element to parse the details from
usecase - usecase that was created from processInstance attribute

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 ".xml" If we're adding more xml based inputs, we could verify that the file matches processml.dtd. I didn't implement this, because it could slow down loading (other types of) files a bit.

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

printNodeList

public void printNodeList(org.w3c.dom.NodeList a)
Prints a nodelist, for testing purposes nly..

Parameters:
a - nodelist to print

main

public static void main(java.lang.String[] args)
Test program used while programming this class

Parameters:
args -

toString

public java.lang.String toString()
returns inputs name

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

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()

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()