net.sourceforge.sconman
Class ContentType

java.lang.Object
  extended by net.sourceforge.sconman.ContentType
All Implemented Interfaces:
IXMLSerializable

public class ContentType
extends java.lang.Object
implements IXMLSerializable

A content type represents a kind of Content.

A content type is defined within the context of a Project, so each project has its own content types that can be different from other projects.

Every content has an associated set of file extensions, that relates files to content types (see getFileExtensions).

Author:
mikeshadow

Field Summary
static int ADD_NEW_PERMISSION
          Permission to add new contents of this type
static int DELETE_PERMISSION
          Permission to delete contents of this type
static int MODIFY_PERMISSION
          Permission to modify contents of this type
static int VIEW_PERMISSION
          Permission to view contents of this type
 
Constructor Summary
ContentType(Project project)
          Creates a new ContentType object.
 
Method Summary
 void addExtensions(java.lang.String extensions)
          Adds a CSV list of file extensions
 Field addField(Field field)
          Adds a new file to this content type
 void addField(java.lang.String id, java.lang.String type, int size, boolean calculated, boolean internationalized, boolean unique, java.lang.String referencedType, java.lang.String defLocale, java.lang.String name, java.lang.String description)
          Adds a Field to the Content Type
 void addFileExtension(java.lang.String ext)
          Adds a new file extension to this content type
 void deserializeXML(org.kxml2.io.KXmlParser in)
          Deserialize from XML
 Category getDefaultCategory()
          Returns the default category for this content type
 java.lang.String getDefaultExtension()
          Returns the defaultExtension
 Field getDefaultField()
          Returns the default field, that is the first one
 java.lang.String getDefaultLocale()
           
 java.lang.String getDescription()
          Returns the content type description in the specified locale
 java.lang.String getDescription(java.lang.String locale)
          Returns the content type description in the specified locale
 Field getField(java.lang.String id)
          Returns a field, known its id
 java.util.Collection getFields()
          Returns all the fields specific to this content type
static java.util.List getFieldTypes()
          Contain a List containing Strings who are allowed Field Types.
 java.util.List getFileExtensions()
          Return all the field extensions associated to this content type
 java.lang.String getFileExtensionsAsString()
          Returns a CSV list with all the field extensions associated to this content type
 IContentTypeHandler getHandler()
          Returns the handler to use when indexing content's data.
 java.lang.String getId()
          Returns the content type id
 java.lang.String getName()
          Returns the content type id in the specified locale
 java.lang.String getName(java.lang.String locale)
          Returns the content type id in the specified locale
 Project getProject()
          Returns the project.
 java.util.List getSortedFields()
          Return the fields in the xml project order
 boolean hasAssociatedFile()
          Returns true if the content type has associated files, or false if this content doesn't have an attached file
 boolean hasUniqueFields()
           
(package private)  boolean isSystem()
          Return true if it is a system category
(package private)  void moveDownField(Field field)
           
(package private)  void moveUpField(Field field)
           
 Content newContent()
          Creates a new content of this type
 void removeField(java.lang.String id)
          Removes the specified field
 void removeFileExtension(java.lang.String ext)
          Removes the specified file extension
 void serializeXML(org.kxml2.io.KXmlSerializer out)
          Serialize to XML
 void setDefaultCategory(Category defaultCategory)
          Sets the default category for this content type
 void setDefaultCategory(java.lang.String category)
          Method setDefaultCategory.
 void setDefaultLocale(java.lang.String defaultLocale)
           
 void setDescription(java.lang.String locale, java.lang.String description)
          Sets the content type description in the specified locale
 void setHandler(IContentTypeHandler handler)
          Sets the handler to use when indexing content's data.
 void setId(java.lang.String id)
          Sets the content type id
 void setName(java.lang.String locale, java.lang.String name)
          Sets the content type id in the specified locale
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

VIEW_PERMISSION

public static final int VIEW_PERMISSION
Permission to view contents of this type

See Also:
Constant Field Values

MODIFY_PERMISSION

public static final int MODIFY_PERMISSION
Permission to modify contents of this type

See Also:
Constant Field Values

DELETE_PERMISSION

public static final int DELETE_PERMISSION
Permission to delete contents of this type

See Also:
Constant Field Values

ADD_NEW_PERMISSION

public static final int ADD_NEW_PERMISSION
Permission to add new contents of this type

See Also:
Constant Field Values
Constructor Detail

ContentType

ContentType(Project project)
Creates a new ContentType object.

Method Detail

toString

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

isSystem

boolean isSystem()
Return true if it is a system category

Returns:

newContent

public Content newContent()
Creates a new content of this type

Returns:
The new content

getFileExtensions

public java.util.List getFileExtensions()
Return all the field extensions associated to this content type

Returns:
A list of String objects

getFileExtensionsAsString

public java.lang.String getFileExtensionsAsString()
Returns a CSV list with all the field extensions associated to this content type

Returns:
A CSV String

addFileExtension

public void addFileExtension(java.lang.String ext)
Adds a new file extension to this content type

Parameters:
ext - The field extension

removeFileExtension

public void removeFileExtension(java.lang.String ext)
Removes the specified file extension

