1 29 30 package com.caucho.xml.stream.events; 31 32 import javax.xml.stream.XMLStreamException; 33 import javax.xml.stream.events.ProcessingInstruction; 34 import java.io.IOException ; 35 import java.io.Writer ; 36 37 public class ProcessingInstructionImpl extends XMLEventImpl 38 implements ProcessingInstruction 39 { 40 private final String _data; 41 private final String _target; 42 43 public ProcessingInstructionImpl(String data, String target) 44 { 45 _data = data; 46 _target = target; 47 } 48 49 public String getData() 50 { 51 return _data; 52 } 53 54 public String getTarget() 55 { 56 return _target; 57 } 58 59 public int getEventType() 60 { 61 return PROCESSING_INSTRUCTION; 62 } 63 64 public void writeAsEncodedUnicode(Writer writer) 65 throws XMLStreamException 66 { 67 try { 68 writer.write("<?" + _target); 69 70 if (_data != null && ! "".equals(_data)) 71 writer.write(" " + _data); 72 73 writer.write("?>"); 74 } 75 catch (IOException e) { 76 throw new XMLStreamException(e); 77 } 78 } 79 } 80 81 | Popular Tags |