1 33 34 package com.icesoft.faces.webapp.parser; 35 36 import org.apache.commons.digester.Digester; 37 38 import javax.faces.context.ExternalContext; 39 import javax.faces.context.FacesContext; 40 import java.io.IOException ; 41 import java.io.InputStream ; 42 import java.util.Vector ; 43 44 50 public class JsfJspDigester extends Digester { 51 52 Vector loadedNamespaces; 53 String viewTagClassName; 54 55 58 public JsfJspDigester() { 59 super(); 60 loadedNamespaces = new Vector (); 61 } 65 66 72 public String stealParentBodyText() { 73 74 StringBuffer parentBodyText = (StringBuffer ) bodyTexts.peek(); 75 if (parentBodyText == null || parentBodyText.length() == 0) { 76 return null; 77 } 78 79 String returnString = new String (parentBodyText.toString()); 80 if (returnString.trim().length() == 0) { 81 returnString = null; 83 } 84 85 parentBodyText.delete(0, parentBodyText.length()); 87 88 return returnString; 89 } 90 91 public void startPrefixMapping(String prefix, String namespaceURI) { 92 ExternalContext context = FacesContext 93 .getCurrentInstance().getExternalContext(); 94 if (loadedNamespaces.contains(namespaceURI)) { 95 return; 96 } 97 try { 98 TagToComponentMap tagMap = new TagToComponentMap(); 99 InputStream tldStream = JspPageToDocument.getTldInputStream( 100 context, namespaceURI); 101 if (null == tldStream) { 102 if (log.isDebugEnabled()) { 103 log.debug("tldStream null"); 104 } 105 return; 106 } 107 tagMap.addTags(tldStream); 108 ComponentRuleSet rules = new ComponentRuleSet(tagMap, namespaceURI); 109 rules.addRuleInstances(this); 110 loadedNamespaces.add(namespaceURI); 111 112 if (log.isDebugEnabled()) { 113 log.debug( 114 "JsfJspDigester loaded " + prefix + ":" + namespaceURI); 115 } 116 } catch (IOException e) { 117 if (log.isDebugEnabled()) { 118 log.debug(e.getMessage(), e); 119 } 120 } 121 } 122 123 124 public void setViewTagClassName(String className) { 125 viewTagClassName = className; 126 } 127 128 public String getViewTagClassName() { 129 return viewTagClassName; 130 } 131 132 } 133 | Popular Tags |