Input: equality / inequality ( == / ! = ) ( level 6 ) [CODESPLIT] final public void equalityExpression ( ) throws ParseException { relationalExpression ( ) ; label_7 : while ( true ) { switch ( ( jj_ntk == - 1 ) ? jj_ntk ( ) : jj_ntk ) { case 15 : case 16 : case 17 : case 18 : ; break ; default : jj_la1 [ 13 ] = jj_gen ; break label_7 ; } switch ( ( jj_ntk == - 1 ) ? jj_ntk ( ) : jj_ntk ) { case 15 : case 16 : switch ( ( jj_ntk == - 1 ) ? jj_ntk ( ) : jj_ntk ) { case 15 : jj_consume_token ( 15 ) ; break ; case 16 : jj_consume_token ( 16 ) ; break ; default : jj_la1 [ 14 ] = jj_gen ; jj_consume_token ( - 1 ) ; throw new ParseException ( ) ; } ASTEq jjtn001 = new ASTEq ( JJTEQ ) ; boolean jjtc001 = true ; jjtree . openNodeScope ( jjtn001 ) ; try { relationalExpression ( ) ; } catch ( Throwable jjte001 ) { if ( jjtc001 ) { jjtree . clearNodeScope ( jjtn001 ) ; jjtc001 = false ; } else { jjtree . popNode ( ) ; } if ( jjte001 instanceof RuntimeException ) { { if ( true ) throw ( RuntimeException ) jjte001 ; } } if ( jjte001 instanceof ParseException ) { { if ( true ) throw ( ParseException ) jjte001 ; } } { if ( true ) throw ( Error ) jjte001 ; } } finally { if ( jjtc001 ) { jjtree . closeNodeScope ( jjtn001 , 2 ) ; } } break ; case 17 : case 18 : switch ( ( jj_ntk == - 1 ) ? jj_ntk ( ) : jj_ntk ) { case 17 : jj_consume_token ( 17 ) ; break ; case 18 : jj_consume_token ( 18 ) ; break ; default : jj_la1 [ 15 ] = jj_gen ; jj_consume_token ( - 1 ) ; throw new ParseException ( ) ; } ASTNotEq jjtn002 = new ASTNotEq ( JJTNOTEQ ) ; boolean jjtc002 = true ; jjtree . openNodeScope ( jjtn002 ) ; try { relationalExpression ( ) ; } catch ( Throwable jjte002 ) { if ( jjtc002 ) { jjtree . clearNodeScope ( jjtn002 ) ; jjtc002 = false ; } else { jjtree . popNode ( ) ; } if ( jjte002 instanceof RuntimeException ) { { if ( true ) throw ( RuntimeException ) jjte002 ; } } if ( jjte002 instanceof ParseException ) { { if ( true ) throw ( ParseException ) jjte002 ; } } { if ( true ) throw ( Error ) jjte002 ; } } finally { if ( jjtc002 ) { jjtree . closeNodeScope ( jjtn002 , 2 ) ; } } break ; default : jj_la1 [ 16 ] = jj_gen ; jj_consume_token ( - 1 ) ; throw new ParseException ( ) ; } } }


Input: boolean relational expressions ( level 5 ) [CODESPLIT] final public void relationalExpression ( ) throws ParseException { shiftExpression ( ) ; label_8 : while ( true ) { switch ( ( jj_ntk == - 1 ) ? jj_ntk ( ) : jj_ntk ) { case 19 : case 20 : case 21 : case 22 : case 23 : case 24 : case 25 : case 26 : case 27 : case 28 : ; break ; default : jj_la1 [ 17 ] = jj_gen ; break label_8 ; } switch ( ( jj_ntk == - 1 ) ? jj_ntk ( ) : jj_ntk ) { case 19 : case 20 : switch ( ( jj_ntk == - 1 ) ? jj_ntk ( ) : jj_ntk ) { case 19 : jj_consume_token ( 19 ) ; break ; case 20 : jj_consume_token ( 20 ) ; break ; default : jj_la1 [ 18 ] = jj_gen ; jj_consume_token ( - 1 ) ; throw new ParseException ( ) ; } ASTLess jjtn001 = new ASTLess ( JJTLESS ) ; boolean jjtc001 = true ; jjtree . openNodeScope ( jjtn001 ) ; try { shiftExpression ( ) ; } catch ( Throwable jjte001 ) { if ( jjtc001 ) { jjtree . clearNodeScope ( jjtn001 ) ; jjtc001 = false ; } else { jjtree . popNode ( ) ; } if ( jjte001 instanceof RuntimeException ) { { if ( true ) throw ( RuntimeException ) jjte001 ; } } if ( jjte001 instanceof ParseException ) { { if ( true ) throw ( ParseException ) jjte001 ; } } { if ( true ) throw ( Error ) jjte001 ; } } finally { if ( jjtc001 ) { jjtree . closeNodeScope ( jjtn001 , 2 ) ; } } break ; case 21 : case 22 : switch ( ( jj_ntk == - 1 ) ? jj_ntk ( ) : jj_ntk ) { case 21 : jj_consume_token ( 21 ) ; break ; case 22 : jj_consume_token ( 22 ) ; break ; default : jj_la1 [ 19 ] = jj_gen ; jj_consume_token ( - 1 ) ; throw new ParseException ( ) ; } ASTGreater jjtn002 = new ASTGreater ( JJTGREATER ) ; boolean jjtc002 = true ; jjtree . openNodeScope ( jjtn002 ) ; try { shiftExpression ( ) ; } catch ( Throwable jjte002 ) { if ( jjtc002 ) { jjtree . clearNodeScope ( jjtn002 ) ; jjtc002 = false ; } else { jjtree . popNode ( ) ; } if ( jjte002 instanceof RuntimeException ) { { if ( true ) throw ( RuntimeException ) jjte002 ; } } if ( jjte002 instanceof ParseException ) { { if ( true ) throw ( ParseException ) jjte002 ; } } { if ( true ) throw ( Error ) jjte002 ; } } finally { if ( jjtc002 ) { jjtree . closeNodeScope ( jjtn002 , 2 ) ; } } break ; case 23 : case 24 : switch ( ( jj_ntk == - 1 ) ? jj_ntk ( ) : jj_ntk ) { case 23 : jj_consume_token ( 23 ) ; break ; case 24 : jj_consume_token ( 24 ) ; break ; default : jj_la1 [ 20 ] = jj_gen ; jj_consume_token ( - 1 ) ; throw new ParseException ( ) ; } ASTLessEq jjtn003 = new ASTLessEq ( JJTLESSEQ ) ; boolean jjtc003 = true ; jjtree . openNodeScope ( jjtn003 ) ; try { shiftExpression ( ) ; } catch ( Throwable jjte003 ) { if ( jjtc003 ) { jjtree . clearNodeScope ( jjtn003 ) ; jjtc003 = false ; } else { jjtree . popNode ( ) ; } if ( jjte003 instanceof RuntimeException ) { { if ( true ) throw ( RuntimeException ) jjte003 ; } } if ( jjte003 instanceof ParseException ) { { if ( true ) throw ( ParseException ) jjte003 ; } } { if ( true ) throw ( Error ) jjte003 ; } } finally { if ( jjtc003 ) { jjtree . closeNodeScope ( jjtn003 , 2 ) ; } } break ; case 25 : case 26 : switch ( ( jj_ntk == - 1 ) ? jj_ntk ( ) : jj_ntk ) { case 25 : jj_consume_token ( 25 ) ; break ; case 26 : jj_consume_token ( 26 ) ; break ; default : jj_la1 [ 21 ] = jj_gen ; jj_consume_token ( - 1 ) ; throw new ParseException ( ) ; } ASTGreaterEq jjtn004 = new ASTGreaterEq ( JJTGREATEREQ ) ; boolean jjtc004 = true ; jjtree . openNodeScope ( jjtn004 ) ; try { shiftExpression ( ) ; } catch ( Throwable jjte004 ) { if ( jjtc004 ) { jjtree . clearNodeScope ( jjtn004 ) ; jjtc004 = false ; } else { jjtree . popNode ( ) ; } if ( jjte004 instanceof RuntimeException ) { { if ( true ) throw ( RuntimeException ) jjte004 ; } } if ( jjte004 instanceof ParseException ) { { if ( true ) throw ( ParseException ) jjte004 ; } } { if ( true ) throw ( Error ) jjte004 ; } } finally { if ( jjtc004 ) { jjtree . closeNodeScope ( jjtn004 , 2 ) ; } } break ; case 27 : jj_consume_token ( 27 ) ; ASTIn jjtn005 = new ASTIn ( JJTIN ) ; boolean jjtc005 = true ; jjtree . openNodeScope ( jjtn005 ) ; try { shiftExpression ( ) ; } catch ( Throwable jjte005 ) { if ( jjtc005 ) { jjtree . clearNodeScope ( jjtn005 ) ; jjtc005 = false ; } else { jjtree . popNode ( ) ; } if ( jjte005 instanceof RuntimeException ) { { if ( true ) throw ( RuntimeException ) jjte005 ; } } if ( jjte005 instanceof ParseException ) { { if ( true ) throw ( ParseException ) jjte005 ; } } { if ( true ) throw ( Error ) jjte005 ; } } finally { if ( jjtc005 ) { jjtree . closeNodeScope ( jjtn005 , 2 ) ; } } break ; case 28 : jj_consume_token ( 28 ) ; jj_consume_token ( 27 ) ; ASTNotIn jjtn006 = new ASTNotIn ( JJTNOTIN ) ; boolean jjtc006 = true ; jjtree . openNodeScope ( jjtn006 ) ; try { shiftExpression ( ) ; } catch ( Throwable jjte006 ) { if ( jjtc006 ) { jjtree . clearNodeScope ( jjtn006 ) ; jjtc006 = false ; } else { jjtree . popNode ( ) ; } if ( jjte006 instanceof RuntimeException ) { { if ( true ) throw ( RuntimeException ) jjte006 ; } } if ( jjte006 instanceof ParseException ) { { if ( true ) throw ( ParseException ) jjte006 ; } } { if ( true ) throw ( Error ) jjte006 ; } } finally { if ( jjtc006 ) { jjtree . closeNodeScope ( jjtn006 , 2 ) ; } } break ; default : jj_la1 [ 22 ] = jj_gen ; jj_consume_token ( - 1 ) ; throw new ParseException ( ) ; } } }


Input: bit shift expressions ( level 4 ) [CODESPLIT] final public void shiftExpression ( ) throws ParseException { additiveExpression ( ) ; label_9 : while ( true ) { switch ( ( jj_ntk == - 1 ) ? jj_ntk ( ) : jj_ntk ) { case 29 : case 30 : case 31 : case 32 : case 33 : case 34 : ; break ; default : jj_la1 [ 23 ] = jj_gen ; break label_9 ; } switch ( ( jj_ntk == - 1 ) ? jj_ntk ( ) : jj_ntk ) { case 29 : case 30 : switch ( ( jj_ntk == - 1 ) ? jj_ntk ( ) : jj_ntk ) { case 29 : jj_consume_token ( 29 ) ; break ; case 30 : jj_consume_token ( 30 ) ; break ; default : jj_la1 [ 24 ] = jj_gen ; jj_consume_token ( - 1 ) ; throw new ParseException ( ) ; } ASTShiftLeft jjtn001 = new ASTShiftLeft ( JJTSHIFTLEFT ) ; boolean jjtc001 = true ; jjtree . openNodeScope ( jjtn001 ) ; try { additiveExpression ( ) ; } catch ( Throwable jjte001 ) { if ( jjtc001 ) { jjtree . clearNodeScope ( jjtn001 ) ; jjtc001 = false ; } else { jjtree . popNode ( ) ; } if ( jjte001 instanceof RuntimeException ) { { if ( true ) throw ( RuntimeException ) jjte001 ; } } if ( jjte001 instanceof ParseException ) { { if ( true ) throw ( ParseException ) jjte001 ; } } { if ( true ) throw ( Error ) jjte001 ; } } finally { if ( jjtc001 ) { jjtree . closeNodeScope ( jjtn001 , 2 ) ; } } break ; case 31 : case 32 : switch ( ( jj_ntk == - 1 ) ? jj_ntk ( ) : jj_ntk ) { case 31 : jj_consume_token ( 31 ) ; break ; case 32 : jj_consume_token ( 32 ) ; break ; default : jj_la1 [ 25 ] = jj_gen ; jj_consume_token ( - 1 ) ; throw new ParseException ( ) ; } ASTShiftRight jjtn002 = new ASTShiftRight ( JJTSHIFTRIGHT ) ; boolean jjtc002 = true ; jjtree . openNodeScope ( jjtn002 ) ; try { additiveExpression ( ) ; } catch ( Throwable jjte002 ) { if ( jjtc002 ) { jjtree . clearNodeScope ( jjtn002 ) ; jjtc002 = false ; } else { jjtree . popNode ( ) ; } if ( jjte002 instanceof RuntimeException ) { { if ( true ) throw ( RuntimeException ) jjte002 ; } } if ( jjte002 instanceof ParseException ) { { if ( true ) throw ( ParseException ) jjte002 ; } } { if ( true ) throw ( Error ) jjte002 ; } } finally { if ( jjtc002 ) { jjtree . closeNodeScope ( jjtn002 , 2 ) ; } } break ; case 33 : case 34 : switch ( ( jj_ntk == - 1 ) ? jj_ntk ( ) : jj_ntk ) { case 33 : jj_consume_token ( 33 ) ; break ; case 34 : jj_consume_token ( 34 ) ; break ; default : jj_la1 [ 26 ] = jj_gen ; jj_consume_token ( - 1 ) ; throw new ParseException ( ) ; } ASTUnsignedShiftRight jjtn003 = new ASTUnsignedShiftRight ( JJTUNSIGNEDSHIFTRIGHT ) ; boolean jjtc003 = true ; jjtree . openNodeScope ( jjtn003 ) ; try { additiveExpression ( ) ; } catch ( Throwable jjte003 ) { if ( jjtc003 ) { jjtree . clearNodeScope ( jjtn003 ) ; jjtc003 = false ; } else { jjtree . popNode ( ) ; } if ( jjte003 instanceof RuntimeException ) { { if ( true ) throw ( RuntimeException ) jjte003 ; } } if ( jjte003 instanceof ParseException ) { { if ( true ) throw ( ParseException ) jjte003 ; } } { if ( true ) throw ( Error ) jjte003 ; } } finally { if ( jjtc003 ) { jjtree . closeNodeScope ( jjtn003 , 2 ) ; } } break ; default : jj_la1 [ 27 ] = jj_gen ; jj_consume_token ( - 1 ) ; throw new ParseException ( ) ; } } }


