// XAAL toolkit // Copyright (C) 2009 Ville Karavirta // // 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 3 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. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . package xaal.objects.metadata; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import xaal.util.EmptyIterator; /** * This class represents metadata about a Xaal animation. */ public class Metadata { // TODO Add support for multiple languages. private List authors; private List keywords; private List applications; private String desc; private String subject; private String title; /** * Constructs a Metadata instance. */ public Metadata() { super(); } /** * Adds an author of the animation. * * @param a The author to add. */ public void addAuthor(Author a) { if (authors == null) authors = new LinkedList(); authors.add(a); } /** * Adds a keyword describing this animation. * * @param keyword The keyword to add. */ public void addKeyword(String keyword) { if (keywords == null) keywords = new LinkedList(); keywords.add(keyword); } /** * Adds an application used to create the animation. * * @param a The application to add. */ public void addApplication(Application a) { if (applications == null) applications = new LinkedList(); applications.add(a); } public String toString() { StringBuffer toStr = new StringBuffer(); Iterator auths = getAuthors(); while (auths.hasNext()) toStr.append("Author: ").append(auths.next()).append("\n"); // TODO Metadata.toString add application strings /* * if (getApplicationName() != null) { toStr += "Application: " + * getApplicationName(); if (getApplicationVersion() != null) toStr += ", * v" + getApplicationVersion(); if (getApplicationHomepage() != null) * toStr += " (" + getApplicationHomepage() + ")"; toStr += "\n"; } */ if (title != null) toStr.append("Animation: ").append(getTitle()).append("\n"); if (subject != null) toStr.append("Subject: ").append(getSubject()).append("\n"); Iterator keys = getKeywords(); while (keys.hasNext()) toStr.append("Keyword: ").append(keys.next()).append("\n"); if (desc != null) toStr.append("Description: ").append(desc).append("\n"); return toStr.toString(); } /** * Returns an Iterator of the keywords. * * @return Iterator of the keywords. */ public Iterator getKeywords() { if (keywords == null) { return new EmptyIterator(); } return keywords.listIterator(); } /** * Returns an Iterator of the authors. * * @return Iterator of the authors. */ public Iterator getAuthors() { if (authors == null) { return new EmptyIterator(); } return authors.listIterator(); } /** * Sets the description of the animation. * * @param string The description to set. */ public void setDesc(String string) { this.desc = string; } /** * Returns the description of the animation. * * @return The description. */ public String getDesc() { return desc; } /** * Returns the subject of the animation. * * @return The subject. */ public String getSubject() { return subject; } /** * Sets the subject of the animation. * * @param subject The subject to set. */ public void setSubject(String subject) { this.subject = subject; } /** * Returns the title of the animation. * * @return The title. */ public String getTitle() { return title; } /** * Sets the title of the animation. * * @param title The title to set. */ public void setTitle(String title) { this.title = title; } /** * Returns an Iterator of the application. * * @return Iterator of the applications. */ public Iterator getApplications() { if (applications == null) { return new EmptyIterator(); } return applications.iterator(); } }