org.xwiki.extension
Class AbstractExtension

java.lang.Object
  extended by org.xwiki.extension.AbstractExtension
All Implemented Interfaces:
Extension

public abstract class AbstractExtension
extends Object
implements Extension

Base class for Extension implementations.

Since:
4.0M1
Version:
$Id: 920c217715950ca6000d220570094425411e9f8e $

Field Summary
protected  List<ExtensionAuthor> authors
           
protected  List<ExtensionDependency> dependencies
           
protected  String description
           
protected  Set<String> features
           
protected  ExtensionFile file
          The file of the extension.
protected  ExtensionId id
           
protected  List<ExtensionLicense> licenses
           
protected  String name
           
protected  Map<String,Object> properties
           
protected  ExtensionRepository repository
           
protected  String summary
           
protected  String type
           
protected  String website
           
 
Constructor Summary
AbstractExtension(ExtensionRepository repository, Extension extension)
          Create new extension descriptor by copying provided one.
AbstractExtension(ExtensionRepository repository, ExtensionId id, String type)
           
 
Method Summary
 void addAuthor(ExtensionAuthor author)
          Add a new author to the extension.
 void addDependency(ExtensionDependency dependency)
          Add a new dependency to the extension.
 void addFeature(String feature)
          Add a new feature to the extension.
 void addLicense(ExtensionLicense license)
          Add a new license to the extension.
 boolean equals(Object obj)
           
 List<ExtensionAuthor> getAuthors()
           
 List<? extends ExtensionDependency> getDependencies()
           
 String getDescription()
           
 Collection<String> getFeatures()
          The idea is to indicate in an extension a list of provided "functionalities".
 ExtensionFile getFile()
          Return extension file descriptor.
 ExtensionId getId()
           
 Collection<ExtensionLicense> getLicenses()
           
 String getName()
           
 Map<String,Object> getProperties()
          Extends Extension standard properties.
 Object getProperty(String key)
           
<T> T
getProperty(String key, T def)
          Get a property.
 ExtensionRepository getRepository()
           
 String getSummary()
           
 String getType()
           
 String getWebSite()
           
 int hashCode()
           
 void putProperty(String key, Object value)
          Set a property.
protected  void set(Extension extension)
          Update optional informations based on the provided extension.
 void setAuthors(Collection<? extends ExtensionAuthor> authors)
           
 void setDependencies(Collection<? extends ExtensionDependency> dependencies)
           
 void setDescription(String description)
           
 void setFeatures(Collection<String> features)
           
protected  void setFile(ExtensionFile file)
           
protected  void setId(ExtensionId id)
           
 void setLicenses(Collection<ExtensionLicense> licenses)
           
 void setName(String name)
           
 void setProperties(Map<String,Object> properties)
          Replace existing properties with provided properties.
protected  void setRepository(ExtensionRepository repository)
           
 void setSummary(String summary)
           
protected  void setType(String type)
           
 void setWebsite(String website)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

id

protected ExtensionId id
See Also:
getId()

features

protected Set<String> features
See Also:
getFeatures()

type

protected String type
See Also:
getType()

name

protected String name
See Also:
getName()

licenses

protected List<ExtensionLicense> licenses
See Also:
getLicenses()

summary

protected String summary
See Also:
getSummary()

description

protected String description
See Also:
getDescription()

authors

protected List<ExtensionAuthor> authors
See Also:
getAuthors()

website

protected String website
See Also:
getWebSite()

repository

protected ExtensionRepository repository
See Also:
getRepository()

properties

protected Map<String,Object> properties
See Also:
getProperties()

dependencies

protected List<ExtensionDependency> dependencies
See Also:
getDependencies()

file

protected ExtensionFile file
The file of the extension.

Constructor Detail

AbstractExtension

public AbstractExtension(ExtensionRepository repository,
                         ExtensionId id,
                         String type)
Parameters:
repository - the repository where this extension comes from
id - the extension identifier
type - the extension type

AbstractExtension

public AbstractExtension(ExtensionRepository repository,
                         Extension extension)
Create new extension descriptor by copying provided one.

Parameters:
repository - the repository where this extension comes from
extension - the extension to copy
Method Detail

set

protected void set(Extension extension)
Update optional informations based on the provided extension.

Parameters:
extension - the extension from which to get informations

getId

public ExtensionId getId()
Specified by:
getId in interface Extension
Returns:
the id/version combination which makes the extension unique

setId

protected void setId(ExtensionId id)
Parameters:
id - the extension id
See Also:
getId()