Input: binary addition / subtraction ( level 3 ) [CODESPLIT] final public void additiveExpression ( ) throws ParseException { multiplicativeExpression ( ) ; label_10 : while ( true ) { switch ( ( jj_ntk == - 1 ) ? jj_ntk ( ) : jj_ntk ) { case 35 : case 36 : ; break ; default : jj_la1 [ 28 ] = jj_gen ; break label_10 ; } switch ( ( jj_ntk == - 1 ) ? jj_ntk ( ) : jj_ntk ) { case 35 : jj_consume_token ( 35 ) ; ASTAdd jjtn001 = new ASTAdd ( JJTADD ) ; boolean jjtc001 = true ; jjtree . openNodeScope ( jjtn001 ) ; try { multiplicativeExpression ( ) ; } catch ( Throwable jjte001 ) { if ( jjtc001 ) { jjtree . clearNodeScope ( jjtn001 ) ; jjtc001 = false ; } else { jjtree . popNode ( ) ; } if ( jjte001 instanceof RuntimeException ) { { if ( true ) throw ( RuntimeException ) jjte001 ; } } if ( jjte001 instanceof ParseException ) { { if ( true ) throw ( ParseException ) jjte001 ; } } { if ( true ) throw ( Error ) jjte001 ; } } finally { if ( jjtc001 ) { jjtree . closeNodeScope ( jjtn001 , 2 ) ; } } break ; case 36 : jj_consume_token ( 36 ) ; ASTSubtract jjtn002 = new ASTSubtract ( JJTSUBTRACT ) ; boolean jjtc002 = true ; jjtree . openNodeScope ( jjtn002 ) ; try { multiplicativeExpression ( ) ; } catch ( Throwable jjte002 ) { if ( jjtc002 ) { jjtree . clearNodeScope ( jjtn002 ) ; jjtc002 = false ; } else { jjtree . popNode ( ) ; } if ( jjte002 instanceof RuntimeException ) { { if ( true ) throw ( RuntimeException ) jjte002 ; } } if ( jjte002 instanceof ParseException ) { { if ( true ) throw ( ParseException ) jjte002 ; } } { if ( true ) throw ( Error ) jjte002 ; } } finally { if ( jjtc002 ) { jjtree . closeNodeScope ( jjtn002 , 2 ) ; } } break ; default : jj_la1 [ 29 ] = jj_gen ; jj_consume_token ( - 1 ) ; throw new ParseException ( ) ; } } }


Input: multiplication / division / remainder ( level 2 ) [CODESPLIT] final public void multiplicativeExpression ( ) throws ParseException { unaryExpression ( ) ; label_11 : while ( true ) { switch ( ( jj_ntk == - 1 ) ? jj_ntk ( ) : jj_ntk ) { case 37 : case 38 : case 39 : ; break ; default : jj_la1 [ 30 ] = jj_gen ; break label_11 ; } switch ( ( jj_ntk == - 1 ) ? jj_ntk ( ) : jj_ntk ) { case 37 : jj_consume_token ( 37 ) ; ASTMultiply jjtn001 = new ASTMultiply ( JJTMULTIPLY ) ; boolean jjtc001 = true ; jjtree . openNodeScope ( jjtn001 ) ; try { unaryExpression ( ) ; } catch ( Throwable jjte001 ) { if ( jjtc001 ) { jjtree . clearNodeScope ( jjtn001 ) ; jjtc001 = false ; } else { jjtree . popNode ( ) ; } if ( jjte001 instanceof RuntimeException ) { { if ( true ) throw ( RuntimeException ) jjte001 ; } } if ( jjte001 instanceof ParseException ) { { if ( true ) throw ( ParseException ) jjte001 ; } } { if ( true ) throw ( Error ) jjte001 ; } } finally { if ( jjtc001 ) { jjtree . closeNodeScope ( jjtn001 , 2 ) ; } } break ; case 38 : jj_consume_token ( 38 ) ; ASTDivide jjtn002 = new ASTDivide ( JJTDIVIDE ) ; boolean jjtc002 = true ; jjtree . openNodeScope ( jjtn002 ) ; try { unaryExpression ( ) ; } catch ( Throwable jjte002 ) { if ( jjtc002 ) { jjtree . clearNodeScope ( jjtn002 ) ; jjtc002 = false ; } else { jjtree . popNode ( ) ; } if ( jjte002 instanceof RuntimeException ) { { if ( true ) throw ( RuntimeException ) jjte002 ; } } if ( jjte002 instanceof ParseException ) { { if ( true ) throw ( ParseException ) jjte002 ; } } { if ( true ) throw ( Error ) jjte002 ; } } finally { if ( jjtc002 ) { jjtree . closeNodeScope ( jjtn002 , 2 ) ; } } break ; case 39 : jj_consume_token ( 39 ) ; ASTRemainder jjtn003 = new ASTRemainder ( JJTREMAINDER ) ; boolean jjtc003 = true ; jjtree . openNodeScope ( jjtn003 ) ; try { unaryExpression ( ) ; } catch ( Throwable jjte003 ) { if ( jjtc003 ) { jjtree . clearNodeScope ( jjtn003 ) ; jjtc003 = false ; } else { jjtree . popNode ( ) ; } if ( jjte003 instanceof RuntimeException ) { { if ( true ) throw ( RuntimeException ) jjte003 ; } } if ( jjte003 instanceof ParseException ) { { if ( true ) throw ( ParseException ) jjte003 ; } } { if ( true ) throw ( Error ) jjte003 ; } } finally { if ( jjtc003 ) { jjtree . closeNodeScope ( jjtn003 , 2 ) ; } } break ; default : jj_la1 [ 31 ] = jj_gen ; jj_consume_token ( - 1 ) ; throw new ParseException ( ) ; } } }


Input: unary ( level 1 ) [CODESPLIT] final public void unaryExpression ( ) throws ParseException { StringBuffer sb ; Token t ; ASTInstanceof ionode ; switch ( ( jj_ntk == - 1 ) ? jj_ntk ( ) : jj_ntk ) { case 36 : jj_consume_token ( 36 ) ; ASTNegate jjtn001 = new ASTNegate ( JJTNEGATE ) ; boolean jjtc001 = true ; jjtree . openNodeScope ( jjtn001 ) ; try { unaryExpression ( ) ; } catch ( Throwable jjte001 ) { if ( jjtc001 ) { jjtree . clearNodeScope ( jjtn001 ) ; jjtc001 = false ; } else { jjtree . popNode ( ) ; } if ( jjte001 instanceof RuntimeException ) { { if ( true ) throw ( RuntimeException ) jjte001 ; } } if ( jjte001 instanceof ParseException ) { { if ( true ) throw ( ParseException ) jjte001 ; } } { if ( true ) throw ( Error ) jjte001 ; } } finally { if ( jjtc001 ) { jjtree . closeNodeScope ( jjtn001 , 1 ) ; } } break ; case 35 : jj_consume_token ( 35 ) ; unaryExpression ( ) ; break ; case 40 : jj_consume_token ( 40 ) ; ASTBitNegate jjtn002 = new ASTBitNegate ( JJTBITNEGATE ) ; boolean jjtc002 = true ; jjtree . openNodeScope ( jjtn002 ) ; try { unaryExpression ( ) ; } catch ( Throwable jjte002 ) { if ( jjtc002 ) { jjtree . clearNodeScope ( jjtn002 ) ; jjtc002 = false ; } else { jjtree . popNode ( ) ; } if ( jjte002 instanceof RuntimeException ) { { if ( true ) throw ( RuntimeException ) jjte002 ; } } if ( jjte002 instanceof ParseException ) { { if ( true ) throw ( ParseException ) jjte002 ; } } { if ( true ) throw ( Error ) jjte002 ; } } finally { if ( jjtc002 ) { jjtree . closeNodeScope ( jjtn002 , 1 ) ; } } break ; case 28 : case 41 : switch ( ( jj_ntk == - 1 ) ? jj_ntk ( ) : jj_ntk ) { case 41 : jj_consume_token ( 41 ) ; break ; case 28 : jj_consume_token ( 28 ) ; break ; default : jj_la1 [ 32 ] = jj_gen ; jj_consume_token ( - 1 ) ; throw new ParseException ( ) ; } ASTNot jjtn003 = new ASTNot ( JJTNOT ) ; boolean jjtc003 = true ; jjtree . openNodeScope ( jjtn003 ) ; try { unaryExpression ( ) ; } catch ( Throwable jjte003 ) { if ( jjtc003 ) { jjtree . clearNodeScope ( jjtn003 ) ; jjtc003 = false ; } else { jjtree . popNode ( ) ; } if ( jjte003 instanceof RuntimeException ) { { if ( true ) throw ( RuntimeException ) jjte003 ; } } if ( jjte003 instanceof ParseException ) { { if ( true ) throw ( ParseException ) jjte003 ; } } { if ( true ) throw ( Error ) jjte003 ; } } finally { if ( jjtc003 ) { jjtree . closeNodeScope ( jjtn003 , 1 ) ; } } break ; case 4 : case 44 : case 46 : case 47 : case 48 : case 49 : case 50 : case 51 : case 52 : case 54 : case 56 : case 57 : case IDENT : case DYNAMIC_SUBSCRIPT : case CHAR_LITERAL : case BACK_CHAR_LITERAL : case STRING_LITERAL : case INT_LITERAL : case FLT_LITERAL : navigationChain ( ) ; switch ( ( jj_ntk == - 1 ) ? jj_ntk ( ) : jj_ntk ) { case 42 : jj_consume_token ( 42 ) ; t = jj_consume_token ( IDENT ) ; ASTInstanceof jjtn004 = new ASTInstanceof ( JJTINSTANCEOF ) ; boolean jjtc004 = true ; jjtree . openNodeScope ( jjtn004 ) ; try { jjtree . closeNodeScope ( jjtn004 , 1 ) ; jjtc004 = false ; sb = new StringBuffer ( t . image ) ; ionode = jjtn004 ; } finally { if ( jjtc004 ) { jjtree . closeNodeScope ( jjtn004 , 1 ) ; } } label_12 : while ( true ) { switch ( ( jj_ntk == - 1 ) ? jj_ntk ( ) : jj_ntk ) { case 43 : ; break ; default : jj_la1 [ 33 ] = jj_gen ; break label_12 ; } jj_consume_token ( 43 ) ; t = jj_consume_token ( IDENT ) ; sb . append ( ' ' ) . append ( t . image ) ; } ionode . setTargetType ( new String ( sb ) ) ; break ; default : jj_la1 [ 34 ] = jj_gen ; ; } break ; default : jj_la1 [ 35 ] = jj_gen ; jj_consume_token ( - 1 ) ; throw new ParseException ( ) ; } }


Input: navigation chain : property references method calls projections selections etc . [CODESPLIT] final public void navigationChain ( ) throws ParseException { primaryExpression ( ) ; label_13 : while ( true ) { switch ( ( jj_ntk == - 1 ) ? jj_ntk ( ) : jj_ntk ) { case 43 : case 44 : case 52 : case DYNAMIC_SUBSCRIPT : ; break ; default : jj_la1 [ 36 ] = jj_gen ; break label_13 ; } switch ( ( jj_ntk == - 1 ) ? jj_ntk ( ) : jj_ntk ) { case 43 : jj_consume_token ( 43 ) ; ASTChain jjtn001 = new ASTChain ( JJTCHAIN ) ; boolean jjtc001 = true ; jjtree . openNodeScope ( jjtn001 ) ; try { switch ( ( jj_ntk == - 1 ) ? jj_ntk ( ) : jj_ntk ) { case IDENT : if ( jj_2_1 ( 2 ) ) { methodCall ( ) ; } else { switch ( ( jj_ntk == - 1 ) ? jj_ntk ( ) : jj_ntk ) { case IDENT : propertyName ( ) ; break ; default : jj_la1 [ 37 ] = jj_gen ; jj_consume_token ( - 1 ) ; throw new ParseException ( ) ; } } break ; case 54 : if ( jj_2_2 ( 2 ) ) { projection ( ) ; } else { switch ( ( jj_ntk == - 1 ) ? jj_ntk ( ) : jj_ntk ) { case 54 : selection ( ) ; break ; default : jj_la1 [ 38 ] = jj_gen ; jj_consume_token ( - 1 ) ; throw new ParseException ( ) ; } } break ; case 44 : jj_consume_token ( 44 ) ; expression ( ) ; jj_consume_token ( 45 ) ; break ; default : jj_la1 [ 39 ] = jj_gen ; jj_consume_token ( - 1 ) ; throw new ParseException ( ) ; } } catch ( Throwable jjte001 ) { if ( jjtc001 ) { jjtree . clearNodeScope ( jjtn001 ) ; jjtc001 = false ; } else { jjtree . popNode ( ) ; } if ( jjte001 instanceof RuntimeException ) { { if ( true ) throw ( RuntimeException ) jjte001 ; } } if ( jjte001 instanceof ParseException ) { { if ( true ) throw ( ParseException ) jjte001 ; } } { if ( true ) throw ( Error ) jjte001 ; } } finally { if ( jjtc001 ) { jjtree . closeNodeScope ( jjtn001 , 2 ) ; } } break ; case 52 : case DYNAMIC_SUBSCRIPT : ASTChain jjtn002 = new ASTChain ( JJTCHAIN ) ; boolean jjtc002 = true ; jjtree . openNodeScope ( jjtn002 ) ; try { index ( ) ; } catch ( Throwable jjte002 ) { if ( jjtc002 ) { jjtree . clearNodeScope ( jjtn002 ) ; jjtc002 = false ; } else { jjtree . popNode ( ) ; } if ( jjte002 instanceof RuntimeException ) { { if ( true ) throw ( RuntimeException ) jjte002 ; } } if ( jjte002 instanceof ParseException ) { { if ( true ) throw ( ParseException ) jjte002 ; } } { if ( true ) throw ( Error ) jjte002 ; } } finally { if ( jjtc002 ) { jjtree . closeNodeScope ( jjtn002 , 2 ) ; } } break ; case 44 : jj_consume_token ( 44 ) ; expression ( ) ; ASTEval jjtn003 = new ASTEval ( JJTEVAL ) ; boolean jjtc003 = true ; jjtree . openNodeScope ( jjtn003 ) ; try { jj_consume_token ( 45 ) ; } finally { if ( jjtc003 ) { jjtree . closeNodeScope ( jjtn003 , 2 ) ; } } break ; default : jj_la1 [ 40 ] = jj_gen ; jj_consume_token ( - 1 ) ; throw new ParseException ( ) ; } } }


