org.argouml.persistence
Class PGMLParser

java.lang.Object
  extended byorg.xml.sax.helpers.DefaultHandler
      extended byorg.tigris.gef.xml.pgml.PGMLParser
          extended byorg.argouml.persistence.PGMLParser
All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler

public class PGMLParser
extends org.tigris.gef.xml.pgml.PGMLParser

The PGML parser.


Nested Class Summary
protected  class PGMLParser.NameVal
          Utility class to pair a name and a value String together.
 
Field Summary
private  String[] entityPaths
           
private  org.tigris.gef.presentation.Fig figGroup
          HACK to handle issue 2719.
private static Logger LOG
           
private  boolean nestedGroupFlag
          HACK to handle issue 2719.
private  org.tigris.gef.presentation.FigNode previousNode
           
private  StringBuffer privateText
           
private  int privateTextDepth
           
private  HashMap translationTable
           
 
Fields inherited from class org.tigris.gef.xml.pgml.PGMLParser
_currentEdge, _currentEncloser, _currentLine, _currentNode, _currentPoly, _detectedFailure, _diagram, _elementState, _figRegistry, _nestedGroups, _ownerRegistry, _textBuf, _x1Int, _y1Int, ANNOTATION_EDGE_STATE, ANNOTATION_STATE, DEFAULT_EDGE_STATE, DEFAULT_NODE_STATE, DEFAULT_STATE, EDGE_STATE, LINE_STATE, NODE_STATE, POLY_EDGE_STATE, POLY_NODE_STATE, POLY_STATE, PRIVATE_EDGE_STATE, PRIVATE_NODE_STATE, PRIVATE_STATE, systemId, TEXT_ANNOTATION_STATE, TEXT_EDGE_STATE, TEXT_NODE_STATE, TEXT_STATE
 
Constructor Summary
PGMLParser(Map modelElementsByUuid)
          Constructor.
 
Method Summary
 void addTranslation(String from, String to)
           
 void characters(char[] ch, int start, int length)
           
 void endElement(String uri, String localname, String name)
           
protected  org.tigris.gef.presentation.Fig findFig(String uri)
           
protected  String[] getEntityPaths()
           
private  Object getModelElement(Attributes attrList)
          Return the model element being referred to by interogating the attributes of the XML group node.
protected  org.tigris.gef.presentation.Fig handleGroup(Attributes attrList)
           
protected  void handlePGML(Attributes attrList)
           
private  Map interpretStyle(StringTokenizer st)
          The StringTokenizer is expected to be positioned at the start a a string of style identifiers in the format name=value;name=value;name=value....
private  boolean isAttributesXml(Attributes attrList)
           
private  boolean isOperationsXml(Attributes attrList)
           
protected  void privateStateEndElement(String tagName)
           
 org.tigris.gef.base.Diagram readDiagram(InputStream is, boolean closeStream)
           
protected  void setElementItemUID(String id)
          Sets the ItemUID value of the current element in the file.
private  void setStyleAttributes(org.tigris.gef.presentation.Fig fig, Map attributeMap)
          Set the fig style attributes.
protected  PGMLParser.NameVal splitNameVal(String str)
          Splits a name value pair into a NameVal instance.
 void startElement(String uri, String localname, String elementName, Attributes attrList)
           
protected  String translateClassName(String oldName)
           
 
Methods inherited from class org.tigris.gef.xml.pgml.PGMLParser
annotationStateStartElement, colorByName, edgeStateStartElement, findOwner, getGraphModelFor, getSystemId, handleEllipse, handleLine, handlePath, handlePolyLine, handleRect, handleText, initDiagram, lineStateStartElement, nodeStateStartElement, polyStateStartElement, readDiagram, readDiagram, resolveEntity, rollbackAdd, setAttrs, setDetectedFailure, setOwnerAttr, setSystemId
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nestedGroupFlag

private boolean nestedGroupFlag
HACK to handle issue 2719.


figGroup

private org.tigris.gef.presentation.Fig figGroup
HACK to handle issue 2719.


