本文整理汇总了Java中com.thoughtworks.xstream.io.xml.XppReader类的典型用法代码示例。如果您正苦于以下问题:Java XppReader类的具体用法?Java XppReader怎么用?Java XppReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XppReader类属于com.thoughtworks.xstream.io.xml包,在下文中一共展示了XppReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseCallSignature
import com.thoughtworks.xstream.io.xml.XppReader; //导入依赖的package包/类
public static PySignature parseCallSignature(String payload) throws PyDebuggerException {
final XppReader reader = openReader(payload, true);
reader.moveDown();
if (!"call_signature".equals(reader.getNodeName())) {
throw new PyDebuggerException("Expected <call_signature>, found " + reader.getNodeName());
}
final String file = readString(reader, "file", "");
final String name = readString(reader, "name", "");
PySignature signature = new PySignature(file, name);
while (reader.hasMoreChildren()) {
reader.moveDown();
if (!"arg".equals(reader.getNodeName())) {
throw new PyDebuggerException("Expected <arg>, found " + reader.getNodeName());
}
signature.addArgument(readString(reader, "name", ""), readString(reader, "type", ""));
reader.moveUp();
}
return signature;
}
示例2: parseThread
import com.thoughtworks.xstream.io.xml.XppReader; //导入依赖的package包/类
@NotNull
public static PyThreadInfo parseThread(final String text, final PyPositionConverter positionConverter) throws PyDebuggerException {
final XppReader reader = openReader(text, true);
reader.moveDown();
if (!"thread".equals(reader.getNodeName())) {
throw new PyDebuggerException("Expected <thread>, found " + reader.getNodeName());
}
final String id = readString(reader, "id", null);
final String name = readString(reader, "name", "");
final int stopReason = readInt(reader, "stop_reason", 0);
String message = readString(reader, "message", "None");
if ("None".equals(message)) {
message = null;
}
final List<PyStackFrameInfo> frames = new LinkedList<PyStackFrameInfo>();
while (reader.hasMoreChildren()) {
reader.moveDown();
frames.add(parseFrame(reader, id, positionConverter));
reader.moveUp();
}
return new PyThreadInfo(id, name, frames, stopReason, message);
}
示例3: parseReferrers
import com.thoughtworks.xstream.io.xml.XppReader; //导入依赖的package包/类
@NotNull
public static List<PyDebugValue> parseReferrers(final String text, final PyFrameAccessor frameAccessor) throws PyDebuggerException {
final List<PyDebugValue> values = new LinkedList<PyDebugValue>();
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;
}
示例4: parseValue
import com.thoughtworks.xstream.io.xml.XppReader; //导入依赖的package包/类
private static PyDebugValue parseValue(final XppReader reader, PyFrameAccessor frameAccessor) throws PyDebuggerException {
if (!"var".equals(reader.getNodeName())) {
throw new PyDebuggerException("Expected <var>, found " + reader.getNodeName());
}
final String name = readString(reader, "name", null);
final String type = readString(reader, "type", null);
String value = readString(reader, "value", null);
final String isContainer = readString(reader, "isContainer", "");
final String isErrorOnEval = readString(reader, "isErrorOnEval", "");
if (value.startsWith(type + ": ")) { // drop unneeded prefix
value = value.substring(type.length() + 2);
}
return new PyDebugValue(name, type, value, "True".equals(isContainer), "True".equals(isErrorOnEval), frameAccessor);
}
示例5: parseArrayValues
import com.thoughtworks.xstream.io.xml.XppReader; //导入依赖的package包/类
public static ArrayChunk parseArrayValues(final String text, final PyFrameAccessor frameAccessor) throws PyDebuggerException {
final XppReader reader = openReader(text, false);
ArrayChunk result = null;
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);
int rows = readInt(reader, "rows", null);
int cols = readInt(reader, "cols", null);
String format = "%" + readString(reader, "format", null);
String type = readString(reader, "type", null);
String max = readString(reader, "max", null);
String min = readString(reader, "min", null);
result =
new ArrayChunk(new PyDebugValue(slice, null, null, false, false, frameAccessor), slice, rows, cols, max, min, format, type, null);
reader.moveUp();
}
Object[][] data = parseArrayValues(reader, frameAccessor);
return new ArrayChunk(result.getValue(), result.getSlicePresentation(), result.getRows(), result.getColumns(), result.getMax(),
result.getMin(), result.getFormat(), result.getType(), data);
}
示例6: testPathsAreDecodedInTracker
import com.thoughtworks.xstream.io.xml.XppReader; //导入依赖的package包/类
public void testPathsAreDecodedInTracker() {
Reader input = new StringReader("" +
"<a>" +
" <b__1/>" +
"</a>");
HierarchicalStreamReader reader = new XppReader(input, new MXParser());
PathTracker pathTracker = new PathTracker();
reader = new PathTrackingReader(reader, pathTracker);
assertEquals(new Path("/a"), pathTracker.getPath());
reader.moveDown();
assertEquals(new Path("/a/b_1"), pathTracker.getPath());
assertEquals("b_1", pathTracker.peekElement());
reader.moveUp();
assertEquals(new Path("/a"), pathTracker.getPath());
}
示例7: createReader
import com.thoughtworks.xstream.io.xml.XppReader; //导入依赖的package包/类
/**
* Creates a {@link HierarchicalStreamReader} using the given inputMessage.
*
* @param inputMessage
* The {@link HttpInputMessage} to create the reader from.
* @return A Fully constructed {@link HierarchicalStreamReader}.
* @throws IllegalStateException
* Thrown if errors occur during the creation of the
* {@link HierarchicalStreamReader}.
* @since 1.0.0
*/
public static HierarchicalStreamReader createReader(final HttpInputMessage inputMessage) {
XmlPullParserFactory factory;
try {
factory = XmlPullParserFactory.newInstance();
final XppReader reader = new XppReader(new InputStreamReader(inputMessage.getBody()),
factory.newPullParser(), new NoNameCoder());
return new PathTrackingReader(reader, new PathTracker());
} catch (XmlPullParserException | IOException e) {
LOGGER.error("Marshalling failure; unable to create stream reader to process HTTP response");
}
throw new IllegalStateException("Unable to create HierarchicalStreamReader");
}
示例8: createReader
import com.thoughtworks.xstream.io.xml.XppReader; //导入依赖的package包/类
private HierarchicalStreamReader createReader(final Reader reader) {
XmlPullParserFactory factory;
try {
factory = XmlPullParserFactory.newInstance();
return new XppReader(reader, factory.newPullParser(), new NoNameCoder());
} catch (final XmlPullParserException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
throw new IllegalStateException("Unable to create HierarchicalStreamReader");
}
示例9: parseProfileName
import com.thoughtworks.xstream.io.xml.XppReader; //导入依赖的package包/类
@Nullable
public static String parseProfileName(String descriptors) {
final XppReader reader = new XppReader(new StringReader(descriptors));
try {
return reader.getAttribute(InspectionApplication.PROFILE);
}
catch (Exception e) {
return null;
}
finally {
reader.close();
}
}
示例10: parseIo
import com.thoughtworks.xstream.io.xml.XppReader; //导入依赖的package包/类
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);
}
示例11: parseFrame
import com.thoughtworks.xstream.io.xml.XppReader; //导入依赖的package包/类
private static PyStackFrameInfo parseFrame(final XppReader reader, final String threadId, final PyPositionConverter positionConverter)
throws PyDebuggerException {
if (!"frame".equals(reader.getNodeName())) {
throw new PyDebuggerException("Expected <frame>, found " + reader.getNodeName());
}
final String id = readString(reader, "id", null);
final String name = readString(reader, "name", null);
final String file = readString(reader, "file", null);
final int line = readInt(reader, "line", 0);
return new PyStackFrameInfo(threadId, id, name, positionConverter.create(file, line));
}
示例12: parseValues
import com.thoughtworks.xstream.io.xml.XppReader; //导入依赖的package包/类
@NotNull
public static List<PyDebugValue> parseValues(final String text, final PyFrameAccessor frameAccessor) throws PyDebuggerException {
final List<PyDebugValue> values = new LinkedList<PyDebugValue>();
final XppReader reader = openReader(text, false);
while (reader.hasMoreChildren()) {
reader.moveDown();
values.add(parseValue(reader, frameAccessor));
reader.moveUp();
}
return values;
}
示例13: openReader
import com.thoughtworks.xstream.io.xml.XppReader; //导入依赖的package包/类
private static XppReader openReader(final String text, final boolean checkForContent) throws PyDebuggerException {
final XppReader reader = new XppReader(new StringReader(text), new MXParser(), new NoNameCoder());
if (checkForContent && !reader.hasMoreChildren()) {
throw new PyDebuggerException("Empty frame: " + text);
}
return reader;
}
示例14: readString
import com.thoughtworks.xstream.io.xml.XppReader; //导入依赖的package包/类
private static String readString(final XppReader reader, final String name, final String fallback) throws PyDebuggerException {
final String value;
try {
value = read(reader, name);
}
catch (PyDebuggerException e) {
if (fallback != null) {
return fallback;
}
else {
throw e;
}
}
return decode(value);
}
示例15: read
import com.thoughtworks.xstream.io.xml.XppReader; //导入依赖的package包/类
private static String read(final XppReader reader, final String name) throws PyDebuggerException {
final String value = reader.getAttribute(name);
if (value == null) {
throw new PyDebuggerException("Attribute not found: " + name);
}
return value;
}