org.jopendocument.dom
Class StyleDesc<S extends Style>

java.lang.Object
  extended by org.jopendocument.dom.StyleDesc<S>
Type Parameters:
S - type of style
Direct Known Subclasses:
DataStyle.DataStyleDesc, StyleStyleDesc

public abstract class StyleDesc<S extends Style>
extends Object

Describe a family of style.

Author:
Sylvain CUAZ

Constructor Summary
protected StyleDesc(Class<S> clazz, XMLVersion version, String elemName, String baseName)
           
protected StyleDesc(Class<S> clazz, XMLVersion version, String elemName, String baseName, String ns, List<String> refQNames)
           
 
Method Summary
static
<C extends Style>
StyleDesc<C>
copy(StyleDesc<C> toClone, XMLVersion version)
           
abstract  S create(ODPackage pkg, org.jdom.Element e)
           
 S createAutoStyle(ODPackage pkg)
           
 S createAutoStyle(ODPackage pkg, String baseName)
          Create a new automatic style in the content of pkg.
 S createCommonStyle(ODPackage pkg, String styleName)
           
protected  org.jdom.Element createElement(String styleName)
           
protected  org.jdom.Element evaluateConditions(StyledNode<S,?> styledNode, List<org.jdom.Element> styleMaps)
           
 S findStyleForNode(ODPackage pkg, org.jdom.Document doc, StyledNode<S,?> styledNode, String name)
           
 S findStyleForNode(StyledNode<S,?> styledNode, String name)
          Find the style for the passed node.
 S findStyleWithName(ODPackage pkg, org.jdom.Document doc, String name)
          Resolve the passed style name.
 String getBaseName()
           
 String getElementName()
          The name of the XML element for this type of style.
 org.jdom.Namespace getElementNS()
           
protected  CollectionMap<String,String> getMultiRefElementsMap()
           
protected  Collection<String> getRefElements()
          The list of elements that can point to this family of style.
protected  CollectionMap<String,String> getRefElementsMap()
           
 XMLVersion getVersion()
           
protected  void initStyle(org.jdom.Element elem)
           
protected  void setElementNS(org.jdom.Namespace elemNS)
           
protected  boolean supportConditions()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StyleDesc

protected StyleDesc(Class<S> clazz,
                    XMLVersion version,
                    String elemName,
                    String baseName,
                    String ns,
                    List<String> refQNames)

StyleDesc

protected StyleDesc(Class<S> clazz,
                    XMLVersion version,
                    String elemName,
                    String baseName)
Method Detail

copy

public static <C extends Style> StyleDesc<C> copy(StyleDesc<C> toClone,
                                                  XMLVersion version)

create

public abstract S create(ODPackage pkg,
                         org.jdom.Element e)

getVersion

public final XMLVersion getVersion()

setElementNS

protected final void setElementNS(org.jdom.Namespace elemNS)

getElementNS

public final org.jdom.Namespace getElementNS()

getElementName

public final String getElementName()
The name of the XML element for this type of style.

Returns:
the name of the element, e.g. "style" or "master-page".

getBaseName

public final String getBaseName()

getRefElements

protected final Collection<String> getRefElements()
The list of elements that can point to this family of style.

Returns:
a list of qualified names, e.g. ["text:h", "text:p"].

getRefElementsMap

protected final CollectionMap<String,String> getRefElementsMap()

getMultiRefElementsMap

protected final CollectionMap<String,String> getMultiRefElementsMap()

findStyleWithName

public final S findStyleWithName(ODPackage pkg,
                                 org.jdom.Document doc,
                                 String name)
Resolve the passed style name. Note: this always return the style named name, possibly ignoring conditions.

Parameters:
pkg - the package of the searched for style.
doc - the document of the searched for style.
name - the name of the style.
Returns:
the corresponding style, null if not found.
See Also:
findStyleForNode(StyledNode, String)

findStyleForNode

public final S findStyleForNode(StyledNode<S,?> styledNode,
                                String name)
Find the style for the passed node. Depending on conditions the returned style might not be named name.

Parameters:
styledNode - needed to evaluate conditions, not null.
name - the name of the style.
Returns:
the corresponding style, null if not found.
See Also:
findStyleWithName(ODPackage, Document, String)

findStyleForNode

public final S findStyleForNode(ODPackage pkg,
                                org.jdom.Document doc,
                                StyledNode<S,?> styledNode,
                                String name)

supportConditions

protected boolean supportConditions()

evaluateConditions

protected org.jdom.Element evaluateConditions(StyledNode<S,?> styledNode,
                                              List<org.jdom.Element> styleMaps)

createAutoStyle

public final S createAutoStyle(ODPackage pkg)

createAutoStyle

public final S createAutoStyle(ODPackage pkg,
                               String baseName)
Create a new automatic style in the content of pkg.

Parameters:
pkg - where to add the new style.
baseName - the base name for the new style, eg "ce".
Returns:
the new style, eg named "ce3".

createCommonStyle

public final S createCommonStyle(ODPackage pkg,
                                 String styleName)

createElement

protected final org.jdom.Element createElement(String styleName)

initStyle

protected void initStyle(org.jdom.Element elem)

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2010 jOpenDocument All Rights Reserved.