001 // This file is part of the Attempto Java Packages. 002 // Copyright 2008-2009, Attempto Group, University of Zurich (see http://attempto.ifi.uzh.ch). 003 // 004 // The Attempto Java Packages is free software: you can redistribute it and/or modify it under the 005 // terms of the GNU Lesser General Public License as published by the Free Software Foundation, 006 // either version 3 of the License, or (at your option) any later version. 007 // 008 // The Attempto Java Packages is distributed in the hope that it will be useful, but WITHOUT ANY 009 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 010 // PURPOSE. See the GNU Lesser General Public License for more details. 011 // 012 // You should have received a copy of the GNU Lesser General Public License along with the Attempto 013 // Java Packages. If not, see http://www.gnu.org/licenses/. 014 015 package ch.uzh.ifi.attempto.acewiki.core.ontology; 016 017 018 /** 019 * This class represents a comment that is a part of an article. A comment must have 020 * an ontology element as owner. 021 */ 022 public class Comment extends Statement { 023 024 private final String text; 025 026 /** 027 * Loads a comment from a serialized form. 028 * 029 * @param serializedComment The serialized form of the comment. 030 * @param owner The owner ontology element of the comment. 031 * @return The new comment object. 032 */ 033 public static Comment load(String serializedComment, OntologyElement owner) { 034 return new Comment(serializedComment.replaceAll("~n", "\n").replaceAll("~t", "~"), owner); 035 } 036 037 /** 038 * Creates a new comment. 039 * 040 * @param text The comment text. 041 * @param owner The owner ontology element. 042 */ 043 public Comment(String text, OntologyElement owner) { 044 super(owner); 045 this.text = text; 046 } 047 048 public String getText() { 049 return text; 050 } 051 052 String serialize() { 053 return "c " + text.replaceAll("~", "~t").replaceAll("\\n", "~n") + "\n"; 054 } 055 056 }