001: /**
002: * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, version 2.1, dated February 1999.
003: *
004: * This program is free software; you can redistribute it and/or modify
005: * it under the terms of the latest version of the GNU Lesser General
006: * Public License as published by the Free Software Foundation;
007: *
008: * This program is distributed in the hope that it will be useful,
009: * but WITHOUT ANY WARRANTY; without even the implied warranty of
010: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
011: * GNU Lesser General Public License for more details.
012: *
013: * You should have received a copy of the GNU Lesser General Public License
014: * along with this program (LICENSE.txt); if not, write to the Free Software
015: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
016: */package org.jamwiki.model;
017:
018: import org.apache.commons.lang.StringUtils;
019: import org.jamwiki.utils.Utilities;
020: import org.jamwiki.utils.WikiLogger;
021:
022: /**
023: * Provides an object representing a Wiki reference, which is a citation
024: * appearing within a Wiki topic.
025: */
026: public class WikiReference {
027:
028: private static final WikiLogger logger = WikiLogger
029: .getLogger(WikiReference.class.getName());
030:
031: private final int citation;
032: private String content;
033: private final int count;
034: private final String name;
035:
036: /**
037: *
038: */
039: public WikiReference(String name, String content, int citation,
040: int count) {
041: this .name = name;
042: this .content = content;
043: this .citation = citation;
044: this .count = count;
045: }
046:
047: /**
048: *
049: */
050: public int getCitation() {
051: return this .citation;
052: }
053:
054: /**
055: *
056: */
057: public String getContent() {
058: return this .content;
059: }
060:
061: /**
062: *
063: */
064: public void setContent(String content) {
065: this .content = content;
066: }
067:
068: /**
069: *
070: */
071: public int getCount() {
072: return this .count;
073: }
074:
075: /**
076: *
077: */
078: public String getName() {
079: return this .name;
080: }
081:
082: /**
083: *
084: */
085: public String getNotationName() {
086: if (StringUtils.isBlank(this .name)) {
087: return "_note-" + this .citation;
088: }
089: return "_note-" + Utilities.encodeForURL(this .name);
090: }
091:
092: /**
093: *
094: */
095: public String getReferenceName() {
096: if (StringUtils.isBlank(this .name)) {
097: return "_ref-" + this .citation;
098: }
099: return "_ref-" + Utilities.encodeForURL(this .name) + "_"
100: + this.count;
101: }
102: }
|