Parameters:
ext - The file extension

getFields

public java.util.Collection getFields()
Returns all the fields specific to this content type

Returns:
A collection of Fieldobjects

getField

public Field getField(java.lang.String id)
Returns a field, known its id

Parameters:
id - Field id
Returns:
The field id

addField

public void addField(java.lang.String id,
                     java.lang.String type,
                     int size,
                     boolean calculated,
                     boolean internationalized,
                     boolean unique,
                     java.lang.String referencedType,
                     java.lang.String defLocale,
                     java.lang.String name,
                     java.lang.String description)
              throws SCMException
Adds a Field to the Content Type

Parameters:
id - Identifier of the Field
type - Type of the Field. Must be a valid Type. Use getFieldTypes()
size - Size of the Field, -1 to unlimited size
calculated - Define if Field is calculated
internationalized - Define if Field is internationalized
unique - Define if Field is Unique
referencedType - If Field is of Type 'Reference' contains referenced Content Type
defLocale - Default locale to store name and description
name - Default Name of Field
description - Default Description of Field
Throws:
SCMException

addField

public Field addField(Field field)
               throws SCMException
Adds a new file to this content type

Parameters:
field - The field to add
Throws:
SCMException

removeField

public void removeField(java.lang.String id)
Removes the specified field

Parameters:
field - The field to remove

getId

public java.lang.String getId()
Returns the content type id

Returns:
The id

setId

public void setId(java.lang.String id)
Sets the content type id

Parameters:
id - The id

getName

public java.lang.String getName()
Returns the content type id in the specified locale

Parameters:
locale -
Returns:

getName

public java.lang.String getName(java.lang.String locale)
Returns the content type id in the specified locale

Parameters:
locale -
Returns:

setName

public void setName(java.lang.String locale,
                    java.lang.String name)
Sets the content type id in the specified locale

Parameters:
locale -
id -

getDescription

public java.lang.String getDescription()
Returns the content type description in the specified locale

Parameters:
locale -
Returns:

getDescription

public java.lang.String getDescription(java.lang.String locale)
Returns the content type description in the specified locale

Parameters:
locale -
Returns:

setDescription

public void setDescription(java.lang.String locale,
                           java.lang.String description)
Sets the content type description in the specified locale

Parameters:
locale -
description -

getDefaultLocale

public java.lang.String getDefaultLocale()
Returns:

setDefaultLocale

public void setDefaultLocale(java.lang.String defaultLocale)
Parameters:
defaultLocale -

getDefaultCategory

public Category getDefaultCategory()
Returns the default category for this content type

Returns:
The default category for this content type

setDefaultCategory

public void setDefaultCategory(Category defaultCategory)
Sets the default category for this content type

Parameters:
defaultCategory - Default category for this content type

getProject

public Project getProject()
Returns the project.

Returns:
Project

addExtensions

public void addExtensions(java.lang.String extensions)
Adds a CSV list of file extensions

Parameters:
extensions - A CSV String with extensions to add

hasAssociatedFile

public boolean hasAssociatedFile()
Returns true if the content type has associated files, or false if this content doesn't have an attached file

Returns:
True if the content type has and associate file that can be requested to the content

setDefaultCategory

public void setDefaultCategory(java.lang.String category)
Method setDefaultCategory.

Parameters:
category -

setHandler

public void setHandler(IContentTypeHandler handler)
Sets the handler to use when indexing content's data. If null, the content is not indexable

Parameters:
handler - The handler to use when indexing content's data.

getHandler

public IContentTypeHandler getHandler()
Returns the handler to use when indexing content's data. If null, the content is not indexable

Returns:
The handler to use when indexing content's data.

getDefaultExtension

public java.lang.String getDefaultExtension()
Returns the defaultExtension

Returns:

hasUniqueFields

public boolean hasUniqueFields()

getFieldTypes

public static java.util.List getFieldTypes()
Contain a List containing Strings who are allowed Field Types.

Returns:
a List containing Strings who are allowed Field Types.

serializeXML

public void serializeXML(org.kxml2.io.KXmlSerializer out)
                  throws java.io.IOException
Description copied from interface: IXMLSerializable
Serialize to XML

Specified by:
serializeXML in interface IXMLSerializable
Parameters:
out - The KXmlSerializer to do the output
Throws:
java.io.IOException - Thrown if there's an IO problem

deserializeXML

public void deserializeXML(org.kxml2.io.KXmlParser in)
                    throws org.xmlpull.v1.XmlPullParserException,
                           java.io.IOException
Description copied from interface: IXMLSerializable
Deserialize from XML

Specified by:
deserializeXML in interface IXMLSerializable
Parameters:
in - The KXml pull parser
Throws:
org.xmlpull.v1.XmlPullParserException - Thrown if there's an XML problem
java.io.IOException - Thrown if there's an IO problem

getSortedFields

public java.util.List getSortedFields()
Return the fields in the xml project order

Returns:
The fields of the content type

getDefaultField

public Field getDefaultField()
Returns the default field, that is the first one

Returns:

moveDownField

void moveDownField(Field field)

moveUpField

void moveUpField(Field field)


Copyright null null. All Rights Reserved.