本文整理汇总了Java中com.thoughtworks.xstream.io.xml.XppReader类的典型用法代码示例。如果您正苦于以下问题:Java XppReader类的具体用法?Java XppReader怎么用?Java XppReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XppReader类属于com.thoughtworks.xstream.io.xml包,在下文中一共展示了XppReader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:ProtocolParser.java
示例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);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:ProtocolParser.java
示例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;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:ProtocolParser.java
示例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);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:ProtocolParser.java
示例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);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:ProtocolParser.java
示例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());
}
开发者ID:x-stream,项目名称:xstream,代码行数:19,代码来源:PathTrackingReaderTest.java
示例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");
}
开发者ID:stevensimmons,项目名称:restalm,代码行数:24,代码来源:MarshallingUtils.java
示例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");
}
开发者ID:stevensimmons,项目名称:restalm,代码行数:12,代码来源:MarshallingUtilsTest.java
示例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();
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:OfflineViewParseUtil.java
示例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);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:ProtocolParser.java
示例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));
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:ProtocolParser.java
示例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;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:ProtocolParser.java
示例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;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:ProtocolParser.java
示例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);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:ProtocolParser.java
示例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;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:ProtocolParser.java
示例16: testCustomObjectCanBeInstantiatedExternallyBeforeDeserialization
import com.thoughtworks.xstream.io.xml.XppReader; //导入依赖的package包/类
public void testCustomObjectCanBeInstantiatedExternallyBeforeDeserialization() {
xstream.alias("friend", SamplePerson.class);
xstream.alias("personHolder", SamplePersonHolder.class);
String xml =
"<personHolder>\n" +
" <aString>hello world</aString>\n" +
" <brother>\n" +
" <anInt>3</anInt>\n" +
" <firstName>Joe</firstName>\n" +
" <lastName>Walnes</lastName>\n" +
" </brother>\n" +
"</personHolder>";
// execute
SamplePersonHolder alreadyInstantiated = new SamplePersonHolder();
xstream.unmarshal(new XppReader(new StringReader(xml)), alreadyInstantiated);
// verify
SamplePersonHolder expectedResult = new SamplePersonHolder();
expectedResult.aString = "hello world";
SamplePerson expectedPerson = new SamplePerson();
expectedPerson.anInt = 3;
expectedPerson.firstName = "Joe";
expectedPerson.lastName = "Walnes";
expectedResult.brother = expectedPerson;
assertEquals(expectedResult, alreadyInstantiated);
}
开发者ID:x-stream,项目名称:xstream,代码行数:31,代码来源:CustomClassesTest.java
示例17: testCanBePassedInToUnmarshallerExternally
import com.thoughtworks.xstream.io.xml.XppReader; //导入依赖的package包/类
public void testCanBePassedInToUnmarshallerExternally() {
// setup
xstream.registerConverter(new StringWithPrefixConverter());
DataHolder dataHolder = xstream.newDataHolder();
// execute
String xml = "<string can-you-see-me=\"yes\">something</string>";
Object result = xstream.unmarshal(new XppReader(new StringReader(xml)), null, dataHolder);
// verify
assertEquals("something", result);
assertEquals("yes", dataHolder.get("saw-this"));
}
开发者ID:x-stream,项目名称:xstream,代码行数:14,代码来源:DataHolderTest.java
示例18: createReader
import com.thoughtworks.xstream.io.xml.XppReader; //导入依赖的package包/类
protected HierarchicalStreamReader createReader(String xml) throws Exception {
HierarchicalStreamReader sourceReader =
new Xpp3Driver().createReader(new StringReader(xml));
StringWriter buffer = new StringWriter();
HierarchicalStreamWriter destinationWriter = new CompactWriter(buffer);
copier.copy(sourceReader, destinationWriter);
return new XppReader(new StringReader(buffer.toString()), XppFactory.createDefaultParser());
}
开发者ID:x-stream,项目名称:xstream,代码行数:12,代码来源:HierarchicalStreamCopierTest.java
示例19: testSkipsValueIfEmpty
import com.thoughtworks.xstream.io.xml.XppReader; //导入依赖的package包/类
public void testSkipsValueIfEmpty() throws XmlPullParserException {
String input = "<root><empty1/><empty2></empty2><not-empty>blah</not-empty></root>";
String expected = "<root><empty1/><empty2/><not-empty>blah</not-empty></root>";
HierarchicalStreamReader sourceReader = new XppReader(
new StringReader(input), XppFactory.createDefaultParser());
StringWriter buffer = new StringWriter();
HierarchicalStreamWriter destinationWriter = new CompactWriter(buffer);
copier.copy(sourceReader, destinationWriter);
assertEquals(expected, buffer.toString());
}
开发者ID:x-stream,项目名称:xstream,代码行数:14,代码来源:HierarchicalStreamCopierTest.java
示例20: testDecoratesReaderAndTracksPath
import com.thoughtworks.xstream.io.xml.XppReader; //导入依赖的package包/类
public void testDecoratesReaderAndTracksPath() {
Reader input = new StringReader("" +
"<a>" +
" <b><c/></b>" +
" <b/>" +
" <d/>" +
"</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"), pathTracker.getPath());
reader.moveDown();
assertEquals(new Path("/a/b/c"), pathTracker.getPath());
reader.moveUp();
assertEquals(new Path("/a/b"), pathTracker.getPath());
reader.moveUp();
reader.moveDown();
assertEquals(new Path("/a/b[2]"), pathTracker.getPath());
reader.moveUp();
reader.moveDown();
assertEquals(new Path("/a/d"), pathTracker.getPath());
reader.moveUp();
assertEquals(new Path("/a"), pathTracker.getPath());
}
开发者ID:x-stream,项目名称:xstream,代码行数:34,代码来源:PathTrackingReaderTest.java
注:本文中的com.thoughtworks.xstream.io.xml.XppReader类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论