1 58 package org.krysalis.barcode.output.svg; 59 60 import org.krysalis.barcode.output.AbstractXMLGeneratingCanvasProvider; 61 import org.krysalis.barcode.output.BarcodeCanvasSetupException; 62 63 68 public abstract class AbstractSVGGeneratingCanvasProvider 69 extends AbstractXMLGeneratingCanvasProvider { 70 71 72 public static final String SVG_NAMESPACE = "http://www.w3.org/2000/svg"; 73 74 private boolean useNamespace = true; 75 private String prefix = ""; 76 77 83 public AbstractSVGGeneratingCanvasProvider(boolean useNamespace, String namespacePrefix) 84 throws BarcodeCanvasSetupException { 85 if (!useNamespace && namespacePrefix != null) 86 throw new IllegalArgumentException ("No prefix allow when namespaces are enabled"); 87 this.useNamespace = true; 88 this.prefix = namespacePrefix; 89 } 90 91 96 public AbstractSVGGeneratingCanvasProvider(String namespacePrefix) 97 throws BarcodeCanvasSetupException { 98 this(true, namespacePrefix); 99 } 100 101 106 public AbstractSVGGeneratingCanvasProvider(boolean useNamespace) 107 throws BarcodeCanvasSetupException { 108 this(useNamespace, null); 109 } 110 111 116 public AbstractSVGGeneratingCanvasProvider() 117 throws BarcodeCanvasSetupException { 118 this(true, null); 119 } 120 121 125 public boolean isNamespaceEnabled() { 126 return this.useNamespace; 127 } 128 129 133 public String getNamespacePrefix() { 134 return this.prefix; 135 } 136 137 143 protected String getQualifiedName(String localName) { 144 if (prefix == null || "".equals(prefix)) { 145 return localName; 146 } else { 147 return prefix + ':' + localName; 148 } 149 } 150 151 } 152 | Popular Tags |