Input: Apply an expression to all elements of a collection creating a new collection as the result . [CODESPLIT] final public void projection ( ) throws ParseException { /*@bgen(jjtree) Project */ ASTProject jjtn000 = new ASTProject ( JJTPROJECT ) ; boolean jjtc000 = true ; jjtree . openNodeScope ( jjtn000 ) ; try { jj_consume_token ( 54 ) ; expression ( ) ; jj_consume_token ( 55 ) ; } catch ( Throwable jjte000 ) { if ( jjtc000 ) { jjtree . clearNodeScope ( jjtn000 ) ; jjtc000 = false ; } else { jjtree . popNode ( ) ; } if ( jjte000 instanceof RuntimeException ) { { if ( true ) throw ( RuntimeException ) jjte000 ; } } if ( jjte000 instanceof ParseException ) { { if ( true ) throw ( ParseException ) jjte000 ; } } { if ( true ) throw ( Error ) jjte000 ; } } finally { if ( jjtc000 ) { jjtree . closeNodeScope ( jjtn000 , true ) ; } } }


Input: Apply a boolean expression to all elements of a collection creating a new collection containing those elements for which the expression returned true . [CODESPLIT] final public void selectAll ( ) throws ParseException { /*@bgen(jjtree) Select */ ASTSelect jjtn000 = new ASTSelect ( JJTSELECT ) ; boolean jjtc000 = true ; jjtree . openNodeScope ( jjtn000 ) ; try { jj_consume_token ( 54 ) ; jj_consume_token ( 3 ) ; expression ( ) ; jj_consume_token ( 55 ) ; } catch ( Throwable jjte000 ) { if ( jjtc000 ) { jjtree . clearNodeScope ( jjtn000 ) ; jjtc000 = false ; } else { jjtree . popNode ( ) ; } if ( jjte000 instanceof RuntimeException ) { { if ( true ) throw ( RuntimeException ) jjte000 ; } } if ( jjte000 instanceof ParseException ) { { if ( true ) throw ( ParseException ) jjte000 ; } } { if ( true ) throw ( Error ) jjte000 ; } } finally { if ( jjtc000 ) { jjtree . closeNodeScope ( jjtn000 , true ) ; } } }


Input: Apply a boolean expression to all elements of a collection creating a new collection containing those elements for the first element for which the expression returned true . [CODESPLIT] final public void selectFirst ( ) throws ParseException { /*@bgen(jjtree) SelectFirst */ ASTSelectFirst jjtn000 = new ASTSelectFirst ( JJTSELECTFIRST ) ; boolean jjtc000 = true ; jjtree . openNodeScope ( jjtn000 ) ; try { jj_consume_token ( 54 ) ; jj_consume_token ( 11 ) ; expression ( ) ; jj_consume_token ( 55 ) ; } catch ( Throwable jjte000 ) { if ( jjtc000 ) { jjtree . clearNodeScope ( jjtn000 ) ; jjtc000 = false ; } else { jjtree . popNode ( ) ; } if ( jjte000 instanceof RuntimeException ) { { if ( true ) throw ( RuntimeException ) jjte000 ; } } if ( jjte000 instanceof ParseException ) { { if ( true ) throw ( ParseException ) jjte000 ; } } { if ( true ) throw ( Error ) jjte000 ; } } finally { if ( jjtc000 ) { jjtree . closeNodeScope ( jjtn000 , true ) ; } } }


Input: Apply a boolean expression to all elements of a collection creating a new collection containing those elements for the first element for which the expression returned true . [CODESPLIT] final public void selectLast ( ) throws ParseException { /*@bgen(jjtree) SelectLast */ ASTSelectLast jjtn000 = new ASTSelectLast ( JJTSELECTLAST ) ; boolean jjtc000 = true ; jjtree . openNodeScope ( jjtn000 ) ; try { jj_consume_token ( 54 ) ; jj_consume_token ( 58 ) ; expression ( ) ; jj_consume_token ( 55 ) ; } catch ( Throwable jjte000 ) { if ( jjtc000 ) { jjtree . clearNodeScope ( jjtn000 ) ; jjtc000 = false ; } else { jjtree . popNode ( ) ; } if ( jjte000 instanceof RuntimeException ) { { if ( true ) throw ( RuntimeException ) jjte000 ; } } if ( jjte000 instanceof ParseException ) { { if ( true ) throw ( ParseException ) jjte000 ; } } { if ( true ) throw ( Error ) jjte000 ; } } finally { if ( jjtc000 ) { jjtree . closeNodeScope ( jjtn000 , true ) ; } } }


