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.concurrent.atomic.AtomicReference;
023:
024: import org.netbeans.modules.bpel.model.api.BpelEntity;
025: import org.netbeans.modules.bpel.model.api.Copy;
026: import org.netbeans.modules.bpel.model.api.To;
027: import org.netbeans.modules.bpel.model.api.support.BpelModelVisitor;
028: import org.netbeans.modules.bpel.model.api.support.TBoolean;
029: import org.netbeans.modules.bpel.model.xam.AfterSources;
030: import org.netbeans.modules.bpel.model.xam.BpelAttributes;
031: import org.netbeans.modules.bpel.model.xam.BpelElements;
032: import org.netbeans.modules.xml.xam.dom.Attribute;
033: import org.w3c.dom.Element;
034:
035: /**
036: * @author ads
037: */
038: public class CopyImpl extends FromHolderImpl implements Copy,
039: AfterSources {
040:
041: CopyImpl(BpelModelImpl model, Element e) {
042: super (model, e);
043: }
044:
045: CopyImpl(BpelBuilderImpl builder) {
046: super (builder, BpelElements.COPY.getName());
047: }
048:
049: /*
050: * (non-Javadoc)
051: *
052: * @see org.netbeans.modules.soa.model.bpel2020.api.Copy#getTo()
053: */
054: public To getTo() {
055: return getChild(To.class);
056: }
057:
058: /*
059: * (non-Javadoc)
060: *
061: * @see org.netbeans.modules.soa.model.bpel2020.api.Copy#setTo(org.netbeans.modules.soa.model.bpel2020.api.To)
062: */
063: public void setTo(To value) {
064: setChild(value, To.class);
065: }
066:
067: /*
068: * (non-Javadoc)
069: *
070: * @see org.netbeans.modules.soa.model.bpel2020.api.BpelEntity#getElementType()
071: */
072: public Class<? extends BpelEntity> getElementType() {
073: return Copy.class;
074: }
075:
076: public void accept(BpelModelVisitor visitor) {
077: visitor.visit(this );
078: }
079:
080: /* (non-Javadoc)
081: * @see org.netbeans.modules.bpel.model.api.Copy#getKeepSrcElementName()
082: */
083: public TBoolean getKeepSrcElementName() {
084: return getBooleanAttribute(BpelAttributes.KEEP_SRC_ELEMENT_NAME);
085: }
086:
087: /* (non-Javadoc)
088: * @see org.netbeans.modules.bpel.model.api.Copy#setKeepSrcElementName(org.netbeans.modules.bpel.model.api.support.TBoolean)
089: */
090: public void setKeepSrcElementName(TBoolean value) {
091: setBpelAttribute(BpelAttributes.KEEP_SRC_ELEMENT_NAME, value);
092: }
093:
094: /* (non-Javadoc)
095: * @see org.netbeans.modules.bpel.model.api.Copy#removeKeepSrcElementName()
096: */
097: public void removeKeepSrcElementName() {
098: removeAttribute(BpelAttributes.KEEP_SRC_ELEMENT_NAME);
099: }
100:
101: /* (non-Javadoc)
102: * @see org.netbeans.modules.bpel.model.api.Copy#getIgnoreMissingFromData()
103: */
104: public TBoolean getIgnoreMissingFromData() {
105: return getBooleanAttribute(BpelAttributes.IGNORE_MISSING_FROM_DATA);
106: }
107:
108: /* (non-Javadoc)
109: * @see org.netbeans.modules.bpel.model.api.Copy#removeIgnoreMissingFromData()
110: */
111: public void removeIgnoreMissingFromData() {
112: removeAttribute(BpelAttributes.IGNORE_MISSING_FROM_DATA);
113: }
114:
115: /* (non-Javadoc)
116: * @see org.netbeans.modules.bpel.model.api.Copy#setIgnoreMissingFromData(org.netbeans.modules.bpel.model.api.support.TBoolean)
117: */
118: public void setIgnoreMissingFromData(TBoolean value) {
119: setBpelAttribute(BpelAttributes.IGNORE_MISSING_FROM_DATA, value);
120: }
121:
122: /*
123: * (non-Javadoc)
124: *
125: * @see org.netbeans.modules.soa.model.bpel20.xdm.impl.BpelContainerImpl#create(org.w3c.dom.Element)
126: */
127: @Override
128: protected BpelEntity create(Element element) {
129: if (BpelElements.TO.getName().equals(element.getLocalName())) {
130: return new ToImpl(getModel(), element);
131: }
132: return super .create(element);
133: }
134:
135: /* (non-Javadoc)
136: * @see org.netbeans.modules.soa.model.bpel20.impl.BpelEntityImpl#getDomainAttributes()
137: */
138: protected Attribute[] getDomainAttributes() {
139: if (myAttributes.get() == null) {
140: Attribute[] attr = super .getDomainAttributes();
141: Attribute[] ret = new Attribute[attr.length + 1];
142: System.arraycopy(attr, 0, ret, 1, attr.length);
143: ret[0] = BpelAttributes.KEEP_SRC_ELEMENT_NAME;
144: myAttributes.compareAndSet(null, ret);
145: }
146: return myAttributes.get();
147: }
148:
149: /* (non-Javadoc)
150: * @see org.netbeans.modules.bpel.model.impl.BpelContainerImpl#getMultiplicity(org.netbeans.modules.bpel.model.api.BpelEntity)
151: */
152: @Override
153: protected Multiplicity getMultiplicity(BpelEntity entity) {
154: if (getChildType(entity).equals(To.class)) {
155: return Multiplicity.SINGLE;
156: }
157: return super .getMultiplicity(entity);
158: }
159:
160: private static AtomicReference<Attribute[]> myAttributes = new AtomicReference<Attribute[]>();
161:
162: }
|