Logo
Distributed Genetic Programming Framework
print print

File org.sfc.xml.formats.Stylesheet.java

Here you can find all the information about the file org.sfc.xml.formats.Stylesheet.java. You may explore it here or download it onto your local disk.
/*
 * Copyright (c) 2005 Thomas Weise
 * 
 * E-Mail           : tweise@gmx.de
 * Creation Date    : 2005-08-20 19:19:03
 * Original Filename: org.sfc.xml.formats.Stylesheet.java
 * Version          : 1.0.2
 * Last modification: 2006-03-07
 *                by: Thomas Weise
 * 
 * License          : GNU LESSER GENERAL PUBLIC LICENSE
 *                    Version 2.1, February 1999
 *                    You should have received a copy of this license along
 *                    with this library; if not, write to the Free Software
 *                    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *                    MA 02111-1307, USA or download the license under
 *                    http://www.gnu.org/copyleft/lesser.html.
 *                    
 * Warranty         : This software is provided "as is" without any
 *                    warranty; without even the implied warranty of
 *                    merchantability or fitness for a particular purpose.
 *                    See the Gnu Lesser General Public License for more
 *                    details.
 */

 
package org.sfc.xml.formats;

import org.xml.sax.SAXException;

import org.sfc.xml.formats.meta.PseudoClass;
import org.sfc.xml.formats.meta.XHTMLTag;

/**
 * Use this class to produce cascading style sheets en masse.
 *
 * @author Thomas Weise
 */

