1 package com.yuji.tdb.db;
\r
3 import javax.jdo.PersistenceManager;
\r
5 public class KeyValueDao {
\r
6 public static final String KEY_CONSUMER_KEY = "CONSUMER_KEY";
\r
7 public static final String KEY_CONSUMER_SECRET = "CONSUMER_SECRET";
\r
8 public static final String KEY_REQUEST_TOKEN = "REQUEST_TOKEN";
\r
9 public static final String KEY_REQUEST_TOKEN_SECRET = "REQUEST_TOKEN_SECRET";
\r
10 public static final String KEY_ACCESS_TOKEN = "ACCESS_TOKEN";
\r
11 public static final String KEY_ACCESS_TOKEN_SECRET = "ACCESS_TOKEN_SECRET";
\r
13 private static KeyValueDao instance = null;
\r
14 private PersistenceManager pm = PMFactory.get().getPersistenceManager();
\r
16 public static KeyValueDao getInstance(){
\r
17 if (instance == null){
\r
18 instance = new KeyValueDao();
\r
23 private KeyValueDao(){
\r
27 public String get(String key){
\r
28 KeyValue keyValue = pm.getObjectById(KeyValue.class, key);
\r
29 if (keyValue == null){
\r
32 return keyValue.getValue();
\r
35 public void put(String key, String value){
\r
36 KeyValue keyValue = new KeyValue(key, value);
\r
37 pm.makePersistent(keyValue);
\r