001: /*---------------------------------------------------------------------------*\
002: $Id: RSSContent.java 7041 2007-09-09 01:04:47Z bmc $
003: ---------------------------------------------------------------------------
004: This software is released under a BSD-style license:
005:
006: Copyright (c) 2004-2007 Brian M. Clapper. All rights reserved.
007:
008: Redistribution and use in source and binary forms, with or without
009: modification, are permitted provided that the following conditions are
010: met:
011:
012: 1. Redistributions of source code must retain the above copyright notice,
013: this list of conditions and the following disclaimer.
014:
015: 2. The end-user documentation included with the redistribution, if any,
016: must include the following acknowlegement:
017:
018: "This product includes software developed by Brian M. Clapper
019: (bmc@clapper.org, http://www.clapper.org/bmc/). That software is
020: copyright (c) 2004-2007 Brian M. Clapper."
021:
022: Alternately, this acknowlegement may appear in the software itself,
023: if wherever such third-party acknowlegements normally appear.
024:
025: 3. Neither the names "clapper.org", "curn", nor any of the names of the
026: project contributors may be used to endorse or promote products
027: derived from this software without prior written permission. For
028: written permission, please contact bmc@clapper.org.
029:
030: 4. Products derived from this software may not be called "curn", nor may
031: "clapper.org" appear in their names without prior written permission
032: of Brian M. Clapper.
033:
034: THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
035: WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
036: MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
037: NO EVENT SHALL BRIAN M. CLAPPER BE LIABLE FOR ANY DIRECT, INDIRECT,
038: INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
039: NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
040: DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
041: THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
042: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
043: THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
044: \*---------------------------------------------------------------------------*/
045:
046: package org.clapper.curn.parser;
047:
048: /**
049: * Represents arbitrary content. Basically, an object of this type just
050: * associates some content with a MIME type. Currently, it only handles
051: * string (text) content.
052: *
053: * @version <tt>$Revision: 7041 $</tt>
054: */
055: public class RSSContent {
056: /*----------------------------------------------------------------------*\
057: Private Instance Data
058: \*----------------------------------------------------------------------*/
059:
060: private String mimeType;
061: private String content;
062:
063: /*----------------------------------------------------------------------*\
064: Constructor
065: \*----------------------------------------------------------------------*/
066:
067: /**
068: * Creates a new instance of <tt>RSSContent</tt>
069: *
070: * @param content the content
071: * @param mimeType the MIME type
072: */
073: public RSSContent(final String content, final String mimeType) {
074: this .content = content;
075: this .mimeType = mimeType;
076: }
077:
078: /*----------------------------------------------------------------------*\
079: Public Methods
080: \*----------------------------------------------------------------------*/
081:
082: /**
083: * Get the content stored in this object.
084: *
085: * @return the content
086: */
087: public String getTextContent() {
088: return content;
089: }
090:
091: /**
092: * Get the MIME type associated with the content.
093: *
094: * @return the MIME type
095: */
096: public String getMIMEType() {
097: return mimeType;
098: }
099:
100: /**
101: * Get a string representation of this object.
102: *
103: * @return a string representation
104: */
105: @Override
106: public String toString() {
107: StringBuilder buf = new StringBuilder();
108:
109: buf.append('(');
110: buf.append(mimeType);
111: buf.append(") ");
112:
113: if (content.length() > 30) {
114: buf.append(content.substring(0, 30));
115: buf.append("...");
116: }
117:
118: else {
119: buf.append(content);
120: }
121:
122: return buf.toString();
123: }
124:
125: /*----------------------------------------------------------------------*\
126: Protected Methods
127: \*----------------------------------------------------------------------*/
128:
129: /*----------------------------------------------------------------------*\
130: Private Methods
131: \*----------------------------------------------------------------------*/
132: }
|