001: /*
002: * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
003: *
004: * Redistribution and use in source and binary forms, with or without
005: * modification, are permitted provided that the following conditions
006: * are met:
007: *
008: * - Redistributions of source code must retain the above copyright
009: * notice, this list of conditions and the following disclaimer.
010: *
011: * - Redistribution in binary form must reproduce the above copyright
012: * notice, this list of conditions and the following disclaimer in
013: * the documentation and/or other materials provided with the
014: * distribution.
015: *
016: * Neither the name of Sun Microsystems, Inc. or the names of
017: * contributors may be used to endorse or promote products derived
018: * from this software without specific prior written permission.
019: *
020: * This software is provided "AS IS," without a warranty of any
021: * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
022: * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
023: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
024: * EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES
025: * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
026: * DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN
027: * OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
028: * FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
029: * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF
030: * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE,
031: * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
032: *
033: * You acknowledge that Software is not designed, licensed or intended
034: * any nuclear facility.
035: */
036:
037: package com.sun.portal.community.template.impl;
038:
039: import java.util.Iterator;
040: import java.util.Set;
041: import java.util.HashSet;
042: import java.util.Map;
043: import java.util.HashMap;
044: import java.util.Locale;
045: import java.util.ResourceBundle;
046:
047: import com.sun.portal.community.template.TemplateDescriptor;
048: import com.sun.portal.community.template.TemplateException;
049:
050: public class CommunityTemplateDescriptorImpl implements
051: TemplateDescriptor {
052:
053: public static final String NAME_KEY = "name";
054: public static final String DESCRIPTION_KEY = "description";
055: public static final String PREVIEWIMAGEURI_KEY = "previewImageURI";
056: public static final String TOKENS_KEY = "tokens";
057:
058: private String _id;
059: private ResourceBundle _res;
060:
061: CommunityTemplateDescriptorImpl(String id, ResourceBundle res) {
062:
063: _id = id;
064: _res = res;
065: }
066:
067: public String getId() {
068:
069: return _id;
070: }
071:
072: public String getName() {
073:
074: return _res.getString(NAME_KEY);
075: }
076:
077: public String getDescription() {
078:
079: return _res.getString(DESCRIPTION_KEY);
080: }
081:
082: public String getPreviewImageURI() {
083:
084: return _res.getString(PREVIEWIMAGEURI_KEY);
085: }
086:
087: public Set getTokens() {
088:
089: String tokensStr = _res.getString(TOKENS_KEY);
090:
091: Set tokens = new HashSet();
092: if (tokensStr != null && tokensStr.length() > 0) {
093: String[] tokensArray = tokensStr.split("\\s");
094: for (int i = 0; i < tokensArray.length; i++) {
095: tokens.add(tokensArray[i]);
096: }
097: }
098: return tokens;
099: }
100:
101: public String toString() {
102:
103: StringBuffer buf = new StringBuffer();
104:
105: buf.append("id=").append(_id).append(", name=").append(
106: getName());
107: buf.append(", description=").append(getDescription());
108: buf.append(", previewImageURI=").append(getPreviewImageURI());
109: buf.append(", tokens=").append(getTokens());
110:
111: return buf.toString();
112: }
113: }
|