be.ac.vub.cocompose.io.xmi
Class XMIModelLinkReader

java.lang.Object
  extended byorg.xml.sax.helpers.DefaultHandler
      extended bybe.ac.vub.cocompose.io.xmi.XMIModelLinkReader
All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler

public class XMIModelLinkReader
extends DefaultHandler

Reads the links in a CoCompose model from an XMI file (requires first pass by XMIModelReader).

Since:
0.2.0
Version:
0.2.10, 11/05/2004
Author:
Dennis Wagelaar

Constructor Summary
XMIModelLinkReader(Model model, Map elementMap)
          Creates an XMIModelLinkReader
 
Method Summary
 void characters(char[] ch, int start, int length)
          Characters.
 void endCoComposeElement(String local)
          Start CoCompose element.
 void endElement(String uri, String local, String raw)
          End element.
 void endOwnedElement()
          Parses an ownedElement tag
 void endXMIElement(String local)
          End XMI element.
 Concept getConcept()
          Gets the last parsed concept.
 ModelElement getElement()
          Gets the last parsed element.
 Map getElementMap()
          Gets the mapping of IDs to elements.
 XMIElementLinkAttributesReader getElementReader()
          Gets the attribute reader.
protected  ModelElement getFromRef(Attributes attrs)
          Gets a ModelElement by IDREF or HREF attribute.
 Model getModel()
          Gets the last parsed model.
 ModelProperty getModelProperty()
          Gets the last parsed model property.
 Namespace getNamespace()
          Gets the last parsed namespace.
 RefinedElement getRefinedElement()
          Gets the last parsed refined element.
 Relationship getRelationship()
          Gets the last parsed relationship.
 Role getRole()
          Gets the last parsed role.
 SolutionPattern getSolutionPattern()
          Gets the last parsed solution pattern.
 void ignorableWhitespace(char[] ch, int start, int length)
          Ignorable whitespace.
 void notationDecl(String name, String publicId, String systemId)
          DTD declaration.
 void processingInstruction(String target, String data)
          Processing instruction.
protected  void setConcept(Concept concept)
          Sets the last parsed concept.
protected  void setElement(ModelElement element)
          Sets the last parsed element.
protected  void setElementMap(Map elementMap)
          Sets the mapping of IDs to elements.
protected  void setElementReader(XMIElementLinkAttributesReader elementReader)
          Sets the attribute reader.
protected  void setModel(Model model)
          Sets the last parsed model.
protected  void setModelProperty(ModelProperty property)
          Sets the last parsed model property.
protected  void setNamespace(Namespace namespace)
          Sets the last parsed namespace.
protected  void setRefinedElement(RefinedElement refinedElement)
          Sets the last parsed refined element.
protected  void setRelationship(Relationship relationship)
          Sets the last parsed relationship.
protected  void setRole(Role role)
          Sets the last parsed role.
protected  void setSolutionPattern(SolutionPattern pattern)
          Sets the last parsed solution pattern.
 void startCoComposeElement(String local, Attributes attrs)
          Start CoCompose element.
 void startDocument()
          Start document.
 void startElement(String uri, String local, String raw, Attributes attrs)
          Start element.
 void startInheritsFrom(Attributes attrs)
          Parses an inheritsFrom tag.
 void startOwnedElement(Attributes attrs)
          Parses an ownedElement tag
 void startPart(Attributes attrs)
          Parses a part tag.
 void startParticipant(Attributes attrs)
          Parses a participant tag
 void startPartOf(Attributes attrs)
          Parses a partOf tag.
 void startSolutionModel(Attributes attrs)
          Parses a solutionModel tag.
 void startSuperimposesOn(Attributes attrs)
          Parses a superimposesOn tag.
 void startTargetModel(Attributes attrs)
          Parses a targetModel tag.
 void startXMIElement(String local, Attributes attrs)
          Start XMI element.
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, error, fatalError, resolveEntity, setDocumentLocator, skippedEntity, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMIModelLinkReader

public XMIModelLinkReader(Model model,
                          Map elementMap)
                   throws ModelElementException
Creates an XMIModelLinkReader

Parameters:
model - the model after one pass by XMIModelReader
elementMap - the map of id -> element
Method Detail

processingInstruction

public void processingInstruction(String target,
                                  String data)
                           throws SAXException
Processing instruction.

Parameters:
target - Processing instruction element name.
data - Processing instruction element data.
Throws:
SAXException

startDocument

public void startDocument()
                   throws SAXException
Start document.

Throws:
SAXException

startElement

public void startElement(String uri,
                         String local,
                         String raw,
                         Attributes attrs)
                  throws SAXException
Start element.

Parameters:
uri - XML namespace URI.
local - local element name.
raw - raw (qualified) element name.
attrs - element attributes.
Throws:
SAXException

startXMIElement

public void startXMIElement(String local,
                            Attributes attrs)
                     throws SAXException
Start XMI element.

Parameters:
local - local element name.
attrs - element attributes.
Throws:
SAXException

startCoComposeElement

public void startCoComposeElement(String local,
                                  Attributes attrs)
                           throws SAXException
Start CoCompose element.

Parameters:
local - local element name.
attrs - element attributes.
Throws:
SAXException

startOwnedElement

public void startOwnedElement(Attributes attrs)
                       throws ModelElementException
Parses an ownedElement tag

Parameters:
attrs - element attributes
Throws:
ModelElementException

startParticipant

public void startParticipant(Attributes attrs)
                      throws ModelElementException
Parses a participant tag

Parameters:
attrs - element attributes
Throws:
ModelElementException

startPartOf

public void startPartOf(Attributes attrs)
                 throws ModelElementException
