Skip to content
Commits on Source (6)
jackson-dataformat-xml (2.9.8-1) unstable; urgency=medium
* New upstream version 2.9.8
* Change homepage to github address.
-- Markus Koschany <apo@debian.org> Wed, 19 Dec 2018 10:53:03 +0100
jackson-dataformat-xml (2.9.7-2) unstable; urgency=medium
* Fix FTBFS by changing the jaxb api version to debian in
......
......@@ -28,7 +28,7 @@ Build-Depends:
Standards-Version: 4.2.1
Vcs-Git: https://anonscm.debian.org/git/pkg-java/jackson-dataformat-xml.git
Vcs-Browser: https://anonscm.debian.org/cgit/pkg-java/jackson-dataformat-xml.git
Homepage: http://wiki.fasterxml.com/JacksonExtensionXmlDataBinding
Homepage: https://github.com/FasterXML/jackson-dataformat-xml
Package: libjackson2-dataformat-xml-java
Architecture: all
......
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: Jackson-dataformat-XML
Source: http://wiki.fasterxml.com/JacksonExtensionXmlDataBinding
Source: https://github.com/FasterXML/jackson-dataformat-xml
Files-Excluded:
docs/*
......
From: Markus Koschany <apo@debian.org>
Date: Tue, 2 Oct 2018 18:54:25 +0200
Subject: jackson-base-version
Date: Wed, 19 Dec 2018 10:55:37 +0100
Subject: jackson base version
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 605c61e..7e8de1d 100644
index b72dfa1..3264169 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
<parent>
<groupId>com.fasterxml.jackson</groupId>
<artifactId>jackson-base</artifactId>
- <version>2.9.7</version>
- <version>2.9.8</version>
+ <version>debian</version>
</parent>
<groupId>com.fasterxml.jackson.dataformat</groupId>
......
......@@ -10,10 +10,10 @@ Bug-Debian: https://bugs.debian.org/906368
1 file changed, 14 insertions(+)
diff --git a/pom.xml b/pom.xml
index 181a0ae..605c61e 100644
index 1b6a698..b72dfa1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -116,6 +116,20 @@ Some data-binding types overridden as well (ObjectMapper sub-classed as XmlMappe
@@ -128,6 +128,20 @@ Some data-binding types overridden as well (ObjectMapper sub-classed as XmlMappe
</execution>
</executions>
</plugin>
......
......@@ -4,11 +4,11 @@
<parent>
<groupId>com.fasterxml.jackson</groupId>
<artifactId>jackson-base</artifactId>
<version>2.9.7</version>
<version>2.9.8</version>
</parent>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
<version>2.9.7</version>
<version>2.9.8</version>
<name>Jackson-dataformat-XML</name>
<packaging>bundle</packaging>
<description>Data format extension for Jackson (http://jackson.codehaus.org) to offer
......@@ -21,7 +21,7 @@ Some data-binding types overridden as well (ObjectMapper sub-classed as XmlMappe
<connection>scm:git:git@github.com:FasterXML/jackson-dataformat-xml.git</connection>
<developerConnection>scm:git:git@github.com:FasterXML/jackson-dataformat-xml.git</developerConnection>
<url>http://github.com/FasterXML/jackson-dataformat-xml</url>
<tag>jackson-dataformat-xml-2.9.7</tag>
<tag>jackson-dataformat-xml-2.9.8</tag>
</scm>
<properties>
<packageVersion.dir>com/fasterxml/jackson/dataformat/xml</packageVersion.dir>
......@@ -103,6 +103,18 @@ Some data-binding types overridden as well (ObjectMapper sub-classed as XmlMappe
</dependency>
</dependencies>
<!-- Alas, need to include snapshot reference since otherwise can not find
snapshot of parent... -->
<repositories>
<repository>
<id>sonatype-nexus-snapshots</id>
<name>Sonatype Nexus Snapshots</name>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<releases><enabled>false</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<build>
<plugins>
<plugin>
......@@ -134,16 +146,4 @@ Some data-binding types overridden as well (ObjectMapper sub-classed as XmlMappe
</plugins>
</build>
<profiles>
<!-- 19-Feb-2012, tatu: Since we have some failing tests, may need to force release -->
<profile>
<id>force-release</id>
<properties>
<maven.test.skip>true</maven.test.skip>
<skipTests>true</skipTests>
</properties>
</profile>
</profiles>
<!-- NOTE: repositories from parent POM -->
</project>
......@@ -4,6 +4,13 @@ Project: jackson-dataformat-xml
= Releases
------------------------------------------------------------------------
2.9.8 (15-Dec-2018)
#270: Add support for `writeBinary()` with `InputStream` to `ToXMLGenerator`
(requested by csbxvs@github; contributed by marc-christian-schulze@github)
#323: Replace slow string concatenation with faster `StringBuilder` (for
long text content)
2.9.7 (19-Sep-2018)
No changes since 2.9.6
......
......@@ -377,11 +377,11 @@ public class XmlTokenStream
return "";
}
String text = null;
CharSequence chars = null;
while (true) {
switch (_xmlReader.next()) {
case XMLStreamConstants.START_ELEMENT:
return (text == null) ? "" : text;
return (chars == null) ? "" : chars.toString();
case XMLStreamConstants.END_ELEMENT:
case XMLStreamConstants.END_DOCUMENT:
......@@ -389,15 +389,15 @@ public class XmlTokenStream
// as `null`, by below, but that breaks existing tests so not
// done at least until 3.0.
/*
if (text == null) {
if (chars == null) {
if (FromXmlParser.Feature.EMPTY_ELEMENT_AS_NULL.enabledIn(_formatFeatures)) {
return null;
}
return "";
}
return text;
return chars;
*/
return (text == null) ? "" : text;
return (chars == null) ? "" : chars.toString();
// note: SPACE is ignorable (and seldom seen), not to be included
case XMLStreamConstants.CHARACTERS:
......@@ -405,10 +405,13 @@ public class XmlTokenStream
// 17-Jul-2017, tatu: as per [dataformat-xml#236], need to try to...
{
String str = _getText(_xmlReader);
if (text == null) {
text = str;
if (chars == null) {
chars = str;
} else {
text += str;
if (chars instanceof String) {
chars = new StringBuilder(chars);
}
((StringBuilder)chars).append(str);
}
}
break;
......
......@@ -840,6 +840,69 @@ public final class ToXmlGenerator
}
}
@Override
public int writeBinary(Base64Variant b64variant, InputStream data, int dataLength) throws IOException
{
if (data == null) {
writeNull();
return 0;
}
_verifyValueWrite("write Binary value");
if (_nextName == null) {
handleMissingName();
}
try {
if (_nextIsAttribute) {
// Stax2 API only has 'full buffer' write method:
byte[] fullBuffer = toFullBuffer(data, dataLength);
_xmlWriter.writeBinaryAttribute("", _nextName.getNamespaceURI(), _nextName.getLocalPart(), fullBuffer);
} else if (checkNextIsUnwrapped()) {
// should we consider pretty-printing or not?
writeStreamAsBinary(data, dataLength);
} else {
if (_xmlPrettyPrinter != null) {
_xmlPrettyPrinter.writeLeafElement(_xmlWriter,
_nextName.getNamespaceURI(), _nextName.getLocalPart(),
toFullBuffer(data, dataLength), 0, dataLength);
} else {
_xmlWriter.writeStartElement(_nextName.getNamespaceURI(), _nextName.getLocalPart());
writeStreamAsBinary(data, dataLength);
_xmlWriter.writeEndElement();
}
}
} catch (XMLStreamException e) {
StaxUtil.throwAsGenerationException(e, this);
}
return dataLength;
}
private void writeStreamAsBinary(InputStream data, int len) throws IOException, XMLStreamException
{
// base64 encodes up to 3 bytes into a 4 bytes string
byte[] tmp = new byte[3];
int offset = 0;
int read;
while((read = data.read(tmp, offset, Math.min(3 - offset, len))) != -1) {
offset += read;
len -= read;
if(offset == 3) {
offset = 0;
_xmlWriter.writeBinary(tmp, 0, 3);
}
if (len == 0) {
break;
}
}
// we still have < 3 bytes in the buffer
if(offset > 0) {
_xmlWriter.writeBinary(tmp, 0, offset);
}
}
private byte[] toFullBuffer(byte[] data, int offset, int len)
{
// might already be ok:
......@@ -853,6 +916,21 @@ public final class ToXmlGenerator
return result;
}
private byte[] toFullBuffer(InputStream data, final int len) throws IOException
{
byte[] result = new byte[len];
int offset = 0;
for (; offset < len; ) {
int count = data.read(result, offset, len - offset);
if (count < 0) {
_reportError("Too few bytes available: missing "+(len - offset)+" bytes (out of "+len+")");
}
offset += count;
}
return result;
}
/*
/**********************************************************
/* Output method implementations, primitive
......
package com.fasterxml.jackson.dataformat.xml.deser.builder;
import java.util.*;
import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.core.Version;
......
......@@ -2,7 +2,6 @@ package com.fasterxml.jackson.dataformat.xml.failing;
import java.util.*;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
......
package com.fasterxml.jackson.dataformat.xml.ser;
import java.nio.*;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
/**
* See <a href="https://github.com/FasterXML/jackson-dataformat-xml/issues/270">issue #270</a>
* for details
*/
public class TestBinaryStreamToXMLSerialization extends XmlTestBase
{
private final XmlMapper MAPPER = new XmlMapper();
public void testWith0Bytes() throws Exception
{
String xml = MAPPER.writeValueAsString(createPojo());
assertEquals("<TestPojo><field/></TestPojo>", xml);
}
public void testWith1Byte() throws Exception
{
String xml = MAPPER.writeValueAsString(createPojo( 'A' ));
assertEquals("<TestPojo><field>QQ==</field></TestPojo>", xml);
}
public void testWith2Bytes() throws Exception
{
String xml = MAPPER.writeValueAsString(createPojo( 'A', 'B' ));
assertEquals("<TestPojo><field>QUI=</field></TestPojo>", xml);
}
public void testWith3Bytes() throws Exception
{
String xml = MAPPER.writeValueAsString(createPojo( 'A', 'B', 'C' ));
assertEquals("<TestPojo><field>QUJD</field></TestPojo>", xml);
}
public void testWith4Bytes() throws Exception
{
String xml = MAPPER.writeValueAsString(createPojo( 'A', 'B', 'C', 'D' ));
assertEquals("<TestPojo><field>QUJDRA==</field></TestPojo>", xml);
}
private TestPojo createPojo(char... content) {
TestPojo obj = new TestPojo();
// DirectByteBuffer does not have an underlying array
// so the ByteArraySerializer has to fallback to stream writing
obj.field = ByteBuffer.allocateDirect(content.length);
for(char b : content) {
obj.field.put((byte) b);
}
obj.field.position(0);
return obj;
}
public static class TestPojo {
public ByteBuffer field;
}
}