1 17 package org.apache.ws.jaxme.js; 18 19 import java.io.IOException ; 20 import java.io.Writer ; 21 22 27 public class WriterTarget implements IndentationTarget { 28 public static final String INDENTATION_STRING = " "; 29 public static final String LINE_SEPARATOR = "\n"; 30 private Writer target; 31 private String indentationString; 32 private String lineSeparator; 33 34 public WriterTarget() {} 35 36 public WriterTarget(Writer pTarget) { 37 target = pTarget; 38 } 39 40 public void setTarget(Writer pTarget) { 41 target = pTarget; 42 } 43 44 public Writer getTarget() { 45 return target; 46 } 47 48 public void setIndentationString(String pIndentationString) { 49 indentationString = pIndentationString; 50 } 51 52 public String getIndentationString() { 53 return indentationString == null ? INDENTATION_STRING : indentationString; 54 } 55 56 public void setLineSeparator(String pLineSeparator) { 57 lineSeparator = pLineSeparator; 58 } 59 60 public String getLineSeparator() { 61 return lineSeparator == null ? LINE_SEPARATOR : lineSeparator; 62 } 63 64 public boolean isInterface() { 65 return false; 66 } 67 68 public void indent(int pLevel) throws IOException { 69 for (int i = 0; i < pLevel; i++) { 70 target.write(getIndentationString()); 71 } 72 } 73 74 public String asString(JavaQName pQName) { 75 return pQName.toString(); 76 } 77 78 public void write(String pValue) throws IOException { 79 target.write(pValue); 80 } 81 82 public void write() throws IOException { 83 target.write(getLineSeparator()); 84 } 85 } 86 | Popular Tags |