Input: Compares two objects for equality even if it has to convert one of them to the other type . If both objects are numeric they are converted to the widest type and compared . If one is non - numeric and one is numeric the non - numeric is converted to double and compared to the double numeric value . If both are non - numeric and Comparable and the types are compatible ( i . e . v1 is of the same or superclass of v2 s type ) they are compared with Comparable . compareTo () . If both values are non - numeric and not Comparable or of incompatible classes this will throw and IllegalArgumentException . [CODESPLIT] public static int compareWithConversion ( Object v1 , Object v2 ) { int result ; if ( v1 == v2 ) { result = 0 ; } else { int t1 = getNumericType ( v1 ) , t2 = getNumericType ( v2 ) , type = getNumericType ( t1 , t2 , true ) ; switch ( type ) { case BIGINT : result = bigIntValue ( v1 ) . compareTo ( bigIntValue ( v2 ) ) ; break ; case BIGDEC : result = bigDecValue ( v1 ) . compareTo ( bigDecValue ( v2 ) ) ; break ; case NONNUMERIC : if ( ( t1 == NONNUMERIC ) && ( t2 == NONNUMERIC ) ) { if ( ( v1 instanceof Comparable ) && v1 . getClass ( ) . isAssignableFrom ( v2 . getClass ( ) ) ) { result = ( ( Comparable ) v1 ) . compareTo ( v2 ) ; break ; } else { throw new IllegalArgumentException ( "invalid comparison: " + v1 . getClass ( ) . getName ( ) + " and " + v2 . getClass ( ) . getName ( ) ) ; } } // else fall through case FLOAT : case DOUBLE : double dv1 = doubleValue ( v1 ) , dv2 = doubleValue ( v2 ) ; return ( dv1 == dv2 ) ? 0 : ( ( dv1 < dv2 ) ? - 1 : 1 ) ; default : long lv1 = longValue ( v1 ) , lv2 = longValue ( v2 ) ; return ( lv1 == lv2 ) ? 0 : ( ( lv1 < lv2 ) ? - 1 : 1 ) ; } } return result ; }


Input: Returns true if object1 is equal to object2 in either the sense that they are the same object or if both are non - null if they are equal in the <CODE > equals () < / CODE > sense . [CODESPLIT] public static boolean isEqual ( Object object1 , Object object2 ) { boolean result = false ; if ( object1 == object2 ) { result = true ; } else { if ( ( object1 != null ) && object1 . getClass ( ) . isArray ( ) ) { if ( ( object2 != null ) && object2 . getClass ( ) . isArray ( ) && ( object2 . getClass ( ) == object1 . getClass ( ) ) ) { result = ( Array . getLength ( object1 ) == Array . getLength ( object2 ) ) ; if ( result ) { for ( int i = 0 , icount = Array . getLength ( object1 ) ; result && ( i < icount ) ; i ++ ) { result = isEqual ( Array . get ( object1 , i ) , Array . get ( object2 , i ) ) ; } } } } else { // Check for converted equivalence first, then equals() equivalence result = ( object1 != null ) && ( object2 != null ) && ( object1 . equals ( object2 ) || ( compareWithConversion ( object1 , object2 ) == 0 ) ) ; } } return result ; }


Input: Evaluates the given object as a boolean : if it is a Boolean object it s easy ; if it s a Number or a Character returns true for non - zero objects ; and otherwise returns true for non - null objects . [CODESPLIT] public static boolean booleanValue ( Object value ) { if ( value == null ) return false ; Class c = value . getClass ( ) ; if ( c == Boolean . class ) return ( ( Boolean ) value ) . booleanValue ( ) ; if ( c == String . class ) return Boolean . parseBoolean ( String . valueOf ( value ) ) ; if ( c == Character . class ) return ( ( Character ) value ) . charValue ( ) != 0 ; if ( value instanceof Number ) return ( ( Number ) value ) . doubleValue ( ) != 0 ; return true ; // non-null }


Input: Evaluates the given object as a long integer . [CODESPLIT] public static long longValue ( Object value ) throws NumberFormatException { if ( value == null ) return 0L ; Class c = value . getClass ( ) ; if ( c . getSuperclass ( ) == Number . class ) return ( ( Number ) value ) . longValue ( ) ; if ( c == Boolean . class ) return ( ( Boolean ) value ) . booleanValue ( ) ? 1 : 0 ; if ( c == Character . class ) return ( ( Character ) value ) . charValue ( ) ; return Long . parseLong ( stringValue ( value , true ) ) ; }


Input: Evaluates the given object as a double - precision floating - point number . [CODESPLIT] public static double doubleValue ( Object value ) throws NumberFormatException { if ( value == null ) return 0.0 ; Class c = value . getClass ( ) ; if ( c . getSuperclass ( ) == Number . class ) return ( ( Number ) value ) . doubleValue ( ) ; if ( c == Boolean . class ) return ( ( Boolean ) value ) . booleanValue ( ) ? 1 : 0 ; if ( c == Character . class ) return ( ( Character ) value ) . charValue ( ) ; String s = stringValue ( value , true ) ; return ( s . length ( ) == 0 ) ? 0.0 : Double . parseDouble ( s ) ; }


Input: Evaluates the given object as a BigInteger . [CODESPLIT] public static BigInteger bigIntValue ( Object value ) throws NumberFormatException { if ( value == null ) return BigInteger . valueOf ( 0L ) ; Class c = value . getClass ( ) ; if ( c == BigInteger . class ) return ( BigInteger ) value ; if ( c == BigDecimal . class ) return ( ( BigDecimal ) value ) . toBigInteger ( ) ; if ( c . getSuperclass ( ) == Number . class ) return BigInteger . valueOf ( ( ( Number ) value ) . longValue ( ) ) ; if ( c == Boolean . class ) return BigInteger . valueOf ( ( ( Boolean ) value ) . booleanValue ( ) ? 1 : 0 ) ; if ( c == Character . class ) return BigInteger . valueOf ( ( ( Character ) value ) . charValue ( ) ) ; return new BigInteger ( stringValue ( value , true ) ) ; }


Input: Evaluates the given object as a BigDecimal . [CODESPLIT] public static BigDecimal bigDecValue ( Object value ) throws NumberFormatException { if ( value == null ) return BigDecimal . valueOf ( 0L ) ; Class c = value . getClass ( ) ; if ( c == BigDecimal . class ) return ( BigDecimal ) value ; if ( c == BigInteger . class ) return new BigDecimal ( ( BigInteger ) value ) ; if ( c == Boolean . class ) return BigDecimal . valueOf ( ( ( Boolean ) value ) . booleanValue ( ) ? 1 : 0 ) ; if ( c == Character . class ) return BigDecimal . valueOf ( ( ( Character ) value ) . charValue ( ) ) ; return new BigDecimal ( stringValue ( value , true ) ) ; }


Input: Evaluates the given object as a String and trims it if the trim flag is true . [CODESPLIT] public static String stringValue ( Object value , boolean trim ) { String result ; if ( value == null ) { result = OgnlRuntime . NULL_STRING ; } else { result = value . toString ( ) ; if ( trim ) { result = result . trim ( ) ; } } return result ; }


Input: Returns a constant from the NumericTypes interface that represents the numeric type of the given object . [CODESPLIT] public static int getNumericType ( Object value ) { if ( value != null ) { Class c = value . getClass ( ) ; if ( c == Integer . class ) return INT ; if ( c == Double . class ) return DOUBLE ; if ( c == Boolean . class ) return BOOL ; if ( c == Byte . class ) return BYTE ; if ( c == Character . class ) return CHAR ; if ( c == Short . class ) return SHORT ; if ( c == Long . class ) return LONG ; if ( c == Float . class ) return FLOAT ; if ( c == BigInteger . class ) return BIGINT ; if ( c == BigDecimal . class ) return BIGDEC ; } return NONNUMERIC ; }


Input: ////////////////////////////////////////////////////////////// [CODESPLIT] public static Object convertValue ( char value , Class toType , boolean preventNull ) { return convertValue ( new Character ( value ) , toType , preventNull ) ; }


Input: /////////////////////////////////////////////////////////////// [CODESPLIT] public static Object toArray ( char value , Class toType , boolean preventNull ) { return toArray ( new Character ( value ) , toType , preventNull ) ; }


Input: Returns the value converted numerically to the given class type This method also detects when arrays are being converted and converts the components of one array to the type of the other . [CODESPLIT] public static Object convertValue ( Object value , Class toType ) { return convertValue ( value , toType , false ) ; }


Input: Converts the specified value to a primitive integer value . [CODESPLIT] public static int getIntValue ( Object value ) { try { if ( value == null ) return - 1 ; if ( Number . class . isInstance ( value ) ) { return ( ( Number ) value ) . intValue ( ) ; } String str = String . class . isInstance ( value ) ? ( String ) value : value . toString ( ) ; return Integer . parseInt ( str ) ; } catch ( Throwable t ) { throw new RuntimeException ( "Error converting " + value + " to integer:" , t ) ; } }


Input: Returns the constant from the NumericTypes interface that best expresses the type of an operation which can be either numeric or not on the two given types . [CODESPLIT] public static int getNumericType ( int t1 , int t2 , boolean canBeNonNumeric ) { if ( t1 == t2 ) return t1 ; if ( canBeNonNumeric && ( t1 == NONNUMERIC || t2 == NONNUMERIC || t1 == CHAR || t2 == CHAR ) ) return NONNUMERIC ; if ( t1 == NONNUMERIC ) t1 = DOUBLE ; // Try to interpret strings as doubles... if ( t2 == NONNUMERIC ) t2 = DOUBLE ; // Try to interpret strings as doubles... if ( t1 >= MIN_REAL_TYPE ) { if ( t2 >= MIN_REAL_TYPE ) return Math . max ( t1 , t2 ) ; if ( t2 < INT ) return t1 ; if ( t2 == BIGINT ) return BIGDEC ; return Math . max ( DOUBLE , t1 ) ; } else if ( t2 >= MIN_REAL_TYPE ) { if ( t1 < INT ) return t2 ; if ( t1 == BIGINT ) return BIGDEC ; return Math . max ( DOUBLE , t2 ) ; } else return Math . max ( t1 , t2 ) ; }


Input: Returns the constant from the NumericTypes interface that best expresses the type of an operation which can be either numeric or not on the two given objects . [CODESPLIT] public static int getNumericType ( Object v1 , Object v2 , boolean canBeNonNumeric ) { return getNumericType ( getNumericType ( v1 ) , getNumericType ( v2 ) , canBeNonNumeric ) ; }


Input: Returns a new Number object of an appropriate type to hold the given integer value . The type of the returned object is consistent with the given type argument which is a constant from the NumericTypes interface . [CODESPLIT] public static Number newInteger ( int type , long value ) { switch ( type ) { case BOOL : case CHAR : case INT : return new Integer ( ( int ) value ) ; case FLOAT : if ( ( long ) ( float ) value == value ) { return new Float ( ( float ) value ) ; } // else fall through: case DOUBLE : if ( ( long ) ( double ) value == value ) { return new Double ( ( double ) value ) ; } // else fall through: case LONG : return new Long ( value ) ; case BYTE : return new Byte ( ( byte ) value ) ; case SHORT : return new Short ( ( short ) value ) ; default : return BigInteger . valueOf ( value ) ; } }


Input: Returns a new Number object of an appropriate type to hold the given real value . The type of the returned object is always either Float or Double and is only Float if the given type tag ( a constant from the NumericTypes interface ) is FLOAT . [CODESPLIT] public static Number newReal ( int type , double value ) { if ( type == FLOAT ) return new Float ( ( float ) value ) ; return new Double ( value ) ; }


Input: Utility method that converts incoming exceptions to { @link RuntimeException } instances - or casts them if they already are . [CODESPLIT] public static RuntimeException castToRuntime ( Throwable t ) { if ( RuntimeException . class . isInstance ( t ) ) return ( RuntimeException ) t ; if ( OgnlException . class . isInstance ( t ) ) throw new UnsupportedCompilationException ( "Error evluating expression: " + t . getMessage ( ) , t ) ; return new RuntimeException ( t ) ; }


Input: / * =================================================================== Overridden methods =================================================================== [CODESPLIT] public Class defineClass ( String enhancedClassName , byte [ ] byteCode ) { return defineClass ( enhancedClassName , byteCode , 0 , byteCode . length ) ; }


Input: Gets the current class type being evaluated on the stack as set by { @link #setCurrentType ( Class ) } . [CODESPLIT] public Class getCurrentType ( ) { if ( _typeStack . isEmpty ( ) ) return null ; return ( Class ) _typeStack . get ( _typeStack . size ( ) - 1 ) ; }


Input: Represents the last known object type on the evaluation stack will be the value of the last known { @link #getCurrentType () } . [CODESPLIT] public Class getPreviousType ( ) { if ( _typeStack . isEmpty ( ) ) return null ; if ( _typeStack . size ( ) > 1 ) return _typeStack . get ( _typeStack . size ( ) - 2 ) ; else return null ; }


Input: Returns the Evaluation at the relative index given . This should be zero or a negative number as a relative reference back up the evaluation stack . Therefore getEvaluation ( 0 ) returns the current Evaluation . [CODESPLIT] public Evaluation getEvaluation ( int relativeIndex ) { Evaluation result = null ; if ( relativeIndex <= 0 ) { result = _currentEvaluation ; while ( ( ++ relativeIndex < 0 ) && ( result != null ) ) { result = result . getParent ( ) ; } } return result ; }


Input: Pushes a new Evaluation onto the stack . This is done before a node evaluates . When evaluation is complete it should be popped from the stack via <code > popEvaluation () < / code > . [CODESPLIT] public void pushEvaluation ( Evaluation value ) { if ( _currentEvaluation != null ) { _currentEvaluation . addChild ( value ) ; } else { setRootEvaluation ( value ) ; } setCurrentEvaluation ( value ) ; }


Input: Pops the current Evaluation off of the top of the stack . This is done after a node has completed its evaluation . [CODESPLIT] public Evaluation popEvaluation ( ) { Evaluation result ; result = _currentEvaluation ; setCurrentEvaluation ( result . getParent ( ) ) ; if ( _currentEvaluation == null ) { setLastEvaluation ( getKeepLastEvaluation ( ) ? result : null ) ; setRootEvaluation ( null ) ; setCurrentNode ( null ) ; } return result ; }


Input: Used by { @link #castExpression ( ognl . OgnlContext ognl . Node String ) } to store the cast java source string in to the current { @link OgnlContext } . This will either add to the existing string present if it already exists or create a new instance and store it using the static key of { @link #PRE_CAST } . [CODESPLIT] public static void addCastString ( OgnlContext context , String cast ) { String value = ( String ) context . get ( PRE_CAST ) ; if ( value != null ) value = cast + value ; else value = cast ; context . put ( PRE_CAST , value ) ; }


Input: Returns the appropriate casting expression ( minus parens ) for the specified class type . [CODESPLIT] public static String getCastString ( Class type ) { if ( type == null ) return null ; return type . isArray ( ) ? type . getComponentType ( ) . getName ( ) + "[]" : type . getName ( ) ; }


Input: Convenience method called by many different property / method resolving AST types to get a root expression resolving string for the given node . The callers are mostly ignorant and rely on this method to properly determine if the expression should be cast at all and take the appropriate actions if it should . [CODESPLIT] public static String getRootExpression ( Node expression , Object root , OgnlContext context ) { String rootExpr = "" ; if ( ! shouldCast ( expression ) ) return rootExpr ; if ( ( ! ASTList . class . isInstance ( expression ) && ! ASTVarRef . class . isInstance ( expression ) && ! ASTStaticMethod . class . isInstance ( expression ) && ! ASTStaticField . class . isInstance ( expression ) && ! ASTConst . class . isInstance ( expression ) && ! ExpressionNode . class . isInstance ( expression ) && ! ASTCtor . class . isInstance ( expression ) && ! ASTStaticMethod . class . isInstance ( expression ) && root != null ) || ( root != null && ASTRootVarRef . class . isInstance ( expression ) ) ) { Class castClass = OgnlRuntime . getCompiler ( ) . getRootExpressionClass ( expression , context ) ; if ( castClass . isArray ( ) || ASTRootVarRef . class . isInstance ( expression ) || ASTThisVarRef . class . isInstance ( expression ) ) { rootExpr = "((" + getCastString ( castClass ) + ")$2)" ; if ( ASTProperty . class . isInstance ( expression ) && ! ( ( ASTProperty ) expression ) . isIndexedAccess ( ) ) rootExpr += "." ; } else if ( ( ASTProperty . class . isInstance ( expression ) && ( ( ASTProperty ) expression ) . isIndexedAccess ( ) ) || ASTChain . class . isInstance ( expression ) ) { rootExpr = "((" + getCastString ( castClass ) + ")$2)" ; } else { rootExpr = "((" + getCastString ( castClass ) + ")$2)." ; } } return rootExpr ; }


Input: Used by { @link #getRootExpression ( ognl . Node Object ognl . OgnlContext ) } to determine if the expression needs to be cast at all . [CODESPLIT] public static boolean shouldCast ( Node expression ) { if ( ASTChain . class . isInstance ( expression ) ) { Node child = expression . jjtGetChild ( 0 ) ; if ( ASTConst . class . isInstance ( child ) || ASTStaticMethod . class . isInstance ( child ) || ASTStaticField . class . isInstance ( child ) || ( ASTVarRef . class . isInstance ( child ) && ! ASTRootVarRef . class . isInstance ( child ) ) ) return false ; } return ! ASTConst . class . isInstance ( expression ) ; }


Input: Helper utility method used by compiler to help resolve class - > method mappings during method calls to { @link OgnlExpressionCompiler#getSuperOrInterfaceClass ( java . lang . reflect . Method Class ) } . [CODESPLIT] public boolean containsMethod ( Method m , Class clazz ) { Method [ ] methods = clazz . getMethods ( ) ; if ( methods == null ) return false ; for ( int i = 0 ; i < methods . length ; i ++ ) { if ( methods [ i ] . getName ( ) . equals ( m . getName ( ) ) && methods [ i ] . getReturnType ( ) == m . getReturnType ( ) ) { Class [ ] parms = m . getParameterTypes ( ) ; if ( parms == null ) continue ; Class [ ] mparms = methods [ i ] . getParameterTypes ( ) ; if ( mparms == null || mparms . length != parms . length ) continue ; boolean parmsMatch = true ; for ( int p = 0 ; p < parms . length ; p ++ ) { if ( parms [ p ] != mparms [ p ] ) { parmsMatch = false ; break ; } } if ( ! parmsMatch ) continue ; Class [ ] exceptions = m . getExceptionTypes ( ) ; if ( exceptions == null ) continue ; Class [ ] mexceptions = methods [ i ] . getExceptionTypes ( ) ; if ( mexceptions == null || mexceptions . length != exceptions . length ) continue ; boolean exceptionsMatch = true ; for ( int e = 0 ; e < exceptions . length ; e ++ ) { if ( exceptions [ e ] != mexceptions [ e ] ) { exceptionsMatch = false ; break ; } } if ( ! exceptionsMatch ) continue ; return true ; } } return false ; }


Input: / * ( non - Javadoc ) [CODESPLIT] public void compileExpression ( OgnlContext context , Node expression , Object root ) throws Exception { //        System.out.println("Compiling expr class " + expression.getClass().getName() + " and root " + root); if ( expression . getAccessor ( ) != null ) return ; String getBody , setBody ; EnhancedClassLoader loader = getClassLoader ( context ) ; ClassPool pool = getClassPool ( context , loader ) ; CtClass newClass = pool . makeClass ( expression . getClass ( ) . getName ( ) + expression . hashCode ( ) + _classCounter ++ + "Accessor" ) ; newClass . addInterface ( getCtClass ( ExpressionAccessor . class ) ) ; CtClass ognlClass = getCtClass ( OgnlContext . class ) ; CtClass objClass = getCtClass ( Object . class ) ; CtMethod valueGetter = new CtMethod ( objClass , "get" , new CtClass [ ] { ognlClass , objClass } , newClass ) ; CtMethod valueSetter = new CtMethod ( CtClass . voidType , "set" , new CtClass [ ] { ognlClass , objClass , objClass } , newClass ) ; CtField nodeMember = null ; // will only be set if uncompilable exception is thrown CtClass nodeClass = getCtClass ( Node . class ) ; CtMethod setExpression = null ; try { getBody = generateGetter ( context , newClass , objClass , pool , valueGetter , expression , root ) ; } catch ( UnsupportedCompilationException uc ) { //uc.printStackTrace(); nodeMember = new CtField ( nodeClass , "_node" , newClass ) ; newClass . addField ( nodeMember ) ; getBody = generateOgnlGetter ( newClass , valueGetter , nodeMember ) ; if ( setExpression == null ) { setExpression = CtNewMethod . setter ( "setExpression" , nodeMember ) ; newClass . addMethod ( setExpression ) ; } } try { setBody = generateSetter ( context , newClass , objClass , pool , valueSetter , expression , root ) ; } catch ( UnsupportedCompilationException uc ) { //uc.printStackTrace(); if ( nodeMember == null ) { nodeMember = new CtField ( nodeClass , "_node" , newClass ) ; newClass . addField ( nodeMember ) ; } setBody = generateOgnlSetter ( newClass , valueSetter , nodeMember ) ; if ( setExpression == null ) { setExpression = CtNewMethod . setter ( "setExpression" , nodeMember ) ; newClass . addMethod ( setExpression ) ; } } try { newClass . addConstructor ( CtNewConstructor . defaultConstructor ( newClass ) ) ; Class clazz = pool . toClass ( newClass ) ; newClass . detach ( ) ; expression . setAccessor ( ( ExpressionAccessor ) clazz . newInstance ( ) ) ; // need to set expression on node if the field was just defined. if ( nodeMember != null ) { expression . getAccessor ( ) . setExpression ( expression ) ; } } catch ( Throwable t ) { //t.printStackTrace(); throw new RuntimeException ( "Error compiling expression on object " + root + " with expression node " + expression + " getter body: " + getBody + " setter body: " + setBody , t ) ; } }


Input: Fail safe getter creation when normal compilation fails . [CODESPLIT] protected String generateOgnlGetter ( CtClass clazz , CtMethod valueGetter , CtField node ) throws Exception { String body = "return " + node . getName ( ) + ".getValue($1, $2);" ; valueGetter . setBody ( body ) ; clazz . addMethod ( valueGetter ) ; return body ; }


Input: Fail safe setter creation when normal compilation fails . [CODESPLIT] protected String generateOgnlSetter ( CtClass clazz , CtMethod valueSetter , CtField node ) throws Exception { String body = node . getName ( ) + ".setValue($1, $2, $3);" ; valueSetter . setBody ( body ) ; clazz . addMethod ( valueSetter ) ; return body ; }


Input: Creates a { @link ClassLoader } instance compatible with the javassist classloader and normal OGNL class resolving semantics . [CODESPLIT] protected EnhancedClassLoader getClassLoader ( OgnlContext context ) { EnhancedClassLoader ret = ( EnhancedClassLoader ) _loaders . get ( context . getClassResolver ( ) ) ; if ( ret != null ) return ret ; ClassLoader classLoader = new ContextClassLoader ( OgnlContext . class . getClassLoader ( ) , context ) ; ret = new EnhancedClassLoader ( classLoader ) ; _loaders . put ( context . getClassResolver ( ) , ret ) ; return ret ; }


Input: Gets either a new or existing { @link ClassPool } for use in compiling javassist classes . A new class path object is inserted in to the returned { @link ClassPool } using the passed in <code > loader< / code > instance if a new pool needs to be created . [CODESPLIT] protected ClassPool getClassPool ( OgnlContext context , EnhancedClassLoader loader ) { if ( _pool != null ) return _pool ; _pool = ClassPool . getDefault ( ) ; _pool . insertClassPath ( new LoaderClassPath ( loader . getParent ( ) ) ) ; return _pool ; }


Input: / * Returns the node on the top of the stack and remove it from the stack . [CODESPLIT] public Node popNode ( ) { if ( -- sp < mk ) { mk = ( ( Integer ) marks . remove ( marks . size ( ) - 1 ) ) . intValue ( ) ; } return ( Node ) nodes . remove ( nodes . size ( ) - 1 ) ; }


Input: / * Override this method if you want to customize how the node dumps out its children . [CODESPLIT] public void dump ( PrintWriter writer , String prefix ) { writer . println ( toString ( prefix ) ) ; if ( _children != null ) { for ( int i = 0 ; i < _children . length ; ++ i ) { SimpleNode n = ( SimpleNode ) _children [ i ] ; if ( n != null ) { n . dump ( writer , prefix + "  " ) ; } } } }


Input: This method may be called from subclasses jjtClose methods . It flattens the tree under this node by eliminating any children that are of the same class as this node and copying their children to this node . [CODESPLIT] protected void flattenTree ( ) { boolean shouldFlatten = false ; int newSize = 0 ; for ( int i = 0 ; i < _children . length ; ++ i ) if ( _children [ i ] . getClass ( ) == getClass ( ) ) { shouldFlatten = true ; newSize += _children [ i ] . jjtGetNumChildren ( ) ; } else ++ newSize ; if ( shouldFlatten ) { Node [ ] newChildren = new Node [ newSize ] ; int j = 0 ; for ( int i = 0 ; i < _children . length ; ++ i ) { Node c = _children [ i ] ; if ( c . getClass ( ) == getClass ( ) ) { for ( int k = 0 ; k < c . jjtGetNumChildren ( ) ; ++ k ) newChildren [ j ++ ] = . jjtGetChild ( k ) ; } else newChildren [ j ++ ] = c ; } if ( j != newSize ) throw new Error ( "Assertion error: " + j + " != " + newSize ) ; _children = newChildren ; } }


Input: Returns OgnlRuntime . NotFound if the property does not exist . [CODESPLIT] public Object getPossibleProperty ( Map context , Object target , String name ) throws OgnlException { Object result ; OgnlContext ognlContext = ( OgnlContext ) context ; try { if ( ( result = OgnlRuntime . getMethodValue ( ognlContext , target , name , true ) ) == OgnlRuntime . NotFound ) { result = OgnlRuntime . getFieldValue ( ognlContext , target , name , true ) ; } } catch ( IntrospectionException ex ) { throw new OgnlException ( name , ex ) ; } catch ( OgnlException ex ) { throw ex ; } catch ( Exception ex ) { throw new OgnlException ( name , ex ) ; } return result ; }


Input: Returns OgnlRuntime . NotFound if the property does not exist . [CODESPLIT] public Object setPossibleProperty ( Map context , Object target , String name , Object value ) throws OgnlException { Object result = null ; OgnlContext ognlContext = ( OgnlContext ) context ; try { if ( ! OgnlRuntime . setMethodValue ( ognlContext , target , name , value , true ) ) { result = OgnlRuntime . setFieldValue ( ognlContext , target , name , value ) ? null : OgnlRuntime . NotFound ; } if ( result == OgnlRuntime . NotFound ) { Method m = OgnlRuntime . getWriteMethod ( target . getClass ( ) , name ) ; if ( m != null ) { result = m . invoke ( target , new Object [ ] { value } ) ; } } } catch ( IntrospectionException ex ) { throw new OgnlException ( name , ex ) ; } catch ( OgnlException ex ) { throw ex ; } catch ( Exception ex ) { throw new OgnlException ( name , ex ) ; } return result ; }


Input: Adds a child to the list of children of this evaluation . The parent of the child is set to the receiver and the children references are modified in the receiver to reflect the new child . The lastChild of the receiver is set to the child and the firstChild is set also if child is the first ( or only ) child . [CODESPLIT] public void addChild ( Evaluation child ) { if ( firstChild == null ) { firstChild = lastChild = child ; } else { if ( firstChild == lastChild ) { firstChild . next = child ; lastChild = child ; lastChild . previous = firstChild ; } else { child . previous = lastChild ; lastChild . next = child ; lastChild = child ; } } child . parent = this ; }


Input: Reinitializes this Evaluation to the parameters specified . [CODESPLIT] public void init ( SimpleNode node , Object source , boolean setOperation ) { this . node = node ; this . source = source ; this . setOperation = setOperation ; result = null ; exception = null ; parent = null ; next = null ; previous = null ; firstChild = null ; lastChild = null ; }


Input: / * =================================================================== Overridden methods =================================================================== [CODESPLIT] protected Class findClass ( String name ) throws ClassNotFoundException { if ( ( context != null ) && ( context . getClassResolver ( ) != null ) ) { return context . getClassResolver ( ) . classForName ( name , context ) ; } return super . findClass ( name ) ; }


Input: / * =================================================================== Protected methods =================================================================== [CODESPLIT] protected void rehash ( ) { int oldCapacity = table . length ; Entry oldTable [ ] = table ; int newCapacity = oldCapacity * 2 + 1 ; Entry newTable [ ] = new Entry [ newCapacity ] ; threshold = ( int ) ( newCapacity * loadFactor ) ; table = newTable ; for ( int i = oldCapacity ; i -- > 0 ; ) { for ( Entry old = oldTable [ i ] ; old != null ; ) { Entry e = old ; int index = ( e . hash & 0x7FFFFFFF ) % newCapacity ; old = old . next ; e . next = newTable [ index ] ; newTable [ index ] = e ; } } }


Input: Converts an escape sequence into a character value . [CODESPLIT] private char escapeChar ( ) { int ofs = image . length ( ) - 1 ; switch ( image . charAt ( ofs ) ) { case ' ' : return ' ' ; case ' ' : return ' ' ; case ' ' : return ' ' ; case ' ' : return ' ' ; case ' ' : return ' ' ; case ' ' : return ' ' ; case ' ' : return ' ' ; case ' ' : return ' ' ; } // Otherwise, it's an octal number.  Find the backslash and convert. while ( image . charAt ( -- ofs ) != ' ' ) { } int value = 0 ; while ( ++ ofs < image . length ( ) ) value = ( value << 3 ) | ( image . charAt ( ofs ) - ' ' ) ; return ( char ) value ; }


Input: Parses the given OGNL expression and returns a tree representation of the expression that can be used by <CODE > Ognl< / CODE > static methods . [CODESPLIT] public static Object parseExpression ( String expression ) throws OgnlException { try { OgnlParser parser = new OgnlParser ( new StringReader ( expression ) ) ; return parser . topLevelExpression ( ) ; } catch ( ParseException e ) { throw new ExpressionSyntaxException ( expression , e ) ; } catch ( TokenMgrError e ) { throw new ExpressionSyntaxException ( expression , e ) ; } }


Input: Parses and compiles the given expression using the { @link ognl . enhance . OgnlExpressionCompiler } returned from { @link ognl . OgnlRuntime#getCompiler () } . [CODESPLIT] public static Node compileExpression ( OgnlContext context , Object root , String expression ) throws Exception { Node expr = ( Node ) Ognl . parseExpression ( expression ) ; OgnlRuntime . compileExpression ( context , expr , root ) ; return expr ; }


Input: Creates and returns a new standard naming context for evaluating an OGNL expression . [CODESPLIT] @ Deprecated public static Map createDefaultContext ( Object root ) { return addDefaultContext ( root , null , null , null , new OgnlContext ( null , null , null ) ) ; }


Input: Creates and returns a new standard naming context for evaluating an OGNL expression . [CODESPLIT] @ Deprecated public static Map createDefaultContext ( Object root , ClassResolver classResolver ) { return addDefaultContext ( root , null , classResolver , null , new OgnlContext ( classResolver , null , null ) ) ; }


Input: Creates and returns a new standard naming context for evaluating an OGNL expression . [CODESPLIT] public static Map createDefaultContext ( Object root , MemberAccess memberAccess , ClassResolver classResolver , TypeConverter converter ) { return addDefaultContext ( root , memberAccess , classResolver , converter , new OgnlContext ( classResolver , converter , memberAccess ) ) ; }


Input: Creates and returns a new standard naming context for evaluating an OGNL expression . [CODESPLIT] public static Map createDefaultContext ( Object root , MemberAccess memberAccess ) { return addDefaultContext ( root , memberAccess , null , null , new OgnlContext ( null , null , memberAccess ) ) ; }


Input: Appends the standard naming context for evaluating an OGNL expression into the context given so that cached maps can be used as a context . [CODESPLIT] @ Deprecated public static Map addDefaultContext ( Object root , Map context ) { return addDefaultContext ( root , null , null , null , context ) ; }


Input: Appends the standard naming context for evaluating an OGNL expression into the context given so that cached maps can be used as a context . [CODESPLIT] public static Map addDefaultContext ( Object root , ClassResolver classResolver , Map context ) { return addDefaultContext ( root , null , classResolver , null , context ) ; }


Input: Appends the standard naming context for evaluating an OGNL expression into the context given so that cached maps can be used as a context . [CODESPLIT] public static Map addDefaultContext ( Object root , MemberAccess memberAccess , ClassResolver classResolver , TypeConverter converter , Map context ) { OgnlContext result ; if ( context instanceof OgnlContext ) { result = ( OgnlContext ) context ; } else { result = new OgnlContext ( memberAccess , classResolver , converter , context ) ; } result . setRoot ( root ) ; return result ; }


Input: Gets the currently configured { @link TypeConverter } for the given context - if any . [CODESPLIT] public static TypeConverter getTypeConverter ( Map context ) { if ( context instanceof OgnlContext ) { return ( ( OgnlContext ) context ) . getTypeConverter ( ) ; } return null ; }


Input: Sets the root object to use for all expressions in the given context - doesn t necessarily replace root object instances explicitly passed in to other expression resolving methods on this class . [CODESPLIT] public static void setRoot ( Map context , Object root ) { context . put ( OgnlContext . ROOT_CONTEXT_KEY , root ) ; }


Input: Evaluates the given OGNL expression tree to extract a value from the given root object . The default context is set for the given context and root via <CODE > addDefaultContext () < / CODE > . [CODESPLIT] public static Object getValue ( Object tree , Map context , Object root ) throws OgnlException { return getValue ( tree , context , root , null ) ; }


Input: Evaluates the given OGNL expression tree to extract a value from the given root object . The default context is set for the given context and root via <CODE > addDefaultContext () < / CODE > . [CODESPLIT] public static Object getValue ( Object tree , Map context , Object root , Class resultType ) throws OgnlException { Object result ; OgnlContext ognlContext = ( OgnlContext ) addDefaultContext ( root , context ) ; Node node = ( Node ) tree ; if ( node . getAccessor ( ) != null ) result = node . getAccessor ( ) . get ( ognlContext , root ) ; else result = node . getValue ( ognlContext , root ) ; if ( resultType != null ) { result = getTypeConverter ( context ) . convertValue ( context , root , null , null , result , resultType ) ; } return result ; }


Input: Gets the value represented by the given pre - compiled expression on the specified root object . [CODESPLIT] public static Object getValue ( ExpressionAccessor expression , OgnlContext context , Object root ) { return expression . get ( context , root ) ; }


Input: Gets the value represented by the given pre - compiled expression on the specified root object . [CODESPLIT] public static Object getValue ( ExpressionAccessor expression , OgnlContext context , Object root , Class resultType ) { return getTypeConverter ( context ) . convertValue ( context , root , null , null , expression . get ( context , root ) , resultType ) ; }


Input: Evaluates the given OGNL expression to extract a value from the given root object in a given context [CODESPLIT] public static Object getValue ( String expression , Map context , Object root ) throws OgnlException { return getValue ( expression , context , root , null ) ; }


Input: Evaluates the given OGNL expression tree to extract a value from the given root object . [CODESPLIT] @ Deprecated public static Object getValue ( Object tree , Object root ) throws OgnlException { return getValue ( tree , root , null ) ; }


Input: Evaluates the given OGNL expression tree to extract a value from the given root object . [CODESPLIT] public static Object getValue ( Object tree , Object root , Class resultType ) throws OgnlException { return getValue ( tree , createDefaultContext ( root ) , root , resultType ) ; }


Input: Convenience method that combines calls to <code > parseExpression < / code > and <code > getValue< / code > . [CODESPLIT] public static Object getValue ( String expression , Object root ) throws OgnlException { return getValue ( expression , root , null ) ; }


Input: Convenience method that combines calls to <code > parseExpression < / code > and <code > getValue< / code > . [CODESPLIT] public static Object getValue ( String expression , Object root , Class resultType ) throws OgnlException { return getValue ( parseExpression ( expression ) , root , resultType ) ; }


Input: Evaluates the given OGNL expression tree to insert a value into the object graph rooted at the given root object . The default context is set for the given context and root via <CODE > addDefaultContext () < / CODE > . [CODESPLIT] public static void setValue ( Object tree , Map context , Object root , Object value ) throws OgnlException { OgnlContext ognlContext = ( OgnlContext ) addDefaultContext ( root , context ) ; Node n = ( Node ) tree ; if ( n . getAccessor ( ) != null ) { n . getAccessor ( ) . set ( ognlContext , root , value ) ; return ; } n . setValue ( ognlContext , root , value ) ; }


Input: Sets the value given using the pre - compiled expression on the specified root object . [CODESPLIT] public static void setValue ( ExpressionAccessor expression , OgnlContext context , Object root , Object value ) { expression . set ( context , root , value ) ; }


Input: Evaluates the given OGNL expression tree to insert a value into the object graph rooted at the given root object . [CODESPLIT] public static void setValue ( Object tree , Object root , Object value ) throws OgnlException { setValue ( tree , createDefaultContext ( root ) , root , value ) ; }


Input: Convenience method that combines calls to <code > parseExpression < / code > and <code > setValue< / code > . [CODESPLIT] public static void setValue ( String expression , Object root , Object value ) throws OgnlException { setValue ( parseExpression ( expression ) , root , value ) ; }


Input: Checks if the specified { @link Node } instance represents a constant expression . [CODESPLIT] public static boolean isConstant ( Object tree , Map context ) throws OgnlException { return ( ( SimpleNode ) tree ) . isConstant ( ( OgnlContext ) addDefaultContext ( null , context ) ) ; }


Input: Checks if the specified expression represents a constant expression . [CODESPLIT] public static boolean isConstant ( String expression , Map context ) throws OgnlException { return isConstant ( parseExpression ( expression ) , context ) ; }


Input: Returns default watch service identifier based on operating system . [CODESPLIT] public static String getDefaultWatchServiceId ( ) { String result = "polling" ; String osName = System . getProperty ( "os.name" ) ; if ( osName != null ) { osName = osName . toLowerCase ( Locale . ENGLISH ) ; if ( osName . contains ( "windows" ) || osName . contains ( "linux" ) ) { result = isAtLeastJava7 ( ) ? "jdk7" : "jnotify" ; } else if ( osName . contains ( "mac" ) ) { result = "jnotify" ; } } return result ; }


Input: startTimeout in milliseconds [CODESPLIT] protected void waitForServerStarted ( String rootUrl , JavaRunnable runner , int startTimeout , boolean spawned ) throws MojoExecutionException , IOException { long endTimeMillis = startTimeout > 0 ? System . currentTimeMillis ( ) + startTimeout : 0L ; boolean started = false ; URL connectUrl = new URL ( rootUrl ) ; int verifyWaitDelay = 1000 ; while ( ! started ) { if ( startTimeout > 0 && endTimeMillis - System . currentTimeMillis ( ) < 0L ) { if ( spawned ) { InternalPlay2StopMojo internalStop = new InternalPlay2StopMojo ( ) ; internalStop . project = project ; try { internalStop . execute ( ) ; } catch ( MojoExecutionException e ) { // just ignore } catch ( MojoFailureException e ) { // just ignore } } throw new MojoExecutionException ( String . format ( "Failed to start Play! server in %d ms" , Integer . valueOf ( startTimeout ) ) ) ; } BuildException runnerException = runner . getException ( ) ; if ( runnerException != null ) { throw new MojoExecutionException ( "Play! server start exception" , runnerException ) ; } try { URLConnection conn = connectUrl . openConnection ( ) ; if ( startTimeout > 0 ) { int connectTimeOut = Long . valueOf ( Math . min ( endTimeMillis - System . currentTimeMillis ( ) , Integer . valueOf ( Integer . MAX_VALUE ) . longValue ( ) ) ) . intValue ( ) ; if ( connectTimeOut > 0 ) { conn . setConnectTimeout ( connectTimeOut ) ; } } connectUrl . openConnection ( ) . getContent ( ) ; started = true ; } catch ( Exception e ) { // return false; } if ( ! started ) { long sleepTime = verifyWaitDelay ; if ( startTimeout > 0 ) { sleepTime = Math . min ( sleepTime , endTimeMillis - System . currentTimeMillis ( ) ) ; } if ( sleepTime > 0 ) { try { Thread . sleep ( sleepTime ) ; } catch ( InterruptedException e ) { throw new MojoExecutionException ( "?" , e ) ; } } } } }


Input: { [CODESPLIT] @ Override public FileWatcher watch ( List < File > filesToWatch , FileWatchCallback watchCallback ) throws FileWatchException { List < File > dirsToWatch = new ArrayList < File > ( filesToWatch . size ( ) ) ; for ( File file : filesToWatch ) { if ( file . exists ( ) ) { if ( file . isDirectory ( ) ) { dirsToWatch . add ( file ) ; } else { if ( log != null && log . isWarnEnabled ( ) ) { log . warn ( String . format ( "[jdk7] \"%s\" is not a directory, will not be watched." , file . getAbsolutePath ( ) ) ) ; } } } else { if ( log != null && log . isWarnEnabled ( ) ) { log . warn ( String . format ( "[jdk7] \"%s\" does not exist, will not be watched." , file . getAbsolutePath ( ) ) ) ; } } } try { JDK7FileWatcher result = new JDK7FileWatcher ( log , dirsToWatch , watchCallback ) ; Thread thread = new Thread ( result , "jdk7-play-watch-service" ) ; thread . setDaemon ( true ) ; thread . start ( ) ; return result ; } catch ( IOException e ) { throw new FileWatchException ( "JDK7FileWatcher initialization failed" , e ) ; } }


Input:
Performs mapping from the position in generated source file to the position in { @code routes } file it was generated from .

 Returns :

 position in { @code routes } file

 { @code null } value if file of the input position is not recognized as generated from { @code routes } file

 [CODESPLIT] @ Override public SourcePosition map ( SourcePosition p ) throws IOException { SourcePosition result = null ; File generatedFile = p . getFile ( ) ; if ( generatedFile != null && generatedFile . isFile ( ) ) { String [ ] generatedFileLines = readFileAsString ( generatedFile ) . split ( "\n" ) ; if ( generatedFileLines [ 0 ] . startsWith ( Play2RoutesGeneratedSource . SOURCE_PREFIX ) // play 2.2.x - 2.3.x || Arrays . asList ( generatedFileLines ) . contains ( GENERATOR_LINE ) ) // play 2.4.x + { Play2RoutesGeneratedSource generatedSource = new Play2RoutesGeneratedSource ( generatedFileLines ) ; String sourceFileName = generatedSource . getSourceFileName ( ) ; if ( sourceFileName != null ) { File sourceFile = new File ( sourceFileName ) ; if ( sourceFile . isFile ( ) ) { int sourceLine = generatedSource . mapLine ( p . getLine ( ) ) ; String [ ] sourceFileLines = readFileAsString ( sourceFile ) . split ( "\n" ) ; if ( sourceFileLines . length >= sourceLine ) { String sourceLineContent = sourceFileLines [ sourceLine - 1 ] ; if ( sourceLineContent . endsWith ( "\r" ) ) // remove trailing CR (on Windows) { sourceLineContent = sourceLineContent . substring ( 0 , sourceLineContent . length ( ) - 1 ) ; } result = new Play2RoutesSourcePosition ( sourceLine , sourceLineContent , sourceFile ) ; } } } } } return result ; }


Input: copied from AbstractPlay2SourcePositionMapper . java [CODESPLIT] private String readFileAsString ( ) throws IOException { FileInputStream is = new FileInputStream ( e . source ( ) ) ; try { byte [ ] buffer = new byte [ 8192 ] ; int len = is . read ( buffer ) ; ByteArrayOutputStream out = new ByteArrayOutputStream ( ) ; while ( len != - 1 ) { out . write ( buffer , 0 , len ) ; len = is . read ( buffer ) ; } return charsetName != null ? new String ( out . toByteArray ( ) , charsetName ) : new String ( out . toByteArray ( ) ) ; } finally { is . close ( ) ; } }


Input: Contrary to its name this doesn t necessarily reload the app . It is invoked on every request and will only trigger a reload of the app if something has changed . [CODESPLIT] @ Override /* BuildLink interface */ public synchronized Object reload ( ) { Object result = null ; try { boolean reloadRequired = buildLink . build ( ) ; if ( reloadRequired ) { int version = ++ classLoaderVersion ; String name = "ReloadableClassLoader(v" + version + ")" ; currentApplicationClassLoader = new DelegatedResourcesClassLoader ( name , toUrls ( outputDirectories ) , baseLoader ) ; result = currentApplicationClassLoader ; } } catch ( MalformedURLException e ) { throw new UnexpectedException ( "Unexpected reloader exception" , e ) ; //?? } catch ( Play2BuildFailure e ) { result = new CompilationException ( e . getMessage ( ) , e . line ( ) , e . position ( ) , e . source ( ) != null ? e . source ( ) . getAbsolutePath ( ) : null , e . input ( ) ) ; } catch ( Play2BuildError e ) { result = new UnexpectedException ( e . getMessage ( ) , e . getCause ( ) ) ; //?? } return result ; }


Input: Called from Less script must be public [CODESPLIT] public static String readContent ( File file ) throws IOException { String result = null ; BufferedReader is = new BufferedReader ( new InputStreamReader ( new FileInputStream ( file ) , "UTF-8" ) ) ; try { StringBuilder sb = new StringBuilder ( ) ; String line = is . readLine ( ) ; while ( line != null ) { sb . append ( line ) . append ( ' ' ) ; line = is . readLine ( ) ; } result = sb . toString ( ) ; } finally { is . close ( ) ; } return result ; }


Input: Called from Less script must be public [CODESPLIT] public static File resolve ( File originalSource , String imported ) { return new File ( originalSource . getParentFile ( ) , imported ) ; }


Input: Process all the comma delimited list of packages . <p > Package names are effectively converted into a directory on the file system and the class files are found and processed . < / p > [CODESPLIT] public List < File > collectClassFilesToEnhance ( long lastEnhanced , File outputDirectory , String packageNames ) { if ( packageNames == null || packageNames . isEmpty ( ) ) { return collectClassFilesToEnhanceFromPackage ( lastEnhanced , outputDirectory , "" , true ) ; // return; } List < File > result = new ArrayList < File > ( ) ; String [ ] pkgs = packageNames . split ( "," ) ; for ( int i = 0 ; i < pkgs . length ; i ++ ) { String pkg = pkgs [ i ] . trim ( ) . replace ( ' ' , ' ' ) ; boolean recurse = false ; if ( pkg . endsWith ( "**" ) ) { recurse = true ; pkg = pkg . substring ( 0 , pkg . length ( ) - 2 ) ; } else if ( pkg . endsWith ( "*" ) ) { recurse = true ; pkg = pkg . substring ( 0 , pkg . length ( ) - 1 ) ; } pkg = trimSlash ( pkg ) ; result . addAll ( collectClassFilesToEnhanceFromPackage ( lastEnhanced , outputDirectory , pkg , recurse ) ) ; } return result ; }


Input: Returns preconfigured archiver [CODESPLIT] protected Archiver getArchiver ( String archiverName ) throws NoSuchArchiverException { Archiver result = archiverManager . getArchiver ( archiverName ) ; result . setDuplicateBehavior ( Archiver . DUPLICATES_FAIL ) ; // Just in case return result ; }


Input: Check for potential Duplicate file exception before archive processing starts [CODESPLIT] protected void checkArchiverForProblems ( Archiver archiver ) { for ( ResourceIterator iter = archiver . getResources ( ) ; iter . hasNext ( ) ; ) { iter . next ( ) ; } }


Input: Private utility methods [CODESPLIT] protected /*private*/ Set < Artifact > getResolvedArtifact ( String groupId , String artifactId , String version ) throws ArtifactResolutionException { return getResolvedArtifact ( groupId , artifactId , version , true ) ; }


Input: Reads the content of the file to a string . [CODESPLIT] protected String readFileAsString ( File file ) throws IOException { FileInputStream is = new FileInputStream ( file ) ; try { byte [ ] buffer = new byte [ 8192 ] ; int len = is . read ( buffer ) ; ByteArrayOutputStream out = new ByteArrayOutputStream ( ) ; while ( len != - 1 ) { out . write ( buffer , 0 , len ) ; len = is . read ( buffer ) ; } return charsetName != null ? new String ( out . toByteArray ( ) , charsetName ) : new String ( out . toByteArray ( ) ) ; } finally { is . close ( ) ; } }


Input: === TEST =================================================================================== [CODESPLIT] private List < MavenProject > calculateProjectsToBuild ( Set < String > changedFilePaths ) { Set < MavenProject > changedProjects = new HashSet < MavenProject > ( projects . size ( ) ) ; for ( String path : changedFilePaths ) { MavenProject p = findProjectFor ( path ) ; changedProjects . add ( p ) ; } Set < MavenProject > changedAndDependentProjects = new HashSet < MavenProject > ( projects . size ( ) ) ; for ( MavenProject p : changedProjects ) { changedAndDependentProjects . add ( p ) ; List < MavenProject > deps = session . getProjectDependencyGraph ( ) . getDownstreamProjects ( p , true /*transitive*/ ) ; for ( MavenProject depP : deps ) { if ( projects . contains ( depP ) ) { changedAndDependentProjects . addAll ( deps ) ; } } } List < MavenProject > result = new ArrayList < MavenProject > ( changedAndDependentProjects . size ( ) ) ; for ( MavenProject p : projects ) { if ( changedAndDependentProjects . contains ( p ) ) { result . add ( p ) ; } } return result ; }


Input: { [CODESPLIT] @ Override public void initialize ( FileWatchLogger log ) throws FileWatchException { super . initialize ( log ) ; pollInterval = DEFAULT_POLL_INTERVAL ; String pollIntervalProp = System . getProperty ( "play2.pollInterval" ) ; if ( pollIntervalProp != null ) { try { pollInterval = Integer . parseInt ( pollIntervalProp ) ; } catch ( NumberFormatException e ) { log . warn ( String . format ( "Unparsable property value \"%s\", using default poll interval %d ms" , pollIntervalProp , Integer . valueOf ( DEFAULT_POLL_INTERVAL ) ) ) ; // throw new FileWatchException( "PollingFileWatcher initialization failed", e ); } } }


Input: { [CODESPLIT] @ Override public FileWatcher watch ( List < File > filesToWatch , FileWatchCallback watchCallback ) { PollingFileWatcher result = new PollingFileWatcher ( log , filesToWatch , watchCallback , pollInterval ) ; Thread thread = new Thread ( result , "polling-play-watch-service" ) ; thread . setDaemon ( true ) ; thread . start ( ) ; return result ; }


Input: Creates and configures Ant project for Java task . [CODESPLIT] protected Project createProject ( ) { final Project antProject = new Project ( ) ; final ProjectHelper helper = ProjectHelper . getProjectHelper ( ) ; antProject . addReference ( ProjectHelper . PROJECTHELPER_REFERENCE , helper ) ; helper . getImportStack ( ) . addElement ( "AntBuilder" ) ; // import checks that stack is not empty final BuildLogger logger = new NoBannerLogger ( ) ; logger . setMessageOutputLevel ( Project . MSG_INFO ) ; logger . setOutputPrintStream ( System . out ) ; logger . setErrorPrintStream ( System . err ) ; antProject . addBuildListener ( logger ) ; antProject . init ( ) ; antProject . getBaseDir ( ) ; return antProject ; }


Input: Adds string type system property to Ant Java task . [CODESPLIT] protected void addSystemProperty ( Java java , String propertyName , String propertyValue ) { Environment . Variable sysPropPlayHome = new Environment . Variable ( ) ; sysPropPlayHome . setKey ( propertyName ) ; sysPropPlayHome . setValue ( propertyValue ) ; java . addSysproperty ( sysPropPlayHome ) ; }


Input: Adds file type system property to Ant Java task . [CODESPLIT] protected void addSystemProperty ( Java java , String propertyName , File propertyValue ) { Environment . Variable sysPropPlayHome = new Environment . Variable ( ) ; sysPropPlayHome . setKey ( propertyName ) ; sysPropPlayHome . setFile ( propertyValue ) ; java . addSysproperty ( sysPropPlayHome ) ; }


Input: { [CODESPLIT] @ Override public void initialize ( FileWatchLogger log ) throws FileWatchException { super . initialize ( log ) ; File nativeLibsDirectory = new File ( "." ) ; // maybe change to temporary directory? String nativeLibsDirectoryProp = System . getProperty ( "play2.nativeLibsDirectory" ) ; if ( nativeLibsDirectoryProp != null && ! "" . equals ( nativeLibsDirectoryProp ) ) { nativeLibsDirectory = new File ( nativeLibsDirectoryProp ) ; } else { String targetDirectoryProp = System . getProperty ( "project.build.directory" ) ; if ( targetDirectoryProp != null && ! "" . equals ( targetDirectoryProp ) ) { File targetDirectory = new File ( targetDirectoryProp ) ; nativeLibsDirectory = new File ( targetDirectory , "native_libraries" ) ; } } String nativeLibsPath = nativeLibsDirectory . getAbsolutePath ( ) ; if ( ! nativeLibsDirectory . exists ( ) && ! nativeLibsDirectory . mkdirs ( ) ) { throw new FileWatchException ( String . format ( "Cannot create \"%s\" directory" , nativeLibsPath ) ) ; } String libraryOS = null ; String libraryName = "jnotify" ; String osName = System . getProperty ( "os.name" ) ; if ( osName != null ) { osName = osName . toLowerCase ( Locale . ENGLISH ) ; String architecture = System . getProperty ( "sun.arch.data.model" ) ; if ( osName . startsWith ( "windows" ) ) { libraryOS = "windows" + architecture ; if ( "amd64" . equals ( System . getProperty ( "os.arch" ) ) ) { libraryName = "jnotify_64bit" ; } } else if ( osName . equals ( "linux" ) ) { libraryOS = "linux" + architecture ; } else if ( osName . startsWith ( "mac os x" ) ) { libraryOS = "osx" ; } } if ( libraryOS == null ) { throw new FileWatchException ( String . format ( "JNotifyFileWatchService initialization failed - unsupported OS \"%s\"" , osName ) ) ; } String libraryResourceName = System . mapLibraryName ( libraryName ) ; libraryResourceName = libraryResourceName . replace ( ".dylib" , ".jnilib" ) ; // fix for JDK-7134701 bug File outputFile = new File ( nativeLibsDirectory , libraryResourceName ) ; if ( ! outputFile . exists ( ) ) { try { copyResourceToFile ( "META-INF/native/" + libraryOS , libraryResourceName , nativeLibsDirectory ) ; } catch ( IOException e ) { throw new FileWatchException ( "JNotifyFileWatchService initialization failed" , e ) ; } } // hack to update java.library.path try { String javaLibraryPath = System . getProperty ( "java.library.path" ) ; javaLibraryPath = javaLibraryPath != null ? javaLibraryPath + File . pathSeparator + nativeLibsPath : nativeLibsPath ; System . setProperty ( "java.library.path" , javaLibraryPath ) ; Field fieldSysPath = ClassLoader . class . getDeclaredField ( "sys_paths" ) ; fieldSysPath . setAccessible ( true ) ; fieldSysPath . set ( null , null ) ; } catch ( Exception e ) { throw new FileWatchException ( "JNotifyFileWatchService initialization failed" , e ) ; } // initialize JNotify try { JNotify . removeWatch ( 0 ) ; } catch ( JNotifyException e ) { throw new FileWatchException ( "JNotifyFileWatchService initialization failed" , e ) ; } }


Input: { [CODESPLIT] @ Override public FileWatcher watch ( List < File > filesToWatch , FileWatchCallback watchCallback ) throws FileWatchException { try { return new JNotifyFileWatcher ( log , filesToWatch , watchCallback ) ; } catch ( JNotifyException e ) { throw new FileWatchException ( "JNotifyFileWatcher initialization failed" , e ) ; } }


Input:
Performs mapping from the position in generated source file to the position in Twirl template file it was generated from .

 Returns :

 position in Twirl template file

 { @code null } value if file of the input position is not recognized as generated from Twirl template file

 [CODESPLIT] @ Override public SourcePosition map ( SourcePosition p ) throws IOException { SourcePosition result = null ; File generatedFile = p . getFile ( ) ; int generatedOffset = p . getOffset ( ) ; if ( generatedFile != null && generatedFile . isFile ( ) && generatedOffset >= 0 ) { Play2TemplateGeneratedSource generated = getGeneratedSource ( generatedFile ) ; if ( generated != null ) { String sourceFileName = generated . getSourceFileName ( ) ; if ( sourceFileName != null ) { File sourceFile = new File ( sourceFileName ) ; if ( sourceFile . isFile ( ) ) { int sourceOffset = generated . mapPosition ( generatedOffset ) ; String sourceFileContent = readFileAsString ( sourceFile ) ; if ( sourceFileContent . length ( ) > sourceOffset ) { String [ ] sourceFileLines = sourceFileContent . split ( "\n" ) ; Play2TemplateLocation sourceLocation = new Play2TemplateMapping ( sourceFileLines ) . location ( sourceOffset ) ; //if ( sourceLocation != null ) //{ result = new Play2TemplateSourcePosition ( sourceFile , sourceLocation ) ; //} } } } } } return result ; }


Input: } [CODESPLIT] public void set ( String fileName , Collection < String > dependencies ) { allDependencies . put ( fileName , new TreeSet < String > ( dependencies ) ) ; }


Input: Increment the counter in the current bucket by one for the given { @link NumerusRollingNumberEvent } type . <p > The { @link NumerusRollingNumberEvent } must be a counter type <code > HystrixRollingNumberEvent . isCounter () == true< / code > . [CODESPLIT] public void increment ( NumerusRollingNumberEvent type , Boolean doNotBlock ) { Bucket lastBucket = getCurrentBucket ( doNotBlock ) ; if ( lastBucket == null ) return ; lastBucket . getAdder ( type ) . increment ( ) ; }


Input: Get the sum of all buckets in the rolling counter for the given { @link NumerusRollingNumberEvent } type . <p > The { @link NumerusRollingNumberEvent } must be a counter type <code > HystrixRollingNumberEvent . isCounter () == true< / code > . [CODESPLIT] public long getRollingSum ( NumerusRollingNumberEvent type , Boolean doNotBlock ) { Bucket lastBucket = getCurrentBucket ( doNotBlock ) ; if ( lastBucket == null ) return 0 ; long sum = 0 ; for ( Bucket b : buckets ) { sum += b . getAdder ( type ) . sum ( ) ; } return sum ; }


Input: Get an array of values for all buckets in the rolling counter for the given { @link NumerusRollingNumberEvent } type . <p > Index 0 is the oldest bucket . <p > The { @link NumerusRollingNumberEvent } must be a counter type <code > HystrixRollingNumberEvent . isCounter () == true< / code > . [CODESPLIT] public long [ ] getValues ( NumerusRollingNumberEvent type ) { Bucket lastBucket = getCurrentBucket ( ) ; if ( lastBucket == null ) return new long [ 0 ] ; // get buckets as an array (which is a copy of the current state at this point in time) Bucket [ ] bucketArray = buckets . getArray ( ) ; // we have bucket data so we'll return an array of values for all buckets long values [ ] = new long [ bucketArray . length ] ; int i = 0 ; for ( Bucket bucket : bucketArray ) { if ( type . isCounter ( ) ) { values [ i ++ ] = bucket . getAdder ( type ) . sum ( ) ; } else if ( type . isMaxUpdater ( ) ) { values [ i ++ ] = bucket . getMaxUpdater ( type ) . max ( ) ; } } return values ; }


Input: Get the max value of values in all buckets for the given { @link NumerusRollingNumberEvent } type . <p > The { @link NumerusRollingNumberEvent } must be a max updater type <code > HystrixRollingNumberEvent . isMaxUpdater () == true< / code > . [CODESPLIT] public long getRollingMaxValue ( NumerusRollingNumberEvent type ) { long values [ ] = getValues ( type ) ; if ( values . length == 0 ) { return 0 ; } else { Arrays . sort ( values ) ; return values [ values . length - 1 ] ; } }


Input:
/ * package for testing [CODESPLIT] Bucket getCurrentBucket ( Boolean doNotBlock ) { long currentTime = time . getCurrentTimeInMillis ( ) ; /* a shortcut to try and get the most common result of immediately finding the current bucket */ /**
         * Retrieve the latest bucket if the given time is BEFORE the end of the bucket window, otherwise it returns NULL.
         *
         * NOTE: This is thread-safe because it's accessing 'buckets' which is a LinkedBlockingDeque
         */ Bucket currentBucket = buckets . peekLast ( ) ; if ( currentBucket != null && currentTime < currentBucket . windowStart + getBucketSizeInMilliseconds ( ) ) { // if we're within the bucket 'window of time' return the current one // NOTE: We do not worry if we are BEFORE the window in a weird case of where thread scheduling causes that to occur, // we'll just use the latest as long as we're not AFTER the window return currentBucket ; } /* if we didn't find the current bucket above, then we have to create one */ /**
         * The following needs to be synchronized/locked even with a synchronized/thread-safe data structure such as LinkedBlockingDeque because
         * the logic involves multiple steps to check existence, create an object then insert the object. The 'check' or 'insertion' themselves
         * are thread-safe by themselves but not the aggregate algorithm, thus we put this entire block of logic inside synchronized.
         *
         * I am using a tryLock if/then (http://download.oracle.com/javase/6/docs/api/java/util/concurrent/locks/Lock.html#tryLock())
         * so that a single thread will get the lock and as soon as one thread gets the lock all others will go the 'else' block
         * and just return the currentBucket until the newBucket is created. This should allow the throughput to be far higher
         * and only slow down 1 thread instead of blocking all of them in each cycle of creating a new bucket based on some testing
         * (and it makes sense that it should as well).
         *
         * This means the timing won't be exact to the millisecond as to what data ends up in a bucket, but that's acceptable.
         * It's not critical to have exact precision to the millisecond, as long as it's rolling, if we can instead reduce the impact synchronization.
         *
         * More importantly though it means that the 'if' block within the lock needs to be careful about what it changes that can still
         * be accessed concurrently in the 'else' block since we're not completely synchronizing access.
         *
         * For example, we can't have a multi-step process to add a bucket, remove a bucket, then update the sum since the 'else' block of code
         * can retrieve the sum while this is all happening. The trade-off is that we don't maintain the rolling sum and let readers just iterate
         * bucket to calculate the sum themselves. This is an example of favoring write-performance instead of read-performance and how the tryLock
         * versus a synchronized block needs to be accommodated.
         */ if ( newBucketLock . tryLock ( ) ) { try { if ( buckets . peekLast ( ) == null ) { // the list is empty so create the first bucket Bucket newBucket = new Bucket ( events , currentTime ) ; buckets . addLast ( newBucket ) ; return newBucket ; } else { // We go into a loop so that it will create as many buckets as needed to catch up to the current time // as we want the buckets complete even if we don't have transactions during a period of time. for ( int i = 0 ; i < numberOfBuckets . get ( ) ; i ++ ) { // we have at least 1 bucket so retrieve it Bucket lastBucket = buckets . peekLast ( ) ; if ( currentTime < lastBucket . windowStart + getBucketSizeInMilliseconds ( ) ) { // if we're within the bucket 'window of time' return the current one // NOTE: We do not worry if we are BEFORE the window in a weird case of where thread scheduling causes that to occur, // we'll just use the latest as long as we're not AFTER the window return lastBucket ; } else if ( currentTime - ( lastBucket . windowStart + getBucketSizeInMilliseconds ( ) ) > timeInMilliseconds . get ( ) ) { // the time passed is greater than the entire rolling counter so we want to clear it all and start from scratch reset ( ) ; // recursively call getCurrentBucket which will create a new bucket and return it return getCurrentBucket ( ) ; } else { // we're past the window so we need to create a new bucket // create a new bucket and add it as the new 'last' buckets . addLast ( new Bucket ( events , lastBucket . windowStart + getBucketSizeInMilliseconds ( ) ) ) ; // add the lastBucket values to the cumulativeSum cumulativeSum . addBucket ( lastBucket ) ; } } // we have finished the for-loop and created all of the buckets, so return the lastBucket now return buckets . peekLast ( ) ; } } finally { newBucketLock . unlock ( ) ; } } else { currentBucket = buckets . peekLast ( ) ; if ( currentBucket != null ) { // we didn't get the lock so just return the latest bucket while another thread creates the next one return currentBucket ; } else { // the rare scenario where multiple threads raced to create the very first bucket // wait slightly and then use recursion while the other thread finishes creating a bucket if ( doNotBlock ) { // caller indicates doNotBlock return null ; } try { Thread . sleep ( 5 ) ; } catch ( Exception e ) { // ignore } return getCurrentBucket ( false ) ; } } }


Input: Add value ( or values ) to current bucket . [CODESPLIT] public void addValue ( int ... value ) { /* no-op if disabled */ if ( ! enabled . get ( ) ) return ; for ( int v : value ) { getCurrentBucket ( ) . data . addValue ( v ) ; } }


Input: Returns the current maximum . The returned value is <em > NOT< / em > an atomic snapshot : Invocation in the absence of concurrent updates returns an accurate result but concurrent updates that occur while the value is being calculated might not be incorporated . [CODESPLIT] public long max ( ) { Cell [ ] as = cells ; long max = base ; if ( as != null ) { int n = as . length ; long v ; for ( int i = 0 ; i < n ; ++ i ) { Cell a = as [ i ] ; if ( a != null && ( v = a . value ) > max ) max = v ; } } return max ; }


Input: / * package [CODESPLIT] void setupActionBar ( ) { // there might not be an ActionBar, for example when started in Theme.Holo.Dialog.NoActionBar theme @ SuppressLint ( "AppCompatMethod" ) final ActionBar actionBar = getActionBar ( ) ; if ( actionBar != null ) { actionBar . setDisplayHomeAsUpEnabled ( true ) ; } }


Input: To create the config make use of the provided { @link DirectoryChooserConfig#builder () } . [CODESPLIT] public static DirectoryChooserFragment newInstance ( @ NonNull final DirectoryChooserConfig config ) { final DirectoryChooserFragment fragment = new DirectoryChooserFragment ( ) ; final Bundle args = new Bundle ( ) ; args . putParcelable ( ARG_CONFIG , config ) ; fragment . setArguments ( args ) ; return fragment ; }


Input: Shows a confirmation dialog that asks the user if he wants to create a new folder . User can modify provided name if it was not disallowed . [CODESPLIT] private void openNewFolderDialog ( ) { @ SuppressLint ( "InflateParams" ) final View dialogView = getActivity ( ) . getLayoutInflater ( ) . inflate ( R . layout . dialog_new_folder , null ) ; final TextView msgView = ( TextView ) dialogView . findViewById ( R . id . msgText ) ; final EditText editText = ( EditText ) dialogView . findViewById ( R . id . editText ) ; editText . setText ( mNewDirectoryName ) ; msgView . setText ( getString ( R . string . create_folder_msg , mNewDirectoryName ) ) ; final AlertDialog alertDialog = new AlertDialog . Builder ( getActivity ( ) ) . setTitle ( R . string . create_folder_label ) . setView ( dialogView ) . setNegativeButton ( R . string . cancel_label , new DialogInterface . OnClickListener ( ) { @ Override public void onClick ( final DialogInterface dialog , final int which ) { dialog . dismiss ( ) ; } } ) . setPositiveButton ( R . string . confirm_label , new DialogInterface . OnClickListener ( ) { @ Override public void onClick ( final DialogInterface dialog , final int which ) { dialog . dismiss ( ) ; mNewDirectoryName = editText . getText ( ) . toString ( ) ; final int msg = createFolder ( ) ; Toast . makeText ( getActivity ( ) , msg , Toast . LENGTH_SHORT ) . show ( ) ; } } ) . show ( ) ; alertDialog . getButton ( DialogInterface . BUTTON_POSITIVE ) . setEnabled ( editText . getText ( ) . length ( ) != 0 ) ; editText . addTextChangedListener ( new TextWatcher ( ) { @ Override public void beforeTextChanged ( final CharSequence charSequence , final int i , final int i2 , final int i3 ) { } @ Override public void onTextChanged ( final CharSequence charSequence , final int i , final int i2 , final int i3 ) { final boolean textNotEmpty = charSequence . length ( ) != 0 ; alertDialog . getButton ( DialogInterface . BUTTON_POSITIVE ) . setEnabled ( textNotEmpty ) ; msgView . setText ( getString ( R . string . create_folder_msg , charSequence . toString ( ) ) ) ; } @ Override public void afterTextChanged ( final Editable editable ) { } } ) ; editText . setVisibility ( mConfig . allowNewDirectoryNameModification ( ) ? View . VISIBLE : View . GONE ) ; }


Input: Change the directory that is currently being displayed . [CODESPLIT] private void changeDirectory ( final File dir ) { if ( dir == null ) { debug ( "Could not change folder: dir was null" ) ; } else if ( ! dir . isDirectory ( ) ) { debug ( "Could not change folder: dir is no directory" ) ; } else { final File [ ] contents = dir . listFiles ( ) ; if ( contents != null ) { int numDirectories = 0 ; for ( final File f : contents ) { if ( f . isDirectory ( ) ) { numDirectories ++ ; } } mFilesInDir = new File [ numDirectories ] ; mFilenames . clear ( ) ; for ( int i = 0 , counter = 0 ; i < numDirectories ; counter ++ ) { if ( contents [ counter ] . isDirectory ( ) ) { mFilesInDir [ i ] = contents [ counter ] ; mFilenames . add ( contents [ counter ] . getName ( ) ) ; i ++ ; } } Arrays . sort ( mFilesInDir ) ; Collections . sort ( mFilenames ) ; mSelectedDir = dir ; mTxtvSelectedFolder . setText ( dir . getAbsolutePath ( ) ) ; mListDirectoriesAdapter . notifyDataSetChanged ( ) ; mFileObserver = createFileObserver ( dir . getAbsolutePath ( ) ) ; mFileObserver . startWatching ( ) ; debug ( "Changed directory to %s" , dir . getAbsolutePath ( ) ) ; } else { debug ( "Could not change folder: contents of dir were null" ) ; } } refreshButtonState ( ) ; }


Input: Changes the state of the buttons depending on the currently selected file or folder . [CODESPLIT] private void refreshButtonState ( ) { final Activity activity = getActivity ( ) ; if ( activity != null && mSelectedDir != null ) { mBtnConfirm . setEnabled ( isValidFile ( mSelectedDir ) ) ; getActivity ( ) . invalidateOptionsMenu ( ) ; } }


Input: Sets up a FileObserver to watch the current directory . [CODESPLIT] private FileObserver createFileObserver ( final String path ) { return new FileObserver ( path , FileObserver . CREATE | FileObserver . DELETE | FileObserver . MOVED_FROM | FileObserver . MOVED_TO ) { @ Override public void onEvent ( final int event , final String path ) { debug ( "FileObserver received event %d" , event ) ; final Activity activity = getActivity ( ) ; if ( activity != null ) { activity . runOnUiThread ( new Runnable ( ) { @ Override public void run ( ) { refreshDirectory ( ) ; } } ) ; } } } ; }


Input: Returns the selected folder as a result to the activity the fragment s attached to . The selected folder can also be null . [CODESPLIT] private void returnSelectedFolder ( ) { if ( mSelectedDir != null ) { debug ( "Returning %s as result" , mSelectedDir . getAbsolutePath ( ) ) ; mListener . foreach ( new UnitFunction < OnFragmentInteractionListener > ( ) { @ Override public void apply ( final OnFragmentInteractionListener f ) { f . onSelectDirectory ( mSelectedDir . getAbsolutePath ( ) ) ; } } ) ; } else { mListener . foreach ( new UnitFunction < OnFragmentInteractionListener > ( ) { @ Override public void apply ( final OnFragmentInteractionListener f ) { f . onCancelChooser ( ) ; } } ) ; } }


Input: Creates a new folder in the current directory with the name CREATE_DIRECTORY_NAME . [CODESPLIT] private int createFolder ( ) { if ( mNewDirectoryName != null && mSelectedDir != null && mSelectedDir . canWrite ( ) ) { final File newDir = new File ( mSelectedDir , mNewDirectoryName ) ; if ( newDir . exists ( ) ) { return R . string . create_folder_error_already_exists ; } else { final boolean result = newDir . mkdir ( ) ; if ( result ) { return R . string . create_folder_success ; } else { return R . string . create_folder_error ; } } } else if ( mSelectedDir != null && ! mSelectedDir . canWrite ( ) ) { return R . string . create_folder_error_no_write_access ; } else { return R . string . create_folder_error ; } }


Input: Returns true if the selected file or directory would be valid selection . [CODESPLIT] private boolean isValidFile ( final File file ) { return ( file != null && file . isDirectory ( ) && file . canRead ( ) && ( mConfig . allowReadOnlyDirectory ( ) || file . canWrite ( ) ) ) ; }


Input: Called when the activity is first created . [CODESPLIT] @ Override public void onCreate ( Bundle savedInstanceState ) { super . onCreate ( savedInstanceState ) ; setContentView ( R . layout . main ) ; mDirectoryTextView = ( TextView ) findViewById ( R . id . textDirectory ) ; // Set up click handler for "Choose Directory" button findViewById ( R . id . btnChoose ) . setOnClickListener ( new OnClickListener ( ) { @ Override public void onClick ( View v ) { final Intent chooserIntent = new Intent ( DirChooserSample . this , DirectoryChooserActivity . class ) ; final DirectoryChooserConfig config = DirectoryChooserConfig . builder ( ) . newDirectoryName ( "DirChooserSample" ) . allowReadOnlyDirectory ( true ) . allowNewDirectoryNameModification ( true ) . build ( ) ; chooserIntent . putExtra ( DirectoryChooserActivity . EXTRA_CONFIG , config ) ; startActivityForResult ( chooserIntent , REQUEST_DIRECTORY ) ; } } ) ; findViewById ( R . id . btnChange ) . setOnClickListener ( new OnClickListener ( ) { @ Override public void onClick ( View v ) { final Intent fragmentSampleIntent = new Intent ( DirChooserSample . this , DirChooserFragmentSample . class ) ; startActivity ( fragmentSampleIntent ) ; } } ) ; }


Input: Returns true if the specified <code > String< / code > parses as a valid domain name with a recognized top - level domain . The parsing is case - insensitive . [CODESPLIT] public boolean isValid ( String domain ) { if ( domain == null ) { return false ; } domain = unicodeToASCII ( domain ) ; // hosts must be equally reachable via punycode and Unicode; // Unicode is never shorter than punycode, so check punycode // if domain did not convert, then it will be caught by ASCII // checks in the regexes below if ( domain . length ( ) > 253 ) { return false ; } String [ ] groups = domainRegex . match ( domain ) ; if ( groups != null && groups . length > 0 ) { return isValidTld ( groups [ 0 ] ) ; } return allowLocal && hostnameRegex . isValid ( domain ) ; }


Input: Returns true if the specified <code > String< / code > matches any IANA - defined infrastructure top - level domain . Leading dots are ignored if present . The search is case - insensitive . [CODESPLIT] public boolean isValidInfrastructureTld ( String iTld ) { iTld = unicodeToASCII ( iTld ) ; return Arrays . binarySearch ( INFRASTRUCTURE_TLDS , ( chompLeadingDot ( iTld . toLowerCase ( Locale . ENGLISH ) ) ) ) >= 0 ; }