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 * This class represents a comment that is a part of an article. A comment must have 019 * an ontology element as owner. 020 */ 021 public class Comment extends Statement { 022 023 private String text; 024 025 /** 026 * Loads a comment from a serialized form. 027 * 028 * @param serializedComment The serialized form of the comment. 029 * @param owner The owner ontology element of the comment. 030 * @return The new comment object. 031 */ 032 public static Comment load(String serializedComment, OntologyElement owner) { 033 return new Comment(serializedComment.replaceAll("~n", "\n").replaceAll("~~", "~"), owner); 034 } 035 036 /** 037 * Creates a new comment. 038 * 039 * @param text The comment text. 040 * @param owner The owner ontology element. 041 */ 042 public Comment(String text, OntologyElement owner) { 043 super(owner); 044 this.text = text; 045 } 046 047 public String getText() { 048 return text; 049 } 050 051 String serialize() { 052 return "c " + text.replaceAll("~", "~~").replaceAll("\\n", "~n") + "\n"; 053 } 054 055 }