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