1 11 package org.eclipse.help.internal.dynamic; 12 13 import org.eclipse.help.IUAElement; 14 import org.eclipse.help.internal.UAElement; 15 16 20 public class DocumentProcessor { 21 22 private ProcessorHandler[] handlers; 23 24 27 public DocumentProcessor() { 28 handlers = new ProcessorHandler[0]; 29 } 30 31 34 public DocumentProcessor(ProcessorHandler[] handlers) { 35 setHandlers(handlers); 36 } 37 38 42 public void process(UAElement element, String id) { 43 for (int i=0;i<handlers.length;++i) { 44 short result = handlers[i].handle(element, id); 45 if (result == ProcessorHandler.HANDLED_CONTINUE) { 46 break; 48 } 49 if (result == ProcessorHandler.HANDLED_SKIP) { 50 return; 52 } 53 } 54 IUAElement[] children = element.getChildren(); 56 for (int i=0;i<children.length;++i) { 57 process((UAElement)children[i], id); 58 } 59 } 60 61 64 public void setHandlers(ProcessorHandler[] handlers) { 65 if (this.handlers != handlers) { 66 this.handlers = handlers; 67 for (int i=0;i<handlers.length;++i) { 68 handlers[i].setProcessor(this); 69 } 70 } 71 } 72 } 73 | Popular Tags |