本文整理汇总了Java中org.xmlpull.mxp1.MXParser类的典型用法代码示例。如果您正苦于以下问题:Java MXParser类的具体用法?Java MXParser怎么用?Java MXParser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MXParser类属于org.xmlpull.mxp1包,在下文中一共展示了MXParser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Combiner
import org.xmlpull.mxp1.MXParser; //导入依赖的package包/类
public Combiner(ManifestResolver resolver, Writer output) throws IOException, XmlPullParserException
{
this.output = output;
this.resolver = resolver;
Reader reader = null;
try
{
reader = resolver.getStream();
parser = new MXParser();
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
parser.setInput(reader);
parseXml();
}
finally
{
Closeables.close(reader, true); // Quietly
}
}
示例2: loadMainParts
import org.xmlpull.mxp1.MXParser; //导入依赖的package包/类
private void loadMainParts(String dateiname)
{
try
{
XmlPullParser parser = new MXParser();
FileReader reader = new FileReader(dateiname);
parser.setInput(reader);
processXML(parser);
reader.close();
}
catch (Exception e)
{
e.printStackTrace();
}
}
示例3: testPathsAreDecodedInTracker
import org.xmlpull.mxp1.MXParser; //导入依赖的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());
}
示例4: parseMacroGroups
import org.xmlpull.mxp1.MXParser; //导入依赖的package包/类
public MacroGroup parseMacroGroups(String macros) throws Exception {
MacroGroup group = null;
XmlPullParser parser = new MXParser();
parser.setInput(new StringReader(macros));
int eventType = parser.getEventType();
while (eventType != XmlPullParser.END_DOCUMENT) {
eventType = parser.next();
if (eventType == XmlPullParser.START_TAG) {
if (parser.getName().equals("macrogroup")) {
group = parseMacroGroup(parser);
}
}
}
return group;
}
示例5: setUp
import org.xmlpull.mxp1.MXParser; //导入依赖的package包/类
public void setUp()
throws Exception
{
// xmlPullParserFactory = XmlPullParserFactory.newInstance();
// xmlPullParserFactory.setNamespaceAware(true);
//
// xmlPullParser = xmlPullParserFactory.newPullParser();
xmlPullParser = new MXParser();
xmlPullParser.setFeature(
"http://xmlpull.org/v1/doc/features.html#process-namespaces",
true);
AbstractSmackInteroperabilityLayer.setImplementationClass(
SmackV3InteroperabilityLayer.class);
colibriIQProvider = new ColibriIQProvider();
}
示例6: getScormVersion
import org.xmlpull.mxp1.MXParser; //导入依赖的package包/类
public static String getScormVersion(Reader xml, boolean alwaysReturnDefaultVersion) throws XmlPullParserException,
IOException
{
XmlPullParser parser = new MXParser();
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
parser.setInput(xml);
parser.next();
String namespace = parser.getNamespace("adlcp");
String version = null;
if( namespace != null )
{
if( namespace.equals("http://www.adlnet.org/xsd/adlcp_rootv1p2") )
{
version = "1.2";
}
else if( namespace.equals("http://www.adlnet.org/xsd/adlcp_v1p3") )
{
version = "1.3";
}
else if( alwaysReturnDefaultVersion )
{
version = "1.2";
}
}
return version;
}
示例7: gatherValuesForTagName
import org.xmlpull.mxp1.MXParser; //导入依赖的package包/类
private static void gatherValuesForTagName(String tagName, Reader xml, StringBuilder gatherer, int maxSize)
throws XmlPullParserException, IOException
{
XmlPullParser parser = new MXParser();
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
parser.setInput(xml);
int event = parser.getEventType();
while( event != XmlPullParser.END_DOCUMENT )
{
if( event == XmlPullParser.START_TAG && parser.getName().equals(tagName) )
{
while( parser.next() == XmlPullParser.TEXT )
{
String s = parser.getText();
if( s != null )
{
// Removal all tabs, newlines, returns, etc.. and trim
// white space
s = s.replaceAll("\\cM?\r?\r\n\t", "").trim();
if( s.length() > 0 )
{
gatherer.append(s);
gatherer.append(' ');
}
}
}
if( gatherer.length() >= maxSize )
{
return;
}
}
event = parser.next();
}
}
示例8: build
import org.xmlpull.mxp1.MXParser; //导入依赖的package包/类
/**
* @deprecated As of 1.4, use {@link XppDom#build(XmlPullParser)} instead
*/
@Deprecated
public static Xpp3Dom build(final Reader reader) throws Exception {
final XmlPullParser parser = new MXParser();
parser.setInput(reader);
try {
return (Xpp3Dom)XppDom.build(parser);
} finally {
reader.close();
}
}
示例9: openReader
import org.xmlpull.mxp1.MXParser; //导入依赖的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;
}
示例10: resetParser
import org.xmlpull.mxp1.MXParser; //导入依赖的package包/类
/**
* Resets the parser using the latest connection's reader. Reseting the parser is necessary
* when the plain connection has been secured or when a new opening stream element is going
* to be sent by the server.
*/
private void resetParser() {
try {
parser = new MXParser();
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
parser.setInput(connection.reader);
}
catch (XmlPullParserException xppe) {
xppe.printStackTrace();
}
}
示例11: testDecoratesReaderAndTracksPath
import org.xmlpull.mxp1.MXParser; //导入依赖的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());
}
示例12: UserDAOImple
import org.xmlpull.mxp1.MXParser; //导入依赖的package包/类
@SuppressWarnings("static-access")
public UserDAOImple(){
this.map = new HashMap<Long, UserDO>();
this.xpp = new MXParser();
this.xsl = new MXSerializer();
this.maxId = Long.MIN_VALUE;
}
示例13: UserDAOImple
import org.xmlpull.mxp1.MXParser; //导入依赖的package包/类
@SuppressWarnings("static-access")
public UserDAOImple() {
this.map = new HashMap<Long, UserDO>();
this.xpp = new MXParser();
this.xsl = new MXSerializer();
this.maxId = Long.MIN_VALUE;
}
示例14: getTranscript
import org.xmlpull.mxp1.MXParser; //导入依赖的package包/类
/**
* Reads in the transcript file using the Xml Pull Parser.
*
* @param transcriptFile the transcript file to read.
* @return the ChatTranscript.
*/
public static ChatTranscript getTranscript(File transcriptFile) {
final ChatTranscript transcript = new ChatTranscript();
if (!transcriptFile.exists()) {
return transcript;
}
try {
final MXParser parser = new MXParser();
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(transcriptFile), "UTF-8"));
parser.setInput(in);
boolean done = false;
while (!done) {
int eventType = parser.next();
if (eventType == XmlPullParser.START_TAG && "message".equals(parser.getName())) {
transcript.addHistoryMessage(getHistoryMessage(parser));
}
else if (eventType == XmlPullParser.END_TAG && "transcript".equals(parser.getName())) {
done = true;
}
}
}
catch (Exception e) {
e.printStackTrace();
}
return transcript;
}
示例15: loadPreviousHistory
import org.xmlpull.mxp1.MXParser; //导入依赖的package包/类
/**
* Loads the previous history.
*/
private void loadPreviousHistory() {
if (!conFile.exists()) {
return;
}
// Otherwise load it.
try {
final MXParser parser = new MXParser();
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(conFile), "UTF-8"));
parser.setInput(in);
boolean done = false;
while (!done) {
int eventType = parser.next();
if (eventType == XmlPullParser.START_TAG && "user".equals(parser.getName())) {
String jid = StringUtils.parseBareAddress(parser.nextText());
historyList.add(jid);
}
else if (eventType == XmlPullParser.END_TAG && "conversations".equals(parser.getName())) {
done = true;
}
}
}
catch (Exception e) {
Log.error(e);
}
}