You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by ke...@apache.org on 2007/05/24 11:27:55 UTC
svn commit: r541235 - in /incubator/tuscany/java/sdo/tools/src/test:
java/com/example/open/ java/com/example/open/impl/
java/org/apache/tuscany/sdo/test/ resources/
Author: kelvingoodson
Date: Thu May 24 02:27:54 2007
New Revision: 541235
URL: http://svn.apache.org/viewvc?view=rev&rev=541235
Log:
new test case for use of anyAttribute on generated classes
Added:
incubator/tuscany/java/sdo/tools/src/test/java/com/example/open/
incubator/tuscany/java/sdo/tools/src/test/java/com/example/open/OneElementAndAnyAttr.java
incubator/tuscany/java/sdo/tools/src/test/java/com/example/open/OpenFactory.java
incubator/tuscany/java/sdo/tools/src/test/java/com/example/open/impl/
incubator/tuscany/java/sdo/tools/src/test/java/com/example/open/impl/OneElementAndAnyAttrImpl.java
incubator/tuscany/java/sdo/tools/src/test/java/com/example/open/impl/OpenFactoryImpl.java
incubator/tuscany/java/sdo/tools/src/test/java/org/apache/tuscany/sdo/test/OpenContentTestCase.java
incubator/tuscany/java/sdo/tools/src/test/resources/Open.xsd
Added: incubator/tuscany/java/sdo/tools/src/test/java/com/example/open/OneElementAndAnyAttr.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/tools/src/test/java/com/example/open/OneElementAndAnyAttr.java?view=auto&rev=541235
==============================================================================
--- incubator/tuscany/java/sdo/tools/src/test/java/com/example/open/OneElementAndAnyAttr.java (added)
+++ incubator/tuscany/java/sdo/tools/src/test/java/com/example/open/OneElementAndAnyAttr.java Thu May 24 02:27:54 2007
@@ -0,0 +1,108 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package com.example.open;
+
+import commonj.sdo.Sequence;
+
+import java.io.Serializable;
+
+/**
+ * <!-- begin-user-doc -->
+ * A representation of the model object '<em><b>One Element And Any Attr</b></em>'.
+ * <!-- end-user-doc -->
+ *
+ * <p>
+ * The following features are supported:
+ * <ul>
+ * <li>{@link com.example.open.OneElementAndAnyAttr#getName <em>Name</em>}</li>
+ * <li>{@link com.example.open.OneElementAndAnyAttr#getAnyAttribute <em>Any Attribute</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @extends Serializable
+ * @generated
+ */
+public interface OneElementAndAnyAttr extends Serializable
+{
+ /**
+ * Returns the value of the '<em><b>Name</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Name</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Name</em>' attribute.
+ * @see #isSetName()
+ * @see #unsetName()
+ * @see #setName(String)
+ * @generated
+ */
+ String getName();
+
+ /**
+ * Sets the value of the '{@link com.example.open.OneElementAndAnyAttr#getName <em>Name</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Name</em>' attribute.
+ * @see #isSetName()
+ * @see #unsetName()
+ * @see #getName()
+ * @generated
+ */
+ void setName(String value);
+
+ /**
+ * Unsets the value of the '{@link com.example.open.OneElementAndAnyAttr#getName <em>Name</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #isSetName()
+ * @see #getName()
+ * @see #setName(String)
+ * @generated
+ */
+ void unsetName();
+
+ /**
+ * Returns whether the value of the '{@link com.example.open.OneElementAndAnyAttr#getName <em>Name</em>}' attribute is set.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return whether the value of the '<em>Name</em>' attribute is set.
+ * @see #unsetName()
+ * @see #getName()
+ * @see #setName(String)
+ * @generated
+ */
+ boolean isSetName();
+
+ /**
+ * Returns the value of the '<em><b>Any Attribute</b></em>' attribute list.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Any Attribute</em>' attribute list isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Any Attribute</em>' attribute list.
+ * @generated
+ */
+ Sequence getAnyAttribute();
+
+} // OneElementAndAnyAttr
Added: incubator/tuscany/java/sdo/tools/src/test/java/com/example/open/OpenFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/tools/src/test/java/com/example/open/OpenFactory.java?view=auto&rev=541235
==============================================================================
--- incubator/tuscany/java/sdo/tools/src/test/java/com/example/open/OpenFactory.java (added)
+++ incubator/tuscany/java/sdo/tools/src/test/java/com/example/open/OpenFactory.java Thu May 24 02:27:54 2007
@@ -0,0 +1,61 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package com.example.open;
+
+import commonj.sdo.helper.HelperContext;
+
+
+/**
+ * <!-- begin-user-doc -->
+ * The <b>Factory</b> for the model.
+ * It provides a create method for each non-abstract class of the model.
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public interface OpenFactory
+{
+
+ /**
+ * The singleton instance of the factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ OpenFactory INSTANCE = com.example.open.impl.OpenFactoryImpl.init();
+
+ /**
+ * Returns a new object of class '<em>One Element And Any Attr</em>'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return a new object of class '<em>One Element And Any Attr</em>'.
+ * @generated
+ */
+ OneElementAndAnyAttr createOneElementAndAnyAttr();
+
+ /**
+ * Registers the types supported by this Factory within the supplied scope.argument
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param scope an instance of HelperContext used to manage the scoping of types.
+ * @generated
+ */
+ public void register(HelperContext scope);
+
+} //OpenFactory
Added: incubator/tuscany/java/sdo/tools/src/test/java/com/example/open/impl/OneElementAndAnyAttrImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/tools/src/test/java/com/example/open/impl/OneElementAndAnyAttrImpl.java?view=auto&rev=541235
==============================================================================
--- incubator/tuscany/java/sdo/tools/src/test/java/com/example/open/impl/OneElementAndAnyAttrImpl.java (added)
+++ incubator/tuscany/java/sdo/tools/src/test/java/com/example/open/impl/OneElementAndAnyAttrImpl.java Thu May 24 02:27:54 2007
@@ -0,0 +1,324 @@
+/**
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package com.example.open.impl;
+
+import com.example.open.OneElementAndAnyAttr;
+import com.example.open.OpenFactory;
+
+import commonj.sdo.Sequence;
+import commonj.sdo.Type;
+
+import org.apache.tuscany.sdo.impl.DataObjectBase;
+
+/**
+ * <!-- begin-user-doc -->
+ * An implementation of the model object '<em><b>One Element And Any Attr</b></em>'.
+ * <!-- end-user-doc -->
+ * <p>
+ * The following features are implemented:
+ * <ul>
+ * <li>{@link com.example.open.impl.OneElementAndAnyAttrImpl#getName <em>Name</em>}</li>
+ * <li>{@link com.example.open.impl.OneElementAndAnyAttrImpl#getAnyAttribute <em>Any Attribute</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @generated
+ */
+public class OneElementAndAnyAttrImpl extends DataObjectBase implements OneElementAndAnyAttr
+{
+
+ public final static int NAME = 0;
+
+ public final static int ANY_ATTRIBUTE = -1;
+
+ public final static int SDO_PROPERTY_COUNT = 1;
+
+ public final static int EXTENDED_PROPERTY_COUNT = -1;
+
+
+ /**
+ * The internal feature id for the '<em><b>Name</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public final static int INTERNAL_NAME = 0;
+
+ /**
+ * The internal feature id for the '<em><b>Any Attribute</b></em>' attribute list.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public final static int INTERNAL_ANY_ATTRIBUTE = 1;
+
+ /**
+ * The number of properties for this type.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public final static int INTERNAL_PROPERTY_COUNT = 2;
+
+ protected int internalConvertIndex(int internalIndex)
+ {
+ switch (internalIndex)
+ {
+ case INTERNAL_NAME: return NAME;
+ case INTERNAL_ANY_ATTRIBUTE: return ANY_ATTRIBUTE;
+ }
+ return super.internalConvertIndex(internalIndex);
+ }
+
+
+ /**
+ * The default value of the '{@link #getName() <em>Name</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getName()
+ * @generated
+ * @ordered
+ */
+ protected static final String NAME_DEFAULT_ = null;
+
+ /**
+ * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getName()
+ * @generated
+ * @ordered
+ */
+ protected String name = NAME_DEFAULT_;
+
+ /**
+ * This is true if the Name attribute has been set.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ protected boolean name_set_ = false;
+
+ /**
+ * The cached value of the '{@link #getAnyAttribute() <em>Any Attribute</em>}' attribute list.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getAnyAttribute()
+ * @generated
+ * @ordered
+ */
+
+ protected Sequence anyAttribute = null;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public OneElementAndAnyAttrImpl()
+ {
+ super();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public Type getType()
+ {
+ return ((OpenFactoryImpl)OpenFactory.INSTANCE).getOneElementAndAnyAttr();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String getName()
+ {
+ return name;
+ }
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setName(String newName)
+ {
+ String oldName = name;
+ name = newName;
+ boolean oldName_set_ = name_set_;
+ name_set_ = true;
+ if (isNotifying())
+ notify(ChangeKind.SET, NAME, oldName, name, !oldName_set_);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void unsetName()
+ {
+ String oldName = name;
+ boolean oldName_set_ = name_set_;
+ name = NAME_DEFAULT_;
+ name_set_ = false;
+ if (isNotifying())
+ notify(ChangeKind.UNSET, NAME, oldName, NAME_DEFAULT_, oldName_set_);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public boolean isSetName()
+ {
+ return name_set_;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public Sequence getAnyAttribute()
+ {
+ if (anyAttribute == null)
+ {
+ anyAttribute = createSequence(INTERNAL_ANY_ATTRIBUTE);
+ }
+ return anyAttribute;
+ }
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public ChangeContext inverseRemove(Object otherEnd, int propertyIndex, ChangeContext changeContext)
+ {
+ switch (propertyIndex)
+ {
+ case ANY_ATTRIBUTE:
+ return removeFromSequence(getAnyAttribute(), otherEnd, changeContext);
+ }
+ return super.inverseRemove(otherEnd, propertyIndex, changeContext);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public Object get(int propertyIndex, boolean resolve)
+ {
+ switch (propertyIndex)
+ {
+ case NAME:
+ return getName();
+ case ANY_ATTRIBUTE:
+ // XXX query introduce coreType as an argument? -- semantic = if true -- coreType - return the core EMF object if value is a non-EMF wrapper/view
+ //if (coreType)
+ return getAnyAttribute();
+ }
+ return super.get(propertyIndex, resolve);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void set(int propertyIndex, Object newValue)
+ {
+ switch (propertyIndex)
+ {
+ case NAME:
+ setName((String)newValue);
+ return;
+ case ANY_ATTRIBUTE:
+ setSequence(getAnyAttribute(), newValue);
+ return;
+ }
+ super.set(propertyIndex, newValue);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void unset(int propertyIndex)
+ {
+ switch (propertyIndex)
+ {
+ case NAME:
+ unsetName();
+ return;
+ case ANY_ATTRIBUTE:
+ unsetSequence(getAnyAttribute());
+ return;
+ }
+ super.unset(propertyIndex);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public boolean isSet(int propertyIndex)
+ {
+ switch (propertyIndex)
+ {
+ case NAME:
+ return isSetName();
+ case ANY_ATTRIBUTE:
+ return anyAttribute != null && !isSequenceEmpty(getAnyAttribute());
+ }
+ return super.isSet(propertyIndex);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String toString()
+ {
+ if (isProxy(this)) return super.toString();
+
+ StringBuffer result = new StringBuffer(super.toString());
+ result.append(" (name: ");
+ if (name_set_) result.append(name); else result.append("<unset>");
+ result.append(", anyAttribute: ");
+ result.append(anyAttribute);
+ result.append(')');
+ return result.toString();
+ }
+
+} //OneElementAndAnyAttrImpl
Added: incubator/tuscany/java/sdo/tools/src/test/java/com/example/open/impl/OpenFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/tools/src/test/java/com/example/open/impl/OpenFactoryImpl.java?view=auto&rev=541235
==============================================================================
--- incubator/tuscany/java/sdo/tools/src/test/java/com/example/open/impl/OpenFactoryImpl.java (added)
+++ incubator/tuscany/java/sdo/tools/src/test/java/com/example/open/impl/OpenFactoryImpl.java Thu May 24 02:27:54 2007
@@ -0,0 +1,249 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package com.example.open.impl;
+
+import commonj.sdo.helper.HelperContext;
+import org.apache.tuscany.sdo.helper.TypeHelperImpl;
+
+import com.example.open.*;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Property;
+import commonj.sdo.Type;
+
+import org.apache.tuscany.sdo.SDOFactory;
+
+import org.apache.tuscany.sdo.impl.FactoryBase;
+
+import org.apache.tuscany.sdo.model.ModelFactory;
+
+import org.apache.tuscany.sdo.model.impl.ModelFactoryImpl;
+
+import org.apache.tuscany.sdo.model.internal.InternalFactory;
+
+import org.apache.tuscany.sdo.util.SDOUtil;
+
+/**
+ * <!-- begin-user-doc -->
+ * An implementation of the model <b>Factory</b>.
+ * Generator information:
+ * patternVersion=1.1;
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public class OpenFactoryImpl extends FactoryBase implements OpenFactory
+{
+
+ /**
+ * The package namespace URI.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String NAMESPACE_URI = "http://www.example.com/open";
+
+ /**
+ * The package namespace name.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String NAMESPACE_PREFIX = "open";
+
+ /**
+ * The version of the generator pattern used to generate this class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String PATTERN_VERSION = "1.1";
+
+ public static final int ONE_ELEMENT_AND_ANY_ATTR = 1;
+
+ /**
+ * Creates an instance of the factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public OpenFactoryImpl()
+ {
+ super(NAMESPACE_URI, NAMESPACE_PREFIX, "com.example.open");
+ }
+
+ /**
+ * Registers the Factory instance so that it is available within the supplied scope.
+ * @argument scope a HelperContext instance that will make the types supported by this Factory available.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void register(HelperContext scope) {
+ if(scope == null) {
+ throw new IllegalArgumentException("Scope can not be null");
+ }
+ TypeHelperImpl th = (TypeHelperImpl)scope.getTypeHelper();
+ th.getExtendedMetaData().putPackage(NAMESPACE_URI, this);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public DataObject create(int typeNumber)
+ {
+ switch (typeNumber)
+ {
+ case ONE_ELEMENT_AND_ANY_ATTR: return (DataObject)createOneElementAndAnyAttr();
+ default:
+ return super.create(typeNumber);
+ }
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public OneElementAndAnyAttr createOneElementAndAnyAttr()
+ {
+ OneElementAndAnyAttrImpl oneElementAndAnyAttr = new OneElementAndAnyAttrImpl();
+ return oneElementAndAnyAttr;
+ }
+
+ // Following creates and initializes SDO metadata for the supported types.
+ protected Type oneElementAndAnyAttrType = null;
+
+ public Type getOneElementAndAnyAttr()
+ {
+ return oneElementAndAnyAttrType;
+ }
+
+
+ private static boolean isInited = false;
+
+ public static OpenFactoryImpl init()
+ {
+ if (isInited) return (OpenFactoryImpl)FactoryBase.getStaticFactory(OpenFactoryImpl.NAMESPACE_URI);
+ OpenFactoryImpl theOpenFactoryImpl = new OpenFactoryImpl();
+ isInited = true;
+
+ // Initialize simple dependencies
+ SDOUtil.registerStaticTypes(SDOFactory.class);
+ SDOUtil.registerStaticTypes(ModelFactory.class);
+ SDOUtil.registerStaticTypes(InternalFactory.class);
+
+ // Create package meta-data objects
+ theOpenFactoryImpl.createMetaData();
+
+ // Initialize created meta-data
+ theOpenFactoryImpl.initializeMetaData();
+
+ // Mark meta-data to indicate it can't be changed
+ //theOpenFactoryImpl.freeze(); //FB do we need to freeze / should we freeze ????
+
+ return theOpenFactoryImpl;
+ }
+
+ private boolean isCreated = false;
+
+ public void createMetaData()
+ {
+ if (isCreated) return;
+ isCreated = true;
+
+ // Create types and their properties
+ oneElementAndAnyAttrType = createType(false, ONE_ELEMENT_AND_ANY_ATTR);
+ createProperty(true, oneElementAndAnyAttrType,OneElementAndAnyAttrImpl.INTERNAL_NAME);
+ createProperty(true, oneElementAndAnyAttrType,OneElementAndAnyAttrImpl.INTERNAL_ANY_ATTRIBUTE);
+ }
+
+ private boolean isInitialized = false;
+
+ public void initializeMetaData()
+ {
+ if (isInitialized) return;
+ isInitialized = true;
+
+ // Obtain other dependent packages
+ ModelFactoryImpl theModelPackageImpl = (ModelFactoryImpl)FactoryBase.getStaticFactory(ModelFactoryImpl.NAMESPACE_URI);
+ Property property = null;
+
+ // Add supertypes to types
+
+ // Initialize types and properties
+ initializeType(oneElementAndAnyAttrType, OneElementAndAnyAttr.class, "OneElementAndAnyAttr", false);
+ property = getProperty(oneElementAndAnyAttrType, OneElementAndAnyAttrImpl.INTERNAL_NAME);
+ initializeProperty(property, theModelPackageImpl.getString(), "name", null, 1, 1, OneElementAndAnyAttr.class, false, true, false);
+
+ property = getProperty(oneElementAndAnyAttrType, OneElementAndAnyAttrImpl.INTERNAL_ANY_ATTRIBUTE);
+ initializeProperty(property, getSequence(), "anyAttribute", null, 0, -1, OneElementAndAnyAttr.class, false, false, false);
+
+ createXSDMetaData(theModelPackageImpl);
+ }
+
+ protected void createXSDMetaData(ModelFactoryImpl theModelPackageImpl)
+ {
+ super.initXSD();
+
+ Property property = null;
+
+
+ property = createGlobalProperty
+ ("globAttribute",
+ theModelPackageImpl.getString(),
+ new String[]
+ {
+ "kind", "attribute",
+ "name", "globAttribute",
+ "namespace", "##targetNamespace"
+ },
+ IS_ATTRIBUTE);
+
+ addXSDMapping
+ (oneElementAndAnyAttrType,
+ new String[]
+ {
+ "name", "OneElementAndAnyAttr",
+ "kind", "elementOnly"
+ });
+
+ addXSDMapping
+ (getProperty(oneElementAndAnyAttrType, OneElementAndAnyAttrImpl.INTERNAL_NAME),
+ new String[]
+ {
+ "kind", "element",
+ "name", "name"
+ });
+
+ addXSDMapping
+ (getProperty(oneElementAndAnyAttrType, OneElementAndAnyAttrImpl.INTERNAL_ANY_ATTRIBUTE),
+ new String[]
+ {
+ "kind", "attributeWildcard",
+ "wildcards", "##any",
+ "name", ":1",
+ "processing", "lax"
+ });
+
+ }
+
+} //OpenFactoryImpl
Added: incubator/tuscany/java/sdo/tools/src/test/java/org/apache/tuscany/sdo/test/OpenContentTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/tools/src/test/java/org/apache/tuscany/sdo/test/OpenContentTestCase.java?view=auto&rev=541235
==============================================================================
--- incubator/tuscany/java/sdo/tools/src/test/java/org/apache/tuscany/sdo/test/OpenContentTestCase.java (added)
+++ incubator/tuscany/java/sdo/tools/src/test/java/org/apache/tuscany/sdo/test/OpenContentTestCase.java Thu May 24 02:27:54 2007
@@ -0,0 +1,75 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sdo.test;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sdo.util.SDOUtil;
+
+import com.example.open.OneElementAndAnyAttr;
+import com.example.open.OpenFactory;
+import commonj.sdo.DataObject;
+import commonj.sdo.Property;
+import commonj.sdo.Sequence;
+import commonj.sdo.helper.HelperContext;
+
+
+public class OpenContentTestCase extends TestCase
+{
+
+ HelperContext scope;
+
+ public void testAnyAttribute() throws IOException
+ {
+
+ OpenFactory.INSTANCE.register(scope);
+ DataObject dob = scope.getDataFactory().create(OneElementAndAnyAttr.class);
+ OneElementAndAnyAttr staticDob = (OneElementAndAnyAttr)dob;
+
+ staticDob.setName("fred");
+
+ assertEquals(1, dob.getInstanceProperties().size());
+ Sequence s = ((OneElementAndAnyAttr)dob).getAnyAttribute();
+
+ assertFalse(dob.getType().isSequenced());
+ assertTrue(dob.getType().isOpen());
+ assertNull(dob.getSequence());
+
+ Property prop = scope.getTypeHelper().getOpenContentProperty("http://www.example.com/open", "globAttribute");
+ s.add(prop, "foo");
+ assertEquals(2, dob.getInstanceProperties().size());
+ assertTrue(dob.getInstanceProperties().contains(prop));
+
+ scope.getXMLHelper().save((DataObject)dob, "http://www.example.com/open", "bar", System.out);
+ }
+
+ protected void setUp() throws Exception {
+ scope = SDOUtil.createHelperContext();
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+
+}
Added: incubator/tuscany/java/sdo/tools/src/test/resources/Open.xsd
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/tools/src/test/resources/Open.xsd?view=auto&rev=541235
==============================================================================
--- incubator/tuscany/java/sdo/tools/src/test/resources/Open.xsd (added)
+++ incubator/tuscany/java/sdo/tools/src/test/resources/Open.xsd Thu May 24 02:27:54 2007
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ -->
+<xsd:schema xmlns:open="http://www.example.com/open" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/open">
+
+
+ <xsd:attribute name="globAttribute" type="xsd:string"/>
+
+ <xsd:complexType name="OneElementAndAnyAttr">
+ <xsd:sequence>
+ <xsd:element name="name" type="xsd:string"/>
+ </xsd:sequence>
+ <xsd:anyAttribute processContents="lax"/>
+ </xsd:complexType>
+
+
+</xsd:schema>
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org