cz.kebrt.html2latex
Class Configuration

java.lang.Object
  extended by cz.kebrt.html2latex.Configuration

 class Configuration
extends java.lang.Object

Program configuration. All of the configuration from the XML configuration file is stored in this class.


Field Summary
private  java.lang.String _commandsPrefix
          Prefix of new LaTeX commands generated by the program.
private  java.util.HashMap<java.lang.String,ElementConfigItem> _elements
          Mapping between HTML elements and LaTeX commands.
private  java.util.HashMap<java.lang.String,java.lang.String> _chars
          Mapping between HTML named entities (ie.
private  java.util.HashMap<java.lang.Integer,java.lang.String> _charsNum
          Mapping between HTML decimal decimal entities and LaTeX commands.
private  LinksConversion _linksConversion
          The way of converting hyperlinks.
private  boolean _makeCmdsFromCSS
          Make new LaTeX commands from the CSS styles.
private  java.util.HashMap<java.lang.String,CSSStyle> _styles
          CSS styles used with converted file.
private  java.util.HashMap<java.lang.String,CSSPropertyConfigItem> _stylesConf
          Mappings between CSS properties and LaTeX commands.
 
Constructor Summary
Configuration()
          Loads all the configuration.
 
Method Summary
 void addStyle(java.lang.String name, CSSStyle style)
          Adds user style to the configuration.
 CSSStyle findStyle(java.lang.String elementName)
          Finds style for element.
 CSSStyle findStyleClass(java.lang.String className, java.lang.String elementName)
          Finds style for element with specified class attribute
 CSSStyle findStyleId(java.lang.String elementId, java.lang.String elementName)
          Finds style for element with specified id attribute
 java.lang.String getCmdStyleName(java.lang.String styleName)
          style name without special chars
 ElementConfigItem getElement(java.lang.String name)
          Returns element's configuration.
 java.lang.String getChar(java.lang.Integer charNum)
          Returns LaTeX command for the specified entity.
 java.lang.String getChar(java.lang.String charName)
          Returns LaTeX command for the specified entity.
 LinksConversion getLinksConversionType()
          Returns the way of converting hyperlinks.
 boolean getMakeCmdsFromCSS()
          Returns true when new LaTeX commands are to be made from CSS styles.
 CSSPropertyConfigItem getPropertyConf(java.lang.String property)
          Returns CSS property configuration.
 CSSStyle getStyle(java.lang.String styleName)
          Returns style defined in the user stylesheet.
private  void loadElementsConfiguration(org.w3c.dom.Element root)
          Loads mapping between HTML elements and LaTeX commands.
private  void loadCharsConfiguration(org.w3c.dom.Element root)
          Loads mapping between HTML named entities (ie.
private  void loadLinksConfiguration(org.w3c.dom.Element root)
          Loads options for converting hyperlinks.
private  void loadStylesConfiguration(org.w3c.dom.Element root)
          Loads mappings between CSS properties and LaTeX commands.
private  void loadStyleSheet(java.io.File f)
          Loads user style sheet.
 java.lang.String makeCmdsFromCSS()
          Makes new LaTeX commands from the CSS styles.
private  java.lang.String replaceSpecialStrings(java.lang.String str)
          Replaces special @-strings with appropriate strings (ie.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_elements

private java.util.HashMap<java.lang.String,ElementConfigItem> _elements
Mapping between HTML elements and LaTeX commands.
key : <elementName>


_chars

private java.util.HashMap<java.lang.String,java.lang.String> _chars
Mapping between HTML named entities (ie. &lt;) and LaTeX commands.
key : <entityName>
value : LaTeX command


_charsNum

private java.util.HashMap<java.lang.Integer,java.lang.String> _charsNum
Mapping between HTML decimal decimal entities and LaTeX commands.
key : <entityDecimalNum>
value : LaTeX command


_styles

private java.util.HashMap<java.lang.String,CSSStyle> _styles
CSS styles used with converted file.
key : <styleName>


_stylesConf

private java.util.HashMap<java.lang.String,CSSPropertyConfigItem> _stylesConf
Mappings between CSS properties and LaTeX commands.
key : <propertyName>-<propertyValue>


_linksConversion

private LinksConversion _linksConversion
The way of converting hyperlinks.


_makeCmdsFromCSS

private boolean _makeCmdsFromCSS
Make new LaTeX commands from the CSS styles.


_commandsPrefix

private java.lang.String _commandsPrefix
Prefix of new LaTeX commands generated by the program.

Constructor Detail

Configuration

public Configuration()
              throws FatalErrorException
Loads all the configuration.

Throws:
FatalErrorException - when error during processing configuration occurs
Method Detail

loadElementsConfiguration

private void loadElementsConfiguration(org.w3c.dom.Element root)
Loads mapping between HTML elements and LaTeX commands.

Parameters:
root - root element of the XML configuration file

loadCharsConfiguration

private void loadCharsConfiguration(org.w3c.dom.Element root)
Loads mapping between HTML named entities (ie. &lt;) and LaTeX commands. Mappings between HTML decimal decimal entities and LaTeX commands are also loaded.

Parameters:
root - root element of the XML configuration file

loadLinksConfiguration

private void loadLinksConfiguration(org.w3c.dom.Element root)
Loads options for converting hyperlinks.

Parameters:
root - root element of the XML configuration file

loadStylesConfiguration

private void loadStylesConfiguration(org.w3c.dom.Element root)
Loads mappings between CSS properties and LaTeX commands.

Parameters:
root - root element of the XML configuration file

loadStyleSheet

private void loadStyleSheet(java.io.File f)
Loads user style sheet.

Parameters:
f - CSS file

replaceSpecialStrings

private java.lang.String replaceSpecialStrings(java.lang.String str)
Replaces special @-strings with appropriate strings (ie. "@NL" with "\n").

Parameters:
str - input string
Returns:
string without special @-strings

getElement

public ElementConfigItem getElement(java.lang.String name)
                             throws NoItemException
Returns element's configuration.

Parameters:
name - element's name
Returns:
element's configuration
Throws:
NoItemException - when element isn't found in the configuration

getLinksConversionType

public LinksConversion getLinksConversionType()
Returns the way of converting hyperlinks.

Returns:
the way of converting hyperlinks

getChar

public java.lang.String getChar(java.lang.String charName)
                         throws NoItemException
Returns LaTeX command for the specified entity.

Parameters:
charName - entity name
Returns:
LaTeX command for the specified entity
Throws:
NoItemException - when entity isn't found in the configuration

getChar

public java.lang.String getChar(java.lang.Integer charNum)
                         throws NoItemException
Returns LaTeX command for the specified entity.

Parameters:
charNum - entity number
Returns:
LaTeX command for the specified entity
Throws:
NoItemException - when entity isn't found in the configuration

getStyle

public CSSStyle getStyle(java.lang.String styleName)
Returns style defined in the user stylesheet.

Parameters:
styleName - style name
Returns:
style defined in the user stylesheet

findStyleClass

public CSSStyle findStyleClass(java.lang.String className,
                               java.lang.String elementName)
Finds style for element with specified class attribute

Parameters:
className - element's class attribute
elementName - element name
Returns:
CSS style

findStyleId

public CSSStyle findStyleId(java.lang.String elementId,
                            java.lang.String elementName)
Finds style for element with specified id attribute

Parameters:
elementId - element's id attribute
elementName - element name
Returns:
CSS style

findStyle

public CSSStyle findStyle(java.lang.String elementName)
Finds style for element.

Parameters:
elementName - element name
Returns:
CSS style

getPropertyConf

public CSSPropertyConfigItem getPropertyConf(java.lang.String property)
                                      throws NoItemException
Returns CSS property configuration.

Parameters:
property - property and value name (<propertyName>-<valueName>)
Returns:
CSS property configuration
Throws:
NoItemException - when property isn't found in the configuration

addStyle

public void addStyle(java.lang.String name,
                     CSSStyle style)
Adds user style to the configuration.

Parameters:
name - style name
style - CSS style

makeCmdsFromCSS

public java.lang.String makeCmdsFromCSS()
Makes new LaTeX commands from the CSS styles.

Returns:
string containing new commands definitions

getCmdStyleName

public java.lang.String getCmdStyleName(java.lang.String styleName)
style name without special chars

Parameters:
styleName - style name
Returns:
style name without special chars (ie. "#") - suitable fo creating new LaTeX command

getMakeCmdsFromCSS

public boolean getMakeCmdsFromCSS()
Returns true when new LaTeX commands are to be made from CSS styles.

Returns:
true when new LaTeX commands are to be made from CSS styles