001: /*
002: * The contents of this file are subject to the terms of the Common Development
003: * and Distribution License (the License). You may not use this file except in
004: * compliance with the License.
005: *
006: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
007: * or http://www.netbeans.org/cddl.txt.
008: *
009: * When distributing Covered Code, include this CDDL Header Notice in each file
010: * and include the License file at http://www.netbeans.org/cddl.txt.
011: * If applicable, add the following below the CDDL Header, with the fields
012: * enclosed by brackets [] replaced by your own identifying information:
013: * "Portions Copyrighted [year] [name of copyright owner]"
014: *
015: * The Original Software is NetBeans. The Initial Developer of the Original
016: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
017: * Microsystems, Inc. All Rights Reserved.
018: */
019:
020: package org.netbeans.modules.bpel.model.impl;
021:
022: import java.util.List;
023: import java.util.concurrent.atomic.AtomicReference;
024:
025: import org.netbeans.modules.bpel.model.api.Assign;
026: import org.netbeans.modules.bpel.model.api.AssignChild;
027: import org.netbeans.modules.bpel.model.api.BpelEntity;
028: import org.netbeans.modules.bpel.model.api.Copy;
029: import org.netbeans.modules.bpel.model.api.support.BpelModelVisitor;
030: import org.netbeans.modules.bpel.model.api.support.TBoolean;
031: import org.netbeans.modules.bpel.model.xam.BpelAttributes;
032: import org.netbeans.modules.bpel.model.xam.BpelElements;
033: import org.netbeans.modules.xml.xam.dom.Attribute;
034: import org.w3c.dom.Element;
035:
036: /**
037: * @author ads
038: */
039: /**
040: * @author ads
041: *
042: */
043: public class AssignImpl extends ActivityImpl implements Assign {
044:
045: AssignImpl(BpelModelImpl model, Element e) {
046: super (model, e);
047: }
048:
049: AssignImpl(BpelBuilderImpl builder) {
050: super (builder, BpelElements.ASSIGN.getName());
051: }
052:
053: /* (non-Javadoc)
054: * @see org.netbeans.modules.soa.model.bpel20.api.Assign#getAssignChildren()
055: */
056: public AssignChild[] getAssignChildren() {
057: readLock();
058: try {
059: List<AssignChild> list = getChildren(AssignChild.class);
060: return list.toArray(new AssignChild[list.size()]);
061: } finally {
062: readUnlock();
063: }
064: }
065:
066: /* (non-Javadoc)
067: * @see org.netbeans.modules.soa.model.bpel20.api.Assign#getAssignChild(int)
068: */
069: public AssignChild getAssignChild(int i) {
070: return getChild(AssignChild.class, i);
071: }
072:
073: /* (non-Javadoc)
074: * @see org.netbeans.modules.soa.model.bpel20.api.Assign#removeAssignChild(int)
075: */
076: public void removeAssignChild(int i) {
077: removeChild(Copy.class, i);
078: }
079:
080: /* (non-Javadoc)
081: * @see org.netbeans.modules.soa.model.bpel20.api.Assign#setAssignChild(org.netbeans.modules.soa.model.bpel20.api.AssignChild, int)
082: */
083: public void setAssignChild(AssignChild child, int i) {
084: setChildAtIndex(child, AssignChild.class, i);
085: }
086:
087: /* (non-Javadoc)
088: * @see org.netbeans.modules.soa.model.bpel20.api.Assign#addAssignChild(org.netbeans.modules.soa.model.bpel20.api.AssignChild)
089: */
090: public void addAssignChild(AssignChild child) {
091: addChildBefore(child, AssignChild.class);
092: }
093:
094: /* (non-Javadoc)
095: * @see org.netbeans.modules.soa.model.bpel20.api.Assign#insertAssignChild(org.netbeans.modules.soa.model.bpel20.api.AssignChild, int)
096: */
097: public void insertAssignChild(AssignChild child, int i) {
098: insertAtIndex(child, AssignChild.class, i);
099: }
100:
101: /* (non-Javadoc)
102: * @see org.netbeans.modules.soa.model.bpel20.api.Assign#setAssignChildren(org.netbeans.modules.soa.model.bpel20.api.AssignChild[])
103: */
104: public void setAssignChildren(AssignChild[] children) {
105: setArrayBefore(children, AssignChild.class);
106: }
107:
108: /* (non-Javadoc)
109: * @see org.netbeans.modules.soa.model.bpel20.api.Assign#sizeOfAssignChildren()
110: */
111: public int sizeOfAssignChildren() {
112: readLock();
113: try {
114: return getChildren(AssignChild.class).size();
115: } finally {
116: readUnlock();
117: }
118: }
119:
120: /*
121: * (non-Javadoc)
122: *
123: * @see org.netbeans.modules.soa.model.bpel20.api.BpelEntity#getElementType()
124: */
125: public Class<? extends BpelEntity> getElementType() {
126: return Assign.class;
127: }
128:
129: /* (non-Javadoc)
130: * @see org.netbeans.modules.soa.model.bpel20.api.Assign#getValidate()
131: */
132: public TBoolean getValidate() {
133: return getBooleanAttribute(BpelAttributes.VALIDATE);
134: }
135:
136: /* (non-Javadoc)
137: * @see org.netbeans.modules.soa.model.bpel20.api.Assign#setValidate(org.netbeans.modules.soa.model.bpel20.api.support.TBoolean)
138: */
139: public void setValidate(TBoolean value) {
140: setBpelAttribute(BpelAttributes.VALIDATE, value);
141: }
142:
143: /* (non-Javadoc)
144: * @see org.netbeans.modules.soa.model.bpel20.api.Assign#removeValidate()
145: */
146: public void removeValidate() {
147: removeAttribute(BpelAttributes.VALIDATE);
148: }
149:
150: public void accept(BpelModelVisitor visitor) {
151: visitor.visit(this );
152: }
153:
154: /* (non-Javadoc)
155: * @see org.netbeans.modules.soa.model.bpel20.impl.BpelContainerImpl#getChildType(T)
156: */
157: @Override
158: protected <T extends BpelEntity> Class<? extends BpelEntity> getChildType(
159: T entity) {
160: if (entity instanceof AssignChild) {
161: return AssignChild.class;
162: }
163: return super .getChildType(entity);
164: }
165:
166: @Override
167: protected BpelEntity create(Element element) {
168: if (BpelElements.COPY.getName().equals(element.getLocalName())) {
169: return new CopyImpl(getModel(), element);
170: } else if (BpelElements.EXTENSIBLE_ASSIGN.getName().equals(
171: element.getLocalName())) {
172: return new ExtensibleAssignImpl(getModel(), element);
173: }
174: return super .create(element);
175: }
176:
177: /* (non-Javadoc)
178: * @see org.netbeans.modules.soa.model.bpel20.impl.BpelEntityImpl#getDomainAttributes()
179: */
180: protected Attribute[] getDomainAttributes() {
181: if (myAttributes.get() == null) {
182: Attribute[] attr = super .getDomainAttributes();
183: Attribute[] ret = new Attribute[attr.length + 1];
184: System.arraycopy(attr, 0, ret, 1, attr.length);
185: ret[0] = BpelAttributes.VALIDATE;
186: myAttributes.compareAndSet(null, ret);
187: }
188: return myAttributes.get();
189: }
190:
191: private static AtomicReference<Attribute[]> myAttributes = new AtomicReference<Attribute[]>();
192:
193: }
|