@Test public void testBadVariableFormat() { List<String> varCells = new ArrayList<String>(); varCells.add( "class1, object2" ); try { RuleSheetParserUtil.getVariableList( varCells ); fail( "should not work" ); } catch ( final DecisionTableParseException e ) { assertNotNull( e.getMessage() ); } }
public static List<Global> getVariableList( final List<String> variableCells ){ final List<Global> variableList = new ArrayList<Global>(); if ( variableCells == null ) return variableList; for( String variableCell: variableCells ){ final StringTokenizer tokens = new StringTokenizer( variableCell, "," ); while ( tokens.hasMoreTokens() ) { final String token = tokens.nextToken(); final Global vars = new Global(); final StringTokenizer paramTokens = new StringTokenizer( token, " " ); vars.setClassName( paramTokens.nextToken() ); if ( !paramTokens.hasMoreTokens() ) { throw new DecisionTableParseException( "The format for global variables is incorrect. " + "It should be: [Class name, Class otherName]. But it was: [" + variableCell + "]" ); } vars.setIdentifier( paramTokens.nextToken() ); variableList.add( vars ); } } return variableList; }
RuleSheetParserUtil { public static List<Global> getVariableList( final List<String> variableCells ){ final List<Global> variableList = new ArrayList<Global>(); if ( variableCells == null ) return variableList; for( String variableCell: variableCells ){ final StringTokenizer tokens = new StringTokenizer( variableCell, "," ); while ( tokens.hasMoreTokens() ) { final String token = tokens.nextToken(); final Global vars = new Global(); final StringTokenizer paramTokens = new StringTokenizer( token, " " ); vars.setClassName( paramTokens.nextToken() ); if ( !paramTokens.hasMoreTokens() ) { throw new DecisionTableParseException( "The format for global variables is incorrect. " + "It should be: [Class name, Class otherName]. But it was: [" + variableCell + "]" ); } vars.setIdentifier( paramTokens.nextToken() ); variableList.add( vars ); } } return variableList; } }
RuleSheetParserUtil { public static List<Global> getVariableList( final List<String> variableCells ){ final List<Global> variableList = new ArrayList<Global>(); if ( variableCells == null ) return variableList; for( String variableCell: variableCells ){ final StringTokenizer tokens = new StringTokenizer( variableCell, "," ); while ( tokens.hasMoreTokens() ) { final String token = tokens.nextToken(); final Global vars = new Global(); final StringTokenizer paramTokens = new StringTokenizer( token, " " ); vars.setClassName( paramTokens.nextToken() ); if ( !paramTokens.hasMoreTokens() ) { throw new DecisionTableParseException( "The format for global variables is incorrect. " + "It should be: [Class name, Class otherName]. But it was: [" + variableCell + "]" ); } vars.setIdentifier( paramTokens.nextToken() ); variableList.add( vars ); } } return variableList; } private  RuleSheetParserUtil(); }
RuleSheetParserUtil { public static List<Global> getVariableList( final List<String> variableCells ){ final List<Global> variableList = new ArrayList<Global>(); if ( variableCells == null ) return variableList; for( String variableCell: variableCells ){ final StringTokenizer tokens = new StringTokenizer( variableCell, "," ); while ( tokens.hasMoreTokens() ) { final String token = tokens.nextToken(); final Global vars = new Global(); final StringTokenizer paramTokens = new StringTokenizer( token, " " ); vars.setClassName( paramTokens.nextToken() ); if ( !paramTokens.hasMoreTokens() ) { throw new DecisionTableParseException( "The format for global variables is incorrect. " + "It should be: [Class name, Class otherName]. But it was: [" + variableCell + "]" ); } vars.setIdentifier( paramTokens.nextToken() ); variableList.add( vars ); } } return variableList; } private  RuleSheetParserUtil(); static String getRuleName(final String ruleRow); static List<Import> getImportList(final List<String> importCells); static List<Global> getVariableList( final List<String> variableCells ); static boolean isStringMeaningTrue(String property); static String rc2name( int row, int col ); }
RuleSheetParserUtil { public static List<Global> getVariableList( final List<String> variableCells ){ final List<Global> variableList = new ArrayList<Global>(); if ( variableCells == null ) return variableList; for( String variableCell: variableCells ){ final StringTokenizer tokens = new StringTokenizer( variableCell, "," ); while ( tokens.hasMoreTokens() ) { final String token = tokens.nextToken(); final Global vars = new Global(); final StringTokenizer paramTokens = new StringTokenizer( token, " " ); vars.setClassName( paramTokens.nextToken() ); if ( !paramTokens.hasMoreTokens() ) { throw new DecisionTableParseException( "The format for global variables is incorrect. " + "It should be: [Class name, Class otherName]. But it was: [" + variableCell + "]" ); } vars.setIdentifier( paramTokens.nextToken() ); variableList.add( vars ); } } return variableList; } private  RuleSheetParserUtil(); static String getRuleName(final String ruleRow); static List<Import> getImportList(final List<String> importCells); static List<Global> getVariableList( final List<String> variableCells ); static boolean isStringMeaningTrue(String property); static String rc2name( int row, int col );  }