1 28 29 package org.objectweb.openccm.uml.transformation.rules.xml; 30 31 32 import ispuml.mdaTransformation.RuleContext; 33 import ispuml.mdaTransformation.TransformationException; 34 import ispuml.mdaTransformation.ActionBase; 35 import ispuml.mdaTransformation.rules.xml.CompositeXmlAction; 36 37 38 41 public class FormatString extends CompositeXmlAction { 42 43 44 private String formatPattern; 45 46 49 public FormatString() { 50 isSrcPropertyRequired = false; 53 isDstPropertyRequired = false; 54 action = new TransformAction(); 55 } 56 57 61 public void setFormatPattern (String formatPattern) { 62 this.formatPattern = formatPattern; 63 } 64 65 68 class TransformAction extends ActionBase { 69 74 public Object execute(Object bean, RuleContext request) throws TransformationException { 75 String toFormat = bean.toString(); 76 if (toFormat.length() > 1) 77 return toFormat.substring(0,1).toUpperCase() + toFormat.substring(1).toLowerCase(); 78 else 79 return toFormat.toUpperCase(); 80 } 81 82 } } 84 | Popular Tags |