de.ug2t.unifiedGui
Class CSSTools

java.lang.Object
  extended by de.ug2t.unifiedGui.CSSTools

public class CSSTools
extends java.lang.Object

A simple CSS file handling class. Reading, writing, querying of css values.

Since:
April 2006

Nested Class Summary
 class CSSTools.MoCSSData
          A small inner class to act as the model for a css element.
 
Field Summary
(package private)  java.util.Hashtable __CSS
          Contains the element matchings to a name, each element is stored as a MoCSSData element.
(package private)  java.lang.String __fileName
          The current file name of the loaded CSS data.
 
Constructor Summary
CSSTools()
           
 
Method Summary
 void commit()
          Writes the file that was loaded with the load(String) method out.
 void commit(java.lang.String xNewFile)
          Writes the CSS data out to a new file at the given location by the variable.
static CSSTools getTool(java.lang.String xFileName)
           
 java.lang.String getValue(java.lang.String xClass, java.lang.String xAttr)
          Obtains the value match for the given css element class and the given attribute key, or an emtpy string ("") when there is NO match.
 java.lang.String getValue(java.lang.String xClass, java.lang.String xAttr, java.lang.String xDef)
          Obtains the value match for the given css element class and the given attribute key, or an emtpy string ("") when there is NO match.
 boolean hasCSS(java.lang.String xClass)
          Simple boolean check to see if the given css element class is stored in memory (ie in the loaded file).
 void load(java.lang.String xFileName)
          This method will load the given CSS file into memory for use.l
 void remove(java.lang.String xClass)
          Removes a full css element from memory.
 void remove(java.lang.String xClass, java.lang.String xAttr)
          Removes a css attribute from memory that matches the given css element classs name and attribute name.
 void set(java.lang.String xClass, java.lang.String xAttr, java.lang.String xValue)
          Sets or enters a new css element-attribute key-value match to memory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

__CSS

java.util.Hashtable __CSS
Contains the element matchings to a name, each element is stored as a MoCSSData element.


__fileName

java.lang.String __fileName
The current file name of the loaded CSS data.

Constructor Detail

CSSTools

public CSSTools()
Method Detail

load

public void load(java.lang.String xFileName)
          throws java.io.IOException
This method will load the given CSS file into memory for use.l

Parameters:
xFileName - the absolute file name (path) to the css file.
Throws:
java.io.IOException - if one occurs.

getTool

public static CSSTools getTool(java.lang.String xFileName)
                        throws java.lang.Exception
Throws:
java.lang.Exception

commit

public void commit()
            throws java.io.IOException
Writes the file that was loaded with the load(String) method out.

Throws:
java.io.IOException
See Also:
out again.

commit

public void commit(java.lang.String xNewFile)
            throws java.io.IOException
Writes the CSS data out to a new file at the given location by the variable.

Parameters:
xNewFile - the new location (file name and path)
Throws:
java.io.IOException - if an IO exception occurs.

set

public void set(java.lang.String xClass,
                java.lang.String xAttr,
                java.lang.String xValue)
Sets or enters a new css element-attribute key-value match to memory.

Parameters:
xClass - the css element
xAttr - the attribute name
xValue - the value.

remove

public void remove(java.lang.String xClass,
                   java.lang.String xAttr)
Removes a css attribute from memory that matches the given css element classs name and attribute name.

Parameters:
xClass - css class to remove from
xAttr - the property to remove from memory.

remove

public void remove(java.lang.String xClass)
Removes a full css element from memory.

Parameters:
xClass - css element to remove.

getValue

public java.lang.String getValue(java.lang.String xClass,
                                 java.lang.String xAttr,
                                 java.lang.String xDef)
Obtains the value match for the given css element class and the given attribute key, or an emtpy string ("") when there is NO match.

Parameters:
xClass - css element that the value is needed for
xAttr - the attribute whose value is needed
xDef - default value
Returns:
the discovered value or an empty string

getValue

public java.lang.String getValue(java.lang.String xClass,
                                 java.lang.String xAttr)
Obtains the value match for the given css element class and the given attribute key, or an emtpy string ("") when there is NO match.

Parameters:
xClass - css element that the value is needed for
xAttr - the attribute whose value is needed
Returns:
the discovered value or an empty string

hasCSS

public boolean hasCSS(java.lang.String xClass)
Simple boolean check to see if the given css element class is stored in memory (ie in the loaded file).

Parameters:
xClass - Css element that may be stored.
Returns:
the results.

WidgetServer