1 7 package org.ejtools.util.service; 8 9 import java.util.Map ; 10 11 import org.ejtools.util.state.DefaultRule; 12 import org.xml.sax.Attributes ; 13 14 18 public class ProfileRule extends DefaultRule 19 { 20 25 public void loadEnter(Map context) 26 { 27 ProfileHolder holder = (ProfileHolder) context.get("HOLDER"); 28 Profile profile = new Profile(); 29 holder.setProfile(profile); 30 context.put("PROFILE", profile); 31 } 32 33 34 40 public static class ProfilePropertyRule extends DefaultRule 41 { 42 43 private String key; 44 45 46 51 public void loadBody(Map context) 52 { 53 Profile profile = (Profile) context.get("PROFILE"); 54 String text = (String ) context.get("TEXT"); 55 profile.put(this.key, text); 56 } 57 58 59 64 public void loadEnter(Map context) 65 { 66 Attributes attrs = (Attributes ) context.get("ATTRIBUTES"); 67 this.key = attrs.getValue("key"); 68 } 69 70 71 76 public void loadExit(Map context) 77 { 78 Profile profile = (Profile) context.get("PROFILE"); 79 String text = profile.getProperty(this.key); 80 if (text == null) 81 { 82 profile.setProperty(this.key, ""); 83 } 84 } 85 } 86 } 87 | Popular Tags |