本文整理匯總了Java中org.xmlpull.v1.XmlPullParser.getNamespace方法的典型用法代碼示例。如果您正苦於以下問題:Java XmlPullParser.getNamespace方法的具體用法?Java XmlPullParser.getNamespace怎麽用?Java XmlPullParser.getNamespace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.xmlpull.v1.XmlPullParser
的用法示例。
在下文中一共展示了XmlPullParser.getNamespace方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getName
import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
/**
* Helper to create Qualified name from current xml element
*
* @param xpp XmlPullParser
* @return QName
*/
private QName getName(XmlPullParser xpp)
{
// Ensure namespace is valid
String uri = xpp.getNamespace();
if (namespaceService.getURIs().contains(uri) == false)
{
throw new ImporterException("Namespace URI " + uri + " has not been defined in the Repository dictionary");
}
// Construct name
String name = xpp.getName();
return QName.createQName(uri, name);
}
示例2: getScormVersion
import org.xmlpull.v1.XmlPullParser; //導入方法依賴的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;
}
示例3: parseApplicationNameByManifest
import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
/**
* get application name by manifest
*
* @param parser parser
* @return application name
*/
private static String parseApplicationNameByManifest(XmlPullParser parser) {
try {
int eventType = parser.getEventType();
String namespaceAndroid = null;
do {
switch (eventType) {
case XmlPullParser.START_DOCUMENT: {
break;
}
case XmlPullParser.START_TAG: {
String tag = parser.getName();
if (tag.equals("manifest")) {
namespaceAndroid = parser.getNamespace("android");
} else if ("application".equals(parser.getName())) {
String applicationName = parser.getAttributeValue("", "name");
if (applicationName == null || "".equals(applicationName)) {
applicationName = parser.getAttributeValue(namespaceAndroid, "name");
}
return applicationName;
}
break;
}
case XmlPullParser.END_TAG: {
break;
}
}
eventType = parser.next();
} while (eventType != XmlPullParser.END_DOCUMENT);
} catch (Exception e1) {
}
return "";
}
示例4: captureElement
import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
/**
* Serializes the current element and all child nodes as a String.
* @param parser The parser to pull from.
* @return The composed element string.
* @throws XmlPullParserException
* @throws IOException
*/
public static String captureElement(XmlPullParser parser)
throws XmlPullParserException, IOException
{
int event = parser.getEventType();
if (event != XmlPullParser.START_TAG) {
throw new XmlPullParserException("Expected call to begin at START_TAG");
}
int depth = 0;
StringWriter sw = new StringWriter();
XmlSerializer serializer = PARSER_FACTORY.newSerializer();
serializer.setOutput(sw);
String namespace, prefix;
while (event != XmlPullParser.END_DOCUMENT) {
switch (event) {
case XmlPullParser.START_TAG:
++depth;
namespace = parser.getNamespace();
prefix = parser.getPrefix();
if (namespace != null && prefix != null) {
serializer.setPrefix(prefix, namespace);
}
serializer.startTag(namespace, parser.getName());
int attrCount = parser.getAttributeCount();
for (int i = 0; i < attrCount; ++i) {
namespace = parser.getAttributeNamespace(i);
prefix = parser.getAttributePrefix(i);
if (namespace != null && prefix != null) {
serializer.setPrefix(prefix, namespace);
}
serializer.attribute(namespace, parser.getAttributeName(i),
parser.getAttributeValue(i));
}
break;
case XmlPullParser.TEXT:
case XmlPullParser.IGNORABLE_WHITESPACE:
serializer.text(parser.getText());
break;
case XmlPullParser.CDSECT:
serializer.cdsect(parser.getText());
break;
case XmlPullParser.END_TAG:
namespace = parser.getNamespace();
if (namespace != null) {
serializer.setPrefix(parser.getPrefix(), namespace);
}
serializer.endTag(namespace, parser.getName());
--depth;
break;
}
if (depth <= 0) {
serializer.flush();
return sw.toString();
}
event = parser.next();
}
throw new IOException("Unexpected end of document.");
}
示例5: b
import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
public static f b(XmlPullParser xmlPullParser) {
f.b bVar = f.b.available;
String attributeValue = xmlPullParser.getAttributeValue("", "type");
if (!(attributeValue == null || attributeValue.equals(""))) {
try {
bVar = f.b.valueOf(attributeValue);
} catch (IllegalArgumentException e) {
System.err.println("Found invalid presence type " + attributeValue);
}
}
f fVar = new f(bVar);
fVar.m(xmlPullParser.getAttributeValue("", SocializeProtocolConstants
.PROTOCOL_KEY_SHARE_TO));
fVar.n(xmlPullParser.getAttributeValue("", "from"));
fVar.l(xmlPullParser.getAttributeValue("", "chid"));
String attributeValue2 = xmlPullParser.getAttributeValue("", "id");
if (attributeValue2 == null) {
attributeValue2 = "ID_NOT_AVAILABLE";
}
fVar.k(attributeValue2);
int i = 0;
while (i == 0) {
int next = xmlPullParser.next();
if (next == 2) {
String name = xmlPullParser.getName();
String namespace = xmlPullParser.getNamespace();
if (name.equals("status")) {
fVar.a(xmlPullParser.nextText());
} else if (name.equals("priority")) {
try {
fVar.a(Integer.parseInt(xmlPullParser.nextText()));
} catch (NumberFormatException e2) {
} catch (IllegalArgumentException e3) {
fVar.a(0);
}
} else if (name.equals("show")) {
name = xmlPullParser.nextText();
try {
fVar.a(f.a.valueOf(name));
} catch (IllegalArgumentException e4) {
System.err.println("Found invalid presence mode " + name);
}
} else if (name.equals("error")) {
fVar.a(e(xmlPullParser));
} else {
fVar.a(a(name, namespace, xmlPullParser));
}
} else if (next == 3 && xmlPullParser.getName().equals("presence")) {
i = 1;
}
}
return fVar;
}
示例6: e
import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
public static h e(XmlPullParser xmlPullParser) {
String attributeValue;
String attributeValue2;
String str = "urn:ietf:params:xml:ns:xmpp-stanzas";
List arrayList = new ArrayList();
String str2 = null;
String str3 = null;
String str4 = "-1";
int i = 0;
while (i < xmlPullParser.getAttributeCount()) {
attributeValue = xmlPullParser.getAttributeName(i).equals("code") ? xmlPullParser
.getAttributeValue("", "code") : str4;
attributeValue2 = xmlPullParser.getAttributeName(i).equals("type") ? xmlPullParser
.getAttributeValue("", "type") : str3;
if (xmlPullParser.getAttributeName(i).equals("reason")) {
str2 = xmlPullParser.getAttributeValue("", "reason");
}
i++;
str3 = attributeValue2;
str4 = attributeValue;
}
Object obj = null;
attributeValue2 = null;
attributeValue = null;
while (obj == null) {
int next = xmlPullParser.next();
if (next == 2) {
if (xmlPullParser.getName().equals("text")) {
attributeValue = xmlPullParser.nextText();
} else {
String name = xmlPullParser.getName();
String namespace = xmlPullParser.getNamespace();
if ("urn:ietf:params:xml:ns:xmpp-stanzas".equals(namespace)) {
attributeValue2 = name;
} else {
arrayList.add(a(name, namespace, xmlPullParser));
}
}
} else if (next == 3) {
if (xmlPullParser.getName().equals("error")) {
obj = 1;
}
} else if (next == 4) {
attributeValue = xmlPullParser.getText();
}
}
return new h(Integer.parseInt(str4), str3 == null ? "cancel" : str3, str2,
attributeValue2, attributeValue, arrayList);
}
示例7: handleElementNode
import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
private static void handleElementNode(XmlPullParser parser,Object object, Field field) throws IllegalAccessException {
NamespaceNode namespaceNode = field.getAnnotation(NamespaceNode.class);
if (namespaceNode != null) {
String prefix = namespaceNode.prefix();
String namespace = parser.getNamespace();
if (!"".equals(prefix)) {
namespace = parser.getNamespace(prefix);
}
field.set(object, namespace);
return;
}
AttributeNode attributeNode = field.getAnnotation(AttributeNode.class);
if (attributeNode != null) {
int index = attributeNode.index();
String s = parser.getAttributeValue(index);
field.set(object, s);
return;
}
}