Java tutorial
/* * Copyright 2009-2010 WSO2, Inc. (http://wso2.com) * * Licensed 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.wso2.developerstudio.eclipse.esb.mediators.impl; import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.commons.lang.StringUtils; import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.impl.ENotificationImpl; import org.w3c.dom.Element; import org.wso2.developerstudio.eclipse.esb.RegistryKeyProperty; import org.wso2.developerstudio.eclipse.esb.core.utils.ESBMediaTypeConstants; import org.wso2.developerstudio.eclipse.esb.impl.AbstractCommonTargetImpl; import org.wso2.developerstudio.eclipse.esb.mediators.CloneTarget; import org.wso2.developerstudio.eclipse.esb.mediators.MediatorsPackage; import org.wso2.developerstudio.eclipse.esb.util.ObjectValidator; import org.wso2.developerstudio.eclipse.platform.core.utils.CSProviderConstants; import org.wso2.developerstudio.eclipse.platform.core.utils.DeveloperStudioProviderUtils; /** * <!-- begin-user-doc --> * An implementation of the model object '<em><b>Clone Target</b></em>'. * <!-- end-user-doc --> * <p> * The following features are implemented: * <ul> * <li>{@link org.wso2.developerstudio.eclipse.esb.mediators.impl.CloneTargetImpl#getSoapAction <em>Soap Action</em>}</li> * <li>{@link org.wso2.developerstudio.eclipse.esb.mediators.impl.CloneTargetImpl#getToAddress <em>To Address</em>}</li> * </ul> * </p> * * @generated */ public class CloneTargetImpl extends AbstractCommonTargetImpl implements CloneTarget { /** * The default value of the '{@link #getSoapAction() <em>Soap Action</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getSoapAction() * @generated * @ordered */ protected static final String SOAP_ACTION_EDEFAULT = null; /** * The cached value of the '{@link #getSoapAction() <em>Soap Action</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getSoapAction() * @generated * @ordered */ protected String soapAction = SOAP_ACTION_EDEFAULT; /** * The default value of the '{@link #getToAddress() <em>To Address</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getToAddress() * @generated * @ordered */ protected static final String TO_ADDRESS_EDEFAULT = null; /** * The cached value of the '{@link #getToAddress() <em>To Address</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getToAddress() * @generated * @ordered */ protected String toAddress = TO_ADDRESS_EDEFAULT; /** * <!-- begin-user-doc --> * <!-- end-user-doc --> */ protected CloneTargetImpl() { super(); // Sequence key. RegistryKeyProperty sequenceKey = getEsbFactory().createRegistryKeyProperty(); //Set filter properties to filter in only sequences media type DeveloperStudioProviderUtils.addFilter((Map<String, List<String>>) sequenceKey.getFilters(), CSProviderConstants.FILTER_MEDIA_TYPE, ESBMediaTypeConstants.MEDIA_TYPE_SEQUENCE); sequenceKey.setPrettyName("Sequence Key"); sequenceKey.setKeyName("sequence"); sequenceKey.setKeyValue(DEFAULT_SEQUENCE_REFERENCE_REGISTRY_KEY); setSequenceKey(sequenceKey); // Endpoint key. RegistryKeyProperty endpointKey = getEsbFactory().createRegistryKeyProperty(); //Set filter properties to filter in only sequences media type DeveloperStudioProviderUtils.addFilter((Map<String, List<String>>) endpointKey.getFilters(), CSProviderConstants.FILTER_MEDIA_TYPE, ESBMediaTypeConstants.MEDIA_TYPE_ENDPOINT); endpointKey.setPrettyName("Endpoint Key"); endpointKey.setKeyName("endpoint"); endpointKey.setKeyValue(DEFAULT_ENDPOINT_REFERENCE_REGISTRY_KEY); setEndpointKey(endpointKey); } /** * {@inheritDoc} */ protected void doLoad(Element self) throws Exception { // Soap action. if (self.hasAttribute("soapAction")) { setSoapAction(self.getAttribute("soapAction")); } // To address. if (self.hasAttribute("to")) { setToAddress(self.getAttribute("to")); } // Delegate. super.doLoad(self); } /** * {@inheritDoc} */ protected Element doSave(Element parent) throws Exception { Element self = super.doSave(parent); // Soap action. if (!StringUtils.isBlank(getSoapAction())) { self.setAttribute("soapAction", getSoapAction()); } // To address. if (!StringUtils.isBlank(getToAddress())) { self.setAttribute("to", getToAddress()); } addComments(self); return self; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected EClass eStaticClass() { return MediatorsPackage.Literals.CLONE_TARGET; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public String getSoapAction() { return soapAction; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setSoapAction(String newSoapAction) { String oldSoapAction = soapAction; soapAction = newSoapAction; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, MediatorsPackage.CLONE_TARGET__SOAP_ACTION, oldSoapAction, soapAction)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public String getToAddress() { return toAddress; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setToAddress(String newToAddress) { String oldToAddress = toAddress; toAddress = newToAddress; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, MediatorsPackage.CLONE_TARGET__TO_ADDRESS, oldToAddress, toAddress)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public Object eGet(int featureID, boolean resolve, boolean coreType) { switch (featureID) { case MediatorsPackage.CLONE_TARGET__SOAP_ACTION: return getSoapAction(); case MediatorsPackage.CLONE_TARGET__TO_ADDRESS: return getToAddress(); } return super.eGet(featureID, resolve, coreType); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eSet(int featureID, Object newValue) { switch (featureID) { case MediatorsPackage.CLONE_TARGET__SOAP_ACTION: setSoapAction((String) newValue); return; case MediatorsPackage.CLONE_TARGET__TO_ADDRESS: setToAddress((String) newValue); return; } super.eSet(featureID, newValue); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case MediatorsPackage.CLONE_TARGET__SOAP_ACTION: setSoapAction(SOAP_ACTION_EDEFAULT); return; case MediatorsPackage.CLONE_TARGET__TO_ADDRESS: setToAddress(TO_ADDRESS_EDEFAULT); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case MediatorsPackage.CLONE_TARGET__SOAP_ACTION: return SOAP_ACTION_EDEFAULT == null ? soapAction != null : !SOAP_ACTION_EDEFAULT.equals(soapAction); case MediatorsPackage.CLONE_TARGET__TO_ADDRESS: return TO_ADDRESS_EDEFAULT == null ? toAddress != null : !TO_ADDRESS_EDEFAULT.equals(toAddress); } return super.eIsSet(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public String toString() { if (eIsProxy()) return super.toString(); StringBuffer result = new StringBuffer(super.toString()); result.append(" (soapAction: "); result.append(soapAction); result.append(", toAddress: "); result.append(toAddress); result.append(')'); return result.toString(); } public Map<String, ObjectValidator> validate() { return new HashMap<String, ObjectValidator>(); } } //CloneTargetImpl