1 16 19 package org.apache.xalan.templates; 20 21 import java.io.Serializable ; 22 23 import javax.xml.transform.TransformerException ; 24 25 import org.apache.xml.utils.QName; 26 import org.apache.xpath.XPath; 27 import org.apache.xpath.XPathContext; 28 import org.apache.xpath.patterns.StepPattern; 29 30 34 class TemplateSubPatternAssociation implements Serializable , Cloneable 35 { 36 37 38 StepPattern m_stepPattern; 39 40 41 private String m_pattern; 42 43 44 private ElemTemplate m_template; 45 46 47 private TemplateSubPatternAssociation m_next = null; 48 49 50 private boolean m_wild; 51 52 53 private String m_targetString; 54 55 61 TemplateSubPatternAssociation(ElemTemplate template, StepPattern pattern, String pat) 62 { 63 64 m_pattern = pat; 65 m_template = template; 66 m_stepPattern = pattern; 67 m_targetString = m_stepPattern.getTargetString(); 68 m_wild = m_targetString.equals("*"); 69 } 70 71 78 public Object clone() throws CloneNotSupportedException 79 { 80 81 TemplateSubPatternAssociation tspa = 82 (TemplateSubPatternAssociation) super.clone(); 83 84 tspa.m_next = null; 85 86 return tspa; 87 } 88 89 95 public final String getTargetString() 96 { 97 return m_targetString; 98 } 99 100 106 public void setTargetString(String key) 107 { 108 m_targetString = key; 109 } 110 111 118 boolean matchMode(QName m1) 119 { 120 return matchModes(m1, m_template.getMode()); 121 } 122 123 131 private boolean matchModes(QName m1, QName m2) 132 { 133 return (((null == m1) && (null == m2)) 134 || ((null != m1) && (null != m2) && m1.equals(m2))); 135 } 136 137 148 public boolean matches(XPathContext xctxt, int targetNode, QName mode) 149 throws TransformerException 150 { 151 152 double score = m_stepPattern.getMatchScore(xctxt, targetNode); 153 154 return (XPath.MATCH_SCORE_NONE != score) 155 && matchModes(mode, m_template.getMode()); 156 } 157 158 163 public final boolean isWild() 164 { 165 return m_wild; 166 } 167 168 174 public final StepPattern getStepPattern() 175 { 176 return m_stepPattern; 177 } 178 179 185 public final String getPattern() 186 { 187 return m_pattern; 188 } 189 190 196 public int getDocOrderPos() 197 { 198 return m_template.getUid(); 199 } 200 201 207 public final int getImportLevel() 208 { 209 return m_template.getStylesheetComposed().getImportCountComposed(); 210 } 211 212 218 public final ElemTemplate getTemplate() 219 { 220 return m_template; 221 } 222 223 228 public final TemplateSubPatternAssociation getNext() 229 { 230 return m_next; 231 } 232 233 242 public void setNext(TemplateSubPatternAssociation mp) 243 { 244 m_next = mp; 245 } 246 } 247 | Popular Tags |