org.opencms.relations
Class CmsRelationType

java.lang.Object
  extended by org.opencms.relations.CmsRelationType
All Implemented Interfaces:
java.io.Serializable

public final class CmsRelationType
extends java.lang.Object
implements java.io.Serializable

Wrapper class for the different types of relations.

The possibles values are:

User defined relation types are also available.

Since:
6.3.0
Version:
$Revision: 1.2 $
Author:
Michael Moossen
See Also:
Serialized Form

Field Summary
static CmsRelationType CATEGORY
          Constant for the category of an OpenCmsVfsFile.
static CmsRelationType EMBEDDED_IMAGE
          Constant for the <img src=''> tag in a html page/element.
static CmsRelationType EMBEDDED_OBJECT
          Constant for the <embed src=''> tag in a html page/element.
static CmsRelationType HYPERLINK
          Constant for the <a href=''> tag in a html page/element.
static CmsRelationType JSP_STRONG
          Constant for the all types of links in a jsp file using the link.strong macro.
static CmsRelationType JSP_WEAK
          Constant for the all types of links in a jsp file using the link.weak macro.
static CmsRelationType OU_RESOURCE
          Constant for the organizational units resource associations.
static CmsRelationType XML_STRONG
          Constant for the OpenCmsVfsFile values in xml content that were defined as 'strong' links.
static CmsRelationType XML_WEAK
          Constant for the OpenCmsVfsFile values in xml content that were defined as 'weak' links.
 
Constructor Summary
CmsRelationType(int id, java.lang.String name, java.lang.String type)
          Public constructor for user defined relation types.
 
Method Summary
 boolean equals(java.lang.Object obj)
           
static java.util.List filterDefinedInContent(java.util.Collection relationTypes)
          Returns all relation types in the given list that define relations in the content.
static java.util.List filterInternal(java.util.Collection relationTypes)
          Returns all internal defined relation types in the given list.
static java.util.List filterNotDefinedInContent(java.util.Collection relationTypes)
          Returns all relation types in the given list that are not defined in the content.
static java.util.List filterStrong(java.util.Collection relationTypes)
          Returns all strong relation types in the given list.
static java.util.List filterUserDefined(java.util.Collection relationTypes)
          Returns all user defined relation types in the given list.
static java.util.List filterWeak(java.util.Collection relationTypes)
          Returns all weak relation types in the given list.
static java.util.List getAll()
          Returns all relation types.
static java.util.List getAllDefinedInContent()
          Returns all relation types for relations defined in the content.
static java.util.List getAllInternal()
          Returns all internally defined relation types.
static java.util.List getAllNotDefinedInContent()
          Returns all relation types for relations that are not defined in the content.
static java.util.List getAllStrong()
          Returns all strong relation types.
static java.util.List getAllUserDefined()
          Returns all user defined relation types.
static java.util.List getAllWeak()
          Returns all weak relation types.
 int getId()
          Returns the internal representation of this type.
 java.lang.String getLocalizedName(java.util.Locale locale)
          Returns a localized name for the given relation type.
 java.lang.String getName()
          Returns the type name.
 java.lang.String getNameForXml()
          Returns the type name for xml output.
 java.lang.String getType()
          Returns the string strong or weak.
 int hashCode()
           
 boolean isDefinedInContent()
          Checks if this relation type is defined in the content of a resource or not.
 boolean isInternal()
          Checks if this is an internal relation type.
 boolean isStrong()
          Checks if the relation type is strong or weak.
 java.lang.String toString()
           
static CmsRelationType valueOf(int id)
          Parses an int into a relation type.
static CmsRelationType valueOf(java.lang.String name)
          Parses an String into a relation type.
static CmsRelationType valueOfJsp(java.lang.String name)
          Parses the given value into a valid enumeration element for a JSP relation type.
static CmsRelationType valueOfXml(java.lang.String name)
          Parses the given value into a valid enumeration element for a XML relation type.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

CATEGORY

public static final CmsRelationType CATEGORY
Constant for the category of an OpenCmsVfsFile.


EMBEDDED_IMAGE

public static final CmsRelationType EMBEDDED_IMAGE
Constant for the <img src=''> tag in a html page/element.


EMBEDDED_OBJECT

public static final CmsRelationType EMBEDDED_OBJECT
Constant for the <embed src=''> tag in a html page/element.


HYPERLINK

public static final CmsRelationType HYPERLINK
Constant for the <a href=''> tag in a html page/element.


JSP_STRONG

public static final CmsRelationType JSP_STRONG
Constant for the all types of links in a jsp file using the link.strong macro.


JSP_WEAK

public static final CmsRelationType JSP_WEAK
Constant for the all types of links in a jsp file using the link.weak macro.


OU_RESOURCE

public static final CmsRelationType OU_RESOURCE
Constant for the organizational units resource associations.


XML_STRONG

public static final CmsRelationType XML_STRONG
Constant for the OpenCmsVfsFile values in xml content that were defined as 'strong' links.


XML_WEAK

public static final CmsRelationType XML_WEAK
Constant for the OpenCmsVfsFile values in xml content that were defined as 'weak' links.

Constructor Detail

CmsRelationType

public CmsRelationType(int id,
                       java.lang.String name,
                       java.lang.String type)
Public constructor for user defined relation types.

