removed jettison

This commit is contained in:
Willem 2016-10-24 17:54:34 +02:00
parent 8bb27c09c6
commit f2b7f4c6d5
2 changed files with 0 additions and 76 deletions

View file

@ -18,11 +18,5 @@
<artifactId>commons-lang3</artifactId> <artifactId>commons-lang3</artifactId>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>org.codehaus.jettison</groupId>
<artifactId>jettison</artifactId>
<version>1.3.7</version>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>

View file

@ -35,9 +35,6 @@ import java.util.Map;
import javax.xml.stream.XMLStreamWriter; import javax.xml.stream.XMLStreamWriter;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.codehaus.jettison.mapped.Configuration;
import org.codehaus.jettison.mapped.MappedNamespaceConvention;
import org.codehaus.jettison.mapped.MappedXMLStreamWriter;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
@ -105,72 +102,5 @@ public class UnitXCConverterStepTest {
para.put("speed_time", new UnitXConverterParameterValue(2, unitManager.getUnitType("minute"))); para.put("speed_time", new UnitXConverterParameterValue(2, unitManager.getUnitType("minute")));
result = unitManager.getConverter().convertStepped(50, "km/h", "mm",para); result = unitManager.getConverter().convertStepped(50, "km/h", "mm",para);
System.out.println("CONVERT-RESULT: "+result); System.out.println("CONVERT-RESULT: "+result);
Configuration config = new Configuration();
MappedNamespaceConvention con = new MappedNamespaceConvention(config);
Writer writer = new OutputStreamWriter(System.out);
XMLStreamWriter xmlStreamWriter = new MappedXMLStreamWriter(con, new IndentedJSONWriter(writer));
//jaxbDriver.getUnitXConverterResult().marshal(result, xmlStreamWriter);
}
class IndentedJSONWriter extends Writer {
private final Writer writer;
private int depth = 0;
private boolean firstLine = true;
public IndentedJSONWriter(Writer writer) {
this.writer = writer;
}
private void writeLineWrap() throws IOException {
writer.write(StringUtils.LF);
writer.write(StringUtils.repeat(StringUtils.SPACE, depth));
}
@Override
public void write(int c) throws IOException {
if (c == '{') {
if (!firstLine) {
writer.write(StringUtils.SPACE);
}
writer.write(c);
depth++;
writeLineWrap();
} else if (c == '}') {
writer.write(c);
depth--;
writeLineWrap();
} else if (c == ',') {
writer.write(c);
writeLineWrap();
} else if (c == '[') {
writer.write(StringUtils.SPACE);
writer.write(c);
writeLineWrap();
} else {
writer.write(c);
}
firstLine = false;
}
@Override
public void write(char[] cbuf, int off, int len) throws IOException {
writer.write(cbuf, off, len);
}
@Override
public void flush() throws IOException {
writer.flush();
}
@Override
public void close() throws IOException {
writer.close();
}
} }
} }