getFeatures

public Collection<String> getFeatures()
Description copied from interface: Extension
The idea is to indicate in an extension a list of provided "functionalities". Then when resolving extensions dependencies the dependencies id could be matched in this list.

Specified by:
getFeatures in interface Extension
Returns:
the extension ids also provided by this extension, an empty collection if there is none

setFeatures

public void setFeatures(Collection<String> features)
Parameters:
features - the extension ids also provided by this extension

addFeature

public void addFeature(String feature)
Add a new feature to the extension.

Parameters:
feature - a feature name

getType

public String getType()
Specified by:
getType in interface Extension
Returns:
the type of the extension

setType

protected void setType(String type)
Parameters:
type - the type of the extension
See Also:
getType()

getName

public String getName()
Specified by:
getName in interface Extension
Returns:
the display name of the extension

setName

public void setName(String name)
Parameters:
name - the display name of the extension

getLicenses

public Collection<ExtensionLicense> getLicenses()
Specified by:
getLicenses in interface Extension
Returns:
the license of the extension, an empty collection if there is none

setLicenses

public void setLicenses(Collection<ExtensionLicense> licenses)
Parameters:
licenses - the licenses of the extension

addLicense

public void addLicense(ExtensionLicense license)
Add a new license to the extension.

Parameters:
license - a license

getSummary

public String getSummary()
Specified by:
getSummary in interface Extension
Returns:
a short description of the extension

setSummary

public void setSummary(String summary)
Parameters:
summary - a short description of the extension

getDescription

public String getDescription()
Specified by:
getDescription in interface Extension
Returns:
a description of the extension

setDescription

public void setDescription(String description)
Parameters:
description - a description of the extension

getAuthors

public List<ExtensionAuthor> getAuthors()
Specified by:
getAuthors in interface Extension
Returns:
the extension authors, an empty collection if there is none

setAuthors

public void setAuthors(Collection<? extends ExtensionAuthor> authors)
Parameters:
authors - the authors of the extension

addAuthor

public void addAuthor(ExtensionAuthor author)
Add a new author to the extension.

Parameters:
author - an author

getWebSite

public String getWebSite()
Specified by:
getWebSite in interface Extension
Returns:
an URL for the extension website

setWebsite

public void setWebsite(String website)
Parameters:
website - an URL for the extension website

addDependency

public void addDependency(ExtensionDependency dependency)
Add a new dependency to the extension.

Parameters:
dependency - a dependency

getDependencies

public List<? extends ExtensionDependency> getDependencies()
Specified by:
getDependencies in interface Extension
Returns:
the dependencies of the extension, an empty collection if there is none

setDependencies

public void setDependencies(Collection<? extends ExtensionDependency> dependencies)
Parameters:
dependencies - the dependencies of the extension
See Also:
getDependencies()

getRepository

public ExtensionRepository getRepository()
Specified by:
getRepository in interface Extension
Returns:
the repository of the extension

setRepository

protected void setRepository(ExtensionRepository repository)
Parameters:
repository - the repository of the extension
See Also:
getRepository()

getFile

public ExtensionFile getFile()
Description copied from interface: Extension
Return extension file descriptor. Also allows to get the content of the file.

Specified by:
getFile in interface Extension
Returns:
the file of the extension

setFile

protected void setFile(ExtensionFile file)
Parameters:
file - the file of the extension

getProperties

public Map<String,Object> getProperties()
Description copied from interface: Extension
Extends Extension standard properties.

Theses are generally provided by specific repositories. For example a maven repository will provide group and artifacts ids.

Specified by:
getProperties in interface Extension
Returns:
the properties

getProperty

public Object getProperty(String key)
Specified by:
getProperty in interface Extension
Parameters:
key - the property key
Returns:
the property value

getProperty

public <T> T getProperty(String key,
                         T def)
Description copied from interface: Extension
Get a property.

Specified by:
getProperty in interface Extension
Type Parameters:
T - type of the property value
Parameters:
key - the property key
def - the value to return if no property is associated to the provided key
Returns:
the property value or default of the property is not found
See Also:
Extension.getProperty(String)

putProperty

public void putProperty(String key,
                        Object value)
Set a property.

Parameters:
key - the property key
value - the property value
See Also:
getProperty(String)

setProperties

public void setProperties(Map<String,Object> properties)
Replace existing properties with provided properties.

Parameters:
properties - the properties

toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright © 2004-2013 XWiki. All Rights Reserved.