/**
* Copyright 1999-2009 The Pegadi Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.pegadi.storysketch.views;
import javax.swing.JPanel;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.pegadi.storysketch.XMLUtil;
public class RDFItem extends JPanel {
String id;
String title;
String description;
String date;
public RDFItem(String id, String title, String description, String date) {
this.id = id;
this.title = title;
this.description = description;
this.date = date;
}
public RDFItem(Element e) {
if(e.getNodeName().equals("item")) {
id = e.getAttribute("id");
title = XMLUtil.extractValue(e, "title");
description = XMLUtil.extractValue(e, "description");
date = XMLUtil.extractValue(e, "date");
}
}
public String getID() {
return id;
}
public String getTitle() {
return title;
}
public String getDescription() {
return description;
}
public String getDate() {
return date;
}
public String toString() {
return title;
}
public Element createElement(Document doc) {
Element item = doc.createElement("item");
item.setAttribute("id", id);
Element titleE = doc.createElement("title");
titleE.appendChild(doc.createTextNode(title));
item.appendChild(titleE);
Element descriptionE = doc.createElement("description");
descriptionE.appendChild(doc.createTextNode(description));
item.appendChild(descriptionE);
Element dateE = doc.createElement("date");
dateE.appendChild(doc.createTextNode(date));
item.appendChild(dateE);
return item;
}
}