Author: tfmorris
Date: 2007-12-21 01:28:02-0800
New Revision: 13963
Modified:
trunk/src/model-mdr/src/org/argouml/model/mdr/CommonBehaviorHelperMDRImpl.java
trunk/src/model-mdr/src/org/argouml/model/mdr/CoreHelperMDRImpl.java
trunk/src/model-mdr/src/org/argouml/model/mdr/ExtensionMechanismsFactoryMDRImpl.java
trunk/src/model-mdr/src/org/argouml/model/mdr/ExtensionMechanismsHelperMDRImpl.java
Log:
Issue 4953 - Extend tagged value API to support multiple dataValues
Modified: trunk/src/model-mdr/src/org/argouml/model/mdr/CommonBehaviorHelperMDRImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/model-mdr/src/org/argouml/model/mdr/CommonBehaviorHelperMDRImpl.java?view=diff&rev=13963&p1=trunk/src/model-mdr/src/org/argouml/model/mdr/CommonBehaviorHelperMDRImpl.java&p2=trunk/src/model-mdr/src/org/argouml/model/mdr/CommonBehaviorHelperMDRImpl.java&r1=13962&r2=13963
==============================================================================
--- trunk/src/model-mdr/src/org/argouml/model/mdr/CommonBehaviorHelperMDRImpl.java (original)
+++ trunk/src/model-mdr/src/org/argouml/model/mdr/CommonBehaviorHelperMDRImpl.java 2007-12-21 01:28:02-0800
@@ -538,8 +538,8 @@
return;
}
if (handle instanceof TaggedValue && value instanceof String) {
- modelImpl.getExtensionMechanismsHelper().setValueOfTag(handle,
- (String) value);
+ modelImpl.getExtensionMechanismsHelper().setDataValues(handle,
+ new String[] {(String) value});
return;
}
throw new IllegalArgumentException("handle: " + handle + ", value:"
Modified: trunk/src/model-mdr/src/org/argouml/model/mdr/CoreHelperMDRImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/model-mdr/src/org/argouml/model/mdr/CoreHelperMDRImpl.java?view=diff&rev=13963&p1=trunk/src/model-mdr/src/org/argouml/model/mdr/CoreHelperMDRImpl.java&p2=trunk/src/model-mdr/src/org/argouml/model/mdr/CoreHelperMDRImpl.java&r1=13962&r2=13963
==============================================================================
--- trunk/src/model-mdr/src/org/argouml/model/mdr/CoreHelperMDRImpl.java (original)
+++ trunk/src/model-mdr/src/org/argouml/model/mdr/CoreHelperMDRImpl.java 2007-12-21 01:28:02-0800
@@ -2969,16 +2969,16 @@
public void setTaggedValue(Object handle, String tag, String value) {
if (handle instanceof ModelElement) {
TaggedValue tv =
- (TaggedValue) modelImpl.getFacade().
- getTaggedValue(handle, tag);
+ (TaggedValue) modelImpl.getFacade().getTaggedValue(handle,
+ tag);
if (tv == null) {
tv =
(TaggedValue) modelImpl.getExtensionMechanismsFactory().
buildTaggedValue(tag, value);
((ModelElement) handle).getTaggedValue().add(tv);
} else {
- modelImpl.getExtensionMechanismsHelper().setValueOfTag(tv,
- value);
+ modelImpl.getExtensionMechanismsHelper().setDataValues(tv,
+ new String[] {value});
}
return;
}
Modified: trunk/src/model-mdr/src/org/argouml/model/mdr/ExtensionMechanismsFactoryMDRImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/model-mdr/src/org/argouml/model/mdr/ExtensionMechanismsFactoryMDRImpl.java?view=diff&rev=13963&p1=trunk/src/model-mdr/src/org/argouml/model/mdr/ExtensionMechanismsFactoryMDRImpl.java&p2=trunk/src/model-mdr/src/org/argouml/model/mdr/ExtensionMechanismsFactoryMDRImpl.java&r1=13962&r2=13963
==============================================================================
--- trunk/src/model-mdr/src/org/argouml/model/mdr/ExtensionMechanismsFactoryMDRImpl.java (original)
+++ trunk/src/model-mdr/src/org/argouml/model/mdr/ExtensionMechanismsFactoryMDRImpl.java 2007-12-21 01:28:02-0800
@@ -209,17 +209,31 @@
}
+ @Deprecated
public TaggedValue buildTaggedValue(String tag, String value) {
- TaggedValue tv = createTaggedValue();
- TagDefinition td = getTagDefinition(tag);
- tv.setType(td);
- // TODO: Some CASE tools appear to manage only one
- // dataValue. This is an array of String according to the
- // UML 1.4 specs.
+ TaggedValue tv = buildTaggedValue(getTagDefinition(tag));
tv.getDataValue().add(value);
return tv;
}
+ private TaggedValue buildTaggedValue(TagDefinition type) {
+ TaggedValue tv = createTaggedValue();
+ tv.setType(type);
+ return tv;
+ }
+
+ public TaggedValue buildTaggedValue(Object type, String[] values) {
+ if (!(type instanceof TagDefinition)) {
+ throw new IllegalArgumentException(
+ "TagDefinition required, received - " + type);
+ }
+ TaggedValue tv = buildTaggedValue((TagDefinition) type);
+ for (String value : values) {
+ tv.getDataValue().add(value);
+ }
+ return tv;
+ }
+
public void copyTaggedValues(Object source, Object target) {
if (!(source instanceof ModelElement)
@@ -325,7 +339,7 @@
public TagDefinition buildTagDefinition(String name, Object owner,
Object namespace) {
- return buildTagDefinition(name, owner, namespace, "String");
+ return buildTagDefinition(name, owner, namespace, null); // "Element");
}
public TagDefinition buildTagDefinition(String name, Object owner,
Modified: trunk/src/model-mdr/src/org/argouml/model/mdr/ExtensionMechanismsHelperMDRImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/model-mdr/src/org/argouml/model/mdr/ExtensionMechanismsHelperMDRImpl.java?view=diff&rev=13963&p1=trunk/src/model-mdr/src/org/argouml/model/mdr/ExtensionMechanismsHelperMDRImpl.java&p2=trunk/src/model-mdr/src/org/argouml/model/mdr/ExtensionMechanismsHelperMDRImpl.java&r1=13962&r2=13963
==============================================================================
--- trunk/src/model-mdr/src/org/argouml/model/mdr/ExtensionMechanismsHelperMDRImpl.java (original)
+++ trunk/src/model-mdr/src/org/argouml/model/mdr/ExtensionMechanismsHelperMDRImpl.java 2007-12-21 01:28:02-0800
@@ -474,23 +474,19 @@
}
}
-
public void setValueOfTag(Object handle, String value) {
+ setDataValues(handle, new String[] {value});
+ }
+
+ public void setDataValues(Object handle, String[] values) {
if (handle instanceof TaggedValue) {
TaggedValue tv = (TaggedValue) handle;
- // TODO: We currently only support a single dataValue
- Collection dataValues = tv.getDataValue();
- if (dataValues.size() > 1) {
- LOG.error("Encountered TaggedValue with multiple dataValues "
- + handle);
- LOG.error("DataValues being cleared = " + dataValues.toArray());
- }
- tv.getDataValue().clear();
- tv.getDataValue().add(value);
+ Collection<String> dataValues = tv.getDataValue();
+ dataValues.clear();
+ Collections.addAll(dataValues, values);
}
}
-
public void addTaggedValue(Object handle, Object taggedValue) {
if (handle instanceof ModelElement
&& taggedValue instanceof TaggedValue) {
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.