1 61 62 63 64 package org.jaxen.expr; 65 66 import org.jaxen.ContextSupport; 67 import org.jaxen.Navigator; 68 import org.jaxen.expr.iter.IterableAxis; 69 70 public class DefaultProcessingInstructionNodeStep extends DefaultStep 71 implements ProcessingInstructionNodeStep 72 { 73 private String name; 74 75 public DefaultProcessingInstructionNodeStep(IterableAxis axis, 76 String name, 77 PredicateSet predicateSet) 78 { 79 super( axis, predicateSet ); 80 81 this.name = name; 82 } 83 84 public String getName() 85 { 86 return this.name; 87 } 88 89 public boolean matches(Object node, 90 ContextSupport support) 91 { 92 Navigator nav = support.getNavigator(); 93 94 boolean isPi = nav.isProcessingInstruction( node ); 95 96 if ( isPi ) 97 { 98 String name = getName(); 99 100 if ( name == null || name.length() == 0 ) 101 { 102 return true; 103 } 104 else 105 { 106 return name.equals( nav.getProcessingInstructionTarget( node ) ); 107 } 108 } 109 110 return false; 111 } 112 113 public void accept(Visitor visitor) 114 { 115 visitor.visit(this); 116 } 117 } 118 | Popular Tags |