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: package org.netbeans.modules.xslt.tmap.model.impl;
020:
021: import java.util.ArrayList;
022: import java.util.List;
023: import org.netbeans.modules.xml.wsdl.model.Part;
024: import org.netbeans.modules.xml.xam.Reference;
025: import org.netbeans.modules.xslt.tmap.model.api.BooleanType;
026: import org.netbeans.modules.xslt.tmap.model.api.Invoke;
027: import org.netbeans.modules.xslt.tmap.model.api.Operation;
028: import org.netbeans.modules.xslt.tmap.model.api.Param;
029: import org.netbeans.modules.xslt.tmap.model.api.TMapAttributes;
030: import org.netbeans.modules.xslt.tmap.model.api.TMapComponent;
031: import org.netbeans.modules.xslt.tmap.model.api.TMapReference;
032: import org.netbeans.modules.xslt.tmap.model.api.TMapVisitor;
033: import org.netbeans.modules.xslt.tmap.model.api.Transform;
034: import org.netbeans.modules.xslt.tmap.model.api.TransformerDescriptor;
035: import org.netbeans.modules.xslt.tmap.model.api.Variable;
036: import org.netbeans.modules.xslt.tmap.model.api.VariableReference;
037: import org.netbeans.modules.xslt.tmap.model.api.WSDLReference;
038: import org.w3c.dom.Element;
039:
040: /**
041: *
042: * @author Vitaly Bychkov
043: * @version 1.0
044: */
045: public class TransformImpl extends TMapComponentContainerImpl implements
046: Transform {
047:
048: public TransformImpl(TMapModelImpl model) {
049: this (model, createNewElement(TMapComponents.TRANSFORM, model));
050: }
051:
052: public TransformImpl(TMapModelImpl model, Element element) {
053: super (model, element);
054: }
055:
056: public void accept(TMapVisitor visitor) {
057: visitor.visit(this );
058: }
059:
060: public Class<? extends TMapComponent> getComponentType() {
061: return Transform.class;
062: }
063:
064: public String getFile() {
065: return getAttribute(TMapAttributes.FILE);
066: }
067:
068: public void setFile(String locationURI) {
069: setAttribute(Transform.FILE, TMapAttributes.FILE, locationURI);
070: }
071:
072: public VariableReference getSource() {
073: return getTMapVarReference(TMapAttributes.SOURCE);
074: }
075:
076: public void setSource(String source) {
077: setAttribute(Transform.SOURCE, TMapAttributes.SOURCE, source);
078: }
079:
080: public void setSource(VariableReference source) {
081: setAttribute(Transform.SOURCE, TMapAttributes.SOURCE,
082: source == null ? "" : source.getRefString());
083: }
084:
085: public VariableReference getResult() {
086: return getTMapVarReference(TMapAttributes.RESULT);
087: }
088:
089: public void setResult(String result) {
090: setAttribute(Transform.RESULT, TMapAttributes.RESULT, result);
091: }
092:
093: public List<Param> getParams() {
094: return getChildren(Param.class);
095: }
096:
097: public void addParam(Param param) {
098: addAfter(TYPE.getTagName(), param, TYPE.getChildTypes());
099: }
100:
101: public void removeParam(Param param) {
102: removeChild(TYPE.getTagName(), param);
103: }
104:
105: public Reference[] getReferences() {
106: List<Reference> refs = new ArrayList<Reference>();
107: VariableReference sourceRef = getSource();
108: if (sourceRef != null) {
109: refs.add(sourceRef);
110: refs.add(sourceRef.getPart());
111: }
112:
113: VariableReference resultRef = getResult();
114: if (resultRef != null) {
115: refs.add(resultRef);
116: refs.add(resultRef.getPart());
117: }
118:
119: return refs.toArray(new Reference[refs.size()]);
120: }
121:
122: }
|