Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
eefae82
Continued code reading of DRLParser.java:
wlaun Apr 15, 2011
4bd1dee
fixing typo
wlaun Apr 15, 2011
6e6d2d7
Merge branch 'master' of [email protected]:droolsjbpm/drools
wlaun Apr 15, 2011
c9c9b74
Merge branch 'master' of [email protected]:droolsjbpm/drools
wlaun Apr 18, 2011
6480d60
Merge commit 'upstream/master'
wlaun Apr 19, 2011
089d9de
Merge commit 'upstream/master'
wlaun Apr 19, 2011
5ac7e77
Merge commit 'upstream/master'
wlaun Apr 19, 2011
cb57d61
Merge commit 'upstream/master'
wlaun Apr 20, 2011
14eee8d
Merge branch 'master' of [email protected]:droolsjbpm/drools
wlaun Apr 25, 2011
a9b3230
Merge branch 'master' of [email protected]:droolsjbpm/drools
wlaun Apr 26, 2011
71e447e
Merge branch 'master' of [email protected]:droolsjbpm/drools
wlaun Apr 27, 2011
341e9b3
forcing update of my clone
wlaun Apr 27, 2011
63cf9fe
syncing blessed and clone
wlaun Apr 27, 2011
75380f1
Merge branch 'master' of [email protected]:droolsjbpm/drools
wlaun Apr 28, 2011
1302a85
Merge branch 'master' of [email protected]:droolsjbpm/drools
wlaun Apr 28, 2011
72264bf
Merge branch 'master' of [email protected]:droolsjbpm/drools
wlaun Apr 29, 2011
7018478
Merge branch 'master' of [email protected]:droolsjbpm/drools
wlaun May 1, 2011
af2c81d
Merge branch 'master' of [email protected]:droolsjbpm/drools
wlaun May 2, 2011
449e1a8
Merge branch 'master' of [email protected]:droolsjbpm/drools
wlaun May 3, 2011
798a3bc
Rewrite of Sudoku, without using salience
wlaun May 3, 2011
851c5d8
Fix name of main class, was Main, now SudokuExample
wlaun May 3, 2011
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
331 changes: 166 additions & 165 deletions drools-compiler/src/main/java/org/drools/lang/DRLParser.java

Large diffs are not rendered by default.

