Home » Modeling » OCL » SimpleAnyType
SimpleAnyType [message #48988] |
Fri, 18 January 2008 19:38 |
Philipp Kutter Messages: 306 Registered: July 2009 |
Senior Member |
|
|
Hi.
Ed Merks told me to use
SimpleAnyType
to wrap any value, independent whether it is an object or a data type.
Does OCL support the treatment of instances of SimpleAnyType in a
convenient way?
This would be huge!
Best, Philipp
-------- Original Message --------
Subject: Re: Wrapper for arbitrary values or objects
Date: Fri, 18 Jan 2008 10:35:22 -0500
From: Ed Merks <merks@ca.ibm.com>
Organization: EclipseCorner
Newsgroups: eclipse.tools.emf
References: <fmqgel$rv9$1@build.eclipse.org>
Phillip,
An instance of SimpleAnyType is an EObject and can have its
setInstanceType be called to reference any EDataType and then setValue
or setRawValue can be used to set an instance of that type or a literal
representation of an instance of that type so in that way it acts as a
wrapper. This is what's created when a serialized instance uses
xsi:type="..." where "..." refers to an EDataType rather than an EClass...
Philipp W. Kutter wrote:
> Hi.
> Has anyone an idea what is the most elegant solution for a
> wrapper for values of some EDataYype, and objects of some EClass?
>
> We need to define an EStructuralFeature which can point both to any
> EObject, or any of EInt, EBoolean, EString, e.t.c.
>
> Creating a class
>
> Wrapper(type: EType, many: boolean, objectValue: EObject*, intValue:
> EInt*, ...)
>
> is obvious, but then the OCL expressions over this get very ugly.
>
> Best, Philipp
|
|
|
Re: SimpleAnyType [message #49021 is a reply to message #48988] |
Fri, 18 January 2008 20:26 |
Eclipse User |
|
|
|
Originally posted by: cdamus.ca.ibm.com
Hi, Philipp,
The SimpleAnyType has a demand-created EClass, if I'm not mistaken, right?
With demand-created features corresponding to the elements and attributes
found in the XML?
In that case, OCL's usual introspection mechanism will find the metadata
that it needs to figure out what you're trying to tell it.
Of course, I haven't actually tried this ... why don't you?
Cheers,
Christian
Philipp W. Kutter wrote:
> Hi.
> Ed Merks told me to use
>
> SimpleAnyType
>
> to wrap any value, independent whether it is an object or a data type.
>
> Does OCL support the treatment of instances of SimpleAnyType in a
> convenient way?
>
> This would be huge!
>
> Best, Philipp
>
> -------- Original Message --------
> Subject: Re: Wrapper for arbitrary values or objects
> Date: Fri, 18 Jan 2008 10:35:22 -0500
> From: Ed Merks <merks@ca.ibm.com>
> Organization: EclipseCorner
> Newsgroups: eclipse.tools.emf
> References: <fmqgel$rv9$1@build.eclipse.org>
>
> Phillip,
>
> An instance of SimpleAnyType is an EObject and can have its
> setInstanceType be called to reference any EDataType and then setValue
> or setRawValue can be used to set an instance of that type or a literal
> representation of an instance of that type so in that way it acts as a
> wrapper. This is what's created when a serialized instance uses
> xsi:type="..." where "..." refers to an EDataType rather than an EClass...
>
>
> Philipp W. Kutter wrote:
> > Hi.
> > Has anyone an idea what is the most elegant solution for a
> > wrapper for values of some EDataYype, and objects of some EClass?
> >
> > We need to define an EStructuralFeature which can point both to any
> > EObject, or any of EInt, EBoolean, EString, e.t.c.
> >
> > Creating a class
> >
> > Wrapper(type: EType, many: boolean, objectValue: EObject*, intValue:
> > EInt*, ...)
> >
> > is obvious, but then the OCL expressions over this get very ugly.
> >
> > Best, Philipp
|
|
|
Re: SimpleAnyType [message #49050 is a reply to message #49021] |
Fri, 18 January 2008 21:37 |
Eclipse User |
|
|
|
Originally posted by: merks.ca.ibm.com
This is a multi-part message in MIME format.
--------------070204060005080907020609
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Christian,
It's like this. You'd create an instance and then you can set it's
instance type to any EDataType. After that you can set the raw value
which must be a literal of the data type or the value which must be an
instance of the data type. In all cases the value is recorded in the
mixed text feature of the parent AnyType. No demand created metadata
need be involved. I suppose the only tricky thing is that the value
returned by getValue must be an instance of the type returned by
getInstanceType. I'm not sure what type of specialized support, if any,
this would need.
package org.eclipse.emf.ecore.xml.type;
import org.eclipse.emf.ecore.EDataType;
/**
* <!-- begin-user-doc -->
* A representation of the model object '<em><b>Simple Any
Type</b></em>'.
* <!-- end-user-doc -->
*
* <p>
* The following features are supported:
* <ul>
* <li>{@link
org.eclipse.emf.ecore.xml.type.SimpleAnyType#getRawValue <em>Raw
Value</em>}</li>
* <li>{@link
org.eclipse.emf.ecore.xml.type.SimpleAnyType#getValue
<em>Value</em>}</li>
* <li>{@link
org.eclipse.emf.ecore.xml.type.SimpleAnyType#getInstanceType
<em>Instance Type</em>}</li>
* </ul>
* </p>
*
* @see org.eclipse.emf.ecore.xml.type.XMLTypePackage#getSimpleAnyTy pe()
* @model extendedMetaData="name='simpleAnyType' kind='simple'"
* @generated
*/
public interface SimpleAnyType extends AnyType
{
/**
* Returns the value of the '<em><b>Raw Value</b></em>' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the value of the '<em>Raw Value</em>' attribute.
* @see #setRawValue(String)
* @see
org.eclipse.emf.ecore.xml.type.XMLTypePackage#getSimpleAnyTy pe_RawValue()
* @model dataType="org.eclipse.emf.ecore.xml.type.String"
transient="true" volatile="true" derived="true"
* extendedMetaData="name=':3' kind='simple'"
* @generated
*/
String getRawValue();
/**
* Sets the value of the '{@link
org.eclipse.emf.ecore.xml.type.SimpleAnyType#getRawValue <em>Raw
Value</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Raw Value</em>' attribute.
* @see #getRawValue()
* @generated
*/
void setRawValue(String value);
/**
* Returns the value of the '<em><b>Value</b></em>' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the value of the '<em>Value</em>' attribute.
* @see #setValue(Object)
* @see
org.eclipse.emf.ecore.xml.type.XMLTypePackage#getSimpleAnyTy pe_Value()
* @model dataType="org.eclipse.emf.ecore.xml.type.AnySimpleType"
transient="true" volatile="true" derived="true"
* extendedMetaData="name=':4' kind='simple'"
* @generated
*/
Object getValue();
/**
* Sets the value of the '{@link
org.eclipse.emf.ecore.xml.type.SimpleAnyType#getValue
<em>Value</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Value</em>' attribute.
* @see #getValue()
* @generated
*/
void setValue(Object value);
/**
* Returns the value of the '<em><b>Instance Type</b></em>' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the value of the '<em>Instance Type</em>' reference.
* @see #setInstanceType(EDataType)
* @see
org.eclipse.emf.ecore.xml.type.XMLTypePackage#getSimpleAnyTy pe_InstanceType()
* @model resolveProxies="false" required="true"
* extendedMetaData="name=':5' kind='simple'"
* @generated
*/
EDataType getInstanceType();
/**
* Sets the value of the '{@link
org.eclipse.emf.ecore.xml.type.SimpleAnyType#getInstanceType
<em>Instance Type</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Instance Type</em>'
reference.
* @see #getInstanceType()
* @generated
*/
void setInstanceType(EDataType value);
} // SimpleAnyType
Christian W. Damus wrote:
> Hi, Philipp,
>
> The SimpleAnyType has a demand-created EClass, if I'm not mistaken, right?
> With demand-created features corresponding to the elements and attributes
> found in the XML?
>
> In that case, OCL's usual introspection mechanism will find the metadata
> that it needs to figure out what you're trying to tell it.
>
> Of course, I haven't actually tried this ... why don't you?
>
> Cheers,
>
> Christian
>
>
> Philipp W. Kutter wrote:
>
>
>> Hi.
>> Ed Merks told me to use
>>
>> SimpleAnyType
>>
>> to wrap any value, independent whether it is an object or a data type.
>>
>> Does OCL support the treatment of instances of SimpleAnyType in a
>> convenient way?
>>
>> This would be huge!
>>
>> Best, Philipp
>>
>> -------- Original Message --------
>> Subject: Re: Wrapper for arbitrary values or objects
>> Date: Fri, 18 Jan 2008 10:35:22 -0500
>> From: Ed Merks <merks@ca.ibm.com>
>> Organization: EclipseCorner
>> Newsgroups: eclipse.tools.emf
>> References: <fmqgel$rv9$1@build.eclipse.org>
>>
>> Phillip,
>>
>> An instance of SimpleAnyType is an EObject and can have its
>> setInstanceType be called to reference any EDataType and then setValue
>> or setRawValue can be used to set an instance of that type or a literal
>> representation of an instance of that type so in that way it acts as a
>> wrapper. This is what's created when a serialized instance uses
>> xsi:type="..." where "..." refers to an EDataType rather than an EClass...
>>
>>
>> Philipp W. Kutter wrote:
>> > Hi.
>> > Has anyone an idea what is the most elegant solution for a
>> > wrapper for values of some EDataYype, and objects of some EClass?
>> >
>> > We need to define an EStructuralFeature which can point both to any
>> > EObject, or any of EInt, EBoolean, EString, e.t.c.
>> >
>> > Creating a class
>> >
>> > Wrapper(type: EType, many: boolean, objectValue: EObject*, intValue:
>> > EInt*, ...)
>> >
>> > is obvious, but then the OCL expressions over this get very ugly.
>> >
>> > Best, Philipp
>>
>
>
--------------070204060005080907020609
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Christian,<br>
<br>
It's like this. You'd create an instance and then you can set it's
instance type to any EDataType. After that you can set the raw value
which must be a literal of the data type or the value which must be an
instance of the data type. In all cases the value is recorded in the
mixed text feature of the parent AnyType. No demand created metadata
need be involved. I suppose the only tricky thing is that the value
returned by getValue must be an instance of the type returned by
getInstanceType. I'm not sure what type of specialized support, if
any, this would need.<small><br>
</small>
<blockquote><small>package org.eclipse.emf.ecore.xml.type;</small><br>
<br>
<br>
<small>import org.eclipse.emf.ecore.EDataType;</small><br>
<br>
<br>
<small>/**</small><br>
<small> * <!-- begin-user-doc --></small><br>
<small> * A representation of the model object
'<em><b>Simple Any Type</b></em>'.</small><br>
<small> * <!-- end-user-doc --></small><br>
<small> *</small><br>
<small> * <p></small><br>
<small> * The following features are supported:</small><br>
<small> * <ul></small><br>
<small> * <li>{@link
org.eclipse.emf.ecore.xml.type.SimpleAnyType#getRawValue <em>Raw
Value</em>}</li></small><br>
<small> * <li>{@link
org.eclipse.emf.ecore.xml.type.SimpleAnyType#getValue
<em>Value</em>}</li&g t; </small><br>
<small> * <li>{@link
org.eclipse.emf.ecore.xml.type.SimpleAnyType#getInstanceType
<em>Instance Type</em>}</li></small><br>
<small> * </ul></small><br>
<small> * </p></small><br>
<small> *</small><br>
<small> * @see
org.eclipse.emf.ecore.xml.type.XMLTypePackage#getSimpleAnyTy pe() </small><br>
<small> * @model extendedMetaData="name='simpleAnyType' kind='simple'"</small><br>
<small> * @generated</small><br>
<small> */</small><br>
<small>public interface SimpleAnyType extends AnyType</small><br>
<small>{</small><br>
<small> /**</small><br>
<small> * Returns the value of the '<em><b>Raw
Value</b></em>' attribute.</small><br>
<small> * <!-- begin-user-doc --></small><br>
<small> * <!-- end-user-doc --></small><br>
<small> * @return the value of the '<em>Raw Value</em>'
attribute.</small><br>
<small> * @see #setRawValue(String)</small><br>
<small> * @see
org.eclipse.emf.ecore.xml.type.XMLTypePackage#getSimpleAnyTy pe_RawValue() </small><br>
<small> * @model dataType="org.eclipse.emf.ecore.xml.type.String"
transient="true" volatile="true" derived="true"</small><br>
<small> *   ; extendedMetaData="name=':3' kind='simple'"</small><br>
<small> * @generated</small><br>
<small> */</small><br>
<small> String getRawValue();</small><br>
<br>
<small> /**</small><br>
<small> * Sets the value of the '{@link
org.eclipse.emf.ecore.xml.type.SimpleAnyType#getRawValue <em>Raw
Value</em>}' attribute.</small><br>
<small> * <!-- begin-user-doc --></small><br>
<small> * <!-- end-user-doc --></small><br>
<small> * @param value the new value of the '<em>Raw
Value</em>' attribute.</small><br>
<small> * @see #getRawValue()</small><br>
<small> * @generated</small><br>
<small> */</small><br>
<small> void setRawValue(String value);</small><br>
<br>
<small> /**</small><br>
<small> * Returns the value of the
'<em><b>Value</b>& amp;lt;/em>' attribute.</small><br>
<small> * <!-- begin-user-doc --></small><br>
<small> * <!-- end-user-doc --></small><br>
<small> * @return the value of the '<em>Value</em>'
attribute.</small><br>
<small> * @see #setValue(Object)</small><br>
<small> * @see
org.eclipse.emf.ecore.xml.type.XMLTypePackage#getSimpleAnyTy pe_Value() </small><br>
<small> * @model
dataType="org.eclipse.emf.ecore.xml.type.AnySimpleType"
transient="true" volatile="true" derived="true"</small><br>
<small> *   ; extendedMetaData="name=':4' kind='simple'"</small><br>
<small> * @generated</small><br>
<small> */</small><br>
<small> Object getValue();</small><br>
<br>
<small> /**</small><br>
<small> * Sets the value of the '{@link
org.eclipse.emf.ecore.xml.type.SimpleAnyType#getValue
<em>Value</em>}' attribute.</small><br>
<small> * <!-- begin-user-doc --></small><br>
<small> * <!-- end-user-doc --></small><br>
<small> * @param value the new value of the
'<em>Value</em>' attribute.</small><br>
<small> * @see #getValue()</small><br>
<small> * @generated</small><br>
<small> */</small><br>
<small> void setValue(Object value);</small><br>
<br>
<small> /**</small><br>
<small> * Returns the value of the '<em><b>Instance
Type</b></em>' reference.</small><br>
<small> * <!-- begin-user-doc --></small><br>
<small> * <!-- end-user-doc --></small><br>
<small> * @return the value of the '<em>Instance
Type</em>' reference.</small><br>
<small> * @see #setInstanceType(EDataType)</small><br>
<small> * @see
org.eclipse.emf.ecore.xml.type.XMLTypePackage#getSimpleAnyTy pe_InstanceType() </small><br>
<small> * @model resolveProxies="false" required="true"</small><br>
<small> *   ; extendedMetaData="name=':5' kind='simple'"</small><br>
<small> * @generated</small><br>
<small> */</small><br>
<small> EDataType getInstanceType();</small><br>
<br>
<small> /**</small><br>
<small> * Sets the value of the '{@link
org.eclipse.emf.ecore.xml.type.SimpleAnyType#getInstanceType
<em>Instance Type</em>}' reference.</small><br>
<small> * <!-- begin-user-doc --></small><br>
<small> * <!-- end-user-doc --></small><br>
<small> * @param value the new value of the '<em>Instance
Type</em>' reference.</small><br>
<small> * @see #getInstanceType()</small><br>
<small> * @generated</small><br>
<small> */</small><br>
<small> void setInstanceType(EDataType value);</small><br>
<br>
<small>} // SimpleAnyType</small><br>
</blockquote>
<br>
Christian W. Damus wrote:
<blockquote cite="mid:fmr217$a7n$1@build.eclipse.org" type="cite">
<pre wrap="">Hi, Philipp,
The SimpleAnyType has a demand-created EClass, if I'm not mistaken, right?
With demand-created features corresponding to the elements and attributes
found in the XML?
In that case, OCL's usual introspection mechanism will find the metadata
that it needs to figure out what you're trying to tell it.
Of course, I haven't actually tried this ... why don't you?
Cheers,
Christian
Philipp W. Kutter wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hi.
Ed Merks told me to use
SimpleAnyType
to wrap any value, independent whether it is an object or a data type.
Does OCL support the treatment of instances of SimpleAnyType in a
convenient way?
This would be huge!
Best, Philipp
-------- Original Message --------
Subject: Re: Wrapper for arbitrary values or objects
Date: Fri, 18 Jan 2008 10:35:22 -0500
From: Ed Merks <a class="moz-txt-link-rfc2396E" href="mailto:merks@ca.ibm.com"><merks@ca.ibm.com></a>
Organization: EclipseCorner
Newsgroups: eclipse.tools.emf
References: <a class="moz-txt-link-rfc2396E" href="mailto:fmqgel$rv9$1@build.eclipse.org"><fmqgel$rv9$1@build.eclipse.org></a>
Phillip,
An instance of SimpleAnyType is an EObject and can have its
setInstanceType be called to reference any EDataType and then setValue
or setRawValue can be used to set an instance of that type or a literal
representation of an instance of that type so in that way it acts as a
wrapper. This is what's created when a serialized instance uses
xsi:type="..." where "..." refers to an EDataType rather than an EClass...
Philipp W. Kutter wrote:
> Hi.
> Has anyone an idea what is the most elegant solution for a
> wrapper for values of some EDataYype, and objects of some EClass?
>
> We need to define an EStructuralFeature which can point both to any
> EObject, or any of EInt, EBoolean, EString, e.t.c.
>
> Creating a class
>
> Wrapper(type: EType, many: boolean, objectValue: EObject*, intValue:
> EInt*, ...)
>
> is obvious, but then the OCL expressions over this get very ugly.
>
> Best, Philipp
</pre>
</blockquote>
<pre wrap=""><!---->
</pre>
</blockquote>
<br>
</body>
</html>
--------------070204060005080907020609--
|
|
|
Re: SimpleAnyType [message #49082 is a reply to message #49050] |
Fri, 18 January 2008 22:13 |
Eclipse User |
|
|
|
Originally posted by: cdamus.ca.ibm.com
Hi, Ed,
Ah! I see. I wasn't quite grokking the significance of the "Simple" part
of the name. Naturally, a SimpleAnyType wouldn't have structure.
All of this feels to me like an XSD-ism, not a modeling concept. I wouldn't
expect this to have any meaning in OCL. The closest equivalent in OCL
would be declaring a property of type OclAny. The value can be anything at
all, except a collection. Unless, of course, the property has
multiplicity, in which case the value is a collection of anything at all,
except a collection.
:-)
I would expect that the SimpleAnyType is already interepreted by MDT OCL as
OclAny, because this is the default type for anything that we don't
understand (don't have a type mapping for). This makes sense to me, but
probably doesn't help Philipp.
Cheers,
Christian
Ed Merks wrote:
> Christian,
>
> It's like this. You'd create an instance and then you can set it's
> instance type to any EDataType. After that you can set the raw value
> which must be a literal of the data type or the value which must be an
> instance of the data type. In all cases the value is recorded in the
> mixed text feature of the parent AnyType. No demand created metadata
> need be involved. I suppose the only tricky thing is that the value
> returned by getValue must be an instance of the type returned by
> getInstanceType. I'm not sure what type of specialized support, if any,
> this would need.
-----8<-----
|
|
|
Goto Forum:
Current Time: Fri Dec 27 19:13:14 GMT 2024
Powered by FUDForum. Page generated in 0.03478 seconds
|