ucot.input
Class ProcessMlInputAdapter

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

public class ProcessMlInputAdapter
extends java.lang.Object
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
private  java.util.Properties options
           
 
Constructor Summary
ProcessMlInputAdapter()
           
 
Method Summary
 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 getOptions()
          Returns adapter's options
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.
 void setOptions(java.util.Properties options)
          Sets options for the adapter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

options

private java.util.Properties options
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

setOptions

public void setOptions(java.util.Properties options)
Description copied from interface: InputInterface
Sets options for the adapter

Specified by:
setOptions in interface InputInterface
Parameters:
options - options for the adapter

getOptions

public java.util.Properties getOptions()
Description copied from interface: InputInterface
Returns adapter's options

Specified by:
getOptions in interface InputInterface
Returns:
adapter's options

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 -