1 18 package org.apache.beehive.netui.core.urltemplates; 19 20 import java.util.HashMap ; 21 import java.util.Map ; 22 23 26 public class URLTemplates 27 { 28 private HashMap _templates = new HashMap (); 29 private HashMap _templateRefGroups = 30 new HashMap (); 31 32 38 public void addTemplate( String templateName, URLTemplate template ) 39 { 40 if ( templateName == null || templateName.length() == 0 ) 41 { 42 throw new IllegalArgumentException ( "Template name cannot be null or empty." ); 43 } 44 45 if ( template == null ) 46 { 47 throw new IllegalArgumentException ( "URLTemplate cannot be null." ); 48 } 49 50 _templates.put( templateName, template ); 51 } 52 53 66 public URLTemplate getTemplate( String templateName ) 67 { 68 URLTemplate template = ( URLTemplate ) _templates.get( templateName ); 69 if ( template == null ) return null; 70 71 return new URLTemplate( template ); 72 } 73 74 80 public void addTemplateRefGroup( String refGroupName, Map templateRefGroup ) 81 { 82 if ( refGroupName == null || refGroupName.length() == 0 ) 83 { 84 throw new IllegalArgumentException ( "Template Reference Group name cannot be null or empty." ); 85 } 86 87 if ( templateRefGroup == null || templateRefGroup.size() == 0 ) 88 { 89 throw new IllegalArgumentException ( "Template Reference Group cannot be null or empty." ); 90 } 91 92 _templateRefGroups.put( refGroupName, templateRefGroup ); 93 } 94 95 102 public String getTemplateNameByRef( String refGroupName, String key ) 103 { 104 String templateName = null; 105 Map templateRefGroup = ( Map ) _templateRefGroups.get( refGroupName ); 106 if ( templateRefGroup != null ) 107 { 108 templateName = ( String ) templateRefGroup.get( key ); 109 } 110 111 return templateName; 112 } 113 } 114 | Popular Tags |