LOG

private static final Logger LOG

privateTextDepth

private int privateTextDepth

privateText

private StringBuffer privateText

translationTable

private HashMap translationTable

entityPaths

private String[] entityPaths

previousNode

private org.tigris.gef.presentation.FigNode previousNode
Constructor Detail

PGMLParser

public PGMLParser(Map modelElementsByUuid)
Constructor.

Parameters:
modelElementsByUuid - a map of model elements indexed by a unique string identifier.
Method Detail

addTranslation

public void addTranslation(String from,
                           String to)
Parameters:
from - the class name to be "translated", i.e. replaced by something else
to - the resulting name

translateClassName

protected String translateClassName(String oldName)
See Also:
PGMLParser.translateClassName(java.lang.String)

getEntityPaths

protected String[] getEntityPaths()
See Also:
PGMLParser.getEntityPaths()

startElement

public void startElement(String uri,
                         String localname,
                         String elementName,
                         Attributes attrList)
                  throws SAXException
Throws:
SAXException
See Also:
Called by the XML framework when an entity starts.

isAttributesXml

private boolean isAttributesXml(Attributes attrList)

isOperationsXml

private boolean isOperationsXml(Attributes attrList)

characters

public void characters(char[] ch,
                       int start,
                       int length)
See Also:
Called by the PGML framework when there are characters inside an XML entity. We need to save them if it would turn out to be a private entity.

setElementItemUID

protected void setElementItemUID(String id)
Sets the ItemUID value of the current element in the file.

Parameters:
id - the given id

splitNameVal

protected PGMLParser.NameVal splitNameVal(String str)
Splits a name value pair into a NameVal instance. A name value pair is a String on the form < name = ["] value ["] >.

Parameters:
str - A String with a name value pair.
Returns:
A NameVal, or null if they could not be split.

readDiagram

public org.tigris.gef.base.Diagram readDiagram(InputStream is,
                                               boolean closeStream)
See Also:
PGMLParser.readDiagram( java.io.InputStream, boolean)

endElement

public void endElement(String uri,
                       String localname,
                       String name)
                throws SAXException
Throws:
SAXException
See Also:
ContentHandler.endElement( java.lang.String, java.lang.String, java.lang.String)

handleGroup

protected org.tigris.gef.presentation.Fig handleGroup(Attributes attrList)
See Also:
This is a correct implementation of handleGroup and will add FigGroups to the diagram ONLY if they are not a FigNode AND if they are not part of a FigNode.

setStyleAttributes

private void setStyleAttributes(org.tigris.gef.presentation.Fig fig,
                                Map attributeMap)
Set the fig style attributes. This should move into the render factories as described in issue 859.

Parameters:
fig - the fig to style.
attributeMap - a map of name value pairs

getModelElement

private Object getModelElement(Attributes attrList)
Return the model element being referred to by interogating the attributes of the XML group node.

Parameters:
attrList - a collection of name value pairs

interpretStyle

private Map interpretStyle(StringTokenizer st)
The StringTokenizer is expected to be positioned at the start a a string of style identifiers in the format name=value;name=value;name=value.... Each name value pair is interpreted and the Fig configured accordingly. The value is optional and will default to a value applicable for its name. The current applicable names are operationsVisible and attributesVisible and are used to show or hide the compartments within Class and Interface. The default values are true.

Parameters:
st - The StrinkTokenizer positioned at the first style identifier
Returns:
a map of attributes

handlePGML

protected void handlePGML(Attributes attrList)
See Also:
PGMLParser.handlePGML(org.xml.sax.Attributes)

privateStateEndElement

protected void privateStateEndElement(String tagName)
See Also:
PGMLParser.privateStateEndElement(java.lang.String)

findFig

protected org.tigris.gef.presentation.Fig findFig(String uri)
See Also:
PGMLParser.findFig(java.lang.String)


ArgoUML © 1996-2004 (20050222)ArgoUML HomepageArgoUML Developers' pageArgoUML Cookbook