Package org.jostraca

Source Code of org.jostraca.VirtualTemplatePath

/*
* Name:    VirtualTemplatePath
* Authors: Richard Rodger
*
* Copyright (c) 2002 Richard Rodger
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/


// package
package org.jostraca;


// import
import org.jostraca.util.Standard;
import org.jostraca.util.FileUtil;
import org.jostraca.util.Internal;
import org.jostraca.util.PropertySet;

import java.io.File;


/** The Service class assumes a file based template model,
*  and expects each template to have a file path. Virtual
*  templates thus have virtual paths to fulfill that requirement.
*  REVIEW: which indicates that the model needs changing, hmm?
*/
public class VirtualTemplatePath implements TemplatePath {

  // public static
  public static final String CN = VirtualTemplatePath.class.getName();




  // private instance
  private String  iTemplateName        = Standard.EMPTY;
  private String  iTemplatePath        = Standard.EMPTY;
  private String  iTemplateFileName    = Standard.EMPTY;
  private String  iTemplateFolder      = Standard.DOT;
  private String  iTemplateListFile    = Standard.EMPTY;
  private boolean iHasTemplateListFile = false;
  private boolean iIsLibraryTemplate   = false;
  private PropertySet iPropertySet     = null;




  // public methods

  /** Calls #setTemplateName(). */
  public VirtualTemplatePath( String pTemplateName ) {
    setTemplateName( pTemplateName );
  }


  /** Calls #setTemplateName(), also sets path.
   *  REVIEW: why is this needed for virtual paths?
   */
  public VirtualTemplatePath( String pTemplateName, File pTemplatePath ) {
    setTemplateName( pTemplateName );

    File templatePath = (File) Internal.null_arg( pTemplatePath );
    iTemplatePath   = pTemplatePath.getAbsolutePath();
    iTemplateFolder = FileUtil.getParent( templatePath );
  }


  /** @see org.jostraca.TemplatePath */
  public VirtualTemplatePath( String pTemplateName, String pTemplateListFile ) {
    // does nothing
  }



  /** @see org.jostraca.TemplatePath */
  public void setTemplateName( String pTemplateName ) {
    iTemplateName        = (String) Internal.null_arg( pTemplateName );
    iHasTemplateListFile = false;
  }



  /** @see org.jostraca.TemplatePath */
  public void setTemplateNameFromFile( String pTemplateName, String pTemplateListFile ) {
    // does nothing
  }



  /** @see org.jostraca.TemplatePath */
  public void resolve( String[] pTemplatePaths ) {
    // does nothing
  }


  /** @see org.jostraca.TemplatePath */
  public String getTemplatePath() {
    return iTemplatePath;
  }


  /** @see org.jostraca.TemplatePath */
  public String getTemplateFolder() {
    return iTemplateFolder;
  }


  /** @see org.jostraca.TemplatePath */
  public String getTemplateFileName() {
    return iTemplateFileName;
  }


  /** @see org.jostraca.TemplatePath */
  public String getTemplateName() {
    return iTemplateName;
  }


  /** @see org.jostraca.TemplatePath */
  public String getTemplateListFile() {
    return iTemplateListFile;
  }


  /** @see org.jostraca.TemplatePath */
  public boolean isLibraryTemplate() {
    return iIsLibraryTemplate;
  }


  /** @see org.jostraca.TemplatePath */
  public PropertySet resolvePropertySet() {
    if( null == iPropertySet ) {
      iPropertySet = new PropertySet();
    }
    return iPropertySet;
  }


  /** Set template path property set dynamically */
  public void setPropertySet( PropertySet pPropertySet ) {
    iPropertySet = (PropertySet) Internal.null_arg( pPropertySet );
  }


  /** @see org.jostraca.TemplatePath */
  public String toString() {
    return "VirtualTemplateName:["+iTemplateName+"]";
  }


  /** @see org.jostraca.TemplatePath */
  public boolean equals( Object pObject ) {
    return
      ( pObject instanceof TemplatePath )
      && ( iTemplateName.equals( ((TemplatePath)pObject).getTemplateName() ) );
  }


  /** @see org.jostraca.TemplatePath */
  public int hashCode() {
    return iTemplateName.hashCode();
  }

}
TOP

Related Classes of org.jostraca.VirtualTemplatePath

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.