testing TemplateHashModel
[mir.git] / source / mircoders / entity / EntityBreaking.java
1 package mircoders.entity;
2
3 /**
4  * Title: EntityBreaking
5  * Description: Maps table "breaking" to Java Object
6  * Copyright:    Copyright (c) 2001
7  * Company:      Indymedia.de
8  * @author /rk
9  * @version 1.0
10  */
11
12 import java.lang.*;
13 import java.io.*;
14 import java.util.*;
15 import java.sql.*;
16
17 import freemarker.template.*;
18
19 import mir.entity.*;
20 import mir.misc.*;
21 import mir.storage.*;
22
23 public class EntityBreaking extends AbstractEntity implements Entity, TemplateHashModel
24 {
25   private static int instances;
26
27         public EntityBreaking() {       super(); instances++;   }
28         public EntityBreaking(StorageObject theStorage) {       this(); setStorage(theStorage); }
29         public void finalize() {
30     instances--;
31     super.finalize();
32   }
33
34
35         public HashMap getValues() {
36                 HashMap returnHash = super.getValues();
37                 String date=null;
38
39                 if ((date=(String)returnHash.get("webdb_create"))!=null)
40                         returnHash.put("webdb_create_formatted", StringUtil.dateToReadableDate(date));
41                 return returnHash;
42         }
43
44   // Now implements freemarkers TemplateHashModel
45   // two methods have to be overridden:
46   // 1. public boolean isEmpty() throws TemplateModelException
47   // 2. public TemplateModel get(java.lang.String key) throws TemplateModelException
48
49   public boolean isEmpty() throws TemplateModelException
50   {
51     if (theValuesHash==null || theValuesHash.isEmpty())
52       return true;
53     return false;
54   }
55
56   public TemplateModel get(java.lang.String key) throws TemplateModelException
57   {
58     return new SimpleScalar(getValue("key"));
59   }
60
61
62   //////////////////////////////////////////////////////////////////////////////////
63
64 }