Advertisement
Guest User

Section.java

a guest
Jul 20th, 2012
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.04 KB | None | 0 0
  1. package com.mysite.models;
  2.  
  3. public class Section
  4. {
  5.     public static final String TABLE = "sections";
  6.     public static final String COLUMN_ID = "_id";
  7.     public static final String COLUMN_TITLE = "title";
  8.     public static final String COLUMN_LINK = "link";
  9.     public static final String COLUMN_SLUG = "slug";
  10.     public static final String COLUMN_LASTUPDATED = "last_updated";
  11.    
  12.     public long id;
  13.     public String title;
  14.     public String link;
  15.     public String slug;
  16.     public String last_updated;
  17.    
  18.     public static final int INDEX_TITLE = 0;
  19.     public static final int INDEX_URL = 1;
  20.     public static final int INDEX_SLUG = 2;
  21.    
  22.     //Database creation sql statement
  23.     public static final String TABLE_CREATE = "CREATE TABLE "
  24.         + Section.TABLE + "( "
  25.             + Section.COLUMN_ID + " INTEGER primary key autoincrement, "
  26.             + Section.COLUMN_SLUG + " TEXT, "
  27.             + Section.COLUMN_LASTUPDATED + " TEXT"
  28.         + ");";
  29.  
  30.            
  31.        
  32.         /*+ ") VALUES "
  33.             + "('Top News', " + "'http://www.mysite.com/csp/cms/sites/mysite/RSS/rssfullpichomepagenewsandroid.csp', " + "'top'), "
  34.             + "('Utah News', " + "'http://www.mysite.com/csp/cms/sites/mysite/RSS/rssfullpicnewspageandroid.csp', " + "'utah'), "
  35.             + "('Sports', " + "'http://www.mysite.com/csp/cms/sites/mysite/RSS/rssfullpicsportspageandroid.csp', " + "'sports'), "
  36.             + "('Opinion', " + "'http://www.mysite.com/csp/cms/sites/mysite/RSS/rssfullpicopinionpageandroid.csp', " + "'opinion'), "
  37.             + "('Money', " + "'http://www.mysite.com/csp/cms/sites/mysite/RSS/rssfullpicmoneypageandroid.csp', " + "'money'), "
  38.             + "('Mix', " + "'http://www.mysite.com/csp/cms/sites/mysite/RSS/rssfullpicmixpageandroid.csp', " + "'mix'), "
  39.             + "('Obituaries', " + "'http://img.mysite.com/getObits_android.php', " + "'obits'), "
  40.             + "('Weather', " + "'http://www.mysite.com/mysite/weather.php', " + "'weather')"
  41.         + "";*/
  42.    
  43.     //name, url, feed
  44.     public static final String[] TOP = {
  45.         "Top News",
  46.         "http://www.mysite.com/csp/cms/sites/mysite/RSS/rssfullpichomepagenewsandroid.csp",
  47.         "top"
  48.     };
  49.  
  50.     public static final String[] UTAH = {
  51.         "Local News",
  52.         "http://www.mysite.com/csp/cms/sites/mysite/RSS/rssfullpicnewspageandroid.csp",
  53.         "utah"
  54.     };
  55.    
  56.     public static final String[] SPORTS = {
  57.         "Sports",
  58.         "http://www.mysite.com/csp/cms/sites/mysite/RSS/rssfullpicsportspageandroid.csp",
  59.         "sports"
  60.     };
  61.     public static final String[] OPINION = {
  62.         "Opinion",
  63.         "http://www.mysite.com/csp/cms/sites/mysite/RSS/rssfullpicopinionpageandroid.csp",
  64.         "opinion"
  65.     };
  66.     public static final String[] MONEY = {
  67.         "Money",
  68.         "http://www.mysite.com/csp/cms/sites/mysite/RSS/rssfullpicmoneypageandroid.csp",
  69.         "money"
  70.     };
  71.     public static final String[] MIX = {
  72.         "The Mix",
  73.         "http://www.mysite.com/csp/cms/sites/mysite/RSS/rssfullpicmixpageandroid.csp",
  74.         "mix"
  75.     };
  76.     public static final String[] OBITS = {
  77.         "Obituaries",
  78.         "http://img.mysite.com/getObits_android.php",
  79.         "obits"
  80.     };
  81.     public static final String[] WEATHER = {
  82.         "Weather",
  83.         "http://www.mysite.com/mysite/weather.php",
  84.         "weather"
  85.     };
  86.     public static final String[] COMICS= {
  87.         "Comics",
  88.         "http://www.mysite.com/csp/cms/sites/mysite/RSS/rssfullpiccomicspageandroid.csp",
  89.         "comics"
  90.     };
  91.     public static final String[] POPULAR = {
  92.         "Popular Stories",
  93.         "http://www.mysite.com/csp/cms/sites/mysite/RSS/rssfullpicpopularandroid.csp",
  94.         "popular"
  95.     };
  96.    
  97.     public static final String[][] SECTIONS = { TOP, UTAH, SPORTS, OPINION, MONEY, MIX, OBITS, WEATHER, COMICS, POPULAR };
  98.     public static String[] currentSection = TOP;
  99.    
  100.  
  101.     public static final String POPULATE_TABLE = "INSERT INTO "
  102.         + Section.TABLE + " "
  103.             + "SELECT '1' AS '" + Section.COLUMN_ID + "', '" + Section.TOP[Section.INDEX_SLUG] + "' AS '" + Section.COLUMN_SLUG + "', '' AS '" + Section.COLUMN_LASTUPDATED + "' "
  104.             + "UNION SELECT '2', '" + Section.UTAH[Section.INDEX_SLUG] + "', '' "
  105.             + "UNION SELECT '3', '" + Section.SPORTS[Section.INDEX_SLUG] + "', ''  "
  106.             + "UNION SELECT '4', '" + Section.OPINION[Section.INDEX_SLUG] + "', ''  "
  107.             + "UNION SELECT '5', '" + Section.MONEY[Section.INDEX_SLUG] + "', ''  "
  108.             + "UNION SELECT '6', '" + Section.MIX[Section.INDEX_SLUG] + "', ''  "
  109.             + "UNION SELECT '7', '" + Section.OBITS[Section.INDEX_SLUG] + "', ''  "
  110.             + "UNION SELECT '8', '" + Section.WEATHER[Section.INDEX_SLUG] + "', ''  "
  111.             + "UNION SELECT '9', '" + Section.COMICS[Section.INDEX_SLUG] + "', ''  "
  112.             + "UNION SELECT '10', '" + Section.POPULAR[Section.INDEX_SLUG] + "', ''";
  113.    
  114.     //Uses a string to return the corresponding
  115.     public static String[] stringToSection(String string)
  116.     {
  117.         String[] section = TOP; //defaults if it can't find a match
  118.         for(final String[] tmpSection : SECTIONS)
  119.         {
  120.             if(tmpSection[INDEX_TITLE].equals(string))
  121.             {
  122.                 section = tmpSection;
  123.             }
  124.         }
  125.         return section;
  126.     }
  127.    
  128.     public static Boolean isEqual(String[] section, String string)
  129.     {
  130.         if(string.equals(section[INDEX_TITLE]) || string.equals(section[INDEX_URL]) || string.equals(section[INDEX_SLUG]))
  131.         {
  132.             return true;
  133.         }
  134.         return false;
  135.     }
  136.    
  137.     public static String currentSectionTitle() {
  138.         return currentSection[INDEX_TITLE];
  139.     }
  140. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement