Added more white space and tab space in the code
This commit is contained in:
parent
275c4aa161
commit
5ba12c3a3e
|
@ -40,12 +40,12 @@ import org.xml.sax.helpers.AttributesImpl;
|
||||||
* @version 1.0 May 3, 2013
|
* @version 1.0 May 3, 2013
|
||||||
*/
|
*/
|
||||||
public class SAX3WriterEnum<TAG extends Enum<?>,TAG_WRITER extends ContentWriter> implements SAX3WriterEnumHammer<TAG>, Closeable {
|
public class SAX3WriterEnum<TAG extends Enum<?>,TAG_WRITER extends ContentWriter> implements SAX3WriterEnumHammer<TAG>, Closeable {
|
||||||
|
|
||||||
private final Attributes EMPTY_ATTRIBUTES = new AttributesImpl();
|
private final Attributes EMPTY_ATTRIBUTES = new AttributesImpl();
|
||||||
private final TAG_WRITER contentWriter;
|
private final TAG_WRITER contentWriter;
|
||||||
private final String tagNamespaceUri;
|
private final String tagNamespaceUri;
|
||||||
private final String tagNamespacePrefix;
|
private final String tagNamespacePrefix;
|
||||||
|
|
||||||
public SAX3WriterEnum(TAG_WRITER contentWriter) {
|
public SAX3WriterEnum(TAG_WRITER contentWriter) {
|
||||||
this(contentWriter, SAX3XMLConstants.NULL_NS_URI, SAX3XMLConstants.NULL_NS_URI);
|
this(contentWriter, SAX3XMLConstants.NULL_NS_URI, SAX3XMLConstants.NULL_NS_URI);
|
||||||
}
|
}
|
||||||
|
@ -91,12 +91,12 @@ public class SAX3WriterEnum<TAG extends Enum<?>,TAG_WRITER extends ContentWriter
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContentCloseable printTag(TAG tag, Attributes atts) throws IOException {
|
public ContentCloseable printTag(TAG tag, Attributes atts) throws IOException {
|
||||||
printTagStart(tag,atts);
|
printTagStart(tag, atts);
|
||||||
return () -> printTagEnd(tag);
|
return () -> printTagEnd(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printTagStartEnd(TAG tag, Attributes atts) throws IOException {
|
public void printTagStartEnd(TAG tag, Attributes atts) throws IOException {
|
||||||
printTagStart(tag,atts);
|
printTagStart(tag, atts);
|
||||||
printTagEnd(tag);
|
printTagEnd(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ public class SAX3WriterEnum<TAG extends Enum<?>,TAG_WRITER extends ContentWriter
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printTagStart(TAG tag) throws IOException {
|
public void printTagStart(TAG tag) throws IOException {
|
||||||
printTagStart(tag,EMPTY_ATTRIBUTES);
|
printTagStart(tag, EMPTY_ATTRIBUTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printTagStart(TAG tag, Attributes atts) throws IOException {
|
public void printTagStart(TAG tag, Attributes atts) throws IOException {
|
||||||
|
@ -127,8 +127,7 @@ public class SAX3WriterEnum<TAG extends Enum<?>,TAG_WRITER extends ContentWriter
|
||||||
|
|
||||||
private String toTagString(TAG tag) {
|
private String toTagString(TAG tag) {
|
||||||
String result = tag.name();
|
String result = tag.name();
|
||||||
if (result.startsWith("_"))
|
if (result.startsWith("_")) {
|
||||||
{
|
|
||||||
result = result.substring(1); // remove _
|
result = result.substring(1); // remove _
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -136,7 +135,7 @@ public class SAX3WriterEnum<TAG extends Enum<?>,TAG_WRITER extends ContentWriter
|
||||||
|
|
||||||
public void printTagCharacters(TAG tag, String text) throws IOException {
|
public void printTagCharacters(TAG tag, String text) throws IOException {
|
||||||
printTagStart(tag);
|
printTagStart(tag);
|
||||||
if (text==null) {
|
if (text == null) {
|
||||||
text = " ";
|
text = " ";
|
||||||
}
|
}
|
||||||
printCharacters(text);
|
printCharacters(text);
|
||||||
|
|
|
@ -42,15 +42,15 @@ public interface SAX3WriterEnumHammer<TAG extends Enum<?>> {
|
||||||
|
|
||||||
void printTagStartEnd(TAG tag) throws IOException;
|
void printTagStartEnd(TAG tag) throws IOException;
|
||||||
|
|
||||||
void printTagStartEnd(TAG tag,Attributes atts) throws IOException;
|
void printTagStartEnd(TAG tag, Attributes atts) throws IOException;
|
||||||
|
|
||||||
void printTagStart(TAG tag) throws IOException;
|
void printTagStart(TAG tag) throws IOException;
|
||||||
|
|
||||||
void printTagStart(TAG tag,Attributes atts) throws IOException;
|
void printTagStart(TAG tag, Attributes atts) throws IOException;
|
||||||
|
|
||||||
void printTagEnd(TAG tag) throws IOException;
|
void printTagEnd(TAG tag) throws IOException;
|
||||||
|
|
||||||
void printTagCharacters(TAG tag,String text) throws IOException;
|
void printTagCharacters(TAG tag, String text) throws IOException;
|
||||||
|
|
||||||
void printCharacters(String text) throws IOException;
|
void printCharacters(String text) throws IOException;
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ import org.xml.sax.helpers.AttributesImpl;
|
||||||
*/
|
*/
|
||||||
public class SAX3WriterHtml extends SAX3WriterEnum<SAX3WriterHtml.Tag,SAX3WriterXml> {
|
public class SAX3WriterHtml extends SAX3WriterEnum<SAX3WriterHtml.Tag,SAX3WriterXml> {
|
||||||
|
|
||||||
public SAX3WriterHtml(Writer out,String encoding) {
|
public SAX3WriterHtml(Writer out, String encoding) {
|
||||||
super(new SAX3WriterXml(out, encoding), "", SAX3XMLConstants.NULL_NS_URI);
|
super(new SAX3WriterXml(out, encoding), "", SAX3XMLConstants.NULL_NS_URI);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,10 +58,10 @@ public class SAX3WriterHtml extends SAX3WriterEnum<SAX3WriterHtml.Tag,SAX3Writer
|
||||||
|
|
||||||
public void printHtmlStart(String language) throws IOException {
|
public void printHtmlStart(String language) throws IOException {
|
||||||
AttributesImpl atts = new AttributesImpl();
|
AttributesImpl atts = new AttributesImpl();
|
||||||
if (language!=null) {
|
if (language != null) {
|
||||||
atts.addAttribute("", "lang", "", "", language);
|
atts.addAttribute("", "lang", "", "", language);
|
||||||
}
|
}
|
||||||
printTagStart(Tag.html,atts);
|
printTagStart(Tag.html, atts);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printHtmlEnd() throws IOException {
|
public void printHtmlEnd() throws IOException {
|
||||||
|
@ -70,11 +70,11 @@ public class SAX3WriterHtml extends SAX3WriterEnum<SAX3WriterHtml.Tag,SAX3Writer
|
||||||
|
|
||||||
public void printHeadMetaDate() throws IOException {
|
public void printHeadMetaDate() throws IOException {
|
||||||
Calendar cal = Calendar.getInstance();
|
Calendar cal = Calendar.getInstance();
|
||||||
printHeadMeta("date",cal.get(Calendar.YEAR)+"-"+(cal.get(Calendar.MONTH)+1)+"-"+cal.get(Calendar.DAY_OF_MONTH));
|
printHeadMeta("date", cal.get(Calendar.YEAR) + "-" + (cal.get(Calendar.MONTH)+1) + "-" + cal.get(Calendar.DAY_OF_MONTH));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printHeadTitle(String title) throws IOException {
|
public void printHeadTitle(String title) throws IOException {
|
||||||
printTagCharacters(Tag.title,title);
|
printTagCharacters(Tag.title, title);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printHeadMetaContentType() throws IOException {
|
public void printHeadMetaContentType() throws IOException {
|
||||||
|
@ -104,7 +104,7 @@ public class SAX3WriterHtml extends SAX3WriterEnum<SAX3WriterHtml.Tag,SAX3Writer
|
||||||
public void printScriptInline(String script) throws IOException {
|
public void printScriptInline(String script) throws IOException {
|
||||||
AttributesImpl atts = new AttributesImpl();
|
AttributesImpl atts = new AttributesImpl();
|
||||||
atts.addAttribute("", "type", "", "", "text/javascript");
|
atts.addAttribute("", "type", "", "", "text/javascript");
|
||||||
printTagStart(Tag.script,atts);
|
printTagStart(Tag.script, atts);
|
||||||
printComment(script);
|
printComment(script);
|
||||||
printTagEnd(Tag.script);
|
printTagEnd(Tag.script);
|
||||||
}
|
}
|
||||||
|
@ -121,11 +121,11 @@ public class SAX3WriterHtml extends SAX3WriterEnum<SAX3WriterHtml.Tag,SAX3Writer
|
||||||
printTagStart(Tag.div);printCharacters(text);printTagEnd(Tag.div);
|
printTagStart(Tag.div);printCharacters(text);printTagEnd(Tag.div);
|
||||||
printTagEnd(Tag.noscript);
|
printTagEnd(Tag.noscript);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printHrefNamed(String name) throws IOException {
|
public void printHrefNamed(String name) throws IOException {
|
||||||
AttributesImpl atts = new AttributesImpl();
|
AttributesImpl atts = new AttributesImpl();
|
||||||
atts.addAttribute("", "name", "", "", name);
|
atts.addAttribute("", "name", "", "", name);
|
||||||
printTagStart(Tag.a,atts);
|
printTagStart(Tag.a, atts);
|
||||||
printComment(" ");
|
printComment(" ");
|
||||||
printTagEnd(Tag.a);
|
printTagEnd(Tag.a);
|
||||||
}
|
}
|
||||||
|
@ -134,7 +134,7 @@ public class SAX3WriterHtml extends SAX3WriterEnum<SAX3WriterHtml.Tag,SAX3Writer
|
||||||
AttributesImpl atts = new AttributesImpl();
|
AttributesImpl atts = new AttributesImpl();
|
||||||
atts.addAttribute("", "href", "", "", href);
|
atts.addAttribute("", "href", "", "", href);
|
||||||
atts.addAttribute("", "target", "", "", target);
|
atts.addAttribute("", "target", "", "", target);
|
||||||
printTagStart(Tag.a,atts);
|
printTagStart(Tag.a, atts);
|
||||||
printCharacters(text);
|
printCharacters(text);
|
||||||
printTagEnd(Tag.a);
|
printTagEnd(Tag.a);
|
||||||
}
|
}
|
||||||
|
@ -156,7 +156,7 @@ public class SAX3WriterHtml extends SAX3WriterEnum<SAX3WriterHtml.Tag,SAX3Writer
|
||||||
printTagStart(Tag.a,atts);
|
printTagStart(Tag.a,atts);
|
||||||
if (spanClass != null) {
|
if (spanClass != null) {
|
||||||
atts = new AttributesImpl();
|
atts = new AttributesImpl();
|
||||||
if (spanClass.length()>0) {
|
if (spanClass.length() > 0) {
|
||||||
atts.addAttribute("", "class", "", "", spanClass);
|
atts.addAttribute("", "class", "", "", spanClass);
|
||||||
}
|
}
|
||||||
printTagStart(Tag.span,atts);
|
printTagStart(Tag.span,atts);
|
||||||
|
@ -180,7 +180,7 @@ public class SAX3WriterHtml extends SAX3WriterEnum<SAX3WriterHtml.Tag,SAX3Writer
|
||||||
printCharacters(text);
|
printCharacters(text);
|
||||||
printTagEnd(tag);
|
printTagEnd(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContentCloseable printTag(Tag tag, String tagClass) throws IOException {
|
public ContentCloseable printTag(Tag tag, String tagClass) throws IOException {
|
||||||
return printTag(tag, tagClass, null, null);
|
return printTag(tag, tagClass, null, null);
|
||||||
}
|
}
|
||||||
|
@ -286,9 +286,9 @@ public class SAX3WriterHtml extends SAX3WriterEnum<SAX3WriterHtml.Tag,SAX3Writer
|
||||||
private final String systemId;
|
private final String systemId;
|
||||||
|
|
||||||
private DocType(String name, String publicId, String systemId) {
|
private DocType(String name, String publicId, String systemId) {
|
||||||
this.name=name;
|
this.name = name;
|
||||||
this.publicId=publicId;
|
this.publicId = publicId;
|
||||||
this.systemId=systemId;
|
this.systemId = systemId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -42,7 +42,7 @@ public class SAX3WriterXml extends AbstractContentWriter {
|
||||||
* Creates XmlWriter which prints to the Writer interface.
|
* Creates XmlWriter which prints to the Writer interface.
|
||||||
* @param out The writer to print the xml to.
|
* @param out The writer to print the xml to.
|
||||||
*/
|
*/
|
||||||
public SAX3WriterXml(Writer out,String encoding) {
|
public SAX3WriterXml(Writer out, String encoding) {
|
||||||
super(out);
|
super(out);
|
||||||
getPropertyConfig().setProperty(OUTPUT_ENCODING, encoding);
|
getPropertyConfig().setProperty(OUTPUT_ENCODING, encoding);
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ public class SAX3WriterXml extends AbstractContentWriter {
|
||||||
* @throws UnsupportedEncodingException Is thrown when UTF-8 can't we printed.
|
* @throws UnsupportedEncodingException Is thrown when UTF-8 can't we printed.
|
||||||
*/
|
*/
|
||||||
public SAX3WriterXml(OutputStream out) throws UnsupportedEncodingException {
|
public SAX3WriterXml(OutputStream out) throws UnsupportedEncodingException {
|
||||||
this(new OutputStreamWriter(out, SAX3XMLConstants.XML_DEFAULT_ENCODING),SAX3XMLConstants.XML_DEFAULT_ENCODING);
|
this(new OutputStreamWriter(out, SAX3XMLConstants.XML_DEFAULT_ENCODING), SAX3XMLConstants.XML_DEFAULT_ENCODING);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -71,6 +71,6 @@ public class SAX3WriterXml extends AbstractContentWriter {
|
||||||
* @throws UnsupportedEncodingException Is thrown when UTF-8 can't we printed.
|
* @throws UnsupportedEncodingException Is thrown when UTF-8 can't we printed.
|
||||||
*/
|
*/
|
||||||
public SAX3WriterXml(OutputStream out,String encoding) throws UnsupportedEncodingException {
|
public SAX3WriterXml(OutputStream out,String encoding) throws UnsupportedEncodingException {
|
||||||
this(new OutputStreamWriter(out, encoding),encoding);
|
this(new OutputStreamWriter(out, encoding), encoding);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,39 +37,39 @@ import org.xml.sax.helpers.AttributesImpl;
|
||||||
*/
|
*/
|
||||||
public class SAX3WriterXsd extends SAX3WriterEnum<SAX3WriterXsd.Tag,SAX3WriterXml> {
|
public class SAX3WriterXsd extends SAX3WriterEnum<SAX3WriterXsd.Tag,SAX3WriterXml> {
|
||||||
|
|
||||||
public SAX3WriterXsd(Writer out,String encoding) {
|
public SAX3WriterXsd(Writer out, String encoding) {
|
||||||
super(new SAX3WriterXml(out, encoding),SAX3XMLConstants.XML_SCHEMA_NS_URI, SAX3XMLConstants.NULL_NS_URI);
|
super(new SAX3WriterXml(out, encoding), SAX3XMLConstants.XML_SCHEMA_NS_URI, SAX3XMLConstants.NULL_NS_URI);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SAX3PropertyConfig getPropertyConfig() {
|
public SAX3PropertyConfig getPropertyConfig() {
|
||||||
return getContentWriterWrapped().getPropertyConfig();
|
return getContentWriterWrapped().getPropertyConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printXsdImport(String namespace,String schemaLocation) throws IOException {
|
public void printXsdImport(String namespace, String schemaLocation) throws IOException {
|
||||||
AttributesImpl atts = new AttributesImpl();
|
AttributesImpl atts = new AttributesImpl();
|
||||||
atts.addAttribute ("", "namespace", "", "", namespace);
|
atts.addAttribute("", "namespace", "", "", namespace);
|
||||||
atts.addAttribute ("", "schemaLocation", "", "", schemaLocation);
|
atts.addAttribute("", "schemaLocation", "", "", schemaLocation);
|
||||||
printTagStartEnd(Tag._import, atts);
|
printTagStartEnd(Tag._import, atts);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printXsdDocumentation(String description) throws IOException {
|
public void printXsdDocumentation(String description) throws IOException {
|
||||||
if (description==null) {
|
if (description == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
printTagStart(Tag.annotation);
|
printTagStart(Tag.annotation);
|
||||||
AttributesImpl atts = new AttributesImpl();
|
AttributesImpl atts = new AttributesImpl();
|
||||||
atts.addAttribute ("", "xml:lang", "", "", "en");
|
atts.addAttribute("", "xml:lang", "", "", "en");
|
||||||
printTagStart(Tag.documentation,atts);
|
printTagStart(Tag.documentation, atts);
|
||||||
printCharacters(description);
|
printCharacters(description);
|
||||||
printTagEnd(Tag.documentation);
|
printTagEnd(Tag.documentation);
|
||||||
printTagEnd(Tag.annotation);
|
printTagEnd(Tag.annotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printXsdElementAttribute(String name,String type,String description) throws IOException {
|
public void printXsdElementAttribute(String name, String type, String description) throws IOException {
|
||||||
AttributesImpl atts = new AttributesImpl();
|
AttributesImpl atts = new AttributesImpl();
|
||||||
atts.addAttribute ("", "name", "", "", name);
|
atts.addAttribute("", "name", "", "", name);
|
||||||
atts.addAttribute ("", "type", "", "", type);
|
atts.addAttribute("", "type", "", "", type);
|
||||||
printTagStart(Tag.attribute,atts);
|
printTagStart(Tag.attribute, atts);
|
||||||
printXsdDocumentation(description);
|
printXsdDocumentation(description);
|
||||||
printTagEnd(Tag.attribute);
|
printTagEnd(Tag.attribute);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ import org.xml.sax.SAXException;
|
||||||
* @version 1.0 May 3, 2013
|
* @version 1.0 May 3, 2013
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractContentWriter extends AbstractContentWriterLexical implements ContentWriter {
|
public abstract class AbstractContentWriter extends AbstractContentWriterLexical implements ContentWriter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an Lecical content writer for XML.
|
* Creates an Lecical content writer for XML.
|
||||||
* @param out The writer to write to.
|
* @param out The writer to write to.
|
||||||
|
@ -42,13 +42,13 @@ public abstract class AbstractContentWriter extends AbstractContentWriterLexical
|
||||||
public AbstractContentWriter(Writer out) {
|
public AbstractContentWriter(Writer out) {
|
||||||
super(out);
|
super(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts and end then element.
|
* Starts and end then element.
|
||||||
* @see org.x4o.sax3.io.ContentWriter#startElementEnd(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
|
* @see org.x4o.sax3.io.ContentWriter#startElementEnd(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
|
||||||
*/
|
*/
|
||||||
public void startElementEnd(String uri, String localName, String name, Attributes atts) throws SAXException {
|
public void startElementEnd(String uri, String localName, String name, Attributes atts) throws SAXException {
|
||||||
startElement(uri,localName,name, atts);
|
startElement(uri, localName, name, atts);
|
||||||
endElement(uri, localName, name);
|
endElement(uri, localName, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,24 +65,24 @@ public class AbstractContentWriterHandler implements ContentHandler, Closeable {
|
||||||
private String lastElement = null;
|
private String lastElement = null;
|
||||||
private Stack<String> elements = null;
|
private Stack<String> elements = null;
|
||||||
|
|
||||||
private final static String PROPERTY_CONTEXT_PREFIX = SAX3PropertyConfig.X4O_PROPERTIES_PREFIX+"content/"; // TODO: change to "writer/xml"
|
private final static String PROPERTY_CONTEXT_PREFIX = SAX3PropertyConfig.X4O_PROPERTIES_PREFIX + "content/"; // TODO: change to "writer/xml"
|
||||||
public final static SAX3PropertyConfig DEFAULT_PROPERTY_CONFIG;
|
public final static SAX3PropertyConfig DEFAULT_PROPERTY_CONFIG;
|
||||||
public final static String OUTPUT_ENCODING = PROPERTY_CONTEXT_PREFIX+"output/encoding";
|
public final static String OUTPUT_ENCODING = PROPERTY_CONTEXT_PREFIX + "output/encoding";
|
||||||
public final static String OUTPUT_CHAR_TAB = PROPERTY_CONTEXT_PREFIX+"output/char-tab";
|
public final static String OUTPUT_CHAR_TAB = PROPERTY_CONTEXT_PREFIX + "output/char-tab";
|
||||||
public final static String OUTPUT_CHAR_NEWLINE = PROPERTY_CONTEXT_PREFIX+"output/char-newline";
|
public final static String OUTPUT_CHAR_NEWLINE = PROPERTY_CONTEXT_PREFIX + "output/char-newline";
|
||||||
public final static String OUTPUT_CHAR_NULL = PROPERTY_CONTEXT_PREFIX+"output/char-null";
|
public final static String OUTPUT_CHAR_NULL = PROPERTY_CONTEXT_PREFIX + "output/char-null";
|
||||||
public final static String OUTPUT_COMMENT_ENABLE = PROPERTY_CONTEXT_PREFIX+"output/comment-enable";
|
public final static String OUTPUT_COMMENT_ENABLE = PROPERTY_CONTEXT_PREFIX + "output/comment-enable";
|
||||||
public final static String OUTPUT_COMMENT_AUTO_SPACE = PROPERTY_CONTEXT_PREFIX+"output/comment-auto-space";
|
public final static String OUTPUT_COMMENT_AUTO_SPACE = PROPERTY_CONTEXT_PREFIX + "output/comment-auto-space";
|
||||||
public final static String OUTPUT_LINE_BREAK_WIDTH = PROPERTY_CONTEXT_PREFIX+"output/line-break-width";
|
public final static String OUTPUT_LINE_BREAK_WIDTH = PROPERTY_CONTEXT_PREFIX + "output/line-break-width";
|
||||||
public final static String OUTPUT_LINE_PER_ATTRIBUTE = PROPERTY_CONTEXT_PREFIX+"output/line-per-attribute";
|
public final static String OUTPUT_LINE_PER_ATTRIBUTE = PROPERTY_CONTEXT_PREFIX + "output/line-per-attribute";
|
||||||
public final static String PROLOG_LICENCE_FILE = PROPERTY_CONTEXT_PREFIX+"prolog/licence-file";
|
public final static String PROLOG_LICENCE_FILE = PROPERTY_CONTEXT_PREFIX + "prolog/licence-file";
|
||||||
public final static String PROLOG_LICENCE_RESOURCE = PROPERTY_CONTEXT_PREFIX+"prolog/licence-resource";
|
public final static String PROLOG_LICENCE_RESOURCE = PROPERTY_CONTEXT_PREFIX + "prolog/licence-resource";
|
||||||
public final static String PROLOG_LICENCE_ENCODING = PROPERTY_CONTEXT_PREFIX+"prolog/licence-encoding";
|
public final static String PROLOG_LICENCE_ENCODING = PROPERTY_CONTEXT_PREFIX + "prolog/licence-encoding";
|
||||||
public final static String PROLOG_LICENCE_ENABLE = PROPERTY_CONTEXT_PREFIX+"prolog/licence-enable";
|
public final static String PROLOG_LICENCE_ENABLE = PROPERTY_CONTEXT_PREFIX + "prolog/licence-enable";
|
||||||
public final static String PROLOG_USER_COMMENT = PROPERTY_CONTEXT_PREFIX+"prolog/user-comment";
|
public final static String PROLOG_USER_COMMENT = PROPERTY_CONTEXT_PREFIX + "prolog/user-comment";
|
||||||
public final static String PROLOG_USER_COMMENT_ENABLE = PROPERTY_CONTEXT_PREFIX+"prolog/user-comment-enable";
|
public final static String PROLOG_USER_COMMENT_ENABLE = PROPERTY_CONTEXT_PREFIX + "prolog/user-comment-enable";
|
||||||
public final static String ROOT_END_APPEND_NEWLINE = PROPERTY_CONTEXT_PREFIX+"root/end-append-newline";
|
public final static String ROOT_END_APPEND_NEWLINE = PROPERTY_CONTEXT_PREFIX + "root/end-append-newline";
|
||||||
public final static String ROOT_START_NAMESPACE_ALL = PROPERTY_CONTEXT_PREFIX+"root/start-namespace-all";
|
public final static String ROOT_START_NAMESPACE_ALL = PROPERTY_CONTEXT_PREFIX + "root/start-namespace-all";
|
||||||
|
|
||||||
static {
|
static {
|
||||||
DEFAULT_PROPERTY_CONFIG = new SAX3PropertyConfig(true,null,PROPERTY_CONTEXT_PREFIX,
|
DEFAULT_PROPERTY_CONFIG = new SAX3PropertyConfig(true,null,PROPERTY_CONTEXT_PREFIX,
|
||||||
|
@ -114,7 +114,7 @@ public class AbstractContentWriterHandler implements ContentHandler, Closeable {
|
||||||
this.prefixMapping = new HashMap<String,String>(15);
|
this.prefixMapping = new HashMap<String,String>(15);
|
||||||
this.printedMappings = new ArrayList<String>(15);
|
this.printedMappings = new ArrayList<String>(15);
|
||||||
this.elements = new Stack<String>();
|
this.elements = new Stack<String>();
|
||||||
this.propertyConfig = new SAX3PropertyConfig(DEFAULT_PROPERTY_CONFIG,PROPERTY_CONTEXT_PREFIX);
|
this.propertyConfig = new SAX3PropertyConfig(DEFAULT_PROPERTY_CONFIG, PROPERTY_CONTEXT_PREFIX);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SAX3PropertyConfig getPropertyConfig() {
|
public SAX3PropertyConfig getPropertyConfig() {
|
||||||
|
@ -143,19 +143,19 @@ public class AbstractContentWriterHandler implements ContentHandler, Closeable {
|
||||||
InputStream licenceInput = null;
|
InputStream licenceInput = null;
|
||||||
String licenceEncoding = propertyConfig.getPropertyString(PROLOG_LICENCE_ENCODING);
|
String licenceEncoding = propertyConfig.getPropertyString(PROLOG_LICENCE_ENCODING);
|
||||||
String licenceResource = propertyConfig.getPropertyString(PROLOG_LICENCE_RESOURCE);
|
String licenceResource = propertyConfig.getPropertyString(PROLOG_LICENCE_RESOURCE);
|
||||||
if (licenceResource!=null) {
|
if (licenceResource != null) {
|
||||||
ClassLoader cl = Thread.currentThread().getContextClassLoader();
|
ClassLoader cl = Thread.currentThread().getContextClassLoader();
|
||||||
if (cl == null) {
|
if (cl == null) {
|
||||||
cl = this.getClass().getClassLoader();
|
cl = this.getClass().getClassLoader();
|
||||||
}
|
}
|
||||||
licenceInput = cl.getResourceAsStream(licenceResource);
|
licenceInput = cl.getResourceAsStream(licenceResource);
|
||||||
if (licenceInput==null) {
|
if (licenceInput == null) {
|
||||||
throw new NullPointerException("Could not load licence resource from: "+licenceResource);
|
throw new NullPointerException("Could not load licence resource from: " + licenceResource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (licenceInput==null) {
|
if (licenceInput == null) {
|
||||||
File licenceFile = propertyConfig.getPropertyFile(PROLOG_LICENCE_FILE);
|
File licenceFile = propertyConfig.getPropertyFile(PROLOG_LICENCE_FILE);
|
||||||
if (licenceFile==null) {
|
if (licenceFile == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
@ -166,7 +166,7 @@ public class AbstractContentWriterHandler implements ContentHandler, Closeable {
|
||||||
}
|
}
|
||||||
String licenceText;
|
String licenceText;
|
||||||
try {
|
try {
|
||||||
licenceText = readLicenceStream(licenceInput,licenceEncoding);
|
licenceText = readLicenceStream(licenceInput, licenceEncoding);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new SAXException(e);
|
throw new SAXException(e);
|
||||||
}
|
}
|
||||||
|
@ -174,24 +174,24 @@ public class AbstractContentWriterHandler implements ContentHandler, Closeable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String readLicenceStream(InputStream inputStream, String encoding) throws IOException {
|
private String readLicenceStream(InputStream inputStream, String encoding) throws IOException {
|
||||||
if (encoding==null) {
|
if (encoding == null) {
|
||||||
encoding = SAX3XMLConstants.XML_DEFAULT_ENCODING;
|
encoding = SAX3XMLConstants.XML_DEFAULT_ENCODING;
|
||||||
}
|
}
|
||||||
BufferedReader br = new BufferedReader(new InputStreamReader(inputStream,Charset.forName(encoding)));
|
BufferedReader br = new BufferedReader(new InputStreamReader(inputStream, Charset.forName(encoding)));
|
||||||
try {
|
try {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append('\n'); // like plugin
|
sb.append('\n');
|
||||||
sb.append('\n'); // like plugin
|
sb.append('\n');
|
||||||
String line = br.readLine();
|
String line = br.readLine();
|
||||||
while (line != null) {
|
while (line != null) {
|
||||||
if (line.length()>0) {
|
if (line.length() > 0) {
|
||||||
sb.append(" "); // like plugin
|
sb.append(" ");
|
||||||
}
|
}
|
||||||
sb.append(line);
|
sb.append(line);
|
||||||
sb.append('\n');
|
sb.append('\n');
|
||||||
line = br.readLine();
|
line = br.readLine();
|
||||||
}
|
}
|
||||||
sb.append('\n'); // like plugin
|
sb.append('\n');
|
||||||
String out = sb.toString();
|
String out = sb.toString();
|
||||||
return out;
|
return out;
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -221,8 +221,8 @@ public class AbstractContentWriterHandler implements ContentHandler, Closeable {
|
||||||
*/
|
*/
|
||||||
public void endDocument() throws SAXException {
|
public void endDocument() throws SAXException {
|
||||||
writeFlush();
|
writeFlush();
|
||||||
if (elements.size()>0) {
|
if (elements.size() > 0) {
|
||||||
throw new SAXException("Invalid xml still have "+elements.size()+" elements open.");
|
throw new SAXException("Invalid xml still have " + elements.size() + " elements open.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,13 +234,13 @@ public class AbstractContentWriterHandler implements ContentHandler, Closeable {
|
||||||
* @see org.xml.sax.ContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
|
* @see org.xml.sax.ContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
|
||||||
*/
|
*/
|
||||||
public void startElement(String uri, String localName, String name, Attributes atts) throws SAXException {
|
public void startElement(String uri, String localName, String name, Attributes atts) throws SAXException {
|
||||||
if (localName==null) {
|
if (localName == null) {
|
||||||
throw new SAXException("LocalName may not be null.");
|
throw new SAXException("LocalName may not be null.");
|
||||||
}
|
}
|
||||||
if (SAX3XMLConstants.isNameString(localName)==false) {
|
if (SAX3XMLConstants.isNameString(localName)==false) {
|
||||||
throw new SAXException("LocalName of element is not valid in xml; '"+localName+"'");
|
throw new SAXException("LocalName of element is not valid in xml; '" + localName + "'");
|
||||||
}
|
}
|
||||||
for (int i=0;i<atts.getLength();i++) {
|
for (int i = 0; i < atts.getLength(); i++) {
|
||||||
boolean isFirst = true;
|
boolean isFirst = true;
|
||||||
String attrLocalName = atts.getLocalName(i);
|
String attrLocalName = atts.getLocalName(i);
|
||||||
if (attrLocalName.isEmpty()) {
|
if (attrLocalName.isEmpty()) {
|
||||||
|
@ -252,11 +252,11 @@ public class AbstractContentWriterHandler implements ContentHandler, Closeable {
|
||||||
if (isFirst) {
|
if (isFirst) {
|
||||||
isFirst = false;
|
isFirst = false;
|
||||||
if (!SAX3XMLConstants.isNameStartChar(attrLocalName.codePoints().findFirst().getAsInt())) {
|
if (!SAX3XMLConstants.isNameStartChar(attrLocalName.codePoints().findFirst().getAsInt())) {
|
||||||
throw new SAXException("LocalAttributeName has illegal start character: " + attrLocalName);
|
throw new SAXException("LocalAttributeName has illegal start character: " + attrLocalName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!SAX3XMLConstants.isNameChar(c)) {
|
if (!SAX3XMLConstants.isNameChar(c)) {
|
||||||
throw new SAXException("LocalAttributeName has illegal name character: " + attrLocalName);
|
throw new SAXException("LocalAttributeName has illegal name character: " + attrLocalName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -279,14 +279,14 @@ public class AbstractContentWriterHandler implements ContentHandler, Closeable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startElementTag(String uri, String localName) throws SAXException {
|
public void startElementTag(String uri, String localName) throws SAXException {
|
||||||
if (SAX3XMLConstants.NULL_NS_URI.equals(uri) | uri==null) {
|
if (SAX3XMLConstants.NULL_NS_URI.equals(uri) || uri == null) {
|
||||||
startElement.append(localName);
|
startElement.append(localName);
|
||||||
} else {
|
} else {
|
||||||
String prefix = prefixMapping.get(uri);
|
String prefix = prefixMapping.get(uri);
|
||||||
if (prefix==null) {
|
if (prefix == null) {
|
||||||
throw new SAXException("preFixUri: "+uri+" is not started.");
|
throw new SAXException("preFixUri: " + uri + " is not started.");
|
||||||
}
|
}
|
||||||
if (SAX3XMLConstants.NULL_NS_URI.equals(prefix)==false) {
|
if (SAX3XMLConstants.NULL_NS_URI.equals(prefix) == false) {
|
||||||
startElement.append(prefix);
|
startElement.append(prefix);
|
||||||
startElement.append(SAX3XMLConstants.XMLNS_ASSIGN);
|
startElement.append(SAX3XMLConstants.XMLNS_ASSIGN);
|
||||||
}
|
}
|
||||||
|
@ -306,13 +306,13 @@ public class AbstractContentWriterHandler implements ContentHandler, Closeable {
|
||||||
}
|
}
|
||||||
String prefix = prefixMapping.get(uri);
|
String prefix = prefixMapping.get(uri);
|
||||||
if (prefix == null) {
|
if (prefix == null) {
|
||||||
throw new SAXException("preFixUri: "+uri+" is not started.");
|
throw new SAXException("preFixUri: " + uri + " is not started.");
|
||||||
}
|
}
|
||||||
printedMappings.add(uri);
|
printedMappings.add(uri);
|
||||||
|
|
||||||
startElement.append(' ');
|
startElement.append(' ');
|
||||||
startElement.append(SAX3XMLConstants.XMLNS_ATTRIBUTE);
|
startElement.append(SAX3XMLConstants.XMLNS_ATTRIBUTE);
|
||||||
if ("".equals(prefix)==false) {
|
if ("".equals(prefix) == false) {
|
||||||
startElement.append(SAX3XMLConstants.XMLNS_ASSIGN);
|
startElement.append(SAX3XMLConstants.XMLNS_ASSIGN);
|
||||||
startElement.append(prefix);
|
startElement.append(prefix);
|
||||||
}
|
}
|
||||||
|
@ -327,27 +327,25 @@ public class AbstractContentWriterHandler implements ContentHandler, Closeable {
|
||||||
}
|
}
|
||||||
String prefix = null;
|
String prefix = null;
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
for (String uri2:prefixMapping.keySet()) {
|
for (String uri2 : prefixMapping.keySet()) {
|
||||||
if (printedMappings.contains(uri2)) {
|
if (printedMappings.contains(uri2)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
prefix = prefixMapping.get(uri2);
|
prefix = prefixMapping.get(uri2);
|
||||||
if (prefix==null) {
|
if (prefix == null) {
|
||||||
throw new SAXException("preFixUri: "+uri2+" is not started.");
|
throw new SAXException("preFixUri: " + uri2 + " is not started.");
|
||||||
}
|
}
|
||||||
printedMappings.add(uri2);
|
printedMappings.add(uri2);
|
||||||
if (SAX3XMLConstants.NULL_NS_URI.equals(uri2)) {
|
if (SAX3XMLConstants.NULL_NS_URI.equals(uri2)) {
|
||||||
continue; // don't print empty namespace uri location
|
continue; // don't print empty namespace uri location
|
||||||
}
|
}
|
||||||
|
|
||||||
if (first) {
|
if (first) {
|
||||||
startElement.append(getPropertyConfig().getPropertyString(OUTPUT_CHAR_NEWLINE));
|
startElement.append(getPropertyConfig().getPropertyString(OUTPUT_CHAR_NEWLINE));
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
startElement.append(' ');
|
startElement.append(' ');
|
||||||
startElement.append(SAX3XMLConstants.XMLNS_ATTRIBUTE);
|
startElement.append(SAX3XMLConstants.XMLNS_ATTRIBUTE);
|
||||||
if ("".equals(prefix)==false) {
|
if ("".equals(prefix) == false) {
|
||||||
startElement.append(SAX3XMLConstants.XMLNS_ASSIGN);
|
startElement.append(SAX3XMLConstants.XMLNS_ASSIGN);
|
||||||
startElement.append(prefix);
|
startElement.append(prefix);
|
||||||
}
|
}
|
||||||
|
@ -367,24 +365,23 @@ public class AbstractContentWriterHandler implements ContentHandler, Closeable {
|
||||||
|
|
||||||
private void startElementAttributes(Attributes atts) throws SAXException {
|
private void startElementAttributes(Attributes atts) throws SAXException {
|
||||||
int prevChars = 0;
|
int prevChars = 0;
|
||||||
for (int i=0;i<atts.getLength();i++) {
|
for (int i = 0; i < atts.getLength(); i++) {
|
||||||
String attributeUri = atts.getURI(i);
|
String attributeUri = atts.getURI(i);
|
||||||
String attributeName = atts.getLocalName(i);
|
String attributeName = atts.getLocalName(i);
|
||||||
String attributeValue = atts.getValue(i);
|
String attributeValue = atts.getValue(i);
|
||||||
if (attributeValue==null) {
|
if (attributeValue == null) {
|
||||||
attributeValue = propertyConfig.getPropertyString(OUTPUT_CHAR_NULL);
|
attributeValue = propertyConfig.getPropertyString(OUTPUT_CHAR_NULL);
|
||||||
}
|
}
|
||||||
String attributeValueSafe = SAX3XMLConstants.escapeAttributeValue(attributeValue);
|
String attributeValueSafe = SAX3XMLConstants.escapeAttributeValue(attributeValue);
|
||||||
|
|
||||||
if (propertyConfig.getPropertyBoolean(OUTPUT_LINE_PER_ATTRIBUTE)) {
|
if (propertyConfig.getPropertyBoolean(OUTPUT_LINE_PER_ATTRIBUTE)) {
|
||||||
if (i==0) {
|
if (i == 0) {
|
||||||
printElementAttributeNewLineSpace();
|
printElementAttributeNewLineSpace();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
startElement.append(' ');
|
startElement.append(' ');
|
||||||
}
|
}
|
||||||
|
if (SAX3XMLConstants.NULL_NS_URI.equals(attributeUri) || attributeUri == null) {
|
||||||
if (SAX3XMLConstants.NULL_NS_URI.equals(attributeUri) | attributeUri ==null) {
|
|
||||||
startElement.append(attributeName);
|
startElement.append(attributeName);
|
||||||
} else {
|
} else {
|
||||||
startElement.append(attributeUri);
|
startElement.append(attributeUri);
|
||||||
|
@ -400,12 +397,12 @@ public class AbstractContentWriterHandler implements ContentHandler, Closeable {
|
||||||
}
|
}
|
||||||
|
|
||||||
int breakLines = propertyConfig.getPropertyInteger(OUTPUT_LINE_BREAK_WIDTH);
|
int breakLines = propertyConfig.getPropertyInteger(OUTPUT_LINE_BREAK_WIDTH);
|
||||||
if (breakLines>0) {
|
if (breakLines > 0) {
|
||||||
if (prevChars==0 && startElement.length() > breakLines) {
|
if (prevChars == 0 && startElement.length() > breakLines) {
|
||||||
printElementAttributeNewLineSpace();
|
printElementAttributeNewLineSpace();
|
||||||
prevChars = startElement.length();
|
prevChars = startElement.length();
|
||||||
}
|
}
|
||||||
if (prevChars>0 && (startElement.length()-prevChars) > breakLines) {
|
if (prevChars > 0 && (startElement.length() - prevChars) > breakLines) {
|
||||||
printElementAttributeNewLineSpace();
|
printElementAttributeNewLineSpace();
|
||||||
prevChars = startElement.length();
|
prevChars = startElement.length();
|
||||||
}
|
}
|
||||||
|
@ -420,17 +417,16 @@ public class AbstractContentWriterHandler implements ContentHandler, Closeable {
|
||||||
* @see org.xml.sax.ContentHandler#endElement(java.lang.String, java.lang.String, java.lang.String)
|
* @see org.xml.sax.ContentHandler#endElement(java.lang.String, java.lang.String, java.lang.String)
|
||||||
*/
|
*/
|
||||||
public void endElement(String uri, String localName, String name) throws SAXException {
|
public void endElement(String uri, String localName, String name) throws SAXException {
|
||||||
|
if (elements.size() > 0 && elements.peek().equals((localName)) == false) {
|
||||||
if (elements.size()>0 && elements.peek().equals((localName))==false) {
|
throw new SAXException("Unexpected end tag: " + localName + " should be: " + elements.peek());
|
||||||
throw new SAXException("Unexpected end tag: "+localName+" should be: "+elements.peek());
|
|
||||||
}
|
}
|
||||||
elements.pop();
|
elements.pop();
|
||||||
|
|
||||||
if (startElement!=null) {
|
if (startElement != null) {
|
||||||
String tag = startElement.toString();
|
String tag = startElement.toString();
|
||||||
write(tag.substring(0,tag.length()-1));// rm normal close
|
write(tag.substring(0,tag.length() - 1));// rm normal close
|
||||||
write(SAX3XMLConstants.TAG_CLOSE_EMPTY);
|
write(SAX3XMLConstants.TAG_CLOSE_EMPTY);
|
||||||
startElement=null;
|
startElement = null;
|
||||||
indent--;
|
indent--;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -442,19 +438,19 @@ public class AbstractContentWriterHandler implements ContentHandler, Closeable {
|
||||||
} else {
|
} else {
|
||||||
printReturn = true;
|
printReturn = true;
|
||||||
}
|
}
|
||||||
if (localName==null) {
|
if (localName == null) {
|
||||||
localName = "null";
|
localName = "null";
|
||||||
}
|
}
|
||||||
|
|
||||||
write(SAX3XMLConstants.TAG_OPEN_END);
|
write(SAX3XMLConstants.TAG_OPEN_END);
|
||||||
if (SAX3XMLConstants.NULL_NS_URI.equals(uri) | uri==null) {
|
if (SAX3XMLConstants.NULL_NS_URI.equals(uri) || uri == null) {
|
||||||
write(localName);
|
write(localName);
|
||||||
} else {
|
} else {
|
||||||
String prefix = prefixMapping.get(uri);
|
String prefix = prefixMapping.get(uri);
|
||||||
if (prefix==null) {
|
if (prefix == null) {
|
||||||
throw new SAXException("preFixUri: "+uri+" is not started.");
|
throw new SAXException("preFixUri: " + uri + " is not started.");
|
||||||
}
|
}
|
||||||
if (SAX3XMLConstants.NULL_NS_URI.equals(prefix)==false) {
|
if (SAX3XMLConstants.NULL_NS_URI.equals(prefix) == false) {
|
||||||
write(prefix);
|
write(prefix);
|
||||||
write(SAX3XMLConstants.XMLNS_ASSIGN);
|
write(SAX3XMLConstants.XMLNS_ASSIGN);
|
||||||
}
|
}
|
||||||
|
@ -484,14 +480,14 @@ public class AbstractContentWriterHandler implements ContentHandler, Closeable {
|
||||||
Set<Map.Entry<String,String>> s = prefixMapping.entrySet();
|
Set<Map.Entry<String,String>> s = prefixMapping.entrySet();
|
||||||
String uri = null;
|
String uri = null;
|
||||||
for (Map.Entry<String,String> e:s) {
|
for (Map.Entry<String,String> e:s) {
|
||||||
if (e.getValue()==null) {
|
if (e.getValue() == null) {
|
||||||
continue; // way ?
|
continue; // way ?
|
||||||
}
|
}
|
||||||
if (e.getValue().equals(prefix)) {
|
if (e.getValue().equals(prefix)) {
|
||||||
uri = e.getKey();
|
uri = e.getKey();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (uri!=null) {
|
if (uri != null) {
|
||||||
printedMappings.remove(uri);
|
printedMappings.remove(uri);
|
||||||
prefixMapping.remove(uri);
|
prefixMapping.remove(uri);
|
||||||
}
|
}
|
||||||
|
@ -507,7 +503,7 @@ public class AbstractContentWriterHandler implements ContentHandler, Closeable {
|
||||||
* @see org.xml.sax.ContentHandler#characters(char[], int, int)
|
* @see org.xml.sax.ContentHandler#characters(char[], int, int)
|
||||||
*/
|
*/
|
||||||
public void characters(char[] ch, int start, int length) throws SAXException {
|
public void characters(char[] ch, int start, int length) throws SAXException {
|
||||||
characters(new String(ch,start,length));
|
characters(new String(ch, start, length));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -517,19 +513,19 @@ public class AbstractContentWriterHandler implements ContentHandler, Closeable {
|
||||||
* @see org.x4o.sax3.io.ContentWriter#characters(java.lang.String)
|
* @see org.x4o.sax3.io.ContentWriter#characters(java.lang.String)
|
||||||
*/
|
*/
|
||||||
public void characters(String text) throws SAXException {
|
public void characters(String text) throws SAXException {
|
||||||
if (text==null) {
|
if (text == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
charactersRaw(SAX3XMLConstants.escapeCharacters(text));
|
charactersRaw(SAX3XMLConstants.escapeCharacters(text));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void characters(char c) throws SAXException {
|
public void characters(char c) throws SAXException {
|
||||||
characters(new char[]{c},0,1);
|
characters(new char[]{c}, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// move or remove ?
|
// move or remove ?
|
||||||
protected void charactersRaw(String text) throws SAXException {
|
protected void charactersRaw(String text) throws SAXException {
|
||||||
if (text==null) {
|
if (text == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
autoCloseStartElement();
|
autoCloseStartElement();
|
||||||
|
@ -547,7 +543,7 @@ public class AbstractContentWriterHandler implements ContentHandler, Closeable {
|
||||||
* @see org.xml.sax.ContentHandler#ignorableWhitespace(char[], int, int)
|
* @see org.xml.sax.ContentHandler#ignorableWhitespace(char[], int, int)
|
||||||
*/
|
*/
|
||||||
public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
|
public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
|
||||||
ignorableWhitespace(new String(ch,start,length));
|
ignorableWhitespace(new String(ch, start, length));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -558,7 +554,7 @@ public class AbstractContentWriterHandler implements ContentHandler, Closeable {
|
||||||
* @see org.x4o.sax3.io.ContentWriter#ignorableWhitespace(java.lang.String)
|
* @see org.x4o.sax3.io.ContentWriter#ignorableWhitespace(java.lang.String)
|
||||||
*/
|
*/
|
||||||
public void ignorableWhitespace(String text) throws SAXException {
|
public void ignorableWhitespace(String text) throws SAXException {
|
||||||
if (text==null) {
|
if (text == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
autoCloseStartElement();
|
autoCloseStartElement();
|
||||||
|
@ -572,9 +568,9 @@ public class AbstractContentWriterHandler implements ContentHandler, Closeable {
|
||||||
* @throws SAXException When IOException has happend while printing.
|
* @throws SAXException When IOException has happend while printing.
|
||||||
*/
|
*/
|
||||||
public void ignorableWhitespace(char c) throws SAXException {
|
public void ignorableWhitespace(char c) throws SAXException {
|
||||||
ignorableWhitespace(new char[]{c},0,1);
|
ignorableWhitespace(new char[]{c}, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prints xml instructions.
|
* Prints xml instructions.
|
||||||
*
|
*
|
||||||
|
@ -587,11 +583,11 @@ public class AbstractContentWriterHandler implements ContentHandler, Closeable {
|
||||||
if (targetLow.startsWith(SAX3XMLConstants.XML)) {
|
if (targetLow.startsWith(SAX3XMLConstants.XML)) {
|
||||||
throw new SAXException("Processing instruction may not start with xml.");
|
throw new SAXException("Processing instruction may not start with xml.");
|
||||||
}
|
}
|
||||||
if (SAX3XMLConstants.isNameString(target)==false) {
|
if (SAX3XMLConstants.isNameString(target) == false) {
|
||||||
throw new SAXException("Processing instruction target is invalid name; '"+target+"'");
|
throw new SAXException("Processing instruction target is invalid name; '" + target + "'");
|
||||||
}
|
}
|
||||||
if (SAX3XMLConstants.isCharString(data)==false) {
|
if (SAX3XMLConstants.isCharString(data) == false) {
|
||||||
throw new SAXException("Processing instruction data is invalid char; '"+data+"'");
|
throw new SAXException("Processing instruction data is invalid char; '" + data + "'");
|
||||||
}
|
}
|
||||||
autoCloseStartElement();
|
autoCloseStartElement();
|
||||||
write(getPropertyConfig().getPropertyString(OUTPUT_CHAR_NEWLINE));
|
write(getPropertyConfig().getPropertyString(OUTPUT_CHAR_NEWLINE));
|
||||||
|
@ -604,7 +600,7 @@ public class AbstractContentWriterHandler implements ContentHandler, Closeable {
|
||||||
writeFlush();
|
writeFlush();
|
||||||
printReturn = true;
|
printReturn = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Not implemented.
|
* Not implemented.
|
||||||
*
|
*
|
||||||
|
@ -613,7 +609,7 @@ public class AbstractContentWriterHandler implements ContentHandler, Closeable {
|
||||||
*/
|
*/
|
||||||
public void setDocumentLocator(Locator locator) {
|
public void setDocumentLocator(Locator locator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Not implemented.
|
* Not implemented.
|
||||||
*
|
*
|
||||||
|
@ -623,7 +619,7 @@ public class AbstractContentWriterHandler implements ContentHandler, Closeable {
|
||||||
public void skippedEntity(String name) throws SAXException {
|
public void skippedEntity(String name) throws SAXException {
|
||||||
// is for validating parser support, so not needed in xml writing.
|
// is for validating parser support, so not needed in xml writing.
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prints xml comment.
|
* Prints xml comment.
|
||||||
*
|
*
|
||||||
|
@ -634,7 +630,7 @@ public class AbstractContentWriterHandler implements ContentHandler, Closeable {
|
||||||
* @see org.xml.sax.ext.DefaultHandler2#comment(char[], int, int)
|
* @see org.xml.sax.ext.DefaultHandler2#comment(char[], int, int)
|
||||||
*/
|
*/
|
||||||
public void comment(char[] ch, int start, int length) throws SAXException {
|
public void comment(char[] ch, int start, int length) throws SAXException {
|
||||||
comment(new String(ch,start,length));
|
comment(new String(ch, start, length));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -645,7 +641,7 @@ public class AbstractContentWriterHandler implements ContentHandler, Closeable {
|
||||||
* @see org.x4o.sax3.io.ContentWriter#comment(java.lang.String)
|
* @see org.x4o.sax3.io.ContentWriter#comment(java.lang.String)
|
||||||
*/
|
*/
|
||||||
public void comment(String text) throws SAXException {
|
public void comment(String text) throws SAXException {
|
||||||
if (text==null) {
|
if (text == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!propertyConfig.getPropertyBoolean(OUTPUT_COMMENT_ENABLE)) {
|
if (!propertyConfig.getPropertyBoolean(OUTPUT_COMMENT_ENABLE)) {
|
||||||
|
@ -653,11 +649,11 @@ public class AbstractContentWriterHandler implements ContentHandler, Closeable {
|
||||||
}
|
}
|
||||||
if (propertyConfig.getPropertyBoolean(OUTPUT_COMMENT_AUTO_SPACE)) {
|
if (propertyConfig.getPropertyBoolean(OUTPUT_COMMENT_AUTO_SPACE)) {
|
||||||
char textStart = text.charAt(0);
|
char textStart = text.charAt(0);
|
||||||
char textEnd = text.charAt(text.length()-1);
|
char textEnd = text.charAt(text.length() - 1);
|
||||||
if (textStart!=' ' && textStart!='\t' && textStart!='\n') {
|
if (textStart != ' ' && textStart != '\t' && textStart != '\n') {
|
||||||
text = " "+text;
|
text = " " + text;
|
||||||
}
|
}
|
||||||
if (textEnd!=' ' && textEnd!='\t' && textEnd!='\n') {
|
if (textEnd != ' ' && textEnd != '\t' && textEnd != '\n') {
|
||||||
text = text + " ";
|
text = text + " ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -666,7 +662,7 @@ public class AbstractContentWriterHandler implements ContentHandler, Closeable {
|
||||||
write(getPropertyConfig().getPropertyString(OUTPUT_CHAR_NEWLINE));
|
write(getPropertyConfig().getPropertyString(OUTPUT_CHAR_NEWLINE));
|
||||||
writeIndent();
|
writeIndent();
|
||||||
write(SAX3XMLConstants.COMMENT_START);
|
write(SAX3XMLConstants.COMMENT_START);
|
||||||
write(SAX3XMLConstants.escapeCharactersComment(text,getPropertyConfig().getPropertyString(OUTPUT_CHAR_TAB),indent));
|
write(SAX3XMLConstants.escapeCharactersComment(text,getPropertyConfig().getPropertyString(OUTPUT_CHAR_TAB), indent));
|
||||||
write(SAX3XMLConstants.COMMENT_END);
|
write(SAX3XMLConstants.COMMENT_END);
|
||||||
printReturn = true;
|
printReturn = true;
|
||||||
}
|
}
|
||||||
|
@ -677,7 +673,7 @@ public class AbstractContentWriterHandler implements ContentHandler, Closeable {
|
||||||
* @param value The value to check.
|
* @param value The value to check.
|
||||||
*/
|
*/
|
||||||
private void checkPrintedReturn(String value) {
|
private void checkPrintedReturn(String value) {
|
||||||
if (value.indexOf(SAX3XMLConstants.CHAR_NEWLINE)>0) {
|
if (value.indexOf(SAX3XMLConstants.CHAR_NEWLINE) > 0) {
|
||||||
printReturn = true;
|
printReturn = true;
|
||||||
} else {
|
} else {
|
||||||
printReturn = false;
|
printReturn = false;
|
||||||
|
@ -689,11 +685,11 @@ public class AbstractContentWriterHandler implements ContentHandler, Closeable {
|
||||||
* @throws SAXException When prints gives exception.
|
* @throws SAXException When prints gives exception.
|
||||||
*/
|
*/
|
||||||
protected void autoCloseStartElement() throws SAXException {
|
protected void autoCloseStartElement() throws SAXException {
|
||||||
if (startElement==null) {
|
if (startElement == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
write(startElement.toString());
|
write(startElement.toString());
|
||||||
startElement=null;
|
startElement = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -34,7 +34,7 @@ import org.xml.sax.ext.LexicalHandler;
|
||||||
* @version 1.0 May 3, 2013
|
* @version 1.0 May 3, 2013
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractContentWriterLexical extends AbstractContentWriterHandler implements LexicalHandler {
|
public abstract class AbstractContentWriterLexical extends AbstractContentWriterHandler implements LexicalHandler {
|
||||||
|
|
||||||
protected boolean printCDATA = false;
|
protected boolean printCDATA = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -44,7 +44,7 @@ public abstract class AbstractContentWriterLexical extends AbstractContentWriter
|
||||||
public AbstractContentWriterLexical(Writer out) {
|
public AbstractContentWriterLexical(Writer out) {
|
||||||
super(out);
|
super(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.xml.sax.ext.LexicalHandler#startCDATA()
|
* @see org.xml.sax.ext.LexicalHandler#startCDATA()
|
||||||
*/
|
*/
|
||||||
|
@ -61,7 +61,7 @@ public abstract class AbstractContentWriterLexical extends AbstractContentWriter
|
||||||
charactersRaw(SAX3XMLConstants.CDATA_END);
|
charactersRaw(SAX3XMLConstants.CDATA_END);
|
||||||
printCDATA = false;
|
printCDATA = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.xml.sax.ext.LexicalHandler#startDTD(java.lang.String, java.lang.String, java.lang.String)
|
* @see org.xml.sax.ext.LexicalHandler#startDTD(java.lang.String, java.lang.String, java.lang.String)
|
||||||
*/
|
*/
|
||||||
|
@ -69,11 +69,11 @@ public abstract class AbstractContentWriterLexical extends AbstractContentWriter
|
||||||
charactersRaw(SAX3XMLConstants.XML_DOCTYPE_TAG_OPEN);
|
charactersRaw(SAX3XMLConstants.XML_DOCTYPE_TAG_OPEN);
|
||||||
charactersRaw(" ");
|
charactersRaw(" ");
|
||||||
charactersRaw(name);
|
charactersRaw(name);
|
||||||
if (publicId!=null) {
|
if (publicId != null) {
|
||||||
charactersRaw(" ");
|
charactersRaw(" ");
|
||||||
charactersRaw(publicId);
|
charactersRaw(publicId);
|
||||||
}
|
}
|
||||||
if (systemId!=null) {
|
if (systemId != null) {
|
||||||
charactersRaw(" \"");
|
charactersRaw(" \"");
|
||||||
charactersRaw(systemId);
|
charactersRaw(systemId);
|
||||||
charactersRaw("\"");
|
charactersRaw("\"");
|
||||||
|
@ -87,7 +87,7 @@ public abstract class AbstractContentWriterLexical extends AbstractContentWriter
|
||||||
public void endDTD() throws SAXException {
|
public void endDTD() throws SAXException {
|
||||||
writeFlush();
|
writeFlush();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.xml.sax.ext.LexicalHandler#startEntity(java.lang.String)
|
* @see org.xml.sax.ext.LexicalHandler#startEntity(java.lang.String)
|
||||||
*/
|
*/
|
||||||
|
@ -97,9 +97,9 @@ public abstract class AbstractContentWriterLexical extends AbstractContentWriter
|
||||||
/**
|
/**
|
||||||
* @see org.xml.sax.ext.LexicalHandler#endEntity(java.lang.String)
|
* @see org.xml.sax.ext.LexicalHandler#endEntity(java.lang.String)
|
||||||
*/
|
*/
|
||||||
public void endEntity(String arg0) throws SAXException {
|
public void endEntity(String arg0) throws SAXException {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.sax3.io.AbstractContentWriterHandler#characters(char[], int, int)
|
* @see org.x4o.sax3.io.AbstractContentWriterHandler#characters(char[], int, int)
|
||||||
*/
|
*/
|
||||||
|
@ -107,14 +107,14 @@ public abstract class AbstractContentWriterLexical extends AbstractContentWriter
|
||||||
public void characters(char[] ch, int start, int length) throws SAXException {
|
public void characters(char[] ch, int start, int length) throws SAXException {
|
||||||
characters(new String(ch, start, length));
|
characters(new String(ch, start, length));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.sax3.io.AbstractContentWriterHandler#characters(java.lang.String)
|
* @see org.x4o.sax3.io.AbstractContentWriterHandler#characters(java.lang.String)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void characters(String text) throws SAXException {
|
public void characters(String text) throws SAXException {
|
||||||
if (printCDATA) {
|
if (printCDATA) {
|
||||||
charactersRaw(SAX3XMLConstants.escapeCharactersCdata(text,"",""));
|
charactersRaw(SAX3XMLConstants.escapeCharactersCdata(text, "", ""));
|
||||||
} else {
|
} else {
|
||||||
super.characters(text);
|
super.characters(text);
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class AttributeMap<K,V> implements Map<K,V> {
|
||||||
|
|
||||||
/** stores the namespace uri for this attributes */
|
/** stores the namespace uri for this attributes */
|
||||||
private String uri = null;
|
private String uri = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constuctes an new AttributeMap.
|
* Constuctes an new AttributeMap.
|
||||||
*
|
*
|
||||||
|
@ -53,7 +53,7 @@ public class AttributeMap<K,V> implements Map<K,V> {
|
||||||
public AttributeMap(Attributes attributes) {
|
public AttributeMap(Attributes attributes) {
|
||||||
setAttributes(attributes);
|
setAttributes(attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructes an new AttributesMap.
|
* Constructes an new AttributesMap.
|
||||||
*
|
*
|
||||||
|
@ -64,7 +64,7 @@ public class AttributeMap<K,V> implements Map<K,V> {
|
||||||
setAttributes(attributes);
|
setAttributes(attributes);
|
||||||
setNameSpace(uri);
|
setNameSpace(uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the data backend of this map.
|
* Sets the data backend of this map.
|
||||||
*
|
*
|
||||||
|
@ -73,7 +73,7 @@ public class AttributeMap<K,V> implements Map<K,V> {
|
||||||
public void setAttributes(Attributes attributes) {
|
public void setAttributes(Attributes attributes) {
|
||||||
this.attributes = attributes;
|
this.attributes = attributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the data backend of this map.
|
* Return the data backend of this map.
|
||||||
*
|
*
|
||||||
|
@ -82,7 +82,7 @@ public class AttributeMap<K,V> implements Map<K,V> {
|
||||||
public Attributes getAttributes() {
|
public Attributes getAttributes() {
|
||||||
return attributes;
|
return attributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the namespace uri, when set to null it is disabled(default).
|
* Sets the namespace uri, when set to null it is disabled(default).
|
||||||
*
|
*
|
||||||
|
@ -91,7 +91,7 @@ public class AttributeMap<K,V> implements Map<K,V> {
|
||||||
public void setNameSpace(String uri) {
|
public void setNameSpace(String uri) {
|
||||||
this.uri = uri;
|
this.uri = uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the namespace used for these attributes.
|
* Returns the namespace used for these attributes.
|
||||||
*
|
*
|
||||||
|
@ -100,9 +100,9 @@ public class AttributeMap<K,V> implements Map<K,V> {
|
||||||
public String getNameSpace() {
|
public String getNameSpace() {
|
||||||
return uri;
|
return uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------- inner util functions.
|
// --------------- inner util functions.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the local of full name by index.
|
* Gets the local of full name by index.
|
||||||
*
|
*
|
||||||
|
@ -115,7 +115,7 @@ public class AttributeMap<K,V> implements Map<K,V> {
|
||||||
}
|
}
|
||||||
return attributes.getQName(index);
|
return attributes.getQName(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the value of the attributes. uses the uri if not null.
|
* Gets the value of the attributes. uses the uri if not null.
|
||||||
*
|
*
|
||||||
|
@ -131,7 +131,7 @@ public class AttributeMap<K,V> implements Map<K,V> {
|
||||||
}
|
}
|
||||||
return attributes.getValue(name);
|
return attributes.getValue(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the attribute value.
|
* Gets the attribute value.
|
||||||
* @param key The name of the attribute.
|
* @param key The name of the attribute.
|
||||||
|
@ -143,9 +143,9 @@ public class AttributeMap<K,V> implements Map<K,V> {
|
||||||
}
|
}
|
||||||
return getValue(key.toString());
|
return getValue(key.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------ MAP intreface
|
// ------------------------------ MAP intreface
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the size of the map.
|
* Returns the size of the map.
|
||||||
*
|
*
|
||||||
|
@ -154,7 +154,7 @@ public class AttributeMap<K,V> implements Map<K,V> {
|
||||||
public int size() {
|
public int size() {
|
||||||
return attributes.getLength();
|
return attributes.getLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if there are attributes in this map.
|
* Checks if there are attributes in this map.
|
||||||
*
|
*
|
||||||
|
@ -166,7 +166,7 @@ public class AttributeMap<K,V> implements Map<K,V> {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if there is an attributes with an certain key.
|
* Checks if there is an attributes with an certain key.
|
||||||
*
|
*
|
||||||
|
@ -179,7 +179,7 @@ public class AttributeMap<K,V> implements Map<K,V> {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if there is an attributes with an value.
|
* Checks if there is an attributes with an value.
|
||||||
*
|
*
|
||||||
|
@ -194,7 +194,7 @@ public class AttributeMap<K,V> implements Map<K,V> {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns The value of an attribute.
|
* Returns The value of an attribute.
|
||||||
*
|
*
|
||||||
|
@ -205,7 +205,7 @@ public class AttributeMap<K,V> implements Map<K,V> {
|
||||||
public V get(Object key) {
|
public V get(Object key) {
|
||||||
return (V)getValue(key);
|
return (V)getValue(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function not implements. because we can't add to the attributes.
|
* Function not implements. because we can't add to the attributes.
|
||||||
*
|
*
|
||||||
|
@ -216,7 +216,7 @@ public class AttributeMap<K,V> implements Map<K,V> {
|
||||||
public V put(K key, V value) {
|
public V put(K key, V value) {
|
||||||
return null; // we can't add.
|
return null; // we can't add.
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function not implements. because we can't remove to the attributes.
|
* Function not implements. because we can't remove to the attributes.
|
||||||
*
|
*
|
||||||
|
@ -226,7 +226,7 @@ public class AttributeMap<K,V> implements Map<K,V> {
|
||||||
public V remove(Object key) {
|
public V remove(Object key) {
|
||||||
return null ;// we can't remove
|
return null ;// we can't remove
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function not implements. because we can't add to the attributes.
|
* Function not implements. because we can't add to the attributes.
|
||||||
*
|
*
|
||||||
|
@ -236,14 +236,14 @@ public class AttributeMap<K,V> implements Map<K,V> {
|
||||||
public void putAll(Map t) {
|
public void putAll(Map t) {
|
||||||
// we can't add.
|
// we can't add.
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function not implements. because we can't clear the attributes.
|
* Function not implements. because we can't clear the attributes.
|
||||||
*/
|
*/
|
||||||
public void clear() {
|
public void clear() {
|
||||||
// we can't clear
|
// we can't clear
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a new Set whith the names of the attributes.
|
* Returns a new Set whith the names of the attributes.
|
||||||
*
|
*
|
||||||
|
@ -257,7 +257,7 @@ public class AttributeMap<K,V> implements Map<K,V> {
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an Collection of the values in the attributes list.
|
* Returns an Collection of the values in the attributes list.
|
||||||
*
|
*
|
||||||
|
@ -271,7 +271,7 @@ public class AttributeMap<K,V> implements Map<K,V> {
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an Set made of Map.Entry. note: This Map.Entry is not refenced by
|
* Returns an Set made of Map.Entry. note: This Map.Entry is not refenced by
|
||||||
* the attribute list. so changes to not reflect to this map object.
|
* the attribute list. so changes to not reflect to this map object.
|
||||||
|
@ -289,7 +289,7 @@ public class AttributeMap<K,V> implements Map<K,V> {
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compares the SAX attribute list.
|
* Compares the SAX attribute list.
|
||||||
*
|
*
|
||||||
|
@ -299,7 +299,7 @@ public class AttributeMap<K,V> implements Map<K,V> {
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
return attributes.equals(o); // compare to attributes
|
return attributes.equals(o); // compare to attributes
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns the hashCode of the attribute list.
|
* returns the hashCode of the attribute list.
|
||||||
*
|
*
|
||||||
|
@ -308,7 +308,7 @@ public class AttributeMap<K,V> implements Map<K,V> {
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return attributes.hashCode();
|
return attributes.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An innerclass used by entrySet().
|
* An innerclass used by entrySet().
|
||||||
*/
|
*/
|
||||||
|
@ -358,7 +358,7 @@ public class AttributeMap<K,V> implements Map<K,V> {
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (o instanceof Map.Entry) {
|
if (o instanceof Map.Entry) {
|
||||||
Map.Entry mapEntry = (Map.Entry) o;
|
Map.Entry mapEntry = (Map.Entry) o;
|
||||||
if (mapEntry.getKey().equals(key) & mapEntry.getValue().equals(value)) {
|
if (mapEntry.getKey().equals(key) && mapEntry.getValue().equals(value)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,80 +34,80 @@ import org.xml.sax.SAXException;
|
||||||
* @version 1.0 Dec 27, 2024
|
* @version 1.0 Dec 27, 2024
|
||||||
*/
|
*/
|
||||||
abstract public class ContentWriterAdapter implements ContentWriter {
|
abstract public class ContentWriterAdapter implements ContentWriter {
|
||||||
|
|
||||||
public void comment(char[] ch, int start, int length) throws SAXException {
|
public void comment(char[] ch, int start, int length) throws SAXException {
|
||||||
comment(new String(ch,start,length));
|
comment(new String(ch, start, length));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
|
public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
|
||||||
ignorableWhitespace(new String(ch,start,length));
|
ignorableWhitespace(new String(ch, start, length));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ignorableWhitespace(char c) throws SAXException {
|
public void ignorableWhitespace(char c) throws SAXException {
|
||||||
ignorableWhitespace(new char[]{c},0,1);
|
ignorableWhitespace(new char[]{c}, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startElementEnd(String uri, String localName, String name, Attributes atts) throws SAXException {
|
public void startElementEnd(String uri, String localName, String name, Attributes atts) throws SAXException {
|
||||||
startElement(uri,localName,name, atts);
|
startElement(uri, localName, name, atts);
|
||||||
endElement(uri, localName, name);
|
endElement(uri, localName, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void characters(char c) throws SAXException {
|
public void characters(char c) throws SAXException {
|
||||||
characters(new char[]{c},0,1);
|
characters(new char[]{c}, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void characters(char[] ch, int start, int length) throws SAXException {
|
public void characters(char[] ch, int start, int length) throws SAXException {
|
||||||
characters(new String(ch,start,length));
|
characters(new String(ch, start, length));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void endCDATA() throws SAXException {
|
public void endCDATA() throws SAXException {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void endDTD() throws SAXException {
|
public void endDTD() throws SAXException {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void endEntity(String arg0) throws SAXException {
|
public void endEntity(String arg0) throws SAXException {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startCDATA() throws SAXException {
|
public void startCDATA() throws SAXException {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startDTD(String arg0, String arg1, String arg2) throws SAXException {
|
public void startDTD(String arg0, String arg1, String arg2) throws SAXException {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startEntity(String arg0) throws SAXException {
|
public void startEntity(String arg0) throws SAXException {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void endPrefixMapping(String arg0) throws SAXException {
|
public void endPrefixMapping(String arg0) throws SAXException {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void processingInstruction(String arg0, String arg1) throws SAXException {
|
public void processingInstruction(String arg0, String arg1) throws SAXException {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setDocumentLocator(Locator arg0) {
|
public void setDocumentLocator(Locator arg0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void skippedEntity(String arg0) throws SAXException {
|
public void skippedEntity(String arg0) throws SAXException {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startPrefixMapping(String arg0, String arg1) throws SAXException {
|
public void startPrefixMapping(String arg0, String arg1) throws SAXException {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void comment(String text) throws SAXException {
|
public void comment(String text) throws SAXException {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ignorableWhitespace(String text) throws SAXException {
|
public void ignorableWhitespace(String text) throws SAXException {
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,54 +43,54 @@ public final class SAX3PropertyConfig implements Cloneable {
|
||||||
private final boolean readOnly;
|
private final boolean readOnly;
|
||||||
private final String keyPrefix;
|
private final String keyPrefix;
|
||||||
|
|
||||||
public SAX3PropertyConfig(String keyPrefix,PropertyConfigItem...items) {
|
public SAX3PropertyConfig(String keyPrefix, PropertyConfigItem... items) {
|
||||||
this(false,null,keyPrefix,items);
|
this(false, null, keyPrefix, items);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SAX3PropertyConfig(SAX3PropertyConfig parentPropertyConfig,String keyPrefix,PropertyConfigItem...items) {
|
public SAX3PropertyConfig(SAX3PropertyConfig parentPropertyConfig, String keyPrefix, PropertyConfigItem... items) {
|
||||||
this(false,parentPropertyConfig,keyPrefix,items);
|
this(false, parentPropertyConfig, keyPrefix, items);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SAX3PropertyConfig(boolean readOnly,SAX3PropertyConfig parentPropertyConfig,String keyPrefix,PropertyConfigItem...itemConfig) {
|
public SAX3PropertyConfig(boolean readOnly, SAX3PropertyConfig parentPropertyConfig, String keyPrefix, PropertyConfigItem... itemConfig) {
|
||||||
if (keyPrefix==null) {
|
if (keyPrefix == null) {
|
||||||
throw new NullPointerException("Can't create PropertyConfig with null keyPrefix.");
|
throw new NullPointerException("Can't create PropertyConfig with null keyPrefix.");
|
||||||
}
|
}
|
||||||
this.readOnly=readOnly;
|
this.readOnly = readOnly;
|
||||||
this.keyPrefix=appendSlashIfMissing(keyPrefix);
|
this.keyPrefix = appendSlashIfMissing(keyPrefix);
|
||||||
Map<String,PropertyConfigItem> fillItems = new HashMap<String,PropertyConfigItem>(itemConfig.length);
|
Map<String,PropertyConfigItem> fillItems = new HashMap<String,PropertyConfigItem>(itemConfig.length);
|
||||||
fillPropertyConfigItems(fillItems,itemConfig);
|
fillPropertyConfigItems(fillItems, itemConfig);
|
||||||
copyParentPropertyConfig(fillItems,parentPropertyConfig);
|
copyParentPropertyConfig(fillItems, parentPropertyConfig);
|
||||||
if (fillItems.isEmpty()) {
|
if (fillItems.isEmpty()) {
|
||||||
throw new IllegalArgumentException("Can't create PropertyConfig with zero PropertyConfigItems.");
|
throw new IllegalArgumentException("Can't create PropertyConfig with zero PropertyConfigItems.");
|
||||||
}
|
}
|
||||||
for (String key:fillItems.keySet()) {
|
for (String key : fillItems.keySet()) {
|
||||||
if (!key.startsWith(X4O_PROPERTIES_PREFIX)) {
|
if (!key.startsWith(X4O_PROPERTIES_PREFIX)) {
|
||||||
throw new IllegalArgumentException("Illegal key missing prefix; "+key);
|
throw new IllegalArgumentException("Illegal key missing prefix; " + key);
|
||||||
}
|
}
|
||||||
fillItems.put(key,fillItems.get(key).clone());
|
fillItems.put(key, fillItems.get(key).clone());
|
||||||
}
|
}
|
||||||
items = Collections.unmodifiableMap(fillItems);
|
items = Collections.unmodifiableMap(fillItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final String appendSlashIfMissing(String keyPrefix) {
|
private final String appendSlashIfMissing(String keyPrefix) {
|
||||||
if (keyPrefix.endsWith("/")==false) {
|
if (keyPrefix.endsWith("/") == false) {
|
||||||
keyPrefix += "/";
|
keyPrefix += "/";
|
||||||
}
|
}
|
||||||
return keyPrefix;
|
return keyPrefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final void fillPropertyConfigItems(Map<String,PropertyConfigItem> fillItems,PropertyConfigItem...itemConfig) {
|
private final void fillPropertyConfigItems(Map<String,PropertyConfigItem> fillItems, PropertyConfigItem... itemConfig) {
|
||||||
for (int i=0;i<itemConfig.length;i++) {
|
for (int i = 0; i < itemConfig.length; i++) {
|
||||||
PropertyConfigItem item = itemConfig[i];
|
PropertyConfigItem item = itemConfig[i];
|
||||||
fillItems.put(item.getValueKey(),item);
|
fillItems.put(item.getValueKey(),item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final void copyParentPropertyConfig(Map<String,PropertyConfigItem> fillItems,SAX3PropertyConfig parentPropertyConfig) {
|
private final void copyParentPropertyConfig(Map<String,PropertyConfigItem> fillItems, SAX3PropertyConfig parentPropertyConfig) {
|
||||||
if (parentPropertyConfig==null) {
|
if (parentPropertyConfig == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (String key:parentPropertyConfig.getPropertyKeys()) {
|
for (String key : parentPropertyConfig.getPropertyKeys()) {
|
||||||
fillItems.put(key, parentPropertyConfig.getPropertyConfigItem(key));
|
fillItems.put(key, parentPropertyConfig.getPropertyConfigItem(key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,29 +102,29 @@ public final class SAX3PropertyConfig implements Cloneable {
|
||||||
private final Object valueDefault;
|
private final Object valueDefault;
|
||||||
private Object value = null;
|
private Object value = null;
|
||||||
|
|
||||||
public PropertyConfigItem(boolean valueRequired,String valueKey,Class<?> valueType) {
|
public PropertyConfigItem(boolean valueRequired, String valueKey, Class<?> valueType) {
|
||||||
this(valueRequired,valueKey,valueType,null);
|
this(valueRequired, valueKey, valueType, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PropertyConfigItem(String valueKey,Class<?> valueType) {
|
public PropertyConfigItem(String valueKey, Class<?> valueType) {
|
||||||
this(false,valueKey,valueType,null);
|
this(false, valueKey, valueType, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PropertyConfigItem(String valueKey,Class<?> valueType,Object valueDefault) {
|
public PropertyConfigItem(String valueKey, Class<?> valueType, Object valueDefault) {
|
||||||
this(false,valueKey,valueType,valueDefault); // with default then value can not be required.
|
this(false, valueKey, valueType, valueDefault); // with default then value can not be required.
|
||||||
}
|
}
|
||||||
|
|
||||||
private PropertyConfigItem(boolean valueRequired,String valueKey,Class<?> valueType,Object valueDefault) {
|
private PropertyConfigItem(boolean valueRequired, String valueKey, Class<?> valueType, Object valueDefault) {
|
||||||
if (valueKey==null) {
|
if (valueKey == null) {
|
||||||
throw new NullPointerException("Can't create PropertyConfigItem with null valueKey.");
|
throw new NullPointerException("Can't create PropertyConfigItem with null valueKey.");
|
||||||
}
|
}
|
||||||
if (valueType==null) {
|
if (valueType == null) {
|
||||||
throw new NullPointerException("Can't create PropertyConfigItem with null valueType.");
|
throw new NullPointerException("Can't create PropertyConfigItem with null valueType.");
|
||||||
}
|
}
|
||||||
this.valueRequired=valueRequired;
|
this.valueRequired = valueRequired;
|
||||||
this.valueKey=valueKey;
|
this.valueKey = valueKey;
|
||||||
this.valueType=valueType;
|
this.valueType = valueType;
|
||||||
this.valueDefault=valueDefault;
|
this.valueDefault = valueDefault;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -175,19 +175,19 @@ public final class SAX3PropertyConfig implements Cloneable {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected PropertyConfigItem clone() {
|
protected PropertyConfigItem clone() {
|
||||||
PropertyConfigItem clone = new PropertyConfigItem(valueRequired,valueKey,valueType,valueDefault);
|
PropertyConfigItem clone = new PropertyConfigItem(valueRequired, valueKey, valueType, valueDefault);
|
||||||
clone.setValue(getValue());
|
clone.setValue(getValue());
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final PropertyConfigItem getPropertyConfigItem(String key) {
|
private final PropertyConfigItem getPropertyConfigItem(String key) {
|
||||||
if (key==null) {
|
if (key == null) {
|
||||||
throw new NullPointerException("Can't search with null key.");
|
throw new NullPointerException("Can't search with null key.");
|
||||||
}
|
}
|
||||||
PropertyConfigItem item = items.get(key);
|
PropertyConfigItem item = items.get(key);
|
||||||
if (item==null) {
|
if (item == null) {
|
||||||
throw new IllegalArgumentException("No config item found for key: "+key);
|
throw new IllegalArgumentException("No config item found for key: " + key);
|
||||||
}
|
}
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
@ -210,14 +210,14 @@ public final class SAX3PropertyConfig implements Cloneable {
|
||||||
|
|
||||||
private final List<String> findPropertyKeysRequired(boolean checkValue) {
|
private final List<String> findPropertyKeysRequired(boolean checkValue) {
|
||||||
List<String> result = new ArrayList<String>(10);
|
List<String> result = new ArrayList<String>(10);
|
||||||
for (String key:getPropertyKeys()) {
|
for (String key : getPropertyKeys()) {
|
||||||
PropertyConfigItem item = getPropertyConfigItem(key);
|
PropertyConfigItem item = getPropertyConfigItem(key);
|
||||||
if (!item.isValueRequired()) {
|
if (!item.isValueRequired()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!checkValue) {
|
if (!checkValue) {
|
||||||
result.add(item.getValueKey());
|
result.add(item.getValueKey());
|
||||||
} else if (item.getValue()==null && item.getValueDefault()==null) {
|
} else if (item.getValue() == null && item.getValueDefault() == null) {
|
||||||
result.add(item.getValueKey());
|
result.add(item.getValueKey());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -232,7 +232,7 @@ public final class SAX3PropertyConfig implements Cloneable {
|
||||||
|
|
||||||
public final void setProperty(String key,Object value) {
|
public final void setProperty(String key,Object value) {
|
||||||
if (readOnly) {
|
if (readOnly) {
|
||||||
throw new IllegalStateException("This property is readonly for key:"+key);
|
throw new IllegalStateException("This property is readonly for key:" + key);
|
||||||
}
|
}
|
||||||
PropertyConfigItem item = getPropertyConfigItem(key);
|
PropertyConfigItem item = getPropertyConfigItem(key);
|
||||||
item.setValue(value);
|
item.setValue(value);
|
||||||
|
@ -246,7 +246,7 @@ public final class SAX3PropertyConfig implements Cloneable {
|
||||||
public final Object getProperty(String key) {
|
public final Object getProperty(String key) {
|
||||||
PropertyConfigItem item = getPropertyConfigItem(key);
|
PropertyConfigItem item = getPropertyConfigItem(key);
|
||||||
Object value = item.getValue();
|
Object value = item.getValue();
|
||||||
if (value==null) {
|
if (value == null) {
|
||||||
value = item.getValueDefault();
|
value = item.getValueDefault();
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
|
@ -257,7 +257,7 @@ public final class SAX3PropertyConfig implements Cloneable {
|
||||||
return item.getValueType();
|
return item.getValueType();
|
||||||
}
|
}
|
||||||
|
|
||||||
public final Class<?> getPropertyType(String key,Supplier<Class<?>> defaultValue) {
|
public final Class<?> getPropertyType(String key, Supplier<Class<?>> defaultValue) {
|
||||||
Class<?> result = getPropertyType(key);
|
Class<?> result = getPropertyType(key);
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
return result;
|
return result;
|
||||||
|
@ -270,13 +270,13 @@ public final class SAX3PropertyConfig implements Cloneable {
|
||||||
if (value instanceof File) {
|
if (value instanceof File) {
|
||||||
return (File)value;
|
return (File)value;
|
||||||
}
|
}
|
||||||
if (value==null) {
|
if (value == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
throw new IllegalStateException("Wrong value type: "+value.getClass()+" for key: "+key);
|
throw new IllegalStateException("Wrong value type: " + value.getClass() + " for key: " + key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final File getPropertyFile(String key,Supplier<File> defaultValue) {
|
public final File getPropertyFile(String key, Supplier<File> defaultValue) {
|
||||||
File result = getPropertyFile(key);
|
File result = getPropertyFile(key);
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
return result;
|
return result;
|
||||||
|
@ -289,13 +289,13 @@ public final class SAX3PropertyConfig implements Cloneable {
|
||||||
if (value instanceof Boolean) {
|
if (value instanceof Boolean) {
|
||||||
return (Boolean)value;
|
return (Boolean)value;
|
||||||
}
|
}
|
||||||
if (value==null) {
|
if (value == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
throw new IllegalStateException("Wrong value type: "+value.getClass()+" for key: "+key);
|
throw new IllegalStateException("Wrong value type: " + value.getClass() + " for key: " + key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final Boolean getPropertyBoolean(String key,Supplier<Boolean> defaultValue) {
|
public final Boolean getPropertyBoolean(String key, Supplier<Boolean> defaultValue) {
|
||||||
Boolean result = getPropertyBoolean(key);
|
Boolean result = getPropertyBoolean(key);
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
return result;
|
return result;
|
||||||
|
@ -308,13 +308,13 @@ public final class SAX3PropertyConfig implements Cloneable {
|
||||||
if (value instanceof Integer) {
|
if (value instanceof Integer) {
|
||||||
return (Integer)value;
|
return (Integer)value;
|
||||||
}
|
}
|
||||||
if (value==null) {
|
if (value == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
throw new IllegalStateException("Wrong value type: "+value.getClass()+" for key: "+key);
|
throw new IllegalStateException("Wrong value type: " + value.getClass() + " for key: " + key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final Integer getPropertyInteger(String key,Supplier<Integer> defaultValue) {
|
public final Integer getPropertyInteger(String key, Supplier<Integer> defaultValue) {
|
||||||
Integer result = getPropertyInteger(key);
|
Integer result = getPropertyInteger(key);
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
return result;
|
return result;
|
||||||
|
@ -328,10 +328,10 @@ public final class SAX3PropertyConfig implements Cloneable {
|
||||||
if (value instanceof List) {
|
if (value instanceof List) {
|
||||||
return (List<String>)value;
|
return (List<String>)value;
|
||||||
}
|
}
|
||||||
if (value==null) {
|
if (value == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
throw new IllegalStateException("Wrong value type: "+value.getClass()+" for key: "+key);
|
throw new IllegalStateException("Wrong value type: " + value.getClass() + " for key: " + key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final List<String> getPropertyList(String key, Supplier<List<String>> defaultValue) {
|
public final List<String> getPropertyList(String key, Supplier<List<String>> defaultValue) {
|
||||||
|
@ -348,10 +348,10 @@ public final class SAX3PropertyConfig implements Cloneable {
|
||||||
if (value instanceof Map) {
|
if (value instanceof Map) {
|
||||||
return (Map<String,String>)value;
|
return (Map<String,String>)value;
|
||||||
}
|
}
|
||||||
if (value==null) {
|
if (value == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
throw new IllegalStateException("Wrong value type: "+value.getClass()+" for key: "+key);
|
throw new IllegalStateException("Wrong value type: " + value.getClass() + " for key: " + key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final Map<String,String> getPropertyMap(String key, Supplier<Map<String,String>> defaultValue) {
|
public final Map<String,String> getPropertyMap(String key, Supplier<Map<String,String>> defaultValue) {
|
||||||
|
@ -367,15 +367,15 @@ public final class SAX3PropertyConfig implements Cloneable {
|
||||||
if (value instanceof String) {
|
if (value instanceof String) {
|
||||||
return (String)value;
|
return (String)value;
|
||||||
}
|
}
|
||||||
if (value==null) {
|
if (value == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
throw new IllegalStateException("Wrong value type: "+value.getClass()+" for key: "+key);
|
throw new IllegalStateException("Wrong value type: " + value.getClass() + " for key: " + key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final String getPropertyString(String key,String defaultValue) {
|
public final String getPropertyString(String key,String defaultValue) {
|
||||||
String propertyValue = getPropertyString(key);
|
String propertyValue = getPropertyString(key);
|
||||||
if (propertyValue==null) {
|
if (propertyValue == null) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
} else {
|
} else {
|
||||||
return propertyValue;
|
return propertyValue;
|
||||||
|
@ -391,9 +391,9 @@ public final class SAX3PropertyConfig implements Cloneable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void copyParentProperties(SAX3PropertyConfig config) {
|
public final void copyParentProperties(SAX3PropertyConfig config) {
|
||||||
for (String key:getPropertyKeys()) {
|
for (String key : getPropertyKeys()) {
|
||||||
Object value = config.getProperty(key);
|
Object value = config.getProperty(key);
|
||||||
if (value==null) {
|
if (value == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
setProperty(key, value);
|
setProperty(key, value);
|
||||||
|
@ -403,7 +403,6 @@ public final class SAX3PropertyConfig implements Cloneable {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public final void setPropertyParsedValue(String key,String value) {
|
public final void setPropertyParsedValue(String key,String value) {
|
||||||
Class<?> valueType = getPropertyType(key);
|
Class<?> valueType = getPropertyType(key);
|
||||||
//System.out.println("key: "+key+" value: "+value+" type: "+valueType);
|
|
||||||
if (String.class.equals(valueType)) {
|
if (String.class.equals(valueType)) {
|
||||||
setProperty(key, value);
|
setProperty(key, value);
|
||||||
return;
|
return;
|
||||||
|
@ -431,11 +430,11 @@ public final class SAX3PropertyConfig implements Cloneable {
|
||||||
if (List.class.equals(valueType)) {
|
if (List.class.equals(valueType)) {
|
||||||
String[] listValues = value.split(",");
|
String[] listValues = value.split(",");
|
||||||
List<String> result = (List<String>)getProperty(key);
|
List<String> result = (List<String>)getProperty(key);
|
||||||
if (result==null) {
|
if (result == null) {
|
||||||
result = new ArrayList<String>(10);
|
result = new ArrayList<String>(10);
|
||||||
setProperty(key, result);
|
setProperty(key, result);
|
||||||
}
|
}
|
||||||
for (String listValue:listValues) {
|
for (String listValue : listValues) {
|
||||||
result.add(listValue);
|
result.add(listValue);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -443,12 +442,12 @@ public final class SAX3PropertyConfig implements Cloneable {
|
||||||
if (Map.class.equals(valueType)) {
|
if (Map.class.equals(valueType)) {
|
||||||
String[] listValues = value.split(",");
|
String[] listValues = value.split(",");
|
||||||
Map<String,String> result = (Map<String,String>)getProperty(key);
|
Map<String,String> result = (Map<String,String>)getProperty(key);
|
||||||
if (result==null) {
|
if (result == null) {
|
||||||
result = new HashMap<String,String>(10);
|
result = new HashMap<String,String>(10);
|
||||||
setProperty(key, result);
|
setProperty(key, result);
|
||||||
}
|
}
|
||||||
if (listValues.length!=2) {
|
if (listValues.length != 2) {
|
||||||
throw new IllegalArgumentException("Coult not parse map value: '"+value+"' parsed length: "+listValues.length+" needs to be 2.");
|
throw new IllegalArgumentException("Coult not parse map value: '" + value + "' parsed length: " + listValues.length + " needs to be 2.");
|
||||||
}
|
}
|
||||||
String mKey = listValues[0];
|
String mKey = listValues[0];
|
||||||
String mValue = listValues[1];
|
String mValue = listValues[1];
|
||||||
|
@ -463,7 +462,7 @@ public final class SAX3PropertyConfig implements Cloneable {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public SAX3PropertyConfig clone() {
|
public SAX3PropertyConfig clone() {
|
||||||
SAX3PropertyConfig clone = new SAX3PropertyConfig(this,this.keyPrefix);
|
SAX3PropertyConfig clone = new SAX3PropertyConfig(this, this.keyPrefix);
|
||||||
clone.copyParentProperties(this);
|
clone.copyParentProperties(this);
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ public final class SAX3XMLConstants {
|
||||||
* XML Namespace prefix attribute.
|
* XML Namespace prefix attribute.
|
||||||
*/
|
*/
|
||||||
public static final String XMLNS_ATTRIBUTE = javax.xml.XMLConstants.XMLNS_ATTRIBUTE; // "xmlns"
|
public static final String XMLNS_ATTRIBUTE = javax.xml.XMLConstants.XMLNS_ATTRIBUTE; // "xmlns"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* XML Namespace prefix seperator
|
* XML Namespace prefix seperator
|
||||||
*/
|
*/
|
||||||
|
@ -61,7 +61,7 @@ public final class SAX3XMLConstants {
|
||||||
* XML Schema namespace URI.
|
* XML Schema namespace URI.
|
||||||
*/
|
*/
|
||||||
public static final String XML_SCHEMA_NS_URI = javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI; // "http://www.w3.org/2001/XMLSchema"
|
public static final String XML_SCHEMA_NS_URI = javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI; // "http://www.w3.org/2001/XMLSchema"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* XML Schema instance namespace URI.
|
* XML Schema instance namespace URI.
|
||||||
*/
|
*/
|
||||||
|
@ -164,14 +164,14 @@ public final class SAX3XMLConstants {
|
||||||
return getDocumentDeclaration(encoding,null);
|
return getDocumentDeclaration(encoding,null);
|
||||||
}
|
}
|
||||||
|
|
||||||
static public String getDocumentDeclaration(String encoding,String version) {
|
static public String getDocumentDeclaration(String encoding, String version) {
|
||||||
if (encoding==null) {
|
if (encoding == null) {
|
||||||
encoding=XML_DEFAULT_ENCODING;
|
encoding = XML_DEFAULT_ENCODING;
|
||||||
}
|
}
|
||||||
if (version==null) {
|
if (version == null) {
|
||||||
version=XML_DEFAULT_VERSION;
|
version = XML_DEFAULT_VERSION;
|
||||||
}
|
}
|
||||||
return String.format("<?xml version=\"%s\" encoding=\"%s\"?>", version,encoding);
|
return String.format("<?xml version=\"%s\" encoding=\"%s\"?>", version, encoding);
|
||||||
}
|
}
|
||||||
|
|
||||||
static public boolean isChar(int c) {
|
static public boolean isChar(int c) {
|
||||||
|
@ -236,7 +236,7 @@ public final class SAX3XMLConstants {
|
||||||
PrimitiveIterator.OfInt iterator = value.codePoints().iterator();
|
PrimitiveIterator.OfInt iterator = value.codePoints().iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
int c = iterator.nextInt();
|
int c = iterator.nextInt();
|
||||||
if (isNameChar(c)==false) {
|
if (isNameChar(c) == false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -250,11 +250,11 @@ public final class SAX3XMLConstants {
|
||||||
int c = iterator.nextInt();
|
int c = iterator.nextInt();
|
||||||
if (first) {
|
if (first) {
|
||||||
first = false;
|
first = false;
|
||||||
if (isNameStartChar(c)==false) {
|
if (isNameStartChar(c) == false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isNameChar(c)==false) {
|
if (isNameChar(c) == false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -348,7 +348,7 @@ public final class SAX3XMLConstants {
|
||||||
|
|
||||||
// Hex code points
|
// Hex code points
|
||||||
if (entity.startsWith("&#")) {
|
if (entity.startsWith("&#")) {
|
||||||
String hex = entity.substring(2,entity.length()-1);
|
String hex = entity.substring(2,entity.length() - 1);
|
||||||
if (hex.startsWith("x")) {
|
if (hex.startsWith("x")) {
|
||||||
hex = hex.substring(1);
|
hex = hex.substring(1);
|
||||||
}
|
}
|
||||||
|
@ -362,7 +362,7 @@ public final class SAX3XMLConstants {
|
||||||
if ("&".equals(entity)) { return true; }
|
if ("&".equals(entity)) { return true; }
|
||||||
if (""".equals(entity)) { return true; }
|
if (""".equals(entity)) { return true; }
|
||||||
if ("'".equals(entity)) { return true; }
|
if ("'".equals(entity)) { return true; }
|
||||||
|
|
||||||
// HTML
|
// HTML
|
||||||
if ("´".equals(entity)) { return true; }
|
if ("´".equals(entity)) { return true; }
|
||||||
if ("ℵ".equals(entity)) { return true; }
|
if ("ℵ".equals(entity)) { return true; }
|
||||||
|
@ -397,7 +397,7 @@ public final class SAX3XMLConstants {
|
||||||
|
|
||||||
static public String escapeCharactersComment(String value,String charTab,int indent) {
|
static public String escapeCharactersComment(String value,String charTab,int indent) {
|
||||||
value = value.replaceAll(COMMENT_START, "");
|
value = value.replaceAll(COMMENT_START, "");
|
||||||
value = value.replaceAll(COMMENT_END, "");
|
value = value.replaceAll(COMMENT_END, "");
|
||||||
StringBuilder result = new StringBuilder(value.length());
|
StringBuilder result = new StringBuilder(value.length());
|
||||||
PrimitiveIterator.OfInt iterator = value.codePoints().iterator();
|
PrimitiveIterator.OfInt iterator = value.codePoints().iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
|
@ -407,7 +407,6 @@ public final class SAX3XMLConstants {
|
||||||
for (int ii = 0; ii < indent; ii++) {
|
for (int ii = 0; ii < indent; ii++) {
|
||||||
result.append(charTab);
|
result.append(charTab);
|
||||||
}
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
result.appendCodePoint(c);
|
result.appendCodePoint(c);
|
||||||
|
|
|
@ -104,7 +104,7 @@ public class AbstractXDBXWriterHandler implements ContentHandler, Closeable {
|
||||||
this.prefixMapping = new HashMap<String,String>(15);
|
this.prefixMapping = new HashMap<String,String>(15);
|
||||||
this.printedMappings = new ArrayList<String>(15);
|
this.printedMappings = new ArrayList<String>(15);
|
||||||
this.elements = new Stack<String>();
|
this.elements = new Stack<String>();
|
||||||
this.propertyConfig = new SAX3PropertyConfig(DEFAULT_PROPERTY_CONFIG,PROPERTY_CONTEXT_PREFIX);
|
this.propertyConfig = new SAX3PropertyConfig(DEFAULT_PROPERTY_CONFIG, PROPERTY_CONTEXT_PREFIX);
|
||||||
this.stringIdx = new HashMap<>();
|
this.stringIdx = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,19 +161,19 @@ public class AbstractXDBXWriterHandler implements ContentHandler, Closeable {
|
||||||
InputStream licenceInput = null;
|
InputStream licenceInput = null;
|
||||||
String licenceEncoding = propertyConfig.getPropertyString(PROLOG_LICENCE_ENCODING);
|
String licenceEncoding = propertyConfig.getPropertyString(PROLOG_LICENCE_ENCODING);
|
||||||
String licenceResource = propertyConfig.getPropertyString(PROLOG_LICENCE_RESOURCE);
|
String licenceResource = propertyConfig.getPropertyString(PROLOG_LICENCE_RESOURCE);
|
||||||
if (licenceResource!=null) {
|
if (licenceResource != null) {
|
||||||
ClassLoader cl = Thread.currentThread().getContextClassLoader();
|
ClassLoader cl = Thread.currentThread().getContextClassLoader();
|
||||||
if (cl == null) {
|
if (cl == null) {
|
||||||
cl = this.getClass().getClassLoader();
|
cl = this.getClass().getClassLoader();
|
||||||
}
|
}
|
||||||
licenceInput = cl.getResourceAsStream(licenceResource);
|
licenceInput = cl.getResourceAsStream(licenceResource);
|
||||||
if (licenceInput==null) {
|
if (licenceInput == null) {
|
||||||
throw new NullPointerException("Could not load licence resource from: "+licenceResource);
|
throw new NullPointerException("Could not load licence resource from: "+licenceResource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (licenceInput==null) {
|
if (licenceInput == null) {
|
||||||
File licenceFile = propertyConfig.getPropertyFile(PROLOG_LICENCE_FILE);
|
File licenceFile = propertyConfig.getPropertyFile(PROLOG_LICENCE_FILE);
|
||||||
if (licenceFile==null) {
|
if (licenceFile == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
@ -184,32 +184,32 @@ public class AbstractXDBXWriterHandler implements ContentHandler, Closeable {
|
||||||
}
|
}
|
||||||
String licenceText;
|
String licenceText;
|
||||||
try {
|
try {
|
||||||
licenceText = readLicenceStream(licenceInput,licenceEncoding);
|
licenceText = readLicenceStream(licenceInput, licenceEncoding);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new SAXException(e);
|
throw new SAXException(e);
|
||||||
}
|
}
|
||||||
comment(licenceText);
|
comment(licenceText);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String readLicenceStream(InputStream inputStream,String encoding) throws IOException {
|
private String readLicenceStream(InputStream inputStream, String encoding) throws IOException {
|
||||||
if (encoding==null) {
|
if (encoding == null) {
|
||||||
encoding = SAX3XMLConstants.XML_DEFAULT_ENCODING;
|
encoding = SAX3XMLConstants.XML_DEFAULT_ENCODING;
|
||||||
}
|
}
|
||||||
BufferedReader br = new BufferedReader(new InputStreamReader(inputStream,Charset.forName(encoding)));
|
BufferedReader br = new BufferedReader(new InputStreamReader(inputStream, Charset.forName(encoding)));
|
||||||
try {
|
try {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append('\n'); // like plugin
|
sb.append('\n');
|
||||||
sb.append('\n'); // like plugin
|
sb.append('\n');
|
||||||
String line = br.readLine();
|
String line = br.readLine();
|
||||||
while (line != null) {
|
while (line != null) {
|
||||||
if (line.length()>0) {
|
if (line.length()>0) {
|
||||||
sb.append(" "); // like plugin
|
sb.append(" ");
|
||||||
}
|
}
|
||||||
sb.append(line);
|
sb.append(line);
|
||||||
sb.append('\n');
|
sb.append('\n');
|
||||||
line = br.readLine();
|
line = br.readLine();
|
||||||
}
|
}
|
||||||
sb.append('\n'); // like plugin
|
sb.append('\n');
|
||||||
String out = sb.toString();
|
String out = sb.toString();
|
||||||
return out;
|
return out;
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -240,8 +240,8 @@ public class AbstractXDBXWriterHandler implements ContentHandler, Closeable {
|
||||||
public void endDocument() throws SAXException {
|
public void endDocument() throws SAXException {
|
||||||
writeTag(XDBXContentTag.DOCUMENT_END);
|
writeTag(XDBXContentTag.DOCUMENT_END);
|
||||||
writeFlush();
|
writeFlush();
|
||||||
if (elements.size()>0) {
|
if (elements.size() > 0) {
|
||||||
throw new SAXException("Invalid xml still have "+elements.size()+" elements open.");
|
throw new SAXException("Invalid xml still have " + elements.size() + " elements open.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,13 +253,13 @@ public class AbstractXDBXWriterHandler implements ContentHandler, Closeable {
|
||||||
* @see org.xml.sax.ContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
|
* @see org.xml.sax.ContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
|
||||||
*/
|
*/
|
||||||
public void startElement(String uri, String localName, String name, Attributes atts) throws SAXException {
|
public void startElement(String uri, String localName, String name, Attributes atts) throws SAXException {
|
||||||
if (localName==null) {
|
if (localName == null) {
|
||||||
throw new SAXException("LocalName may not be null.");
|
throw new SAXException("LocalName may not be null.");
|
||||||
}
|
}
|
||||||
if (SAX3XMLConstants.isNameString(localName)==false) {
|
if (SAX3XMLConstants.isNameString(localName) == false) {
|
||||||
throw new SAXException("LocalName of element is not valid in xml; '"+localName+"'");
|
throw new SAXException("LocalName of element is not valid in xml; '" + localName + "'");
|
||||||
}
|
}
|
||||||
for (int i=0;i<atts.getLength();i++) {
|
for (int i = 0; i < atts.getLength(); i++) {
|
||||||
boolean isFirst = true;
|
boolean isFirst = true;
|
||||||
String attrLocalName = atts.getLocalName(i);
|
String attrLocalName = atts.getLocalName(i);
|
||||||
if (attrLocalName.isEmpty()) {
|
if (attrLocalName.isEmpty()) {
|
||||||
|
@ -271,27 +271,27 @@ public class AbstractXDBXWriterHandler implements ContentHandler, Closeable {
|
||||||
if (isFirst) {
|
if (isFirst) {
|
||||||
isFirst = false;
|
isFirst = false;
|
||||||
if (!SAX3XMLConstants.isNameStartChar(attrLocalName.codePoints().findFirst().getAsInt())) {
|
if (!SAX3XMLConstants.isNameStartChar(attrLocalName.codePoints().findFirst().getAsInt())) {
|
||||||
throw new SAXException("LocalAttributeName has illegal start character: " + attrLocalName);
|
throw new SAXException("LocalAttributeName has illegal start character: " + attrLocalName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!SAX3XMLConstants.isNameChar(c)) {
|
if (!SAX3XMLConstants.isNameChar(c)) {
|
||||||
throw new SAXException("LocalAttributeName has illegal name character: " + attrLocalName);
|
throw new SAXException("LocalAttributeName has illegal name character: " + attrLocalName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
startElementTag(uri,localName,name);
|
startElementTag(uri,localName,name);
|
||||||
startElementNamespace(uri);
|
startElementNamespace(uri);
|
||||||
startElementAttributes(atts);
|
startElementAttributes(atts);
|
||||||
if (SAX3XMLConstants.NULL_NS_URI.equals(uri) | uri==null) {
|
if (SAX3XMLConstants.NULL_NS_URI.equals(uri) || uri == null) {
|
||||||
elements.push(localName);
|
elements.push(localName);
|
||||||
} else {
|
} else {
|
||||||
elements.push(uri + ":" + name);
|
elements.push(uri + ":" + name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startElementTag(String uri, String localName,String name) throws SAXException {
|
public void startElementTag(String uri, String localName, String name) throws SAXException {
|
||||||
boolean localNameIdx = xdbxStringId(localName);
|
boolean localNameIdx = xdbxStringId(localName);
|
||||||
if (SAX3XMLConstants.NULL_NS_URI.equals(uri) | uri==null) {
|
if (SAX3XMLConstants.NULL_NS_URI.equals(uri) || uri==null) {
|
||||||
if (localNameIdx) {
|
if (localNameIdx) {
|
||||||
writeTag(XDBXContentTag.ELEMENT_I);
|
writeTag(XDBXContentTag.ELEMENT_I);
|
||||||
writeVariableInteger(xdbxStringStore(localName));
|
writeVariableInteger(xdbxStringStore(localName));
|
||||||
|
@ -304,7 +304,7 @@ public class AbstractXDBXWriterHandler implements ContentHandler, Closeable {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
String prefix = prefixMapping.get(uri);
|
String prefix = prefixMapping.get(uri);
|
||||||
if (prefix==null) {
|
if (prefix == null) {
|
||||||
throw new SAXException("preFixUri: "+uri+" is not started.");
|
throw new SAXException("preFixUri: "+uri+" is not started.");
|
||||||
}
|
}
|
||||||
if (localNameIdx) {
|
if (localNameIdx) {
|
||||||
|
@ -320,9 +320,9 @@ public class AbstractXDBXWriterHandler implements ContentHandler, Closeable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startElementNamespace(String uri) throws SAXException {
|
public void startElementNamespace(String uri) throws SAXException {
|
||||||
if ((uri!=null & SAX3XMLConstants.NULL_NS_URI.equals(uri)==false) && printedMappings.contains(uri)==false) {
|
if ((uri != null && SAX3XMLConstants.NULL_NS_URI.equals(uri) == false) && printedMappings.contains(uri) == false) {
|
||||||
String prefix = prefixMapping.get(uri);
|
String prefix = prefixMapping.get(uri);
|
||||||
if (prefix==null) {
|
if (prefix == null) {
|
||||||
throw new SAXException("preFixUri: "+uri+" is not started.");
|
throw new SAXException("preFixUri: "+uri+" is not started.");
|
||||||
}
|
}
|
||||||
printedMappings.add(uri);
|
printedMappings.add(uri);
|
||||||
|
@ -339,10 +339,10 @@ public class AbstractXDBXWriterHandler implements ContentHandler, Closeable {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String prefix = null;
|
String prefix = null;
|
||||||
for (String uri2:prefixMapping.keySet()) {
|
for (String uri2 : prefixMapping.keySet()) {
|
||||||
if (printedMappings.contains(uri2)==false) {
|
if (printedMappings.contains(uri2) == false) {
|
||||||
prefix = prefixMapping.get(uri2);
|
prefix = prefixMapping.get(uri2);
|
||||||
if (prefix==null) {
|
if (prefix == null) {
|
||||||
throw new SAXException("preFixUri: "+uri+" is not started.");
|
throw new SAXException("preFixUri: "+uri+" is not started.");
|
||||||
}
|
}
|
||||||
printedMappings.add(uri2);
|
printedMappings.add(uri2);
|
||||||
|
@ -355,18 +355,18 @@ public class AbstractXDBXWriterHandler implements ContentHandler, Closeable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startElementAttributes(Attributes atts) throws SAXException {
|
private void startElementAttributes(Attributes atts) throws SAXException {
|
||||||
for (int i=0;i<atts.getLength();i++) {
|
for (int i = 0; i < atts.getLength(); i++) {
|
||||||
String attributeUri = atts.getURI(i);
|
String attributeUri = atts.getURI(i);
|
||||||
String attributeName = atts.getLocalName(i);
|
String attributeName = atts.getLocalName(i);
|
||||||
String attributeValue = atts.getValue(i);
|
String attributeValue = atts.getValue(i);
|
||||||
if (attributeValue==null) {
|
if (attributeValue == null) {
|
||||||
attributeValue = propertyConfig.getPropertyString(OUTPUT_CHAR_NULL);
|
attributeValue = propertyConfig.getPropertyString(OUTPUT_CHAR_NULL);
|
||||||
}
|
}
|
||||||
String attributeValueSafe = SAX3XMLConstants.escapeAttributeValue(attributeValue);
|
String attributeValueSafe = SAX3XMLConstants.escapeAttributeValue(attributeValue);
|
||||||
boolean attributeValueSimple = attributeValue.equals(attributeValueSafe);
|
boolean attributeValueSimple = attributeValue.equals(attributeValueSafe);
|
||||||
boolean attributeNameIdx = xdbxStringId(attributeName);
|
boolean attributeNameIdx = xdbxStringId(attributeName);
|
||||||
|
|
||||||
if (SAX3XMLConstants.NULL_NS_URI.equals(attributeUri) | attributeUri ==null) {
|
if (SAX3XMLConstants.NULL_NS_URI.equals(attributeUri) || attributeUri ==null) {
|
||||||
if (attributeNameIdx) {
|
if (attributeNameIdx) {
|
||||||
writeTag(XDBXContentTag.ATTRIBUTE_I);
|
writeTag(XDBXContentTag.ATTRIBUTE_I);
|
||||||
writeVariableInteger(xdbxStringStore(attributeName));
|
writeVariableInteger(xdbxStringStore(attributeName));
|
||||||
|
@ -379,8 +379,8 @@ public class AbstractXDBXWriterHandler implements ContentHandler, Closeable {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
String attributeUriPrefix = prefixMapping.get(attributeUri);
|
String attributeUriPrefix = prefixMapping.get(attributeUri);
|
||||||
if (attributeUriPrefix==null) {
|
if (attributeUriPrefix == null) {
|
||||||
throw new SAXException("preFixUri: "+attributeUri+" is not started.");
|
throw new SAXException("preFixUri: " + attributeUri + " is not started.");
|
||||||
}
|
}
|
||||||
if (attributeNameIdx) {
|
if (attributeNameIdx) {
|
||||||
if (attributeValueSimple) {
|
if (attributeValueSimple) {
|
||||||
|
@ -407,14 +407,14 @@ public class AbstractXDBXWriterHandler implements ContentHandler, Closeable {
|
||||||
* @see org.xml.sax.ContentHandler#endElement(java.lang.String, java.lang.String, java.lang.String)
|
* @see org.xml.sax.ContentHandler#endElement(java.lang.String, java.lang.String, java.lang.String)
|
||||||
*/
|
*/
|
||||||
public void endElement(String uri, String localName, String name) throws SAXException {
|
public void endElement(String uri, String localName, String name) throws SAXException {
|
||||||
if (SAX3XMLConstants.NULL_NS_URI.equals(uri) | uri==null) {
|
if (SAX3XMLConstants.NULL_NS_URI.equals(uri) || uri==null) {
|
||||||
if (elements.size()>0 && elements.peek().equals(localName)==false) {
|
if (elements.size() > 0 && elements.peek().equals(localName) == false) {
|
||||||
throw new SAXException("Unexpected end tag: "+localName+" should be: "+elements.peek());
|
throw new SAXException("Unexpected end tag: " + localName + " should be: " + elements.peek());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
String qName = uri + ":" + name;
|
String qName = uri + ":" + name;
|
||||||
if (elements.size()>0 && elements.peek().equals(qName)==false) {
|
if (elements.size() > 0 && elements.peek().equals(qName) == false) {
|
||||||
throw new SAXException("Unexpected end tag: "+qName+" should be: "+elements.peek());
|
throw new SAXException("Unexpected end tag: " + qName + " should be: " + elements.peek());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elements.pop();
|
elements.pop();
|
||||||
|
@ -436,7 +436,6 @@ public class AbstractXDBXWriterHandler implements ContentHandler, Closeable {
|
||||||
writeTagLengthValue(XDBXContentTag.STRING_ID, prefix);
|
writeTagLengthValue(XDBXContentTag.STRING_ID, prefix);
|
||||||
writeVariableInteger(prefixIdxNum);
|
writeVariableInteger(prefixIdxNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean uriIdx = xdbxStringId(uri);
|
boolean uriIdx = xdbxStringId(uri);
|
||||||
if (!uriIdx) {
|
if (!uriIdx) {
|
||||||
int uriIdxNum = xdbxStringStore(uri);
|
int uriIdxNum = xdbxStringStore(uri);
|
||||||
|
@ -452,19 +451,19 @@ public class AbstractXDBXWriterHandler implements ContentHandler, Closeable {
|
||||||
public void endPrefixMapping(String prefix) throws SAXException {
|
public void endPrefixMapping(String prefix) throws SAXException {
|
||||||
Set<Map.Entry<String,String>> s = prefixMapping.entrySet();
|
Set<Map.Entry<String,String>> s = prefixMapping.entrySet();
|
||||||
String uri = null;
|
String uri = null;
|
||||||
for (Map.Entry<String,String> e:s) {
|
for (Map.Entry<String,String> e : s) {
|
||||||
if (e.getValue()==null) {
|
if (e.getValue() == null) {
|
||||||
continue; // way ?
|
continue; // way ?
|
||||||
}
|
}
|
||||||
if (e.getValue().equals(prefix)) {
|
if (e.getValue().equals(prefix)) {
|
||||||
uri = e.getKey();
|
uri = e.getKey();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (uri!=null) {
|
if (uri != null) {
|
||||||
prefixMapping.remove(uri);
|
prefixMapping.remove(uri);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prints xml characters and uses characters(java.lang.String) method.
|
* Prints xml characters and uses characters(java.lang.String) method.
|
||||||
*
|
*
|
||||||
|
@ -475,7 +474,7 @@ public class AbstractXDBXWriterHandler implements ContentHandler, Closeable {
|
||||||
* @see org.xml.sax.ContentHandler#characters(char[], int, int)
|
* @see org.xml.sax.ContentHandler#characters(char[], int, int)
|
||||||
*/
|
*/
|
||||||
public void characters(char[] ch, int start, int length) throws SAXException {
|
public void characters(char[] ch, int start, int length) throws SAXException {
|
||||||
characters(new String(ch,start,length));
|
characters(new String(ch, start, length));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -485,19 +484,19 @@ public class AbstractXDBXWriterHandler implements ContentHandler, Closeable {
|
||||||
* @see org.x4o.sax3.io.ContentWriter#characters(java.lang.String)
|
* @see org.x4o.sax3.io.ContentWriter#characters(java.lang.String)
|
||||||
*/
|
*/
|
||||||
public void characters(String text) throws SAXException {
|
public void characters(String text) throws SAXException {
|
||||||
if (text==null) {
|
if (text == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
charactersRaw(SAX3XMLConstants.escapeCharacters(text));
|
charactersRaw(SAX3XMLConstants.escapeCharacters(text));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void characters(char c) throws SAXException {
|
public void characters(char c) throws SAXException {
|
||||||
characters(new char[]{c},0,1);
|
characters(new char[]{c}, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// move or remove ?
|
// move or remove ?
|
||||||
protected void charactersRaw(String text) throws SAXException {
|
protected void charactersRaw(String text) throws SAXException {
|
||||||
if (text==null) {
|
if (text == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
writeTagLengthValue(XDBXContentTag.TEXT_T, text);
|
writeTagLengthValue(XDBXContentTag.TEXT_T, text);
|
||||||
|
@ -513,7 +512,7 @@ public class AbstractXDBXWriterHandler implements ContentHandler, Closeable {
|
||||||
* @see org.xml.sax.ContentHandler#ignorableWhitespace(char[], int, int)
|
* @see org.xml.sax.ContentHandler#ignorableWhitespace(char[], int, int)
|
||||||
*/
|
*/
|
||||||
public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
|
public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
|
||||||
ignorableWhitespace(new String(ch,start,length));
|
ignorableWhitespace(new String(ch, start, length));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -524,7 +523,7 @@ public class AbstractXDBXWriterHandler implements ContentHandler, Closeable {
|
||||||
* @see org.x4o.sax3.io.ContentWriter#ignorableWhitespace(java.lang.String)
|
* @see org.x4o.sax3.io.ContentWriter#ignorableWhitespace(java.lang.String)
|
||||||
*/
|
*/
|
||||||
public void ignorableWhitespace(String text) throws SAXException {
|
public void ignorableWhitespace(String text) throws SAXException {
|
||||||
if (text==null) {
|
if (text == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
writeTagLengthValue(XDBXContentTag.TEXT_WHITE_SPACE, text);
|
writeTagLengthValue(XDBXContentTag.TEXT_WHITE_SPACE, text);
|
||||||
|
@ -537,9 +536,9 @@ public class AbstractXDBXWriterHandler implements ContentHandler, Closeable {
|
||||||
* @throws SAXException When IOException has happend while printing.
|
* @throws SAXException When IOException has happend while printing.
|
||||||
*/
|
*/
|
||||||
public void ignorableWhitespace(char c) throws SAXException {
|
public void ignorableWhitespace(char c) throws SAXException {
|
||||||
ignorableWhitespace(new char[]{c},0,1);
|
ignorableWhitespace(new char[]{c}, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prints xml instructions.
|
* Prints xml instructions.
|
||||||
*
|
*
|
||||||
|
@ -552,11 +551,11 @@ public class AbstractXDBXWriterHandler implements ContentHandler, Closeable {
|
||||||
if (targetLow.startsWith(SAX3XMLConstants.XML)) {
|
if (targetLow.startsWith(SAX3XMLConstants.XML)) {
|
||||||
throw new SAXException("Processing instruction may not start with xml.");
|
throw new SAXException("Processing instruction may not start with xml.");
|
||||||
}
|
}
|
||||||
if (SAX3XMLConstants.isNameString(target)==false) {
|
if (SAX3XMLConstants.isNameString(target) == false) {
|
||||||
throw new SAXException("Processing instruction target is invalid name; '"+target+"'");
|
throw new SAXException("Processing instruction target is invalid name; '" + target + "'");
|
||||||
}
|
}
|
||||||
if (SAX3XMLConstants.isCharString(data)==false) {
|
if (SAX3XMLConstants.isCharString(data) == false) {
|
||||||
throw new SAXException("Processing instruction data is invalid char; '"+data+"'");
|
throw new SAXException("Processing instruction data is invalid char; '" + data + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
//'I' LengthValue StringID
|
//'I' LengthValue StringID
|
||||||
|
@ -571,7 +570,7 @@ public class AbstractXDBXWriterHandler implements ContentHandler, Closeable {
|
||||||
|
|
||||||
writeFlush();
|
writeFlush();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Not implemented.
|
* Not implemented.
|
||||||
*
|
*
|
||||||
|
@ -580,7 +579,7 @@ public class AbstractXDBXWriterHandler implements ContentHandler, Closeable {
|
||||||
*/
|
*/
|
||||||
public void setDocumentLocator(Locator locator) {
|
public void setDocumentLocator(Locator locator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Not implemented.
|
* Not implemented.
|
||||||
*
|
*
|
||||||
|
@ -590,7 +589,7 @@ public class AbstractXDBXWriterHandler implements ContentHandler, Closeable {
|
||||||
public void skippedEntity(String name) throws SAXException {
|
public void skippedEntity(String name) throws SAXException {
|
||||||
// is for validating parser support, so not needed in xml writing.
|
// is for validating parser support, so not needed in xml writing.
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prints xml comment.
|
* Prints xml comment.
|
||||||
*
|
*
|
||||||
|
@ -601,7 +600,7 @@ public class AbstractXDBXWriterHandler implements ContentHandler, Closeable {
|
||||||
* @see org.xml.sax.ext.DefaultHandler2#comment(char[], int, int)
|
* @see org.xml.sax.ext.DefaultHandler2#comment(char[], int, int)
|
||||||
*/
|
*/
|
||||||
public void comment(char[] ch, int start, int length) throws SAXException {
|
public void comment(char[] ch, int start, int length) throws SAXException {
|
||||||
comment(new String(ch,start,length));
|
comment(new String(ch, start, length));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -612,7 +611,7 @@ public class AbstractXDBXWriterHandler implements ContentHandler, Closeable {
|
||||||
* @see org.x4o.sax3.io.ContentWriter#comment(java.lang.String)
|
* @see org.x4o.sax3.io.ContentWriter#comment(java.lang.String)
|
||||||
*/
|
*/
|
||||||
public void comment(String text) throws SAXException {
|
public void comment(String text) throws SAXException {
|
||||||
if (text==null) {
|
if (text == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!propertyConfig.getPropertyBoolean(OUTPUT_COMMENT_ENABLE)) {
|
if (!propertyConfig.getPropertyBoolean(OUTPUT_COMMENT_ENABLE)) {
|
||||||
|
@ -620,15 +619,15 @@ public class AbstractXDBXWriterHandler implements ContentHandler, Closeable {
|
||||||
}
|
}
|
||||||
if (propertyConfig.getPropertyBoolean(OUTPUT_COMMENT_AUTO_SPACE)) {
|
if (propertyConfig.getPropertyBoolean(OUTPUT_COMMENT_AUTO_SPACE)) {
|
||||||
char textStart = text.charAt(0);
|
char textStart = text.charAt(0);
|
||||||
char textEnd = text.charAt(text.length()-1);
|
char textEnd = text.charAt(text.length() - 1);
|
||||||
if (textStart!=' ' && textStart!='\t' && textStart!='\n') {
|
if (textStart != ' ' && textStart != '\t' && textStart != '\n') {
|
||||||
text = " "+text;
|
text = " "+text;
|
||||||
}
|
}
|
||||||
if (textEnd!=' ' && textEnd!='\t' && textEnd!='\n') {
|
if (textEnd != ' ' && textEnd != '\t' && textEnd != '\n') {
|
||||||
text = text + " ";
|
text = text + " ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
writeTagLengthValue(XDBXContentTag.COMMENT, SAX3XMLConstants.escapeCharactersComment(text,"", 0));
|
writeTagLengthValue(XDBXContentTag.COMMENT, SAX3XMLConstants.escapeCharactersComment(text, "", 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void writeFlush() throws SAXException {
|
protected void writeFlush() throws SAXException {
|
||||||
|
|
|
@ -34,8 +34,8 @@ import org.xml.sax.ext.LexicalHandler;
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 Dec 20, 2024
|
* @version 1.0 Dec 20, 2024
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractXDBXWriterLexical extends AbstractXDBXWriterHandler implements LexicalHandler {
|
public abstract class AbstractXDBXWriterLexical extends AbstractXDBXWriterHandler implements LexicalHandler {
|
||||||
|
|
||||||
protected boolean printCDATA = false;
|
protected boolean printCDATA = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,7 +45,7 @@ public abstract class AbstractXDBXWriterLexical extends AbstractXDBXWriterHandle
|
||||||
public AbstractXDBXWriterLexical(OutputStream out) {
|
public AbstractXDBXWriterLexical(OutputStream out) {
|
||||||
super(out);
|
super(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.xml.sax.ext.LexicalHandler#startCDATA()
|
* @see org.xml.sax.ext.LexicalHandler#startCDATA()
|
||||||
*/
|
*/
|
||||||
|
@ -59,7 +59,7 @@ public abstract class AbstractXDBXWriterLexical extends AbstractXDBXWriterHandle
|
||||||
public void endCDATA() throws SAXException {
|
public void endCDATA() throws SAXException {
|
||||||
printCDATA = false;
|
printCDATA = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.xml.sax.ext.LexicalHandler#startDTD(java.lang.String, java.lang.String, java.lang.String)
|
* @see org.xml.sax.ext.LexicalHandler#startDTD(java.lang.String, java.lang.String, java.lang.String)
|
||||||
*/
|
*/
|
||||||
|
@ -72,7 +72,7 @@ public abstract class AbstractXDBXWriterLexical extends AbstractXDBXWriterHandle
|
||||||
*/
|
*/
|
||||||
public void endDTD() throws SAXException {
|
public void endDTD() throws SAXException {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.xml.sax.ext.LexicalHandler#startEntity(java.lang.String)
|
* @see org.xml.sax.ext.LexicalHandler#startEntity(java.lang.String)
|
||||||
*/
|
*/
|
||||||
|
@ -84,7 +84,7 @@ public abstract class AbstractXDBXWriterLexical extends AbstractXDBXWriterHandle
|
||||||
*/
|
*/
|
||||||
public void endEntity(String arg0) throws SAXException {
|
public void endEntity(String arg0) throws SAXException {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.sax3.io.AbstractContentWriterHandler#characters(char[], int, int)
|
* @see org.x4o.sax3.io.AbstractContentWriterHandler#characters(char[], int, int)
|
||||||
*/
|
*/
|
||||||
|
@ -92,14 +92,14 @@ public abstract class AbstractXDBXWriterLexical extends AbstractXDBXWriterHandle
|
||||||
public void characters(char[] ch, int start, int length) throws SAXException {
|
public void characters(char[] ch, int start, int length) throws SAXException {
|
||||||
characters(new String(ch, start, length));
|
characters(new String(ch, start, length));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.sax3.io.AbstractContentWriterHandler#characters(java.lang.String)
|
* @see org.x4o.sax3.io.AbstractContentWriterHandler#characters(java.lang.String)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void characters(String text) throws SAXException {
|
public void characters(String text) throws SAXException {
|
||||||
if (printCDATA) {
|
if (printCDATA) {
|
||||||
String textSafe = SAX3XMLConstants.escapeCharactersCdata(text,"","");
|
String textSafe = SAX3XMLConstants.escapeCharactersCdata(text, "", "");
|
||||||
writeTagLengthValue(XDBXContentTag.TEXT_CDATA, textSafe);
|
writeTagLengthValue(XDBXContentTag.TEXT_CDATA, textSafe);
|
||||||
} else {
|
} else {
|
||||||
super.characters(text);
|
super.characters(text);
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class XDBXReaderXml {
|
||||||
this.stringIdx = new HashMap<>();
|
this.stringIdx = new HashMap<>();
|
||||||
this.elementStack = new Stack<>();
|
this.elementStack = new Stack<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: replace with proper PropertyConfig support
|
// TODO: replace with proper PropertyConfig support
|
||||||
public XDBXReaderXml withNoFailOnUnsupportedTag() {
|
public XDBXReaderXml withNoFailOnUnsupportedTag() {
|
||||||
failOnUnsupportedTag = false;
|
failOnUnsupportedTag = false;
|
||||||
|
@ -236,7 +236,7 @@ public class XDBXReaderXml {
|
||||||
throw new SAXException("Unsupported tag: " + (char)token + " 0x" + Integer.toHexString(token).toUpperCase());
|
throw new SAXException("Unsupported tag: " + (char)token + " 0x" + Integer.toHexString(token).toUpperCase());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void flushDocDeclaration() throws SAXException {
|
protected void flushDocDeclaration() throws SAXException {
|
||||||
if (docMetaFlushed) {
|
if (docMetaFlushed) {
|
||||||
return;
|
return;
|
||||||
|
@ -244,7 +244,7 @@ public class XDBXReaderXml {
|
||||||
docMetaFlushed = true;
|
docMetaFlushed = true;
|
||||||
out.declaration(docXmlVersion, docEncoding, "");
|
out.declaration(docXmlVersion, docEncoding, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void flushElement() throws SAXException {
|
protected void flushElement() throws SAXException {
|
||||||
flushDocDeclaration();
|
flushDocDeclaration();
|
||||||
if (elementStack.isEmpty()) {
|
if (elementStack.isEmpty()) {
|
||||||
|
@ -257,13 +257,13 @@ public class XDBXReaderXml {
|
||||||
element.started = true;
|
element.started = true;
|
||||||
out.startElement(element.uri, element.localName, element.name, element.atts);
|
out.startElement(element.uri, element.localName, element.name, element.atts);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String readLengthValue(InputStream in) throws IOException {
|
protected String readLengthValue(InputStream in) throws IOException {
|
||||||
int len = readVariableInteger(in);
|
int len = readVariableInteger(in);
|
||||||
String value = new String(in.readNBytes(len));
|
String value = new String(in.readNBytes(len));
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int readVariableInteger(InputStream in) throws IOException {
|
protected int readVariableInteger(InputStream in) throws IOException {
|
||||||
int result = in.read();
|
int result = in.read();
|
||||||
if (result < 128) {
|
if (result < 128) {
|
||||||
|
@ -275,7 +275,7 @@ public class XDBXReaderXml {
|
||||||
}
|
}
|
||||||
return result + (in.read() << 14);
|
return result + (in.read() << 14);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int readHeaderFlags(InputStream in) throws IOException {
|
public int readHeaderFlags(InputStream in) throws IOException {
|
||||||
int result = 0;
|
int result = 0;
|
||||||
result += in.read() << 24;
|
result += in.read() << 24;
|
||||||
|
|
Loading…
Reference in a new issue