1 /* 2 * $Id: FruitBowlToFruitBasket.java 11283 2008-03-09 11:32:42Z rossmason $ 3 * -------------------------------------------------------------------------------------- 4 * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com 5 * 6 * The software in this package is published under the terms of the CPAL v1.0 7 * license, a copy of which has been included with this distribution in the 8 * LICENSE.txt file. 9 */ 10 package org.mule.tck.testmodels.fruit; 11 12 import org.mule.api.transformer.DiscoverableTransformer; 13 import org.mule.api.transformer.TransformerException; 14 import org.mule.transformer.AbstractTransformer; 15 16 /** 17 * Converts a FruitBowl to a FruitBasket (for testing obviously :) 18 */ 19 public class FruitBowlToFruitBasket extends AbstractTransformer implements DiscoverableTransformer 20 { 21 private int weighting = 1; 22 23 public FruitBowlToFruitBasket() 24 { 25 registerSourceType(FruitBowl.class); 26 setReturnClass(FruitBasket.class); 27 } 28 29 protected Object doTransform(Object src, String encoding) throws TransformerException 30 { 31 FruitBowl bowl = (FruitBowl)src; 32 FruitBasket basket = new FruitBasket(); 33 basket.setFruit(bowl.getFruit()); 34 return basket; 35 } 36 37 /** 38 * If 2 or more discoverable transformers are equal, this value can be used to select the correct one 39 * 40 * @return the priority weighting for this transformer. This is a value between 41 * {@link #MIN_PRIORITY_WEIGHTING} and {@link #MAX_PRIORITY_WEIGHTING}. 42 */ 43 public int getPriorityWeighting() 44 { 45 return weighting; 46 } 47 48 /** 49 * If 2 or more discoverable transformers are equal, this value can be used to select the correct one 50 * 51 * @param weighting the priority weighting for this transformer. This is a value between 52 * {@link #MIN_PRIORITY_WEIGHTING} and {@link #MAX_PRIORITY_WEIGHTING}. 53 */ 54 public void setPriorityWeighting(int weighting) 55 { 56 this.weighting = weighting; 57 } 58 }