26 changes: 14 additions & 12 deletions drools-examples/src/main/java/org/drools/examples/sudoku/Cell.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class Cell extends SetOfNine {
* Constructor, leaving all references at null. You must call
* makeReferences to complete the object.
*/
public Cell(){
public Cell() {
super();
}

Expand All @@ -43,15 +43,15 @@ public Cell(){
* @param col the cell group for the column
* @param sqr the cell group for the square 3x3 area
*/
public void makeReferences( CellRow row, CellCol col, CellSqr sqr ){
public void makeReferences(CellRow row, CellCol col, CellSqr sqr) {
this.cellRow = row;
this.cellCol = col;
this.cellSqr = sqr;
this.exCells = new HashSet<Cell>();
this.exCells.addAll( this.cellRow.getCells() );
this.exCells.addAll( this.cellCol.getCells() );
this.exCells.addAll( this.cellSqr.getCells() );
this.exCells.remove( this );
this.exCells.addAll(this.cellRow.getCells());
this.exCells.addAll(this.cellCol.getCells());
this.exCells.addAll(this.cellSqr.getCells());
this.exCells.remove(this);
}

/**
Expand All @@ -77,7 +77,7 @@ public void setValue(Integer value) {
*
* @return a Set of Cell objects not including this cell.
*/
public Set<Cell> getExCells(){
public Set<Cell> getExCells() {
return exCells;
}

Expand Down Expand Up @@ -126,14 +126,16 @@ public CellSqr getCellSqr() {
* @see java.lang.Object#toString()
*/
@Override
public String toString(){
String rowNo = cellRow == null ? "?" : Integer.toString( cellRow.getNumber() );
String colNo = cellCol == null ? "?" : Integer.toString( cellCol.getNumber() );
return "[" + rowNo + "," + colNo + "]: " + (value == null ? " " : value.toString());
public String toString() {
return posAsString() + ": " + valueAsString();
}

public String valueAsString(){
public String valueAsString() {
return value == null ? " " : value.toString();
}

public String posAsString(){
return "[" + cellRow.getNumber() + "," + cellCol.getNumber() + "]";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class CellCol extends CellFile {
*
* @param number the column number.
*/
public CellCol(int number){
public CellCol(int number) {
super( number );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package org.drools.examples.sudoku;

/**
* Abstract class for numbered cell groups: rows and columns.
* Abstract class for "numbered" cell groups: rows and columns.
*/
public abstract class CellFile extends CellGroup {

Expand All @@ -27,7 +27,7 @@ public abstract class CellFile extends CellGroup {
*
* @param number thw row or column number.
*/
protected CellFile(int number){
protected CellFile(int number) {
super();
this.number = number;
}
Expand All @@ -45,12 +45,12 @@ public int getNumber() {
* @see java.lang.Object#toString()
*/
@Override
public String toString(){
public String toString() {
StringBuilder sb = new StringBuilder();
String del = "";
for( int i = 0; i < getCells().size(); i++ ){
for (int i = 0; i < getCells().size(); i++) {
String cStr = getCells().get( i ).toString();
sb.append( del ).append( cStr );
sb.append(del).append(cStr);
del = ", ";
}
return sb.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,24 @@ public abstract class CellGroup extends SetOfNine {

public static Set<Integer> allNine = new CopyOnWriteArraySet<Integer>();
static {
for( int i = 1; i <= 9; i++ ) allNine.add( i );
for (int i = 1; i <= 9; i++) allNine.add(i);
}

private List<Cell> cells = new ArrayList<Cell>();

/**
* Constructor.
*/
protected CellGroup(){
protected CellGroup() {
super();
}

/**
* Add another Cell object to the cells of this group.
* @param cell a Cell object.
*/
public void addCell( Cell cell ){
cells.add( cell );
public void addCell(Cell cell) {
cells.add(cell);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ public class CellRow extends CellFile {
*
* @param number the row number.
*/
public CellRow(int number){
super( number );
public CellRow(int number) {
super(number);
}

/*
* (non-Javadoc)
* @see sudoku.CellFile#toString()
*/
@Override
public String toString(){
public String toString() {
return "Row " + getNumber() + ": " + super.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ public class CellSqr extends CellGroup {
* @param cellCol1 the 2nd column passing through this block.
* @param cellCol2 the 3rd column passing through this block.
*/
public CellSqr( CellRow cellRow0, CellRow cellRow1, CellRow cellRow2,
CellCol cellCol0, CellCol cellCol1, CellCol cellCol2 ){
public CellSqr(CellRow cellRow0, CellRow cellRow1, CellRow cellRow2,
CellCol cellCol0, CellCol cellCol1, CellCol cellCol2) {
super();

for( int iRow = cellRow0.getNumber(); iRow <= cellRow2.getNumber(); iRow++ ){
addCell( cellCol0.getCells().get( iRow ) );
addCell( cellCol1.getCells().get( iRow ) );
addCell( cellCol2.getCells().get( iRow ) );
for (int iRow = cellRow0.getNumber(); iRow <= cellRow2.getNumber(); iRow++) {
addCell(cellCol0.getCells().get(iRow));
addCell(cellCol1.getCells().get(iRow));
addCell(cellCol2.getCells().get(iRow));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
public class Counter {

private int count;

/**
* Constructor, setting an initial value.
* @param init the initialization value
*/
public Counter( int init ){
this.count = init;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2010 JBoss Inc
* Copyright 20101 JBoss Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,53 +18,56 @@
import java.util.Set;
import java.util.HashSet;


/**
* Abstract base class for the three types of cell groups of nine cells.
*/
public abstract class SetOfNine {

private Set<Integer> free;

protected SetOfNine() {
free = new HashSet<Integer>( CellGroup.allNine );
}

/**
* Redefine the set of acceptable values for this cell.
* @param values the Integer objects representing the new set of acceptable values.
*/
public void blockExcept(Integer... values) {
free = new HashSet<Integer>();
free.clear();
for( Integer value: values ){
free.add( value );
free.add(value);
}
}

protected SetOfNine(){
free = new HashSet<Integer>( CellGroup.allNine );
}
/**
* Remove an Integer from the values still to be assigned to some cell of this group.
* @param i an Integer object
*/
public void blockValue( Integer i ){
free.remove( i );
public void blockValue(Integer i) {
free.remove(i);
}

/**
* Returns the set of Integers that still need to be assigned to some cell of this group.
* @return a Set of Integer objects.
*/
public Set<Integer> getFree(){
public Set<Integer> getFree() {
return free;
}

/**
* Returns the number of Integers that still need to be assigned to some cell of this group.
* @return an int value
*/
public int getFreeCount(){
public int getFreeCount() {
return free.size();
}
/**
* Returns the first (only) permissible Integer value.
* @return an Integer object
*/
public Integer getFreeValue(){
public Integer getFreeValue() {
return free.iterator().next();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2010 JBoss Inc
* Copyright 2011 JBoss Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -30,7 +30,7 @@ public class Setting {
* @param col the column number of the Cell to set
* @param value the value to set
*/
public Setting( int row, int col, Integer value ){
public Setting (int row, int col, Integer value) {
this.rowNo = row;
this.colNo = col;
this.value = value;
Expand Down
Loading