removed jettison
This commit is contained in:
parent
8bb27c09c6
commit
f2b7f4c6d5
|
@ -18,11 +18,5 @@
|
|||
<artifactId>commons-lang3</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.jettison</groupId>
|
||||
<artifactId>jettison</artifactId>
|
||||
<version>1.3.7</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -35,9 +35,6 @@ import java.util.Map;
|
|||
import javax.xml.stream.XMLStreamWriter;
|
||||
|
||||
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 static org.junit.Assert.assertFalse;
|
||||
|
@ -105,72 +102,5 @@ public class UnitXCConverterStepTest {
|
|||
para.put("speed_time", new UnitXConverterParameterValue(2, unitManager.getUnitType("minute")));
|
||||
result = unitManager.getConverter().convertStepped(50, "km/h", "mm",para);
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue