1 21 22 package org.dbunit.dataset.csv.handlers; 23 24 import org.dbunit.dataset.csv.IllegalInputCharacterException; 25 26 public class IsAlnumHandler extends AbstractPipelineComponent { 27 28 private IsAlnumHandler() {} 29 30 public static final PipelineComponent ACCEPT () { 31 return createPipelineComponent(new IsAlnumHandler(), new ACCEPT()); 32 } 33 34 public static final PipelineComponent IGNORE () { 35 return createPipelineComponent(new IsAlnumHandler(), new IGNORE()); 36 } 37 38 public static final PipelineComponent QUOTE () { 39 return createPipelineComponent(new IsAlnumHandler(), new QUOTE()); 40 } 41 42 47 48 49 public boolean canHandle(char c) throws IllegalInputCharacterException { 50 if (c != SeparatorHandler.SEPARATOR_CHAR 51 && !Character.isWhitespace(c) 52 && c != EscapeHandler.ESCAPE_CHAR) { 53 return true; 54 } 55 return false; 56 } 57 58 static protected class QUOTE extends Helper { 59 60 private boolean add = true; 61 62 public void helpWith(char c) { 63 64 getHandler().getPipeline().putFront(SeparatorHandler.ENDPIECE()); 65 getHandler().getPipeline().putFront(IsAlnumHandler.ACCEPT()); 66 getHandler().getPipeline().putFront(WhitespacesHandler.ACCEPT()); 67 69 getHandler().accept(c); 70 } 71 } 72 73 static protected class UNQUOTE extends Helper { 74 75 76 public void helpWith(char c) { 77 try { 78 getHandler().getPipeline().removeFront(); 79 getHandler().getPipeline().removeFront(); 80 getHandler().getPipeline().removeFront(); 81 getHandler().getPipeline().removeFront(); 82 } catch (PipelineException e) { 83 throw new RuntimeException (e.getMessage()); 84 } 85 } 87 } 88 89 } 90 | Popular Tags |