Parses a partOf tag.

Parameters:
attrs - element attributes.
Throws:
ModelElementException.
ModelElementException

startPart

public void startPart(Attributes attrs)
               throws ModelElementException
Parses a part tag.

Parameters:
attrs - element attributes.
Throws:
ModelElementException.
ModelElementException

startInheritsFrom

public void startInheritsFrom(Attributes attrs)
                       throws ModelElementException
Parses an inheritsFrom tag.

Parameters:
attrs - element attributes.
Throws:
ModelElementException.
ModelElementException

startSuperimposesOn

public void startSuperimposesOn(Attributes attrs)
                         throws ModelElementException
Parses a superimposesOn tag.

Parameters:
attrs - element attributes.
Throws:
ModelElementException.
ModelElementException

startSolutionModel

public void startSolutionModel(Attributes attrs)
                        throws ModelElementException
Parses a solutionModel tag.

Parameters:
attrs - element attributes.
Throws:
ModelElementException.
ModelElementException

startTargetModel

public void startTargetModel(Attributes attrs)
                      throws ModelElementException
Parses a targetModel tag.

Parameters:
attrs - element attributes.
Throws:
ModelElementException.
ModelElementException

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws SAXException
Characters.

Parameters:
ch - Characters to print.
start - Starting index of characters.
length - Length of characters.
Throws:
SAXException

ignorableWhitespace

public void ignorableWhitespace(char[] ch,
                                int start,
                                int length)
                         throws SAXException
Ignorable whitespace.

Parameters:
ch - Characters to print.
start - Starting index of characters.
length - Length of characters.
Throws:
SAXException

endElement

public void endElement(String uri,
                       String local,
                       String raw)
                throws SAXException
End element.

Parameters:
uri - Ignored.
local - Ignored.
raw - Element name.
Throws:
SAXException

endXMIElement

public void endXMIElement(String local)
                   throws SAXException
End XMI element.

Parameters:
local - local element name.
Throws:
SAXException

endCoComposeElement

public void endCoComposeElement(String local)
                         throws SAXException
Start CoCompose element.

Parameters:
local - local element name.
Throws:
SAXException

endOwnedElement

public void endOwnedElement()
                     throws ModelElementException
Parses an ownedElement tag

Throws:
ModelElementException

notationDecl

public void notationDecl(String name,
                         String publicId,
                         String systemId)
                  throws SAXException
DTD declaration.

Parameters:
name - DTD name.
publicId - DTD public ID.
systemId - DTD system ID.
Throws:
SAXException

setConcept

protected void setConcept(Concept concept)
Sets the last parsed concept.

Parameters:
concept - the last parsed concept.

getConcept

public Concept getConcept()
Gets the last parsed concept.

Returns:
the last parsed concept.

setElement

protected void setElement(ModelElement element)
Sets the last parsed element.

Parameters:
element - the last parsed element.

getElement

public ModelElement getElement()
Gets the last parsed element.

Returns:
the last parsed element.

setElementMap

protected void setElementMap(Map elementMap)
Sets the mapping of IDs to elements.

Parameters:
elementMap - the mapping of IDs to elements.

getElementMap

public Map getElementMap()
Gets the mapping of IDs to elements.

Returns:
the mapping of IDs to elements.

setElementReader

protected void setElementReader(XMIElementLinkAttributesReader elementReader)
Sets the attribute reader.

Parameters:
elementReader - the attribute reader.

getElementReader

public XMIElementLinkAttributesReader getElementReader()
Gets the attribute reader.

Returns:
the attribute reader.

setModel

protected void setModel(Model model)
Sets the last parsed model.

Parameters:
model - the last parsed model.

getModel

public Model getModel()
Gets the last parsed model.

Returns:
the last parsed model.

setNamespace

protected void setNamespace(Namespace namespace)
Sets the last parsed namespace.

Parameters:
namespace - the last parsed namespace.

getNamespace

public Namespace getNamespace()
Gets the last parsed namespace.

Returns:
the last parsed namespace.

setRelationship

protected void setRelationship(Relationship relationship)
Sets the last parsed relationship.

Parameters:
relationship - the last parsed relationship.

getRelationship

public Relationship getRelationship()
Gets the last parsed relationship.

Returns:
the last parsed relationship.

setRole

protected void setRole(Role role)
Sets the last parsed role.

Parameters:
role - the last parsed role.

getRole

public Role getRole()
Gets the last parsed role.

Returns:
the last parsed role.

setRefinedElement

protected void setRefinedElement(RefinedElement refinedElement)
Sets the last parsed refined element.

Parameters:
refinedElement - the last parsed refined element.

getRefinedElement

public RefinedElement getRefinedElement()
Gets the last parsed refined element.

Returns:
the last parsed refined element.

getSolutionPattern

public SolutionPattern getSolutionPattern()
Gets the last parsed solution pattern.

Returns:
the last parsed solution pattern.

setSolutionPattern

protected void setSolutionPattern(SolutionPattern pattern)
Sets the last parsed solution pattern.

Parameters:
pattern - the last parsed solution pattern.

getModelProperty

public ModelProperty getModelProperty()
Gets the last parsed model property.

Returns:
the last parsed model property.

setModelProperty

protected void setModelProperty(ModelProperty property)
Sets the last parsed model property.

Parameters:
property - the last parsed model property.

getFromRef

protected ModelElement getFromRef(Attributes attrs)
                           throws ModelElementException
Gets a ModelElement by IDREF or HREF attribute.

Parameters:
attrs - the XML attributes.
Returns:
the ModelElement, or null if not found.
Throws:
ModelElementException - if no idref or href attribute is found or if no model element is found.