Parameters:
id - the id of the relation type
name - the name of the relation
type - the type of relation type, strong or weak
Method Detail

filterDefinedInContent

public static java.util.List filterDefinedInContent(java.util.Collection relationTypes)
Returns all relation types in the given list that define relations in the content.

Parameters:
relationTypes - the collection of relation types to filter
Returns:
a list of CmsRelationType objects

filterInternal

public static java.util.List filterInternal(java.util.Collection relationTypes)
Returns all internal defined relation types in the given list.

Parameters:
relationTypes - the collection of relation types to filter
Returns:
a list of CmsRelationType objects

filterNotDefinedInContent

public static java.util.List filterNotDefinedInContent(java.util.Collection relationTypes)
Returns all relation types in the given list that are not defined in the content.

Parameters:
relationTypes - the collection of relation types to filter
Returns:
a list of CmsRelationType objects

filterStrong

public static java.util.List filterStrong(java.util.Collection relationTypes)
Returns all strong relation types in the given list.

Parameters:
relationTypes - the collection of relation types to filter
Returns:
a list of CmsRelationType objects

filterUserDefined

public static java.util.List filterUserDefined(java.util.Collection relationTypes)
Returns all user defined relation types in the given list.

Parameters:
relationTypes - the collection of relation types to filter
Returns:
a list of CmsRelationType objects

filterWeak

public static java.util.List filterWeak(java.util.Collection relationTypes)
Returns all weak relation types in the given list.

Parameters:
relationTypes - the collection of relation types to filter
Returns:
a list of CmsRelationType objects

getAll

public static java.util.List getAll()
Returns all relation types.

Returns:
a list of CmsRelationType objects

getAllDefinedInContent

public static java.util.List getAllDefinedInContent()
Returns all relation types for relations defined in the content.

Returns:
a list of CmsRelationType objects

getAllInternal

public static java.util.List getAllInternal()
Returns all internally defined relation types.

Returns:
a list of CmsRelationType objects

getAllNotDefinedInContent

public static java.util.List getAllNotDefinedInContent()
Returns all relation types for relations that are not defined in the content.

Returns:
a list of CmsRelationType objects

getAllStrong

public static java.util.List getAllStrong()
Returns all strong relation types.

Returns:
a list of CmsRelationType objects

getAllUserDefined

public static java.util.List getAllUserDefined()
Returns all user defined relation types.

Returns:
a list of CmsRelationType objects

getAllWeak

public static java.util.List getAllWeak()
Returns all weak relation types.

Returns:
a list of CmsRelationType objects

valueOf

public static CmsRelationType valueOf(int id)
                               throws CmsIllegalArgumentException
Parses an int into a relation type.

Parameters:
id - the internal representation number to parse
Returns:
the enumeration element
Throws:
CmsIllegalArgumentException - if the given value could not be matched against a CmsRelationType object.

valueOf

public static CmsRelationType valueOf(java.lang.String name)
                               throws CmsIllegalArgumentException
Parses an String into a relation type.

Parameters:
name - the relation type name
Returns:
the enumeration element
Throws:
CmsIllegalArgumentException - if the given value could not be matched against a CmsRelationType object
See Also:
valueOfXml(String), valueOfJsp(String)

valueOfJsp

public static CmsRelationType valueOfJsp(java.lang.String name)
Parses the given value into a valid enumeration element for a JSP relation type.

This should be used to extend Strings like "weak" or "strong" to full relation type descriptors for JSP pages like "JSP_WEAK" or "JSP_STRONG".

Parameters:
name - the name to get the JSP type for
Returns:
the JSP enumeration element
See Also:
valueOf(String)

valueOfXml

public static CmsRelationType valueOfXml(java.lang.String name)
Parses the given value into a valid enumeration element for a XML relation type.

This should be used to extend Strings like "weak" or "strong" to full relation type descriptors for XML documents like "XML_WEAK" or "XML_STRONG".

Parameters:
name - the name to get the XML type for
Returns:
the XML enumeration element
See Also:
valueOf(String)

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object
See Also:
Object.equals(java.lang.Object)

getId

public int getId()
Returns the internal representation of this type.

Returns:
the internal representation of this type

getLocalizedName

public java.lang.String getLocalizedName(java.util.Locale locale)
Returns a localized name for the given relation type.

Parameters:
locale - the locale
Returns:
a localized name

getName

public java.lang.String getName()
Returns the type name.

Returns:
the type name
See Also:
valueOf(String)

getNameForXml

public java.lang.String getNameForXml()
Returns the type name for xml output.

The short type name of XML or JSP types is only "WEAK" or "STRONG". For other types the short name is equal to the name.

In case you need the full type name, use getName().

Returns:
the short type name
See Also:
getName(), valueOfJsp(String), valueOfXml(String)

getType

public java.lang.String getType()
Returns the string strong or weak.

Returns:
the string strong or weak
See Also:
isStrong()

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object
See Also:
Object.hashCode()

isDefinedInContent

public boolean isDefinedInContent()
Checks if this relation type is defined in the content of a resource or not.

Returns:
true if this relation type is defined in the content of a resource

isInternal

public boolean isInternal()
Checks if this is an internal relation type.

Returns:
true if this is an internal relation type

isStrong

public boolean isStrong()
Checks if the relation type is strong or weak.

Returns:
true if the relation type is strong

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()