/* * File : TripleString.java * Created : 28-apr-2003 10:14 * By : fbusquets * * JClic - Authoring and playing system for educational activities * * Copyright (C) 2000 - 2005 Francesc Busquets & Departament * d'Educacio de la Generalitat de Catalunya * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details (see the LICENSE file). */ package edu.xtec.util; import java.io.File; import java.io.FileInputStream; import java.util.Iterator; import java.util.Properties; import java.util.Vector; /** * * @author Francesc Busquets (fbusquets@xtec.net) */ public class TripleString extends Object implements Comparable{ public static final int ELEMENTS=3; public static final int NAME=0, CLASS=1, DESCRIPTION=2; public static final char SEP='|'; String[] str; /** Creates a new instance of TripleString */ public TripleString(String name, String className, String description) { str=new String[ELEMENTS]; str[NAME]=name; str[CLASS]=className; str[DESCRIPTION]=description; } public TripleString(String className, String nameAndDescription){ str=new String[ELEMENTS]; str[CLASS]=className; if(nameAndDescription!=null){ nameAndDescription=nameAndDescription.trim(); int p=nameAndDescription.indexOf(SEP); if(p>=0){ str[NAME]=nameAndDescription.substring(0, p); str[DESCRIPTION]=nameAndDescription.substring(p+1); } else{ str[NAME]=nameAndDescription; } } } public String getStr(int index){ return (index>=0 && index=0 && index0) bundleName=bundleName.substring(k+1); File file=new File(System.getProperty("user.home"), bundleName+".properties"); if(file.exists()){ Properties prop=new Properties(); prop.load(new FileInputStream(file)); Iterator it=prop.keySet().iterator(); while(it.hasNext()){ String key=(String)it.next(); String str=prop.getProperty(key); if(str!=null) v.addElement(new TripleString(key, str)); } } } if(sorted) java.util.Collections.sort(v); if(includeEmpty){ v.add(0, new TripleString(options.getMsg("NONE"), null, null)); } return v; } public int compareTo(Object obj) { String s1=(obj instanceof TripleString) ? ((TripleString)obj).getClassName() : obj==null ? "" : obj.toString(); return getClassName().compareTo(s1); } }