< prev index next >

src/jdk.xml.bind/share/classes/com/sun/codemodel/internal/JConditional.java

Print this page




  59     /**
  60      * Return the block to be excuted by the "then" branch
  61      *
  62      * @return Then block
  63      */
  64     public JBlock _then() {
  65         return _then;
  66     }
  67 
  68     /**
  69      * Create a block to be executed by "else" branch
  70      *
  71      * @return Newly generated else block
  72      */
  73     public JBlock _else() {
  74         if (_else == null) _else = new JBlock();
  75         return _else;
  76     }
  77 
  78     /**
  79      * Creates <tt>... else if(...) ...</tt> code.
  80      */
  81     public JConditional _elseif(JExpression boolExp) {
  82         return _else()._if(boolExp);
  83     }
  84 
  85     public void state(JFormatter f) {
  86         if(test==JExpr.TRUE) {
  87             _then.generateBody(f);
  88             return;
  89         }
  90         if(test==JExpr.FALSE) {
  91             _else.generateBody(f);
  92             return;
  93         }
  94 
  95         if (JOp.hasTopOp(test)) {
  96             f.p("if ").g(test);
  97         } else {
  98             f.p("if (").g(test).p(')');
  99         }


  59     /**
  60      * Return the block to be excuted by the "then" branch
  61      *
  62      * @return Then block
  63      */
  64     public JBlock _then() {
  65         return _then;
  66     }
  67 
  68     /**
  69      * Create a block to be executed by "else" branch
  70      *
  71      * @return Newly generated else block
  72      */
  73     public JBlock _else() {
  74         if (_else == null) _else = new JBlock();
  75         return _else;
  76     }
  77 
  78     /**
  79      * Creates {@code ... else if(...) ...} code.
  80      */
  81     public JConditional _elseif(JExpression boolExp) {
  82         return _else()._if(boolExp);
  83     }
  84 
  85     public void state(JFormatter f) {
  86         if(test==JExpr.TRUE) {
  87             _then.generateBody(f);
  88             return;
  89         }
  90         if(test==JExpr.FALSE) {
  91             _else.generateBody(f);
  92             return;
  93         }
  94 
  95         if (JOp.hasTopOp(test)) {
  96             f.p("if ").g(test);
  97         } else {
  98             f.p("if (").g(test).p(')');
  99         }
< prev index next >