1 18 19 20 package org.apache.tomcat.util.digester; 21 22 import org.xml.sax.Attributes ; 23 24 39 40 public class ObjectParamRule extends Rule { 41 49 public ObjectParamRule(int paramIndex, Object param) { 50 this(paramIndex, null, param); 51 } 52 53 54 62 public ObjectParamRule(int paramIndex, String attributeName, Object param) { 63 this.paramIndex = paramIndex; 64 this.attributeName = attributeName; 65 this.param = param; 66 } 67 68 69 71 74 protected String attributeName = null; 75 76 79 protected int paramIndex = 0; 80 81 84 protected Object param = null; 85 86 87 89 94 public void begin(String namespace, String name, 95 Attributes attributes) throws Exception { 96 Object anAttribute = null; 97 Object parameters[] = (Object []) digester.peekParams(); 98 99 if (attributeName != null) { 100 anAttribute = attributes.getValue(attributeName); 101 if(anAttribute != null) { 102 parameters[paramIndex] = param; 103 } 104 }else{ 107 parameters[paramIndex] = param; 108 } 109 } 110 111 114 public String toString() { 115 StringBuffer sb = new StringBuffer ("ObjectParamRule["); 116 sb.append("paramIndex="); 117 sb.append(paramIndex); 118 sb.append(", attributeName="); 119 sb.append(attributeName); 120 sb.append(", param="); 121 sb.append(param); 122 sb.append("]"); 123 return (sb.toString()); 124 } 125 } 126 | Popular Tags |