X4O: Formatted the SAX3 package to eclipse-160 (code+comment)
This commit is contained in:
parent
2819b36a45
commit
a61ce241e1
26 changed files with 1192 additions and 909 deletions
|
|
@ -41,7 +41,7 @@ import org.xml.sax.helpers.AttributesImpl;
|
|||
* @param <TAG> The enum for the XML tag values.
|
||||
* @param <TAG_WRITER> The tag writer to output to.
|
||||
*/
|
||||
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 TAG_WRITER contentWriter;
|
||||
|
|
@ -121,7 +121,7 @@ public class SAX3WriterEnum<TAG extends Enum<?>,TAG_WRITER extends ContentWriter
|
|||
|
||||
public void printTagEnd(TAG tag) throws IOException {
|
||||
try {
|
||||
contentWriter.endElement(getTagNamespaceUri(),toTagString(tag) , "");
|
||||
contentWriter.endElement(getTagNamespaceUri(), toTagString(tag), "");
|
||||
} catch (SAXException e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ import org.xml.sax.helpers.AttributesImpl;
|
|||
* @author Willem Cazander
|
||||
* @version 1.0 Apr 30, 2013
|
||||
*/
|
||||
public class SAX3WriterHtml extends SAX3WriterEnum<SAX3WriterHtml.Tag,SAX3WriterXml> {
|
||||
public class SAX3WriterHtml extends SAX3WriterEnum<SAX3WriterHtml.Tag, SAX3WriterXml> {
|
||||
|
||||
public SAX3WriterHtml(Writer out, String encoding) {
|
||||
super(new SAX3WriterXml(out, encoding), "", SAX3XMLConstants.NULL_NS_URI);
|
||||
|
|
@ -70,7 +70,7 @@ public class SAX3WriterHtml extends SAX3WriterEnum<SAX3WriterHtml.Tag,SAX3Writer
|
|||
|
||||
public void printHeadMetaDate() throws IOException {
|
||||
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 {
|
||||
|
|
@ -127,7 +127,9 @@ public class SAX3WriterHtml extends SAX3WriterEnum<SAX3WriterHtml.Tag,SAX3Writer
|
|||
text = "JavaScript is disabled on your browser.";
|
||||
}
|
||||
printTagStart(Tag.noscript);
|
||||
printTagStart(Tag.div);printCharacters(text);printTagEnd(Tag.div);
|
||||
printTagStart(Tag.div);
|
||||
printCharacters(text);
|
||||
printTagEnd(Tag.div);
|
||||
printTagEnd(Tag.noscript);
|
||||
}
|
||||
|
||||
|
|
@ -162,13 +164,13 @@ public class SAX3WriterHtml extends SAX3WriterEnum<SAX3WriterHtml.Tag,SAX3Writer
|
|||
if (title != null) {
|
||||
atts.addAttribute("", "title", "", "", title);
|
||||
}
|
||||
printTagStart(Tag.a,atts);
|
||||
printTagStart(Tag.a, atts);
|
||||
if (spanClass != null) {
|
||||
atts = new AttributesImpl();
|
||||
if (spanClass.length() > 0) {
|
||||
atts.addAttribute("", "class", "", "", spanClass);
|
||||
}
|
||||
printTagStart(Tag.span,atts);
|
||||
printTagStart(Tag.span, atts);
|
||||
}
|
||||
printCharacters(text);
|
||||
if (spanClass != null) {
|
||||
|
|
@ -244,51 +246,151 @@ public class SAX3WriterHtml extends SAX3WriterEnum<SAX3WriterHtml.Tag,SAX3Writer
|
|||
public enum Tag {
|
||||
|
||||
/* Deprecated TAGS */
|
||||
frameset,frame,noframes,tt,font,dir,center,strike,
|
||||
big,basefont,acronym,applet,iframe,
|
||||
frameset,
|
||||
frame,
|
||||
noframes,
|
||||
tt,
|
||||
font,
|
||||
dir,
|
||||
center,
|
||||
strike,
|
||||
big,
|
||||
basefont,
|
||||
acronym,
|
||||
applet,
|
||||
iframe,
|
||||
|
||||
/* HTML 4 TAGS */
|
||||
html,head,title,meta,link,base,body,script,style,
|
||||
html,
|
||||
head,
|
||||
title,
|
||||
meta,
|
||||
link,
|
||||
base,
|
||||
body,
|
||||
script,
|
||||
style,
|
||||
|
||||
h1,h2,h3,h4,h5,h6,
|
||||
a,div,span,p,pre,img,hr,br,
|
||||
b,em,strong,small,noscript,
|
||||
h1,
|
||||
h2,
|
||||
h3,
|
||||
h4,
|
||||
h5,
|
||||
h6,
|
||||
a,
|
||||
div,
|
||||
span,
|
||||
p,
|
||||
pre,
|
||||
img,
|
||||
hr,
|
||||
br,
|
||||
b,
|
||||
em,
|
||||
strong,
|
||||
small,
|
||||
noscript,
|
||||
|
||||
ul,li,dl,dt,dd,ol,
|
||||
table,thead,tfoot,tbody,caption,th,tr,td,
|
||||
ul,
|
||||
li,
|
||||
dl,
|
||||
dt,
|
||||
dd,
|
||||
ol,
|
||||
table,
|
||||
thead,
|
||||
tfoot,
|
||||
tbody,
|
||||
caption,
|
||||
th,
|
||||
tr,
|
||||
td,
|
||||
|
||||
abbr,address,area,bdo,blockquote,
|
||||
cite,code,col,colgroup,del,dfn,i,ins,
|
||||
kbd,legend,map,menu,object,param,
|
||||
optgroup,q,s,samp,sub,u,var,
|
||||
abbr,
|
||||
address,
|
||||
area,
|
||||
bdo,
|
||||
blockquote,
|
||||
cite,
|
||||
code,
|
||||
col,
|
||||
colgroup,
|
||||
del,
|
||||
dfn,
|
||||
i,
|
||||
ins,
|
||||
kbd,
|
||||
legend,
|
||||
map,
|
||||
menu,
|
||||
object,
|
||||
param,
|
||||
optgroup,
|
||||
q,
|
||||
s,
|
||||
samp,
|
||||
sub,
|
||||
u,
|
||||
var,
|
||||
|
||||
form,fieldset,input,option,
|
||||
label,button,select,textarea,
|
||||
form,
|
||||
fieldset,
|
||||
input,
|
||||
option,
|
||||
label,
|
||||
button,
|
||||
select,
|
||||
textarea,
|
||||
|
||||
/* HTML 5 TAGS */
|
||||
canvas,audio,video,source,embed,track,
|
||||
datalist,keygen,output,
|
||||
article,aside,bdi,command,details,dialog,summary,
|
||||
figure,figcaption,footer,header,hgroup,mark,meter,
|
||||
nav,progress,ruby,rt,rp,section,time,wbr,
|
||||
;
|
||||
canvas,
|
||||
audio,
|
||||
video,
|
||||
source,
|
||||
embed,
|
||||
track,
|
||||
datalist,
|
||||
keygen,
|
||||
output,
|
||||
article,
|
||||
aside,
|
||||
bdi,
|
||||
command,
|
||||
details,
|
||||
dialog,
|
||||
summary,
|
||||
figure,
|
||||
figcaption,
|
||||
footer,
|
||||
header,
|
||||
hgroup,
|
||||
mark,
|
||||
meter,
|
||||
nav,
|
||||
progress,
|
||||
ruby,
|
||||
rt,
|
||||
rp,
|
||||
section,
|
||||
time,
|
||||
wbr,;
|
||||
}
|
||||
|
||||
private final static String DOCTYPE_NAME = "HTML PUBLIC";
|
||||
|
||||
public enum DocType {
|
||||
/* Order from worst to better. */
|
||||
HTML_5("html","",""),
|
||||
HTML_5("html", "", ""),
|
||||
|
||||
HTML_4_FRAMESET(DOCTYPE_NAME,"\"-//W3C//DTD HTML 4.01 Frameset//EN\"","http://www.w3.org/TR/html4/frameset.dtd"),
|
||||
HTML_4_TRANSITIONAL(DOCTYPE_NAME,"\"-//W3C//DTD HTML 4.01 Transitional//EN\"","http://www.w3.org/TR/html4/loose.dtd"),
|
||||
HTML_4_STRICT(DOCTYPE_NAME,"\"-//W3C//DTD HTML 4.01//EN\"","http://www.w3.org/TR/html4/strict.dtd"),
|
||||
HTML_4_FRAMESET(DOCTYPE_NAME, "\"-//W3C//DTD HTML 4.01 Frameset//EN\"", "http://www.w3.org/TR/html4/frameset.dtd"),
|
||||
HTML_4_TRANSITIONAL(DOCTYPE_NAME, "\"-//W3C//DTD HTML 4.01 Transitional//EN\"", "http://www.w3.org/TR/html4/loose.dtd"),
|
||||
HTML_4_STRICT(DOCTYPE_NAME, "\"-//W3C//DTD HTML 4.01//EN\"", "http://www.w3.org/TR/html4/strict.dtd"),
|
||||
|
||||
XHTML_1_FRAMESET(DOCTYPE_NAME,"\"-//W3C//DTD XHTML 1.0 Frameset//EN\"","http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"),
|
||||
XHTML_1_TRANSITIONAL(DOCTYPE_NAME,"\"-//W3C//DTD XHTML 1.0 Transitional//EN\"","http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"),
|
||||
XHTML_1_STRICT(DOCTYPE_NAME,"\"-//W3C//DTD XHTML 1.0 Strict//EN\"","http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"),
|
||||
XHTML_1_FRAMESET(DOCTYPE_NAME, "\"-//W3C//DTD XHTML 1.0 Frameset//EN\"", "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"),
|
||||
XHTML_1_TRANSITIONAL(DOCTYPE_NAME, "\"-//W3C//DTD XHTML 1.0 Transitional//EN\"", "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"),
|
||||
XHTML_1_STRICT(DOCTYPE_NAME, "\"-//W3C//DTD XHTML 1.0 Strict//EN\"", "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"),
|
||||
|
||||
XHTML_11(DOCTYPE_NAME,"\"-//W3C//DTD XHTML 1.1//EN\"","http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"),
|
||||
;
|
||||
XHTML_11(DOCTYPE_NAME, "\"-//W3C//DTD XHTML 1.1//EN\"", "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"),;
|
||||
|
||||
private final String name;
|
||||
private final String publicId;
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ public class SAX3WriterXml extends AbstractContentWriter {
|
|||
|
||||
/**
|
||||
* Creates XmlWriter which prints to the Writer interface.
|
||||
*
|
||||
* @param out The writer to print the xml to.
|
||||
*/
|
||||
public SAX3WriterXml(Writer out, String encoding) {
|
||||
|
|
@ -49,14 +50,16 @@ public class SAX3WriterXml extends AbstractContentWriter {
|
|||
|
||||
/**
|
||||
* Creates XmlWriter which prints to the Writer interface.
|
||||
*
|
||||
* @param out The writer to print the xml to.
|
||||
*/
|
||||
public SAX3WriterXml(Writer out) {
|
||||
this(out,null);
|
||||
this(out, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates XmlWriter which prints to the OutputStream interface.
|
||||
*
|
||||
* @param out The OutputStream to write to.
|
||||
* @throws UnsupportedEncodingException Is thrown when UTF-8 can't we printed.
|
||||
*/
|
||||
|
|
@ -66,11 +69,12 @@ public class SAX3WriterXml extends AbstractContentWriter {
|
|||
|
||||
/**
|
||||
* Creates XmlWriter which prints to the OutputStream interface.
|
||||
*
|
||||
* @param out The OutputStream to write to.
|
||||
* @param encoding The OutputStream encoding.
|
||||
* @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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ import org.xml.sax.helpers.AttributesImpl;
|
|||
* @author Willem Cazander
|
||||
* @version 1.0 May 3, 2013
|
||||
*/
|
||||
public class SAX3WriterXsd extends SAX3WriterEnum<SAX3WriterXsd.Tag,SAX3WriterXml> {
|
||||
public class SAX3WriterXsd extends SAX3WriterEnum<SAX3WriterXsd.Tag, SAX3WriterXml> {
|
||||
|
||||
public SAX3WriterXsd(Writer out, String encoding) {
|
||||
super(new SAX3WriterXml(out, encoding), SAX3XMLConstants.XML_SCHEMA_NS_URI, SAX3XMLConstants.NULL_NS_URI);
|
||||
|
|
@ -75,10 +75,35 @@ public class SAX3WriterXsd extends SAX3WriterEnum<SAX3WriterXsd.Tag,SAX3WriterXm
|
|||
}
|
||||
|
||||
public enum Tag {
|
||||
all,annotation,any,anyAttribute,appinfo,attribute,attributeGroup,
|
||||
choice,complexContent,complexType,documentation,element,extension,
|
||||
field,group,_import,include,key,keyref,list,notation,
|
||||
redefine,restriction,schema,selector,sequence,
|
||||
simpleContent,simpleType,unoin,unique
|
||||
all,
|
||||
annotation,
|
||||
any,
|
||||
anyAttribute,
|
||||
appinfo,
|
||||
attribute,
|
||||
attributeGroup,
|
||||
choice,
|
||||
complexContent,
|
||||
complexType,
|
||||
documentation,
|
||||
element,
|
||||
extension,
|
||||
field,
|
||||
group,
|
||||
_import,
|
||||
include,
|
||||
key,
|
||||
keyref,
|
||||
list,
|
||||
notation,
|
||||
redefine,
|
||||
restriction,
|
||||
schema,
|
||||
selector,
|
||||
sequence,
|
||||
simpleContent,
|
||||
simpleType,
|
||||
unoin,
|
||||
unique
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ public abstract class AbstractContentWriter extends AbstractContentWriterLexical
|
|||
|
||||
/**
|
||||
* Creates an Lecical content writer for XML.
|
||||
*
|
||||
* @param out The writer to write to.
|
||||
*/
|
||||
public AbstractContentWriter(Writer out) {
|
||||
|
|
@ -45,6 +46,7 @@ public abstract class AbstractContentWriter extends AbstractContentWriterLexical
|
|||
|
||||
/**
|
||||
* 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)
|
||||
*/
|
||||
public void startElementEnd(String uri, String localName, String name, Attributes atts) throws SAXException {
|
||||
|
|
|
|||
|
|
@ -59,13 +59,14 @@ public class AbstractContentWriterHandler implements ContentHandler, Closeable {
|
|||
private final Writer out;
|
||||
private boolean started = false;
|
||||
private int indent = 0;
|
||||
private Map<String,String> prefixMapping = null;
|
||||
private Map<String, String> prefixMapping = null;
|
||||
private List<String> printedMappings = null;
|
||||
private StringBuilder startElement = null;
|
||||
private boolean printReturn = false;
|
||||
private String lastElement = null;
|
||||
private Stack<String> elements = null;
|
||||
|
||||
//@formatter:off
|
||||
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 String OUTPUT_ENCODING = PROPERTY_CONTEXT_PREFIX + "output/encoding";
|
||||
|
|
@ -105,14 +106,16 @@ public class AbstractContentWriterHandler implements ContentHandler, Closeable {
|
|||
new PropertyConfigItem(ROOT_START_NAMESPACE_ALL, Boolean.class, true)
|
||||
);
|
||||
}
|
||||
//@formatter:on
|
||||
|
||||
/**
|
||||
* Creates XmlWriter which prints to the Writer interface.
|
||||
*
|
||||
* @param out The writer to print the xml to.
|
||||
*/
|
||||
public AbstractContentWriterHandler(Writer out) {
|
||||
this.out = Objects.requireNonNull(out, "Can't write on null writer.");
|
||||
this.prefixMapping = new HashMap<String,String>(15);
|
||||
this.prefixMapping = new HashMap<String, String>(15);
|
||||
this.printedMappings = new ArrayList<String>(15);
|
||||
this.elements = new Stack<String>();
|
||||
this.propertyConfig = new SAX3PropertyConfig(DEFAULT_PROPERTY_CONFIG, PROPERTY_CONTEXT_PREFIX);
|
||||
|
|
@ -242,7 +245,7 @@ public class AbstractContentWriterHandler implements ContentHandler, Closeable {
|
|||
if (localName == 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 + "'");
|
||||
}
|
||||
for (int i = 0; i < atts.getLength(); i++) {
|
||||
|
|
@ -273,7 +276,7 @@ public class AbstractContentWriterHandler implements ContentHandler, Closeable {
|
|||
}
|
||||
startElement.append(SAX3XMLConstants.TAG_OPEN);
|
||||
|
||||
startElementTag(uri,localName);
|
||||
startElementTag(uri, localName);
|
||||
startElementNamespace(uri);
|
||||
startElementNamespaceAll();
|
||||
startElementAttributes(atts);
|
||||
|
|
@ -363,7 +366,7 @@ public class AbstractContentWriterHandler implements ContentHandler, Closeable {
|
|||
|
||||
private void printElementAttributeNewLineSpace() {
|
||||
startElement.append(SAX3XMLConstants.CHAR_NEWLINE);
|
||||
for (int ii = 0; ii < indent+1; ii++) {
|
||||
for (int ii = 0; ii < indent + 1; ii++) {
|
||||
startElement.append(getPropertyConfig().getPropertyString(OUTPUT_CHAR_TAB));
|
||||
}
|
||||
}
|
||||
|
|
@ -429,7 +432,7 @@ public class AbstractContentWriterHandler implements ContentHandler, Closeable {
|
|||
|
||||
if (startElement != null) {
|
||||
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);
|
||||
startElement = null;
|
||||
indent--;
|
||||
|
|
@ -469,6 +472,7 @@ public class AbstractContentWriterHandler implements ContentHandler, Closeable {
|
|||
|
||||
/**
|
||||
* Starts the prefix mapping of an xml namespace uri.
|
||||
*
|
||||
* @param prefix The xml prefix of this xml namespace uri.
|
||||
* @param uri The xml namespace uri to add the prefix for.
|
||||
* @see org.xml.sax.ContentHandler#startPrefixMapping(java.lang.String, java.lang.String)
|
||||
|
|
@ -482,9 +486,9 @@ public class AbstractContentWriterHandler implements ContentHandler, Closeable {
|
|||
* @see org.xml.sax.ContentHandler#endPrefixMapping(java.lang.String)
|
||||
*/
|
||||
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;
|
||||
for (Map.Entry<String,String> e : s) {
|
||||
for (Map.Entry<String, String> e : s) {
|
||||
if (e.getValue() == null) {
|
||||
continue; // way ?
|
||||
}
|
||||
|
|
@ -513,6 +517,7 @@ public class AbstractContentWriterHandler implements ContentHandler, Closeable {
|
|||
|
||||
/**
|
||||
* Escape and prints xml characters.
|
||||
*
|
||||
* @param text The text to write.
|
||||
* @throws SAXException When IOException has happend while printing.
|
||||
* @see org.x4o.sax3.io.ContentWriter#characters(java.lang.String)
|
||||
|
|
@ -525,7 +530,7 @@ public class AbstractContentWriterHandler implements ContentHandler, Closeable {
|
|||
}
|
||||
|
||||
public void characters(char c) throws SAXException {
|
||||
characters(new char[]{c}, 0, 1);
|
||||
characters(new char[] { c }, 0, 1);
|
||||
}
|
||||
|
||||
// move or remove ?
|
||||
|
|
@ -573,7 +578,7 @@ public class AbstractContentWriterHandler implements ContentHandler, Closeable {
|
|||
* @throws SAXException When IOException has happend while printing.
|
||||
*/
|
||||
public void ignorableWhitespace(char c) throws SAXException {
|
||||
ignorableWhitespace(new char[]{c}, 0, 1);
|
||||
ignorableWhitespace(new char[] { c }, 0, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -667,7 +672,7 @@ public class AbstractContentWriterHandler implements ContentHandler, Closeable {
|
|||
write(getPropertyConfig().getPropertyString(OUTPUT_CHAR_NEWLINE));
|
||||
writeIndent();
|
||||
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);
|
||||
printReturn = true;
|
||||
}
|
||||
|
|
@ -687,6 +692,7 @@ public class AbstractContentWriterHandler implements ContentHandler, Closeable {
|
|||
|
||||
/**
|
||||
* Auto close the start element if working in printing event.
|
||||
*
|
||||
* @throws SAXException When prints gives exception.
|
||||
*/
|
||||
protected void autoCloseStartElement() throws SAXException {
|
||||
|
|
@ -699,6 +705,7 @@ public class AbstractContentWriterHandler implements ContentHandler, Closeable {
|
|||
|
||||
/**
|
||||
* Indent the output writer with tabs by indent count.
|
||||
*
|
||||
* @throws SAXException When prints gives exception.
|
||||
*/
|
||||
private void writeIndent() throws SAXException {
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ public abstract class AbstractContentWriterLexical extends AbstractContentWriter
|
|||
|
||||
/**
|
||||
* Creates XmlWriter which prints to the Writer interface.
|
||||
*
|
||||
* @param out The writer to print the xml to.
|
||||
*/
|
||||
public AbstractContentWriterLexical(Writer out) {
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ import java.util.Set;
|
|||
* @param <K> The key class.
|
||||
* @param <V> The value class.
|
||||
*/
|
||||
public class AttributeMap<K,V> implements Map<K,V> {
|
||||
public class AttributeMap<K, V> implements Map<K, V> {
|
||||
|
||||
/** stores the SAX attributes set */
|
||||
private Attributes attributes = null;
|
||||
|
|
@ -134,6 +134,7 @@ public class AttributeMap<K,V> implements Map<K,V> {
|
|||
|
||||
/**
|
||||
* Gets the attribute value.
|
||||
*
|
||||
* @param key The name of the attribute.
|
||||
* @return The value of the attribute.
|
||||
*/
|
||||
|
|
@ -203,7 +204,7 @@ public class AttributeMap<K,V> implements Map<K,V> {
|
|||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public V get(Object key) {
|
||||
return (V)getValue(key);
|
||||
return (V) getValue(key);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -224,7 +225,7 @@ public class AttributeMap<K,V> implements Map<K,V> {
|
|||
* @return always null
|
||||
*/
|
||||
public V remove(Object key) {
|
||||
return null ;// we can't remove
|
||||
return null;// we can't remove
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -253,7 +254,7 @@ public class AttributeMap<K,V> implements Map<K,V> {
|
|||
public Set<K> keySet() {
|
||||
HashSet<K> result = new HashSet<K>();
|
||||
for (int i = 0; i < size(); i++) {
|
||||
result.add((K)getName(i));
|
||||
result.add((K) getName(i));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
@ -267,14 +268,13 @@ public class AttributeMap<K,V> implements Map<K,V> {
|
|||
public Collection<V> values() {
|
||||
ArrayList<V> result = new ArrayList<V>();
|
||||
for (int i = 0; i < size(); i++) {
|
||||
result.add((V)attributes.getValue(i));
|
||||
result.add((V) attributes.getValue(i));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* 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.
|
||||
*
|
||||
* @see java.util.Map#entrySet()
|
||||
* @return An entry set.
|
||||
|
|
@ -320,6 +320,7 @@ public class AttributeMap<K,V> implements Map<K,V> {
|
|||
|
||||
/**
|
||||
* Creates AttributeMapEntry with key object.
|
||||
*
|
||||
* @param key The key.
|
||||
*/
|
||||
protected AttributeMapEntry(Object key) {
|
||||
|
|
@ -335,6 +336,7 @@ public class AttributeMap<K,V> implements Map<K,V> {
|
|||
|
||||
/**
|
||||
* Sets the value of this Map.Entry.
|
||||
*
|
||||
* @param value The value to set.
|
||||
* @return The old value.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ package org.x4o.sax3.io;
|
|||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
/**
|
||||
* Functional closable callback for indenting api flow.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ import org.xml.sax.ContentHandler;
|
|||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.ext.LexicalHandler;
|
||||
|
||||
|
||||
/**
|
||||
* ContentWriter is ContentHandler for writing sax events.
|
||||
*
|
||||
|
|
@ -58,6 +57,7 @@ public interface ContentWriter extends ContentHandler, LexicalHandler, Closeable
|
|||
|
||||
/**
|
||||
* Starts and ends an element in one call.
|
||||
*
|
||||
* @param uri The uri of the element.
|
||||
* @param localName The localName of the element.
|
||||
* @param name The name of the element.
|
||||
|
|
@ -68,6 +68,7 @@ public interface ContentWriter extends ContentHandler, LexicalHandler, Closeable
|
|||
|
||||
/**
|
||||
* Writes a String as xml comment.
|
||||
*
|
||||
* @param text The text to have embedded as comment in xml.
|
||||
* @throws SAXException On error.
|
||||
*/
|
||||
|
|
@ -75,6 +76,7 @@ public interface ContentWriter extends ContentHandler, LexicalHandler, Closeable
|
|||
|
||||
/**
|
||||
* Writes a whitespace String to the body.
|
||||
*
|
||||
* @param text The String of whitespace to write.
|
||||
* @throws SAXException On error.
|
||||
*/
|
||||
|
|
@ -82,6 +84,7 @@ public interface ContentWriter extends ContentHandler, LexicalHandler, Closeable
|
|||
|
||||
/**
|
||||
* Writes a whitespace character to the body.
|
||||
*
|
||||
* @param c The character to write.
|
||||
* @throws SAXException On error;
|
||||
*/
|
||||
|
|
@ -89,6 +92,7 @@ public interface ContentWriter extends ContentHandler, LexicalHandler, Closeable
|
|||
|
||||
/**
|
||||
* Writes a String in the body.
|
||||
*
|
||||
* @param text The text to write.
|
||||
* @throws SAXException On error.
|
||||
*/
|
||||
|
|
@ -96,6 +100,7 @@ public interface ContentWriter extends ContentHandler, LexicalHandler, Closeable
|
|||
|
||||
/**
|
||||
* Writes a single character in the body body.
|
||||
*
|
||||
* @param c The character to write.
|
||||
* @throws SAXException On error.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ import org.xml.sax.Attributes;
|
|||
import org.xml.sax.Locator;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
|
||||
/**
|
||||
* ContentWriterAdapter is base ContentHandler for writing SAX3 events.
|
||||
*
|
||||
|
|
@ -44,7 +43,7 @@ abstract public class ContentWriterAdapter implements ContentWriter {
|
|||
}
|
||||
|
||||
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 {
|
||||
|
|
@ -53,7 +52,7 @@ abstract public class ContentWriterAdapter implements ContentWriter {
|
|||
}
|
||||
|
||||
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 {
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ import java.util.function.Supplier;
|
|||
public final class SAX3PropertyConfig implements Cloneable {
|
||||
|
||||
public final static String X4O_PROPERTIES_PREFIX = "http://x4o.org/properties/";
|
||||
private final Map<String,PropertyConfigItem> items;
|
||||
private final Map<String, PropertyConfigItem> items;
|
||||
private final boolean readOnly;
|
||||
private final String keyPrefix;
|
||||
|
||||
|
|
@ -57,7 +57,7 @@ public final class SAX3PropertyConfig implements Cloneable {
|
|||
}
|
||||
this.readOnly = readOnly;
|
||||
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);
|
||||
copyParentPropertyConfig(fillItems, parentPropertyConfig);
|
||||
if (fillItems.isEmpty()) {
|
||||
|
|
@ -79,14 +79,14 @@ public final class SAX3PropertyConfig implements Cloneable {
|
|||
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++) {
|
||||
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) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -171,6 +171,7 @@ public final class SAX3PropertyConfig implements Cloneable {
|
|||
|
||||
/**
|
||||
* Clones all the fields into the new PropertyConfigItem.
|
||||
*
|
||||
* @see java.lang.Object#clone()
|
||||
*/
|
||||
@Override
|
||||
|
|
@ -230,7 +231,7 @@ public final class SAX3PropertyConfig implements Cloneable {
|
|||
return Collections.unmodifiableList(result);
|
||||
}
|
||||
|
||||
public final void setProperty(String key,Object value) {
|
||||
public final void setProperty(String key, Object value) {
|
||||
if (readOnly) {
|
||||
throw new IllegalStateException("This property is readonly for key:" + key);
|
||||
}
|
||||
|
|
@ -268,7 +269,7 @@ public final class SAX3PropertyConfig implements Cloneable {
|
|||
public final File getPropertyFile(String key) {
|
||||
Object value = getProperty(key);
|
||||
if (value instanceof File) {
|
||||
return (File)value;
|
||||
return (File) value;
|
||||
}
|
||||
if (value == null) {
|
||||
return null;
|
||||
|
|
@ -287,7 +288,7 @@ public final class SAX3PropertyConfig implements Cloneable {
|
|||
public final Boolean getPropertyBoolean(String key) {
|
||||
Object value = getProperty(key);
|
||||
if (value instanceof Boolean) {
|
||||
return (Boolean)value;
|
||||
return (Boolean) value;
|
||||
}
|
||||
if (value == null) {
|
||||
return null;
|
||||
|
|
@ -306,7 +307,7 @@ public final class SAX3PropertyConfig implements Cloneable {
|
|||
public final Integer getPropertyInteger(String key) {
|
||||
Object value = getProperty(key);
|
||||
if (value instanceof Integer) {
|
||||
return (Integer)value;
|
||||
return (Integer) value;
|
||||
}
|
||||
if (value == null) {
|
||||
return null;
|
||||
|
|
@ -326,7 +327,7 @@ public final class SAX3PropertyConfig implements Cloneable {
|
|||
public final List<String> getPropertyList(String key) {
|
||||
Object value = getProperty(key);
|
||||
if (value instanceof List) {
|
||||
return (List<String>)value;
|
||||
return (List<String>) value;
|
||||
}
|
||||
if (value == null) {
|
||||
return null;
|
||||
|
|
@ -343,10 +344,10 @@ public final class SAX3PropertyConfig implements Cloneable {
|
|||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public final Map<String,String> getPropertyMap(String key) {
|
||||
public final Map<String, String> getPropertyMap(String key) {
|
||||
Object value = getProperty(key);
|
||||
if (value instanceof Map) {
|
||||
return (Map<String,String>)value;
|
||||
return (Map<String, String>) value;
|
||||
}
|
||||
if (value == null) {
|
||||
return null;
|
||||
|
|
@ -354,8 +355,8 @@ public final class SAX3PropertyConfig implements Cloneable {
|
|||
throw new IllegalStateException("Wrong value type: " + value.getClass() + " for key: " + key);
|
||||
}
|
||||
|
||||
public final Map<String,String> getPropertyMap(String key, Supplier<Map<String,String>> defaultValue) {
|
||||
Map<String,String> result = getPropertyMap(key);
|
||||
public final Map<String, String> getPropertyMap(String key, Supplier<Map<String, String>> defaultValue) {
|
||||
Map<String, String> result = getPropertyMap(key);
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
|
|
@ -365,7 +366,7 @@ public final class SAX3PropertyConfig implements Cloneable {
|
|||
public final String getPropertyString(String key) {
|
||||
Object value = getProperty(key);
|
||||
if (value instanceof String) {
|
||||
return (String)value;
|
||||
return (String) value;
|
||||
}
|
||||
if (value == null) {
|
||||
return null;
|
||||
|
|
@ -373,7 +374,7 @@ public final class SAX3PropertyConfig implements Cloneable {
|
|||
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);
|
||||
if (propertyValue == null) {
|
||||
return defaultValue;
|
||||
|
|
@ -382,7 +383,7 @@ public final class SAX3PropertyConfig implements Cloneable {
|
|||
}
|
||||
}
|
||||
|
||||
public final String getPropertyString(String key,Supplier<String> defaultValue) {
|
||||
public final String getPropertyString(String key, Supplier<String> defaultValue) {
|
||||
String result = getPropertyString(key);
|
||||
if (result != null) {
|
||||
return result;
|
||||
|
|
@ -401,7 +402,7 @@ public final class SAX3PropertyConfig implements Cloneable {
|
|||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public final void setPropertyParsedValue(String key,String value) {
|
||||
public final void setPropertyParsedValue(String key, String value) {
|
||||
Class<?> valueType = getPropertyType(key);
|
||||
if (String.class.equals(valueType)) {
|
||||
setProperty(key, value);
|
||||
|
|
@ -429,7 +430,7 @@ public final class SAX3PropertyConfig implements Cloneable {
|
|||
}
|
||||
if (List.class.equals(valueType)) {
|
||||
String[] listValues = value.split(",");
|
||||
List<String> result = (List<String>)getProperty(key);
|
||||
List<String> result = (List<String>) getProperty(key);
|
||||
if (result == null) {
|
||||
result = new ArrayList<String>(10);
|
||||
setProperty(key, result);
|
||||
|
|
@ -441,9 +442,9 @@ public final class SAX3PropertyConfig implements Cloneable {
|
|||
}
|
||||
if (Map.class.equals(valueType)) {
|
||||
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) {
|
||||
result = new HashMap<String,String>(10);
|
||||
result = new HashMap<String, String>(10);
|
||||
setProperty(key, result);
|
||||
}
|
||||
if (listValues.length != 2) {
|
||||
|
|
@ -458,6 +459,7 @@ public final class SAX3PropertyConfig implements Cloneable {
|
|||
|
||||
/**
|
||||
* Clones all the properties into the new PropertyConfig.
|
||||
*
|
||||
* @see java.lang.Object#clone()
|
||||
*/
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ public final class SAX3XMLConstants {
|
|||
|
||||
/**
|
||||
* Null or empty namespace uri.
|
||||
*
|
||||
* @see <a href="http://www.w3.org/TR/REC-xml-names/#defaulting">Namespaces in XML, 5.2 Namespace Defaulting</a>
|
||||
*/
|
||||
public static final String NULL_NS_URI = javax.xml.XMLConstants.NULL_NS_URI; // ""
|
||||
|
|
@ -131,12 +132,12 @@ public final class SAX3XMLConstants {
|
|||
/**
|
||||
* The regex expression of a cdata start section.
|
||||
*/
|
||||
public static final String CDATA_START_REGEX = "<!\\x"+Integer.toHexString('[')+"CDATA\\x"+Integer.toHexString('[');
|
||||
public static final String CDATA_START_REGEX = "<!\\x" + Integer.toHexString('[') + "CDATA\\x" + Integer.toHexString('[');
|
||||
|
||||
/**
|
||||
* The regex expression of a cdata end section.
|
||||
*/
|
||||
public static final String CDATA_END_REGEX = "\\x"+Integer.toHexString(']')+"\\x"+Integer.toHexString(']')+">";
|
||||
public static final String CDATA_END_REGEX = "\\x" + Integer.toHexString(']') + "\\x" + Integer.toHexString(']') + ">";
|
||||
|
||||
/**
|
||||
* Tab char
|
||||
|
|
@ -161,7 +162,7 @@ public final class SAX3XMLConstants {
|
|||
public static final int CODE_POINT_ENTIY_REF_TERMINATOR = ';';
|
||||
|
||||
static public String getDocumentDeclaration(String encoding) {
|
||||
return getDocumentDeclaration(encoding,null);
|
||||
return getDocumentDeclaration(encoding, null);
|
||||
}
|
||||
|
||||
static public String getDocumentDeclaration(String encoding, String version) {
|
||||
|
|
@ -176,45 +177,106 @@ public final class SAX3XMLConstants {
|
|||
|
||||
static public boolean isChar(int c) {
|
||||
// Exclude "compatibility characters", as defined in section 2.3 of [Unicode]
|
||||
if (c>=0x7F & c<=0x84) { return false; }
|
||||
if (c>=0x86 & c<=0x9F) { return false; }
|
||||
if (c>=0xFDD0 & c<=0xFDEF) { return false; }
|
||||
if ((c>=0x1FFFE & c<=0x1FFFF)||(c>=0x2FFFE & c<=0x2FFFF)|(c>=0x3FFFE & c<=0x3FFFF)) { return false; }
|
||||
if ((c>=0x4FFFE & c<=0x4FFFF)||(c>=0x5FFFE & c<=0x5FFFF)|(c>=0x6FFFE & c<=0x6FFFF)) { return false; }
|
||||
if ((c>=0x7FFFE & c<=0x7FFFF)||(c>=0x8FFFE & c<=0x8FFFF)|(c>=0x9FFFE & c<=0x9FFFF)) { return false; }
|
||||
if ((c>=0xAFFFE & c<=0xAFFFF)||(c>=0xBFFFE & c<=0xBFFFF)|(c>=0xCFFFE & c<=0xCFFFF)) { return false; }
|
||||
if ((c>=0xDFFFE & c<=0xDFFFF)||(c>=0xEFFFE & c<=0xEFFFF)|(c>=0xFFFFE & c<=0xFFFFF)) { return false; }
|
||||
if (c>=0x10FFFE & c<=0x10FFFF) { return false; }
|
||||
if (c >= 0x7F & c <= 0x84) {
|
||||
return false;
|
||||
}
|
||||
if (c >= 0x86 & c <= 0x9F) {
|
||||
return false;
|
||||
}
|
||||
if (c >= 0xFDD0 & c <= 0xFDEF) {
|
||||
return false;
|
||||
}
|
||||
if ((c >= 0x1FFFE & c <= 0x1FFFF) || (c >= 0x2FFFE & c <= 0x2FFFF) | (c >= 0x3FFFE & c <= 0x3FFFF)) {
|
||||
return false;
|
||||
}
|
||||
if ((c >= 0x4FFFE & c <= 0x4FFFF) || (c >= 0x5FFFE & c <= 0x5FFFF) | (c >= 0x6FFFE & c <= 0x6FFFF)) {
|
||||
return false;
|
||||
}
|
||||
if ((c >= 0x7FFFE & c <= 0x7FFFF) || (c >= 0x8FFFE & c <= 0x8FFFF) | (c >= 0x9FFFE & c <= 0x9FFFF)) {
|
||||
return false;
|
||||
}
|
||||
if ((c >= 0xAFFFE & c <= 0xAFFFF) || (c >= 0xBFFFE & c <= 0xBFFFF) | (c >= 0xCFFFE & c <= 0xCFFFF)) {
|
||||
return false;
|
||||
}
|
||||
if ((c >= 0xDFFFE & c <= 0xDFFFF) || (c >= 0xEFFFE & c <= 0xEFFFF) | (c >= 0xFFFFE & c <= 0xFFFFF)) {
|
||||
return false;
|
||||
}
|
||||
if (c >= 0x10FFFE & c <= 0x10FFFF) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Source;
|
||||
// #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
|
||||
if (c==0x9) { return true; }
|
||||
if (c==0xA) { return true; }
|
||||
if (c==0xD) { return true; }
|
||||
if (c>=0x20 & c<=0xD7FF) { return true; }
|
||||
if (c>=0xE000 & c<=0xFFFD) { return true; }
|
||||
if (c>=0x10000 & c<=0x10FFFF) { return true; }
|
||||
if (c == 0x9) {
|
||||
return true;
|
||||
}
|
||||
if (c == 0xA) {
|
||||
return true;
|
||||
}
|
||||
if (c == 0xD) {
|
||||
return true;
|
||||
}
|
||||
if (c >= 0x20 & c <= 0xD7FF) {
|
||||
return true;
|
||||
}
|
||||
if (c >= 0xE000 & c <= 0xFFFD) {
|
||||
return true;
|
||||
}
|
||||
if (c >= 0x10000 & c <= 0x10FFFF) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static public boolean isNameStartChar(int c) {
|
||||
// Source;
|
||||
// ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
|
||||
if (c>='a' & c<='z') { return true; }
|
||||
if (c>='A' & c<='Z') { return true; }
|
||||
if (c==':' || c=='_') { return true; }
|
||||
if (c>=0xC0 & c<=0xD6) { return true; }
|
||||
if (c>=0xD8 & c<=0xF6) { return true; }
|
||||
if (c>=0xF8 & c<=0x2FF) { return true; }
|
||||
if (c>=0x370 & c<=0x37D) { return true; }
|
||||
if (c>=0x37F & c<=0x1FFF) { return true; }
|
||||
if (c>=0x200C & c<=0x200D) { return true; }
|
||||
if (c>=0x2070 & c<=0x218F) { return true; }
|
||||
if (c>=0x2C00 & c<=0x2FEF) { return true; }
|
||||
if (c>=0x3001 & c<=0xD7FF) { return true; }
|
||||
if (c>=0xF900 & c<=0xFDCF) { return true; }
|
||||
if (c>=0xFDF0 & c<=0xFFFD) { return true; }
|
||||
if (c>=0x10000 & c<=0xEFFFF) { return true; }
|
||||
// ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] |
|
||||
// [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
|
||||
if (c >= 'a' & c <= 'z') {
|
||||
return true;
|
||||
}
|
||||
if (c >= 'A' & c <= 'Z') {
|
||||
return true;
|
||||
}
|
||||
if (c == ':' || c == '_') {
|
||||
return true;
|
||||
}
|
||||
if (c >= 0xC0 & c <= 0xD6) {
|
||||
return true;
|
||||
}
|
||||
if (c >= 0xD8 & c <= 0xF6) {
|
||||
return true;
|
||||
}
|
||||
if (c >= 0xF8 & c <= 0x2FF) {
|
||||
return true;
|
||||
}
|
||||
if (c >= 0x370 & c <= 0x37D) {
|
||||
return true;
|
||||
}
|
||||
if (c >= 0x37F & c <= 0x1FFF) {
|
||||
return true;
|
||||
}
|
||||
if (c >= 0x200C & c <= 0x200D) {
|
||||
return true;
|
||||
}
|
||||
if (c >= 0x2070 & c <= 0x218F) {
|
||||
return true;
|
||||
}
|
||||
if (c >= 0x2C00 & c <= 0x2FEF) {
|
||||
return true;
|
||||
}
|
||||
if (c >= 0x3001 & c <= 0xD7FF) {
|
||||
return true;
|
||||
}
|
||||
if (c >= 0xF900 & c <= 0xFDCF) {
|
||||
return true;
|
||||
}
|
||||
if (c >= 0xFDF0 & c <= 0xFFFD) {
|
||||
return true;
|
||||
}
|
||||
if (c >= 0x10000 & c <= 0xEFFFF) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -224,11 +286,21 @@ public final class SAX3XMLConstants {
|
|||
if (isNameStartChar(c)) {
|
||||
return true;
|
||||
}
|
||||
if (c=='-' || c=='.') { return true; }
|
||||
if (c>='0' & c<='9') { return true; }
|
||||
if (c==0xB7) { return true; }
|
||||
if (c>=0x0300 & c<=0x036F) { return true; }
|
||||
if (c>=0x203F & c<=0x2040) { return true; }
|
||||
if (c == '-' || c == '.') {
|
||||
return true;
|
||||
}
|
||||
if (c >= '0' & c <= '9') {
|
||||
return true;
|
||||
}
|
||||
if (c == 0xB7) {
|
||||
return true;
|
||||
}
|
||||
if (c >= 0x0300 & c <= 0x036F) {
|
||||
return true;
|
||||
}
|
||||
if (c >= 0x203F & c <= 0x2040) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -293,7 +365,7 @@ public final class SAX3XMLConstants {
|
|||
while (iterator.hasNext()) {
|
||||
int c = iterator.nextInt();
|
||||
// 3.3.3 Attribute-Value Normalization.
|
||||
if (escapeXMLValueAppend(c,result)) {
|
||||
if (escapeXMLValueAppend(c, result)) {
|
||||
continue;
|
||||
}
|
||||
result.appendCodePoint(c);
|
||||
|
|
@ -323,18 +395,18 @@ public final class SAX3XMLConstants {
|
|||
result.append(entity);
|
||||
continue; // contine to next i char.
|
||||
} else {
|
||||
//i = iOrg; // continue normal escape.
|
||||
// i = iOrg; // continue normal escape.
|
||||
PrimitiveIterator.OfInt entityIterator = entity.codePoints().iterator();
|
||||
while (entityIterator.hasNext()) {
|
||||
int entityCodePoint = entityIterator.nextInt();
|
||||
if (escapeXMLValueAppend(entityCodePoint,result)) {
|
||||
if (escapeXMLValueAppend(entityCodePoint, result)) {
|
||||
continue;
|
||||
}
|
||||
result.appendCodePoint(entityCodePoint);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (escapeXMLValueAppend(c,result)) {
|
||||
if (escapeXMLValueAppend(c, result)) {
|
||||
continue;
|
||||
}
|
||||
result.appendCodePoint(c);
|
||||
|
|
@ -348,7 +420,7 @@ public final class SAX3XMLConstants {
|
|||
|
||||
// Hex code points
|
||||
if (entity.startsWith("&#")) {
|
||||
String hex = entity.substring(2,entity.length() - 1);
|
||||
String hex = entity.substring(2, entity.length() - 1);
|
||||
if (hex.startsWith("x")) {
|
||||
hex = hex.substring(1);
|
||||
}
|
||||
|
|
@ -357,45 +429,95 @@ public final class SAX3XMLConstants {
|
|||
}
|
||||
|
||||
// XML
|
||||
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;
|
||||
}
|
||||
if (">".equals(entity)) {
|
||||
return true;
|
||||
}
|
||||
if ("&".equals(entity)) {
|
||||
return true;
|
||||
}
|
||||
if (""".equals(entity)) {
|
||||
return true;
|
||||
}
|
||||
if ("'".equals(entity)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// HTML
|
||||
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; }
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
// TODO: etc/etc
|
||||
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; }
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
if (" ".equals(entity)) {
|
||||
return true;
|
||||
}
|
||||
if ("®".equals(entity)) {
|
||||
return true;
|
||||
}
|
||||
if ("™".equals(entity)) {
|
||||
return true;
|
||||
}
|
||||
if ("©".equals(entity)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static public String escapeCharactersCdata(String value,String replaceCdataStart,String replaceCdataEnd) {
|
||||
static public String escapeCharactersCdata(String value, String replaceCdataStart, String replaceCdataEnd) {
|
||||
value = value.replaceAll(CDATA_START_REGEX, replaceCdataStart);
|
||||
value = value.replaceAll(CDATA_END_REGEX, replaceCdataEnd);
|
||||
return value;
|
||||
}
|
||||
|
||||
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_END, "");
|
||||
StringBuilder result = new StringBuilder(value.length());
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ public abstract class AbstractXDBXWriter extends AbstractXDBXWriterLexical imple
|
|||
|
||||
/**
|
||||
* Creates writer which prints to the stream interface.
|
||||
*
|
||||
* @param out The stream to print the xml to.
|
||||
*/
|
||||
public AbstractXDBXWriter(OutputStream out) {
|
||||
|
|
@ -46,10 +47,11 @@ public abstract class AbstractXDBXWriter extends AbstractXDBXWriterLexical imple
|
|||
|
||||
/**
|
||||
* 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)
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,11 +60,12 @@ public class AbstractXDBXWriterHandler implements ContentHandler, Closeable {
|
|||
|
||||
private final SAX3PropertyConfig propertyConfig;
|
||||
private final OutputStream out;
|
||||
private Map<String,String> prefixMapping = null;
|
||||
private Map<String, String> prefixMapping = null;
|
||||
private List<String> printedMappings = null;
|
||||
private Stack<String> elements = null;
|
||||
private Map<String,Integer> stringIdx = null;
|
||||
private Map<String, Integer> stringIdx = null;
|
||||
|
||||
//@formatter:off
|
||||
private final static String PROPERTY_CONTEXT_PREFIX = SAX3PropertyConfig.X4O_PROPERTIES_PREFIX+"writer/xdbx/";
|
||||
public final static SAX3PropertyConfig DEFAULT_PROPERTY_CONFIG;
|
||||
public final static String OUTPUT_DECLARATION = PROPERTY_CONTEXT_PREFIX+"output/declaration";
|
||||
|
|
@ -94,14 +95,16 @@ public class AbstractXDBXWriterHandler implements ContentHandler, Closeable {
|
|||
new PropertyConfigItem(ROOT_START_NAMESPACE_ALL, Boolean.class, true)
|
||||
);
|
||||
}
|
||||
//@formatter:on
|
||||
|
||||
/**
|
||||
* Creates writer which prints to the stream interface.
|
||||
*
|
||||
* @param out The stream to print the xml to.
|
||||
*/
|
||||
public AbstractXDBXWriterHandler(OutputStream out) {
|
||||
this.out = Objects.requireNonNull(out, "Can't write on null OutputStream.");
|
||||
this.prefixMapping = new HashMap<String,String>(15);
|
||||
this.prefixMapping = new HashMap<String, String>(15);
|
||||
this.printedMappings = new ArrayList<String>(15);
|
||||
this.elements = new Stack<String>();
|
||||
this.propertyConfig = new SAX3PropertyConfig(DEFAULT_PROPERTY_CONFIG, PROPERTY_CONTEXT_PREFIX);
|
||||
|
|
@ -146,9 +149,9 @@ public class AbstractXDBXWriterHandler implements ContentHandler, Closeable {
|
|||
writeLengthValue("1.0");
|
||||
writeTag(XDBXContentTag.ENCODING);
|
||||
writeLengthValue("utf-8");
|
||||
//Standalone in TV(standalone) form where the value of 'standalone' is either 0 or 1.
|
||||
//write(XDBXContentTag.STANDALONE);
|
||||
//write(1);
|
||||
// Standalone in TV(standalone) form where the value of 'standalone' is either 0 or 1.
|
||||
// write(XDBXContentTag.STANDALONE);
|
||||
// write(1);
|
||||
}
|
||||
prologWriteLicence();
|
||||
prologWriteUserComment();
|
||||
|
|
@ -168,7 +171,7 @@ public class AbstractXDBXWriterHandler implements ContentHandler, Closeable {
|
|||
}
|
||||
licenceInput = cl.getResourceAsStream(licenceResource);
|
||||
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) {
|
||||
|
|
@ -202,7 +205,7 @@ public class AbstractXDBXWriterHandler implements ContentHandler, Closeable {
|
|||
sb.append('\n');
|
||||
String line = br.readLine();
|
||||
while (line != null) {
|
||||
if (line.length()>0) {
|
||||
if (line.length() > 0) {
|
||||
sb.append(" ");
|
||||
}
|
||||
sb.append(line);
|
||||
|
|
@ -228,8 +231,8 @@ public class AbstractXDBXWriterHandler implements ContentHandler, Closeable {
|
|||
if (userComment.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
String chEnter = "\n"; //getPropertyConfig().getPropertyString(OUTPUT_CHAR_NEWLINE);
|
||||
String chTab = "\t"; //getPropertyConfig().getPropertyString(OUTPUT_CHAR_TAB);
|
||||
String chEnter = "\n"; // getPropertyConfig().getPropertyString(OUTPUT_CHAR_NEWLINE);
|
||||
String chTab = "\t"; // getPropertyConfig().getPropertyString(OUTPUT_CHAR_TAB);
|
||||
userComment = userComment.replaceAll("\n", chEnter + chTab);
|
||||
comment(chEnter + chTab + userComment + chEnter);
|
||||
}
|
||||
|
|
@ -279,7 +282,7 @@ public class AbstractXDBXWriterHandler implements ContentHandler, Closeable {
|
|||
}
|
||||
}
|
||||
}
|
||||
startElementTag(uri,localName,name);
|
||||
startElementTag(uri, localName, name);
|
||||
startElementNamespace(uri);
|
||||
startElementAttributes(atts);
|
||||
if (SAX3XMLConstants.NULL_NS_URI.equals(uri) || uri == null) {
|
||||
|
|
@ -291,7 +294,7 @@ public class AbstractXDBXWriterHandler implements ContentHandler, Closeable {
|
|||
|
||||
public void startElementTag(String uri, String localName, String name) throws SAXException {
|
||||
boolean localNameIdx = xdbxStringId(localName);
|
||||
if (SAX3XMLConstants.NULL_NS_URI.equals(uri) || uri==null) {
|
||||
if (SAX3XMLConstants.NULL_NS_URI.equals(uri) || uri == null) {
|
||||
if (localNameIdx) {
|
||||
writeTag(XDBXContentTag.ELEMENT_I);
|
||||
writeVariableInteger(xdbxStringStore(localName));
|
||||
|
|
@ -305,7 +308,7 @@ public class AbstractXDBXWriterHandler implements ContentHandler, Closeable {
|
|||
} else {
|
||||
String prefix = prefixMapping.get(uri);
|
||||
if (prefix == null) {
|
||||
throw new SAXException("preFixUri: "+uri+" is not started.");
|
||||
throw new SAXException("preFixUri: " + uri + " is not started.");
|
||||
}
|
||||
if (localNameIdx) {
|
||||
writeTag(XDBXContentTag.ELEMENT_III);
|
||||
|
|
@ -323,7 +326,7 @@ public class AbstractXDBXWriterHandler implements ContentHandler, Closeable {
|
|||
if ((uri != null && SAX3XMLConstants.NULL_NS_URI.equals(uri) == false) && printedMappings.contains(uri) == false) {
|
||||
String prefix = prefixMapping.get(uri);
|
||||
if (prefix == null) {
|
||||
throw new SAXException("preFixUri: "+uri+" is not started.");
|
||||
throw new SAXException("preFixUri: " + uri + " is not started.");
|
||||
}
|
||||
printedMappings.add(uri);
|
||||
|
||||
|
|
@ -343,7 +346,7 @@ public class AbstractXDBXWriterHandler implements ContentHandler, Closeable {
|
|||
if (printedMappings.contains(uri2) == false) {
|
||||
prefix = prefixMapping.get(uri2);
|
||||
if (prefix == null) {
|
||||
throw new SAXException("preFixUri: "+uri+" is not started.");
|
||||
throw new SAXException("preFixUri: " + uri + " is not started.");
|
||||
}
|
||||
printedMappings.add(uri2);
|
||||
|
||||
|
|
@ -366,7 +369,7 @@ public class AbstractXDBXWriterHandler implements ContentHandler, Closeable {
|
|||
boolean attributeValueSimple = attributeValue.equals(attributeValueSafe);
|
||||
boolean attributeNameIdx = xdbxStringId(attributeName);
|
||||
|
||||
if (SAX3XMLConstants.NULL_NS_URI.equals(attributeUri) || attributeUri ==null) {
|
||||
if (SAX3XMLConstants.NULL_NS_URI.equals(attributeUri) || attributeUri == null) {
|
||||
if (attributeNameIdx) {
|
||||
writeTag(XDBXContentTag.ATTRIBUTE_I);
|
||||
writeVariableInteger(xdbxStringStore(attributeName));
|
||||
|
|
@ -407,7 +410,7 @@ public class AbstractXDBXWriterHandler implements ContentHandler, Closeable {
|
|||
* @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 {
|
||||
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) {
|
||||
throw new SAXException("Unexpected end tag: " + localName + " should be: " + elements.peek());
|
||||
}
|
||||
|
|
@ -423,6 +426,7 @@ public class AbstractXDBXWriterHandler implements ContentHandler, Closeable {
|
|||
|
||||
/**
|
||||
* Starts the prefix mapping of an xml namespace uri.
|
||||
*
|
||||
* @param prefix The xml prefix of this xml namespace uri.
|
||||
* @param uri The xml namespace uri to add the prefix for.
|
||||
* @see org.xml.sax.ContentHandler#startPrefixMapping(java.lang.String, java.lang.String)
|
||||
|
|
@ -449,9 +453,9 @@ public class AbstractXDBXWriterHandler implements ContentHandler, Closeable {
|
|||
* @see org.xml.sax.ContentHandler#endPrefixMapping(java.lang.String)
|
||||
*/
|
||||
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;
|
||||
for (Map.Entry<String,String> e : s) {
|
||||
for (Map.Entry<String, String> e : s) {
|
||||
if (e.getValue() == null) {
|
||||
continue; // way ?
|
||||
}
|
||||
|
|
@ -479,6 +483,7 @@ public class AbstractXDBXWriterHandler implements ContentHandler, Closeable {
|
|||
|
||||
/**
|
||||
* Escape and prints xml characters.
|
||||
*
|
||||
* @param text The text to write.
|
||||
* @throws SAXException When IOException has happend while printing.
|
||||
* @see org.x4o.sax3.io.ContentWriter#characters(java.lang.String)
|
||||
|
|
@ -491,7 +496,7 @@ public class AbstractXDBXWriterHandler implements ContentHandler, Closeable {
|
|||
}
|
||||
|
||||
public void characters(char c) throws SAXException {
|
||||
characters(new char[]{c}, 0, 1);
|
||||
characters(new char[] { c }, 0, 1);
|
||||
}
|
||||
|
||||
// move or remove ?
|
||||
|
|
@ -536,7 +541,7 @@ public class AbstractXDBXWriterHandler implements ContentHandler, Closeable {
|
|||
* @throws SAXException When IOException has happend while printing.
|
||||
*/
|
||||
public void ignorableWhitespace(char c) throws SAXException {
|
||||
ignorableWhitespace(new char[]{c}, 0, 1);
|
||||
ignorableWhitespace(new char[] { c }, 0, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -558,12 +563,12 @@ public class AbstractXDBXWriterHandler implements ContentHandler, Closeable {
|
|||
throw new SAXException("Processing instruction data is invalid char; '" + data + "'");
|
||||
}
|
||||
|
||||
//'I' LengthValue StringID
|
||||
// 'I' LengthValue StringID
|
||||
int targetIdx = xdbxStringStore(target);
|
||||
writeTagLengthValue(XDBXContentTag.STRING_ID, target);
|
||||
writeVariableInteger(targetIdx);
|
||||
|
||||
//'P' StringID LengthValue
|
||||
// 'P' StringID LengthValue
|
||||
writeTag(XDBXContentTag.PROCESSING_INSTRUCTION);
|
||||
writeVariableInteger(targetIdx);
|
||||
writeLengthValue(data);
|
||||
|
|
@ -621,7 +626,7 @@ public class AbstractXDBXWriterHandler implements ContentHandler, Closeable {
|
|||
char textStart = text.charAt(0);
|
||||
char textEnd = text.charAt(text.length() - 1);
|
||||
if (textStart != ' ' && textStart != '\t' && textStart != '\n') {
|
||||
text = " "+text;
|
||||
text = " " + text;
|
||||
}
|
||||
if (textEnd != ' ' && textEnd != '\t' && textEnd != '\n') {
|
||||
text = text + " ";
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ public abstract class AbstractXDBXWriterLexical extends AbstractXDBXWriterHandle
|
|||
|
||||
/**
|
||||
* Creates writer which prints to the stream interface.
|
||||
*
|
||||
* @param out The stream to print the xml to.
|
||||
*/
|
||||
public AbstractXDBXWriterLexical(OutputStream out) {
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ package org.x4o.sax3.io.xdbx;
|
|||
*/
|
||||
public final class XDBXConstants {
|
||||
|
||||
static public final byte[] HEADER_MARKER = new byte[] {(byte) 0xCA, 0x3B};
|
||||
static public final byte[] HEADER_MARKER = new byte[] { (byte) 0xCA, 0x3B };
|
||||
static public final byte HEADER_LENGHT = 0x05;
|
||||
static public final byte HEADER_VERSION = 0x01;
|
||||
|
||||
|
|
|
|||
|
|
@ -54,8 +54,7 @@ public enum XDBXContentTag {
|
|||
PROCESSING_INSTRUCTION('P'),
|
||||
STRING_ID('I'),
|
||||
HINT('H'),
|
||||
SEQUENCE_SEPERATOR('@'),
|
||||
;
|
||||
SEQUENCE_SEPERATOR('@'),;
|
||||
|
||||
private final int tagNumber;
|
||||
|
||||
|
|
|
|||
|
|
@ -233,7 +233,7 @@ public class XDBXReaderXml {
|
|||
return; // NOP is done by caller
|
||||
}
|
||||
if (failOnUnsupportedTag) {
|
||||
throw new SAXException("Unsupported tag: " + (char)token + " 0x" + Integer.toHexString(token).toUpperCase());
|
||||
throw new SAXException("Unsupported tag: " + (char) token + " 0x" + Integer.toHexString(token).toUpperCase());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -303,6 +303,7 @@ public class XDBXReaderXml {
|
|||
XDBXElement() {
|
||||
atts = new AttributesImpl();
|
||||
}
|
||||
|
||||
XDBXElement(String localName) {
|
||||
this();
|
||||
this.localName = localName;
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ public class XDBXWriterXml extends AbstractXDBXWriter {
|
|||
|
||||
/**
|
||||
* Creates XmlWriter which prints to the OutputStream interface.
|
||||
*
|
||||
* @param out The OutputStream to write to.
|
||||
*/
|
||||
public XDBXWriterXml(OutputStream out) {
|
||||
|
|
|
|||
|
|
@ -54,13 +54,13 @@ public class SAX3WriterXmlAttributeTest {
|
|||
try (SAX3WriterXml writer = new SAX3WriterXml(outputWriter)) {
|
||||
writer.startDocument();
|
||||
AttributesImpl atts = new AttributesImpl();
|
||||
atts.addAttribute ("", "attr", "", "", "foobar");
|
||||
atts.addAttribute("", "attr", "", "", "foobar");
|
||||
writer.startElementEnd("", "test", "", atts);
|
||||
writer.endDocument();
|
||||
}
|
||||
String output = outputWriter.toString();
|
||||
Assertions.assertNotNull(output);
|
||||
Assertions.assertTrue(output.length()>0);
|
||||
Assertions.assertTrue(output.length() > 0);
|
||||
Assertions.assertTrue(output.equals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<test attr=\"foobar\"/>"), output);
|
||||
}
|
||||
|
||||
|
|
@ -70,14 +70,16 @@ public class SAX3WriterXmlAttributeTest {
|
|||
try (SAX3WriterXml writer = new SAX3WriterXml(outputWriter)) {
|
||||
writer.startDocument();
|
||||
AttributesImpl atts = new AttributesImpl();
|
||||
atts.addAttribute ("", "attr", "", "", "<test/> & 'foobar' is \"quoted\"!");
|
||||
atts.addAttribute("", "attr", "", "", "<test/> & 'foobar' is \"quoted\"!");
|
||||
writer.startElementEnd("", "test", "", atts);
|
||||
writer.endDocument();
|
||||
}
|
||||
String output = outputWriter.toString();
|
||||
Assertions.assertNotNull(output);
|
||||
Assertions.assertTrue(output.length()>0);
|
||||
Assertions.assertTrue(output.equals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<test attr=\"<test/> & 'foobar' is "quoted"!\"/>"), output);
|
||||
Assertions.assertTrue(output.length() > 0);
|
||||
Assertions.assertTrue(
|
||||
output.equals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<test attr=\"<test/> & 'foobar' is "quoted"!\"/>"),
|
||||
output);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -87,32 +89,32 @@ public class SAX3WriterXmlAttributeTest {
|
|||
writer.startDocument();
|
||||
Assertions.assertThrows(SAXException.class, () -> {
|
||||
AttributesImpl atts = new AttributesImpl();
|
||||
atts.addAttribute ("", "", "", "", "junit");
|
||||
atts.addAttribute("", "", "", "", "junit");
|
||||
writer.startElementEnd("", "test", "", atts);
|
||||
});
|
||||
Assertions.assertThrows(SAXException.class, () -> {
|
||||
AttributesImpl atts = new AttributesImpl();
|
||||
atts.addAttribute ("", " ", "", "", "junit");
|
||||
atts.addAttribute("", " ", "", "", "junit");
|
||||
writer.startElementEnd("", "test", "", atts);
|
||||
});
|
||||
Assertions.assertThrows(SAXException.class, () -> {
|
||||
AttributesImpl atts = new AttributesImpl();
|
||||
atts.addAttribute ("", "foo bar", "", "", "junit");
|
||||
atts.addAttribute("", "foo bar", "", "", "junit");
|
||||
writer.startElementEnd("", "test", "", atts);
|
||||
});
|
||||
Assertions.assertThrows(SAXException.class, () -> {
|
||||
AttributesImpl atts = new AttributesImpl();
|
||||
atts.addAttribute ("", "foobar", "", "", "junit");
|
||||
atts.addAttribute("", "foobar", "", "", "junit");
|
||||
writer.startElementEnd("", "test junit", "", atts);
|
||||
});
|
||||
AttributesImpl atts = new AttributesImpl();
|
||||
atts.addAttribute ("", "abc", "", "", " junit ");
|
||||
atts.addAttribute("", "abc", "", "", " junit ");
|
||||
writer.startElementEnd("", "root", "", atts);
|
||||
writer.endDocument();
|
||||
}
|
||||
String output = outputWriter.toString();
|
||||
Assertions.assertNotNull(output);
|
||||
Assertions.assertTrue(output.length()>0);
|
||||
Assertions.assertTrue(output.length() > 0);
|
||||
Assertions.assertTrue(output.equals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<root abc=\" junit \"/>"), output);
|
||||
}
|
||||
|
||||
|
|
@ -122,13 +124,13 @@ public class SAX3WriterXmlAttributeTest {
|
|||
try (SAX3WriterXml writer = new SAX3WriterXml(outputWriter)) {
|
||||
writer.startDocument();
|
||||
AttributesImpl atts = new AttributesImpl();
|
||||
atts.addAttribute ("", "仙上主天", "", "", "仙上主天");
|
||||
atts.addAttribute("", "仙上主天", "", "", "仙上主天");
|
||||
writer.startElementEnd("", "chinees", "", atts);
|
||||
writer.endDocument();
|
||||
}
|
||||
String output = outputWriter.toString();
|
||||
Assertions.assertNotNull(output);
|
||||
Assertions.assertTrue(output.length()>0);
|
||||
Assertions.assertTrue(output.length() > 0);
|
||||
Assertions.assertTrue(output.equals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<chinees 仙上主天=\"仙上主天\"/>"), output);
|
||||
|
||||
SAXParserFactory saxFactory = SAXParserFactory.newInstance();
|
||||
|
|
@ -145,15 +147,17 @@ public class SAX3WriterXmlAttributeTest {
|
|||
// Legal by spec, but not in JVM SAX Reader
|
||||
writer.startDocument();
|
||||
AttributesImpl atts = new AttributesImpl();
|
||||
atts.addAttribute ("", "𑀳𑁂𑀮𑀺𑀉𑁄𑀤𑁄𑀭𑁂𑀡𑀪𑀸𑀕", "", "", "𑀳𑁂𑀮𑀺𑀉𑁄𑀤𑁄𑀭𑁂𑀡𑀪𑀸𑀕");
|
||||
atts.addAttribute ("", "ᒡᒢᑊᒻᒻᓫᔿ", "", "", "ᒡᒢᑊᒻᒻᓫᔿ");
|
||||
atts.addAttribute("", "𑀳𑁂𑀮𑀺𑀉𑁄𑀤𑁄𑀭𑁂𑀡𑀪𑀸𑀕", "", "", "𑀳𑁂𑀮𑀺𑀉𑁄𑀤𑁄𑀭𑁂𑀡𑀪𑀸𑀕");
|
||||
atts.addAttribute("", "ᒡᒢᑊᒻᒻᓫᔿ", "", "", "ᒡᒢᑊᒻᒻᓫᔿ");
|
||||
writer.startElementEnd("", "test", "", atts);
|
||||
writer.endDocument();
|
||||
}
|
||||
String output = outputWriter.toString();
|
||||
Assertions.assertNotNull(output);
|
||||
Assertions.assertTrue(output.length()>0);
|
||||
Assertions.assertTrue(output.equals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<test 𑀳𑁂𑀮𑀺𑀉𑁄𑀤𑁄𑀭𑁂𑀡𑀪𑀸𑀕=\"𑀳𑁂𑀮𑀺𑀉𑁄𑀤𑁄𑀭𑁂𑀡𑀪𑀸𑀕\" ᒡᒢᑊᒻᒻᓫᔿ=\"ᒡᒢᑊᒻᒻᓫᔿ\"/>"), output);
|
||||
Assertions.assertTrue(output.length() > 0);
|
||||
Assertions.assertTrue(output.equals(
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<test 𑀳𑁂𑀮𑀺𑀉𑁄𑀤𑁄𑀭𑁂𑀡𑀪𑀸𑀕=\"𑀳𑁂𑀮𑀺𑀉𑁄𑀤𑁄𑀭𑁂𑀡𑀪𑀸𑀕\" ᒡᒢᑊᒻᒻᓫᔿ=\"ᒡᒢᑊᒻᒻᓫᔿ\"/>"),
|
||||
output);
|
||||
|
||||
// TODO: fix SAX impl
|
||||
Assertions.assertThrows(SAXException.class, () -> {
|
||||
|
|
@ -164,10 +168,10 @@ public class SAX3WriterXmlAttributeTest {
|
|||
});
|
||||
}
|
||||
|
||||
private String createLongAttribute(Map<String,Object> para) throws SAXException, IOException {
|
||||
private String createLongAttribute(Map<String, Object> para) throws SAXException, IOException {
|
||||
StringWriter outputWriter = new StringWriter();
|
||||
try (SAX3WriterXml writer = new SAX3WriterXml(outputWriter)) {
|
||||
for (String key:para.keySet()) {
|
||||
for (String key : para.keySet()) {
|
||||
Object value = para.get(key);
|
||||
writer.getPropertyConfig().setProperty(key, value);
|
||||
}
|
||||
|
|
@ -175,8 +179,8 @@ public class SAX3WriterXmlAttributeTest {
|
|||
AttributesImpl atts = new AttributesImpl();
|
||||
String data = "_FOR_FOO_BAR";
|
||||
String dataValue = "LOOP";
|
||||
for (int i=0;i<15;i++) {
|
||||
atts.addAttribute("", "attr"+i, "", "", dataValue+=data);
|
||||
for (int i = 0; i < 15; i++) {
|
||||
atts.addAttribute("", "attr" + i, "", "", dataValue += data);
|
||||
}
|
||||
writer.startDocument();
|
||||
writer.startElement("", "test", "", atts);
|
||||
|
|
@ -190,40 +194,40 @@ public class SAX3WriterXmlAttributeTest {
|
|||
|
||||
@Test
|
||||
public void testAttributeLongNormal() throws Exception {
|
||||
Map<String,Object> para = new HashMap<String,Object>();
|
||||
Map<String, Object> para = new HashMap<String, Object>();
|
||||
String output = createLongAttribute(para);
|
||||
int newlines = output.split("\n").length;
|
||||
Assertions.assertNotNull(output);
|
||||
Assertions.assertTrue(newlines==4, "outputs: "+newlines);
|
||||
Assertions.assertTrue(newlines == 4, "outputs: " + newlines);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAttributeLongPerLine() throws Exception {
|
||||
Map<String,Object> para = new HashMap<String,Object>();
|
||||
Map<String, Object> para = new HashMap<String, Object>();
|
||||
para.put(SAX3WriterXml.OUTPUT_LINE_PER_ATTRIBUTE, true);
|
||||
String output = createLongAttribute(para);
|
||||
int newlines = output.split("\n").length;
|
||||
Assertions.assertNotNull(output);
|
||||
Assertions.assertTrue(newlines==20, "outputs: "+newlines);
|
||||
Assertions.assertTrue(newlines == 20, "outputs: " + newlines);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAttributeLongSplit80() throws Exception {
|
||||
Map<String,Object> para = new HashMap<String,Object>();
|
||||
Map<String, Object> para = new HashMap<String, Object>();
|
||||
para.put(SAX3WriterXml.OUTPUT_LINE_BREAK_WIDTH, 80);
|
||||
String output = createLongAttribute(para);
|
||||
int newlines = output.split("\n").length;
|
||||
Assertions.assertNotNull(output);
|
||||
Assertions.assertTrue(newlines==16, "outputs: "+newlines);
|
||||
Assertions.assertTrue(newlines == 16, "outputs: " + newlines);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAttributeLongSplit180() throws Exception {
|
||||
Map<String,Object> para = new HashMap<String,Object>();
|
||||
Map<String, Object> para = new HashMap<String, Object>();
|
||||
para.put(SAX3WriterXml.OUTPUT_LINE_BREAK_WIDTH, 180);
|
||||
String output = createLongAttribute(para);
|
||||
int newlines = output.split("\n").length;
|
||||
Assertions.assertNotNull(output);
|
||||
Assertions.assertTrue(newlines==11, "outputs: "+newlines);
|
||||
Assertions.assertTrue(newlines == 11, "outputs: " + newlines);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public class SAX3WriterXmlCDataTest {
|
|||
}
|
||||
String output = outputWriter.toString();
|
||||
Assertions.assertNotNull(output);
|
||||
Assertions.assertTrue(output.length()>0);
|
||||
Assertions.assertTrue(output.length() > 0);
|
||||
Assertions.assertTrue(output.equals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>foobar"), output);
|
||||
}
|
||||
|
||||
|
|
@ -60,7 +60,7 @@ public class SAX3WriterXmlCDataTest {
|
|||
}
|
||||
String output = outputWriter.toString();
|
||||
Assertions.assertNotNull(output);
|
||||
Assertions.assertTrue(output.length()>0);
|
||||
Assertions.assertTrue(output.length() > 0);
|
||||
Assertions.assertTrue(output.equals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>foobar<test/>"), output);
|
||||
}
|
||||
|
||||
|
|
@ -76,7 +76,7 @@ public class SAX3WriterXmlCDataTest {
|
|||
}
|
||||
String output = outputWriter.toString();
|
||||
Assertions.assertNotNull(output);
|
||||
Assertions.assertTrue(output.length()>0);
|
||||
Assertions.assertTrue(output.length() > 0);
|
||||
Assertions.assertTrue(output.equals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><![CDATA[foobar]]>"), output);
|
||||
}
|
||||
|
||||
|
|
@ -92,7 +92,7 @@ public class SAX3WriterXmlCDataTest {
|
|||
}
|
||||
String output = outputWriter.toString();
|
||||
Assertions.assertNotNull(output);
|
||||
Assertions.assertTrue(output.length()>0);
|
||||
Assertions.assertTrue(output.length() > 0);
|
||||
Assertions.assertTrue(output.equals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><![CDATA[foobar<test/>]]>"), output);
|
||||
}
|
||||
|
||||
|
|
@ -108,7 +108,7 @@ public class SAX3WriterXmlCDataTest {
|
|||
}
|
||||
String output = outputWriter.toString();
|
||||
Assertions.assertNotNull(output);
|
||||
Assertions.assertTrue(output.length()>0);
|
||||
Assertions.assertTrue(output.length() > 0);
|
||||
Assertions.assertTrue(output.equals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><![CDATA[foobar]]>"), output);
|
||||
}
|
||||
|
||||
|
|
@ -124,7 +124,7 @@ public class SAX3WriterXmlCDataTest {
|
|||
}
|
||||
String output = outputWriter.toString();
|
||||
Assertions.assertNotNull(output);
|
||||
Assertions.assertTrue(output.length()>0);
|
||||
Assertions.assertTrue(output.length() > 0);
|
||||
Assertions.assertTrue(output.equals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><![CDATA[foobar]]>"), output);
|
||||
}
|
||||
|
||||
|
|
@ -140,7 +140,7 @@ public class SAX3WriterXmlCDataTest {
|
|||
}
|
||||
String output = outputWriter.toString();
|
||||
Assertions.assertNotNull(output);
|
||||
Assertions.assertTrue(output.length()>0);
|
||||
Assertions.assertTrue(output.length() > 0);
|
||||
Assertions.assertTrue(output.equals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><![CDATA[ᒡᒢᑊᒻᒻᓫᔿ]]>"), output);
|
||||
}
|
||||
|
||||
|
|
@ -156,7 +156,7 @@ public class SAX3WriterXmlCDataTest {
|
|||
}
|
||||
String output = outputWriter.toString();
|
||||
Assertions.assertNotNull(output);
|
||||
Assertions.assertTrue(output.length()>0);
|
||||
Assertions.assertTrue(output.length() > 0);
|
||||
Assertions.assertTrue(output.equals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><![CDATA[tokens like \'\' are <invalid>]]>"), output);
|
||||
}
|
||||
|
||||
|
|
@ -172,7 +172,7 @@ public class SAX3WriterXmlCDataTest {
|
|||
}
|
||||
String output = outputWriter.toString();
|
||||
Assertions.assertNotNull(output);
|
||||
Assertions.assertTrue(output.length()>0);
|
||||
Assertions.assertTrue(output.length() > 0);
|
||||
Assertions.assertTrue(output.equals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><![CDATA[tokens like \']]>\' are <valid>]]>"));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ public class SAX3WriterXmlTest {
|
|||
}
|
||||
String output = outputWriter.toString();
|
||||
Assertions.assertNotNull(output);
|
||||
Assertions.assertTrue(output.length()>0);
|
||||
Assertions.assertTrue(output.length() > 0);
|
||||
Assertions.assertTrue(output.equals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>test is foobar!"), output);
|
||||
}
|
||||
|
||||
|
|
@ -62,7 +62,7 @@ public class SAX3WriterXmlTest {
|
|||
}
|
||||
String output = outputWriter.toString();
|
||||
Assertions.assertNotNull(output);
|
||||
Assertions.assertTrue(output.length()>0);
|
||||
Assertions.assertTrue(output.length() > 0);
|
||||
Assertions.assertTrue(output.equals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><test/> & 'foobar' is "quoted"!"), output);
|
||||
}
|
||||
|
||||
|
|
@ -76,7 +76,7 @@ public class SAX3WriterXmlTest {
|
|||
}
|
||||
String output = outputWriter.toString();
|
||||
Assertions.assertNotNull(output);
|
||||
Assertions.assertTrue(output.length()>0);
|
||||
Assertions.assertTrue(output.length() > 0);
|
||||
Assertions.assertTrue(output.equals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!-- foobar -->"), output);
|
||||
}
|
||||
|
||||
|
|
@ -96,7 +96,7 @@ public class SAX3WriterXmlTest {
|
|||
|
||||
String output = outputWriter.toString();
|
||||
Assertions.assertNotNull(output);
|
||||
Assertions.assertTrue(output.length()>0);
|
||||
Assertions.assertTrue(output.length() > 0);
|
||||
Assertions.assertTrue(output.equals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!-- foobar -->"), output);
|
||||
}
|
||||
|
||||
|
|
@ -147,7 +147,7 @@ public class SAX3WriterXmlTest {
|
|||
}
|
||||
String output = outputWriter.toString();
|
||||
Assertions.assertNotNull(output);
|
||||
Assertions.assertTrue(output.length()>0);
|
||||
Assertions.assertTrue(output.length() > 0);
|
||||
Assertions.assertTrue(output.equals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<?target data?>\n<test/>"), output);
|
||||
}
|
||||
|
||||
|
|
@ -165,8 +165,9 @@ public class SAX3WriterXmlTest {
|
|||
}
|
||||
String output = outputWriter.toString();
|
||||
Assertions.assertNotNull(output);
|
||||
Assertions.assertTrue(output.length()>0);
|
||||
Assertions.assertTrue(output.equals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<?target data?>\n<test>\n\t<?target-doc data-doc?>\n</test>\n"), output);
|
||||
Assertions.assertTrue(output.length() > 0);
|
||||
Assertions.assertTrue(output.equals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<?target data?>\n<test>\n\t<?target-doc data-doc?>\n</test>\n"),
|
||||
output);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -202,7 +203,7 @@ public class SAX3WriterXmlTest {
|
|||
try (SAX3WriterXml writer = new SAX3WriterXml(outputWriter)) {
|
||||
SAXException e = Assertions.assertThrows(SAXException.class, () -> {
|
||||
writer.startDocument();
|
||||
writer.processingInstruction("target", "isInvalidChar="+0xD800);
|
||||
writer.processingInstruction("target", "isInvalidChar=" + 0xD800);
|
||||
});
|
||||
Assertions.assertTrue(e.getMessage().contains("instruction"));
|
||||
Assertions.assertTrue(e.getMessage().contains("invalid char"));
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ public class XDBXReaderXmlTest {
|
|||
try (XDBXWriterXml writer = new XDBXWriterXml(baos)) {
|
||||
writer.startDocument();
|
||||
AttributesImpl atts = new AttributesImpl();
|
||||
atts.addAttribute ("", "attr", "", "", "foobar");
|
||||
atts.addAttribute("", "attr", "", "", "foobar");
|
||||
writer.startElementEnd("", "test", "", atts);
|
||||
writer.endDocument();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ public class XDBXWriterXmlTest {
|
|||
writer.startElement("", "root", "", new AttributesImpl());
|
||||
|
||||
AttributesImpl atts = new AttributesImpl();
|
||||
atts.addAttribute ("", "mgr", "", "", "NO");
|
||||
atts.addAttribute("", "mgr", "", "", "NO");
|
||||
writer.startElement("", "name", "", atts);
|
||||
writer.characters("Joe");
|
||||
writer.endElement("", "name", "");
|
||||
|
|
@ -69,74 +69,73 @@ public class XDBXWriterXmlTest {
|
|||
int outIdx = 8;
|
||||
Assertions.assertNotNull(output);
|
||||
Assertions.assertTrue(output.length > 0);
|
||||
Assertions.assertEquals((byte)'X', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'X', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 4, output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'r', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'o', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'o', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'t', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'r', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'o', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'o', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 't', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 1, output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 0, output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 0, output[outIdx++]);
|
||||
|
||||
Assertions.assertEquals((byte)'X', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'X', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 4, output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'n', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'a', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'m', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'e', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'n', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'a', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'm', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'e', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 2, output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 0, output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 0, output[outIdx++]);
|
||||
|
||||
Assertions.assertEquals((byte)'Y', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'Y', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 3, output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'m', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'g', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'r', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'm', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'g', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'r', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 3, output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 0, output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 0, output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 2, output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'N', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'O', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'T', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'N', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'O', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'T', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 3, output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'J', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'o', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'e', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'J', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'o', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'e', output[outIdx++]);
|
||||
|
||||
Assertions.assertEquals((byte)'z', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'e', output[outIdx++]); // IBM SPEC example FAIL: 'x' is for WITH namespace
|
||||
Assertions.assertEquals((byte) 'z', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'e', output[outIdx++]); // IBM SPEC example FAIL: 'x' is for WITH namespace
|
||||
Assertions.assertEquals((byte) 2, output[outIdx++]);
|
||||
//Assertions.assertEquals((byte) 0, output[outIdx++]); // IBM SPEC example FAIL: 'x' is for WITH namespace
|
||||
//Assertions.assertEquals((byte) 0, output[outIdx++]); // IBM SPEC example FAIL: 'x' is for WITH namespace
|
||||
Assertions.assertEquals((byte)'T', output[outIdx++]);
|
||||
// Assertions.assertEquals((byte) 0, output[outIdx++]); // IBM SPEC example FAIL: 'x' is for WITH namespace
|
||||
// Assertions.assertEquals((byte) 0, output[outIdx++]); // IBM SPEC example FAIL: 'x' is for WITH namespace
|
||||
Assertions.assertEquals((byte) 'T', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 5, output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'S', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'u', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'s', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'a', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'n', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'S', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'u', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 's', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'a', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'n', output[outIdx++]);
|
||||
|
||||
Assertions.assertEquals((byte)'z', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'e', output[outIdx++]); // IBM SPEC example FAIL: 'x' is for WITH namespace
|
||||
Assertions.assertEquals((byte) 'z', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'e', output[outIdx++]); // IBM SPEC example FAIL: 'x' is for WITH namespace
|
||||
Assertions.assertEquals((byte) 2, output[outIdx++]);
|
||||
//Assertions.assertEquals((byte) 0, output[outIdx++]); // IBM SPEC example FAIL: 'x' is for WITH namespace
|
||||
//Assertions.assertEquals((byte) 0, output[outIdx++]); // IBM SPEC example FAIL: 'x' is for WITH namespace
|
||||
Assertions.assertEquals((byte)'T', output[outIdx++]);
|
||||
// Assertions.assertEquals((byte) 0, output[outIdx++]); // IBM SPEC example FAIL: 'x' is for WITH namespace
|
||||
// Assertions.assertEquals((byte) 0, output[outIdx++]); // IBM SPEC example FAIL: 'x' is for WITH namespace
|
||||
Assertions.assertEquals((byte) 'T', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 4, output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'B', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'i', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'l', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'l', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'B', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'i', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'l', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'l', output[outIdx++]);
|
||||
|
||||
Assertions.assertEquals((byte)'z', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'z', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'Z', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'z', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'z', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'Z', output[outIdx++]);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testExample3StringIds() throws Exception {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
|
|
@ -150,7 +149,7 @@ public class XDBXWriterXmlTest {
|
|||
|
||||
writer.startElement("", "Person", "", new AttributesImpl());
|
||||
atts = new AttributesImpl();
|
||||
atts.addAttribute ("", "mgr", "", "", "NO");
|
||||
atts.addAttribute("", "mgr", "", "", "NO");
|
||||
writer.startElement("", "name", "", atts);
|
||||
writer.characters("Bill");
|
||||
writer.endElement("", "name", "");
|
||||
|
|
@ -161,7 +160,7 @@ public class XDBXWriterXmlTest {
|
|||
|
||||
writer.startElement("", "Person", "", new AttributesImpl());
|
||||
atts = new AttributesImpl();
|
||||
atts.addAttribute ("", "mgr", "", "", "NO");
|
||||
atts.addAttribute("", "mgr", "", "", "NO");
|
||||
writer.startElement("", "name", "", atts);
|
||||
writer.characters("Joe");
|
||||
writer.endElement("", "name", "");
|
||||
|
|
@ -178,118 +177,118 @@ public class XDBXWriterXmlTest {
|
|||
int outIdx = 8;
|
||||
Assertions.assertNotNull(output);
|
||||
Assertions.assertTrue(output.length > 0);
|
||||
Assertions.assertEquals((byte)'I', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'I', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 3, output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'f', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'o', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'o', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'f', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'o', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'o', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 1, output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'I', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'I', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 3, output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'b', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'a', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'r', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'b', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'a', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'r', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 2, output[outIdx++]);
|
||||
|
||||
Assertions.assertEquals((char)'X', (char)output[outIdx++]);
|
||||
Assertions.assertEquals((char) 'X', (char) output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 4, output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'r', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'o', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'o', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'t', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'r', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'o', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'o', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 't', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 3, output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 0, output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 0, output[outIdx++]);
|
||||
Assertions.assertEquals((char)'m', (char)output[outIdx++]);
|
||||
Assertions.assertEquals((char) 'm', (char) output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 1, output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 2, output[outIdx++]);
|
||||
|
||||
Assertions.assertEquals((char)'X', (char)output[outIdx++]);
|
||||
Assertions.assertEquals((char) 'X', (char) output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 6, output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'P', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'e', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'r', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'s', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'o', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'n', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'P', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'e', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'r', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 's', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'o', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'n', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 4, output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 0, output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 0, output[outIdx++]);
|
||||
|
||||
Assertions.assertEquals((char)'X', (char)output[outIdx++]);
|
||||
Assertions.assertEquals((char) 'X', (char) output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 4, output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'n', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'a', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'m', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'e', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'n', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'a', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'm', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'e', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 5, output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 0, output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 0, output[outIdx++]);
|
||||
|
||||
Assertions.assertEquals((char)'Y', (char)output[outIdx++]);
|
||||
Assertions.assertEquals((char) 'Y', (char) output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 3, output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'m', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'g', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'r', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'm', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'g', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'r', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 6, output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 0, output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 0, output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 2, output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'N', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'O', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'N', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'O', output[outIdx++]);
|
||||
|
||||
Assertions.assertEquals((byte)'T', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'T', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 4, output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'B', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'i', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'l', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'l', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'z', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'B', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'i', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'l', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'l', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'z', output[outIdx++]);
|
||||
|
||||
Assertions.assertEquals((char)'X', (char)output[outIdx++]);
|
||||
Assertions.assertEquals((char) 'X', (char) output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 3, output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'a', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'g', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'e', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'a', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'g', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'e', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 7, output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 1, output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 2, output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'T', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 2, output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'3', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'5', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'z', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'z', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'e', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) '3', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) '5', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'z', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'z', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'e', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 4, output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'e', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'e', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 5, output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'a', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'a', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 6, output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 2, output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'N', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'O', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'N', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'O', output[outIdx++]);
|
||||
|
||||
Assertions.assertEquals((byte)'T', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'T', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 3, output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'J', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'o', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'e', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'z', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'x', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'J', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'o', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'e', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'z', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'x', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 7, output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 1, output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 2, output[outIdx++]);
|
||||
|
||||
Assertions.assertEquals((byte)'T', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'T', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 2, output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'4', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'5', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) '4', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) '5', output[outIdx++]);
|
||||
|
||||
Assertions.assertEquals((byte)'z', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'z', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'z', output[outIdx++]);
|
||||
Assertions.assertEquals((byte)'Z', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'z', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'z', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'z', output[outIdx++]);
|
||||
Assertions.assertEquals((byte) 'Z', output[outIdx++]);
|
||||
|
||||
StringWriter outputXmlStr = new StringWriter();
|
||||
SAX3WriterXml outputXml = new SAX3WriterXml(outputXmlStr);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue