KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > meshcms > taglib > User


1 /*
2  * MeshCMS - A simple CMS based on SiteMesh
3  * Copyright (C) 2004-2007 Luciano Vernaschi
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  *
19  * You can contact the author at http://www.cromoteca.com
20  * and at info@cromoteca.com
21  */

22
23 package org.meshcms.taglib;
24
25 import java.io.*;
26
27 /**
28  * Writes some user data (username, e-mail or user details).
29  *
30  * @see org.meshcms.core.UserInfo
31  */

32 public final class User extends AbstractTag {
33   public void writeTag() throws IOException {
34     String JavaDoc result = null;
35
36     if (id != null) {
37       id = id.toLowerCase();
38
39       if (id.equals("username")) {
40         result = userInfo.getUsername();
41       } else if (id.equals("email") || id.equals("e-mail")) {
42         result = userInfo.getEmail();
43       } else {
44         result = userInfo.getValue(id);
45       }
46     }
47
48     if (result == null) {
49       result = userInfo.getDisplayName();
50     }
51
52     getOut().write(result);
53   }
54 }
55
Popular Tags