FileDocCategorySizeDatePackage
GOMLinkImpl.javaAPI DocApache Lucene 2.1.07739Wed Feb 14 10:45:58 GMT 2007org.apache.lucene.gdata.gom.core

GOMLinkImpl

public class GOMLinkImpl extends AbstractGOMElement implements org.apache.lucene.gdata.gom.GOMLink
element atom:link { atomCommonAttributes, attribute href { atomUri }, attribute rel { atomNCName | atomUri }?, attribute type { atomMediaType }?, attribute hreflang { atomLanguageTag }?, attribute title { text }?, attribute length { text }?, undefinedContent }
author
Simon Willnauer

Fields Summary
private String
href
private String
rel
private String
type
private String
hrefLang
private String
title
private Integer
length
Constructors Summary
public GOMLinkImpl()

		super();
		this.localName = LOCALNAME;
		this.qname = new QName(this.localName);
	
Methods Summary
public java.lang.StringgetHref()

see
org.apache.lucene.gdata.gom.GOMLink#getHref()

		return this.href;
	
public java.lang.StringgetHrefLang()

see
org.apache.lucene.gdata.gom.GOMLink#getHrefLang()

		return this.hrefLang;
	
public java.lang.IntegergetLength()

see
org.apache.lucene.gdata.gom.GOMLink#getLength()

		return this.length;
	
public java.lang.StringgetRel()

see
org.apache.lucene.gdata.gom.GOMLink#getRel()

		return this.rel;
	
public java.lang.StringgetTitle()

see
org.apache.lucene.gdata.gom.GOMLink#getTitle()

		return this.title;
	
public java.lang.StringgetType()

see
org.apache.lucene.gdata.gom.GOMLink#getType()

		return this.type;
	
public voidprocessAttribute(javax.xml.namespace.QName aQName, java.lang.String aValue)

see
org.apache.lucene.gdata.gom.core.AbstractGOMElement#processAttribute(javax.xml.namespace.QName, java.lang.String)

		if (aQName == null)
			throw new IllegalArgumentException("QName must not be null");

		if (aQName.getNamespaceURI().equals(GOMNamespace.ATOM_NS_URI)
				|| aQName.getNamespaceURI().equals("")) {
			String localName = aQName.getLocalPart();

			if (localName.equals("href")) {
				if (this.href != null)
					throw new GDataParseException(String.format(
							DUPLICATE_ATTRIBUTE, "href"));
				this.href = aValue;
			} else if (localName.equals("type")) {
				if (this.type != null)
					throw new GDataParseException(String.format(
							DUPLICATE_ATTRIBUTE, "type"));
				this.type = aValue;
			} else if (localName.equals("rel")) {
				if (this.rel != null)
					throw new GDataParseException(String.format(
							DUPLICATE_ATTRIBUTE, "rel"));
				this.rel = aValue;
			} else if (localName.equals("title")) {
				if (this.title != null)
					throw new GDataParseException(String.format(
							DUPLICATE_ATTRIBUTE, "title"));
				this.title = aValue;

			} else if (localName.equals("hreflang")) {
				if (this.hrefLang != null)
					throw new GDataParseException(String.format(
							DUPLICATE_ATTRIBUTE, "hreflang"));
				this.hrefLang = aValue;
			} else if (localName.equals("length")) {
				if (this.length != null)
					throw new GDataParseException(String.format(
							DUPLICATE_ATTRIBUTE, "length"));
				try {
					this.length = new Integer(Integer.parseInt(aValue));
				} catch (NumberFormatException e) {
					throw new GDataParseException(
							"attribute lenght must be an integer");
				}
			}

		}
		super.processAttribute(aQName, aValue);
	
public voidprocessEndElement()

see
org.apache.lucene.gdata.gom.core.AbstractGOMElement#processEndElement()

		if (this.href == null)
			throw new GDataParseException(String.format(
					MISSING_ELEMENT_ATTRIBUTE, this.localName, "href"));
		try {
			AtomParserUtils.getAbsolutAtomURI(this.xmlBase, this.href);
		} catch (URISyntaxException e) {
			throw new GDataParseException(String.format(INVALID_ATTRIBUTE,
					"href", "absolute uri"), e);
		}

	
public voidsetHref(java.lang.String aHref)

see
org.apache.lucene.gdata.gom.GOMLink#setHref(java.lang.String)

		href = aHref;
	
public voidsetHrefLang(java.lang.String aHrefLang)

see
org.apache.lucene.gdata.gom.GOMLink#setHrefLang(java.lang.String)

		hrefLang = aHrefLang;
	
public voidsetLength(java.lang.Integer aLength)

see
org.apache.lucene.gdata.gom.GOMLink#setLength(java.lang.String)

		length = aLength;
	
public voidsetRel(java.lang.String aRel)

see
org.apache.lucene.gdata.gom.GOMLink#setRel(java.lang.String)

		rel = aRel;
	
public voidsetTitle(java.lang.String aTitle)

see
org.apache.lucene.gdata.gom.GOMLink#setTitle(java.lang.String)

		title = aTitle;
	
public voidsetType(java.lang.String aType)

see
org.apache.lucene.gdata.gom.GOMLink#setType(java.lang.String)

		type = aType;
	
public voidwriteAtomOutput(org.apache.lucene.gdata.gom.writer.GOMOutputWriter aStreamWriter)

see
org.apache.lucene.gdata.gom.GOMElement#writeAtomOutput(org.apache.lucene.gdata.gom.writer.GOMStaxWriter)

		List<GOMAttribute> attList = getXmlNamespaceAttributes();
		attList.add(GOMUtils.buildDefaultNamespaceAttribute(
				this.href == null ? "" : this.href, "href"));
		if (this.rel != null)
			attList.add(GOMUtils
					.buildDefaultNamespaceAttribute(this.rel, "rel"));
		if (this.title != null)
			attList.add(GOMUtils.buildDefaultNamespaceAttribute(this.title,
					"title"));
		if (this.type != null)
			attList.add(GOMUtils.buildDefaultNamespaceAttribute(this.type,
					"type"));
		if (this.hrefLang != null)
			attList.add(GOMUtils.buildDefaultNamespaceAttribute(this.hrefLang,
					"hreflang"));
		if (this.length != null)
			attList.add(GOMUtils.buildDefaultNamespaceAttribute(this.length
					.toString(), "length"));

		aStreamWriter.writeSimpleXMLElement(this.qname, attList, null);

	
public voidwriteRssOutput(org.apache.lucene.gdata.gom.writer.GOMOutputWriter aStreamWriter)

see
org.apache.lucene.gdata.gom.GOMElement#writeRssOutput(org.apache.lucene.gdata.gom.writer.GOMStaxWriter)

		List<GOMAttribute> xmlNamespaceAttributes = getXmlNamespaceAttributes();
		if (this.rel != null && rel.equalsIgnoreCase("enclosure")) {
			if (type != null)
				xmlNamespaceAttributes.add(GOMUtils
						.buildDefaultNamespaceAttribute(type, "type"));
			if (href != null)
				xmlNamespaceAttributes.add(GOMUtils
						.buildDefaultNamespaceAttribute(href, "href"));

			aStreamWriter.writeSimpleXMLElement("enclosure",
					xmlNamespaceAttributes, null);
		} else if ("comments".equalsIgnoreCase(this.rel))
			aStreamWriter.writeSimpleXMLElement("comments", null, this.href);

		else if ("alternate".equalsIgnoreCase(this.rel))
			aStreamWriter.writeSimpleXMLElement("link", null, this.href);