public  abstract  class Stylesheet
  {  
/**
 * Create a new abstract css writer.
 */

  Stylesheet ()
    {
    super();
    }
 
  
/**
 * Internally write a character.
 * @param p_char  The character to be written.
 * @throws  SAXException  If something goes wrong with underlying sax.
 * @throws  CSSException  If something goes wrong.
 */

  abstract  void  write (final  char  p_char) throws SAXException;
  
/**
 * Internally write a string.
 * @param p_string  The string to be written.
 * @throws  SAXException  If something goes wrong with underlying sax.
 * @throws  CSSException  If something goes wrong.
 */

  abstract  void  write (final  String p_string) throws SAXException;
  
/**
 * Finish the css document.
 * @throws  SAXException  If something goes wrong with underlying sax.
 * @throws  CSSException  If something goes wrong.
 */

  public  void  end_stylesheet  ()  throws SAXException
    {
    //
    }
  
/**
 * Format a given xhtml-tag.
 * @param p_tag The tag to be formatted.
 * @param p_style The style to use.
 * @return this
 * @throws  SAXException  If something goes wrong with underlying sax.
 * @throws  CSSException  If something goes wrong.
 */

  public  final Stylesheet format_tag
                                  (final  XHTMLTag  p_tag,
                                   final  Style     p_style)
                      throws SAXException                     
    {
    this.write(p_tag.toString());
    this.write('{');
    this.write(p_style.toString());
    this.write('}');
    return this;
    }
  
/**
 * Format some html tags with the same format.
 * @param p_tags The tags to be formatted.
 * @param p_style The style to use.
 * @return this
 * @throws  SAXException  If something goes wrong with underlying sax.
 * @throws  CSSException  If something goes wrong.
 */

  public  final Stylesheet format_tags (
                                   final  XHTMLTag[]  p_tags,
                                   final  Style       p_style)
              throws SAXException                     
    {
    int l_i;
    
    for(l_i = (p_tags.length-1); l_i > 0; l_i--)
      {
      this.write(p_tags[l_i].toString());
      this.write(',');
      }
    this.write(p_tags[0].toString());
    this.write('{');
    this.write(p_style.toString());
    this.write('}');
    return this;
    }
  
/**
 * Format an nested html tag.
 * @param p_nesting The nesting hierarchy of tags to be formatted.
 *                  <code>p_nesting[0]</code> will be the outermost tag,
 *                  <code>p_nesting[p_nesting.length-1]</code> will be the
 *                  innermost tag, that is formatted.
 * @param p_style The style to use.
 * @return this
 * @throws  SAXException  If something goes wrong with underlying sax.
 * @throws  CSSException  If something goes wrong.
 */

  public  final Stylesheet format_nested_tag
                                        (final  XHTMLTag[]  p_nesting,
                                         final  Style       p_style)
                                throws SAXException                     
    {
    int l_i;
    
    this.write(p_nesting[0].toString());
    for(l_i = 1; l_i < p_nesting.length; l_i++)
      {
      this.write(' ');
      this.write(p_nesting[l_i].toString());
      }
    this.write('{');
    this.write(p_style.toString());
    this.write('}');
    return this;
    }
  
/**
 * Format a given selector with the specified style. The selector may be
 * anything to complicated to be expressed with the other format_xxx
 * methods.
 * @param p_selector  Any given css-type selector, like
 *                    <dl>
 *                      <dt>div p</dt>
 *                      <dd>format i-elements in div-elements,
 *                          with no regard of their nesting</dd>
 *                      <dt>div > p</dt>
 *                      <dd>format i-elements in div-elements,
 *                          but only if they occure directly
 *                          in the div-element with no other
 *                          parenting element inbetween</dd>
 *                      <dt>div * p</dt>
 *                      <dd>format i-elements in div-elements,
 *                          but only if they occure in the div-element
 *                          with at least one other
 *                          parenting element inbetween</dd>
 *                      <dt>div + p</dt>
 *                      <dd>this goes for p-elements following exactly
 *                          one div-element</dd>
 *                      <dt>div[align=center]</dt>
 *                      <dd>div-elements which are center-aligned</dd>
 *                      <dt>...</dt>
 *                      <dd>...</dd>
 *                    </dl>.
 * @param p_style The style to format the selector with.
 * @return this
 * @throws  SAXException  if something goes wrong.
 */

  public  final Stylesheet format_selector
                                      (final String p_selector,
                                       final Style  p_style)
                          throws SAXException
    {
    this.write(p_selector.trim());
    this.write('{');
    this.write(p_style.toString());
    this.write('}');
    return this;
    }
  
/**
 * Format a class of elements.
 * @param p_tag   The xhtml-tag to subclass. Leave this <code>null</code>
 *                to make the class universal (*) so it goes for all
 *                elements.
 * @param p_class The classes name.
 * @param p_style The style to format elements of the class with.
 * @return this
 * @throws  SAXException  Thrown when something goes wrong.
 */

  public  final Stylesheet format_class
                                    (final  XHTMLTag  p_tag,
                                     final  String    p_class,
                                     final  Style     p_style)
                              throws SAXException
    {
    if(p_tag == null) this.write('*');
    else              this.write(p_tag.toString());
    this.write('.');
    this.write(p_class);
    this.write('{');
    this.write(p_style.toString());
    this.write('}');
    return this;
    }

/**
 * Format a individual element with the specified id-attribute.
 * @param p_tag   The xhtml-tag to subclass. Leave this <code>null</code>
 *                to make the class universal (*) so it goes for all
 *                elements.
 * @param p_id    The id-attribute of the element.
 * @param p_style The style to format elements of the class with.
 * @return this
 * @throws  SAXException  Thrown when something goes wrong.
 */

  public  final Stylesheet format_individual
                                       (final  XHTMLTag  p_tag,
                                        final  String    p_id,
                                        final  Style     p_style)
                              throws SAXException
    {
    if(p_tag != null) this.write(p_tag.toString());
    this.write('#');
    this.write(p_id);
    this.write('{');
    this.write(p_style.toString());
    this.write('}');
    return this;
    }
  
/**
 * Format a pseudo-class of elements.
 * @param p_tag   The xhtml-tag to format a pseudo-class of. Leave this
 *                <code>null</code> to make the class universal (*) so it
 *                goes for all elements.
 * @param p_pseudo_class  The pseudo-class to be used.
 * @param p_style The style to format elements of the class with.
 * @return this
 * @throws  SAXException  Thrown when something goes wrong.
 */

  public  final Stylesheet format_pseudo_class
                                       (final  XHTMLTag     p_tag,
                                        final  PseudoClass  p_pseudo_class,
                                        final  Style        p_style)
                              throws SAXException
    {
    if(p_tag != null) this.write(p_tag.toString());
    this.write(p_pseudo_class.toString());
    this.write('{');
    this.write(p_style.toString());
    this.write('}');
    return this;
    }
  }

File Information:

file name:Stylesheet.java
package:org.sfc.xml.formats
qualified name:org.sfc.xml.formats.Stylesheet.java
file type:Java Source File
download location:download http://dgpf.sourceforge.net/source/org/sfc/xml/formats/Stylesheet.java
size:9.395 KB (9621 B)
uploaded: 2018-01-07 12:03:36 GMT+0000
last update: 2006-03-07 04:20:28 GMT+0000
last access: 2018-04-21 07:25:30 GMT+0000

statistics online since 2006-01-02.   RSS Feed
Contact us by sending an email to tweise@gmx.de to receive further information, to report errors, or to join our project.
All content on this site (http://dgpf.sourceforge.net/) is LGPL-licensed.
http://dgpf.sourceforge.net/scripts/source/source.php last modified at 2018-01-07 12:03:34 GMT+0000 served at 2018-04-21 07:25:30 GMT+0000.
Valid CSS Valid XHTML 1.1
Valid RSS SourceForge.net Logo