android-ibc-forum

Unnamed repository; edit this file 'description' to name the repository.
git clone http://git.code.weiherhei.de/android-ibc-forum.git
Log | Files | Refs

MediaAttributes.java (1509B)


      1 /*
      2  * Copyright (C) 2010 A. Horn
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package org.mcsoxford.rss;
     18 
     19 /**
     20  * Internal helper class for RSS 2.0 media attributes.
     21  * 
     22  * @author Mr Horn
     23  */
     24 final class MediaAttributes {
     25 
     26   /* Hide constructor */
     27   private MediaAttributes() {}
     28 
     29   /**
     30    * Returns the RSS 2.0 attribute with the specified local name as a string.
     31    * The return value is {@code null} if no attribute with such name exists.
     32    */
     33   static String stringValue(org.xml.sax.Attributes attributes, String name) {
     34     return attributes.getValue(name);
     35   }
     36 
     37   /**
     38    * Returns the RSS 2.0 attribute with the specified local name as an integer. 
     39    * The {@code defaultValue} is returned if no attribute with such name exists.
     40    */
     41   static int intValue(org.xml.sax.Attributes attributes, String name, int defaultValue) {
     42     final String value = stringValue(attributes, name);
     43     if(value == null) {
     44       return defaultValue;
     45     }
     46 
     47     return Integer.parseInt(value);
     48   }
     49 
     50 }
     51