本文整理匯總了Java中org.xmlpull.v1.XmlPullParser.getAttributeValue方法的典型用法代碼示例。如果您正苦於以下問題:Java XmlPullParser.getAttributeValue方法的具體用法?Java XmlPullParser.getAttributeValue怎麽用?Java XmlPullParser.getAttributeValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.xmlpull.v1.XmlPullParser
的用法示例。
在下文中一共展示了XmlPullParser.getAttributeValue方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: handleStartTag
import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
private void handleStartTag(XmlPullParser xml) {
String strNode = xml.getName();
if (strNode.equals(Constants.TAG_FEATURE)) {
mInsideFeature = true;
mService = xml.getAttributeValue(null, Constants.ATTR_NAME);
} else if (mInsideFeature && strNode.equals(Constants.TAG_PARAM)) {
mParamType = xml.getAttributeValue(null, Constants.ATTR_NAME);
if (mParamType.equals(Constants.ATTR_SERVICE)) // check if it is using the older mService param
mService = xml.getAttributeValue(null, Constants.ATTR_VALUE);
else if (mParamType.equals(Constants.ATTR_PACKAGE) || mParamType.equals(Constants.ATTR_ANDROID_PACKAGE))
mPluginClass = xml.getAttributeValue(null, Constants.ATTR_VALUE);
else if (mParamType.equals(Constants.ATTR_ONLOAD))
mOnLoad = "true".equals(xml.getAttributeValue(null, Constants.ATTR_VALUE));
else if (mParamType.equals(Constants.ATTR_CATEGORY))
mCategory = xml.getAttributeValue(null, Constants.ATTR_VALUE);
else if (mParamType.equals(Constants.ATTR_API))
mApi = xml.getAttributeValue(null, Constants.ATTR_VALUE);
}
}
示例2: parseStreamElementStartTag
import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
private void parseStreamElementStartTag(XmlPullParser parser) throws ParserException {
type = parseType(parser);
putNormalizedAttribute(KEY_TYPE, type);
if (type == StreamElement.TYPE_TEXT) {
subType = parseRequiredString(parser, KEY_SUB_TYPE);
} else {
subType = parser.getAttributeValue(null, KEY_SUB_TYPE);
}
name = parser.getAttributeValue(null, KEY_NAME);
qualityLevels = parseInt(parser, KEY_QUALITY_LEVELS, -1);
url = parseRequiredString(parser, KEY_URL);
maxWidth = parseInt(parser, KEY_MAX_WIDTH, -1);
maxHeight = parseInt(parser, KEY_MAX_HEIGHT, -1);
displayWidth = parseInt(parser, KEY_DISPLAY_WIDTH, -1);
displayHeight = parseInt(parser, KEY_DISPLAY_HEIGHT, -1);
language = parser.getAttributeValue(null, KEY_LANGUAGE);
putNormalizedAttribute(KEY_LANGUAGE, language);
timescale = parseInt(parser, KEY_TIME_SCALE, -1);
if (timescale == -1) {
timescale = (Long) getNormalizedAttribute(KEY_TIME_SCALE);
}
startTimes = new ArrayList<>();
}
示例3: handleStartTag
import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
public void handleStartTag(XmlPullParser xml) {
String strNode = xml.getName();
if (strNode.equals("feature")) {
//Check for supported feature sets aka. plugins (Accelerometer, Geolocation, etc)
//Set the bit for reading params
insideFeature = true;
service = xml.getAttributeValue(null, "name");
}
else if (insideFeature && strNode.equals("param")) {
paramType = xml.getAttributeValue(null, "name");
if (paramType.equals("service")) // check if it is using the older service param
service = xml.getAttributeValue(null, "value");
else if (paramType.equals("package") || paramType.equals("android-package"))
pluginClass = xml.getAttributeValue(null,"value");
else if (paramType.equals("onload"))
onload = "true".equals(xml.getAttributeValue(null, "value"));
}
else if (strNode.equals("preference")) {
String name = xml.getAttributeValue(null, "name").toLowerCase(Locale.ENGLISH);
String value = xml.getAttributeValue(null, "value");
prefs.set(name, value);
}
else if (strNode.equals("content")) {
String src = xml.getAttributeValue(null, "src");
if (src != null) {
setStartUrl(src);
}
}
}
示例4: action
import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
/**
* {@inheritDoc}
*/
@Override
public void action( Dsmlv2Container container ) throws XmlPullParserException
{
PresentFilter presentFilter = new PresentFilter();
XmlPullParser xpp = container.getParser();
// Adding the filter to the Search Filter
SearchRequestDsml searchRequestDecorator = ( SearchRequestDsml )
container.getBatchRequest().getCurrentRequest();
try
{
searchRequestDecorator.addCurrentFilter( presentFilter );
}
catch ( DecoderException de )
{
throw new XmlPullParserException( de.getMessage(), xpp, de );
}
// Checking and adding the filter's attributes
String attributeValue;
// name
attributeValue = xpp.getAttributeValue( "", NAME );
if ( attributeValue != null )
{
presentFilter.setAttributeDescription( attributeValue );
}
else
{
throw new XmlPullParserException( "name attribute is required", xpp, null );
}
}
示例5: handleStartTag
import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
private void handleStartTag(XmlPullParser xml) {
String strNode = xml.getName();
if (strNode.equals("preference")) {
String name = xml.getAttributeValue(null, "name").toLowerCase(Locale.ENGLISH);
String value = xml.getAttributeValue(null, "value");
prefs.set(name, value);
}
}
示例6: readLongAttribute
import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
private long readLongAttribute(XmlPullParser parser, String attr, long defaultValue) {
String valueString = parser.getAttributeValue(null, attr);
if (valueString == null) return defaultValue;
try {
return Long.parseLong(valueString);
} catch (NumberFormatException nfe) {
return defaultValue;
}
}
示例7: processACL
import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
/**
* Process ACL definition
*
* @param xpp XmlPullParser
* @param parserContext ParserContext
*/
private void processACL(XmlPullParser xpp, ParserContext parserContext)
{
NodeContext node = peekNodeContext(parserContext.elementStack);
String strInherit = xpp.getAttributeValue(NamespaceService.REPOSITORY_VIEW_1_0_URI, VIEW_INHERIT_PERMISSIONS_ATTR);
if (strInherit != null)
{
Boolean inherit = Boolean.valueOf(strInherit);
if (!inherit)
{
node.setInheritPermissions(false);
}
}
}
示例8: onStartReadXmlTag
import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
/**
* XML interface: callback on start of an xml tag reading
*/
public boolean onStartReadXmlTag(XmlPullParser parser)
{
if (getBaseType().toString().equalsIgnoreCase(parser.getName()))
{
String attr = parser.getAttributeValue(null, FormulaList.XML_PROP_INRIGHTOFPREVIOUS);
if (attr != null)
{
inRightOfPrevious = Boolean.valueOf(attr);
}
}
return false;
}
示例9: readFromXml
import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
public void readFromXml(XmlPullParser parser)
{
final DecimalFormat df = CompatUtils.getDecimalFormat("0.00000");
String attr = parser.getAttributeValue(null, XML_PROP_VERSION);
documentVersion = (attr != null)? Integer.parseInt(attr) : DEFAULT_DOCUMENT_VERSION;
attr = parser.getAttributeValue(null, XML_PROP_TEXT_WIDTH);
if (attr != null)
{
textWidth = Integer.parseInt(attr);
}
attr = parser.getAttributeValue(null, XML_PROP_SIGNIFICANT_DIGITS);
if (attr != null)
{
significantDigits = Integer.parseInt(attr);
}
attr = parser.getAttributeValue(null, XML_PROP_SCALE);
if (attr != null)
{
try
{
scaledDimensions.setScaleFactor(df.parse(attr).floatValue());
}
catch (ParseException e)
{
scaledDimensions.setScaleFactor(1.0f);
}
}
attr = parser.getAttributeValue(null, XML_PROP_REDEFINE_ALLOWED);
if (attr != null)
{
redefineAllowed = Boolean.parseBoolean(attr);
}
}
示例10: action
import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
/**
* {@inheritDoc}
*/
@Override
public void action( Dsmlv2Container container ) throws XmlPullParserException
{
ModDNResponseDsml modDNResponse = new ModDNResponseDsml(
container.getLdapCodecService(), new ModifyDnResponseImpl() );
container.getBatchResponse().addResponse( modDNResponse );
LdapResult ldapResult = modDNResponse.getLdapResult();
XmlPullParser xpp = container.getParser();
// Checking and adding the batchRequest's attributes
String attributeValue;
// requestID
attributeValue = xpp.getAttributeValue( "", "requestID" );
if ( attributeValue != null )
{
modDNResponse.setMessageId( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) );
}
// MatchedDN
attributeValue = xpp.getAttributeValue( "", "matchedDN" );
if ( attributeValue != null )
{
try
{
ldapResult.setMatchedDn( new Dn( attributeValue ) );
}
catch ( LdapInvalidDnException lide )
{
throw new XmlPullParserException( lide.getMessage(), xpp, lide );
}
}
}
示例11: parseRequiredString
import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
protected final String parseRequiredString(XmlPullParser parser, String key)
throws MissingFieldException {
String value = parser.getAttributeValue(null, key);
if (value != null) {
return value;
} else {
throw new MissingFieldException(key);
}
}
示例12: readIntAttribute
import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
public static int readIntAttribute(XmlPullParser in, String name, int defaultValue) {
final String value = in.getAttributeValue(null, name);
if (TextUtils.isEmpty(value)) {
return defaultValue;
}
try {
return Integer.parseInt(value);
} catch (NumberFormatException e) {
return defaultValue;
}
}
示例13: readUrl
import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
private static void readUrl(XmlPullParser parser, SearchEngine searchEngine) throws XmlPullParserException, IOException {
parser.require(XmlPullParser.START_TAG, null, "Url");
final String type = parser.getAttributeValue(null, "type");
final String template = parser.getAttributeValue(null, "template");
final String rel = parser.getAttributeValue(null, "rel");
Uri uri = Uri.parse(template);
while (parser.next() != XmlPullParser.END_TAG) {
if (parser.getEventType() != XmlPullParser.START_TAG) {
continue;
}
final String tag = parser.getName();
if (tag.equals("Param")) {
final String name = parser.getAttributeValue(null, "name");
final String value = parser.getAttributeValue(null, "value");
uri = uri.buildUpon().appendQueryParameter(name, value).build();
parser.nextTag();
} else {
skip(parser);
}
}
if (type.equals(URLTYPE_SEARCH_HTML)) {
// Prefer mobile URIs.
if (rel != null && rel.equals(URL_REL_MOBILE)) {
searchEngine.resultsUris.add(0, uri);
} else {
searchEngine.resultsUris.add(uri);
}
} else if (type.equals(URLTYPE_SUGGEST_JSON)) {
searchEngine.suggestUri = uri;
}
}
示例14: parseAccount
import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
private static ImportedAccount parseAccount(XmlPullParser xpp, List<String> accountUuids, boolean overview)
throws XmlPullParserException, IOException {
String uuid = xpp.getAttributeValue(null, SettingsExporter.UUID_ATTRIBUTE);
try {
UUID.fromString(uuid);
} catch (Exception e) {
skipToEndTag(xpp, SettingsExporter.ACCOUNT_ELEMENT);
Timber.w("Skipping account with invalid UUID %s", uuid);
return null;
}
ImportedAccount account = new ImportedAccount();
account.uuid = uuid;
if (overview || accountUuids.contains(uuid)) {
int eventType = xpp.next();
while (!(eventType == XmlPullParser.END_TAG && SettingsExporter.ACCOUNT_ELEMENT.equals(xpp.getName()))) {
if (eventType == XmlPullParser.START_TAG) {
String element = xpp.getName();
if (SettingsExporter.NAME_ELEMENT.equals(element)) {
account.name = getText(xpp);
} else if (SettingsExporter.INCOMING_SERVER_ELEMENT.equals(element)) {
if (overview) {
skipToEndTag(xpp, SettingsExporter.INCOMING_SERVER_ELEMENT);
} else {
account.incoming = parseServerSettings(xpp, SettingsExporter.INCOMING_SERVER_ELEMENT);
}
} else if (SettingsExporter.OUTGOING_SERVER_ELEMENT.equals(element)) {
if (overview) {
skipToEndTag(xpp, SettingsExporter.OUTGOING_SERVER_ELEMENT);
} else {
account.outgoing = parseServerSettings(xpp, SettingsExporter.OUTGOING_SERVER_ELEMENT);
}
} else if (SettingsExporter.SETTINGS_ELEMENT.equals(element)) {
if (overview) {
skipToEndTag(xpp, SettingsExporter.SETTINGS_ELEMENT);
} else {
account.settings = parseSettings(xpp, SettingsExporter.SETTINGS_ELEMENT);
}
} else if (SettingsExporter.IDENTITIES_ELEMENT.equals(element)) {
account.identities = parseIdentities(xpp);
} else if (SettingsExporter.FOLDERS_ELEMENT.equals(element)) {
if (overview) {
skipToEndTag(xpp, SettingsExporter.FOLDERS_ELEMENT);
} else {
account.folders = parseFolders(xpp);
}
} else {
Timber.w("Unexpected start tag: %s", xpp.getName());
}
}
eventType = xpp.next();
}
} else {
skipToEndTag(xpp, SettingsExporter.ACCOUNT_ELEMENT);
Timber.i("Skipping account with UUID %s", uuid);
}
// If we couldn't find an account name use the UUID
if (account.name == null) {
account.name = uuid;
}
return account;
}
示例15: readTrkPoint
import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
private LocSample readTrkPoint(XmlPullParser parser) {
String szLat = parser.getAttributeValue(null, "lat");
String szLon = parser.getAttributeValue(null, "lon");
return new LocSample(Double.parseDouble(szLat), Double.parseDouble(szLon), 0, 0, 1.0, "");
}