CVS: jfor/src/org/jfor/jfor/converter AfterBuilder.java,NONE,1.1

Bertrand Delacretaz <[email protected]> Sun, 14 Jul 2002 23:44:07 -0700
Newsgroups gmane.text.xml.jfor.cvs
Message-ID <[email protected]>
Update of /cvsroot/jfor/jfor/src/org/jfor/jfor/converter
In directory usw-pr-cvs1:/tmp/cvs-serv21245/src/org/jfor/jfor/converter

Added Files:
	AfterBuilder.java 
Log Message:
footer code contributed by Andreas Lambert <[email protected]>

--- NEW FILE: AfterBuilder.java ---
package org.jfor.jfor.converter;

import java.util.Iterator;
import java.io.IOException;
import org.xml.sax.Attributes;
import org.jfor.jfor.rtflib.rtfdoc.*;

/*-----------------------------------------------------------------------------
 * jfor - Open-Source XSL-FO to RTF converter - see www.jfor.org
 *
 * ====================================================================
 * jfor Apache-Style Software License.
 * Copyright (c) 2002 by the jfor project. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 * notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in
 * the documentation and/or other materials provided with the
 * distribution.
 *
 * 3. The end-user documentation included with the redistribution,
 * if any, must include the following acknowledgment:
 * "This product includes software developed
 * by the jfor project (http://www.jfor.org)."
 * Alternately, this acknowledgment may appear in the software itself,
 * if and wherever such third-party acknowledgments normally appear.
 *
 * 4. The name "jfor" must not be used to endorse
 * or promote products derived from this software without prior written
 * permission.  For written permission, please contact [email protected].
 *
 * 5. Products derived from this software may not be called "jfor",
 * nor may "jfor" appear in their name, without prior written
 * permission of [email protected].
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE JFOR PROJECT OR ITS CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * ====================================================================
 * Contributor(s):
 *  @author Andreas Lambert <[email protected]> 
-----------------------------------------------------------------------------*/

//------------------------------------------------------------------------------
// $Id: AfterBuilder.java,v 1.1 2002/07/15 06:44:05 bdelacretaz Exp $
// $Log: AfterBuilder.java,v $
// Revision 1.1  2002/07/15 06:44:05  bdelacretaz
// footer code contributed by Andreas Lambert <[email protected]>
//
//------------------------------------------------------------------------------

/** AbstractBuilder used to build the "after" region, i.e. footers */
class AfterBuilder extends AbstractBuilder {

  //@TODO: Move this to some Constants interface or to the AbstractBuilder
  public static final String TAG_STATIC = "fo:static-content";
  
  public static final String TAG_XSL_REGION_AFTER = "xsl-region-after";
  
  private Attributes    m_attrib;
  private RtfAfter      m_after;
  private RtfAttributes afterAttributes;
    
    /** if this fo:block is nested into another one, this is the builder that
     *  processes the enclosing block
     */
    
    AfterBuilder(BuilderContext ctx) {
        super(ctx);
        System.out.println("An AfterBuilder instance was born");
    }
    
    /** called by Converter at the start of an element */
    public void start(String rawName, Attributes attrs) throws IOException {
        //we know that the only attribute will be \footer
        afterAttributes = new RtfAttributes();
        afterAttributes.set(RtfAfter.FOOTER);
        final IRtfAfterContainer c = (IRtfAfterContainer)m_context.getContainer(IRtfAfterContainer.class,true,this);
        m_after = c.newAfter(afterAttributes);
        m_context.pushContainer(m_after);
    }
    
    /** called by Converter at the end of an element */
    public void end() throws IOException {
        m_context.popContainer();
    }
    
    
    /** this builder processes fo:block elements */
    public IBuilder getBuilder(BuilderContext ctx,String rawName, Attributes atts) {
        
        final String attsString = atts.getValue("flow-name");
        boolean equals = false;

        // Checking it this way there's no need for nullpointer checking.
        if (TAG_XSL_REGION_AFTER.equals(attsString))
        {
          equals=true;
        }
        
        if(rawName.equals(TAG_STATIC) && equals) {
          return new AfterBuilder(ctx);
        }
        else return null;
    }
}



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf