use of com.thoughtworks.xstream.io.xml.XppReader in project intellij-community by JetBrains.
the class ProtocolParser method parseReferrers.
@NotNull
public static List<PyDebugValue> parseReferrers(final String text, final PyFrameAccessor frameAccessor) throws PyDebuggerException {
final List<PyDebugValue> values = new LinkedList<>();
final XppReader reader = openReader(text, false);
while (reader.hasMoreChildren()) {
reader.moveDown();
if (reader.getNodeName().equals("var")) {
PyDebugValue value = parseValue(reader, frameAccessor);
value.setId(readString(reader, "id", null));
values.add(value);
} else if (reader.getNodeName().equals("for")) {
//TODO
} else {
throw new PyDebuggerException("Expected <var> or <for>, found " + reader.getNodeName());
}
reader.moveUp();
}
return values;
}
use of com.thoughtworks.xstream.io.xml.XppReader in project intellij-community by JetBrains.
the class ProtocolParser method parseValues.
@NotNull
public static List<PyDebugValue> parseValues(final String text, final PyFrameAccessor frameAccessor) throws PyDebuggerException {
final List<PyDebugValue> values = new LinkedList<>();
final XppReader reader = openReader(text, false);
while (reader.hasMoreChildren()) {
reader.moveDown();
values.add(parseValue(reader, frameAccessor));
reader.moveUp();
}
return values;
}
use of com.thoughtworks.xstream.io.xml.XppReader in project intellij-community by JetBrains.
the class ProtocolParser method parseIo.
public static PyIo parseIo(final String text) throws PyDebuggerException {
final XppReader reader = openReader(text, true);
reader.moveDown();
if (!"io".equals(reader.getNodeName())) {
throw new PyDebuggerException("Expected <io>, found " + reader.getNodeName());
}
final String s = readString(reader, "s", "");
final int ctx = readInt(reader, "ctx", 1);
return new PyIo(s, ctx);
}
use of com.thoughtworks.xstream.io.xml.XppReader in project intellij-community by JetBrains.
the class ProtocolParser method parseArrayValues.
public static ArrayChunk parseArrayValues(final String text, final PyFrameAccessor frameAccessor) throws PyDebuggerException {
final XppReader reader = openReader(text, false);
ArrayChunkBuilder result = new ArrayChunkBuilder();
if (reader.hasMoreChildren()) {
reader.moveDown();
if (!"array".equals(reader.getNodeName())) {
throw new PyDebuggerException("Expected <array> at first node, found " + reader.getNodeName());
}
String slice = readString(reader, "slice", null);
result.setSlicePresentation(slice);
result.setRows(readInt(reader, "rows", null));
result.setColumns(readInt(reader, "cols", null));
result.setFormat("%" + readString(reader, "format", null));
result.setType(readString(reader, "type", null));
result.setMax(readString(reader, "max", null));
result.setMin(readString(reader, "min", null));
result.setValue(new PyDebugValue(slice, null, null, null, false, false, false, false, frameAccessor));
reader.moveUp();
}
if ("headerdata".equals(reader.peekNextChild())) {
parseArrayHeaderData(reader, result);
}
Object[][] data = parseArrayValues(reader, frameAccessor);
result.setData(data);
return result.createArrayChunk();
}
use of com.thoughtworks.xstream.io.xml.XppReader in project ddf by codice.
the class TestCswTransformProvider method testUnmarshalOtherSchema.
@Test
public void testUnmarshalOtherSchema() throws Exception {
InputTransformer mockInputTransformer = mock(InputTransformer.class);
when(mockInputManager.getTransformerByProperty(TransformerManager.SCHEMA, OTHER_SCHEMA)).thenReturn(mockInputTransformer);
when(mockInputTransformer.transform(any(InputStream.class))).thenReturn(getMetacard());
// XppReader is not namespace aware so it will read the XML and ignore the namespaces
// WstxReader is namespace aware. It may fail for XML fragments.
HierarchicalStreamReader reader = new XppReader(new StringReader(getRecord()), XmlPullParserFactory.newInstance().newPullParser());
CswTransformProvider provider = new CswTransformProvider(null, mockInputManager);
UnmarshallingContext context = new TreeUnmarshaller(null, null, null, null);
context.put(CswConstants.TRANSFORMER_LOOKUP_KEY, TransformerManager.SCHEMA);
context.put(CswConstants.TRANSFORMER_LOOKUP_VALUE, OTHER_SCHEMA);
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
provider.unmarshal(reader, context);
// Verify the context arguments were set correctly
verify(mockInputManager, times(1)).getTransformerByProperty(captor.capture(), captor.capture());
String outputSchema = captor.getValue();
assertThat(outputSchema, is(OTHER_SCHEMA));
}
Aggregations