org.activemath.content.items
Class Item

java.lang.Object
  extended by org.activemath.content.items.Item
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
DynamicItem, ExerciseItem, TheoryItem

public class Item
extends Object
implements Serializable

Java abstraction of a content item. Implements Serializable for use as cache objects in org.apache.cache.Cache. Since we are not using a persistent cache, no care has been taken to provide a custom serialization. See Chapter 10 of "Effective Java" by Joshua Bloch.

See Also:
Serialized Form

Field Summary
protected  Map<String,List<String>> copyrights
           
protected  List<Dependency> dependsOn
           
protected  ItemFactory factory
           
protected  FlavorSet flavorSet
           
protected  String forId
           
protected  List<String> forIds
           
protected  String id
           
protected static Logger log
           
protected  MBaseID mbaseId
           
protected  Metadata metadata
           
protected  String omdocTag
           
protected  String omdocType
           
protected  List<Dependency> relatedTo
           
protected  List<ItemRelation> relationsIn
           
protected  List<ItemRelation> relationsOut
           
protected  boolean shouldUseTitleFromID
           
protected  String theoryId
           
protected  String title
           
protected  Map<String,String> titles
           
 
Constructor Summary
Item(String id)
           
 
Method Summary
 boolean equals(Object o)
           
 Map<String,List<String>> getCopyrightData()
           
 OJElement getCopyrightElement()
           
 List<Dependency> getDependsOn()
          Deprecated. use getOutgoingRelations() instead
 String getDifficulty()
          Deprecated. use getMetadata().getDifficulty(), now depends on learning context.
 FlavorSet getFlavorSet()
           
 String getForId()
           
 List<String> getForIds()
           
 OJElement getFullDOM()
          Provide the full DOM tree for this item, wrapped in a theory element.
 String getId()
           
 List<ItemRelation> getIncomingRelations()
           
 MBaseID getMBaseId()
           
 Metadata getMetadata()
           
 OJElement getMetadataElement()
           
 int getNumWords()
           
 String getOmdocTag()
           
 String getOmdocType()
           
 List<ItemRelation> getOutgoingRelations()
          Get or build outgoing relations for this item.
 List<Dependency> getRelatedTo()
          Deprecated. use getIncomingRelations() instead
 String getSystemId()
           
 OJElement getTextualDOM()
          Construct the DOM tree for the textual representation of this item.
 String getTheoryId()
           
 String getTitle()
          Get "default" title, which is the first title we get from mbase.getCommonName().
 String getTitle(String lang)
          Get localized item title, without fallback to default language
 String getTitle(String lang, String defaultLang)
          Get localized item title, with fallback to default language
 Map<String,String> getTitles()
           
 boolean hasFlavors()
           
 int hashCode()
           
 void setUseTitleFromID(boolean should)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

log

protected static Logger log

factory

protected ItemFactory factory

id

protected String id

mbaseId

protected MBaseID mbaseId

title

protected String title

shouldUseTitleFromID

protected boolean shouldUseTitleFromID

titles

protected Map<String,String> titles

omdocTag

protected String omdocTag

omdocType

protected String omdocType

copyrights

protected Map<String,List<String>> copyrights

metadata

protected Metadata metadata

forId

protected String forId

forIds

protected List<String> forIds

theoryId

protected String theoryId

dependsOn

protected List<Dependency> dependsOn

relatedTo

protected List<Dependency> relatedTo

relationsOut

protected List<ItemRelation> relationsOut

relationsIn

protected List<ItemRelation> relationsIn

flavorSet

protected FlavorSet flavorSet
Constructor Detail

Item

public Item(String id)
Method Detail

getNumWords

public int getNumWords()

getTextualDOM

public OJElement getTextualDOM()
Construct the DOM tree for the textual representation of this item.

metadataand CMP children are fetched from MBase and put inside a theory element.

Returns:
this item in its textual DOM representation, or null if there is a problem.

getFullDOM

public OJElement getFullDOM()
Provide the full DOM tree for this item, wrapped in a theory element.

This code is very similar to getTextualDOM() but fetches everything in one go instead of first getting the metadata element and then only the CMP.

Returns:
theory element with item content inside, or null if there is an error.

getSystemId

public String getSystemId()

getId

public String getId()

getMBaseId

public MBaseID getMBaseId()

getTitles

public Map<String,String> getTitles()

getTitle

public String getTitle()
Get "default" title, which is the first title we get from mbase.getCommonName().

Returns:
must not return null.

setUseTitleFromID

public void setUseTitleFromID(boolean should)

getTitle

public String getTitle(String lang)
Get localized item title, without fallback to default language


getTitle

public String getTitle(String lang,
                       String defaultLang)
Get localized item title, with fallback to default language

Parameters:
lang -
defaultLang -
Returns:
Return localized title for this item, either in
  • requested language
  • requested default language
  • this.title, which is any title we get from mbase.getCommonName()

    getOmdocTag

    public String getOmdocTag()
    Returns:

    getOmdocType

    public String getOmdocType()
    Returns:

    getMetadata

    public Metadata getMetadata()
    Returns:
    metadata object for this item

    getCopyrightData

    public Map<String,List<String>> getCopyrightData()

    getMetadataElement

    public OJElement getMetadataElement()

    getCopyrightElement

    public OJElement getCopyrightElement()

    getTheoryId

    public String getTheoryId()

    getDifficulty

    public String getDifficulty()
    Deprecated. use getMetadata().getDifficulty(), now depends on learning context.


    getOutgoingRelations

    public List<ItemRelation> getOutgoingRelations()
    Get or build outgoing relations for this item.

    Relation list is initialized lazily on first access.

    Outgoing relations are based on MBaseRef.getDependencies(), whose result is turned into a list of ItemRelation objects.

    Returns:
    List of ItemRelation objects (empty on MBase error)

    getIncomingRelations

    public List<ItemRelation> getIncomingRelations()

    getDependsOn

    public List<Dependency> getDependsOn()
    Deprecated. use getOutgoingRelations() instead

    Get "depends-on" dependencies for this item. Dependency list is initialized lazily on first access.

    Returns:
    List of Dependencies (empty on MBase error)

    getRelatedTo

    public List<Dependency> getRelatedTo()
    Deprecated. use getIncomingRelations() instead

    Get "related-to" dependencies for this item. Dependency list is initialized lazily on first access.

    Returns:
    List of Dependencies (empty on MBase error)

    getForIds

    public List<String> getForIds()
    Returns:
    result of MBaseRef.getForWhat() (List of Strings (item ids))

    getForId

    public String getForId()
    Returns:
    value of the "for" attribute of this item.

    getFlavorSet

    public FlavorSet getFlavorSet()
    Returns:
    the associated FlavorSet

    hasFlavors

    public boolean hasFlavors()
    Returns:
    true if flavors are available for this item

    toString

    public String toString()
    Overrides:
    toString in class Object

    equals

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

    hashCode

    public int hashCode()
    Overrides:
    hashCode in class Object