00001 /* 00002 * OpenMobileIS - a free Java(TM) Framework for mobile applications Java(TM) 00003 * Copyright (C) 2004-2005 Philippe Delrieu 00004 * All rights reserved. 00005 * Contact: openmobileis@e-care.fr 00006 * 00007 * This library is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2.1 of the License, or any later version. 00011 * 00012 * This library is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with this library; if not, write to the Free Software 00019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00020 * USA 00021 * 00022 * Author : Philippe Delrieu 00023 * 00024 * Modifications : 00025 * 2005 Creation P.Delrieu 00026 * 00027 */ 00028 00029 package org.openmobileis.modules.profils.embedded.data; 00030 00031 import org.openmobileis.common.util.collection.Array; 00032 00041 public class EmbeddedProfilChannel { 00042 00043 protected String name; 00044 protected Array rubrics; 00045 00046 public EmbeddedProfilChannel() { 00047 rubrics = new Array(1); 00048 } 00049 00050 public EmbeddedProfilChannel(String channelName) { 00051 this(); 00052 this.name = channelName; 00053 } 00054 00055 public void setName (String name) { 00056 this.name = name; 00057 } 00058 00059 public String getName() { 00060 return name; 00061 } 00062 00063 public void addRubic(EmbeddedProfilRubric rub) { 00064 rubrics.add(rub); 00065 } 00066 00067 public Array getRubrics() { 00068 return rubrics; 00069 } 00070 00071 public EmbeddedProfilRubric getRubric (int pos) { 00072 return (EmbeddedProfilRubric)rubrics.get(pos); 00073 } 00074 00075 public int getRubricSize() { 00076 return rubrics.size(); 00077 } 00078 00079 public void setSelection (boolean selected) { 00080 for (int i=0; i<rubrics.size();i++) { 00081 ((EmbeddedProfilRubric)rubrics.get(i)).setSelection(selected); 00082 } 00083 } 00084 00085 // Could be optimized... 00086 public EmbeddedProfilRubric getRubric (String rubricName) { 00087 for (int i=0; i<rubrics.size();i++) { 00088 if (((EmbeddedProfilRubric)rubrics.get(i)).getName().equals(rubricName)) 00089 return (EmbeddedProfilRubric)rubrics.get(i); 00090 } 00091 return null; 00092 } 00093 00094 public boolean isSelected() { 00095 for (int i=0; i<rubrics.size();i++) { 00096 if (!((EmbeddedProfilRubric)rubrics.get(i)).isSelected()) 00097 return false; 00098 } 00099 return true; 00100 } 00101 00102 public String getXmlDescription() { 00103 StringBuffer buffer = new StringBuffer(); 00104 buffer.append("<channel>\n"); 00105 buffer.append("<name>"); 00106 buffer.append(name); 00107 buffer.append("</name>\n"); 00108 for (int i=0; i < rubrics.size(); i++) 00109 buffer.append(((EmbeddedProfilRubric)rubrics.get(i)).getXmlDescription()); 00110 buffer.append("</channel>\n"); 00111 return buffer.toString(); 00112 } 00113 00114 }