|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.day.cq.wcm.foundation.Download
public class Download
Provides convenience methods for rendering download paragraphs.
| Field Summary | |
|---|---|
protected Map<String,String> |
attrs
map of tag attributes |
static String |
NN_FILE
name of the file node. |
protected Node |
node
internal node |
static String |
PN_DESCRIPTION
name of the description property |
static String |
PN_FILE_NAME
name of the 'file name' property. |
static String |
PN_REFERENCE
name of the file reference property. |
static String |
PN_TITLE
name of the title property. |
protected org.apache.sling.api.resource.ValueMap |
properties
internal properties |
protected org.apache.sling.api.resource.Resource |
resource
internal resource |
| Constructor Summary | |
|---|---|
Download(org.apache.sling.api.resource.Resource resource)
Creates a new download based on the given resource. |
|
| Method Summary | |
|---|---|
void |
addAttribute(String name,
String value)
Adds a tag attribute to this download. |
void |
addCssClass(String name)
Adds a CSS class name to the respective attribute. |
void |
draw(Writer w)
Writes this download as link tag to the given writer |
String |
get(String name)
Get a property either from the overlaid map or the underlying properties. |
int |
get(String name,
int defaultValue)
Get a property and convert it to an integer. |
Map<String,String> |
getAttributes()
Returns a map of attributes. |
Property |
getData()
Returns the property that contains the binary data of this download. |
String |
getDescription()
Returns the image description as defined by getItemName(PN_DESCRIPTION) or overridden by setDescription(String). |
String |
getDescription(boolean escape)
Returns the image description as defined by 'getItemName(PN_DESCRIPTION)' or overridden by setDescription(String). |
String |
getExtension()
Returns the extension. |
String |
getFileName()
Returns the file name of this download as defined by the property with the name from 'getItemName(PN_FILE_NAME). |
String |
getFileNodePath()
Returns the file path. |
String |
getFileReference()
Returns the file reference. |
String |
getHref()
Returns the href attribute of this download. |
String |
getIconPath()
Returns a path to an icon representing the file. |
String |
getIconType()
Returns the icon type of this file. |
Object |
getInnerHtml()
Returns the inner html object for the download link. |
String |
getItemName(String name)
Returns the name of the given item which is either the default or can be redefined by setItemName(String, String). |
Calendar |
getLastModified()
Returns the last modified of this image. |
String |
getMimeType()
Returns the mime type of this image. |
org.apache.sling.api.resource.Resource |
getResource()
Returns the underlying resource. |
String |
getSelector()
Returns the selector string. |
String |
getString()
Returns a string representation as HTML tag of this image. |
String |
getSuffix()
Returns the suffix. |
String |
getTitle()
Returns the image title as defined by 'getItemName(PN_TITLE)' or overridden by setTitle(String). |
String |
getTitle(boolean escape)
Returns the image title as defined by 'getItemName(PN_TITLE)' or overridden by setTitle(String). |
boolean |
hasContent()
Checks if this download has content. |
void |
init()
Calculates all default values if 'source' is null |
void |
set(String name,
String value)
Set a property to the overlaid map. |
void |
setDescription(String description)
Sets the description. |
void |
setExtension(String extension)
Sets the extension. |
void |
setFileName(String fileName)
Sets the file name. |
void |
setFileNodePath(String fileNodePath)
Sets the path to the file node. |
void |
setFileReference(String fileReference)
Sets the file reference. |
void |
setHref(String href)
Sets the href attribute |
void |
setInnerHtml(Object innerHtml)
Sets the inner html object for the download. |
void |
setItemName(String key,
String name)
Defines the name of an item. |
void |
setSelector(String selector)
Sets the selector string. |
void |
setSuffix(String suffix)
Sets the suffix. |
void |
setTitle(String title)
Sets the title. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String PN_REFERENCE
public static final String NN_FILE
public static final String PN_FILE_NAME
public static final String PN_TITLE
public static final String PN_DESCRIPTION
protected final org.apache.sling.api.resource.Resource resource
protected final org.apache.sling.api.resource.ValueMap properties
protected final Node node
protected Map<String,String> attrs
| Constructor Detail |
|---|
public Download(org.apache.sling.api.resource.Resource resource)
resource - resource of the image
IllegalArgumentException - if the given resource is not adaptable to node.| Method Detail |
|---|
public org.apache.sling.api.resource.Resource getResource()
public String get(String name)
name - name of the property
public int get(String name,
int defaultValue)
name - name of the propertydefaultValue - default value
public void set(String name,
String value)
name - name of the propertyvalue - value of the property
public void addAttribute(String name,
String value)
drawing the tag.
name - name of the attributevalue - value of the attributepublic void addCssClass(String name)
name - the class namepublic void init()
null
public String getItemName(String name)
setItemName(String, String). If the name
is not defined, the given name is returned.
Example: Donwload.getItemName(Download.PN_FILE_NAME)
name - item name
public void setItemName(String key,
String name)
key - key. eg PN_FILE_NAME.name - redefined namepublic String getFileReference()
public void setFileReference(String fileReference)
fileReference - the file reference.public Object getInnerHtml()
null if not defined.public void setInnerHtml(Object innerHtml)
innerHtml - the inner html objectpublic String getFileNodePath()
public void setFileNodePath(String fileNodePath)
fileNodePath - path of the file node.public String getFileName()
public void setFileName(String fileName)
fileName - the file namepublic String getTitle()
setTitle(String).
public String getTitle(boolean escape)
setTitle(String).
escape - if true the string is HTML escaped
public void setTitle(String title)
title - the title.public String getDescription()
setDescription(String).
public String getDescription(boolean escape)
setDescription(String).
escape - if true the string is HTML escaped
public void setDescription(String description)
description - the description.public String getHref()
public void setHref(String href)
href - the href attributepublic String getExtension()
.res
- Returns:
- the extension.
public void setExtension(String extension)
extension - the extension.public String getIconType()
public String getIconPath()
null.public String getSuffix()
""
- Returns:
- the suffix.
public void setSuffix(String suffix)
suffix - the suffix.public String getSelector()
public void setSelector(String selector)
selector - the selector string.public boolean hasContent()
true if this download has content.
public void draw(Writer w)
throws IOException
w - the writer
IOException - if an I/O error occurspublic String getString()
public String getMimeType()
throws RepositoryException
getData().
RepositoryException - if an error accessing the repository occurs.
public Calendar getLastModified()
throws RepositoryException
getData().
RepositoryException - if an error accessing the repository occurs.
public Property getData()
throws RepositoryException
null
RepositoryException - if an error accessing the repository occurs.public Map<String,String> getAttributes()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||