Package org.jostraca

Examples of org.jostraca.Template


  }



  public void testPerform() throws Exception {
    Template tm = new BasicTemplate();
    TemplateActionHandlerStub tahs  = new TemplateActionHandlerStub();
    PropertySet               ps    = new PropertySet();
    ps.load( Tools.findRelativeSystemPath( "conf/system.conf" ) );
    TextualTransformManagerTable   ttmt = new TextualTransformManagerTable( ps );
View Full Code Here


   
    String src =
      "<% @conf main.JostracaVersion = 0.4 \n main.TemplateScript = javascript %>"
      +"Hi <% @"+IncludeDirectiveSupport.NAME+" foo bar %>";
   
    Template t = new VirtualTemplate("test01.js",src);

    try {
      g.generate(t);
    }
    catch( Exception e ) {
      System.out.println("cw:"+t.getCodeWriterSource());
      throw e;
    }

    System.out.println("res:"+t.getResult());
   
    assertEquals("Hi include this",t.getResult());
  }
View Full Code Here

    // do nothing
  }


  protected void processImpl( Template pTemplate ) {
    Template    template   = pTemplate;
    PropertySet tmps       = pTemplate.getMergedPropertySet();

    String codeWriterLang = template.getCodeWriterLang();
    //t.track( "codeWriterLang", codeWriterLang );

    PropertySet langPS = loadLangPropertySet( codeWriterLang, tmps );
    mUserMessageHandler.debug( "Template Script:", codeWriterLang );

    template.setPropertySet( CONF_lang, langPS );

    // prepare settings
    handleCodeWriterName( template );
    overridePropertySet( template, iPropertySetModifierManager );

    template.modifyForOldVersion();

    //validateMergedPropertySet( template.getMergedPropertySet() );

    tmps = template.getMergedPropertySet();
    TemplatePath tp   = template.getTemplatePath();
    dumpPropertySet(    tmps, tp );
    dumpTemplateSource( tmps, tp, template );
  }
