|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.argouml.uml.generator.Parser
org.argouml.uml.generator.ParserDisplay
This class is responsible for the parsing of the text that the user entered on the display, i.e. the diagram. Consequently, the UML elements represented by the text are created or adapted.
There is a certain relation in namegiving with the class GeneratorDisplay, which generates a textual representation of UML elements for displaying on diagrams.
Nested Class Summary | |
(package private) class |
ParserDisplay.ModelElementInfoList
This class manages a list of UML modelelements that existed before and after the parseXxxxx() function was called. |
Field Summary | |
private Vector |
attributeCustomSep
The vector of CustomSeparators to use when tokenizing attributes. |
private PropertySpecialString[] |
attributeSpecialStrings
The array of special properties for attributes. |
private static Logger |
LOG
The standard error etc. |
private Vector |
operationCustomSep
The vector of CustomSeparators to use when tokenizing attributes. |
private PropertySpecialString[] |
operationSpecialStrings
The array of special properties for operations. |
private Vector |
parameterCustomSep
The vector of CustomSeparators to use when tokenizing parameters. |
static ParserDisplay |
SINGLETON
The one and only ParserDisplay. |
private static String |
VISIBILITYCHARS
The character with a meaning as a visibility at the start of an attribute. |
Constructor Summary | |
private |
ParserDisplay()
Constructs the object contained in SINGLETON and initializes some instance variables. |
Method Summary | |
private Object |
buildNewCallAction(String s)
This builds a CallAction with default attributes. |
private boolean |
compareMsgNumbers(String n1,
String n2)
Compares two message numbers with each other to see if they are equal, in the sense that they refer to the same position in a call tree. |
private int |
countParameters(Object bf)
Counts the number of parameters that are not return values. |
private void |
delete(Object obj)
This deletes modelelements, and swallows null without barking. |
private Collection |
filterWithActivator(Collection c,
Object a)
Finds the messages in Collection c that has message a as activator. |
private Collection |
findCandidateRoots(Collection c,
Object a,
Object veto)
Finds the root candidates in a collection c, ie the messages in c that has the activator a (may be null) and has no predecessor with the same activator. |
private Object |
findMsg(Object r,
String n)
Finds the message in ClassifierRole r that has the message number written in n. |
private static int |
findMsgOrderBreak(String s)
Finds the break between message number and (possibly) message order. |
private Vector |
getOperation(Collection c,
String name,
int params)
Finds the operations in Collection c with name name and params number of parameters. |
private Object |
getStereotype(Object obj,
String name)
Finds a stereotype named name either in the subtree of the model rooted at root, or in the the ProfileJava model. |
private Object |
getType(String name,
Object defaultSpace)
Finds the classifier associated with the type named in name. |
private Object |
getVisibility(String name)
Finds a visibility for the visibility specified by name. |
private boolean |
hasMsgWithActivator(Object r,
Object m)
Examines a collection to see if any message has the given message as an activator. |
private int |
indexOfNextCheckedSemicolon(String s,
int start)
Checks for ';' in Strings or chars in ';' separated tokens in order to return an index to the next attribute or operation substring, -1 otherwise (a ';' inside a String or char delimiters is ignored). |
private void |
insertSuccessor(Object m,
Object s,
int p)
Inserts message s as the p'th successor of message m. |
private boolean |
isBadPreMsg(Object ans,
Object chld)
Examines the call tree from chld to see if ans is an ancestor. |
private boolean |
isMsgNumberStartOf(String n1,
String n2)
Compares two message numbers n1, n2 with each other to determine if n1 specifies a the same position as n2 in a call tree or n1 specifies a position that is a father of the position specified by n2. |
private boolean |
isPredecessorMsg(Object pre,
Object suc,
int md)
Examines the call tree from suc to see if pre is a predecessor. |
Object |
parseActionState(String s,
Object actionState)
An action state figure shows the action expression of the entry action according to the UML spec. |
void |
parseAttribute(String s,
Object attr)
Parse a line on the form: visibility name [: type-expression] [= initial-value] If only one of visibility and name is given, then it is assumed to be the name and the visibility is left unchanged. |
void |
parseAttributeFig(Object cls,
Object at,
String text)
Parse a string representing one ore more ';' separated attributes. |
void |
parseClassifierRole(Object cls,
String s)
Parses a ClassifierRole represented by the following line of the format: baselist := [base] [, base]* classifierRole := [name] [/ role] [: baselist] |
void |
parseComponentInstance(Object coi,
String s)
Parse a line of the form: "name : base-component". |
private void |
parseEffect(Object trans,
String actions)
Handle the Effect (Action) of a Transition. |
Object |
parseExtensionPoint(String text)
Parse a string representing an extension point and return a new extension point. |
void |
parseExtensionPointFig(Object useCase,
Object ep,
String text)
Parse an extension point. |
private void |
parseGuard(Object trans,
String guard)
Handle the Guard of a Transition. |
void |
parseMessage(Object mes,
String s)
Parse a Message textual description. |
void |
parseModelElement(Object me,
String text)
Parses a model element, ie reads a string on the format: |
private static int |
parseMsgOrder(String s)
Parses a message order specification. |
void |
parseNodeInstance(Object noi,
String s)
Parse a line of the form: "name : base-node". |
void |
parseObject(Object obj,
String s)
Parse a textual representatation of an Object, i.e. |
void |
parseObjectFlowState1(String s,
Object objectFlowState)
An objectFlowState is represented on a diagram by 2 strings: 1. |
void |
parseObjectFlowState2(String s,
Object objectFlowState)
An objectFlowState is represented on a diagram by 2 strings: 1. |
void |
parseOperation(String s,
Object op)
Parse a line of text and aligns the MOperation to the specification given. |
void |
parseOperationFig(Object cls,
Object op,
String text)
Parse a string representing one ore more ';' separated operations. |
private void |
parseParamList(Object op,
String param,
int paramOffset)
Parses a parameter list and aligns the parameter list in op to that specified in param. |
void |
parseStateBody(Object st,
String s)
Parse user input for state bodies and assign the individual lines to according actions or transistions. |
private void |
parseStateDoAction(Object st,
String s)
Parse a line of the form: "do /action" and create an action. |
private void |
parseStateEntryAction(Object st,
String s)
Parse a line of the form: "entry /action" and create an action. |
private void |
parseStateExitAction(Object st,
String s)
Parse a line of the form: "exit /action" and create an action. |
void |
parseStimulus(Object sti,
String s)
Parse a line of the form: "name: action". |
Object |
parseTransition(Object trans,
String s)
Parse a transition description line of the form: |
private void |
parseTrigger(Object trans,
String trigger)
Parse the Event that is the trigger of the given transition. |
private Object |
recFindStereotype(Object obj,
Object root,
String name)
Recursively search a hive of a model for a stereotype with the name given in name. |
private void |
setParamKind(Object p,
String s)
|
private void |
setProperties(Object elem,
Vector prop,
PropertySpecialString[] spec)
Applies a Vector of name value pairs of properties to a model element. |
private void |
setReturnParameter(Object op,
Object type)
Sets the return parameter of op to be of type type. |
private Object |
successor(Object r,
int steps)
Finds the steps'th successor of message r in the sense that it is a direct successor of r. |
private void |
updateAction(Object old,
String s)
Update an existing Action with a new Script. |
private Object |
walk(Object r,
int steps,
boolean strict)
Finds the steps'th successor of r in the sense that it is a successor of a successor of r (steps times). |
private Object |
walkTree(Object root,
Vector path)
Walks a call tree from a root node following the directions given in path to a destination node. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final ParserDisplay SINGLETON
private static final Logger LOG
private PropertySpecialString[] attributeSpecialStrings
private Vector attributeCustomSep
private PropertySpecialString[] operationSpecialStrings
private Vector operationCustomSep
private Vector parameterCustomSep
private static final String VISIBILITYCHARS
Constructor Detail |
private ParserDisplay()
SINGLETON
Method Detail |
public void parseExtensionPointFig(Object useCase, Object ep, String text)
The syntax is "name: location", "name:", "location" or "". The fields of the extension point are updated appropriately.
useCase
- The use case that owns this extension pointep
- The extension point concernedtext
- The text to parsepublic void parseModelElement(Object me, String text) throws ParseException
[ << stereotype >>] [name]and assigns the properties to the passed MModelElement.
me
- The ModelElement text describes.text
- A String on the above format.
ParseException
- when it detects an error in the attribute string. See also
ParseError.getErrorOffset().private int indexOfNextCheckedSemicolon(String s, int start)
public void parseOperationFig(Object cls, Object op, String text) throws ParseException
cls
- Classifier The classifier the operation(s) belong toop
- Operation The operation on which the editing happenedtext
- The string to parse
ParseException
- for invalid inputpublic void parseAttributeFig(Object cls, Object at, String text) throws ParseException
cls
- Classifier The classifier the attribute(s) belong toat
- Attribute The attribute on which the editing happenedtext
- The string to parse
ParseException
- for invalid inputpublic Object parseExtensionPoint(String text)
The syntax is "name: location", "name:", "location" or "". Note: If either field is blank, it will be set to null in the extension point. We break up the string into tokens at the ":". We must keep the ":" as a token, so we can distinguish between "name:" and "location". The number of tokens will distinguish our four cases.
TODO: This method needs to be replaced, since it by design cannot cope with the current design of the model component.
parseExtensionPoint
in class Parser
text
- The string to parse
null
if we are given null
or a
blank string. Note. The string ":" can be used to set
both name and location to null.Parser.parseExtensionPoint(java.lang.String)
public void parseOperation(String s, Object op) throws ParseException
A stereotype can be given between any element in the line on the form: <<stereotype>>
The following properties are recognized to have special meaning: abstract, concurrency, concurrent, guarded, leaf, query, root and sequential.
This syntax is compatible with the UML 1.3 spec.
(formerly visibility name (parameter list) : return-type-expression {property-string} ) (formerly 2nd: [visibility] [keywords] returntype name(params)[;] )
parseOperation
in class Parser
s
- The String to parse.op
- The MOperation to adjust to the spcification in s.
ParseException
- when it detects an error in the attribute string. See also
ParseError.getErrorOffset().Parser.parseOperation(java.lang.String,
java.lang.Object)
private void parseParamList(Object op, String param, int paramOffset) throws ParseException
param := [inout] [name] [: type] [= initial value] list := [param] [, param]*inout is optional and if omitted the old value preserved. If no value has been assigned, then in is assumed.
This syntax is compatible with the UML 1.3 specification.
op
- The operation the parameter list belongs to.param
- The parameter list, without enclosing parentheses.paramOffset
- The offset to the beginning of the parameter list. Used for
error reports.
ParseException
- when it detects an error in the attribute string. See also
ParseError.getErrorOffset().private void setReturnParameter(Object op, Object type)
private void setParamKind(Object p, String s)
public void parseAttribute(String s, Object attr) throws ParseException
The following properties are recognized to have special meaning: frozen.
This syntax is compatible with the UML 1.3 spec. (formerly: visibility name [multiplicity] : type-expression = initial-value {property-string} ) (2nd formerly: [visibility] [keywords] type name [= init] [;] )
parseAttribute
in class Parser
s
- The String to parse.attr
- The attribute to modify to comply with the instructions in s.
ParseException
- when it detects an error in the attribute string. See also
ParseError.getErrorOffset().Parser.parseAttribute(java.lang.String,
java.lang.Object)
private Object getType(String name, Object defaultSpace)
name
- The name of the type to get.defaultSpace
- The default name-space to place the type in.
private Object getVisibility(String name)
name
- The Java name of the visibility.
private void setProperties(Object elem, Vector prop, PropertySpecialString[] spec)
elem
- An model element to apply the properties to.prop
- A Vector with name, value pairs of properties.spec
- An array of PropertySpecialStrings to use.private Object recFindStereotype(Object obj, Object root, String name)
obj
- The model element to be suitable for.root
- The model element to search from.name
- The name of the stereotype to search for.
private Object getStereotype(Object obj, String name)
TODO: Should create the stereotype under root if it isn't found.
obj
- A MModelElements to find a suitable stereotype for.name
- The name of the stereotype to search for.
public void parseStateBody(Object st, String s) throws ParseException
"action-label" stands for one of "entry", "do" and "exit". The words "entry", "do" and "exit" are case-independent.
st
- The State object.s
- The string to parse.
ParseException
- when there is a syntax problem,
e.g. non-matching brackets () or []private void parseStateEntryAction(Object st, String s)
st
- the state objects
- the string to be parsedprivate void parseStateExitAction(Object st, String s)
st
- the state objects
- the string to be parsedprivate void parseStateDoAction(Object st, String s)
st
- the state objects
- the string to be parsedpublic Object parseTransition(Object trans, String s) throws ParseException
"event-signature [guard-condition] / action-expression".If the last character of this line is a ";", then it is ignored.
The "event-signature" may be one of the 4 formats:
An alternative solution would be to create a CallEvent by default, and when editing an existing event, do not change the type.
TODO: This function fails when the event-signature contains a "[" or a "/".
parseTransition
in class Parser
trans
- the transition object to which this string appliess
- the string to be parsed
ParseException
- when no matching [] are foundParser.parseTransition(java.lang.Object,
java.lang.String)
private void parseTrigger(Object trans, String trigger) throws ParseException
trans
- the transition which is triggered by the given eventtrigger
- the given trigger
ParseException
private void parseGuard(Object trans, String guard)
We can distinct between 4 cases:
1. A guard is given. None exists yet.
2. The expression of the guard was present, but is altered.
3. A guard is not given. None exists yet.
4. The expression of the guard was present, but is removed.
The reaction in these cases should be:
trans
- the UML element transitionguard
- the string that represents the guard expressionprivate void parseEffect(Object trans, String actions)
actions
- the string to be parsedtrans
- the transition that causes the effect (actions)public void parseClassifierRole(Object cls, String s) throws ParseException
role and baselist can be given in any order.
This syntax is compatible with the UML 1.3 specification. (formerly: "name: base" )
cls
- the classifier role to apply any changes tos
- the String to parse
ParseException
- when it detects an error in the attribute string. See also
ParseError.getErrorOffset().public void parseMessage(Object mes, String s) throws ParseException
TODO: - This method is too complex, lets break it up. Parses a message line on the form:
intno := integer|name seq := intno ['.' intno]* recurrance := '*'['//'] | '*'['//']'[' iteration ']' | '[' condition ']' seqelem := {[intno] ['['recurrance']']} seq2 := seqelem ['.' seqelem]* ret_list := lvalue [',' lvalue]* arg_list := rvalue [',' rvalue]* message := [seq [',' seq]* '/'] seq2 ':' [ret_list :=] name ([arg_list])Which is rather complex, so a few examples:
Actually, only a subset of this syntax is currently supported, and some is not even planned to be supported. The exceptions are intno, which allows a number possibly followed by a sequence of letters in the range 'a' - 'z', seqelem, which does not allow a recurrance, and message, which does allow one recurrance near seq2. (formerly: name: action )
mes
- the MMessage to apply any changes tos
- the String to parse
ParseException
- when it detects an error in the attribute string. See also
ParseError.getErrorOffset().private boolean isBadPreMsg(Object ans, Object chld)
ans
- MMessagechld
- MMessageprivate boolean isPredecessorMsg(Object pre, Object suc, int md)
pre
- MMessagesuc
- MMessageprivate Object walkTree(Object root, Vector path)
root
- The root of the call tree.path
- The path to walk in the call tree.
null
.private boolean hasMsgWithActivator(Object r, Object m)
r
- MClassifierRolem
- MMessageprivate void insertSuccessor(Object m, Object s, int p)
m
- MMessages
- MMessageprivate Object successor(Object r, int steps)
private Object walk(Object r, int steps, boolean strict)
private Collection findCandidateRoots(Collection c, Object a, Object veto)
c
- The collection.a
- The message.veto
- The veto message.
private Collection filterWithActivator(Collection c, Object a)
private Object findMsg(Object r, String n)
private boolean compareMsgNumbers(String n1, String n2)
private boolean isMsgNumberStartOf(String n1, String n2)
private Vector getOperation(Collection c, String name, int params)
c
- the collection of operations to be searchedname
- the name of the operation to be foundparams
- the number of parameters of the operation to be found
private int countParameters(Object bf)
private static int parseMsgOrder(String s)
private static int findMsgOrderBreak(String s)
public void parseStimulus(Object sti, String s)
sti
- the stimulus object to which the string appliess
- the string to be parsed.public void parseObject(Object obj, String s)
obj
- the UML Object to be parsed.s
- the string to be parsed.public void parseNodeInstance(Object noi, String s)
noi
- the node instance on which the string applies.s
- the string to be parsed.public void parseComponentInstance(Object coi, String s)
coi
- the component instance on which the string applies.s
- the string to parse.private Object buildNewCallAction(String s)
s
- string representing the Script of the Actionprivate void updateAction(Object old, String s)
old
- the Actions
- a string representing a new Script for the ActionExpressionprivate void delete(Object obj)
obj
- the modelelement to be deletedpublic Object parseActionState(String s, Object actionState)
parseActionState
in class Parser
actionState
- the input actionstates
- the input string
Parser.parseActionState(
java.lang.String, java.lang.Object)
public void parseObjectFlowState1(String s, Object objectFlowState) throws ParseException
s
- the string to be parsedobjectFlowState
- the input object
ParseException
- when the input should be rejected
(i.e. when the classifier does not exist)public void parseObjectFlowState2(String s, Object objectFlowState) throws ParseException
s
- the string to be parsedobjectFlowState
- the input object
ParseException
- when the input should be rejected
(i.e. when the classifier or the state do not exist)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ArgoUML © 1996-2004 (20050222) | ArgoUML Homepage | ArgoUML Developers' page | ArgoUML Cookbook |