Package org.jostraca.section

Examples of org.jostraca.section.Section


    if( ! Standard.EMPTY.equals( pArguments.trim() ) ) {
      String match = doRegExpMatchArguments( pArguments );

      if( null != match ) {
        String  sectionName = match;
        Section section     = pTemplateActionHandler.getSection( sectionName );

        if( pPropertySet.isYes( Property.jostraca_old ) ) {
          pTemplateActionHandler.append( section.getContent() );
        }

        // backwards compatibility support
        Hashtable isattr = new Hashtable();
        isattr.put( InsertSectionTransform.ATTR_unit_source_section, sectionName );
        BasicUnit bu = new BasicUnit( NAME, pTemplateActionHandler.getDefaultSection(), section.getContent(),
                                      new BasicUnitOrigin(), isattr );
        pBasicUnitList.add( bu );
      }
      else {
       
View Full Code Here


    if( ! Standard.EMPTY.equals( pArguments.trim() ) ) {
      String match = doRegExpMatchArguments( pArguments );

      if( null != match ) {
        String  sectionName = match;
        Section section     = pTemplateActionHandler.getSection( sectionName );

        if( pPropertySet.isYes( Property.jostraca_old ) ) {
          pTemplateActionHandler.append( section.getContent() );
        }

        // backwards compatibility support
        Hashtable isattr = new Hashtable();
        isattr.put( InsertSectionTransform.ATTR_unit_source_section, sectionName );
        BasicUnit bu = new BasicUnit( NAME, pTemplateActionHandler.getDefaultSection(), section.getContent(),
                                      new BasicUnitOrigin(), isattr );
        pBasicUnitList.add( bu );
      }
      else {
       
View Full Code Here

    String footextcollapse = commentLinePrefix+" Section: "+fooname+" "+commentLineSuffix;
    String barname         = "barname";
    String bartext         = "bartext";
    String bartextcollapse = commentLinePrefix+" Section: "+barname+" "+commentLineSuffix;

    Section fooin = new BasicSection( fooname );
    fooin.setContent( footext );
    Section barin = new BasicSection( barname );
    barin.setContent( bartext );
    SectionSet foobarin = new SectionSet();
    foobarin.addSection( fooin );
    foobarin.addSection( barin );

    Collapser collapser = new Collapser();
   
    Section fooout = collapser.modify( fooin, mps );
    assertTrue( fooout.getContent().equals( footextcollapse ) );
    assertTrue( fooout.getName().equals( fooname ) );

    collapser.modify( barin, mps );
    assertTrue( barin.getContent().equals( bartextcollapse ) );
    assertTrue( barin.getName().equals( barname ) );   

    fooin.setContent( footext );
    barin.setContent( bartext );

    SectionSet  foobarout   = collapser.modify( foobarin, mps );
    Enumeration sectionEnum = foobarout.enumerateSections();
    while( sectionEnum.hasMoreElements() ) {
      Section section = (Section) sectionEnum.nextElement();
      if( fooname.equals( section.getName() ) ) {
        assertTrue( section.getContent().equals( footextcollapse ) );
      }
      else if( barname.equals( section.getName() ) ) {
        assertTrue( section.getContent().equals( bartextcollapse ) );
      }
      else {
        fail();
      }
    }
View Full Code Here

    String bartext1        = "bartext1" + Standard.NEWLINE;
    String bartext2        = "bartext2";
    String naffname        = "naff";
    String nafftext1       = "nafftext1" + Standard.NEWLINE;
    String nafftext2       = "nafftext2";
    Section foos  = new BasicSection( fooname );
    foos.setContent( footext1 + footext2 );
    Section bars  = new BasicSection( barname );
    bars.setContent( bartext1 + bartext2 );
    Section naffs = new BasicSection( naffname );
    naffs.setContent( nafftext1 + nafftext2 );
    SectionSet foobarss = new SectionSet();
    foobarss.addSection( foos  );
    foobarss.addSection( bars  );
    foobarss.addSection( naffs );

    String in_1     = "  ";
    String in_1_2   = "    ";
    String in_1_2_3 = "      ";

    String wfsource1
      = in_1+"!<foo>" + Standard.NEWLINE
      + in_1+"--" + Standard.NEWLINE
      + in_1_2+"!<bar>" + Standard.NEWLINE
      + in_1+"--" + Standard.NEWLINE
      + in_1_2_3+"!<naff>" + Standard.NEWLINE
      + in_1+"--" + Standard.NEWLINE
      ;

    mps.set( Property.jostraca_writerformat_source, wfsource1 );   

    BlockIndenter bi = new BlockIndenter();

    bi.modify( foobarss, mps );

    assertTrue( ( footext1+in_1+footext2   ).equals( foos.getContent() ) );
    assertTrue( ( bartext1+in_1_2+bartext2 ).equals( bars.getContent() ) );
    assertTrue( ( nafftext1+in_1_2_3+nafftext2 ).equals( naffs.getContent() ) );

  }
View Full Code Here

    mps.set( PropertyPython.tabAsSpaces,            tabAsSpaces);
    mps.set( PropertyPython.nonStatementLineRegExp, "^[ \\t]*(#.*)?$" );
    mps.set( PropertyPython.controlFlowRegExp,      ":[ \\t]*(#.*)?$" );
    mps.set( Property.lang_InsertPrefix,            "_py_insert( " );

    Section sec = new BasicSection( "sec" );

    String in1  = "print 'foo' ";
    String out1 = "print 'foo' ";
    sec.setContent( in1 );
    pi.modify( sec, mps );
    //System.out.println( in1  );
    //System.out.println( out1 );
    //System.out.println( sec.getContent() );
    assertTrue( out1.equals( sec.getContent() ) );

    String in2  = "  print 'foo' ";
    String out2 = "  print 'foo' ";
    sec.setContent( in2 );
    pi.modify( sec, mps );   
    //System.out.println( in2  );
    //System.out.println( out2 );
    //System.out.println( sec.getContent() );
    assertTrue( out2.equals( sec.getContent() ) );

    String in3 
      = "print 'foo'"+Standard.NEWLINE
      + "_py_insert( \"abc\" )"
      ;
    String out3
      = "print 'foo'"+Standard.NEWLINE
      + "_py_insert( \"abc\" )"
      ;
    sec.setContent( in3 );
    pi.modify( sec, mps );   
    //System.out.println( in3  );
    //System.out.println( out3 );
    //System.out.println( sec.getContent() );
    assertTrue( out3.equals( sec.getContent() ) );

    String in4 
      = "  print 'foo'"+Standard.NEWLINE
      + "_py_insert( \"abc\" )"
      ;
    String out4
      = "  print 'foo'"+Standard.NEWLINE
      + "  _py_insert( \"abc\" )"
      ;
    sec.setContent( in4 );
    pi.modify( sec, mps );   
    //System.out.println( in4  );
    //System.out.println( out4 );
    //System.out.println( sec.getContent() );
    assertTrue( out4.equals( sec.getContent() ) );

    String in4_1 
      = "  print 'foo'"+Standard.NEWLINE
      + "    "+Standard.NEWLINE
      + "_py_insert( \"abc\" )"
      ;
    String out4_1
      = "  print 'foo'"+Standard.NEWLINE
      + "    "+Standard.NEWLINE
      + "  _py_insert( \"abc\" )"
      ;
    sec.setContent( in4_1 );
    pi.modify( sec, mps );   
    //System.out.println( in4_1  );
    //System.out.println( out4_1 );
    //System.out.println( sec.getContent() );
    assertTrue( out4_1.equals( sec.getContent() ) );

    String in4_2 
      = "  print 'foo'"+Standard.NEWLINE
      + "    # foo"+Standard.NEWLINE
      + "_py_insert( \"abc\" )"
      ;
    String out4_2
      = "  print 'foo'"+Standard.NEWLINE
      + "    # foo"+Standard.NEWLINE
      + "  _py_insert( \"abc\" )"
      ;
    sec.setContent( in4_2 );
    pi.modify( sec, mps );   
    //System.out.println( in4_2  );
    //System.out.println( out4_2 );
    //System.out.println( sec.getContent() );
    assertTrue( out4_2.equals( sec.getContent() ) );



    String in5 
      = "if foo == bar :"+Standard.NEWLINE
      + "   _py_insert( \"abc\" )"
      ;
    String out5
      = "if foo == bar :"+Standard.NEWLINE
      + "  _py_insert( \"abc\" )"
      ;
    sec.setContent( in5 );
    pi.modify( sec, mps );   
    //System.out.println( in5  );
    //System.out.println( out5 );
    //System.out.println( sec.getContent() );
    assertTrue( out5.equals( sec.getContent() ) );

    String in6 
      = "if foo == bar : "+Standard.NEWLINE
      + " _py_insert( \"abc\" )"
      ;
    String out6
      = "if foo == bar : "+Standard.NEWLINE
      + "  _py_insert( \"abc\" )"
      ;
    sec.setContent( in6 );
    pi.modify( sec, mps );   
    //System.out.println( in6  );
    //System.out.println( out6 );
    //System.out.println( sec.getContent() );
    assertTrue( out6.equals( sec.getContent() ) );

    String in7 
      = "if foo == bar : # fooby"+Standard.NEWLINE
      + "  _py_insert( \"abc\" )"
      ;
    String out7
      = "if foo == bar : # fooby"+Standard.NEWLINE
      + "  _py_insert( \"abc\" )"
      ;
    sec.setContent( in7 );
    pi.modify( sec, mps );   
    //System.out.println( in7  );
    //System.out.println( out7 );
    //System.out.println( sec.getContent() );
    assertTrue( out7.equals( sec.getContent() ) );

    String in8
      = "if foo == bar : # fooby"+Standard.NEWLINE
      + "  _py_insert( \"abc\" )"+Standard.NEWLINE
      + "    pass"
      ;
    String out8
      = "if foo == bar : # fooby"+Standard.NEWLINE
      + "    _py_insert( \"abc\" )"+Standard.NEWLINE
      + "    pass"
      ;
    sec.setContent( in8 );
    pi.modify( sec, mps );   
    //System.out.println( in8  );
    //System.out.println( out8 );
    //System.out.println( sec.getContent() );
    assertTrue( out8.equals( sec.getContent() ) );


    String in9
      = "if foo == bar : # fooby"+Standard.NEWLINE
      + " pass"+Standard.NEWLINE
      + "  _py_insert( \"abc\" )"

      ;
    String out9
      = "if foo == bar : # fooby"+Standard.NEWLINE
      + " pass"+Standard.NEWLINE
      + " _py_insert( \"abc\" )"

      ;
    sec.setContent( in9 );
    pi.modify( sec, mps );   
    //System.out.println( in9  );
    //System.out.println( out9 );
    //System.out.println( sec.getContent() );
    assertTrue( out9.equals( sec.getContent() ) );

    String in10
      = "  if foo == bar : # fooby"+Standard.NEWLINE
      + "  _py_insert( \"abc\" )"+Standard.NEWLINE
      + "    pass"

      ;
    String out10
      = "  if foo == bar : # fooby"+Standard.NEWLINE
      + "    _py_insert( \"abc\" )"+Standard.NEWLINE
      + "    pass"
      ;
    sec.setContent( in10 );
    pi.modify( sec, mps );   
    //System.out.println( in10  );
    //System.out.println( out10 );
    //System.out.println( sec.getContent() );
    assertTrue( out10.equals( sec.getContent() ) );

    String in11
      = "  if foo == bar : # fooby"+Standard.NEWLINE
      + "_py_insert( \"abc\" )"+Standard.NEWLINE
      + "  pass"

      ;
    String out11
      = "  if foo == bar : # fooby"+Standard.NEWLINE
      + "    _py_insert( \"abc\" )"+Standard.NEWLINE
      + "  pass"
      ;
    sec.setContent( in11 );
    pi.modify( sec, mps );   
    //System.out.println( in11  );
    //System.out.println( out11 );
    //System.out.println( sec.getContent() );
    assertTrue( out11.equals( sec.getContent() ) );

    String in12
      = "  if foo == bar : # fooby"+Standard.NEWLINE
      + "_py_insert( \"abc\" )"+Standard.NEWLINE
      + "pass"

      ;
    String out12
      = "  if foo == bar : # fooby"+Standard.NEWLINE
      + "    _py_insert( \"abc\" )"+Standard.NEWLINE
      + "pass"
      ;
    sec.setContent( in12 );
    pi.modify( sec, mps );   
    //System.out.println( in12  );
    //System.out.println( out12 );
    //System.out.println( sec.getContent() );
    assertTrue( out12.equals( sec.getContent() ) );

    String in13
      = "\tif foo == bar : # fooby"+Standard.NEWLINE
      + "_py_insert( \"abc\" )"+Standard.NEWLINE
      + "pass"

      ;
    String out13
      = "\tif foo == bar : # fooby"+Standard.NEWLINE
      + tabAsSpaces+"  _py_insert( \"abc\" )"+Standard.NEWLINE
      + "pass"
      ;
    sec.setContent( in13 );
    pi.modify( sec, mps );   
    //System.out.println( in13  );
    //System.out.println( out13 );
    //System.out.println( sec.getContent() );
    assertTrue( out13.equals( sec.getContent() ) );


    String in14
      = "def list( max ) :"+Standard.NEWLINE
      + ""+Standard.NEWLINE
      + "  _py_insert( \"\\nlist\" )"+Standard.NEWLINE
      + "_py_insert( max )"+Standard.NEWLINE
      + "_py_insert( \" = \" )"+Standard.NEWLINE
      + ""+Standard.NEWLINE
      + ""+Standard.NEWLINE
      + "  for i in range( 0, max ) :"+Standard.NEWLINE
      + "    _py_insert( \"[\" )"+Standard.NEWLINE
      + "_py_insert( i )"+Standard.NEWLINE
      + "_py_insert( \"]\" )"+Standard.NEWLINE
      ;
    String out14
      = "def list( max ) :"+Standard.NEWLINE
      + "  _py_insert( \"\\nlist\" )"+Standard.NEWLINE
      + "  _py_insert( max )"+Standard.NEWLINE
      + "  _py_insert( \" = \" )"+Standard.NEWLINE
      + "  for i in range( 0, max ) :"+Standard.NEWLINE
      + "    _py_insert( \"[\" )"+Standard.NEWLINE
      + "    _py_insert( i )"+Standard.NEWLINE
      + "    _py_insert( \"]\" )"+Standard.NEWLINE
      ;
    sec = new BasicSection( "declare" );
    sec.setContent( in14 );
    pi.modify( sec, mps );   
    //System.out.println( in14  );
    //System.out.println( out14 );
    //System.out.println( sec.getContent() );
    assertTrue( out14.equals( sec.getContent() ) );




  }
View Full Code Here

  public void testBasic() {

    String  s1_name  = "s1_name";
    String  s1_text1 = "s1_text1 ";
    Section s1       = (Section)( new BasicSection( s1_name ) );
    String  s2_name  = "s2_name";
    Section s2       = (Section)( new BasicSection( s2_name ) );

    assertEquals( s1, s1 );

    SectionSet ss = new SectionSet();
    ss.addSection( s1 );
View Full Code Here

    assertEquals( ss, ss );
  }


  public void testAddSection() {
    Section    s1  = new BasicSection( "s1" );
    SectionSet ss1 = new SectionSet();
    ss1.addSection( s1 );
    assertTrue( ss1.hasSection( "s1" ) );
    assertTrue( !ss1.hasSection( "s2" ) );
  }
View Full Code Here

    assertTrue( !ss1.hasSection( "s2" ) );
  }


  public void testHasSection() {
    Section    s1  = new BasicSection( "s1" );
    SectionSet ss1 = new SectionSet();
    ss1.addSection( s1 );
    assertTrue( ss1.hasSection( "s1" ) );
    assertTrue( !ss1.hasSection( "s2" ) );
    assertTrue( !ss1.hasSection( null ) );
View Full Code Here

    assertTrue( !ss1.hasSection( null ) );
  }


  public void appendToSection() {
    Section    s1  = new BasicSection( "s1" );
    SectionSet ss1 = new SectionSet();
    ss1.addSection( s1 );
    ss1.appendToSection( "s1", "a" );
    assertTrue( ss1.hasSection( "s1" ) );
    assertEquals( "a", ss1.getSection( "s1").getContent() );
View Full Code Here

    assertEquals( "ab", ss1.getSection( "s1").getContent() );
  }


  public void testClearSection() {
    Section    s1  = new BasicSection( "s1" );
    SectionSet ss1 = new SectionSet();
    ss1.addSection( s1 );
    ss1.appendToSection( "s1", "a" );
    assertTrue( ss1.hasSection( "s1" ) );
    assertEquals( "a", ss1.getSection( "s1").getContent() );
View Full Code Here

TOP

Related Classes of org.jostraca.section.Section

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.