Package org.jostraca.util

Examples of org.jostraca.util.PropertySet




  protected String resolveBagName( Template pTemplate ) {
    Template    tm   = pTemplate;
    PropertySet tmps = tm.getMergedPropertySet();

    StringBuffer bagname = new StringBuffer();
    bagname.append( " "+tmps.get( Property.main_ExternalCompiler ) );
    bagname.append( " "+tmps.get( Property.main_ExternalCompilerOptions ) );

    return bagname.toString();
  }
View Full Code Here


  // compile using props from first tm
  protected void compileAsFirst( List pTemplateList ) {
    List        tmlist  = pTemplateList;
    Template    firsttm = (Template) pTemplateList.get(0);
    PropertySet tmps    = firsttm.getMergedPropertySet();

    boolean successful = false;
    boolean compile    = false;
    StringBuffer sourceFilesB = new StringBuffer();
    for( Iterator tmT = tmlist.iterator(); tmT.hasNext(); ) {
      Template tm  = (Template) tmT.next();

      File executablePath = makeExecutablePath( tm );
      tm.setCodeWriterExecutablePath( executablePath );

      boolean compileRequired = compileRequired( tm );

      if( compileRequired ) {
        File cwF = tm.getCodeWriterPath();
        sourceFilesB.append( " "+TextUtil.quoteSpaces( cwF.getPath() ) );
        WayPointRecorder.add( BasicWayPoint.CompilingCodeWriter.make( cwF.getAbsolutePath() ) );
        compile = true;
      }
    }

    if( compile ) {
      String sourceFiles  = sourceFilesB.toString();
      String compiler     = tmps.get( Property.main_ExternalCompiler );
      String compilerOpts = tmps.get( Property.main_ExternalCompilerOptions );

      ExecutableCommand cmd = new ExecutableCommand( compiler, compilerOpts, sourceFiles );
      String fullcmd = cmd.getFullCmd();

      cmd.setUserMessageHandler( iUserMessageHandler );
View Full Code Here

  protected boolean compileRequired( Template pTemplate ) {
    try {
      Template     tm              = pTemplate;
      boolean      compileRequired = true;
      PropertySet  tmps            = tm.getMergedPropertySet();
      StringBuffer reason          = new StringBuffer();
      File         executablePath  = pTemplate.getCodeWriterExecutablePath();

      // definitely compile
      if( tmps.isYes( Property.main_CompileCodeWriter ) ) {
        compileRequired = true;
        reason.append( "main.CompileCodeWriter="+tmps.get( Property.main_CompileCodeWriter ) );
      }

      // definitely do not compile
      else if( tmps.isNo( Property.main_CompileCodeWriter ) ) {
        compileRequired = false;
        reason.append( "main.CompileCodeWriter="+tmps.get( Property.main_CompileCodeWriter ) );
      }

      // otherwise, compile only if needed
      else if( tmps.isYes( Property.lang_HasExecutable ) ) {

        // no executable => definitely compile
        if( ! executablePath.exists() ) {
          compileRequired = true;
          reason.append( "executable not found: "+executablePath );
View Full Code Here

    File   cwp          = pTemplate.getCodeWriterPath();
    File   parent       = cwp.getParentFile();
    String name         = cwp.getName();
    int    dotJavaIndex = name.lastIndexOf( Standard.DOT );

    PropertySet tmps = pTemplate.getMergedPropertySet();
    String      cf   = tmps.get( PropertyJava.ClassFolder );
    if( !"".equals( cf ) ) {
      parent = new File( cf );
    }

    File epf = cwp;
View Full Code Here


  /** Modify template properties to handle older template versions. */
  public void modifyForOldVersion() {
   
    PropertySet mps  = getMergedPropertySet();
    PropertySet tmps = iOrderedPSM.get( Service.CONF_template );

    String version = mps.get( Property.main_JostracaVersion );

    if( ! version.startsWith( Service.VERSION_NUMBER ) ) {
      if( "0.1".equals( version ) ) {
        // set markers
        tmps.set( Property.parse_SectionMarker,     "@" );
        tmps.set( Property.parse_DirectiveMarker,   "!" );
        tmps.set( Property.parse_DeclarationMarker, "" ); // no declarations in v0.1
         
        // section marker is a prefix in v0.1
        tmps.set( Property.jostraca_regexp_MatchSectionName
                  ,"$<jostraca.regexp.AnyWhiteSpaceAtStart>"
                  +"$<parse.SectionMarker>$<jostraca.regexp.SubmatchSectionName>"
                  +"$<jostraca.regexp.SubmatchAnyWhiteSpaceAnyCharsAtEnd>" );

      }

      // old perl and python writer formats
      if( "0.1".equals( version ) || "0.2".equals( version ) || "0.3".equals( version ) ) {
        String csn = iTemplateScript.getCanonicalScriptName( mps );

        if( "perl".equals( csn ) && -1 != mps.get( Property.main_CodeWriterFormat ).indexOf("BasicPerlWriterFormat") ) {
          tmps.set( Property.main_CodeWriterFormat, "NonObjectPerlWriterFormat" );
          tmps.set( Property.lang_InsertPrefix,     "_insert( " );
        }
        else if( "python".equals( csn ) && -1 != mps.get( Property.main_CodeWriterFormat ).indexOf("BasicPythonWriterFormat") ) {
          tmps.set( Property.main_CodeWriterFormat, "NonObjectPythonWriterFormat" );
          tmps.set( Property.lang_InsertPrefix,     "_py_insert( " );
        }
      }
    }
  }
View Full Code Here

  /** Create regexps used to implement preprocessing directives */
  private void createRegExps() {
    String regexpFailed = "RegExp invalid for ";

    PropertySet ps = getMergedPropertySet();

    try {
      String confREDef = ps.get( Property.jostraca_regexp_template_ConfDirective, DEFAULT_REGEXP_Conf );
      iConfRegExp = RegExp.make( confREDef, RegExp.ModeSet.DotMatchesNewline );
    }
    catch( Exception e ) {
      throw new TemplateException( TemplateException.CODE_re_conf, e );
    }


    try {
      String includeREDef = ps.get( Property.jostraca_regexp_template_IncludeDirective, DEFAULT_REGEXP_Include );
      iIncludeRegExp = RegExp.make( includeREDef, RegExp.ModeSet.DotMatchesNewline );
    }
    catch( Exception e ) {
      throw new TemplateException( TemplateException.CODE_re_include, e );
    }


    try {
      String includeBaseREDef = ps.get( Property.jostraca_regexp_template_IncludeBaseDirective, DEFAULT_REGEXP_IncludeBase );
      iIncludeBaseRegExp = RegExp.make( includeBaseREDef, RegExp.ModeSet.DotMatchesNewline );
    }
    catch( Exception e ) {
      throw new TemplateException( TemplateException.CODE_re_includebase, e );
    }


    try {
      String includeBlockREDef = ps.get( Property.jostraca_regexp_template_IncludeBlockDirective, DEFAULT_REGEXP_IncludeBlock );
      iIncludeBlockRegExp = RegExp.make( includeBlockREDef, RegExp.ModeSet.DotMatchesNewline );
    }
    catch( Exception e ) {
      throw new TemplateException( TemplateException.CODE_re_includeblock, e );
    }
View Full Code Here

      int           numConfs = allconfs.length;
      if( 0 == numConfs && pConfRequired ) {
        throw new TemplateException( TemplateException.CODE_no_conf, new ValueSet( ValueCode.TEMPLATE, iPath ) );
      }
      else {
        PropertySet ps        = new PropertySet();
        boolean     foundConf = false;
        RegExpMatch conf      = null;
        String      props     = null;
        PropertySet propSet   = null;
        for( int confI = 0; confI < numConfs; confI++ ) {
          conf    = allconfs[ confI ];
          props   = conf.matchFirstSub();
          propSet = new PropertySet();
          propSet.parse( props );
          ps.overrideWith( propSet );
          foundConf = true;
        }
       
        iOrderedPSM.get( Service.CONF_template ).overrideWith( ps );
View Full Code Here

  }


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

    boolean                     successful = false;
    PrintStream                 sysOut     = null;
    PrintStream                 sysErr     = null;
    RecordingUserMessageHandler rumh       = new RecordingUserMessageHandler();
    Object                      result     = null;

    try {
      String   cwo  = makeCodeWriterOptions( tmps, template );
      String[] args = ArgUtil.splitQuoted( cwo );

      // DO NOT use CommandLineUserMessageHandler here - causes infinite recursion
      MessageHandlerOutputStream  out  = new MessageHandlerOutputStream( UserMessageHandler.INFO,  rumh );
      MessageHandlerOutputStream  err  = new MessageHandlerOutputStream( UserMessageHandler.ERROR, rumh );

      // space out dots to avoid accidental replace on System DOT out search
      sysOut = System . out;
      sysErr = System . err;
   
      // set context if not null
      Object context = template.getContext();

      boolean throwWriterExceptions = tmps.isYes( Property.main_CodeWriter_throwExceptions );

      String script = template.getCodeWriterSource();

      Context cx = Context.enter();
View Full Code Here

  }


  /** Perform special processing on template property set */
  private void processProperties() throws Exception {
    PropertySet tmps = iOrderedPSM.get( Service.CONF_template );

    if( null != iTemplatePath ) {
      PropertySet tpps = iTemplatePath.resolvePropertySet();
      tmps.inheritFrom( tpps );
    }

    tmps.set( Property.jostraca_template_path,      iTemplatePath.getTemplatePath() );
    tmps.set( Property.jostraca_template_name,      iTemplatePath.getTemplateName() );
View Full Code Here



  /** Determine template script */
  private void handleTemplateScript() {
    PropertySet mps = getMergedPropertySet();
   
    if( null == iTemplateScript ) {
      // FIX: not the right way to create it
      iTemplateScript = BasicTemplateScript.defineByProperty( mps );
    }

    iTemplateScript.setByProperty( mps );

    // FIX: so suffixes are not automatic anymore? check this
    if( mps.isYes( "jostraca.support.ForceScriptByPath" ) ) {
      TemplateScript ts = BasicTemplateScript.defineByPath( iTemplatePath.getTemplatePath() );
      if( null != ts ) {
        iTemplateScript = ts;
      }
    }
View Full Code Here

TOP

Related Classes of org.jostraca.util.PropertySet

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.