Google Data APIs Client Library (1.41.1)



com.google.gdata.data
Class TextConstruct

java.lang.Object
  extended by com.google.gdata.data.TextConstruct
All Implemented Interfaces:
ITextConstruct
Direct Known Subclasses:
HtmlTextConstruct, PlainTextConstruct, XhtmlTextConstruct

public abstract class TextConstruct
extends java.lang.Object
implements ITextConstruct

Abstract base class for text construct type.


Nested Class Summary
static class TextConstruct.ChildHandlerInfo
          Return type for getChildHandler(Attributes); contains an element handler and a text construct.
static class TextConstruct.RssFormat
          Enumerates the kinds of restrictions on what HTML tags are allowed.
static class TextConstruct.Type
          Defines the possible text construct types: TEXT, HTML, and XHTML.
 
Field Summary
protected  java.lang.String lang
          Language.
 
Constructor Summary
TextConstruct()
           
 
Method Summary
static TextConstruct create(int type, java.lang.String textOrHtml, XmlBlob xhtml)
          Creates a text construct.
abstract  void generateAtom(com.google.gdata.util.common.xml.XmlWriter w, java.lang.String elementName)
          Generates XML in the Atom format.
abstract  void generateRss(com.google.gdata.util.common.xml.XmlWriter w, java.lang.String elementName, TextConstruct.RssFormat rssFormat)
          Generates XML in the RSS format.
static TextConstruct.ChildHandlerInfo getChildHandler(org.xml.sax.Attributes attrs)
          Parses XML in the Atom format.
 java.lang.String getLang()
           
abstract  java.lang.String getPlainText()
          Returns a plain-text representation of this text construct.
abstract  int getType()
          Returns this text construct's type (text, HTML, or XHTML).
static TextConstruct html(java.lang.String html)
          Construct a new html text content with the given html.
abstract  boolean isEmpty()
          Returns true if this text construct has no contents.
static TextConstruct plainText(java.lang.String text)
          Construct a new plain text content with the given text.
 void setLang(java.lang.String v)
          Specifies the human language that this text construct is written in.
static TextConstruct xhtml(XmlBlob div)
          Construct a new Xhtml text content from the given div.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lang

protected java.lang.String lang
Language. Derived from the current state of xml:lang.

Constructor Detail

TextConstruct

public TextConstruct()
Method Detail

getType

public abstract int getType()
Returns this text construct's type (text, HTML, or XHTML).

Specified by:
getType in interface ITextConstruct
Returns:
an integer value of 1 to represent TEXT, 2 to represent HTML, or 3 to represent XHTML.

isEmpty

public abstract boolean isEmpty()
Returns true if this text construct has no contents.


getPlainText

public abstract java.lang.String getPlainText()
Returns a plain-text representation of this text construct.

Specified by:
getPlainText in interface ITextConstruct

getLang

public java.lang.String getLang()
Returns:
the human language that this text construct is written in

setLang

public void setLang(java.lang.String v)
Specifies the human language that this text construct is written in.


create

public static TextConstruct create(int type,
                                   java.lang.String textOrHtml,
                                   XmlBlob xhtml)
Creates a text construct. This method is convenient for some service implementations. Note that XHTML is treated somewhat differently from text and HTML.

Parameters:
type - the type of the new text construct (TEXT, HTML, or XHTML)
textOrHtml - the contents to put in this text construct, if the type is TEXT or HTML. If type is XHTML, set this parameter to null.
xhtml - the contents to put in this text construct, if the type is XHTML. If type is TEXT or HTML, set this parameter to null.
Returns:
a TextConstruct, or null if invalid type.

plainText

public static TextConstruct plainText(java.lang.String text)
Construct a new plain text content with the given text.


html

public static TextConstruct html(java.lang.String html)
Construct a new html text content with the given html.


xhtml

public static TextConstruct xhtml(XmlBlob div)
Construct a new Xhtml text content from the given div.


generateAtom

public abstract void generateAtom(com.google.gdata.util.common.xml.XmlWriter w,
                                  java.lang.String elementName)
                           throws java.io.IOException
Generates XML in the Atom format.

Parameters:
w - output writer
elementName - Atom element name
Throws:
java.io.IOException

generateRss

public abstract void generateRss(com.google.gdata.util.common.xml.XmlWriter w,
                                 java.lang.String elementName,
                                 TextConstruct.RssFormat rssFormat)
                          throws java.io.IOException
Generates XML in the RSS format.

Parameters:
w - output writer
elementName - RSS element name
rssFormat - the restrictions on what HTML tags are allowed
Throws:
java.io.IOException

getChildHandler

public static TextConstruct.ChildHandlerInfo getChildHandler(org.xml.sax.Attributes attrs)
                                                      throws ParseException,
                                                             java.io.IOException
Parses XML in the Atom format.

Parameters:
attrs - XML attributes of the root TextConstruct node. Used to determine the type of this node.
Returns:
a child handler
Throws:
ParseException
java.io.IOException