View Full Code Here

  public void testSaver() throws Exception {
    CommandLineUserMessageHandler cm = new CommandLineUserMessageHandler();
    FormatManager fm = new BasicFormatManager();
   
    Template tm01 = PackageTest.makeTemplate("tm01");
    Template tm02 = PackageTest.makeTemplate("tm02");
    ArrayList tmlist = ListUtil.make( tm01, tm02 );

    for( Iterator tmT = tmlist.iterator(); tmT.hasNext(); ) {
      Template tm = (Template) tmT.next();
      tm.getPropertySet( Service.CONF_template )
        .set( TemplateHandlerManager.PROPERTY_PREFIX+"Preparer", "org.jostraca.process.GenericPreparer" );
      tm.getPropertySet(Service.CONF_template)
        .set( TemplateHandlerManager.PROPERTY_PREFIX+"Parser", "org.jostraca.process.GenericParser" );
      tm.getPropertySet(Service.CONF_template)
        .set( TemplateHandlerManager.PROPERTY_PREFIX+"Merger", "org.jostraca.process.GenericMerger" );
      tm.getPropertySet(Service.CONF_template)
        .set( TemplateHandlerManager.PROPERTY_PREFIX+"Saver""org.jostraca.process.GenericSaver" );
    }

    PreparerProcessStage prps = new PreparerProcessStage();
    prps.setUserMessageHandler( cm );
View Full Code Here

  public static final String FILE_EXT_meta = "-meta.properties";



  public static void saveMetaData( Template pTemplate ) {
    Template    tm   = (Template) Internal.null_arg( pTemplate );
    PropertySet tmps = (PropertySet) tm.getMergedPropertySet();

    if( tmps.isYes( Property.main_EnableMeta ) ) {
      TemplatePath tp       = tm.getTemplatePath();
      File         metaFile = makeMetaFilePath( tmps, tp );

      try {
        FileUtil.ensureParentFolder( metaFile );
        tmps.set( Property.jostraca_properties_NameValueList, Standard.EMPTY );
        tmps.set( Property.jostraca_template_properties,
                  Tools.normaliseTemplatePropertySet( pTemplate.getPropertySet( CONF_template ) ) );

        //t.track( "saveMetaData.pPropertySet.size", pPropertySet.size() );

        tmps.save( metaFile );
        tm.setMetaFile( metaFile );
      }
      catch( Exception e ) {
        throw ProcessException.CODE_save_meta( new ValueSet( ValueCode.FILE, metaFile ), e );
      }
    }
View Full Code Here

  }



  public static PropertySet loadMetaData( Template pTemplate ) {
    Template    tm   = (Template) Internal.null_arg( pTemplate );
    PropertySet tmps = (PropertySet) tm.getMergedPropertySet();
    PropertySet ps   = new PropertySet();

    if( tmps.isYes( Property.main_EnableMeta ) ) {
      TemplatePath tp       = tm.getTemplatePath();
      File         metaFile = makeMetaFilePath( tmps, tp );

      try {
        ps.load( metaFile );
      }
View Full Code Here

  }


  protected void compileAsFirst( List pTemplateList ) {
    List        tmlist  = pTemplateList;
    Template    firsttm = (Template) pTemplateList.get(0);
    PropertySet tmps    = firsttm.getMergedPropertySet();

    List sourceFilesList = new ArrayList();
    StringBuffer sourceFilesB = new StringBuffer( tmlist.size() * 33 );
    boolean      compile      = makeCompileList( tmlist, sourceFilesB, sourceFilesList );
    String       sourceFiles  = sourceFilesB.toString();
View Full Code Here

    // do nothing
  }


  protected void processImpl( Template pTemplate ) {
    Template    template   = pTemplate;
    PropertySet tmps       = pTemplate.getMergedPropertySet();

    if( tmps.isYes( Property.main_SaveCodeWriter ) ) {

      File   codeWriterPath   = template.getCodeWriterPath();
      String codeWriterSource = template.getCodeWriterSource();

      boolean changed                  = true;
      String  previousCodeWriterSource = Standard.EMPTY;

      if( codeWriterPath.exists() ) {
        try {
          previousCodeWriterSource = FileUtil.readFile( codeWriterPath );       
          changed = !( codeWriterSource.equals( previousCodeWriterSource ) );
        }
        catch( IOException ioe ) {
          // assume that this is a non-fatal error
          // keep going to try to at least save the CodeWriter
          changed = true;
        }
      }

      try {
        // always save code writer so that we can tell that template was parsed
        FileUtil.ensureParentFolder( codeWriterPath );
        FileUtil.writeFile( codeWriterPath, codeWriterSource );
        WayPointRecorder.add( BasicWayPoint.SavingCodeWriter.make( codeWriterPath.getAbsolutePath() ) );
      }
      catch( Exception e ) {
        throw ProcessException.CODE_cw_not_saved( new String[] {"path", codeWriterPath.getAbsolutePath()}, e );
      }
     
      template.setCodeWriterChanged( changed );
    }

    MetaUtil.saveMetaData( template );
  }
View Full Code Here

    FormatManager fm = new BasicFormatManager();
   
    List tmlist = makeTMList();

    for( Iterator tmT = tmlist.iterator(); tmT.hasNext(); ) {
      Template tm = (Template) tmT.next();
      tm.getPropertySet(Service.CONF_template)
        .set( TemplateHandlerManager.PROPERTY_PREFIX+"Compiler", "org.jostraca.process.GenericCompiler" );
    }

    preprocess( cm, fm, tmlist );
View Full Code Here

    FormatManager fm = new BasicFormatManager();
   
    List tmlist = makeTMList();

    for( Iterator tmT = tmlist.iterator(); tmT.hasNext(); ) {
      Template tm = (Template) tmT.next();
      tm.getPropertySet(Service.CONF_template)
        .set( TemplateHandlerManager.PROPERTY_PREFIX+"Compiler", "org.jostraca.process.JavaCompiler" );
    }

    preprocess( cm, fm, tmlist );
    CompilerProcessStage cps = new CompilerProcessStage();
View Full Code Here

TOP

Related Classes of org.jostraca.Template

Copyright © 2018 www.massapicom. 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.