[jboss-svn-commits] JBL Code SVN: r6907 - in labs/jbossrules/trunk/drools-core/src: main/java/org/drools main/java/org/drools/audit main/java/org/drools/base main/java/org/drools/base/dataproviders main/java/org/drools/base/evaluators main/java/org/drools/base/extractors main/java/org/drools/base/field main/java/org/drools/base/resolvers main/java/org/drools/common main/java/org/drools/conflict main/java/org/drools/facttemplates main/java/org/drools/leaps main/java/org/drools/leaps/conflict main/java/org/drools/leaps/util main/java/org/drools/reteoo main/java/org/drools/rule main/java/org/drools/spi main/java/org/drools/util main/java/org/drools/util/asm main/java/org/drools/util/concurrent/locks test/java/org/drools test/java/org/drools/base test/java/org/drools/base/dataproviders test/java/org/drools/base/extractors test/java/org/drools/base/resolvers test/java/org/drools/examples/manners test/java/org/drools/examples/waltz test/java/org/drools/facttemplates test/java/org/drools/lea! ps test/java/org/drools/leaps/util test/java/org/drools/reteoo test/java/org/drools/rule test/java/org/drools/spi test/java/org/drools/util test/java/org/drools/util/asm
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Oct 18 20:35:05 EDT 2006
Author: mark.proctor at jboss.com
Date: 2006-10-18 20:32:57 -0400 (Wed, 18 Oct 2006)
New Revision: 6907
Added:
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/FieldIndexHashTable.java
Removed:
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/CompositeFieldIndexHashTable.java
Modified:
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/InitialFact.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/RuleBase.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/SynchronizedWorkingMemory.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/WorkingMemory.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/audit/WorkingMemoryLogger.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/BaseClassFieldExtractor.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/BaseEvaluator.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/ClassFieldExtractor.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/ClassFieldExtractorCache.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/ClassFieldExtractorFactory.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/ClassObjectType.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/DefaultKnowledgeHelper.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/DroolsQuery.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/FieldFactory.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/ShadowProxy.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/ShadowProxyFactory.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/ValueType.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/dataproviders/Invoker.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/dataproviders/MethodDataProvider.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/dataproviders/MethodInvoker.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/ArrayFactory.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/BigDecimalFactory.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/BigIntegerFactory.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/BooleanFactory.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/ByteFactory.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/CharacterFactory.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/DateFactory.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/DoubleFactory.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/EvaluatorFactory.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/FactTemplateFactory.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/FloatFactory.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/IntegerFactory.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/LongFactory.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/ObjectFactory.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/Operator.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/ShortFactory.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/StringFactory.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/BaseBooleanClassFieldExtractor.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/BaseByteClassFieldExtractor.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/BaseCharClassFieldExtractor.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/BaseDoubleClassFieldExtractor.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/BaseFloatClassFieldExtractor.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/BaseIntClassFieldExtractor.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/BaseLongClassFieldExtractors.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/BaseObjectClassFieldExtractor.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/BaseShortClassFieldExtractor.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/field/BooleanFieldImpl.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/field/DoubleFieldImpl.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/field/LongFieldImpl.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/field/ObjectFieldImpl.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/resolvers/DeclarationVariable.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/resolvers/GlobalVariable.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/resolvers/ListValue.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/resolvers/LiteralValue.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/resolvers/MapValue.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/resolvers/ValueHandler.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractRuleBase.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AgendaGroupImpl.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AgendaItem.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/BaseNode.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/BetaConstraints.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/DefaultAgenda.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/DefaultBetaConstraints.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/DefaultFactHandle.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/DoubleBetaConstraints.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/EmptyBetaConstraints.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/EqualityAssertMapComparator.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/EqualityKey.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/EqualityKeyComparator.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/IdentityAssertMapComparator.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InstanceEqualsConstraint.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InstanceNotEqualsConstraint.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalAgenda.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalFactHandle.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalRuleBase.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalWorkingMemory.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/NodeMemory.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/RuleFlowNode.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/ScheduledAgendaItem.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/SingleBetaConstraints.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/TripleBetaConstraints.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/TruthMaintenanceSystem.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/conflict/TotalRecencyConflictResolver.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/facttemplates/Fact.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/facttemplates/FactImpl.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/facttemplates/FactTemplate.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/facttemplates/FactTemplateFieldExtractor.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/facttemplates/FactTemplateImpl.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/facttemplates/FactTemplateObjectType.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/facttemplates/FieldTemplateImpl.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/AlphaMemory.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/Builder.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/ColumnConstraints.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/ConflictResolver.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/FactHandleTupleAssembly.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/FactTable.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/FromConstraint.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/HashedTableComponent.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/LeapsAgenda.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/LeapsBuilder.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/LeapsFactHandle.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/LeapsFactHandleFactory.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/LeapsRule.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/LeapsRuleBase.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/LeapsRuleHandle.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/LeapsTuple.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/LeapsWorkingMemory.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/Token.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/TokenEvaluator.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/conflict/CompositeConflictResolver.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/ConstrainedIteratorFromPositionToTableStart.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/IteratorFromPositionToTableEnd.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/IteratorFromPositionToTableStart.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/RecordComparator.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/Table.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/TableIterator.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/TableRecord.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/TokenStack.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/AccumulateNode.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/AlphaNode.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/BetaMemory.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/BetaNode.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/CollectNode.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/CompositeObjectSinkAdapter.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/CompositeTupleSinkAdapter.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/EvalConditionNode.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/FromNode.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/JoinNode.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/LeftInputAdapterNode.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/MemoryVisitor.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/NotNode.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectHashTable.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectSink.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectSinkNode.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectSinkNodeList.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectSinkPropagator.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectSource.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectTypeNode.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/Rete.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteTuple.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteooBuilder.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteooFactHandleFactory.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteooRuleBase.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteooWorkingMemory.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/RightInputAdapterNode.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/SingleObjectSinkAdapter.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/SingleTupleSinkAdapter.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/TerminalNode.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/TupleSink.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/TupleSinkNode.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/TupleSinkNodeList.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/TupleSinkPropagator.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/TupleSource.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/AbstractCompositeRestriction.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/Accumulate.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/AndCompositeRestriction.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/Collect.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/Column.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/ContextEntry.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/Declaration.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/From.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/LineMappings.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/LiteralConstraint.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/LiteralRestriction.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/OrCompositeRestriction.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/Package.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/PackageCompilationData.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/PredicateConstraint.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/ReturnValueConstraint.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/ReturnValueRestriction.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/VariableConstraint.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/VariableRestriction.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/AgendaGroup.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/AlphaNodeFieldConstraint.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/AvailableVariables.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/BetaNodeFieldConstraint.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/ColumnExtractor.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/CompiledInvoker.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/Constraint.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/DataProvider.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/FactHandleFactory.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/FieldValue.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/FunctionResolver.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/ObjectType.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/PropagationContext.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/Restriction.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/AbstractHashTable.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/BinaryHeapQueue.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/FactHashTable.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/LinkedList.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/LinkedListEntry.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/LinkedListNode.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/ObjectHashMap.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/ReflectiveVisitor.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/TupleHashTable.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/UUID.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/UUIDGenerator.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/asm/ClassFieldInspector.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/concurrent/locks/ReentrantLock.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/Cheese.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/RuleBaseFactoryTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/ClassFieldExtractorFactoryTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/ClassFieldExtractorTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/EvaluatorFactoryTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/FieldFactoryTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/ShadowProxyFactoryTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/TestBean.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/ValueTypeTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/dataproviders/MethodDataProviderTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/dataproviders/TestVariable.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/extractors/BooleanClassFieldExtractorTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/extractors/ByteClassFieldExtractorTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/extractors/CharClassFieldExtractorTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/extractors/ClassFieldExtractorsBaseTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/extractors/DoubleClassFieldExtractorTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/extractors/FloatClassFieldExtractorTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/extractors/IntClassFieldExtractorTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/extractors/LongClassFieldExtractorTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/extractors/ObjectClassFieldExtractorTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/extractors/ShortClassFieldExtractorTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/resolvers/DeclarationVariableTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/resolvers/GlobalVariableTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/resolvers/ListValueTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/resolvers/LiteralValueTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/resolvers/MapValueTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/BaseMannersTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/Chosen.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/Context.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/Count.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/Guest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/Hobby.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/LastSeat.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/Path.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/ReteooMannersTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/Seating.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/Sex.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/waltz/BaseWaltzTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/facttemplates/FactTemplateFieldExtractorTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/facttemplates/FactTemplateTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/facttemplates/FieldTemplateTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/ColumnConstraintsTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/HandleFactoryTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/HandleTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/HashedTableComponentTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/LeapsFactHandleTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/LeapsRuleBaseTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/LeapsTupleTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/LeapsWorkingMemoryTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/LogicalAssertionTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/QueryResultsTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/QueryTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/SchedulerTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/util/TableIteratorTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/util/TableTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/util/TokenStackTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/AccumulateNodeTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/AlphaNodeTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/CollectNodeTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/FactHandleTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/FromNodeTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/InstrumentedReteTuple.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/JoinNodeTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/LeftInputAdapterNodeTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/MockAccumulator.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/MockObjectSink.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/MockObjectSource.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/MockTupleSink.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/MockTupleSource.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/NotNodeTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/ObjectSourceTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/ObjectTypeNodeTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/ReteTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/ReteooRuleBaseTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/ReteooWorkingMemoryTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/TupleSourceTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/rule/ColumnTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/rule/DeclarationTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/rule/FieldConstraintTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/rule/OrTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/spi/MockObjectType.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/BinaryHeapPriorityQueueTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/FactHashTableTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/FieldIndexEntryTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/FieldIndexHashTableTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/ObjectHashMapTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/asm/AbstractClass.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/asm/ClassFieldInspectorTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/asm/InterfaceChildImpl.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/asm/InterfaceParent2.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/asm/TestBean.java
Log:
JBRULES-526 Implement a CompositeIndex for Facts
-tidy ups
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/InitialFact.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/InitialFact.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/InitialFact.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -18,6 +18,8 @@
* limitations under the License.
*/
-public interface InitialFact extends Serializable {
+public interface InitialFact
+ extends
+ Serializable {
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/RuleBase.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/RuleBase.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/RuleBase.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -94,8 +94,9 @@
* @see org.drools.conflict.DefaultConflictResolver
*
* @return A serialised initialized <code>WorkingMemory</code>.
- */
- WorkingMemory newWorkingMemory(InputStream stream) throws IOException, ClassNotFoundException;
+ */
+ WorkingMemory newWorkingMemory(InputStream stream) throws IOException,
+ ClassNotFoundException;
/**
* RuleBases handle the returning of a Serialized WorkingMemory
@@ -112,18 +113,19 @@
* @see org.drools.conflict.DefaultConflictResolver
*
* @return A serialised initialized <code>WorkingMemory</code>.
- */
- WorkingMemory newWorkingMemory(InputStream stream, boolean keepReference ) throws IOException, ClassNotFoundException;
-
+ */
+ WorkingMemory newWorkingMemory(InputStream stream,
+ boolean keepReference) throws IOException,
+ ClassNotFoundException;
Package[] getPackages();
void addPackage(Package pkg) throws Exception;
-
+
void removePackage(String packageName);
-
+
void removeRule(String packageName,
- String ruleName);
-
+ String ruleName);
+
public Set getWorkingMemories();
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/SynchronizedWorkingMemory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/SynchronizedWorkingMemory.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/SynchronizedWorkingMemory.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -152,8 +152,8 @@
public Map getGlobals() {
return this.workingMemory.getGlobals();
}
-
- public void setGlobalResolver(GlobalResolver globalResolver) {
+
+ public void setGlobalResolver(final GlobalResolver globalResolver) {
this.workingMemory.setGlobalResolver( globalResolver );
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/WorkingMemory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/WorkingMemory.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/WorkingMemory.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -111,7 +111,7 @@
* @return application data or null if nothing is set under this name
*/
Object getGlobal(String name);
-
+
/**
* Delegate used to resolve any global names not found in the global map.
* @param globalResolver
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/audit/WorkingMemoryLogger.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/audit/WorkingMemoryLogger.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/audit/WorkingMemoryLogger.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -217,10 +217,10 @@
final Declaration[] declarations = activation.getRule().getDeclarations();
for ( int i = 0, length = declarations.length; i < length; i++ ) {
final Declaration declaration = declarations[i];
- final FactHandle handle = tuple.get( declaration );
+ final FactHandle handle = tuple.get( declaration );
if ( handle instanceof InternalFactHandle ) {
final InternalFactHandle handleImpl = (InternalFactHandle) handle;
- if ( handleImpl.getId() == -1 ) {
+ if ( handleImpl.getId() == -1 ) {
// This handle is now invalid, probably due to an fact retraction
continue;
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/BaseClassFieldExtractor.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/BaseClassFieldExtractor.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/BaseClassFieldExtractor.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -27,18 +27,18 @@
abstract public class BaseClassFieldExtractor
implements
FieldExtractor {
- private final int index;
+ private final int index;
- private final Class fieldType;
-
- private final ValueType valueType;
+ private final Class fieldType;
+ private final ValueType valueType;
+
public BaseClassFieldExtractor(final Class clazz,
final String fieldName) {
try {
final ClassFieldInspector inspector = new ClassFieldInspector( clazz );
- this.index = ((Integer) inspector.getFieldNames().get( fieldName ) ).intValue();
- this.fieldType = (Class) inspector.getFieldTypes().get( fieldName ) ;
+ this.index = ((Integer) inspector.getFieldNames().get( fieldName )).intValue();
+ this.fieldType = (Class) inspector.getFieldTypes().get( fieldName );
this.valueType = ValueType.determineValueType( this.fieldType );
} catch ( final Exception e ) {
throw new RuntimeDroolsException( e );
@@ -52,8 +52,8 @@
public Class getExtractToClass() {
return this.fieldType;
}
-
- public ValueType getValueType() {
+
+ public ValueType getValueType() {
return this.valueType;
}
@@ -75,5 +75,5 @@
}
final BaseClassFieldExtractor other = (BaseClassFieldExtractor) object;
return this.fieldType == other.fieldType && this.index == other.index;
- }
+ }
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/BaseEvaluator.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/BaseEvaluator.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/BaseEvaluator.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -29,7 +29,7 @@
implements
Evaluator {
- private final Operator operator;
+ private final Operator operator;
private final ValueType type;
@@ -54,8 +54,8 @@
if ( object == null || getClass() != object.getClass() ) {
return false;
}
-
- Evaluator other = ( Evaluator ) object;
+
+ final Evaluator other = (Evaluator) object;
return this.getOperator() == other.getOperator() && this.getValueType() == other.getValueType();
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/ClassFieldExtractor.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/ClassFieldExtractor.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/ClassFieldExtractor.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -81,7 +81,7 @@
public ValueType getValueType() {
return this.extractor.getValueType();
}
-
+
public Class getExtractToClass() {
return this.extractor.getExtractToClass();
}
@@ -108,35 +108,35 @@
return this.extractor.getValueType() == other.getValueType() && this.extractor.getIndex() == other.getIndex();
}
- public boolean getBooleanValue(Object object) {
+ public boolean getBooleanValue(final Object object) {
return this.extractor.getBooleanValue( object );
}
- public byte getByteValue(Object object) {
+ public byte getByteValue(final Object object) {
return this.extractor.getByteValue( object );
}
- public char getCharValue(Object object) {
+ public char getCharValue(final Object object) {
return this.extractor.getCharValue( object );
}
- public double getDoubleValue(Object object) {
+ public double getDoubleValue(final Object object) {
return this.extractor.getDoubleValue( object );
}
- public float getFloatValue(Object object) {
+ public float getFloatValue(final Object object) {
return this.extractor.getFloatValue( object );
}
- public int getIntValue(Object object) {
+ public int getIntValue(final Object object) {
return this.extractor.getIntValue( object );
}
- public long getLongValue(Object object) {
+ public long getLongValue(final Object object) {
return this.extractor.getLongValue( object );
}
- public short getShortValue(Object object) {
+ public short getShortValue(final Object object) {
return this.extractor.getShortValue( object );
}
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/ClassFieldExtractorCache.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/ClassFieldExtractorCache.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/ClassFieldExtractorCache.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -14,19 +14,22 @@
*/
public class ClassFieldExtractorCache {
private Map cache;
-
- public ClassFieldExtractorCache( ) {
+
+ public ClassFieldExtractorCache() {
this.cache = new HashMap();
}
-
- public ClassFieldExtractor getExtractor(Class clazz, String fieldName) {
- String key = clazz.getName() + "|" + fieldName;
- if (this.cache.containsKey( key )) {
- return (ClassFieldExtractor) cache.get( key );
+
+ public ClassFieldExtractor getExtractor(final Class clazz,
+ final String fieldName) {
+ final String key = clazz.getName() + "|" + fieldName;
+ if ( this.cache.containsKey( key ) ) {
+ return (ClassFieldExtractor) this.cache.get( key );
} else {
- ClassFieldExtractor ex = new ClassFieldExtractor(clazz, fieldName);
- cache.put( key, ex );
+ final ClassFieldExtractor ex = new ClassFieldExtractor( clazz,
+ fieldName );
+ this.cache.put( key,
+ ex );
return ex;
- }
+ }
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/ClassFieldExtractorFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/ClassFieldExtractorFactory.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/ClassFieldExtractorFactory.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -83,7 +83,7 @@
final ClassWriter cw = new ClassWriter( true );
- Class superClass = getSuperClassFor( fieldType );
+ final Class superClass = getSuperClassFor( fieldType );
buildClassHeader( superClass,
className,
cw );
@@ -91,9 +91,13 @@
buildConstructor( superClass,
className,
cw );
-
- buildGetMethod( originalClass, className, superClass, getterMethod, cw );
+ buildGetMethod( originalClass,
+ className,
+ superClass,
+ getterMethod,
+ cw );
+
cw.visitEnd();
return cw.toByteArray();
@@ -136,7 +140,7 @@
mv = cw.visitMethod( Opcodes.ACC_PUBLIC,
"<init>",
Type.getMethodDescriptor( Type.VOID_TYPE,
- new Type[]{ Type.getType( Class.class ), Type.getType( String.class )} ),
+ new Type[]{Type.getType( Class.class ), Type.getType( String.class )} ),
null,
null );
mv.visitCode();
@@ -152,7 +156,7 @@
Type.getInternalName( superClazz ),
"<init>",
Type.getMethodDescriptor( Type.VOID_TYPE,
- new Type[]{ Type.getType( Class.class ), Type.getType( String.class )} ));
+ new Type[]{Type.getType( Class.class ), Type.getType( String.class )} ) );
final Label l1 = new Label();
mv.visitLabel( l1 );
mv.visitInsn( Opcodes.RETURN );
@@ -190,35 +194,36 @@
* @param method
* @param cw
*/
- protected static void buildGetMethod(Class originalClass,
- String className,
- Class superClass,
- Method getterMethod,
- ClassWriter cw) {
-
- Class fieldType = getterMethod.getReturnType();
+ protected static void buildGetMethod(final Class originalClass,
+ final String className,
+ final Class superClass,
+ final Method getterMethod,
+ final ClassWriter cw) {
+
+ final Class fieldType = getterMethod.getReturnType();
Method overridingMethod;
try {
- overridingMethod = superClass.getMethod( getOverridingMethodName( fieldType ),
- new Class[] { Object.class } );
- } catch ( Exception e ) {
- throw new RuntimeDroolsException("This is a bug. Please report back to JBRules team.", e);
+ overridingMethod = superClass.getMethod( getOverridingMethodName( fieldType ),
+ new Class[]{Object.class} );
+ } catch ( final Exception e ) {
+ throw new RuntimeDroolsException( "This is a bug. Please report back to JBRules team.",
+ e );
}
- MethodVisitor mv = cw.visitMethod( Opcodes.ACC_PUBLIC,
+ final MethodVisitor mv = cw.visitMethod( Opcodes.ACC_PUBLIC,
overridingMethod.getName(),
Type.getMethodDescriptor( overridingMethod ),
null,
null );
-
+
mv.visitCode();
-
+
final Label l0 = new Label();
mv.visitLabel( l0 );
mv.visitVarInsn( Opcodes.ALOAD,
1 );
mv.visitTypeInsn( Opcodes.CHECKCAST,
Type.getInternalName( originalClass ) );
-
+
if ( originalClass.isInterface() ) {
mv.visitMethodInsn( Opcodes.INVOKEINTERFACE,
Type.getInternalName( originalClass ),
@@ -250,7 +255,7 @@
mv.visitEnd();
}
- private static String getOverridingMethodName( Class fieldType ) {
+ private static String getOverridingMethodName(final Class fieldType) {
String ret = null;
if ( fieldType.isPrimitive() ) {
if ( fieldType == char.class ) {
@@ -283,7 +288,7 @@
* @param fieldType
* @return
*/
- private static Class getSuperClassFor(Class fieldType) {
+ private static Class getSuperClassFor(final Class fieldType) {
Class ret = null;
if ( fieldType.isPrimitive() ) {
if ( fieldType == char.class ) {
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/ClassObjectType.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/ClassObjectType.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/ClassObjectType.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -16,8 +16,6 @@
* limitations under the License.
*/
-import java.lang.reflect.InvocationTargetException;
-
import org.drools.RuntimeDroolsException;
import org.drools.spi.ObjectType;
@@ -118,13 +116,14 @@
return this.valueType;
}
- public Object getShadow(Object fact) throws RuntimeDroolsException {
+ public Object getShadow(final Object fact) throws RuntimeDroolsException {
ShadowProxy proxy = null;
if ( isShadowEnabled() ) {
try {
- proxy = (ShadowProxy) shadowClass.getConstructor( new Class[]{this.objectTypeClass} ).newInstance( new Object[]{fact} );
- } catch ( Exception e ) {
- throw new RuntimeDroolsException("Error creating shadow fact for object: "+fact, e);
+ proxy = (ShadowProxy) this.shadowClass.getConstructor( new Class[]{this.objectTypeClass} ).newInstance( new Object[]{fact} );
+ } catch ( final Exception e ) {
+ throw new RuntimeDroolsException( "Error creating shadow fact for object: " + fact,
+ e );
}
}
return proxy;
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/DefaultKnowledgeHelper.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/DefaultKnowledgeHelper.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/DefaultKnowledgeHelper.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -49,8 +49,8 @@
this.tuple = agendaItem.getTuple();
this.workingMemory = (InternalWorkingMemoryActions) workingMemory;
}
-
- public void setActivation(Activation agendaItem) {
+
+ public void setActivation(final Activation agendaItem) {
this.rule = agendaItem.getRule();
this.activation = agendaItem;
this.tuple = agendaItem.getTuple();
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/DroolsQuery.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/DroolsQuery.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/DroolsQuery.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -31,20 +31,20 @@
public int hashCode() {
final int PRIME = 31;
int result = 1;
- result = PRIME * result + ((name == null) ? 0 : name.hashCode());
+ result = PRIME * result + ((this.name == null) ? 0 : this.name.hashCode());
return result;
}
- public boolean equals(Object object) {
- if (this == object) {
+ public boolean equals(final Object object) {
+ if ( this == object ) {
return true;
}
-
- if (object == null || getClass() != object.getClass()) {
+
+ if ( object == null || getClass() != object.getClass() ) {
return false;
}
-
+
final DroolsQuery other = (DroolsQuery) object;
- return name.equals(other.name);
- }
+ return this.name.equals( other.name );
+ }
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/FieldFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/FieldFactory.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/FieldFactory.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -36,7 +36,7 @@
}
- public static FieldValue getFieldValue(String value,
+ public static FieldValue getFieldValue(final String value,
ValueType valueType) {
FieldValue field = null;
if ( value == null ) {
@@ -50,7 +50,7 @@
} else if ( valueType == ValueType.BYTE_TYPE ) {
field = new LongFieldImpl( Long.parseLong( value ) );
} else if ( valueType == ValueType.SHORT_TYPE ) {
- field = new LongFieldImpl( Long.parseLong( value ) );
+ field = new LongFieldImpl( Long.parseLong( value ) );
} else if ( valueType == ValueType.INTEGER_TYPE ) {
field = new LongFieldImpl( Long.parseLong( stripNumericType( value ) ) );
} else if ( valueType == ValueType.LONG_TYPE ) {
@@ -72,20 +72,21 @@
} else if ( valueType == ValueType.OBJECT_TYPE ) {
field = new ObjectFieldImpl( value );
} else if ( valueType == ValueType.BIG_DECIMAL_TYPE ) {
- field = new ObjectFieldImpl( new BigDecimal(value) );
+ field = new ObjectFieldImpl( new BigDecimal( value ) );
} else if ( valueType == ValueType.BIG_INTEGER_TYPE ) {
- field = new ObjectFieldImpl( new BigInteger(value) );
+ field = new ObjectFieldImpl( new BigInteger( value ) );
}
return field;
}
-
+
private static String stripNumericType(String value) {
// incase a user adds a f or l, strip it as its not needed
- if ( Character.getType( value.charAt( value.length() -1 ) ) != Character.DECIMAL_DIGIT_NUMBER ) {
- value = value.substring( 0, value.length() -1 );
+ if ( Character.getType( value.charAt( value.length() - 1 ) ) != Character.DECIMAL_DIGIT_NUMBER ) {
+ value = value.substring( 0,
+ value.length() - 1 );
}
-
+
return value;
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/ShadowProxy.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/ShadowProxy.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/ShadowProxy.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -20,7 +20,7 @@
* A markup interface for shadow fact proxies
*/
public interface ShadowProxy {
-
+
public void updateProxy();
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/ShadowProxyFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/ShadowProxyFactory.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/ShadowProxyFactory.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -34,7 +34,7 @@
* A factory for ShadowProxy classes
*/
public class ShadowProxyFactory {
- private static final String UPDATE_PROXY = "updateProxy";
+ private static final String UPDATE_PROXY = "updateProxy";
private static final String BASE_INTERFACE = Type.getInternalName( ShadowProxy.class );
@@ -97,29 +97,29 @@
className,
cw );
- buildField( DELEGATE_FIELD_NAME,
+ buildField( ShadowProxyFactory.DELEGATE_FIELD_NAME,
Type.getDescriptor( clazz ),
cw );
- Map fieldTypes = new HashMap();
- Method[] methods = clazz.getMethods();
+ final Map fieldTypes = new HashMap();
+ final Method[] methods = clazz.getMethods();
for ( int i = 0; i < methods.length; i++ ) {
if ( (!Modifier.isFinal( methods[i].getModifiers() )) && Modifier.isPublic( methods[i].getModifiers() ) ) {
- if ( (!methods[i].getReturnType().equals( Void.TYPE )) && (methods[i].getParameterTypes().length == 0)) {
- String fieldName = methods[i].getName();
+ if ( (!methods[i].getReturnType().equals( Void.TYPE )) && (methods[i].getParameterTypes().length == 0) ) {
+ final String fieldName = methods[i].getName();
- buildField( /*FIELD_NAME_PREFIX +*/ fieldName,
+ buildField( /*FIELD_NAME_PREFIX +*/fieldName,
Type.getDescriptor( methods[i].getReturnType() ),
cw );
- fieldTypes.put( /*FIELD_NAME_PREFIX +*/ fieldName,
+ fieldTypes.put( /*FIELD_NAME_PREFIX +*/fieldName,
methods[i].getReturnType() );
- buildField( /*FIELD_NAME_PREFIX +*/ fieldName + FIELD_SET_FLAG,
+ buildField( /*FIELD_NAME_PREFIX +*/fieldName + ShadowProxyFactory.FIELD_SET_FLAG,
Type.BOOLEAN_TYPE.getDescriptor(),
cw );
- buildGetMethod( /*FIELD_NAME_PREFIX +*/ fieldName,
+ buildGetMethod( /*FIELD_NAME_PREFIX +*/fieldName,
methods[i].getReturnType(),
- /*FIELD_NAME_PREFIX +*/ fieldName + FIELD_SET_FLAG,
+ /*FIELD_NAME_PREFIX +*/fieldName + ShadowProxyFactory.FIELD_SET_FLAG,
methods[i],
className,
clazz,
@@ -153,31 +153,30 @@
className,
cw );
- buildField( DELEGATE_FIELD_NAME,
+ buildField( ShadowProxyFactory.DELEGATE_FIELD_NAME,
Type.getDescriptor( clazz ),
cw );
- Map fieldTypes = new HashMap();
- Map fieldMethods = new HashMap();
+ final Map fieldTypes = new HashMap();
+ final Map fieldMethods = new HashMap();
- Method[] methods = clazz.getMethods();
+ final Method[] methods = clazz.getMethods();
for ( int i = 0; i < methods.length; i++ ) {
if ( (!Modifier.isFinal( methods[i].getModifiers() )) && Modifier.isPublic( methods[i].getModifiers() ) ) {
- if ( (!methods[i].getReturnType().equals( Void.TYPE )) && (methods[i].getParameterTypes().length == 0) &&
- ((methods[i].getName().startsWith( "get" )) || (methods[i].getName().startsWith( "is" )))) {
- String fieldName = methods[i].getName();
+ if ( (!methods[i].getReturnType().equals( Void.TYPE )) && (methods[i].getParameterTypes().length == 0) && ((methods[i].getName().startsWith( "get" )) || (methods[i].getName().startsWith( "is" ))) ) {
+ final String fieldName = methods[i].getName();
- buildField( /*FIELD_NAME_PREFIX +*/ fieldName,
+ buildField( /*FIELD_NAME_PREFIX +*/fieldName,
Type.getDescriptor( methods[i].getReturnType() ),
cw );
- fieldMethods.put( /*FIELD_NAME_PREFIX +*/ fieldName,
+ fieldMethods.put( /*FIELD_NAME_PREFIX +*/fieldName,
methods[i] );
- fieldTypes.put( /*FIELD_NAME_PREFIX +*/ fieldName,
+ fieldTypes.put( /*FIELD_NAME_PREFIX +*/fieldName,
methods[i].getReturnType() );
- buildSimpleGetMethod( /*FIELD_NAME_PREFIX +*/ fieldName,
+ buildSimpleGetMethod( /*FIELD_NAME_PREFIX +*/fieldName,
methods[i].getReturnType(),
- /*FIELD_NAME_PREFIX +*/ fieldName + FIELD_SET_FLAG,
+ /*FIELD_NAME_PREFIX +*/fieldName + ShadowProxyFactory.FIELD_SET_FLAG,
methods[i],
className,
clazz,
@@ -220,14 +219,14 @@
className,
null,
Type.getInternalName( Object.class ),
- new String[]{BASE_INTERFACE, Type.getInternalName( clazz )} );
+ new String[]{ShadowProxyFactory.BASE_INTERFACE, Type.getInternalName( clazz )} );
} else {
cw.visit( Opcodes.V1_2,
Opcodes.ACC_PUBLIC + Opcodes.ACC_SUPER,
className,
null,
Type.getInternalName( clazz ),
- new String[]{BASE_INTERFACE} );
+ new String[]{ShadowProxyFactory.BASE_INTERFACE} );
}
cw.visitSource( null,
@@ -240,9 +239,9 @@
* @param cw
* @param fieldDef
*/
- protected static void buildField(String name,
- String type,
- ClassWriter cw) {
+ protected static void buildField(final String name,
+ final String type,
+ final ClassWriter cw) {
FieldVisitor fv;
fv = cw.visitField( Opcodes.ACC_PRIVATE,
name,
@@ -274,7 +273,7 @@
mv.visitCode();
// super();
- Label l0 = new Label();
+ final Label l0 = new Label();
mv.visitLabel( l0 );
mv.visitLineNumber( 41,
l0 );
@@ -295,7 +294,7 @@
}
// this.delegate = delegate
- Label l1 = new Label();
+ final Label l1 = new Label();
mv.visitLabel( l1 );
mv.visitLineNumber( 42,
l1 );
@@ -305,17 +304,17 @@
1 );
mv.visitFieldInsn( Opcodes.PUTFIELD,
className,
- DELEGATE_FIELD_NAME,
+ ShadowProxyFactory.DELEGATE_FIELD_NAME,
Type.getDescriptor( clazz ) );
// return
- Label l2 = new Label();
+ final Label l2 = new Label();
mv.visitLabel( l2 );
mv.visitLineNumber( 43,
l2 );
mv.visitInsn( Opcodes.RETURN );
- Label l3 = new Label();
+ final Label l3 = new Label();
mv.visitLabel( l3 );
mv.visitLocalVariable( "this",
"L" + className + ";",
@@ -323,7 +322,7 @@
l0,
l3,
0 );
- mv.visitLocalVariable( DELEGATE_FIELD_NAME,
+ mv.visitLocalVariable( ShadowProxyFactory.DELEGATE_FIELD_NAME,
Type.getDescriptor( clazz ),
null,
l0,
@@ -357,7 +356,7 @@
mv.visitCode();
// super();
- Label l0 = new Label();
+ final Label l0 = new Label();
mv.visitLabel( l0 );
mv.visitLineNumber( 41,
l0 );
@@ -378,7 +377,7 @@
}
// this.delegate = delegate
- Label l1 = new Label();
+ final Label l1 = new Label();
mv.visitLabel( l1 );
mv.visitVarInsn( Opcodes.ALOAD,
0 );
@@ -386,27 +385,28 @@
1 );
mv.visitFieldInsn( Opcodes.PUTFIELD,
className,
- DELEGATE_FIELD_NAME,
+ ShadowProxyFactory.DELEGATE_FIELD_NAME,
Type.getDescriptor( clazz ) );
-
+
// this.updateProxy();
- Label l4 = new Label();
+ final Label l4 = new Label();
mv.visitLabel( l4 );
- mv.visitVarInsn( Opcodes.ALOAD, 0 );
+ mv.visitVarInsn( Opcodes.ALOAD,
+ 0 );
mv.visitMethodInsn( Opcodes.INVOKEVIRTUAL,
className,
- UPDATE_PROXY,
+ ShadowProxyFactory.UPDATE_PROXY,
Type.getMethodDescriptor( Type.VOID_TYPE,
new Type[]{} ) );
// return
- Label l2 = new Label();
+ final Label l2 = new Label();
mv.visitLabel( l2 );
mv.visitLineNumber( 43,
l2 );
mv.visitInsn( Opcodes.RETURN );
- Label l3 = new Label();
+ final Label l3 = new Label();
mv.visitLabel( l3 );
mv.visitLocalVariable( "this",
"L" + className + ";",
@@ -414,7 +414,7 @@
l0,
l3,
0 );
- mv.visitLocalVariable( DELEGATE_FIELD_NAME,
+ mv.visitLocalVariable( ShadowProxyFactory.DELEGATE_FIELD_NAME,
Type.getDescriptor( clazz ),
null,
l0,
@@ -434,17 +434,17 @@
* @param method
* @param cw
*/
- protected static void buildGetMethod(String fieldName,
- Class fieldType,
- String fieldFlag,
- Method method,
- String className,
- Class clazz,
- ClassWriter cw) {
+ protected static void buildGetMethod(final String fieldName,
+ final Class fieldType,
+ final String fieldFlag,
+ final Method method,
+ final String className,
+ final Class clazz,
+ final ClassWriter cw) {
// method signature
- Class[] exceptionTypes = method.getExceptionTypes();
- String[] exceptions = getExceptionArrayAsString( exceptionTypes );
- MethodVisitor mv = cw.visitMethod( Opcodes.ACC_PUBLIC,
+ final Class[] exceptionTypes = method.getExceptionTypes();
+ final String[] exceptions = getExceptionArrayAsString( exceptionTypes );
+ final MethodVisitor mv = cw.visitMethod( Opcodes.ACC_PUBLIC,
method.getName(),
Type.getMethodDescriptor( method ),
null,
@@ -452,7 +452,7 @@
mv.visitCode();
// if ( ! _fieldIsSet ) {
- Label l0 = new Label();
+ final Label l0 = new Label();
mv.visitLabel( l0 );
mv.visitVarInsn( Opcodes.ALOAD,
0 );
@@ -460,12 +460,12 @@
className,
fieldFlag,
Type.BOOLEAN_TYPE.getDescriptor() );
- Label l1 = new Label();
+ final Label l1 = new Label();
mv.visitJumpInsn( Opcodes.IFNE,
l1 );
// __field = this.delegate.method();
- Label l2 = new Label();
+ final Label l2 = new Label();
mv.visitLabel( l2 );
mv.visitVarInsn( Opcodes.ALOAD,
0 );
@@ -473,7 +473,7 @@
0 );
mv.visitFieldInsn( Opcodes.GETFIELD,
className,
- DELEGATE_FIELD_NAME,
+ ShadowProxyFactory.DELEGATE_FIELD_NAME,
Type.getDescriptor( clazz ) );
if ( clazz.isInterface() ) {
mv.visitMethodInsn( Opcodes.INVOKEINTERFACE,
@@ -492,7 +492,7 @@
Type.getDescriptor( fieldType ) );
// __fieldIsSet = true;
- Label l3 = new Label();
+ final Label l3 = new Label();
mv.visitLabel( l3 );
mv.visitVarInsn( Opcodes.ALOAD,
0 );
@@ -514,7 +514,7 @@
mv.visitInsn( Type.getType( fieldType ).getOpcode( Opcodes.IRETURN ) );
// local variables table
- Label l4 = new Label();
+ final Label l4 = new Label();
mv.visitLabel( l4 );
mv.visitLocalVariable( "this",
"L" + className + ";",
@@ -535,17 +535,17 @@
* @param method
* @param cw
*/
- protected static void buildSimpleGetMethod(String fieldName,
- Class fieldType,
- String fieldFlag,
- Method method,
- String className,
- Class clazz,
- ClassWriter cw) {
+ protected static void buildSimpleGetMethod(final String fieldName,
+ final Class fieldType,
+ final String fieldFlag,
+ final Method method,
+ final String className,
+ final Class clazz,
+ final ClassWriter cw) {
// method signature
- Class[] exceptionTypes = method.getExceptionTypes();
- String[] exceptions = getExceptionArrayAsString( exceptionTypes );
- MethodVisitor mv = cw.visitMethod( Opcodes.ACC_PUBLIC,
+ final Class[] exceptionTypes = method.getExceptionTypes();
+ final String[] exceptions = getExceptionArrayAsString( exceptionTypes );
+ final MethodVisitor mv = cw.visitMethod( Opcodes.ACC_PUBLIC,
method.getName(),
Type.getMethodDescriptor( method ),
null,
@@ -553,7 +553,7 @@
mv.visitCode();
// return __field;
- Label l0 = new Label();
+ final Label l0 = new Label();
mv.visitLabel( l0 );
mv.visitVarInsn( Opcodes.ALOAD,
0 );
@@ -564,7 +564,7 @@
mv.visitInsn( Type.getType( fieldType ).getOpcode( Opcodes.IRETURN ) );
// local variables table
- Label l4 = new Label();
+ final Label l4 = new Label();
mv.visitLabel( l4 );
mv.visitLocalVariable( "this",
"L" + className + ";",
@@ -577,28 +577,28 @@
mv.visitEnd();
}
- protected static void buildEagerUpdateProxyMethod(Class delegate,
- Map fieldTypes,
- Map fieldMethods,
- String className,
- ClassWriter cw) {
- MethodVisitor mv = cw.visitMethod( Opcodes.ACC_PUBLIC,
- UPDATE_PROXY,
+ protected static void buildEagerUpdateProxyMethod(final Class delegate,
+ final Map fieldTypes,
+ final Map fieldMethods,
+ final String className,
+ final ClassWriter cw) {
+ final MethodVisitor mv = cw.visitMethod( Opcodes.ACC_PUBLIC,
+ ShadowProxyFactory.UPDATE_PROXY,
Type.getMethodDescriptor( Type.VOID_TYPE,
new Type[]{} ),
null,
null );
mv.visitCode();
- Label l0 = new Label();
+ final Label l0 = new Label();
mv.visitLabel( l0 );
- for ( Iterator it = fieldTypes.entrySet().iterator(); it.hasNext(); ) {
- Map.Entry entry = (Map.Entry) it.next();
- String fieldName = (String) entry.getKey();
- Class fieldType = (Class) entry.getValue();
- Method method = (Method) fieldMethods.get( fieldName );
+ for ( final Iterator it = fieldTypes.entrySet().iterator(); it.hasNext(); ) {
+ final Map.Entry entry = (Map.Entry) it.next();
+ final String fieldName = (String) entry.getKey();
+ final Class fieldType = (Class) entry.getValue();
+ final Method method = (Method) fieldMethods.get( fieldName );
// __field = this.delegate.getField()
- Label l1 = new Label();
+ final Label l1 = new Label();
mv.visitLabel( l1 );
mv.visitVarInsn( Opcodes.ALOAD,
0 );
@@ -606,7 +606,7 @@
0 );
mv.visitFieldInsn( Opcodes.GETFIELD,
className,
- DELEGATE_FIELD_NAME,
+ ShadowProxyFactory.DELEGATE_FIELD_NAME,
Type.getDescriptor( delegate ) );
if ( delegate.isInterface() ) {
mv.visitMethodInsn( Opcodes.INVOKEINTERFACE,
@@ -625,10 +625,10 @@
Type.getDescriptor( fieldType ) );
}
- Label l4 = new Label();
+ final Label l4 = new Label();
mv.visitLabel( l4 );
mv.visitInsn( Opcodes.RETURN );
- Label l5 = new Label();
+ final Label l5 = new Label();
mv.visitLabel( l5 );
mv.visitLocalVariable( "this",
"L" + className + ";",
@@ -641,24 +641,24 @@
mv.visitEnd();
}
- protected static void buildUpdateProxyMethod(Map fieldTypes,
- String className,
- ClassWriter cw) {
- MethodVisitor mv = cw.visitMethod( Opcodes.ACC_PUBLIC,
- UPDATE_PROXY,
+ protected static void buildUpdateProxyMethod(final Map fieldTypes,
+ final String className,
+ final ClassWriter cw) {
+ final MethodVisitor mv = cw.visitMethod( Opcodes.ACC_PUBLIC,
+ ShadowProxyFactory.UPDATE_PROXY,
Type.getMethodDescriptor( Type.VOID_TYPE,
new Type[]{} ),
null,
null );
mv.visitCode();
- Label l0 = new Label();
+ final Label l0 = new Label();
mv.visitLabel( l0 );
- for ( Iterator it = fieldTypes.entrySet().iterator(); it.hasNext(); ) {
- Map.Entry entry = (Map.Entry) it.next();
- String fieldName = (String) entry.getKey();
- String fieldFlag = fieldName + FIELD_SET_FLAG;
- Class fieldType = (Class) entry.getValue();
- Label l1 = new Label();
+ for ( final Iterator it = fieldTypes.entrySet().iterator(); it.hasNext(); ) {
+ final Map.Entry entry = (Map.Entry) it.next();
+ final String fieldName = (String) entry.getKey();
+ final String fieldFlag = fieldName + ShadowProxyFactory.FIELD_SET_FLAG;
+ final Class fieldType = (Class) entry.getValue();
+ final Label l1 = new Label();
mv.visitLabel( l1 );
mv.visitVarInsn( Opcodes.ALOAD,
0 );
@@ -679,7 +679,7 @@
className,
fieldName,
Type.getDescriptor( fieldType ) );
- Label l2 = new Label();
+ final Label l2 = new Label();
mv.visitLabel( l2 );
mv.visitVarInsn( Opcodes.ALOAD,
0 );
@@ -689,10 +689,10 @@
fieldFlag,
Type.BOOLEAN_TYPE.getDescriptor() );
}
- Label l4 = new Label();
+ final Label l4 = new Label();
mv.visitLabel( l4 );
mv.visitInsn( Opcodes.RETURN );
- Label l5 = new Label();
+ final Label l5 = new Label();
mv.visitLabel( l5 );
mv.visitLocalVariable( "this",
"L" + className + ";",
@@ -705,14 +705,14 @@
mv.visitEnd();
}
- protected static void buildDelegateMethod(Method method,
- Class clazz,
- String className,
- ClassWriter cw) {
+ protected static void buildDelegateMethod(final Method method,
+ final Class clazz,
+ final String className,
+ final ClassWriter cw) {
// creating method visitor
- String[] exceptions = getExceptionArrayAsString( method.getExceptionTypes() );
- MethodVisitor mv = cw.visitMethod( Opcodes.ACC_PUBLIC,
+ final String[] exceptions = getExceptionArrayAsString( method.getExceptionTypes() );
+ final MethodVisitor mv = cw.visitMethod( Opcodes.ACC_PUBLIC,
method.getName(),
Type.getMethodDescriptor( method ),
null,
@@ -720,16 +720,16 @@
mv.visitCode();
// return this.delegate.method(...);
- Label l0 = new Label();
+ final Label l0 = new Label();
mv.visitLabel( l0 );
mv.visitVarInsn( Opcodes.ALOAD,
0 );
mv.visitFieldInsn( Opcodes.GETFIELD,
className,
- DELEGATE_FIELD_NAME,
+ ShadowProxyFactory.DELEGATE_FIELD_NAME,
Type.getDescriptor( clazz ) );
- Class[] parameters = method.getParameterTypes();
+ final Class[] parameters = method.getParameterTypes();
for ( int i = 0; i < parameters.length; i++ ) {
mv.visitVarInsn( Type.getType( parameters[i] ).getOpcode( Opcodes.ILOAD ),
i + 1 );
@@ -739,7 +739,7 @@
method.getName(),
Type.getMethodDescriptor( method ) );
mv.visitInsn( Type.getType( method.getReturnType() ).getOpcode( Opcodes.IRETURN ) );
- Label l1 = new Label();
+ final Label l1 = new Label();
mv.visitLabel( l1 );
mv.visitLocalVariable( "this",
"L" + className + ";",
@@ -764,8 +764,8 @@
* @param exceptionTypes
* @return
*/
- private static String[] getExceptionArrayAsString(Class[] exceptionTypes) {
- String[] exceptions = new String[exceptionTypes.length];
+ private static String[] getExceptionArrayAsString(final Class[] exceptionTypes) {
+ final String[] exceptions = new String[exceptionTypes.length];
for ( int i = 0; i < exceptions.length; i++ ) {
exceptions[i] = Type.getInternalName( exceptionTypes[i] );
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/ValueType.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/ValueType.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/ValueType.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -111,9 +111,9 @@
private final Class classType;
private final EvaluatorFactory evaluatorFactory;
- private ValueType(String name,
- Class classType,
- EvaluatorFactory evaluatorFactory) {
+ private ValueType(final String name,
+ final Class classType,
+ final EvaluatorFactory evaluatorFactory) {
this.name = name;
this.classType = classType;
this.evaluatorFactory = evaluatorFactory;
@@ -131,11 +131,11 @@
return this.classType;
}
- public Evaluator getEvaluator(Operator operator) {
+ public Evaluator getEvaluator(final Operator operator) {
return this.evaluatorFactory.getEvaluator( operator );
}
- public static ValueType determineValueType(Class clazz) {
+ public static ValueType determineValueType(final Class clazz) {
if ( clazz == null ) {
return ValueType.NULL_TYPE;
}
@@ -199,7 +199,7 @@
return this.name.hashCode();
}
- public boolean equals(Object object) {
+ public boolean equals(final Object object) {
if ( object == this ) {
return true;
}
@@ -212,13 +212,8 @@
}
public boolean isNumber() {
- return (Number.class.isAssignableFrom( this.classType )) ||
- (this.classType == Byte.TYPE) ||
- (this.classType == Short.TYPE) ||
- (this.classType == Integer.TYPE) ||
- (this.classType == Long.TYPE) ||
- (this.classType == Float.TYPE) ||
- (this.classType == Double.TYPE);
+ return (Number.class.isAssignableFrom( this.classType )) || (this.classType == Byte.TYPE) || (this.classType == Short.TYPE) || (this.classType == Integer.TYPE) || (this.classType == Long.TYPE) || (this.classType == Float.TYPE)
+ || (this.classType == Double.TYPE);
}
public boolean isChar() {
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/dataproviders/Invoker.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/dataproviders/Invoker.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/dataproviders/Invoker.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -9,6 +9,6 @@
public Object invoke(Tuple tuple,
WorkingMemory wm,
PropagationContext ctx);
-
+
public Declaration[] getRequiredDeclarations();
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/dataproviders/MethodDataProvider.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/dataproviders/MethodDataProvider.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/dataproviders/MethodDataProvider.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -14,27 +14,28 @@
implements
DataProvider {
private final Invoker invoker;
-
- public MethodDataProvider(Invoker invoker) {
+
+ public MethodDataProvider(final Invoker invoker) {
this.invoker = invoker;
}
-
public Declaration[] getRequiredDeclarations() {
return this.invoker.getRequiredDeclarations();
}
- public Iterator getResults(Tuple tuple,
- WorkingMemory wm,
- PropagationContext ctx) {
- Object result = this.invoker.invoke( tuple, wm, ctx );
+ public Iterator getResults(final Tuple tuple,
+ final WorkingMemory wm,
+ final PropagationContext ctx) {
+ final Object result = this.invoker.invoke( tuple,
+ wm,
+ ctx );
if ( result instanceof Collection ) {
return ((Collection) result).iterator();
} else if ( result instanceof Iterator ) {
return (Iterator) result;
- } else {
+ } else {
return Collections.singletonList( result ).iterator();
- }
+ }
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/dataproviders/MethodInvoker.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/dataproviders/MethodInvoker.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/dataproviders/MethodInvoker.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -31,14 +31,14 @@
/**
* Method invoker for static method
*/
- public MethodInvoker(String methodName,
- Class clazz,
- ValueHandler[] valueHandlers) {
+ public MethodInvoker(final String methodName,
+ final Class clazz,
+ final ValueHandler[] valueHandlers) {
this.instanceValueHandler = null;
this.valueHandlers = valueHandlers;
// determine required declarations
- List list = new ArrayList( 1 );
+ final List list = new ArrayList( 1 );
for ( int i = 0, length = valueHandlers.length; i < length; i++ ) {
if ( valueHandlers[i].getClass() == DeclarationVariable.class ) {
@@ -47,7 +47,7 @@
}
if ( list.isEmpty() ) {
- this.requiredDeclarations = EMPTY_DECLARATIONS;
+ this.requiredDeclarations = MethodInvoker.EMPTY_DECLARATIONS;
} else {
this.requiredDeclarations = (Declaration[]) list.toArray( new Declaration[list.size()] );
}
@@ -64,14 +64,14 @@
/**
* Method invoker for an instance
*/
- public MethodInvoker(String methodName,
- ValueHandler instanceValueHandler,
- ValueHandler[] valueHandlers) {
+ public MethodInvoker(final String methodName,
+ final ValueHandler instanceValueHandler,
+ final ValueHandler[] valueHandlers) {
this.instanceValueHandler = instanceValueHandler;
this.valueHandlers = valueHandlers;
// determine required declarations
- List list = new ArrayList( 1 );
+ final List list = new ArrayList( 1 );
if ( instanceValueHandler != null && instanceValueHandler.getClass() == DeclarationVariable.class ) {
list.add( ((DeclarationVariable) instanceValueHandler).getDeclaration() );
}
@@ -83,7 +83,7 @@
}
if ( list.isEmpty() ) {
- this.requiredDeclarations = EMPTY_DECLARATIONS;
+ this.requiredDeclarations = MethodInvoker.EMPTY_DECLARATIONS;
} else {
this.requiredDeclarations = (Declaration[]) list.toArray( new Declaration[list.size()] );
}
@@ -99,10 +99,10 @@
/**
* work out what method we will be calling at runtime, based on the name and number of parameters.
*/
- private static Method configureMethod(Class clazz,
- String methodName,
- int numOfArgs) {
- Method[] methods = clazz.getMethods();
+ private static Method configureMethod(final Class clazz,
+ final String methodName,
+ final int numOfArgs) {
+ final Method[] methods = clazz.getMethods();
for ( int i = 0; i < methods.length; i++ ) {
if ( methods[i].getName().equals( methodName ) ) {
if ( methods[i].getParameterTypes().length == numOfArgs ) {
@@ -114,15 +114,15 @@
}
public Declaration[] getRequiredDeclarations() {
- return requiredDeclarations;
+ return this.requiredDeclarations;
}
- public Object invoke(Tuple tuple,
- WorkingMemory wm,
- PropagationContext ctx) {
+ public Object invoke(final Tuple tuple,
+ final WorkingMemory wm,
+ final PropagationContext ctx) {
//get the instance that we are operating on
- Object instance = this.instanceValueHandler.getValue( tuple,
+ final Object instance = this.instanceValueHandler.getValue( tuple,
wm );
if ( instance == null ) {
@@ -130,15 +130,15 @@
}
//the args values that we will pass
- Object[] args = new Object[this.valueHandlers.length];
+ final Object[] args = new Object[this.valueHandlers.length];
//now we need to set all the values, convert if literal
for ( int i = 0; i < this.valueHandlers.length; i++ ) {
- ValueHandler handler = valueHandlers[i];
+ final ValueHandler handler = this.valueHandlers[i];
if ( handler instanceof LiteralValue ) {
- String text = (String) handler.getValue( tuple,
+ final String text = (String) handler.getValue( tuple,
wm );
- Class type = parameterTypes[i];
+ final Class type = this.parameterTypes[i];
if ( type == String.class ) {
args[i] = text;
} else {
@@ -157,11 +157,11 @@
result = this.method.invoke( instance,
args );
// @todo : should wrap and return an exception that the user understands
- } catch ( IllegalArgumentException e ) {
+ } catch ( final IllegalArgumentException e ) {
throw new RuntimeDroolsException( e );
- } catch ( IllegalAccessException e ) {
+ } catch ( final IllegalAccessException e ) {
throw new RuntimeDroolsException( e );
- } catch ( InvocationTargetException e ) {
+ } catch ( final InvocationTargetException e ) {
throw new RuntimeDroolsException( e );
}
@@ -171,8 +171,8 @@
/**
* Attempt to convert text to the target class type
*/
- private static Object convert(String text,
- Class type) {
+ private static Object convert(final String text,
+ final Class type) {
if ( type == Integer.class || type == int.class ) {
return new Integer( text );
} else if ( text == "null" ) {
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/ArrayFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/ArrayFactory.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/ArrayFactory.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -42,10 +42,10 @@
}
public static EvaluatorFactory getInstance() {
- if ( INSTANCE == null ) {
- INSTANCE = new ArrayFactory();
+ if ( ArrayFactory.INSTANCE == null ) {
+ ArrayFactory.INSTANCE = new ArrayFactory();
}
- return INSTANCE;
+ return ArrayFactory.INSTANCE;
}
public Evaluator getEvaluator(final Operator operator) {
@@ -77,8 +77,8 @@
public boolean evaluate(final Extractor extractor,
final Object object1,
final FieldValue object2) {
- Object value1 = extractor.getValue( object1 );
- Object value2 = object2.getValue();
+ final Object value1 = extractor.getValue( object1 );
+ final Object value2 = object2.getValue();
if ( value1 == null ) {
return value2 == null;
}
@@ -88,26 +88,26 @@
public boolean evaluate(final FieldValue object1,
final Extractor extractor,
final Object object2) {
- Object value1 = object1.getValue();
- Object value2 = extractor.getValue( object2 );
+ final Object value1 = object1.getValue();
+ final Object value2 = extractor.getValue( object2 );
if ( value1 == null ) {
return value2 == null;
}
return value1.equals( value2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
- Object value = context.declaration.getExtractor().getValue( left );
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
+ final Object value = context.declaration.getExtractor().getValue( left );
if ( value == null ) {
return ((ObjectVariableContextEntry) context).right == null;
}
return value.equals( ((ObjectVariableContextEntry) context).right );
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
- Object value = context.extractor.getValue( right );
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
+ final Object value = context.extractor.getValue( right );
if ( ((ObjectVariableContextEntry) context).left == null ) {
return value == null;
}
@@ -134,8 +134,8 @@
public boolean evaluate(final Extractor extractor,
final Object object1,
final FieldValue object2) {
- Object value1 = extractor.getValue( object1 );
- Object value2 = object2.getValue();
+ final Object value1 = extractor.getValue( object1 );
+ final Object value2 = object2.getValue();
if ( value1 == null ) {
return value2 == null;
}
@@ -145,26 +145,26 @@
public boolean evaluate(final FieldValue object1,
final Extractor extractor,
final Object object2) {
- Object value1 = object1.getValue();
- Object value2 = extractor.getValue( object2 );
+ final Object value1 = object1.getValue();
+ final Object value2 = extractor.getValue( object2 );
if ( value1 == null ) {
return value2 == null;
}
return !value1.equals( value2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
- Object value = context.declaration.getExtractor().getValue( left );
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
+ final Object value = context.declaration.getExtractor().getValue( left );
if ( value == null ) {
return ((ObjectVariableContextEntry) context).right == null;
}
return !value.equals( ((ObjectVariableContextEntry) context).right );
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
- Object value = context.extractor.getValue( right );
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
+ final Object value = context.extractor.getValue( right );
if ( ((ObjectVariableContextEntry) context).left == null ) {
return value == null;
}
@@ -191,7 +191,7 @@
public boolean evaluate(final Extractor extractor,
final Object object1,
final FieldValue object2) {
- Object value = object2.getValue();
+ final Object value = object2.getValue();
final Object[] array = (Object[]) extractor.getValue( object1 );
if ( Arrays.binarySearch( array,
@@ -204,7 +204,7 @@
public boolean evaluate(final FieldValue object1,
final Extractor extractor,
final Object object2) {
- Object value = extractor.getValue( object2 );
+ final Object value = extractor.getValue( object2 );
final Object[] array = (Object[]) object1.getValue();
if ( Arrays.binarySearch( array,
value ) == -1 ) {
@@ -213,9 +213,9 @@
return true;
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
- Object value = ((ObjectVariableContextEntry) context).right;
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
+ final Object value = ((ObjectVariableContextEntry) context).right;
final Object[] array = (Object[]) context.declaration.getExtractor().getValue( left );
if ( Arrays.binarySearch( array,
value ) == -1 ) {
@@ -224,9 +224,9 @@
return true;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
- Object value = context.extractor.getValue( right );
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
+ final Object value = context.extractor.getValue( right );
final Object[] array = (Object[]) ((ObjectVariableContextEntry) context).left;
if ( Arrays.binarySearch( array,
value ) == -1 ) {
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/BigDecimalFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/BigDecimalFactory.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/BigDecimalFactory.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -38,10 +38,10 @@
}
public static EvaluatorFactory getInstance() {
- if ( INSTANCE == null ) {
- INSTANCE = new BigDecimalFactory();
+ if ( BigDecimalFactory.INSTANCE == null ) {
+ BigDecimalFactory.INSTANCE = new BigDecimalFactory();
}
- return INSTANCE;
+ return BigDecimalFactory.INSTANCE;
}
public Evaluator getEvaluator(final Operator operator) {
@@ -77,8 +77,8 @@
public boolean evaluate(final Extractor extractor,
final Object object1,
final FieldValue object2) {
- Object value1 = extractor.getValue( object1 );
- Object value2 = object2.getValue();
+ final Object value1 = extractor.getValue( object1 );
+ final Object value2 = object2.getValue();
if ( value1 == null ) {
return value2 == null;
}
@@ -88,26 +88,26 @@
public boolean evaluate(final FieldValue object1,
final Extractor extractor,
final Object object2) {
- Object value1 = object1.getValue();
- Object value2 = extractor.getValue( object2 );
+ final Object value1 = object1.getValue();
+ final Object value2 = extractor.getValue( object2 );
if ( value1 == null ) {
return value2 == null;
}
return value1.equals( value2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
- Object value = context.declaration.getExtractor().getValue( left );
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
+ final Object value = context.declaration.getExtractor().getValue( left );
if ( value == null ) {
return ((ObjectVariableContextEntry) context).right == null;
}
return value.equals( ((ObjectVariableContextEntry) context).right );
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
- Object value = context.extractor.getValue( right );
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
+ final Object value = context.extractor.getValue( right );
if ( ((ObjectVariableContextEntry) context).left == null ) {
return value == null;
}
@@ -134,8 +134,8 @@
public boolean evaluate(final Extractor extractor,
final Object object1,
final FieldValue object2) {
- Object value1 = extractor.getValue( object1 );
- Object value2 = object2.getValue();
+ final Object value1 = extractor.getValue( object1 );
+ final Object value2 = object2.getValue();
if ( value1 == null ) {
return value2 != null;
}
@@ -145,26 +145,26 @@
public boolean evaluate(final FieldValue object1,
final Extractor extractor,
final Object object2) {
- Object value1 = object1.getValue();
- Object value2 = extractor.getValue( object2 );
+ final Object value1 = object1.getValue();
+ final Object value2 = extractor.getValue( object2 );
if ( value1 == null ) {
return value2 != null;
}
return !value1.equals( value2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
- Object value = context.declaration.getExtractor().getValue( left );
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
+ final Object value = context.declaration.getExtractor().getValue( left );
if ( value == null ) {
return ((ObjectVariableContextEntry) context).right != null;
}
return !value.equals( ((ObjectVariableContextEntry) context).right );
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
- Object value = context.extractor.getValue( right );
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
+ final Object value = context.extractor.getValue( right );
if ( ((ObjectVariableContextEntry) context).left == null ) {
return value != null;
}
@@ -202,14 +202,14 @@
return comp.compareTo( extractor.getValue( object2 ) ) < 0;
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
final BigDecimal comp = (BigDecimal) context.declaration.getExtractor().getValue( left );
return comp.compareTo( ((ObjectVariableContextEntry) context).right ) < 0;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
final BigDecimal comp = (BigDecimal) ((ObjectVariableContextEntry) context).left;
return comp.compareTo( context.extractor.getValue( right ) ) < 0;
}
@@ -245,14 +245,14 @@
return comp.compareTo( extractor.getValue( object2 ) ) <= 0;
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
final BigDecimal comp = (BigDecimal) context.declaration.getExtractor().getValue( left );
return comp.compareTo( ((ObjectVariableContextEntry) context).right ) <= 0;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
final BigDecimal comp = (BigDecimal) ((ObjectVariableContextEntry) context).left;
return comp.compareTo( context.extractor.getValue( right ) ) <= 0;
}
@@ -288,14 +288,14 @@
return comp.compareTo( extractor.getValue( object2 ) ) > 0;
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
final BigDecimal comp = (BigDecimal) context.declaration.getExtractor().getValue( left );
return comp.compareTo( ((ObjectVariableContextEntry) context).right ) > 0;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
final BigDecimal comp = (BigDecimal) ((ObjectVariableContextEntry) context).left;
return comp.compareTo( context.extractor.getValue( right ) ) > 0;
}
@@ -331,14 +331,14 @@
return comp.compareTo( extractor.getValue( object2 ) ) >= 0;
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
final BigDecimal comp = (BigDecimal) context.declaration.getExtractor().getValue( left );
return comp.compareTo( ((ObjectVariableContextEntry) context).right ) >= 0;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
final BigDecimal comp = (BigDecimal) ((ObjectVariableContextEntry) context).left;
return comp.compareTo( context.extractor.getValue( right ) ) >= 0;
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/BigIntegerFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/BigIntegerFactory.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/BigIntegerFactory.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -26,20 +26,22 @@
import org.drools.spi.Extractor;
import org.drools.spi.FieldValue;
-public class BigIntegerFactory implements EvaluatorFactory {
+public class BigIntegerFactory
+ implements
+ EvaluatorFactory {
- private static final long serialVersionUID = 4180922947425495749L;
- private static EvaluatorFactory INSTANCE = new BigIntegerFactory();
-
+ private static final long serialVersionUID = 4180922947425495749L;
+ private static EvaluatorFactory INSTANCE = new BigIntegerFactory();
+
private BigIntegerFactory() {
-
+
}
-
+
public static EvaluatorFactory getInstance() {
- if ( INSTANCE == null ) {
- INSTANCE = new BigIntegerFactory();
+ if ( BigIntegerFactory.INSTANCE == null ) {
+ BigIntegerFactory.INSTANCE = new BigIntegerFactory();
}
- return INSTANCE;
+ return BigIntegerFactory.INSTANCE;
}
public Evaluator getEvaluator(final Operator operator) {
@@ -55,7 +57,7 @@
return BigIntegerGreaterEvaluator.INSTANCE;
} else if ( operator == Operator.GREATER_OR_EQUAL ) {
return BigIntegerGreaterOrEqualEvaluator.INSTANCE;
- } else {
+ } else {
throw new RuntimeException( "Operator '" + operator + "' does not exist for BigIntegerEvaluator" );
}
}
@@ -75,8 +77,8 @@
public boolean evaluate(final Extractor extractor,
final Object object1,
final FieldValue object2) {
- Object value1 = extractor.getValue( object1 );
- Object value2 = object2.getValue();
+ final Object value1 = extractor.getValue( object1 );
+ final Object value2 = object2.getValue();
if ( value1 == null ) {
return value2 == null;
}
@@ -86,26 +88,26 @@
public boolean evaluate(final FieldValue object1,
final Extractor extractor,
final Object object2) {
- Object value1 = object1.getValue();
- Object value2 = extractor.getValue( object2 );
+ final Object value1 = object1.getValue();
+ final Object value2 = extractor.getValue( object2 );
if ( value1 == null ) {
return value2 == null;
}
return value1.equals( value2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
- Object value = context.declaration.getExtractor().getValue( left );
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
+ final Object value = context.declaration.getExtractor().getValue( left );
if ( value == null ) {
return ((ObjectVariableContextEntry) context).right == null;
}
return value.equals( ((ObjectVariableContextEntry) context).right );
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
- Object value = context.extractor.getValue( right );
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
+ final Object value = context.extractor.getValue( right );
if ( ((ObjectVariableContextEntry) context).left == null ) {
return value == null;
}
@@ -132,8 +134,8 @@
public boolean evaluate(final Extractor extractor,
final Object object1,
final FieldValue object2) {
- Object value1 = extractor.getValue( object1 );
- Object value2 = object2.getValue();
+ final Object value1 = extractor.getValue( object1 );
+ final Object value2 = object2.getValue();
if ( value1 == null ) {
return value2 != null;
}
@@ -143,26 +145,26 @@
public boolean evaluate(final FieldValue object1,
final Extractor extractor,
final Object object2) {
- Object value1 = object1.getValue();
- Object value2 = extractor.getValue( object2 );
+ final Object value1 = object1.getValue();
+ final Object value2 = extractor.getValue( object2 );
if ( value1 == null ) {
return value2 != null;
}
return !value1.equals( value2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
- Object value = context.declaration.getExtractor().getValue( left );
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
+ final Object value = context.declaration.getExtractor().getValue( left );
if ( value == null ) {
return ((ObjectVariableContextEntry) context).right != null;
}
return !value.equals( ((ObjectVariableContextEntry) context).right );
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
- Object value = context.extractor.getValue( right );
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
+ final Object value = context.extractor.getValue( right );
if ( ((ObjectVariableContextEntry) context).left == null ) {
return value != null;
}
@@ -200,14 +202,14 @@
return comp.compareTo( extractor.getValue( object2 ) ) < 0;
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
final BigInteger comp = (BigInteger) context.declaration.getExtractor().getValue( left );
return comp.compareTo( ((ObjectVariableContextEntry) context).right ) < 0;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
final BigInteger comp = (BigInteger) ((ObjectVariableContextEntry) context).left;
return comp.compareTo( context.extractor.getValue( right ) ) < 0;
}
@@ -243,14 +245,14 @@
return comp.compareTo( extractor.getValue( object2 ) ) <= 0;
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
final BigInteger comp = (BigInteger) context.declaration.getExtractor().getValue( left );
return comp.compareTo( ((ObjectVariableContextEntry) context).right ) <= 0;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
final BigInteger comp = (BigInteger) ((ObjectVariableContextEntry) context).left;
return comp.compareTo( context.extractor.getValue( right ) ) <= 0;
}
@@ -286,14 +288,14 @@
return comp.compareTo( extractor.getValue( object2 ) ) > 0;
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
final BigInteger comp = (BigInteger) context.declaration.getExtractor().getValue( left );
return comp.compareTo( ((ObjectVariableContextEntry) context).right ) > 0;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
final BigInteger comp = (BigInteger) ((ObjectVariableContextEntry) context).left;
return comp.compareTo( context.extractor.getValue( right ) ) > 0;
}
@@ -329,14 +331,14 @@
return comp.compareTo( extractor.getValue( object2 ) ) >= 0;
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
final BigInteger comp = (BigInteger) context.declaration.getExtractor().getValue( left );
return comp.compareTo( ((ObjectVariableContextEntry) context).right ) >= 0;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
final BigInteger comp = (BigInteger) ((ObjectVariableContextEntry) context).left;
return comp.compareTo( context.extractor.getValue( right ) ) >= 0;
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/BooleanFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/BooleanFactory.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/BooleanFactory.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -28,18 +28,18 @@
implements
EvaluatorFactory {
- private static final long serialVersionUID = -1463529133869380215L;
- private static EvaluatorFactory INSTANCE = new BooleanFactory();
+ private static final long serialVersionUID = -1463529133869380215L;
+ private static EvaluatorFactory INSTANCE = new BooleanFactory();
private BooleanFactory() {
}
public static EvaluatorFactory getInstance() {
- if ( INSTANCE == null ) {
- INSTANCE = new BooleanFactory();
+ if ( BooleanFactory.INSTANCE == null ) {
+ BooleanFactory.INSTANCE = new BooleanFactory();
}
- return INSTANCE;
+ return BooleanFactory.INSTANCE;
}
public Evaluator getEvaluator(final Operator operator) {
@@ -76,13 +76,13 @@
return extractor.getBooleanValue( object2 ) == object1.getBooleanValue();
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
return context.declaration.getExtractor().getBooleanValue( left ) == ((BooleanVariableContextEntry) context).right;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object object2) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object object2) {
return context.extractor.getBooleanValue( object2 ) == ((BooleanVariableContextEntry) context).left;
}
@@ -115,13 +115,13 @@
return extractor.getBooleanValue( object2 ) != object1.getBooleanValue();
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
return context.declaration.getExtractor().getBooleanValue( left ) != ((BooleanVariableContextEntry) context).right;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object object2) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object object2) {
return context.extractor.getBooleanValue( object2 ) != ((BooleanVariableContextEntry) context).left;
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/ByteFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/ByteFactory.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/ByteFactory.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -36,10 +36,10 @@
}
public static EvaluatorFactory getInstance() {
- if ( INSTANCE == null ) {
- INSTANCE = new ByteFactory();
+ if ( ByteFactory.INSTANCE == null ) {
+ ByteFactory.INSTANCE = new ByteFactory();
}
- return INSTANCE;
+ return ByteFactory.INSTANCE;
}
public Evaluator getEvaluator(final Operator operator) {
@@ -84,13 +84,13 @@
return object1.getByteValue() == extractor.getByteValue( object2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
return context.declaration.getExtractor().getByteValue( left ) == ((LongVariableContextEntry) context).right;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
return ((LongVariableContextEntry) context).left == context.extractor.getByteValue( right );
}
@@ -123,13 +123,13 @@
return object1.getByteValue() != extractor.getByteValue( object2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
return context.declaration.getExtractor().getByteValue( left ) != ((LongVariableContextEntry) context).right;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
return ((LongVariableContextEntry) context).left != context.extractor.getByteValue( right );
}
@@ -162,13 +162,13 @@
return object1.getByteValue() < extractor.getByteValue( object2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
return context.declaration.getExtractor().getByteValue( left ) < ((LongVariableContextEntry) context).right;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
return ((LongVariableContextEntry) context).left < context.extractor.getByteValue( right );
}
@@ -201,13 +201,13 @@
return object1.getByteValue() <= extractor.getByteValue( object2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
return context.declaration.getExtractor().getByteValue( left ) <= ((LongVariableContextEntry) context).right;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
return ((LongVariableContextEntry) context).left <= context.extractor.getByteValue( right );
}
@@ -240,13 +240,13 @@
return object1.getByteValue() > extractor.getByteValue( object2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
return context.declaration.getExtractor().getByteValue( left ) > ((LongVariableContextEntry) context).right;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
return ((LongVariableContextEntry) context).left > context.extractor.getByteValue( right );
}
@@ -279,13 +279,13 @@
return object1.getByteValue() >= extractor.getByteValue( object2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
return context.declaration.getExtractor().getByteValue( left ) >= ((LongVariableContextEntry) context).right;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
return ((LongVariableContextEntry) context).left >= context.extractor.getByteValue( right );
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/CharacterFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/CharacterFactory.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/CharacterFactory.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -36,10 +36,10 @@
}
public static EvaluatorFactory getInstance() {
- if ( INSTANCE == null ) {
- INSTANCE = new CharacterFactory();
+ if ( CharacterFactory.INSTANCE == null ) {
+ CharacterFactory.INSTANCE = new CharacterFactory();
}
- return INSTANCE;
+ return CharacterFactory.INSTANCE;
}
public Evaluator getEvaluator(final Operator operator) {
@@ -84,13 +84,13 @@
return object1.getCharValue() == extractor.getCharValue( object2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
return context.declaration.getExtractor().getCharValue( left ) == ((LongVariableContextEntry) context).right;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
return ((LongVariableContextEntry) context).left == context.extractor.getCharValue( right );
}
@@ -123,13 +123,13 @@
return object1.getCharValue() != extractor.getCharValue( object2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
return context.declaration.getExtractor().getCharValue( left ) != ((LongVariableContextEntry) context).right;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
return ((LongVariableContextEntry) context).left != context.extractor.getCharValue( right );
}
@@ -162,13 +162,13 @@
return object1.getCharValue() < extractor.getCharValue( object2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
return context.declaration.getExtractor().getCharValue( left ) < ((LongVariableContextEntry) context).right;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
return ((LongVariableContextEntry) context).left < context.extractor.getCharValue( right );
}
@@ -201,13 +201,13 @@
return object1.getCharValue() <= extractor.getCharValue( object2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
return context.declaration.getExtractor().getCharValue( left ) <= ((LongVariableContextEntry) context).right;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
return ((LongVariableContextEntry) context).left <= context.extractor.getCharValue( right );
}
@@ -240,13 +240,13 @@
return object1.getCharValue() > extractor.getCharValue( object2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
return context.declaration.getExtractor().getCharValue( left ) > ((LongVariableContextEntry) context).right;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
return ((LongVariableContextEntry) context).left > context.extractor.getCharValue( right );
}
@@ -279,13 +279,13 @@
return object1.getCharValue() >= extractor.getCharValue( object2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
return context.declaration.getExtractor().getCharValue( left ) >= ((LongVariableContextEntry) context).right;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
return ((LongVariableContextEntry) context).left >= context.extractor.getCharValue( right );
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/DateFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/DateFactory.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/DateFactory.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -55,10 +55,10 @@
}
public static EvaluatorFactory getInstance() {
- if ( INSTANCE == null ) {
- INSTANCE = new DateFactory();
+ if ( DateFactory.INSTANCE == null ) {
+ DateFactory.INSTANCE = new DateFactory();
}
- return INSTANCE;
+ return DateFactory.INSTANCE;
}
public Evaluator getEvaluator(final Operator operator) {
@@ -94,8 +94,8 @@
public boolean evaluate(final Extractor extractor,
final Object object1,
final FieldValue object2) {
- Date value1 = (Date) extractor.getValue( object1 );
- Object value2 = object2.getValue();
+ final Date value1 = (Date) extractor.getValue( object1 );
+ final Object value2 = object2.getValue();
if ( value1 == null ) {
return value2 == null;
}
@@ -108,8 +108,8 @@
public boolean evaluate(final FieldValue object1,
final Extractor extractor,
final Object object2) {
- Date value1 = (Date) object1.getValue();
- Object value2 = extractor.getValue( object2 );
+ final Date value1 = (Date) object1.getValue();
+ final Object value2 = extractor.getValue( object2 );
if ( value1 == null ) {
return value2 == null;
}
@@ -119,10 +119,10 @@
return value1.compareTo( getRightDate( value2 ) ) == 0;
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
- Date value1 = (Date) context.declaration.getExtractor().getValue( left );
- Object value2 = ((ObjectVariableContextEntry) context).right;
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
+ final Date value1 = (Date) context.declaration.getExtractor().getValue( left );
+ final Object value2 = ((ObjectVariableContextEntry) context).right;
if ( value1 == null ) {
return value2 == null;
}
@@ -132,10 +132,10 @@
return value1.compareTo( getRightDate( value2 ) ) == 0;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
- Date value1 = (Date) ((ObjectVariableContextEntry) context).left;
- Object value2 = context.extractor.getValue( right );
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
+ final Date value1 = (Date) ((ObjectVariableContextEntry) context).left;
+ final Object value2 = context.extractor.getValue( right );
if ( value1 == null ) {
return value2 == null;
}
@@ -165,8 +165,8 @@
public boolean evaluate(final Extractor extractor,
final Object object1,
final FieldValue object2) {
- Date value1 = (Date) extractor.getValue( object1 );
- Object value2 = object2.getValue();
+ final Date value1 = (Date) extractor.getValue( object1 );
+ final Object value2 = object2.getValue();
if ( value1 == null ) {
return value2 != null;
}
@@ -179,8 +179,8 @@
public boolean evaluate(final FieldValue object1,
final Extractor extractor,
final Object object2) {
- Date value1 = (Date) object1.getValue();
- Object value2 = extractor.getValue( object2 );
+ final Date value1 = (Date) object1.getValue();
+ final Object value2 = extractor.getValue( object2 );
if ( value1 == null ) {
return value2 != null;
}
@@ -190,10 +190,10 @@
return value1.compareTo( getRightDate( value2 ) ) != 0;
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
- Date value1 = (Date) context.declaration.getExtractor().getValue( left );
- Object value2 = ((ObjectVariableContextEntry) context).right;
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
+ final Date value1 = (Date) context.declaration.getExtractor().getValue( left );
+ final Object value2 = ((ObjectVariableContextEntry) context).right;
if ( value1 == null ) {
return value2 != null;
}
@@ -203,10 +203,10 @@
return value1.compareTo( getRightDate( value2 ) ) != 0;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
- Date value1 = (Date) ((ObjectVariableContextEntry) context).left;
- Object value2 = context.extractor.getValue( right );
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
+ final Date value1 = (Date) ((ObjectVariableContextEntry) context).left;
+ final Object value2 = context.extractor.getValue( right );
if ( value1 == null ) {
return value2 != null;
}
@@ -236,30 +236,30 @@
public boolean evaluate(final Extractor extractor,
final Object object1,
final FieldValue object2) {
- Date value1 = (Date) extractor.getValue( object1 );
- Object value2 = object2.getValue();
+ final Date value1 = (Date) extractor.getValue( object1 );
+ final Object value2 = object2.getValue();
return value1.compareTo( getRightDate( value2 ) ) < 0;
}
public boolean evaluate(final FieldValue object1,
final Extractor extractor,
final Object object2) {
- Date value1 = (Date) object1.getValue();
- Object value2 = extractor.getValue( object2 );
+ final Date value1 = (Date) object1.getValue();
+ final Object value2 = extractor.getValue( object2 );
return value1.compareTo( getRightDate( value2 ) ) < 0;
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
- Date value1 = (Date) context.declaration.getExtractor().getValue( left );
- Object value2 = ((ObjectVariableContextEntry) context).right;
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
+ final Date value1 = (Date) context.declaration.getExtractor().getValue( left );
+ final Object value2 = ((ObjectVariableContextEntry) context).right;
return value1.compareTo( getRightDate( value2 ) ) < 0;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
- Date value1 = (Date) ((ObjectVariableContextEntry) context).left;
- Object value2 = context.extractor.getValue( right );
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
+ final Date value1 = (Date) ((ObjectVariableContextEntry) context).left;
+ final Object value2 = context.extractor.getValue( right );
return value1.compareTo( getRightDate( value2 ) ) < 0;
}
@@ -283,30 +283,30 @@
public boolean evaluate(final Extractor extractor,
final Object object1,
final FieldValue object2) {
- Date value1 = (Date) extractor.getValue( object1 );
- Object value2 = object2.getValue();
+ final Date value1 = (Date) extractor.getValue( object1 );
+ final Object value2 = object2.getValue();
return value1.compareTo( getRightDate( value2 ) ) <= 0;
}
public boolean evaluate(final FieldValue object1,
final Extractor extractor,
final Object object2) {
- Date value1 = (Date) object1.getValue();
- Object value2 = extractor.getValue( object2 );
+ final Date value1 = (Date) object1.getValue();
+ final Object value2 = extractor.getValue( object2 );
return value1.compareTo( getRightDate( value2 ) ) <= 0;
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
- Date value1 = (Date) context.declaration.getExtractor().getValue( left );
- Object value2 = ((ObjectVariableContextEntry) context).right;
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
+ final Date value1 = (Date) context.declaration.getExtractor().getValue( left );
+ final Object value2 = ((ObjectVariableContextEntry) context).right;
return value1.compareTo( getRightDate( value2 ) ) <= 0;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
- Date value1 = (Date) ((ObjectVariableContextEntry) context).left;
- Object value2 = context.extractor.getValue( right );
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
+ final Date value1 = (Date) ((ObjectVariableContextEntry) context).left;
+ final Object value2 = context.extractor.getValue( right );
return value1.compareTo( getRightDate( value2 ) ) <= 0;
}
@@ -330,30 +330,30 @@
public boolean evaluate(final Extractor extractor,
final Object object1,
final FieldValue object2) {
- Date value1 = (Date) extractor.getValue( object1 );
- Object value2 = object2.getValue();
+ final Date value1 = (Date) extractor.getValue( object1 );
+ final Object value2 = object2.getValue();
return value1.compareTo( getRightDate( value2 ) ) > 0;
}
public boolean evaluate(final FieldValue object1,
final Extractor extractor,
final Object object2) {
- Date value1 = (Date) object1.getValue();
- Object value2 = extractor.getValue( object2 );
+ final Date value1 = (Date) object1.getValue();
+ final Object value2 = extractor.getValue( object2 );
return value1.compareTo( getRightDate( value2 ) ) > 0;
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
- Date value1 = (Date) context.declaration.getExtractor().getValue( left );
- Object value2 = ((ObjectVariableContextEntry) context).right;
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
+ final Date value1 = (Date) context.declaration.getExtractor().getValue( left );
+ final Object value2 = ((ObjectVariableContextEntry) context).right;
return value1.compareTo( getRightDate( value2 ) ) > 0;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
- Date value1 = (Date) ((ObjectVariableContextEntry) context).left;
- Object value2 = context.extractor.getValue( right );
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
+ final Date value1 = (Date) ((ObjectVariableContextEntry) context).left;
+ final Object value2 = context.extractor.getValue( right );
return value1.compareTo( getRightDate( value2 ) ) > 0;
}
@@ -377,30 +377,30 @@
public boolean evaluate(final Extractor extractor,
final Object object1,
final FieldValue object2) {
- Date value1 = (Date) extractor.getValue( object1 );
- Object value2 = object2.getValue();
+ final Date value1 = (Date) extractor.getValue( object1 );
+ final Object value2 = object2.getValue();
return value1.compareTo( getRightDate( value2 ) ) >= 0;
}
public boolean evaluate(final FieldValue object1,
final Extractor extractor,
final Object object2) {
- Date value1 = (Date) object1.getValue();
- Object value2 = extractor.getValue( object2 );
+ final Date value1 = (Date) object1.getValue();
+ final Object value2 = extractor.getValue( object2 );
return value1.compareTo( getRightDate( value2 ) ) >= 0;
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
- Date value1 = (Date) context.declaration.getExtractor().getValue( left );
- Object value2 = ((ObjectVariableContextEntry) context).right;
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
+ final Date value1 = (Date) context.declaration.getExtractor().getValue( left );
+ final Object value2 = ((ObjectVariableContextEntry) context).right;
return value1.compareTo( getRightDate( value2 ) ) >= 0;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
- Date value1 = (Date) ((ObjectVariableContextEntry) context).left;
- Object value2 = context.extractor.getValue( right );
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
+ final Date value1 = (Date) ((ObjectVariableContextEntry) context).left;
+ final Object value2 = context.extractor.getValue( right );
return value1.compareTo( getRightDate( value2 ) ) >= 0;
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/DoubleFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/DoubleFactory.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/DoubleFactory.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -36,10 +36,10 @@
}
public static EvaluatorFactory getInstance() {
- if ( INSTANCE == null ) {
- INSTANCE = new DoubleFactory();
+ if ( DoubleFactory.INSTANCE == null ) {
+ DoubleFactory.INSTANCE = new DoubleFactory();
}
- return INSTANCE;
+ return DoubleFactory.INSTANCE;
}
public Evaluator getEvaluator(final Operator operator) {
@@ -86,14 +86,14 @@
return object1.getDoubleValue() == extractor.getDoubleValue( object2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
// TODO: we are not handling delta right now... maybe we should
return context.declaration.getExtractor().getDoubleValue( left ) == ((DoubleVariableContextEntry) context).right;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
// TODO: we are not handling delta right now... maybe we should
return ((DoubleVariableContextEntry) context).left == context.extractor.getDoubleValue( right );
}
@@ -129,14 +129,14 @@
return object1.getDoubleValue() != extractor.getDoubleValue( object2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
// TODO: we are not handling delta right now... maybe we should
return context.declaration.getExtractor().getDoubleValue( left ) != ((DoubleVariableContextEntry) context).right;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
// TODO: we are not handling delta right now... maybe we should
return ((DoubleVariableContextEntry) context).left != context.extractor.getDoubleValue( right );
}
@@ -172,14 +172,14 @@
return object1.getDoubleValue() < extractor.getDoubleValue( object2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
// TODO: we are not handling delta right now... maybe we should
return context.declaration.getExtractor().getDoubleValue( left ) < ((DoubleVariableContextEntry) context).right;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
// TODO: we are not handling delta right now... maybe we should
return ((DoubleVariableContextEntry) context).left < context.extractor.getDoubleValue( right );
}
@@ -215,14 +215,14 @@
return object1.getDoubleValue() <= extractor.getDoubleValue( object2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
// TODO: we are not handling delta right now... maybe we should
return context.declaration.getExtractor().getDoubleValue( left ) <= ((DoubleVariableContextEntry) context).right;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
// TODO: we are not handling delta right now... maybe we should
return ((DoubleVariableContextEntry) context).left <= context.extractor.getDoubleValue( right );
}
@@ -258,14 +258,14 @@
return object1.getDoubleValue() > extractor.getDoubleValue( object2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
// TODO: we are not handling delta right now... maybe we should
return context.declaration.getExtractor().getDoubleValue( left ) > ((DoubleVariableContextEntry) context).right;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
// TODO: we are not handling delta right now... maybe we should
return ((DoubleVariableContextEntry) context).left > context.extractor.getDoubleValue( right );
}
@@ -301,14 +301,14 @@
return object1.getDoubleValue() >= extractor.getDoubleValue( object2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
// TODO: we are not handling delta right now... maybe we should
return context.declaration.getExtractor().getDoubleValue( left ) >= ((DoubleVariableContextEntry) context).right;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
// TODO: we are not handling delta right now... maybe we should
return ((DoubleVariableContextEntry) context).left >= context.extractor.getDoubleValue( right );
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/EvaluatorFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/EvaluatorFactory.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/EvaluatorFactory.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -4,6 +4,8 @@
import org.drools.spi.Evaluator;
-public interface EvaluatorFactory extends Serializable{
+public interface EvaluatorFactory
+ extends
+ Serializable {
public Evaluator getEvaluator(Operator operator);
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/FactTemplateFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/FactTemplateFactory.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/FactTemplateFactory.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -43,10 +43,10 @@
}
public static EvaluatorFactory getInstance() {
- if ( INSTANCE == null ) {
- INSTANCE = new FactTemplateFactory();
+ if ( FactTemplateFactory.INSTANCE == null ) {
+ FactTemplateFactory.INSTANCE = new FactTemplateFactory();
}
- return INSTANCE;
+ return FactTemplateFactory.INSTANCE;
}
public Evaluator getEvaluator(final Operator operator) {
@@ -74,8 +74,8 @@
public boolean evaluate(final Extractor extractor,
final Object object1,
final FieldValue object2) {
- Object value1 = extractor.getValue( object1 );
- Object value2 = object2.getValue();
+ final Object value1 = extractor.getValue( object1 );
+ final Object value2 = object2.getValue();
if ( value1 == null ) {
return value2 == null;
}
@@ -85,26 +85,26 @@
public boolean evaluate(final FieldValue object1,
final Extractor extractor,
final Object object2) {
- Object value1 = object1.getValue();
- Object value2 = extractor.getValue( object2 );
+ final Object value1 = object1.getValue();
+ final Object value2 = extractor.getValue( object2 );
if ( value1 == null ) {
return value2 == null;
}
return value1.equals( value2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
- Object value = context.declaration.getExtractor().getValue( left );
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
+ final Object value = context.declaration.getExtractor().getValue( left );
if ( value == null ) {
return ((ObjectVariableContextEntry) context).right == null;
}
return value.equals( ((ObjectVariableContextEntry) context).right );
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
- Object value = context.extractor.getValue( right );
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
+ final Object value = context.extractor.getValue( right );
if ( ((ObjectVariableContextEntry) context).left == null ) {
return value == null;
}
@@ -131,8 +131,8 @@
public boolean evaluate(final Extractor extractor,
final Object object1,
final FieldValue object2) {
- Object value1 = extractor.getValue( object1 );
- Object value2 = object2.getValue();
+ final Object value1 = extractor.getValue( object1 );
+ final Object value2 = object2.getValue();
if ( value1 == null ) {
return value2 != null;
}
@@ -142,26 +142,26 @@
public boolean evaluate(final FieldValue object1,
final Extractor extractor,
final Object object2) {
- Object value1 = object1.getValue();
- Object value2 = extractor.getValue( object2 );
+ final Object value1 = object1.getValue();
+ final Object value2 = extractor.getValue( object2 );
if ( value1 == null ) {
return value2 != null;
}
return !value1.equals( value2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
- Object value = context.declaration.getExtractor().getValue( left );
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
+ final Object value = context.declaration.getExtractor().getValue( left );
if ( value == null ) {
return ((ObjectVariableContextEntry) context).right != null;
}
return !value.equals( ((ObjectVariableContextEntry) context).right );
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
- Object value = context.extractor.getValue( right );
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
+ final Object value = context.extractor.getValue( right );
if ( ((ObjectVariableContextEntry) context).left == null ) {
return value != null;
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/FloatFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/FloatFactory.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/FloatFactory.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -36,10 +36,10 @@
}
public static EvaluatorFactory getInstance() {
- if ( INSTANCE == null ) {
- INSTANCE = new FloatFactory();
+ if ( FloatFactory.INSTANCE == null ) {
+ FloatFactory.INSTANCE = new FloatFactory();
}
- return INSTANCE;
+ return FloatFactory.INSTANCE;
}
public Evaluator getEvaluator(final Operator operator) {
@@ -84,14 +84,14 @@
return object1.getFloatValue() == extractor.getFloatValue( object2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
// TODO: we are not handling delta right now... maybe we should
return context.declaration.getExtractor().getFloatValue( left ) == ((DoubleVariableContextEntry) context).right;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
// TODO: we are not handling delta right now... maybe we should
return ((DoubleVariableContextEntry) context).left == context.extractor.getFloatValue( right );
}
@@ -127,14 +127,14 @@
return object1.getFloatValue() != extractor.getFloatValue( object2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
// TODO: we are not handling delta right now... maybe we should
return context.declaration.getExtractor().getFloatValue( left ) != ((DoubleVariableContextEntry) context).right;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
// TODO: we are not handling delta right now... maybe we should
return ((DoubleVariableContextEntry) context).left != context.extractor.getFloatValue( right );
}
@@ -170,14 +170,14 @@
return object1.getFloatValue() < extractor.getFloatValue( object2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
// TODO: we are not handling delta right now... maybe we should
return context.declaration.getExtractor().getFloatValue( left ) < ((DoubleVariableContextEntry) context).right;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
// TODO: we are not handling delta right now... maybe we should
return ((DoubleVariableContextEntry) context).left < context.extractor.getFloatValue( right );
}
@@ -213,14 +213,14 @@
return object1.getFloatValue() <= extractor.getFloatValue( object2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
// TODO: we are not handling delta right now... maybe we should
return context.declaration.getExtractor().getFloatValue( left ) <= ((DoubleVariableContextEntry) context).right;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
// TODO: we are not handling delta right now... maybe we should
return ((DoubleVariableContextEntry) context).left <= context.extractor.getFloatValue( right );
}
@@ -256,14 +256,14 @@
return object1.getFloatValue() > extractor.getFloatValue( object2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
// TODO: we are not handling delta right now... maybe we should
return context.declaration.getExtractor().getFloatValue( left ) > ((DoubleVariableContextEntry) context).right;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
// TODO: we are not handling delta right now... maybe we should
return ((DoubleVariableContextEntry) context).left > context.extractor.getFloatValue( right );
}
@@ -299,14 +299,14 @@
return object1.getFloatValue() >= extractor.getFloatValue( object2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
// TODO: we are not handling delta right now... maybe we should
return context.declaration.getExtractor().getFloatValue( left ) >= ((DoubleVariableContextEntry) context).right;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
// TODO: we are not handling delta right now... maybe we should
return ((DoubleVariableContextEntry) context).left >= context.extractor.getFloatValue( right );
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/IntegerFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/IntegerFactory.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/IntegerFactory.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -28,18 +28,18 @@
implements
EvaluatorFactory {
- private static final long serialVersionUID = -6863552870087722275L;
- private static EvaluatorFactory INSTANCE = new IntegerFactory();
+ private static final long serialVersionUID = -6863552870087722275L;
+ private static EvaluatorFactory INSTANCE = new IntegerFactory();
private IntegerFactory() {
}
public static EvaluatorFactory getInstance() {
- if ( INSTANCE == null ) {
- INSTANCE = new IntegerFactory();
+ if ( IntegerFactory.INSTANCE == null ) {
+ IntegerFactory.INSTANCE = new IntegerFactory();
}
- return INSTANCE;
+ return IntegerFactory.INSTANCE;
}
public Evaluator getEvaluator(final Operator operator) {
@@ -84,13 +84,13 @@
return extractor.getIntValue( object2 ) == object1.getIntValue();
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
return context.declaration.getExtractor().getIntValue( left ) == ((LongVariableContextEntry) context).right;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object object2) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object object2) {
return context.extractor.getIntValue( object2 ) == ((LongVariableContextEntry) context).left;
}
@@ -124,13 +124,13 @@
return extractor.getIntValue( object2 ) != object1.getIntValue();
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
return context.declaration.getExtractor().getIntValue( left ) != ((LongVariableContextEntry) context).right;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object object2) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object object2) {
return context.extractor.getIntValue( object2 ) != ((LongVariableContextEntry) context).left;
}
@@ -163,13 +163,13 @@
return object1.getIntValue() < extractor.getIntValue( object2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
return context.declaration.getExtractor().getIntValue( left ) < ((LongVariableContextEntry) context).right;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
return ((LongVariableContextEntry) context).left < context.extractor.getIntValue( right );
}
@@ -202,13 +202,13 @@
return object1.getIntValue() <= extractor.getIntValue( object2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
return context.declaration.getExtractor().getIntValue( left ) <= ((LongVariableContextEntry) context).right;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
return ((LongVariableContextEntry) context).left <= context.extractor.getIntValue( right );
}
@@ -241,13 +241,13 @@
return object1.getIntValue() > extractor.getIntValue( object2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
return context.declaration.getExtractor().getIntValue( left ) > ((LongVariableContextEntry) context).right;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
return ((LongVariableContextEntry) context).left > context.extractor.getIntValue( right );
}
@@ -280,13 +280,13 @@
return object1.getIntValue() >= extractor.getIntValue( object2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
return context.declaration.getExtractor().getIntValue( left ) >= ((LongVariableContextEntry) context).right;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
return ((LongVariableContextEntry) context).left >= context.extractor.getIntValue( right );
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/LongFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/LongFactory.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/LongFactory.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -27,7 +27,7 @@
public class LongFactory
implements
EvaluatorFactory {
-
+
private static final long serialVersionUID = 4184811148799115566L;
private static EvaluatorFactory INSTANCE = new LongFactory();
@@ -36,10 +36,10 @@
}
public static EvaluatorFactory getInstance() {
- if ( INSTANCE == null ) {
- INSTANCE = new LongFactory();
+ if ( LongFactory.INSTANCE == null ) {
+ LongFactory.INSTANCE = new LongFactory();
}
- return INSTANCE;
+ return LongFactory.INSTANCE;
}
public Evaluator getEvaluator(final Operator operator) {
@@ -84,13 +84,13 @@
return object1.getLongValue() == extractor.getLongValue( object2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
return context.declaration.getExtractor().getLongValue( left ) == ((LongVariableContextEntry) context).right;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
return ((LongVariableContextEntry) context).left == context.extractor.getLongValue( right );
}
@@ -123,13 +123,13 @@
return object1.getLongValue() != extractor.getLongValue( object2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
return context.declaration.getExtractor().getLongValue( left ) != ((LongVariableContextEntry) context).right;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
return ((LongVariableContextEntry) context).left != context.extractor.getLongValue( right );
}
@@ -162,13 +162,13 @@
return object1.getLongValue() < extractor.getLongValue( object2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
return context.declaration.getExtractor().getLongValue( left ) < ((LongVariableContextEntry) context).right;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
return ((LongVariableContextEntry) context).left < context.extractor.getLongValue( right );
}
@@ -201,13 +201,13 @@
return object1.getLongValue() <= extractor.getLongValue( object2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
return context.declaration.getExtractor().getLongValue( left ) <= ((LongVariableContextEntry) context).right;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
return ((LongVariableContextEntry) context).left <= context.extractor.getLongValue( right );
}
@@ -240,13 +240,13 @@
return object1.getLongValue() > extractor.getLongValue( object2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
return context.declaration.getExtractor().getLongValue( left ) > ((LongVariableContextEntry) context).right;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
return ((LongVariableContextEntry) context).left > context.extractor.getLongValue( right );
}
@@ -279,13 +279,13 @@
return object1.getLongValue() >= extractor.getLongValue( object2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
return context.declaration.getExtractor().getLongValue( left ) >= ((LongVariableContextEntry) context).right;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
return ((LongVariableContextEntry) context).left >= context.extractor.getLongValue( right );
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/ObjectFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/ObjectFactory.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/ObjectFactory.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -41,18 +41,18 @@
implements
EvaluatorFactory {
- private static final long serialVersionUID = -8547142029512452551L;
- private static EvaluatorFactory INSTANCE = new ObjectFactory();
+ private static final long serialVersionUID = -8547142029512452551L;
+ private static EvaluatorFactory INSTANCE = new ObjectFactory();
private ObjectFactory() {
}
public static EvaluatorFactory getInstance() {
- if ( INSTANCE == null ) {
- INSTANCE = new ObjectFactory();
+ if ( ObjectFactory.INSTANCE == null ) {
+ ObjectFactory.INSTANCE = new ObjectFactory();
}
- return INSTANCE;
+ return ObjectFactory.INSTANCE;
}
public Evaluator getEvaluator(final Operator operator) {
@@ -92,8 +92,8 @@
public boolean evaluate(final Extractor extractor,
final Object object1,
final FieldValue object2) {
- Object value1 = extractor.getValue( object1 );
- Object value2 = object2.getValue();
+ final Object value1 = extractor.getValue( object1 );
+ final Object value2 = object2.getValue();
if ( value1 == null ) {
return value2 == null;
}
@@ -103,32 +103,32 @@
public boolean evaluate(final FieldValue object1,
final Extractor extractor,
final Object object2) {
- Object value1 = object1.getValue();
- Object value2 = extractor.getValue( object2 );
+ final Object value1 = object1.getValue();
+ final Object value2 = extractor.getValue( object2 );
if ( value1 == null ) {
return value2 == null;
}
return value1.equals( value2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
- Object value = context.declaration.getExtractor().getValue( left );
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
+ final Object value = context.declaration.getExtractor().getValue( left );
if ( value == null ) {
return ((ObjectVariableContextEntry) context).right == null;
}
return value.equals( ((ObjectVariableContextEntry) context).right );
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
- Object value = context.extractor.getValue( right );
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
+ final Object value = context.extractor.getValue( right );
if ( ((ObjectVariableContextEntry) context).left == null ) {
return value == null;
}
return ((ObjectVariableContextEntry) context).left.equals( value );
}
-
+
public String toString() {
return "Object ==";
}
@@ -150,8 +150,8 @@
public boolean evaluate(final Extractor extractor,
final Object object1,
final FieldValue object2) {
- Object value1 = extractor.getValue( object1 );
- Object value2 = object2.getValue();
+ final Object value1 = extractor.getValue( object1 );
+ final Object value2 = object2.getValue();
if ( value1 == null ) {
return value2 != null;
}
@@ -161,32 +161,32 @@
public boolean evaluate(final FieldValue object1,
final Extractor extractor,
final Object object2) {
- Object value1 = object1.getValue();
- Object value2 = extractor.getValue( object2 );
+ final Object value1 = object1.getValue();
+ final Object value2 = extractor.getValue( object2 );
if ( value1 == null ) {
return value2 != null;
}
return !value1.equals( value2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
- Object value = context.declaration.getExtractor().getValue( left );
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
+ final Object value = context.declaration.getExtractor().getValue( left );
if ( value == null ) {
return ((ObjectVariableContextEntry) context).right != null;
}
return !value.equals( ((ObjectVariableContextEntry) context).right );
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
- Object value = context.extractor.getValue( right );
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
+ final Object value = context.extractor.getValue( right );
if ( ((ObjectVariableContextEntry) context).left == null ) {
return value != null;
}
return !((ObjectVariableContextEntry) context).left.equals( value );
}
-
+
public String toString() {
return "Object !=";
}
@@ -215,18 +215,18 @@
return comp.compareTo( extractor.getValue( object2 ) ) < 0;
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
final Comparable comp = (Comparable) context.declaration.getExtractor().getValue( left );
return comp.compareTo( ((ObjectVariableContextEntry) context).right ) < 0;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
final Comparable comp = (Comparable) ((ObjectVariableContextEntry) context).left;
return comp.compareTo( context.extractor.getValue( right ) ) < 0;
}
-
+
public String toString() {
return "Object <";
}
@@ -258,18 +258,18 @@
return comp.compareTo( extractor.getValue( object2 ) ) <= 0;
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
final Comparable comp = (Comparable) context.declaration.getExtractor().getValue( left );
return comp.compareTo( ((ObjectVariableContextEntry) context).right ) <= 0;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
final Comparable comp = (Comparable) ((ObjectVariableContextEntry) context).left;
return comp.compareTo( context.extractor.getValue( right ) ) <= 0;
}
-
+
public String toString() {
return "Object <=";
}
@@ -301,18 +301,18 @@
return comp.compareTo( extractor.getValue( object2 ) ) >= 0;
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
final Comparable comp = (Comparable) context.declaration.getExtractor().getValue( left );
return comp.compareTo( ((ObjectVariableContextEntry) context).right ) >= 0;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
final Comparable comp = (Comparable) ((ObjectVariableContextEntry) context).left;
return comp.compareTo( context.extractor.getValue( right ) ) >= 0;
}
-
+
public String toString() {
return "Object >";
}
@@ -344,18 +344,18 @@
return comp.compareTo( extractor.getValue( object2 ) ) >= 0;
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
final Comparable comp = (Comparable) context.declaration.getExtractor().getValue( left );
return comp.compareTo( ((ObjectVariableContextEntry) context).right ) >= 0;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
final Comparable comp = (Comparable) ((ObjectVariableContextEntry) context).left;
return comp.compareTo( context.extractor.getValue( right ) ) >= 0;
}
-
+
public String toString() {
return "Object >=";
}
@@ -376,7 +376,7 @@
public boolean evaluate(final Extractor extractor,
final Object object1,
final FieldValue object2) {
- Object value = object2.getValue();
+ final Object value = object2.getValue();
final Collection col = (Collection) extractor.getValue( object1 );
return col.contains( value );
}
@@ -384,25 +384,25 @@
public boolean evaluate(final FieldValue object1,
final Extractor extractor,
final Object object2) {
- Object value = extractor.getValue( object2);
+ final Object value = extractor.getValue( object2 );
final Collection col = (Collection) object1.getValue();
return col.contains( value );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
- Object value = ((ObjectVariableContextEntry) context).right;
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
+ final Object value = ((ObjectVariableContextEntry) context).right;
final Collection col = (Collection) context.declaration.getExtractor().getValue( left );
return col.contains( value );
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
- Object value = context.extractor.getValue( right );
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
+ final Object value = context.extractor.getValue( right );
final Collection col = (Collection) ((ObjectVariableContextEntry) context).left;
return col.contains( value );
}
-
+
public String toString() {
return "Object contains";
}
@@ -423,7 +423,7 @@
public boolean evaluate(final Extractor extractor,
final Object object1,
final FieldValue object2) {
- Object value = object2.getValue();
+ final Object value = object2.getValue();
final Collection col = (Collection) extractor.getValue( object1 );
return !col.contains( value );
}
@@ -431,21 +431,21 @@
public boolean evaluate(final FieldValue object1,
final Extractor extractor,
final Object object2) {
- Object value = extractor.getValue( object2);
+ final Object value = extractor.getValue( object2 );
final Collection col = (Collection) object1.getValue();
return !col.contains( value );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
- Object value = ((ObjectVariableContextEntry) context).right;
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
+ final Object value = ((ObjectVariableContextEntry) context).right;
final Collection col = (Collection) context.declaration.getExtractor().getValue( left );
return !col.contains( value );
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
- Object value = context.extractor.getValue( right );
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
+ final Object value = context.extractor.getValue( right );
final Collection col = (Collection) ((ObjectVariableContextEntry) context).left;
return !col.contains( value );
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/Operator.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/Operator.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/Operator.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -4,67 +4,68 @@
import org.drools.RuntimeDroolsException;
-public class Operator implements Serializable {
-
- private static final long serialVersionUID = 320;
-
- public static final Operator EQUAL = new Operator( "==" );
- public static final Operator NOT_EQUAL = new Operator( "!=" );
- public static final Operator LESS = new Operator( "<" );
- public static final Operator LESS_OR_EQUAL = new Operator( "<=" );
- public static final Operator GREATER = new Operator( ">" );
+public class Operator
+ implements
+ Serializable {
+
+ private static final long serialVersionUID = 320;
+
+ public static final Operator EQUAL = new Operator( "==" );
+ public static final Operator NOT_EQUAL = new Operator( "!=" );
+ public static final Operator LESS = new Operator( "<" );
+ public static final Operator LESS_OR_EQUAL = new Operator( "<=" );
+ public static final Operator GREATER = new Operator( ">" );
public static final Operator GREATER_OR_EQUAL = new Operator( ">=" );
- public static final Operator CONTAINS = new Operator( "contains" );
- public static final Operator MATCHES = new Operator( "matches" );
- public static final Operator EXCLUDES = new Operator( "excludes" );
-
- private String operator;
-
- private Operator(String operator) {
+ public static final Operator CONTAINS = new Operator( "contains" );
+ public static final Operator MATCHES = new Operator( "matches" );
+ public static final Operator EXCLUDES = new Operator( "excludes" );
+
+ private String operator;
+
+ private Operator(final String operator) {
this.operator = operator;
}
-
- private Object readResolve () throws java.io.ObjectStreamException
- {
+
+ private Object readResolve() throws java.io.ObjectStreamException {
return determineOperator( this.operator );
- }
-
- public static Operator determineOperator(String string) {
+ }
+
+ public static Operator determineOperator(final String string) {
if ( string.equals( "==" ) ) {
- return Operator.EQUAL;
+ return Operator.EQUAL;
} else if ( string.equals( "!=" ) ) {
- return Operator.NOT_EQUAL;
+ return Operator.NOT_EQUAL;
} else if ( string.equals( "<" ) ) {
- return Operator.LESS;
+ return Operator.LESS;
} else if ( string.equals( "<=" ) ) {
- return Operator.LESS_OR_EQUAL;
+ return Operator.LESS_OR_EQUAL;
} else if ( string.equals( ">" ) ) {
- return Operator.GREATER;
+ return Operator.GREATER;
} else if ( string.equals( ">=" ) ) {
- return Operator.GREATER_OR_EQUAL;
+ return Operator.GREATER_OR_EQUAL;
} else if ( string.equals( "contains" ) ) {
- return Operator.CONTAINS;
+ return Operator.CONTAINS;
} else if ( string.equals( "matches" ) ) {
- return Operator.MATCHES;
+ return Operator.MATCHES;
} else if ( string.equals( "excludes" ) ) {
- return Operator.EXCLUDES;
- }
- throw new RuntimeDroolsException( "unable to determine operator for String [" + string + "]" );
- }
+ return Operator.EXCLUDES;
+ }
+ throw new RuntimeDroolsException( "unable to determine operator for String [" + string + "]" );
+ }
public String toString() {
return "Operator = '" + this.operator + "'";
}
-
+
public int hashCode() {
return this.operator.hashCode();
}
-
- public boolean equals(Object object) {
+
+ public boolean equals(final Object object) {
if ( object == this ) {
return true;
}
-
+
return false;
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/ShortFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/ShortFactory.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/ShortFactory.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -24,21 +24,23 @@
import org.drools.spi.Extractor;
import org.drools.spi.FieldValue;
-public class ShortFactory implements EvaluatorFactory {
+public class ShortFactory
+ implements
+ EvaluatorFactory {
- private static final long serialVersionUID = -1295210800055648796L;
- private static EvaluatorFactory INSTANCE = new ShortFactory();
-
+ private static final long serialVersionUID = -1295210800055648796L;
+ private static EvaluatorFactory INSTANCE = new ShortFactory();
+
private ShortFactory() {
-
+
}
-
+
public static EvaluatorFactory getInstance() {
- if ( INSTANCE == null ) {
- INSTANCE = new ShortFactory();
+ if ( ShortFactory.INSTANCE == null ) {
+ ShortFactory.INSTANCE = new ShortFactory();
}
- return INSTANCE;
- }
+ return ShortFactory.INSTANCE;
+ }
public Evaluator getEvaluator(final Operator operator) {
if ( operator == Operator.EQUAL ) {
@@ -53,17 +55,17 @@
return ShortGreaterEvaluator.INSTANCE;
} else if ( operator == Operator.GREATER_OR_EQUAL ) {
return ShortGreaterOrEqualEvaluator.INSTANCE;
- } else {
+ } else {
throw new RuntimeException( "Operator '" + operator + "' does not exist for ShortEvaluator" );
- }
+ }
}
-
+
static class ShortEqualEvaluator extends BaseEvaluator {
/**
*
*/
private static final long serialVersionUID = 320;
- private static Evaluator INSTANCE = new ShortEqualEvaluator();
+ private static final Evaluator INSTANCE = new ShortEqualEvaluator();
private ShortEqualEvaluator() {
super( ValueType.SHORT_TYPE,
@@ -82,13 +84,13 @@
return object1.getShortValue() == extractor.getShortValue( object2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
return context.declaration.getExtractor().getShortValue( left ) == ((LongVariableContextEntry) context).right;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
return ((LongVariableContextEntry) context).left == context.extractor.getShortValue( right );
}
@@ -102,8 +104,8 @@
*
*/
private static final long serialVersionUID = 320;
- private static Evaluator INSTANCE = new ShortNotEqualEvaluator();
-
+ private static final Evaluator INSTANCE = new ShortNotEqualEvaluator();
+
private ShortNotEqualEvaluator() {
super( ValueType.SHORT_TYPE,
Operator.NOT_EQUAL );
@@ -121,13 +123,13 @@
return object1.getShortValue() != extractor.getShortValue( object2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
return context.declaration.getExtractor().getShortValue( left ) != ((LongVariableContextEntry) context).right;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
return ((LongVariableContextEntry) context).left != context.extractor.getShortValue( right );
}
@@ -141,7 +143,7 @@
*
*/
private static final long serialVersionUID = 320;
- private static Evaluator INSTANCE = new ShortLessEvaluator();
+ private static final Evaluator INSTANCE = new ShortLessEvaluator();
private ShortLessEvaluator() {
super( ValueType.SHORT_TYPE,
@@ -160,13 +162,13 @@
return object1.getShortValue() < extractor.getShortValue( object2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
return context.declaration.getExtractor().getShortValue( left ) < ((LongVariableContextEntry) context).right;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
return ((LongVariableContextEntry) context).left < context.extractor.getShortValue( right );
}
@@ -180,7 +182,7 @@
*
*/
private static final long serialVersionUID = 320;
- private static Evaluator INSTANCE = new ShortLessOrEqualEvaluator();
+ private static final Evaluator INSTANCE = new ShortLessOrEqualEvaluator();
private ShortLessOrEqualEvaluator() {
super( ValueType.SHORT_TYPE,
@@ -199,13 +201,13 @@
return object1.getShortValue() <= extractor.getShortValue( object2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
return context.declaration.getExtractor().getShortValue( left ) <= ((LongVariableContextEntry) context).right;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
return ((LongVariableContextEntry) context).left <= context.extractor.getShortValue( right );
}
@@ -219,7 +221,7 @@
*
*/
private static final long serialVersionUID = 320;
- private static Evaluator INSTANCE = new ShortGreaterEvaluator();
+ private static final Evaluator INSTANCE = new ShortGreaterEvaluator();
private ShortGreaterEvaluator() {
super( ValueType.SHORT_TYPE,
@@ -238,13 +240,13 @@
return object1.getShortValue() > extractor.getShortValue( object2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
return context.declaration.getExtractor().getShortValue( left ) > ((LongVariableContextEntry) context).right;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
return ((LongVariableContextEntry) context).left > context.extractor.getShortValue( right );
}
@@ -258,7 +260,7 @@
*
*/
private static final long serialVersionUID = 320;
- private static Evaluator INSTANCE = new ShortGreaterOrEqualEvaluator();
+ private static final Evaluator INSTANCE = new ShortGreaterOrEqualEvaluator();
private ShortGreaterOrEqualEvaluator() {
super( ValueType.SHORT_TYPE,
@@ -277,13 +279,13 @@
return object1.getShortValue() >= extractor.getShortValue( object2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
return context.declaration.getExtractor().getShortValue( left ) >= ((LongVariableContextEntry) context).right;
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
return ((LongVariableContextEntry) context).left >= context.extractor.getShortValue( right );
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/StringFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/StringFactory.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/StringFactory.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -43,10 +43,10 @@
}
public static EvaluatorFactory getInstance() {
- if ( INSTANCE == null ) {
- INSTANCE = new StringFactory();
+ if ( StringFactory.INSTANCE == null ) {
+ StringFactory.INSTANCE = new StringFactory();
}
- return INSTANCE;
+ return StringFactory.INSTANCE;
}
public Evaluator getEvaluator(final Operator operator) {
@@ -76,8 +76,8 @@
public boolean evaluate(final Extractor extractor,
final Object object1,
final FieldValue object2) {
- Object value1 = extractor.getValue( object1 );
- Object value2 = object2.getValue();
+ final Object value1 = extractor.getValue( object1 );
+ final Object value2 = object2.getValue();
if ( value1 == null ) {
return value2 == null;
}
@@ -87,26 +87,26 @@
public boolean evaluate(final FieldValue object1,
final Extractor extractor,
final Object object2) {
- Object value1 = object1.getValue();
- Object value2 = extractor.getValue( object2 );
+ final Object value1 = object1.getValue();
+ final Object value2 = extractor.getValue( object2 );
if ( value1 == null ) {
return value2 == null;
}
return value1.equals( value2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
- Object value = context.declaration.getExtractor().getValue( left );
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
+ final Object value = context.declaration.getExtractor().getValue( left );
if ( value == null ) {
return ((ObjectVariableContextEntry) context).right == null;
}
return value.equals( ((ObjectVariableContextEntry) context).right );
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
- Object value = context.extractor.getValue( right );
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
+ final Object value = context.extractor.getValue( right );
if ( ((ObjectVariableContextEntry) context).left == null ) {
return value == null;
}
@@ -133,8 +133,8 @@
public boolean evaluate(final Extractor extractor,
final Object object1,
final FieldValue object2) {
- Object value1 = extractor.getValue( object1 );
- Object value2 = object2.getValue();
+ final Object value1 = extractor.getValue( object1 );
+ final Object value2 = object2.getValue();
if ( value1 == null ) {
return value2 != null;
}
@@ -144,26 +144,26 @@
public boolean evaluate(final FieldValue object1,
final Extractor extractor,
final Object object2) {
- Object value1 = object1.getValue();
- Object value2 = extractor.getValue( object2 );
+ final Object value1 = object1.getValue();
+ final Object value2 = extractor.getValue( object2 );
if ( value1 == null ) {
return value2 != null;
}
return !value1.equals( value2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
- Object value = context.declaration.getExtractor().getValue( left );
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
+ final Object value = context.declaration.getExtractor().getValue( left );
if ( value == null ) {
return ((ObjectVariableContextEntry) context).right != null;
}
return value.equals( ((ObjectVariableContextEntry) context).right );
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
- Object value = context.extractor.getValue( right );
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
+ final Object value = context.extractor.getValue( right );
if ( ((ObjectVariableContextEntry) context).left == null ) {
return value != null;
}
@@ -190,8 +190,8 @@
public boolean evaluate(final Extractor extractor,
final Object object1,
final FieldValue object2) {
- String value1 = (String) extractor.getValue( object1 );
- String value2 = (String) object2.getValue();
+ final String value1 = (String) extractor.getValue( object1 );
+ final String value2 = (String) object2.getValue();
if ( value1 == null ) {
return false;
}
@@ -201,29 +201,29 @@
public boolean evaluate(final FieldValue object1,
final Extractor extractor,
final Object object2) {
- String value1 = (String) object1.getValue();
- String value2 = (String) extractor.getValue( object2 );
+ final String value1 = (String) object1.getValue();
+ final String value2 = (String) extractor.getValue( object2 );
if ( value1 == null ) {
return false;
}
return value1.matches( value2 );
}
- public boolean evaluateCachedRight(VariableContextEntry context,
- Object left) {
- String value = (String) context.declaration.getExtractor().getValue( left );
+ public boolean evaluateCachedRight(final VariableContextEntry context,
+ final Object left) {
+ final String value = (String) context.declaration.getExtractor().getValue( left );
if ( value == null ) {
return false;
}
return value.matches( (String) ((ObjectVariableContextEntry) context).right );
}
- public boolean evaluateCachedLeft(VariableContextEntry context,
- Object right) {
+ public boolean evaluateCachedLeft(final VariableContextEntry context,
+ final Object right) {
if ( ((ObjectVariableContextEntry) context).left == null ) {
return false;
}
- String value = (String) context.extractor.getValue( right );
+ final String value = (String) context.extractor.getValue( right );
return ((String) ((ObjectVariableContextEntry) context).left).matches( value );
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/BaseBooleanClassFieldExtractor.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/BaseBooleanClassFieldExtractor.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/BaseBooleanClassFieldExtractor.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -28,45 +28,45 @@
public abstract class BaseBooleanClassFieldExtractor extends BaseClassFieldExtractor {
private static final long serialVersionUID = 9104214567753008212L;
-
- public BaseBooleanClassFieldExtractor(Class clazz,
- String fieldName) {
+
+ public BaseBooleanClassFieldExtractor(final Class clazz,
+ final String fieldName) {
super( clazz,
fieldName );
}
- public Object getValue(Object object) {
+ public Object getValue(final Object object) {
return getBooleanValue( object ) ? Boolean.TRUE : Boolean.FALSE;
}
public abstract boolean getBooleanValue(Object object);
- public byte getByteValue(Object object) {
- throw new RuntimeDroolsException("Conversion to byte not supported from boolean");
+ public byte getByteValue(final Object object) {
+ throw new RuntimeDroolsException( "Conversion to byte not supported from boolean" );
}
- public char getCharValue(Object object) {
- throw new RuntimeDroolsException("Conversion to char not supported from boolean");
+ public char getCharValue(final Object object) {
+ throw new RuntimeDroolsException( "Conversion to char not supported from boolean" );
}
- public double getDoubleValue(Object object) {
- throw new RuntimeDroolsException("Conversion to double not supported from boolean");
+ public double getDoubleValue(final Object object) {
+ throw new RuntimeDroolsException( "Conversion to double not supported from boolean" );
}
- public float getFloatValue(Object object) {
- throw new RuntimeDroolsException("Conversion to float not supported from boolean");
+ public float getFloatValue(final Object object) {
+ throw new RuntimeDroolsException( "Conversion to float not supported from boolean" );
}
- public int getIntValue(Object object) {
- throw new RuntimeDroolsException("Conversion to int not supported from boolean");
+ public int getIntValue(final Object object) {
+ throw new RuntimeDroolsException( "Conversion to int not supported from boolean" );
}
- public long getLongValue(Object object) {
- throw new RuntimeDroolsException("Conversion to long not supported from boolean");
+ public long getLongValue(final Object object) {
+ throw new RuntimeDroolsException( "Conversion to long not supported from boolean" );
}
- public short getShortValue(Object object) {
- throw new RuntimeDroolsException("Conversion to short not supported from boolean");
+ public short getShortValue(final Object object) {
+ throw new RuntimeDroolsException( "Conversion to short not supported from boolean" );
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/BaseByteClassFieldExtractor.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/BaseByteClassFieldExtractor.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/BaseByteClassFieldExtractor.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -28,44 +28,44 @@
public abstract class BaseByteClassFieldExtractor extends BaseClassFieldExtractor {
private static final long serialVersionUID = 2031113412868487706L;
-
- public BaseByteClassFieldExtractor(Class clazz,
- String fieldName) {
+
+ public BaseByteClassFieldExtractor(final Class clazz,
+ final String fieldName) {
super( clazz,
fieldName );
}
- public Object getValue(Object object) {
+ public Object getValue(final Object object) {
return new Long( getByteValue( object ) );
}
- public boolean getBooleanValue(Object object) {
- throw new RuntimeDroolsException("Conversion to boolean not supported from byte");
+ public boolean getBooleanValue(final Object object) {
+ throw new RuntimeDroolsException( "Conversion to boolean not supported from byte" );
}
public abstract byte getByteValue(Object object);
- public char getCharValue(Object object) {
- throw new RuntimeDroolsException("Conversion to char not supported from byte");
+ public char getCharValue(final Object object) {
+ throw new RuntimeDroolsException( "Conversion to char not supported from byte" );
}
- public double getDoubleValue(Object object) {
+ public double getDoubleValue(final Object object) {
return getByteValue( object );
}
- public float getFloatValue(Object object) {
+ public float getFloatValue(final Object object) {
return getByteValue( object );
}
- public int getIntValue(Object object) {
+ public int getIntValue(final Object object) {
return getByteValue( object );
}
- public long getLongValue(Object object) {
+ public long getLongValue(final Object object) {
return getByteValue( object );
}
- public short getShortValue(Object object) {
+ public short getShortValue(final Object object) {
return getByteValue( object );
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/BaseCharClassFieldExtractor.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/BaseCharClassFieldExtractor.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/BaseCharClassFieldExtractor.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -6,45 +6,45 @@
public abstract class BaseCharClassFieldExtractor extends BaseClassFieldExtractor {
private static final long serialVersionUID = 91214567753008212L;
-
- public BaseCharClassFieldExtractor(Class clazz,
- String fieldName) {
+
+ public BaseCharClassFieldExtractor(final Class clazz,
+ final String fieldName) {
super( clazz,
fieldName );
}
- public Object getValue(Object object) {
+ public Object getValue(final Object object) {
return new Long( getCharValue( object ) );
}
- public boolean getBooleanValue(Object object) {
- throw new RuntimeDroolsException("Conversion to boolean not supported from char");
+ public boolean getBooleanValue(final Object object) {
+ throw new RuntimeDroolsException( "Conversion to boolean not supported from char" );
}
- public byte getByteValue(Object object) {
- throw new RuntimeDroolsException("Conversion to byte not supported from char");
+ public byte getByteValue(final Object object) {
+ throw new RuntimeDroolsException( "Conversion to byte not supported from char" );
}
public abstract char getCharValue(Object object);
- public double getDoubleValue(Object object) {
- throw new RuntimeDroolsException("Conversion to double not supported from char");
+ public double getDoubleValue(final Object object) {
+ throw new RuntimeDroolsException( "Conversion to double not supported from char" );
}
- public float getFloatValue(Object object) {
- throw new RuntimeDroolsException("Conversion to float not supported from char");
+ public float getFloatValue(final Object object) {
+ throw new RuntimeDroolsException( "Conversion to float not supported from char" );
}
- public int getIntValue(Object object) {
- throw new RuntimeDroolsException("Conversion to int not supported from char");
+ public int getIntValue(final Object object) {
+ throw new RuntimeDroolsException( "Conversion to int not supported from char" );
}
- public long getLongValue(Object object) {
- throw new RuntimeDroolsException("Conversion to long not supported from char");
+ public long getLongValue(final Object object) {
+ throw new RuntimeDroolsException( "Conversion to long not supported from char" );
}
- public short getShortValue(Object object) {
- throw new RuntimeDroolsException("Conversion to short not supported from char");
+ public short getShortValue(final Object object) {
+ throw new RuntimeDroolsException( "Conversion to short not supported from char" );
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/BaseDoubleClassFieldExtractor.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/BaseDoubleClassFieldExtractor.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/BaseDoubleClassFieldExtractor.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -6,45 +6,45 @@
public abstract class BaseDoubleClassFieldExtractor extends BaseClassFieldExtractor {
private static final long serialVersionUID = 20311112843487706L;
-
- public BaseDoubleClassFieldExtractor(Class clazz,
- String fieldName) {
+
+ public BaseDoubleClassFieldExtractor(final Class clazz,
+ final String fieldName) {
super( clazz,
fieldName );
}
- public Object getValue(Object object) {
+ public Object getValue(final Object object) {
return new Double( getDoubleValue( object ) );
}
- public boolean getBooleanValue(Object object) {
- throw new RuntimeDroolsException("Conversion to boolean not supported from double");
+ public boolean getBooleanValue(final Object object) {
+ throw new RuntimeDroolsException( "Conversion to boolean not supported from double" );
}
- public byte getByteValue(Object object) {
+ public byte getByteValue(final Object object) {
return (byte) getDoubleValue( object );
-
+
}
- public char getCharValue(Object object) {
- throw new RuntimeDroolsException("Conversion to char not supported from double");
+ public char getCharValue(final Object object) {
+ throw new RuntimeDroolsException( "Conversion to char not supported from double" );
}
public abstract double getDoubleValue(Object object);
- public float getFloatValue(Object object) {
+ public float getFloatValue(final Object object) {
return (float) getDoubleValue( object );
}
- public int getIntValue(Object object) {
+ public int getIntValue(final Object object) {
return (int) getDoubleValue( object );
}
- public long getLongValue(Object object) {
+ public long getLongValue(final Object object) {
return (long) getDoubleValue( object );
}
- public short getShortValue(Object object) {
+ public short getShortValue(final Object object) {
return (short) getDoubleValue( object );
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/BaseFloatClassFieldExtractor.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/BaseFloatClassFieldExtractor.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/BaseFloatClassFieldExtractor.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -6,45 +6,45 @@
public abstract class BaseFloatClassFieldExtractor extends BaseClassFieldExtractor {
private static final long serialVersionUID = 20311112843487706L;
-
- public BaseFloatClassFieldExtractor(Class clazz,
- String fieldName) {
+
+ public BaseFloatClassFieldExtractor(final Class clazz,
+ final String fieldName) {
super( clazz,
fieldName );
}
- public Object getValue(Object object) {
+ public Object getValue(final Object object) {
return new Float( getFloatValue( object ) );
}
- public boolean getBooleanValue(Object object) {
- throw new RuntimeDroolsException("Conversion to boolean not supported from float");
+ public boolean getBooleanValue(final Object object) {
+ throw new RuntimeDroolsException( "Conversion to boolean not supported from float" );
}
- public byte getByteValue(Object object) {
+ public byte getByteValue(final Object object) {
return (byte) getFloatValue( object );
-
+
}
- public char getCharValue(Object object) {
- throw new RuntimeDroolsException("Conversion to char not supported from float");
+ public char getCharValue(final Object object) {
+ throw new RuntimeDroolsException( "Conversion to char not supported from float" );
}
- public double getDoubleValue(Object object) {
+ public double getDoubleValue(final Object object) {
return getFloatValue( object );
}
public abstract float getFloatValue(Object object);
- public int getIntValue(Object object) {
+ public int getIntValue(final Object object) {
return (int) getFloatValue( object );
}
- public long getLongValue(Object object) {
+ public long getLongValue(final Object object) {
return (long) getFloatValue( object );
}
- public short getShortValue(Object object) {
+ public short getShortValue(final Object object) {
return (short) getFloatValue( object );
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/BaseIntClassFieldExtractor.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/BaseIntClassFieldExtractor.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/BaseIntClassFieldExtractor.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -5,47 +5,46 @@
public abstract class BaseIntClassFieldExtractor extends BaseClassFieldExtractor {
-
private static final long serialVersionUID = 203112843487706L;
-
- public BaseIntClassFieldExtractor(Class clazz,
- String fieldName) {
+
+ public BaseIntClassFieldExtractor(final Class clazz,
+ final String fieldName) {
super( clazz,
fieldName );
}
- public Object getValue(Object object) {
+ public Object getValue(final Object object) {
return new Long( getIntValue( object ) );
}
- public boolean getBooleanValue(Object object) {
- throw new RuntimeDroolsException("Conversion to boolean not supported from int");
+ public boolean getBooleanValue(final Object object) {
+ throw new RuntimeDroolsException( "Conversion to boolean not supported from int" );
}
- public byte getByteValue(Object object) {
+ public byte getByteValue(final Object object) {
return (byte) getIntValue( object );
-
+
}
- public char getCharValue(Object object) {
- throw new RuntimeDroolsException("Conversion to char not supported from int");
+ public char getCharValue(final Object object) {
+ throw new RuntimeDroolsException( "Conversion to char not supported from int" );
}
- public double getDoubleValue(Object object) {
+ public double getDoubleValue(final Object object) {
return getIntValue( object );
}
- public float getFloatValue(Object object) {
+ public float getFloatValue(final Object object) {
return getIntValue( object );
}
public abstract int getIntValue(Object object);
- public long getLongValue(Object object) {
+ public long getLongValue(final Object object) {
return getIntValue( object );
}
- public short getShortValue(Object object) {
+ public short getShortValue(final Object object) {
return (short) getIntValue( object );
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/BaseLongClassFieldExtractors.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/BaseLongClassFieldExtractors.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/BaseLongClassFieldExtractors.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -6,45 +6,45 @@
public abstract class BaseLongClassFieldExtractors extends BaseClassFieldExtractor {
private static final long serialVersionUID = 2031113412843487706L;
-
- public BaseLongClassFieldExtractors(Class clazz,
- String fieldName) {
+
+ public BaseLongClassFieldExtractors(final Class clazz,
+ final String fieldName) {
super( clazz,
fieldName );
}
- public Object getValue(Object object) {
+ public Object getValue(final Object object) {
return new Long( getLongValue( object ) );
}
- public boolean getBooleanValue(Object object) {
- throw new RuntimeDroolsException("Conversion to boolean not supported from long");
+ public boolean getBooleanValue(final Object object) {
+ throw new RuntimeDroolsException( "Conversion to boolean not supported from long" );
}
- public byte getByteValue(Object object) {
+ public byte getByteValue(final Object object) {
return (byte) getLongValue( object );
-
+
}
- public char getCharValue(Object object) {
- throw new RuntimeDroolsException("Conversion to char not supported from long");
+ public char getCharValue(final Object object) {
+ throw new RuntimeDroolsException( "Conversion to char not supported from long" );
}
- public double getDoubleValue(Object object) {
+ public double getDoubleValue(final Object object) {
return getLongValue( object );
}
- public float getFloatValue(Object object) {
+ public float getFloatValue(final Object object) {
return getLongValue( object );
}
- public int getIntValue(Object object) {
+ public int getIntValue(final Object object) {
return (int) getLongValue( object );
}
public abstract long getLongValue(Object object);
- public short getShortValue(Object object) {
+ public short getShortValue(final Object object) {
return (short) getLongValue( object );
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/BaseObjectClassFieldExtractor.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/BaseObjectClassFieldExtractor.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/BaseObjectClassFieldExtractor.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -6,93 +6,93 @@
public abstract class BaseObjectClassFieldExtractor extends BaseClassFieldExtractor {
private static final long serialVersionUID = 91214567753008212L;
-
- public BaseObjectClassFieldExtractor(Class clazz,
- String fieldName) {
+
+ public BaseObjectClassFieldExtractor(final Class clazz,
+ final String fieldName) {
super( clazz,
fieldName );
}
public abstract Object getValue(Object object);
- public boolean getBooleanValue(Object object) {
+ public boolean getBooleanValue(final Object object) {
// this can be improved by generating specific
// bytecode generation in the subclass, avoiding the if instanceof
- Object value = getValue( object );
- if( value instanceof Boolean ) {
+ final Object value = getValue( object );
+ if ( value instanceof Boolean ) {
return ((Boolean) value).booleanValue();
}
- throw new RuntimeDroolsException("Conversion to boolean not supported from "+value.getClass().getName());
+ throw new RuntimeDroolsException( "Conversion to boolean not supported from " + value.getClass().getName() );
}
- public byte getByteValue(Object object) {
+ public byte getByteValue(final Object object) {
// this can be improved by generating specific
// bytecode generation in the subclass, avoiding the if instanceof
- Object value = getValue( object );
- if( value instanceof Number ) {
+ final Object value = getValue( object );
+ if ( value instanceof Number ) {
return ((Number) value).byteValue();
}
- throw new RuntimeDroolsException("Conversion to byte not supported from "+value.getClass().getName());
+ throw new RuntimeDroolsException( "Conversion to byte not supported from " + value.getClass().getName() );
}
- public char getCharValue(Object object) {
+ public char getCharValue(final Object object) {
// this can be improved by generating specific
// bytecode generation in the subclass, avoiding the if instanceof
- Object value = getValue( object );
- if( value instanceof Character ) {
+ final Object value = getValue( object );
+ if ( value instanceof Character ) {
return ((Character) value).charValue();
}
- throw new RuntimeDroolsException("Conversion to char not supported from "+value.getClass().getName());
+ throw new RuntimeDroolsException( "Conversion to char not supported from " + value.getClass().getName() );
}
- public double getDoubleValue(Object object) {
+ public double getDoubleValue(final Object object) {
// this can be improved by generating specific
// bytecode generation in the subclass, avoiding the if instanceof
- Object value = getValue( object );
- if( value instanceof Number ) {
+ final Object value = getValue( object );
+ if ( value instanceof Number ) {
return ((Number) value).doubleValue();
}
- throw new RuntimeDroolsException("Conversion to double not supported from "+value.getClass().getName());
+ throw new RuntimeDroolsException( "Conversion to double not supported from " + value.getClass().getName() );
}
- public float getFloatValue(Object object) {
+ public float getFloatValue(final Object object) {
// this can be improved by generating specific
// bytecode generation in the subclass, avoiding the if instanceof
- Object value = getValue( object );
- if( value instanceof Number ) {
+ final Object value = getValue( object );
+ if ( value instanceof Number ) {
return ((Number) value).floatValue();
}
- throw new RuntimeDroolsException("Conversion to float not supported from "+value.getClass().getName());
+ throw new RuntimeDroolsException( "Conversion to float not supported from " + value.getClass().getName() );
}
- public int getIntValue(Object object) {
+ public int getIntValue(final Object object) {
// this can be improved by generating specific
// bytecode generation in the subclass, avoiding the if instanceof
- Object value = getValue( object );
- if( value instanceof Number ) {
+ final Object value = getValue( object );
+ if ( value instanceof Number ) {
return ((Number) value).intValue();
}
- throw new RuntimeDroolsException("Conversion to int not supported from "+value.getClass().getName());
+ throw new RuntimeDroolsException( "Conversion to int not supported from " + value.getClass().getName() );
}
- public long getLongValue(Object object) {
+ public long getLongValue(final Object object) {
// this can be improved by generating specific
// bytecode generation in the subclass, avoiding the if instanceof
- Object value = getValue( object );
- if( value instanceof Number ) {
+ final Object value = getValue( object );
+ if ( value instanceof Number ) {
return ((Number) value).longValue();
}
- throw new RuntimeDroolsException("Conversion to long not supported from "+value.getClass().getName());
+ throw new RuntimeDroolsException( "Conversion to long not supported from " + value.getClass().getName() );
}
- public short getShortValue(Object object) {
+ public short getShortValue(final Object object) {
// this can be improved by generating specific
// bytecode generation in the subclass, avoiding the if instanceof
- Object value = getValue( object );
- if( value instanceof Number ) {
+ final Object value = getValue( object );
+ if ( value instanceof Number ) {
return ((Number) value).shortValue();
}
- throw new RuntimeDroolsException("Conversion to short not supported from "+value.getClass().getName());
+ throw new RuntimeDroolsException( "Conversion to short not supported from " + value.getClass().getName() );
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/BaseShortClassFieldExtractor.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/BaseShortClassFieldExtractor.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/BaseShortClassFieldExtractor.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -6,43 +6,43 @@
public abstract class BaseShortClassFieldExtractor extends BaseClassFieldExtractor {
private static final long serialVersionUID = 2031113412843487706L;
-
- public BaseShortClassFieldExtractor(Class clazz,
- String fieldName) {
+
+ public BaseShortClassFieldExtractor(final Class clazz,
+ final String fieldName) {
super( clazz,
fieldName );
}
- public Object getValue(Object object) {
+ public Object getValue(final Object object) {
return new Long( getShortValue( object ) );
}
- public boolean getBooleanValue(Object object) {
- throw new RuntimeDroolsException("Conversion to boolean not supported from short");
+ public boolean getBooleanValue(final Object object) {
+ throw new RuntimeDroolsException( "Conversion to boolean not supported from short" );
}
- public byte getByteValue(Object object) {
+ public byte getByteValue(final Object object) {
return (byte) getShortValue( object );
-
+
}
- public char getCharValue(Object object) {
- throw new RuntimeDroolsException("Conversion to char not supported from short");
+ public char getCharValue(final Object object) {
+ throw new RuntimeDroolsException( "Conversion to char not supported from short" );
}
- public double getDoubleValue(Object object) {
+ public double getDoubleValue(final Object object) {
return getShortValue( object );
}
- public float getFloatValue(Object object) {
+ public float getFloatValue(final Object object) {
return getShortValue( object );
}
- public int getIntValue(Object object) {
+ public int getIntValue(final Object object) {
return getShortValue( object );
}
- public long getLongValue(Object object) {
+ public long getLongValue(final Object object) {
return getShortValue( object );
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/field/BooleanFieldImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/field/BooleanFieldImpl.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/field/BooleanFieldImpl.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -47,31 +47,31 @@
}
public byte getByteValue() {
- throw new RuntimeDroolsException( "Conversion to byte not supported for type boolean");
+ throw new RuntimeDroolsException( "Conversion to byte not supported for type boolean" );
}
public char getCharValue() {
- throw new RuntimeDroolsException( "Conversion to char not supported for type boolean");
+ throw new RuntimeDroolsException( "Conversion to char not supported for type boolean" );
}
public double getDoubleValue() {
- throw new RuntimeDroolsException( "Conversion to double not supported for type boolean");
+ throw new RuntimeDroolsException( "Conversion to double not supported for type boolean" );
}
public float getFloatValue() {
- throw new RuntimeDroolsException( "Conversion to float not supported for type boolean");
+ throw new RuntimeDroolsException( "Conversion to float not supported for type boolean" );
}
public int getIntValue() {
- throw new RuntimeDroolsException( "Conversion to int not supported for type boolean");
+ throw new RuntimeDroolsException( "Conversion to int not supported for type boolean" );
}
public long getLongValue() {
- throw new RuntimeDroolsException( "Conversion to long not supported for type boolean");
+ throw new RuntimeDroolsException( "Conversion to long not supported for type boolean" );
}
public short getShortValue() {
- throw new RuntimeDroolsException( "Conversion to short not supported for type boolean");
+ throw new RuntimeDroolsException( "Conversion to short not supported for type boolean" );
}
public boolean equals(final Object object) {
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/field/DoubleFieldImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/field/DoubleFieldImpl.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/field/DoubleFieldImpl.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -8,14 +8,14 @@
FieldValue {
private static final long serialVersionUID = 320;
- private double value;
+ private double value;
public DoubleFieldImpl(final double value) {
this.value = value;
}
public Object getValue() {
- return new Double(this.value);
+ return new Double( this.value );
}
public String toString() {
@@ -23,7 +23,7 @@
}
public boolean getBooleanValue() {
- throw new RuntimeDroolsException( "Conversion to boolean not supported for type double");
+ throw new RuntimeDroolsException( "Conversion to boolean not supported for type double" );
}
public byte getByteValue() {
@@ -35,7 +35,7 @@
}
public double getDoubleValue() {
- return (double) this.value;
+ return this.value;
}
public float getFloatValue() {
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/field/LongFieldImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/field/LongFieldImpl.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/field/LongFieldImpl.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -15,7 +15,7 @@
}
public Object getValue() {
- return new Long(this.value);
+ return new Long( this.value );
}
public String toString() {
@@ -23,7 +23,7 @@
}
public boolean getBooleanValue() {
- throw new RuntimeDroolsException( "Conversion to boolean not supported for type long");
+ throw new RuntimeDroolsException( "Conversion to boolean not supported for type long" );
}
public byte getByteValue() {
@@ -35,11 +35,11 @@
}
public double getDoubleValue() {
- return (double) this.value;
+ return this.value;
}
public float getFloatValue() {
- return (float) this.value;
+ return this.value;
}
public int getIntValue() {
@@ -47,7 +47,7 @@
}
public long getLongValue() {
- return (long) this.value;
+ return this.value;
}
public short getShortValue() {
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/field/ObjectFieldImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/field/ObjectFieldImpl.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/field/ObjectFieldImpl.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -39,61 +39,61 @@
}
public boolean getBooleanValue() {
- if( this.value instanceof Boolean ) {
- return ((Boolean)this.value).booleanValue();
+ if ( this.value instanceof Boolean ) {
+ return ((Boolean) this.value).booleanValue();
}
- throw new RuntimeDroolsException("Conversion to boolean not supported for type: "+this.value.getClass());
+ throw new RuntimeDroolsException( "Conversion to boolean not supported for type: " + this.value.getClass() );
}
public byte getByteValue() {
- if( this.value instanceof Number ) {
- return ((Number)this.value).byteValue();
+ if ( this.value instanceof Number ) {
+ return ((Number) this.value).byteValue();
}
- throw new RuntimeDroolsException("Conversion to byte not supported for type: "+this.value.getClass());
+ throw new RuntimeDroolsException( "Conversion to byte not supported for type: " + this.value.getClass() );
}
public char getCharValue() {
- if( this.value instanceof Character ) {
- return ((Character)this.value).charValue();
+ if ( this.value instanceof Character ) {
+ return ((Character) this.value).charValue();
}
- throw new RuntimeDroolsException("Conversion to char not supported for type: "+this.value.getClass());
+ throw new RuntimeDroolsException( "Conversion to char not supported for type: " + this.value.getClass() );
}
public double getDoubleValue() {
- if( this.value instanceof Number ) {
- return ((Number)this.value).doubleValue();
+ if ( this.value instanceof Number ) {
+ return ((Number) this.value).doubleValue();
}
- throw new RuntimeDroolsException("Conversion to double not supported for type: "+this.value.getClass());
+ throw new RuntimeDroolsException( "Conversion to double not supported for type: " + this.value.getClass() );
}
public float getFloatValue() {
- if( this.value instanceof Number ) {
- return ((Number)this.value).floatValue();
+ if ( this.value instanceof Number ) {
+ return ((Number) this.value).floatValue();
}
- throw new RuntimeDroolsException("Conversion to float not supported for type: "+this.value.getClass());
+ throw new RuntimeDroolsException( "Conversion to float not supported for type: " + this.value.getClass() );
}
public int getIntValue() {
- if( this.value instanceof Number ) {
- return ((Number)this.value).intValue();
+ if ( this.value instanceof Number ) {
+ return ((Number) this.value).intValue();
}
- throw new RuntimeDroolsException("Conversion to int not supported for type: "+this.value.getClass());
+ throw new RuntimeDroolsException( "Conversion to int not supported for type: " + this.value.getClass() );
}
public long getLongValue() {
- if( this.value instanceof Number ) {
- return ((Number)this.value).longValue();
+ if ( this.value instanceof Number ) {
+ return ((Number) this.value).longValue();
}
- throw new RuntimeDroolsException("Conversion to long not supported for type: "+this.value.getClass());
+ throw new RuntimeDroolsException( "Conversion to long not supported for type: " + this.value.getClass() );
}
public short getShortValue() {
- if( this.value instanceof Number ) {
- return ((Number)this.value).shortValue();
+ if ( this.value instanceof Number ) {
+ return ((Number) this.value).shortValue();
}
- throw new RuntimeDroolsException("Conversion to short not supported for type: "+this.value.getClass());
+ throw new RuntimeDroolsException( "Conversion to short not supported for type: " + this.value.getClass() );
}
-
+
public boolean equals(final Object object) {
if ( this == object ) {
return true;
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/resolvers/DeclarationVariable.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/resolvers/DeclarationVariable.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/resolvers/DeclarationVariable.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -12,35 +12,35 @@
ValueHandler {
private static final long serialVersionUID = 320L;
-
- private Declaration declaration;
-
- private Object cachedValue = ValueHandler.EMPTY;
+ private Declaration declaration;
+
+ private Object cachedValue = ValueHandler.EMPTY;
+
public DeclarationVariable(final Declaration dec) {
this.declaration = dec;
}
public Object getValue(final Tuple tuple,
final WorkingMemory wm) {
- if ( cachedValue == ValueHandler.EMPTY ) {
- this.cachedValue = tuple.get( this.declaration ).getObject();
+ if ( this.cachedValue == ValueHandler.EMPTY ) {
+ this.cachedValue = tuple.get( this.declaration ).getObject();
}
- return this.cachedValue;
+ return this.cachedValue;
}
-
+
public Declaration getDeclaration() {
return this.declaration;
}
-
+
public Class getExtractToClass() {
return this.declaration.getExtractor().getExtractToClass();
}
-
+
public void reset() {
this.cachedValue = ValueHandler.EMPTY;
}
-
+
public String toString() {
return "[DeclarationVariable " + this.declaration + "]";
}
@@ -52,22 +52,18 @@
return result;
}
- public boolean equals(Object object) {
+ public boolean equals(final Object object) {
if ( this == object ) {
return true;
}
-
+
if ( object == null || getClass() != object.getClass() ) {
return false;
}
-
+
final DeclarationVariable other = (DeclarationVariable) object;
-
+
return this.declaration.equals( other.declaration );
}
-
-
-
-
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/resolvers/GlobalVariable.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/resolvers/GlobalVariable.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/resolvers/GlobalVariable.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -12,13 +12,13 @@
private static final long serialVersionUID = 320L;
- public final String globalName;
- public final Class clazz;
-
-
- private Object cachedValue = ValueHandler.EMPTY;
+ public final String globalName;
+ public final Class clazz;
- public GlobalVariable(final String name, final Class clazz) {
+ private Object cachedValue = ValueHandler.EMPTY;
+
+ public GlobalVariable(final String name,
+ final Class clazz) {
this.globalName = name;
this.clazz = clazz;
}
@@ -30,15 +30,15 @@
}
return this.cachedValue;
}
-
+
public Class getExtractToClass() {
return this.clazz;
- }
-
+ }
+
public void reset() {
this.cachedValue = ValueHandler.EMPTY;
- }
-
+ }
+
public String toString() {
return "[GlobalVariable name=" + this.globalName + "]";
}
@@ -50,14 +50,14 @@
return result;
}
- public boolean equals(Object object) {
+ public boolean equals(final Object object) {
if ( this == object ) {
return true;
}
if ( object == null || getClass() != object.getClass() ) {
return false;
}
-
+
final GlobalVariable other = (GlobalVariable) object;
return this.globalName.equals( other.globalName );
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/resolvers/ListValue.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/resolvers/ListValue.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/resolvers/ListValue.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -13,40 +13,40 @@
public class ListValue
implements
ValueHandler {
-
+
private static final long serialVersionUID = 320L;
- private final List list;
-
- private Object cachedValue = ValueHandler.EMPTY;
+ private final List list;
+ private Object cachedValue = ValueHandler.EMPTY;
+
public ListValue(final List list) {
this.list = list;
}
public Object getValue(final Tuple tuple,
final WorkingMemory wm) {
- if ( this.cachedValue == ValueHandler.EMPTY ) {
+ if ( this.cachedValue == ValueHandler.EMPTY ) {
final List resolvedList = new ArrayList( this.list.size() );
-
+
for ( final Iterator it = this.list.iterator(); it.hasNext(); ) {
resolvedList.add( ((ValueHandler) it.next()).getValue( tuple,
wm ) );
}
-
+
this.cachedValue = resolvedList;
}
return this.cachedValue;
}
-
+
public Class getExtractToClass() {
return List.class;
- }
-
+ }
+
public void reset() {
this.cachedValue = ValueHandler.EMPTY;
}
-
+
public String toString() {
return "[ListValue list=" + this.list + "]";
}
@@ -58,17 +58,17 @@
return result;
}
- public boolean equals(Object object) {
+ public boolean equals(final Object object) {
if ( this == object ) {
return true;
}
-
- if ( object == null || getClass() != object.getClass()) {
+
+ if ( object == null || getClass() != object.getClass() ) {
return false;
}
-
+
final ListValue other = (ListValue) object;
return this.list.equals( other.list );
}
-
+
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/resolvers/LiteralValue.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/resolvers/LiteralValue.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/resolvers/LiteralValue.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -3,18 +3,16 @@
*/
package org.drools.base.resolvers;
-import java.util.List;
-
import org.drools.WorkingMemory;
import org.drools.spi.Tuple;
public class LiteralValue
implements
ValueHandler {
-
+
private static final long serialVersionUID = 320L;
- private final Object value;
+ private final Object value;
public LiteralValue(final Object value) {
this.value = value;
@@ -24,15 +22,15 @@
final WorkingMemory wm) {
return this.value;
}
-
+
public Class getExtractToClass() {
return this.value.getClass();
- }
-
+ }
+
public void reset() {
// N/A
- }
-
+ }
+
public String toString() {
return "LiteralValue value=[" + this.value + "]";
}
@@ -44,17 +42,15 @@
return result;
}
- public boolean equals(Object object) {
+ public boolean equals(final Object object) {
if ( this == object ) {
return true;
}
- if ( object == null || getClass() != object.getClass()) {
+ if ( object == null || getClass() != object.getClass() ) {
return false;
}
final LiteralValue other = (LiteralValue) object;
return this.value.equals( other.value );
}
-
-
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/resolvers/MapValue.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/resolvers/MapValue.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/resolvers/MapValue.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -5,7 +5,6 @@
import java.io.Serializable;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import org.drools.WorkingMemory;
@@ -14,22 +13,22 @@
public class MapValue
implements
ValueHandler {
-
- private static final long serialVersionUID = 320L;
+ private static final long serialVersionUID = 320L;
+
private final KeyValuePair[] pairs;
-
- private Object cachedValue = ValueHandler.EMPTY;
+ private Object cachedValue = ValueHandler.EMPTY;
+
public MapValue(final KeyValuePair[] pairs) {
this.pairs = pairs;
}
public Object getValue(final Tuple tuple,
final WorkingMemory wm) {
- if ( this.cachedValue == ValueHandler.EMPTY ) {
+ if ( this.cachedValue == ValueHandler.EMPTY ) {
final Map map = new HashMap();
-
+
for ( int i = 0, length = this.pairs.length; i < length; i++ ) {
final ValueHandler key = this.pairs[i].getKey();
final ValueHandler value = this.pairs[i].getValue();
@@ -43,21 +42,23 @@
return this.cachedValue;
}
-
+
public Class getExtractToClass() {
return Map.class;
- }
+ }
public void reset() {
this.cachedValue = ValueHandler.EMPTY;
- }
-
- public static class KeyValuePair implements Serializable {
+ }
+
+ public static class KeyValuePair
+ implements
+ Serializable {
private static final long serialVersionUID = 320L;
-
- private ValueHandler key;
- private ValueHandler value;
+ private ValueHandler key;
+ private ValueHandler value;
+
public KeyValuePair(final ValueHandler key,
final ValueHandler value) {
this.key = key;
@@ -79,7 +80,7 @@
public ValueHandler getValue() {
return this.value;
}
-
+
public String toString() {
return this.key + "/" + this.value;
}
@@ -90,31 +91,30 @@
result = PRIME * result + this.key.hashCode();
result = PRIME * result + this.value.hashCode();
return result;
- }
+ }
- public boolean equals(Object object) {
+ public boolean equals(final Object object) {
if ( this == object ) {
return true;
}
-
- if ( object == null || getClass() != object.getClass() ) {
+
+ if ( object == null || getClass() != object.getClass() ) {
return false;
}
final KeyValuePair other = (KeyValuePair) object;
return this.key.equals( other.key ) && this.value.equals( other.value );
- }
+ }
}
-
+
public String toString() {
- StringBuffer buffer = new StringBuffer();
+ final StringBuffer buffer = new StringBuffer();
buffer.append( "MapValue pairs=" );
for ( int i = 0, length = this.pairs.length; i < length; i++ ) {
- buffer.append( this.pairs[i] );
+ buffer.append( this.pairs[i] );
}
buffer.append( "]" );
-
+
return buffer.toString();
}
-
-
+
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/resolvers/ValueHandler.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/resolvers/ValueHandler.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/resolvers/ValueHandler.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -13,7 +13,7 @@
Serializable {
public static final Object EMPTY = new Serializable() {
- };
+ };
/**
* Returns a value resolved. Declarations are resolved from the tuple, globals from the working memory and literals are just returned as is.
@@ -25,9 +25,9 @@
*/
public Object getValue(Tuple tuple,
WorkingMemory wm);
-
- public Class getExtractToClass() ;
+ public Class getExtractToClass();
+
/**
* NULL the cached value
*
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractRuleBase.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractRuleBase.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractRuleBase.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -84,11 +84,10 @@
/** Special value when adding to the underlying map. */
protected static final Object PRESENT = new Object();
-
/**
* Default constructor - for Externalizable. This should never be used by a user, as it
* will result in an invalid state for the instance.
- */
+ */
public AbstractRuleBase() {
}
@@ -301,7 +300,6 @@
final Package newPkg) throws PackageIntegrationException {
final Map globals = pkg.getGlobals();
final List imports = pkg.getImports();
-
// First update the binary files
// @todo: this probably has issues if you add classes in the incorrect order - functions, rules, invokers.
@@ -329,13 +327,13 @@
}
}
globals.putAll( newPkg.getGlobals() );
-
+
//Add rules into the RuleBase package
//as this is needed for individual rule removal later on
- Rule[] newRules = newPkg.getRules();
+ final Rule[] newRules = newPkg.getRules();
for ( int i = 0; i < newRules.length; i++ ) {
- Rule newRule = newRules[i];
- if (pkg.getRule( newRule.getName() ) == null) {
+ final Rule newRule = newRules[i];
+ if ( pkg.getRule( newRule.getName() ) == null ) {
pkg.addRule( newRule );
}
}
@@ -429,20 +427,20 @@
return this.config;
}
- public WorkingMemory newWorkingMemory(InputStream stream) throws IOException,
+ public WorkingMemory newWorkingMemory(final InputStream stream) throws IOException,
ClassNotFoundException {
return newWorkingMemory( stream,
true );
}
- public WorkingMemory newWorkingMemory(InputStream stream,
- boolean keepReference) throws IOException,
+ public WorkingMemory newWorkingMemory(final InputStream stream,
+ final boolean keepReference) throws IOException,
ClassNotFoundException {
final ObjectInputStreamWithLoader streamWithLoader = new ObjectInputStreamWithLoader( stream,
this.packageClassLoader );
- AbstractWorkingMemory workingMemory = (AbstractWorkingMemory) streamWithLoader.readObject();
+ final AbstractWorkingMemory workingMemory = (AbstractWorkingMemory) streamWithLoader.readObject();
workingMemory.setRuleBase( this );
return workingMemory;
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -143,7 +143,7 @@
final RuleBaseConfiguration conf = this.ruleBase.getConfiguration();
this.assertMap = new ObjectHashMap();
-
+
if ( RuleBaseConfiguration.WM_BEHAVIOR_IDENTITY.equals( conf.getProperty( RuleBaseConfiguration.PROPERTY_ASSERT_BEHAVIOR ) ) ) {
this.assertMap.setComparator( new IdentityAssertMapComparator( this.handleFactory.getFactHandleType() ) );
} else {
@@ -163,61 +163,61 @@
// Instance methods
// ------------------------------------------------------------
- void setRuleBase(InternalRuleBase ruleBase) {
+ void setRuleBase(final InternalRuleBase ruleBase) {
this.ruleBase = ruleBase;
}
public void addEventListener(final WorkingMemoryEventListener listener) {
try {
- lock.lock();
+ this.lock.lock();
this.workingMemoryEventSupport.addEventListener( listener );
} finally {
- lock.unlock();
+ this.lock.unlock();
}
}
public void removeEventListener(final WorkingMemoryEventListener listener) {
try {
- lock.lock();
+ this.lock.lock();
this.workingMemoryEventSupport.removeEventListener( listener );
} finally {
- lock.unlock();
+ this.lock.unlock();
}
}
public List getWorkingMemoryEventListeners() {
try {
- lock.lock();
+ this.lock.lock();
return this.workingMemoryEventSupport.getEventListeners();
} finally {
- lock.unlock();
+ this.lock.unlock();
}
}
public void addEventListener(final AgendaEventListener listener) {
try {
- lock.lock();
+ this.lock.lock();
this.agendaEventSupport.addEventListener( listener );
} finally {
- lock.unlock();
+ this.lock.unlock();
}
}
public void removeEventListener(final AgendaEventListener listener) {
try {
- lock.lock();
+ this.lock.lock();
this.agendaEventSupport.removeEventListener( listener );
} finally {
- lock.unlock();
+ this.lock.unlock();
}
}
public List getAgendaEventListeners() {
try {
- lock.lock();
+ this.lock.lock();
return this.agendaEventSupport.getEventListeners();
} finally {
- lock.unlock();
+ this.lock.unlock();
}
}
@@ -230,10 +230,10 @@
*/
public Map getGlobals() {
try {
- lock.lock();
+ this.lock.lock();
return this.globals;
} finally {
- lock.unlock();
+ this.lock.unlock();
}
}
@@ -241,14 +241,14 @@
* @see WorkingMemory
*/
public void setGlobal(final String name,
- Object value) {
+ final Object value) {
// Cannot set null values
if ( value == null ) {
return;
}
try {
- lock.lock();
+ this.lock.lock();
// Make sure the global has been declared in the RuleBase
final Map globalDefintions = this.ruleBase.getGlobals();
final Class type = (Class) globalDefintions.get( name );
@@ -262,11 +262,11 @@
value );
}
} finally {
- lock.unlock();
+ this.lock.unlock();
}
}
- public void setGlobalResolver(GlobalResolver globalResolver) {
+ public void setGlobalResolver(final GlobalResolver globalResolver) {
this.globalResolver = globalResolver;
}
@@ -279,14 +279,14 @@
*/
public Object getGlobal(final String name) {
try {
- lock.lock();
+ this.lock.lock();
Object object = this.globals.get( name );
if ( object == null && this.globalResolver != null ) {
object = this.globalResolver.resolve( name );
}
return object;
} finally {
- lock.unlock();
+ this.lock.unlock();
}
}
@@ -365,17 +365,17 @@
*/
public Object getObject(final FactHandle handle) {
try {
- lock.lock();
+ this.lock.lock();
// you must always take the value from the assertMap, incase the handle
// is not from this WorkingMemory
- InternalFactHandle factHandle = (InternalFactHandle) this.assertMap.get( handle );
+ final InternalFactHandle factHandle = (InternalFactHandle) this.assertMap.get( handle );
if ( factHandle != null ) {
return factHandle.getObject();
}
return null;
} finally {
- lock.unlock();
+ this.lock.unlock();
}
}
@@ -385,22 +385,22 @@
*/
public FactHandle getFactHandle(final Object object) {
try {
- lock.lock();
+ this.lock.lock();
final FactHandle factHandle = (FactHandle) this.assertMap.get( object );
return factHandle;
} finally {
- lock.unlock();
+ this.lock.unlock();
}
}
public List getFactHandles() {
try {
- lock.lock();
- return null;
+ this.lock.lock();
+ return null;
//return new ArrayList( this.assertMap.values() );
} finally {
- lock.unlock();
+ this.lock.unlock();
}
}
@@ -412,7 +412,7 @@
* @return
*/
public Map getFactHandleMap() {
- return null;
+ return null;
//return Collections.unmodifiableMap( this.assertMap );
}
@@ -422,22 +422,22 @@
public List getObjects() {
final List list = new ArrayList( this.assertMap.size() );
-// for ( final Iterator it = this.assertMap.keySet().iterator(); it.hasNext(); ) {
-// list.add( ((InternalFactHandle) it.next()).getObject() );
-// }
+ // for ( final Iterator it = this.assertMap.keySet().iterator(); it.hasNext(); ) {
+ // list.add( ((InternalFactHandle) it.next()).getObject() );
+ // }
return list;
}
public List getObjects(final Class objectClass) {
final List list = new ArrayList();
-// for ( final Iterator it = this.assertMap.keySet().iterator(); it.hasNext(); ) {
-// final Object object = ((InternalFactHandle) it.next()).getObject();
-//
-// if ( objectClass.isInstance( object ) ) {
-// list.add( object );
-// }
-// }
+ // for ( final Iterator it = this.assertMap.keySet().iterator(); it.hasNext(); ) {
+ // final Object object = ((InternalFactHandle) it.next()).getObject();
+ //
+ // if ( objectClass.isInstance( object ) ) {
+ // list.add( object );
+ // }
+ // }
return list;
}
@@ -814,10 +814,10 @@
*
* @see WorkingMemory
*/
- public void modifyObject( final FactHandle factHandle,
- final Object object,
- final Rule rule,
- final Activation activation ) throws FactException {
+ public void modifyObject(final FactHandle factHandle,
+ final Object object,
+ final Rule rule,
+ final Activation activation) throws FactException {
try {
this.lock.lock();
final int status = ((InternalFactHandle) factHandle).getEqualityKey().getStatus();
@@ -864,11 +864,14 @@
PropagationContext.MODIFICATION,
rule,
activation );
- doRetract( handle, propagationContext );
+ doRetract( handle,
+ propagationContext );
this.handleFactory.increaseFactHandleRecency( handle );
- doAssertObject( handle, object, propagationContext );
+ doAssertObject( handle,
+ object,
+ propagationContext );
this.workingMemoryEventSupport.fireObjectModified( propagationContext,
factHandle,
@@ -892,7 +895,7 @@
}
- public void queueWorkingMemoryAction(WorkingMemoryAction action) {
+ public void queueWorkingMemoryAction(final WorkingMemoryAction action) {
this.factQueue.add( action );
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AgendaGroupImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AgendaGroupImpl.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AgendaGroupImpl.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -37,11 +37,11 @@
public class AgendaGroupImpl
implements
AgendaGroup {
-
- private static final long serialVersionUID = 320L;
-
- private final String name;
+ private static final long serialVersionUID = 320L;
+
+ private final String name;
+
/** Items in the agenda. */
private final BinaryHeapQueue queue;
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AgendaItem.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AgendaItem.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AgendaItem.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -18,7 +18,6 @@
import java.io.Serializable;
-import org.drools.FactHandle;
import org.drools.rule.Rule;
import org.drools.spi.Activation;
import org.drools.spi.PropagationContext;
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/BaseNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/BaseNode.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/BaseNode.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -16,8 +16,6 @@
* limitations under the License.
*/
-import org.drools.spi.PropagationContext;
-
/**
* The base class for all Rete nodes.
*
@@ -30,9 +28,9 @@
NetworkNode {
protected final int id;
- protected boolean hasMemory = false;
+ protected boolean hasMemory = false;
- protected int sharedCount = 0;
+ protected int sharedCount = 0;
/**
* All nodes have a unique id, set in the constructor.
@@ -84,19 +82,19 @@
public abstract void remove(BaseNode node,
InternalWorkingMemory[] workingMemories);
-// /**
-// * When nodes are added to the network that already has data. that existing data must be repropagated to the new node.
-// * This new propagation may result in one or more assertions, so a PropagationContext and the workingMemory for the facts
-// * must be provided.
-// *
-// * @param workingMemory
-// * The WorkingMemory
-// * @param context
-// * The PropagationContext
-// *
-// */
-// public abstract void updateNewNode(InternalWorkingMemory workingMemory,
-// PropagationContext context);
+ // /**
+ // * When nodes are added to the network that already has data. that existing data must be repropagated to the new node.
+ // * This new propagation may result in one or more assertions, so a PropagationContext and the workingMemory for the facts
+ // * must be provided.
+ // *
+ // * @param workingMemory
+ // * The WorkingMemory
+ // * @param context
+ // * The PropagationContext
+ // *
+ // */
+ // public abstract void updateNewNode(InternalWorkingMemory workingMemory,
+ // PropagationContext context);
/**
* Each time a node is shared a counter is increased.
@@ -148,5 +146,5 @@
public String toString() {
return "[" + this.getClass().getName() + "(" + this.id + ")]";
- }
+ }
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/BetaConstraints.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/BetaConstraints.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/BetaConstraints.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -1,10 +1,8 @@
package org.drools.common;
import org.drools.reteoo.BetaMemory;
-import org.drools.reteoo.ObjectHashTable;
import org.drools.reteoo.ReteTuple;
import org.drools.util.LinkedList;
-import org.drools.util.TupleHashTable;
public interface BetaConstraints {
@@ -16,11 +14,11 @@
public boolean isAllowedCachedRight(ReteTuple tuple);
- public LinkedList getConstraints();
-
+ public LinkedList getConstraints();
+
public boolean isIndexed();
-
+
public boolean isEmpty();
-
+
public BetaMemory createBetaMemory();
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/DefaultAgenda.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/DefaultAgenda.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/DefaultAgenda.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -32,7 +32,6 @@
import org.drools.spi.AgendaFilter;
import org.drools.spi.AgendaGroup;
import org.drools.spi.ConsequenceException;
-import org.drools.spi.KnowledgeHelper;
import org.drools.util.LinkedListNode;
import org.drools.util.Queueable;
@@ -99,7 +98,7 @@
*/
public DefaultAgenda(final WorkingMemory workingMemory) {
this.workingMemory = workingMemory;
- this.knowledgeHelper = new DefaultKnowledgeHelper(this.workingMemory);
+ this.knowledgeHelper = new DefaultKnowledgeHelper( this.workingMemory );
this.agendaGroups = new HashMap();
this.activationGroups = new HashMap();
this.focusStack = new LinkedList();
@@ -435,8 +434,8 @@
activation.setActivated( false );
try {
- knowledgeHelper.setActivation(activation);
- activation.getRule().getConsequence().evaluate( knowledgeHelper,
+ this.knowledgeHelper.setActivation( activation );
+ activation.getRule().getConsequence().evaluate( this.knowledgeHelper,
this.workingMemory );
} catch ( final Exception e ) {
//e.printStackTrace();
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/DefaultBetaConstraints.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/DefaultBetaConstraints.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/DefaultBetaConstraints.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -17,51 +17,40 @@
*/
import java.io.Serializable;
-import java.util.HashSet;
-import java.util.Set;
-import org.drools.WorkingMemory;
import org.drools.base.evaluators.Operator;
-import org.drools.common.InstanceNotEqualsConstraint.InstanceNotEqualsConstraintContextEntry;
import org.drools.reteoo.BetaMemory;
-import org.drools.reteoo.ObjectHashTable;
import org.drools.reteoo.ReteTuple;
import org.drools.rule.ContextEntry;
-import org.drools.rule.Declaration;
-import org.drools.rule.LiteralConstraint;
import org.drools.rule.VariableConstraint;
import org.drools.spi.BetaNodeFieldConstraint;
import org.drools.spi.Constraint;
-import org.drools.spi.Evaluator;
-import org.drools.spi.AlphaNodeFieldConstraint;
-import org.drools.spi.FieldExtractor;
-import org.drools.spi.Tuple;
-import org.drools.util.CompositeFieldIndexHashTable;
import org.drools.util.FactHashTable;
import org.drools.util.FieldIndexHashTable;
import org.drools.util.LinkedList;
import org.drools.util.LinkedListEntry;
import org.drools.util.TupleHashTable;
-import org.drools.util.CompositeFieldIndexHashTable.FieldIndex;
+import org.drools.util.FieldIndexHashTable.FieldIndex;
public class DefaultBetaConstraints
implements
- Serializable, BetaConstraints {
+ Serializable,
+ BetaConstraints {
/**
*
*/
- private static final long serialVersionUID = 320L;
+ private static final long serialVersionUID = 320L;
- private final LinkedList constraints;
+ private final LinkedList constraints;
- private ContextEntry contexts;
+ private ContextEntry contexts;
- private boolean indexed;
+ private boolean indexed;
public DefaultBetaConstraints(final BetaNodeFieldConstraint constraint) {
this( new BetaNodeFieldConstraint[]{constraint} );
- }
+ }
public DefaultBetaConstraints(final BetaNodeFieldConstraint[] constraints) {
this.constraints = new LinkedList();
@@ -70,14 +59,15 @@
// Determine if this constraint is indexable
// it is only indexable if there is already no indexed constraints
// An indexed constraint is always the first constraint
- if ( isIndexable( constraints[i] ) && !indexed ) {
- this.constraints.insertAfter( null, new LinkedListEntry( constraints[i] ) );
+ if ( isIndexable( constraints[i] ) && !this.indexed ) {
+ this.constraints.insertAfter( null,
+ new LinkedListEntry( constraints[i] ) );
this.indexed = true;
} else {
this.constraints.add( new LinkedListEntry( constraints[i] ) );
}
//Setup the contextEntry cache to be iterated in the same order
- ContextEntry context = constraints[i].getContextEntry();
+ final ContextEntry context = constraints[i].getContextEntry();
if ( current == null ) {
current = context;
this.contexts = context;
@@ -87,11 +77,11 @@
current = context;
}
}
-
- private boolean isIndexable(final BetaNodeFieldConstraint constraint) {
+
+ private boolean isIndexable(final BetaNodeFieldConstraint constraint) {
if ( constraint.getClass() == VariableConstraint.class ) {
- VariableConstraint variableConstraint = (VariableConstraint) constraint;
- return ( variableConstraint.getEvaluator().getOperator() == Operator.EQUAL );
+ final VariableConstraint variableConstraint = (VariableConstraint) constraint;
+ return (variableConstraint.getEvaluator().getOperator() == Operator.EQUAL);
} else {
return false;
}
@@ -100,7 +90,7 @@
/* (non-Javadoc)
* @see org.drools.common.BetaNodeConstraints#updateFromTuple(org.drools.reteoo.ReteTuple)
*/
- public void updateFromTuple(ReteTuple tuple) {
+ public void updateFromTuple(final ReteTuple tuple) {
for ( ContextEntry context = this.contexts; context != null; context = context.getNext() ) {
context.updateFromTuple( tuple );
}
@@ -109,68 +99,71 @@
/* (non-Javadoc)
* @see org.drools.common.BetaNodeConstraints#updateFromFactHandle(org.drools.common.InternalFactHandle)
*/
- public void updateFromFactHandle(InternalFactHandle handle) {
+ public void updateFromFactHandle(final InternalFactHandle handle) {
for ( ContextEntry context = this.contexts; context != null; context = context.getNext() ) {
context.updateFromFactHandle( handle );
}
}
-
+
/* (non-Javadoc)
* @see org.drools.common.BetaNodeConstraints#isAllowedCachedLeft(java.lang.Object)
*/
- public boolean isAllowedCachedLeft(Object object ) {
+ public boolean isAllowedCachedLeft(final Object object) {
LinkedListEntry entry = (LinkedListEntry) this.constraints.getFirst();
ContextEntry context = this.contexts;
while ( entry != null ) {
- if ( !((BetaNodeFieldConstraint) entry.getObject()).isAllowedCachedLeft(context, object ) ) {
+ if ( !((BetaNodeFieldConstraint) entry.getObject()).isAllowedCachedLeft( context,
+ object ) ) {
return false;
}
entry = (LinkedListEntry) entry.getNext();
context = context.getNext();
}
- return true;
- }
-
+ return true;
+ }
+
/* (non-Javadoc)
* @see org.drools.common.BetaNodeConstraints#isAllowedCachedRight(org.drools.reteoo.ReteTuple)
*/
- public boolean isAllowedCachedRight(ReteTuple tuple) {
+ public boolean isAllowedCachedRight(final ReteTuple tuple) {
LinkedListEntry entry = (LinkedListEntry) this.constraints.getFirst();
ContextEntry context = this.contexts;
while ( entry != null ) {
- if ( !((BetaNodeFieldConstraint) entry.getObject()).isAllowedCachedRight(tuple, context ) ) {
+ if ( !((BetaNodeFieldConstraint) entry.getObject()).isAllowedCachedRight( tuple,
+ context ) ) {
return false;
}
entry = (LinkedListEntry) entry.getNext();
context = context.getNext();
}
- return true;
- }
-
+ return true;
+ }
+
public boolean isIndexed() {
return this.indexed;
}
-
+
public boolean isEmpty() {
- return false;
+ return false;
}
-
- public BetaMemory createBetaMemory() {
+
+ public BetaMemory createBetaMemory() {
BetaMemory memory;
if ( this.indexed ) {
- Constraint constraint = ( Constraint ) this.constraints.getFirst();
- VariableConstraint variableConstraint = (VariableConstraint) constraint;
- FieldIndex index = new FieldIndex(variableConstraint.getFieldExtractor(), variableConstraint.getRequiredDeclarations()[0]);
+ final Constraint constraint = (Constraint) this.constraints.getFirst();
+ final VariableConstraint variableConstraint = (VariableConstraint) constraint;
+ final FieldIndex index = new FieldIndex( variableConstraint.getFieldExtractor(),
+ variableConstraint.getRequiredDeclarations()[0] );
memory = new BetaMemory( new TupleHashTable(),
- new CompositeFieldIndexHashTable( new FieldIndex[] { index } ) );
- } else {
+ new FieldIndexHashTable( new FieldIndex[]{index} ) );
+ } else {
memory = new BetaMemory( new TupleHashTable(),
new FactHashTable() );
}
-
- return memory;
- }
+ return memory;
+ }
+
// public Set getRequiredDeclarations() {
// final Set declarations = new HashSet();
// for ( int i = 0; i < this.constraints.length; i++ ) {
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/DefaultFactHandle.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/DefaultFactHandle.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/DefaultFactHandle.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -35,12 +35,12 @@
*/
private static final long serialVersionUID = 320L;
/** Handle id. */
- private long id;
- private long recency;
- private Object object;
- private EqualityKey key;
- private int objectHashCode;
-
+ private long id;
+ private long recency;
+ private Object object;
+ private EqualityKey key;
+ private int objectHashCode;
+
// ----------------------------------------------------------------------
// Constructors
// ----------------------------------------------------------------------
@@ -90,8 +90,8 @@
return this.id == ((DefaultFactHandle) object).id;
}
-
- public int getObjectHashCode() {
+
+ public int getObjectHashCode() {
return this.objectHashCode;
}
@@ -99,7 +99,7 @@
* @see Object
*/
public int hashCode() {
- return (int)(this.id ^ (this.id >>> 32));
+ return (int) (this.id ^ (this.id >>> 32));
}
/**
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/DoubleBetaConstraints.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/DoubleBetaConstraints.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/DoubleBetaConstraints.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -18,34 +18,20 @@
import java.io.Serializable;
import java.util.ArrayList;
-import java.util.HashSet;
import java.util.List;
-import java.util.Set;
-import org.drools.WorkingMemory;
import org.drools.base.evaluators.Operator;
-import org.drools.common.InstanceNotEqualsConstraint.InstanceNotEqualsConstraintContextEntry;
import org.drools.reteoo.BetaMemory;
-import org.drools.reteoo.ObjectHashTable;
import org.drools.reteoo.ReteTuple;
import org.drools.rule.ContextEntry;
-import org.drools.rule.Declaration;
-import org.drools.rule.LiteralConstraint;
import org.drools.rule.VariableConstraint;
import org.drools.spi.BetaNodeFieldConstraint;
-import org.drools.spi.Constraint;
-import org.drools.spi.Evaluator;
-import org.drools.spi.AlphaNodeFieldConstraint;
-import org.drools.spi.FieldExtractor;
-import org.drools.spi.Tuple;
import org.drools.util.FactHashTable;
import org.drools.util.FieldIndexHashTable;
import org.drools.util.LinkedList;
import org.drools.util.LinkedListEntry;
-import org.drools.util.LinkedListNode;
import org.drools.util.TupleHashTable;
-import org.drools.util.CompositeFieldIndexHashTable;
-import org.drools.util.CompositeFieldIndexHashTable.FieldIndex;
+import org.drools.util.FieldIndexHashTable.FieldIndex;
public class DoubleBetaConstraints
implements
@@ -67,8 +53,8 @@
private boolean indexed1;
public DoubleBetaConstraints(final BetaNodeFieldConstraint[] constraints) {
- boolean i0 = isIndexable( constraints[0] );
- boolean i1 = isIndexable( constraints[1] );
+ final boolean i0 = isIndexable( constraints[0] );
+ final boolean i1 = isIndexable( constraints[1] );
if ( i0 ) {
this.indexed0 = true;
@@ -77,7 +63,7 @@
}
} else if ( i1 ) {
this.indexed0 = true;
- BetaNodeFieldConstraint temp = constraints[0];
+ final BetaNodeFieldConstraint temp = constraints[0];
constraints[0] = constraints[1];
constraints[1] = temp;
}
@@ -91,7 +77,7 @@
private boolean isIndexable(final BetaNodeFieldConstraint constraint) {
if ( constraint.getClass() == VariableConstraint.class ) {
- VariableConstraint variableConstraint = (VariableConstraint) constraint;
+ final VariableConstraint variableConstraint = (VariableConstraint) constraint;
return (variableConstraint.getEvaluator().getOperator() == Operator.EQUAL);
} else {
return false;
@@ -101,35 +87,35 @@
/* (non-Javadoc)
* @see org.drools.common.BetaNodeConstraints#updateFromTuple(org.drools.reteoo.ReteTuple)
*/
- public void updateFromTuple(ReteTuple tuple) {
- context0.updateFromTuple( tuple );
- context1.updateFromTuple( tuple );
+ public void updateFromTuple(final ReteTuple tuple) {
+ this.context0.updateFromTuple( tuple );
+ this.context1.updateFromTuple( tuple );
}
/* (non-Javadoc)
* @see org.drools.common.BetaNodeConstraints#updateFromFactHandle(org.drools.common.InternalFactHandle)
*/
- public void updateFromFactHandle(InternalFactHandle handle) {
- context0.updateFromFactHandle( handle );
- context1.updateFromFactHandle( handle );
+ public void updateFromFactHandle(final InternalFactHandle handle) {
+ this.context0.updateFromFactHandle( handle );
+ this.context1.updateFromFactHandle( handle );
}
/* (non-Javadoc)
* @see org.drools.common.BetaNodeConstraints#isAllowedCachedLeft(java.lang.Object)
*/
- public boolean isAllowedCachedLeft(Object object) {
- return (this.indexed0 || this.constraint0.isAllowedCachedLeft( context0,
- object )) && (this.indexed1 || this.constraint1.isAllowedCachedLeft( context1,
+ public boolean isAllowedCachedLeft(final Object object) {
+ return (this.indexed0 || this.constraint0.isAllowedCachedLeft( this.context0,
+ object )) && (this.indexed1 || this.constraint1.isAllowedCachedLeft( this.context1,
object ));
}
/* (non-Javadoc)
* @see org.drools.common.BetaNodeConstraints#isAllowedCachedRight(org.drools.reteoo.ReteTuple)
*/
- public boolean isAllowedCachedRight(ReteTuple tuple) {
+ public boolean isAllowedCachedRight(final ReteTuple tuple) {
return this.constraint0.isAllowedCachedRight( tuple,
- context0 ) && this.constraint1.isAllowedCachedRight( tuple,
- context1 );
+ this.context0 ) && this.constraint1.isAllowedCachedRight( tuple,
+ this.context1 );
}
public boolean isIndexed() {
@@ -143,26 +129,26 @@
public BetaMemory createBetaMemory() {
BetaMemory memory;
- List list = new ArrayList( 2 );
+ final List list = new ArrayList( 2 );
if ( this.indexed0 ) {
- VariableConstraint variableConstraint = (VariableConstraint) this.constraint0;
- FieldIndex index = new FieldIndex( variableConstraint.getFieldExtractor(),
- variableConstraint.getRequiredDeclarations()[0] );
+ final VariableConstraint variableConstraint = (VariableConstraint) this.constraint0;
+ final FieldIndex index = new FieldIndex( variableConstraint.getFieldExtractor(),
+ variableConstraint.getRequiredDeclarations()[0] );
list.add( index );
}
if ( this.indexed1 ) {
- VariableConstraint variableConstraint = (VariableConstraint) this.constraint1;
- FieldIndex index = new FieldIndex( variableConstraint.getFieldExtractor(),
- variableConstraint.getRequiredDeclarations()[0] );
+ final VariableConstraint variableConstraint = (VariableConstraint) this.constraint1;
+ final FieldIndex index = new FieldIndex( variableConstraint.getFieldExtractor(),
+ variableConstraint.getRequiredDeclarations()[0] );
list.add( index );
}
if ( !list.isEmpty() ) {
- FieldIndex[] indexes = (FieldIndex[]) list.toArray( new FieldIndex[list.size()] );
+ final FieldIndex[] indexes = (FieldIndex[]) list.toArray( new FieldIndex[list.size()] );
memory = new BetaMemory( new TupleHashTable(),
- new CompositeFieldIndexHashTable( indexes ) );
+ new FieldIndexHashTable( indexes ) );
} else {
memory = new BetaMemory( new TupleHashTable(),
new FactHashTable() );
@@ -190,7 +176,7 @@
* @see org.drools.common.BetaNodeConstraints#getConstraints()
*/
public LinkedList getConstraints() {
- LinkedList list = new LinkedList();
+ final LinkedList list = new LinkedList();
list.add( new LinkedListEntry( this.constraint0 ) );
list.add( new LinkedListEntry( this.constraint1 ) );
return list;
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/EmptyBetaConstraints.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/EmptyBetaConstraints.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/EmptyBetaConstraints.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -17,91 +17,73 @@
*/
import java.io.Serializable;
-import java.util.HashSet;
-import java.util.Set;
-import org.drools.WorkingMemory;
-import org.drools.base.evaluators.Operator;
-import org.drools.common.InstanceNotEqualsConstraint.InstanceNotEqualsConstraintContextEntry;
import org.drools.reteoo.BetaMemory;
-import org.drools.reteoo.ObjectHashTable;
import org.drools.reteoo.ReteTuple;
-import org.drools.rule.ContextEntry;
-import org.drools.rule.Declaration;
-import org.drools.rule.LiteralConstraint;
-import org.drools.rule.VariableConstraint;
-import org.drools.spi.BetaNodeFieldConstraint;
-import org.drools.spi.Constraint;
-import org.drools.spi.Evaluator;
-import org.drools.spi.AlphaNodeFieldConstraint;
-import org.drools.spi.FieldExtractor;
-import org.drools.spi.Tuple;
import org.drools.util.FactHashTable;
-import org.drools.util.FieldIndexHashTable;
import org.drools.util.LinkedList;
-import org.drools.util.LinkedListEntry;
-import org.drools.util.LinkedListNode;
import org.drools.util.TupleHashTable;
public class EmptyBetaConstraints
implements
- Serializable, BetaConstraints {
+ Serializable,
+ BetaConstraints {
private static final BetaConstraints INSTANCE = new EmptyBetaConstraints();
-
+
public static BetaConstraints getInstance() {
- return INSTANCE;
+ return EmptyBetaConstraints.INSTANCE;
}
-
+
/**
*
*/
- private static final long serialVersionUID = 320L;
-
+ private static final long serialVersionUID = 320L;
+
private EmptyBetaConstraints() {
}
/* (non-Javadoc)
* @see org.drools.common.BetaNodeConstraints#updateFromTuple(org.drools.reteoo.ReteTuple)
*/
- public void updateFromTuple(ReteTuple tuple) {
+ public void updateFromTuple(final ReteTuple tuple) {
}
/* (non-Javadoc)
* @see org.drools.common.BetaNodeConstraints#updateFromFactHandle(org.drools.common.InternalFactHandle)
*/
- public void updateFromFactHandle(InternalFactHandle handle) {
+ public void updateFromFactHandle(final InternalFactHandle handle) {
}
-
+
/* (non-Javadoc)
* @see org.drools.common.BetaNodeConstraints#isAllowedCachedLeft(java.lang.Object)
*/
- public boolean isAllowedCachedLeft(Object object ) {
+ public boolean isAllowedCachedLeft(final Object object) {
return true;
- }
-
+ }
+
/* (non-Javadoc)
* @see org.drools.common.BetaNodeConstraints#isAllowedCachedRight(org.drools.reteoo.ReteTuple)
*/
- public boolean isAllowedCachedRight(ReteTuple tuple) {
+ public boolean isAllowedCachedRight(final ReteTuple tuple) {
return true;
- }
-
+ }
+
public boolean isIndexed() {
return false;
}
-
+
public boolean isEmpty() {
- return true;
+ return true;
}
-
- public BetaMemory createBetaMemory() {
- BetaMemory memory = new BetaMemory( new TupleHashTable(),
+
+ public BetaMemory createBetaMemory() {
+ final BetaMemory memory = new BetaMemory( new TupleHashTable(),
new FactHashTable() );
-
- return memory;
- }
+ return memory;
+ }
+
public int hashCode() {
return 1;
}
@@ -110,7 +92,7 @@
* @see org.drools.common.BetaNodeConstraints#getConstraints()
*/
public LinkedList getConstraints() {
- LinkedList list = new LinkedList();
+ final LinkedList list = new LinkedList();
return list;
}
@@ -128,7 +110,7 @@
return true;
}
- return ( object != null && getClass() == object.getClass() );
+ return (object != null && getClass() == object.getClass());
}
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/EqualityAssertMapComparator.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/EqualityAssertMapComparator.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/EqualityAssertMapComparator.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -38,13 +38,13 @@
}
return rehash( obj.hashCode() );
}
-
+
public int rehash(int h) {
h += ~(h << 9);
h ^= (h >>> 14);
h += (h << 4);
h ^= (h >>> 10);
- return h;
+ return h;
}
/**
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/EqualityKey.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/EqualityKey.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/EqualityKey.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -1,4 +1,5 @@
package org.drools.common;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -28,7 +29,9 @@
* @author <a href="mailto:mark.proctor at jboss.com">Mark Proctor</a>
*
*/
-public class EqualityKey implements Serializable {
+public class EqualityKey
+ implements
+ Serializable {
public final static int STATED = 1;
public final static int JUSTIFIED = 2;
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/EqualityKeyComparator.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/EqualityKeyComparator.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/EqualityKeyComparator.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -1,4 +1,5 @@
package org.drools.common;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -17,12 +18,14 @@
import org.drools.util.AbstractHashTable.ObjectComparator;
-public class EqualityKeyComparator implements ObjectComparator {
+public class EqualityKeyComparator
+ implements
+ ObjectComparator {
/**
*
*/
private static final long serialVersionUID = 320L;
-
+
private static EqualityKeyComparator instance;
public static EqualityKeyComparator getInstance() {
@@ -32,24 +35,24 @@
return EqualityKeyComparator.instance;
}
-
- public int hashCodeOf(Object key) {
+
+ public int hashCodeOf(final Object key) {
return rehash( key.hashCode() );
}
-
+
public int rehash(int h) {
h += ~(h << 9);
h ^= (h >>> 14);
h += (h << 4);
h ^= (h >>> 10);
- return h;
+ return h;
}
/**
* Equality key reverses the compare, so that the key controls the comparison
*/
public boolean equal(final Object o1,
- final Object o2) {
+ final Object o2) {
return (o1 == null) ? (o2 == null) : (o1 == o2) || o2.equals( o1 );
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/IdentityAssertMapComparator.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/IdentityAssertMapComparator.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/IdentityAssertMapComparator.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -36,15 +36,15 @@
if ( obj.getClass() == this.factHandleClass ) {
return rehash( ((InternalFactHandle) obj).getObjectHashCode() );
}
- return rehash( obj.hashCode());
+ return rehash( obj.hashCode() );
}
-
+
public int rehash(int h) {
h += ~(h << 9);
h ^= (h >>> 14);
h += (h << 4);
h ^= (h >>> 10);
- return h;
+ return h;
}
/**
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InstanceEqualsConstraint.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InstanceEqualsConstraint.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InstanceEqualsConstraint.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -16,16 +16,12 @@
package org.drools.common;
-import org.drools.WorkingMemory;
import org.drools.common.InstanceNotEqualsConstraint.InstanceNotEqualsConstraintContextEntry;
import org.drools.reteoo.ReteTuple;
import org.drools.rule.Column;
import org.drools.rule.ContextEntry;
import org.drools.rule.Declaration;
-import org.drools.spi.AlphaNodeFieldConstraint;
import org.drools.spi.BetaNodeFieldConstraint;
-import org.drools.spi.FieldExtractor;
-import org.drools.spi.Tuple;
/**
* InstanceEqualsConstraint
@@ -38,13 +34,13 @@
public class InstanceEqualsConstraint
implements
- BetaNodeFieldConstraint {
+ BetaNodeFieldConstraint {
- private static final long serialVersionUID = 320L;
+ private static final long serialVersionUID = 320L;
private final Declaration[] declarations = new Declaration[0];
- private Column otherColumn;
+ private Column otherColumn;
public InstanceEqualsConstraint(final Column otherColumn) {
this.otherColumn = otherColumn;
@@ -53,23 +49,25 @@
public Declaration[] getRequiredDeclarations() {
return this.declarations;
}
-
+
public Column getOtherColumn() {
return this.otherColumn;
}
-
+
public ContextEntry getContextEntry() {
- return new InstanceEqualsConstraintContextEntry( this.otherColumn );
+ return new InstanceEqualsConstraintContextEntry( this.otherColumn );
}
-
- public boolean isAllowedCachedLeft(ContextEntry context, Object object ) {
- return ((InstanceNotEqualsConstraintContextEntry)context).left == object;
- }
-
- public boolean isAllowedCachedRight(ReteTuple tuple, ContextEntry context) {
- return tuple.get( this.otherColumn.getFactIndex()).getObject() == ((InstanceNotEqualsConstraintContextEntry)context).right ;
- }
+ public boolean isAllowedCachedLeft(final ContextEntry context,
+ final Object object) {
+ return ((InstanceNotEqualsConstraintContextEntry) context).left == object;
+ }
+
+ public boolean isAllowedCachedRight(final ReteTuple tuple,
+ final ContextEntry context) {
+ return tuple.get( this.otherColumn.getFactIndex() ).getObject() == ((InstanceNotEqualsConstraintContextEntry) context).right;
+ }
+
public String toString() {
return "[InstanceEqualsConstraint otherColumn=" + this.otherColumn + " ]";
}
@@ -91,33 +89,34 @@
return this.otherColumn.equals( other.otherColumn );
}
- public static class InstanceEqualsConstraintContextEntry implements ContextEntry {
- public Object left;
- public Object right;
-
- private Column column;
+ public static class InstanceEqualsConstraintContextEntry
+ implements
+ ContextEntry {
+ public Object left;
+ public Object right;
+
+ private Column column;
private ContextEntry entry;
-
-
- public InstanceEqualsConstraintContextEntry(Column column) {
+
+ public InstanceEqualsConstraintContextEntry(final Column column) {
this.column = column;
}
-
+
public ContextEntry getNext() {
return this.entry;
}
-
- public void setNext(ContextEntry entry) {
+
+ public void setNext(final ContextEntry entry) {
this.entry = entry;
}
-
- public void updateFromTuple(ReteTuple tuple) {
- this.left = tuple.get( this.column.getFactIndex() ).getObject();
- }
-
- public void updateFromFactHandle(InternalFactHandle handle) {
+
+ public void updateFromTuple(final ReteTuple tuple) {
+ this.left = tuple.get( this.column.getFactIndex() ).getObject();
+ }
+
+ public void updateFromFactHandle(final InternalFactHandle handle) {
this.right = handle.getObject();
-
- }
- }
+
+ }
+ }
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InstanceNotEqualsConstraint.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InstanceNotEqualsConstraint.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InstanceNotEqualsConstraint.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -16,32 +16,28 @@
* limitations under the License.
*/
-import org.drools.WorkingMemory;
-import org.drools.common.InstanceEqualsConstraint.InstanceEqualsConstraintContextEntry;
import org.drools.reteoo.ReteTuple;
import org.drools.rule.Column;
import org.drools.rule.ContextEntry;
import org.drools.rule.Declaration;
-import org.drools.spi.AlphaNodeFieldConstraint;
import org.drools.spi.BetaNodeFieldConstraint;
-import org.drools.spi.Tuple;
public class InstanceNotEqualsConstraint
implements
BetaNodeFieldConstraint {
- private static final long serialVersionUID = 320L;
+ private static final long serialVersionUID = 320L;
private static final Declaration[] declarations = new Declaration[0];
- private Column otherColumn;
+ private Column otherColumn;
public InstanceNotEqualsConstraint(final Column otherColumn) {
this.otherColumn = otherColumn;
}
public Declaration[] getRequiredDeclarations() {
- return this.declarations;
+ return InstanceNotEqualsConstraint.declarations;
}
public Column getOtherColumn() {
@@ -53,17 +49,17 @@
}
public boolean isAllowed(final ContextEntry entry) {
- InstanceNotEqualsConstraintContextEntry context = (InstanceNotEqualsConstraintContextEntry) entry;
+ final InstanceNotEqualsConstraintContextEntry context = (InstanceNotEqualsConstraintContextEntry) entry;
return context.left != context.right;
}
- public boolean isAllowedCachedLeft(ContextEntry context,
- Object object) {
+ public boolean isAllowedCachedLeft(final ContextEntry context,
+ final Object object) {
return ((InstanceNotEqualsConstraintContextEntry) context).left != object;
}
- public boolean isAllowedCachedRight(ReteTuple tuple,
- ContextEntry context) {
+ public boolean isAllowedCachedRight(final ReteTuple tuple,
+ final ContextEntry context) {
return tuple.get( this.otherColumn.getFactIndex() ).getObject() != ((InstanceNotEqualsConstraintContextEntry) context).right;
}
@@ -97,7 +93,7 @@
private Column column;
private ContextEntry entry;
- public InstanceNotEqualsConstraintContextEntry(Column column) {
+ public InstanceNotEqualsConstraintContextEntry(final Column column) {
this.column = column;
}
@@ -105,15 +101,15 @@
return this.entry;
}
- public void setNext(ContextEntry entry) {
+ public void setNext(final ContextEntry entry) {
this.entry = entry;
}
- public void updateFromTuple(ReteTuple tuple) {
+ public void updateFromTuple(final ReteTuple tuple) {
this.left = tuple.get( this.column.getFactIndex() ).getObject();
}
-
- public void updateFromFactHandle(InternalFactHandle handle) {
+
+ public void updateFromFactHandle(final InternalFactHandle handle) {
this.right = handle.getObject();
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalAgenda.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalAgenda.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalAgenda.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -11,13 +11,13 @@
Agenda {
public void fireActivation(final Activation activation) throws ConsequenceException;
-
+
public void removeScheduleItem(final ScheduledAgendaItem item);
-
+
public boolean fireNextItem(AgendaFilter filter) throws ConsequenceException;
-
+
public void scheduleItem(final ScheduledAgendaItem item);
-
+
public void addAgendaGroup(final AgendaGroup agendaGroup);
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalFactHandle.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalFactHandle.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalFactHandle.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -36,6 +36,6 @@
public void setRecency(long recency);
public void invalidate();
-
+
public int getObjectHashCode();
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalRuleBase.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalRuleBase.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalRuleBase.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -1,4 +1,5 @@
package org.drools.common;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -33,8 +34,8 @@
/**
* @return the id
*/
- public String getId();
-
+ public String getId();
+
public FactHandleFactory newFactHandleFactory();
public Map getGlobals();
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalWorkingMemory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalWorkingMemory.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalWorkingMemory.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -6,23 +6,24 @@
import org.drools.event.AgendaEventSupport;
import org.drools.spi.FactHandleFactory;
-public interface InternalWorkingMemory extends WorkingMemory {
+public interface InternalWorkingMemory
+ extends
+ WorkingMemory {
public long getId();
-
+
public Object getNodeMemory(NodeMemory node);
-
+
public void clearNodeMemory(NodeMemory node);
-
+
public long getNextPropagationIdCounter();
-
+
public Map getFactHandleMap();
-
+
public AgendaEventSupport getAgendaEventSupport();
-
+
public TruthMaintenanceSystem getTruthMaintenanceSystem();
-
+
public void propagateQueuedActions();
- public FactHandleFactory getFactHandleFactory();
+ public FactHandleFactory getFactHandleFactory();
}
-
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/NodeMemory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/NodeMemory.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/NodeMemory.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -1,4 +1,5 @@
package org.drools.common;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -17,8 +18,6 @@
import org.drools.RuleBaseConfiguration;
-
-
public interface NodeMemory {
public int getId();
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/RuleFlowNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/RuleFlowNode.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/RuleFlowNode.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -14,18 +14,18 @@
implements
AgendaGroup {
- private static final long serialVersionUID = 320L;
+ private static final long serialVersionUID = 320L;
- private final String name;
+ private final String name;
- private final InternalAgenda agenda;
+ private final InternalAgenda agenda;
/** @todo Maybe this should just be a LinkedList and we sort on use? */
private final BinaryHeapQueue queue;
- private List childNodes = Collections.EMPTY_LIST;
+ private List childNodes = Collections.EMPTY_LIST;
- private Object lock;
+ private final Object lock;
/**
* Construct an <code>RuleFlowNode</code> with the given name.
@@ -47,14 +47,14 @@
return this.name;
}
- public void addChildNode(RuleFlowNode child) {
+ public void addChildNode(final RuleFlowNode child) {
if ( this.childNodes == Collections.EMPTY_LIST ) {
this.childNodes = new ArrayList( 1 );
}
this.childNodes.add( child );
}
- public boolean removeChildNode(RuleFlowNode child) {
+ public boolean removeChildNode(final RuleFlowNode child) {
return this.childNodes.remove( child );
}
@@ -120,11 +120,11 @@
}
// Make a runnable execution so we can fire all the activations
- ExecuteRuleFlowNode execute = new ExecuteRuleFlowNode( this.agenda,
+ final ExecuteRuleFlowNode execute = new ExecuteRuleFlowNode( this.agenda,
(RuleFlowNode[]) this.childNodes.toArray( new RuleFlowNode[this.childNodes.size()] ),
activations );
- Thread thread = new Thread( execute );
- thread.start();
+ final Thread thread = new Thread( execute );
+ thread.start();
}
public String toString() {
@@ -155,7 +155,7 @@
private final Activation[] activations;
public ExecuteRuleFlowNode(final InternalAgenda agenda,
- RuleFlowNode[] nodes,
+ final RuleFlowNode[] nodes,
final Activation[] activations) {
this.agenda = agenda;
this.nodes = nodes;
@@ -163,11 +163,11 @@
}
public void run() {
- for ( int i = 0, length = activations.length; i < length; i++ ) {
+ for ( int i = 0, length = this.activations.length; i < length; i++ ) {
this.agenda.fireActivation( this.activations[i] );
}
- for ( int i = 0, length = nodes.length; i < length; i++ ) {
+ for ( int i = 0, length = this.nodes.length; i < length; i++ ) {
this.nodes[i].activate();
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/ScheduledAgendaItem.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/ScheduledAgendaItem.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/ScheduledAgendaItem.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -19,7 +19,6 @@
import java.io.Serializable;
import java.util.TimerTask;
-import org.drools.FactHandle;
import org.drools.rule.Rule;
import org.drools.spi.Activation;
import org.drools.spi.PropagationContext;
@@ -56,7 +55,7 @@
/** The rule. */
private final Rule rule;
- private final InternalAgenda agenda;
+ private final InternalAgenda agenda;
private final PropagationContext context;
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/SingleBetaConstraints.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/SingleBetaConstraints.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/SingleBetaConstraints.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -17,19 +17,19 @@
*/
import java.io.Serializable;
+
import org.drools.base.evaluators.Operator;
import org.drools.reteoo.BetaMemory;
import org.drools.reteoo.ReteTuple;
import org.drools.rule.ContextEntry;
import org.drools.rule.VariableConstraint;
import org.drools.spi.BetaNodeFieldConstraint;
-import org.drools.util.CompositeFieldIndexHashTable;
import org.drools.util.FactHashTable;
import org.drools.util.FieldIndexHashTable;
import org.drools.util.LinkedList;
import org.drools.util.LinkedListEntry;
import org.drools.util.TupleHashTable;
-import org.drools.util.CompositeFieldIndexHashTable.FieldIndex;
+import org.drools.util.FieldIndexHashTable.FieldIndex;
public class SingleBetaConstraints
implements
@@ -59,7 +59,7 @@
private boolean isIndexable(final BetaNodeFieldConstraint constraint) {
if ( constraint.getClass() == VariableConstraint.class ) {
- VariableConstraint variableConstraint = (VariableConstraint) constraint;
+ final VariableConstraint variableConstraint = (VariableConstraint) constraint;
return (variableConstraint.getEvaluator().getOperator() == Operator.EQUAL);
} else {
return false;
@@ -69,31 +69,31 @@
/* (non-Javadoc)
* @see org.drools.common.BetaNodeConstraints#updateFromTuple(org.drools.reteoo.ReteTuple)
*/
- public void updateFromTuple(ReteTuple tuple) {
- context.updateFromTuple( tuple );
+ public void updateFromTuple(final ReteTuple tuple) {
+ this.context.updateFromTuple( tuple );
}
/* (non-Javadoc)
* @see org.drools.common.BetaNodeConstraints#updateFromFactHandle(org.drools.common.InternalFactHandle)
*/
- public void updateFromFactHandle(InternalFactHandle handle) {
- context.updateFromFactHandle( handle );
+ public void updateFromFactHandle(final InternalFactHandle handle) {
+ this.context.updateFromFactHandle( handle );
}
/* (non-Javadoc)
* @see org.drools.common.BetaNodeConstraints#isAllowedCachedLeft(java.lang.Object)
*/
- public boolean isAllowedCachedLeft(Object object) {
- return this.indexed || this.constraint.isAllowedCachedLeft( context,
+ public boolean isAllowedCachedLeft(final Object object) {
+ return this.indexed || this.constraint.isAllowedCachedLeft( this.context,
object );
}
/* (non-Javadoc)
* @see org.drools.common.BetaNodeConstraints#isAllowedCachedRight(org.drools.reteoo.ReteTuple)
*/
- public boolean isAllowedCachedRight(ReteTuple tuple) {
+ public boolean isAllowedCachedRight(final ReteTuple tuple) {
return this.constraint.isAllowedCachedRight( tuple,
- context );
+ this.context );
}
public boolean isIndexed() {
@@ -107,10 +107,11 @@
public BetaMemory createBetaMemory() {
BetaMemory memory;
if ( this.indexed ) {
- VariableConstraint variableConstraint = (VariableConstraint) this.constraint;
- FieldIndex index = new FieldIndex(variableConstraint.getFieldExtractor(), variableConstraint.getRequiredDeclarations()[0]);
+ final VariableConstraint variableConstraint = (VariableConstraint) this.constraint;
+ final FieldIndex index = new FieldIndex( variableConstraint.getFieldExtractor(),
+ variableConstraint.getRequiredDeclarations()[0] );
memory = new BetaMemory( new TupleHashTable(),
- new CompositeFieldIndexHashTable( new FieldIndex[] { index } ) );
+ new FieldIndexHashTable( new FieldIndex[]{index} ) );
} else {
memory = new BetaMemory( new TupleHashTable(),
new FactHashTable() );
@@ -138,7 +139,7 @@
* @see org.drools.common.BetaNodeConstraints#getConstraints()
*/
public LinkedList getConstraints() {
- LinkedList list = new LinkedList();
+ final LinkedList list = new LinkedList();
list.add( new LinkedListEntry( this.constraint ) );
return list;
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/TripleBetaConstraints.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/TripleBetaConstraints.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/TripleBetaConstraints.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -18,34 +18,20 @@
import java.io.Serializable;
import java.util.ArrayList;
-import java.util.HashSet;
import java.util.List;
-import java.util.Set;
-import org.drools.WorkingMemory;
import org.drools.base.evaluators.Operator;
-import org.drools.common.InstanceNotEqualsConstraint.InstanceNotEqualsConstraintContextEntry;
import org.drools.reteoo.BetaMemory;
-import org.drools.reteoo.ObjectHashTable;
import org.drools.reteoo.ReteTuple;
import org.drools.rule.ContextEntry;
-import org.drools.rule.Declaration;
-import org.drools.rule.LiteralConstraint;
import org.drools.rule.VariableConstraint;
import org.drools.spi.BetaNodeFieldConstraint;
-import org.drools.spi.Constraint;
-import org.drools.spi.Evaluator;
-import org.drools.spi.AlphaNodeFieldConstraint;
-import org.drools.spi.FieldExtractor;
-import org.drools.spi.Tuple;
-import org.drools.util.CompositeFieldIndexHashTable;
import org.drools.util.FactHashTable;
import org.drools.util.FieldIndexHashTable;
import org.drools.util.LinkedList;
import org.drools.util.LinkedListEntry;
-import org.drools.util.LinkedListNode;
import org.drools.util.TupleHashTable;
-import org.drools.util.CompositeFieldIndexHashTable.FieldIndex;
+import org.drools.util.FieldIndexHashTable.FieldIndex;
public class TripleBetaConstraints
implements
@@ -61,9 +47,9 @@
private final BetaNodeFieldConstraint constraint1;
private final BetaNodeFieldConstraint constraint2;
- private ContextEntry context0;
- private ContextEntry context1;
- private ContextEntry context2;
+ private final ContextEntry context0;
+ private final ContextEntry context1;
+ private final ContextEntry context2;
private boolean indexed0;
private boolean indexed1;
@@ -93,9 +79,9 @@
// this.constraint2 = constraints[2];
// this.context2 = this.constraint2.getContextEntry();
- boolean i0 = isIndexable( constraints[0] );
- boolean i1 = isIndexable( constraints[1] );
- boolean i2 = isIndexable( constraints[2] );
+ final boolean i0 = isIndexable( constraints[0] );
+ final boolean i1 = isIndexable( constraints[1] );
+ final boolean i2 = isIndexable( constraints[2] );
if ( i0 ) {
this.indexed0 = true;
@@ -104,22 +90,22 @@
}
} else if ( i1 ) {
this.indexed0 = true;
- BetaNodeFieldConstraint temp = constraints[0];
+ final BetaNodeFieldConstraint temp = constraints[0];
constraints[0] = constraints[1];
constraints[1] = temp;
}
-
- if ( i2 ) {
- if (i0) {
+
+ if ( i2 ) {
+ if ( i0 ) {
this.indexed1 = true;
- BetaNodeFieldConstraint temp = constraints[1];
+ final BetaNodeFieldConstraint temp = constraints[1];
constraints[1] = constraints[2];
- constraints[2] = temp;
+ constraints[2] = temp;
} else {
this.indexed0 = true;
- BetaNodeFieldConstraint temp = constraints[0];
+ final BetaNodeFieldConstraint temp = constraints[0];
constraints[0] = constraints[2];
- constraints[2] = temp;
+ constraints[2] = temp;
}
}
@@ -135,7 +121,7 @@
private boolean isIndexable(final BetaNodeFieldConstraint constraint) {
if ( constraint.getClass() == VariableConstraint.class ) {
- VariableConstraint variableConstraint = (VariableConstraint) constraint;
+ final VariableConstraint variableConstraint = (VariableConstraint) constraint;
return (variableConstraint.getEvaluator().getOperator() == Operator.EQUAL);
} else {
return false;
@@ -145,44 +131,44 @@
/* (non-Javadoc)
* @see org.drools.common.BetaNodeConstraints#updateFromTuple(org.drools.reteoo.ReteTuple)
*/
- public void updateFromTuple(ReteTuple tuple) {
- context0.updateFromTuple( tuple );
- context1.updateFromTuple( tuple );
- context2.updateFromTuple( tuple );
+ public void updateFromTuple(final ReteTuple tuple) {
+ this.context0.updateFromTuple( tuple );
+ this.context1.updateFromTuple( tuple );
+ this.context2.updateFromTuple( tuple );
}
/* (non-Javadoc)
* @see org.drools.common.BetaNodeConstraints#updateFromFactHandle(org.drools.common.InternalFactHandle)
*/
- public void updateFromFactHandle(InternalFactHandle handle) {
- context0.updateFromFactHandle( handle );
- context1.updateFromFactHandle( handle );
- context2.updateFromFactHandle( handle );
+ public void updateFromFactHandle(final InternalFactHandle handle) {
+ this.context0.updateFromFactHandle( handle );
+ this.context1.updateFromFactHandle( handle );
+ this.context2.updateFromFactHandle( handle );
}
/* (non-Javadoc)
* @see org.drools.common.BetaNodeConstraints#isAllowedCachedLeft(java.lang.Object)
*/
- public boolean isAllowedCachedLeft(Object object) {
+ public boolean isAllowedCachedLeft(final Object object) {
// return ( this.indexed0 || this.constraint0.isAllowedCachedLeft( context0,
// object ) ) && this.constraint1.isAllowedCachedLeft( context1,
// object ) && this.constraint2.isAllowedCachedLeft( context2,
// object );
- return (this.indexed0 || this.constraint0.isAllowedCachedLeft( context0,
- object )) && (this.indexed1 || this.constraint1.isAllowedCachedLeft( context1,
- object )) && (this.indexed2 || this.constraint2.isAllowedCachedLeft( context2,
- object ) );
+ return (this.indexed0 || this.constraint0.isAllowedCachedLeft( this.context0,
+ object )) && (this.indexed1 || this.constraint1.isAllowedCachedLeft( this.context1,
+ object )) && (this.indexed2 || this.constraint2.isAllowedCachedLeft( this.context2,
+ object ));
}
/* (non-Javadoc)
* @see org.drools.common.BetaNodeConstraints#isAllowedCachedRight(org.drools.reteoo.ReteTuple)
*/
- public boolean isAllowedCachedRight(ReteTuple tuple) {
+ public boolean isAllowedCachedRight(final ReteTuple tuple) {
return this.constraint0.isAllowedCachedRight( tuple,
- context0 ) && this.constraint1.isAllowedCachedRight( tuple,
- context1 ) && this.constraint1.isAllowedCachedRight( tuple,
- context1 );
+ this.context0 ) && this.constraint1.isAllowedCachedRight( tuple,
+ this.context1 ) && this.constraint1.isAllowedCachedRight( tuple,
+ this.context1 );
}
public boolean isIndexed() {
@@ -209,33 +195,33 @@
BetaMemory memory;
- List list = new ArrayList( 2 );
+ final List list = new ArrayList( 2 );
if ( this.indexed0 ) {
- VariableConstraint variableConstraint = (VariableConstraint) this.constraint0;
- FieldIndex index = new FieldIndex( variableConstraint.getFieldExtractor(),
- variableConstraint.getRequiredDeclarations()[0] );
+ final VariableConstraint variableConstraint = (VariableConstraint) this.constraint0;
+ final FieldIndex index = new FieldIndex( variableConstraint.getFieldExtractor(),
+ variableConstraint.getRequiredDeclarations()[0] );
list.add( index );
}
if ( this.indexed1 ) {
- VariableConstraint variableConstraint = (VariableConstraint) this.constraint1;
- FieldIndex index = new FieldIndex( variableConstraint.getFieldExtractor(),
- variableConstraint.getRequiredDeclarations()[0] );
+ final VariableConstraint variableConstraint = (VariableConstraint) this.constraint1;
+ final FieldIndex index = new FieldIndex( variableConstraint.getFieldExtractor(),
+ variableConstraint.getRequiredDeclarations()[0] );
list.add( index );
}
-
+
if ( this.indexed2 ) {
- VariableConstraint variableConstraint = (VariableConstraint) this.constraint2;
- FieldIndex index = new FieldIndex( variableConstraint.getFieldExtractor(),
- variableConstraint.getRequiredDeclarations()[0] );
+ final VariableConstraint variableConstraint = (VariableConstraint) this.constraint2;
+ final FieldIndex index = new FieldIndex( variableConstraint.getFieldExtractor(),
+ variableConstraint.getRequiredDeclarations()[0] );
list.add( index );
- }
+ }
if ( !list.isEmpty() ) {
- FieldIndex[] indexes = (FieldIndex[]) list.toArray( new FieldIndex[list.size()] );
+ final FieldIndex[] indexes = (FieldIndex[]) list.toArray( new FieldIndex[list.size()] );
memory = new BetaMemory( new TupleHashTable(),
- new CompositeFieldIndexHashTable( indexes ) );
+ new FieldIndexHashTable( indexes ) );
} else {
memory = new BetaMemory( new TupleHashTable(),
new FactHashTable() );
@@ -263,7 +249,7 @@
* @see org.drools.common.BetaNodeConstraints#getConstraints()
*/
public LinkedList getConstraints() {
- LinkedList list = new LinkedList();
+ final LinkedList list = new LinkedList();
list.add( new LinkedListEntry( this.constraint0 ) );
list.add( new LinkedListEntry( this.constraint1 ) );
list.add( new LinkedListEntry( this.constraint2 ) );
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/TruthMaintenanceSystem.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/TruthMaintenanceSystem.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/TruthMaintenanceSystem.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -1,4 +1,5 @@
package org.drools.common;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -18,7 +19,6 @@
import java.io.Serializable;
import java.util.HashSet;
import java.util.Iterator;
-import java.util.Map;
import java.util.Set;
import org.drools.FactException;
@@ -38,10 +38,12 @@
* @author <a href="mailto:mark.proctor at jboss.com">Mark Proctor</a>
*
*/
-public class TruthMaintenanceSystem implements Serializable {
-
- private static final long serialVersionUID = 320L;
+public class TruthMaintenanceSystem
+ implements
+ Serializable {
+ private static final long serialVersionUID = 320L;
+
private final AbstractWorkingMemory WorkingMemory;
private final PrimitiveLongMap justifiedMap;
@@ -52,7 +54,7 @@
this.WorkingMemory = workingMemory;
this.justifiedMap = new PrimitiveLongMap( 8,
- 32 );
+ 32 );
this.assertMap = new ObjectHashMap();
this.assertMap.setComparator( EqualityKeyComparator.getInstance() );
}
@@ -67,7 +69,7 @@
public Object put(final EqualityKey key) {
return this.assertMap.put( key,
- key,
+ key,
false );
}
@@ -104,17 +106,17 @@
for ( LogicalDependency node = (LogicalDependency) list.getFirst(); node != null; node = (LogicalDependency) node.getNext() ) {
final InternalFactHandle handle = (InternalFactHandle) node.getFactHandle();
final Set set = (Set) this.justifiedMap.get( handle.getId() );
- if (set != null) {
+ if ( set != null ) {
set.remove( node );
- if (set.isEmpty( )) {
- this.justifiedMap.remove( handle.getId( ) );
+ if ( set.isEmpty() ) {
+ this.justifiedMap.remove( handle.getId() );
// this needs to be scheduled so we don't upset the current
// working memory operation
this.WorkingMemory.queueRetractAction( handle,
false,
true,
- context.getRuleOrigin( ),
- context.getActivationOrigin( ) );
+ context.getRuleOrigin(),
+ context.getActivationOrigin() );
}
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/conflict/TotalRecencyConflictResolver.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/conflict/TotalRecencyConflictResolver.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/conflict/TotalRecencyConflictResolver.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -75,10 +75,10 @@
long leftRecency = 0;
long rightRecency = 0;
if ( lhs.getTuple() instanceof ReteTuple ) {
- leftRecency = ((Tuple) lhs.getTuple()).getRecency();
+ leftRecency = (lhs.getTuple()).getRecency();
}
if ( rhs.getTuple() instanceof ReteTuple ) {
- rightRecency = ((Tuple) rhs.getTuple()).getRecency();
+ rightRecency = (rhs.getTuple()).getRecency();
}
return (rightRecency > leftRecency) ? 1 : (rightRecency < leftRecency) ? -1 : 0;
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/facttemplates/Fact.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/facttemplates/Fact.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/facttemplates/Fact.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -16,7 +16,6 @@
*/
package org.drools.facttemplates;
-
/**
* @author Peter Lin
*
@@ -30,13 +29,15 @@
* @return
*/
Object getFieldValue(int index);
-
+
Object getFieldValue(String name);
-
- void setFieldValue(String name, Object value);
-
- void setFieldValue(int index, Object value);
+ void setFieldValue(String name,
+ Object value);
+
+ void setFieldValue(int index,
+ Object value);
+
/**
* Return the unique ID for the fact
* @return
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/facttemplates/FactImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/facttemplates/FactImpl.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/facttemplates/FactImpl.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -19,7 +19,6 @@
import java.io.Serializable;
import java.util.Arrays;
-
//import woolfel.engine.rule.Rule;
/**
@@ -28,11 +27,16 @@
* Deffact is a concrete implementation of Fact interface. It is
* equivalent to deffact in CLIPS.
*/
-public class FactImpl implements Fact, Serializable {
+public class FactImpl
+ implements
+ Fact,
+ Serializable {
- private static int hashCode(Object[] array) {
+ private static int hashCode(final Object[] array) {
final int PRIME = 31;
- if ( array == null ) return 0;
+ if ( array == null ) {
+ return 0;
+ }
int result = 1;
for ( int index = 0; index < array.length; index++ ) {
result = PRIME * result + (array[index] == null ? 0 : array[index].hashCode());
@@ -41,61 +45,63 @@
}
private FactTemplate factTemplate = null;
- private Object[] values = null;
- private int hashCode;
-
+ private Object[] values = null;
+ private int hashCode;
+
/**
* the Fact id must be unique, since we use it for the indexes
*/
- private long id;
-
+ private long id;
+
/**
* this is the default constructor
* @param instance
* @param values
*/
- public FactImpl(FactTemplate template, Object[] values, long id){
+ public FactImpl(final FactTemplate template,
+ final Object[] values,
+ final long id) {
this.factTemplate = template;
- this.values= values;
+ this.values = values;
this.id = id;
}
- public FactImpl(FactTemplate template, long id){
+ public FactImpl(final FactTemplate template,
+ final long id) {
this.factTemplate = template;
- this.values= new Object[ template.getNumberOfFields() ];
+ this.values = new Object[template.getNumberOfFields()];
this.id = id;
- }
-
+ }
+
/**
* Method returns the value of the given slot at the
* id.
* @param id
* @return
*/
- public Object getFieldValue(int index){
- return this.values[ index ];
+ public Object getFieldValue(final int index) {
+ return this.values[index];
}
-
- public Object getFieldValue(String name){
- return this.values[ this.factTemplate.getFieldTemplateIndex( name ) ];
+
+ public Object getFieldValue(final String name) {
+ return this.values[this.factTemplate.getFieldTemplateIndex( name )];
}
-
-
-
- public void setFieldValue(String name, Object value) {
+
+ public void setFieldValue(final String name,
+ final Object value) {
setFieldValue( this.factTemplate.getFieldTemplateIndex( name ),
value );
}
-
- public void setFieldValue(int index, Object value) {
- this.values[ index ] = value;
+
+ public void setFieldValue(final int index,
+ final Object value) {
+ this.values[index] = value;
}
-
/**
* Return the long factId
*/
- public long getFactId(){
+ public long getFactId() {
return this.id;
}
@@ -104,49 +110,49 @@
* assert the same fact again, we reset the id to the existing one.
* @param fact
*/
- protected void resetId(Fact fact) {
- this.id = fact.getFactId();
+ protected void resetId(final Fact fact) {
+ this.id = fact.getFactId();
}
-
+
/**
* Return the deftemplate for the fact
*/
- public FactTemplate getFactTemplate(){
+ public FactTemplate getFactTemplate() {
return this.factTemplate;
- }
-
+ }
+
public int hashCode() {
- if ( hashCode == 0 ) {
+ if ( this.hashCode == 0 ) {
final int PRIME = 31;
int result = 1;
result = PRIME * result + this.factTemplate.hashCode();
result = PRIME * result + FactImpl.hashCode( this.values );
- hashCode = result;
-
+ this.hashCode = result;
+
}
return this.hashCode;
}
- public boolean equals(Object object) {
+ public boolean equals(final Object object) {
if ( this == object ) {
return true;
}
-
+
if ( object == null || FactImpl.class != object.getClass() ) {
return false;
}
-
- final FactImpl other = ( FactImpl ) object;
+ final FactImpl other = (FactImpl) object;
+
if ( !this.factTemplate.equals( other.factTemplate ) ) {
return false;
}
-
+
if ( !Arrays.equals( this.values,
other.values ) ) {
return false;
}
-
+
return true;
- }
+ }
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/facttemplates/FactTemplate.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/facttemplates/FactTemplate.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/facttemplates/FactTemplate.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -20,7 +20,6 @@
import org.drools.rule.Package;
-
/**
* @author Peter Lin
*
@@ -31,9 +30,9 @@
public interface FactTemplate
extends
Serializable {
-
+
Package getPackage();
-
+
/**
* The name of the template may be the fully qualified
* class name, or an alias.
@@ -73,6 +72,6 @@
* @return
*/
int getFieldTemplateIndex(String name);
-
+
Fact createFact(long id);
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/facttemplates/FactTemplateFieldExtractor.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/facttemplates/FactTemplateFieldExtractor.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/facttemplates/FactTemplateFieldExtractor.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -7,70 +7,61 @@
implements
FieldExtractor {
- private static final long serialVersionUID = 320;
- private FactTemplate factTemplate;
- private int fieldIndex;
+ private static final long serialVersionUID = 320;
+ private FactTemplate factTemplate;
+ private int fieldIndex;
public FactTemplateFieldExtractor(final FactTemplate factTemplate,
- final int fieldIndex) {
+ final int fieldIndex) {
this.factTemplate = factTemplate;
this.fieldIndex = fieldIndex;
}
-
-
+
public ValueType getValueType() {
- return this.factTemplate.getFieldTemplate( fieldIndex ).getValueType();
- }
+ return this.factTemplate.getFieldTemplate( this.fieldIndex ).getValueType();
+ }
- public Object getValue(Object object) {
+ public Object getValue(final Object object) {
return ((Fact) object).getFieldValue( this.fieldIndex );
}
-
+
public int getIndex() {
return this.fieldIndex;
}
-
+
public Class getExtractToClass() {
return Fact.class;//this.factTemplate.getFieldTemplate( fieldIndex ).getValueType().getClass();
}
-
- public boolean getBooleanValue(Object object) {
- return ((Boolean)((Fact) object).getFieldValue( this.fieldIndex )).booleanValue();
+ public boolean getBooleanValue(final Object object) {
+ return ((Boolean) ((Fact) object).getFieldValue( this.fieldIndex )).booleanValue();
}
-
- public byte getByteValue(Object object) {
- return ((Number)((Fact) object).getFieldValue( this.fieldIndex )).byteValue();
+ public byte getByteValue(final Object object) {
+ return ((Number) ((Fact) object).getFieldValue( this.fieldIndex )).byteValue();
}
-
- public char getCharValue(Object object) {
- return ((Character)((Fact) object).getFieldValue( this.fieldIndex )).charValue();
+ public char getCharValue(final Object object) {
+ return ((Character) ((Fact) object).getFieldValue( this.fieldIndex )).charValue();
}
-
- public double getDoubleValue(Object object) {
- return ((Number)((Fact) object).getFieldValue( this.fieldIndex )).doubleValue();
+ public double getDoubleValue(final Object object) {
+ return ((Number) ((Fact) object).getFieldValue( this.fieldIndex )).doubleValue();
}
-
- public float getFloatValue(Object object) {
- return ((Number)((Fact) object).getFieldValue( this.fieldIndex )).floatValue();
+ public float getFloatValue(final Object object) {
+ return ((Number) ((Fact) object).getFieldValue( this.fieldIndex )).floatValue();
}
-
- public int getIntValue(Object object) {
- return ((Number)((Fact) object).getFieldValue( this.fieldIndex )).intValue();
+ public int getIntValue(final Object object) {
+ return ((Number) ((Fact) object).getFieldValue( this.fieldIndex )).intValue();
}
-
- public long getLongValue(Object object) {
- return ((Number)((Fact) object).getFieldValue( this.fieldIndex )).longValue();
+ public long getLongValue(final Object object) {
+ return ((Number) ((Fact) object).getFieldValue( this.fieldIndex )).longValue();
}
-
- public short getShortValue(Object object) {
- return ((Number)((Fact) object).getFieldValue( this.fieldIndex )).shortValue();
+ public short getShortValue(final Object object) {
+ return ((Number) ((Fact) object).getFieldValue( this.fieldIndex )).shortValue();
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/facttemplates/FactTemplateImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/facttemplates/FactTemplateImpl.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/facttemplates/FactTemplateImpl.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -20,7 +20,6 @@
import org.drools.rule.Package;
-
/**
* @author Peter Lin
* Deftemplate is equivalent to CLIPS deftemplate<br/>
@@ -38,10 +37,14 @@
* approach is very costly and would make redeclaring a deftemplate
* undesirable.
*/
-public class FactTemplateImpl implements FactTemplate {
- private static int hashCode(Object[] array) {
+public class FactTemplateImpl
+ implements
+ FactTemplate {
+ private static int hashCode(final Object[] array) {
final int PRIME = 31;
- if ( array == null ) return 0;
+ if ( array == null ) {
+ return 0;
+ }
int result = 1;
for ( int index = 0; index < array.length; index++ ) {
result = PRIME * result + (array[index] == null ? 0 : array[index].hashCode());
@@ -50,25 +53,27 @@
}
private FieldTemplate[] fields;
- private Package pkg;
- private String name;
+ private Package pkg;
+ private String name;
- public FactTemplateImpl(Package pkg, String name, FieldTemplate[] fields){
+ public FactTemplateImpl(final Package pkg,
+ final String name,
+ final FieldTemplate[] fields) {
this.pkg = pkg;
this.name = name;
this.fields = fields;
- this.pkg.addFactTemplate( this );
+ this.pkg.addFactTemplate( this );
}
-
+
public Package getPackage() {
return this.pkg;
}
-
+
/**
* the template name is an alias for an object
* @param name
*/
- public String getName(){
+ public String getName() {
return this.name;
}
@@ -76,83 +81,84 @@
* Return the number of slots in the deftemplate
* @return
*/
- public int getNumberOfFields(){
+ public int getNumberOfFields() {
return this.fields.length;
}
-
+
/**
* Return all the slots
* @return
*/
- public FieldTemplate[] getAllFieldTemplates(){
+ public FieldTemplate[] getAllFieldTemplates() {
return this.fields;
}
-
+
/**
* A convienance method for finding the slot matching
* the String name.
* @param name
* @return
*/
- public FieldTemplate getFieldTemplate(String name) {
- for (int idx=0; idx < this.fields.length; idx++) {
- if (this.fields[idx].getName().equals(name)) {
+ public FieldTemplate getFieldTemplate(final String name) {
+ for ( int idx = 0; idx < this.fields.length; idx++ ) {
+ if ( this.fields[idx].getName().equals( name ) ) {
return this.fields[idx];
}
}
return null;
}
-
+
/**
* get the Slot at the given column id
* @param id
* @return
*/
- public FieldTemplate getFieldTemplate(int index) {
+ public FieldTemplate getFieldTemplate(final int index) {
return this.fields[index];
}
-
+
/**
* Look up the column index of the slot
* @param name
* @return
*/
- public int getFieldTemplateIndex(String name) {
- for (int index=0; index < this.fields.length; index++) {
- if (this.fields[index].getName().equals(name)) {
+ public int getFieldTemplateIndex(final String name) {
+ for ( int index = 0; index < this.fields.length; index++ ) {
+ if ( this.fields[index].getName().equals( name ) ) {
return index;
}
}
return -1;
}
-
+
/**
* Method takes a list of Slots and creates a deffact from it.
* @param data
* @param id
* @return
*/
- public Fact createFact(long id) {
- return new FactImpl(this, id);
+ public Fact createFact(final long id) {
+ return new FactImpl( this,
+ id );
}
-
+
/**
* Method will return a string format with the int type code
* for the slot type
*/
- public String toString(){
- StringBuffer buf = new StringBuffer();
- buf.append("(" + this.name + " ");
-// for (int idx=0; idx < this.slots.length; idx++){
-// buf.append("(" + this.slots[idx].getName() +
-// " (type " + ConversionUtils.getTypeName(
-// this.slots[idx].getValueType()) +
-// ") ) ");
-// }
-// if (this.clazz != null){
-// buf.append("[" + this.clazz.getClassObject().getName() + "] ");
-// }
- buf.append(")");
+ public String toString() {
+ final StringBuffer buf = new StringBuffer();
+ buf.append( "(" + this.name + " " );
+ // for (int idx=0; idx < this.slots.length; idx++){
+ // buf.append("(" + this.slots[idx].getName() +
+ // " (type " + ConversionUtils.getTypeName(
+ // this.slots[idx].getValueType()) +
+ // ") ) ");
+ // }
+ // if (this.clazz != null){
+ // buf.append("[" + this.clazz.getClassObject().getName() + "] ");
+ // }
+ buf.append( ")" );
return buf.toString();
}
@@ -165,22 +171,22 @@
return result;
}
- public boolean equals(Object object) {
+ public boolean equals(final Object object) {
if ( this == object ) {
return true;
}
-
+
if ( object == null || getClass() != object.getClass() ) {
return false;
}
-
+
final FactTemplateImpl other = (FactTemplateImpl) object;
if ( !Arrays.equals( this.fields,
- other.fields ) ) return false;
-
- return this.pkg.equals( other.pkg ) && this.name.equals( other.name );
+ other.fields ) ) {
+ return false;
+ }
+
+ return this.pkg.equals( other.pkg ) && this.name.equals( other.name );
}
-
-
-
+
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/facttemplates/FactTemplateObjectType.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/facttemplates/FactTemplateObjectType.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/facttemplates/FactTemplateObjectType.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -1,6 +1,5 @@
package org.drools.facttemplates;
-
/*
* Copyright 2005 JBoss Inc
*
@@ -40,7 +39,7 @@
private static final long serialVersionUID = 320;
/** FieldTemplate. */
- protected FactTemplate factTemplate;
+ protected FactTemplate factTemplate;
// ------------------------------------------------------------
// Constructors
@@ -66,7 +65,7 @@
* @return The Fact Template
*/
public FactTemplate getFactTemplate() {
- return this.factTemplate;
+ return this.factTemplate;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -85,18 +84,17 @@
*/
public boolean matches(final Object object) {
if ( object.getClass() == FactImpl.class ) {
- return this.factTemplate.equals( ( (Fact) object ).getFactTemplate() );
+ return this.factTemplate.equals( ((Fact) object).getFactTemplate() );
} else {
return false;
}
}
-
public ValueType getValueType() {
return ValueType.FACTTEMPLATE_TYPE;
}
- public Object getShadow(Object fact) {
+ public Object getShadow(final Object fact) {
// @TODO: shadow not implemented for templates yet
return null;
}
@@ -105,7 +103,7 @@
// @TODO: shadow not implemented for templates yet
return false;
}
-
+
public String toString() {
return "[ClassObjectType class=" + this.factTemplate.getName() + "]";
}
@@ -128,8 +126,8 @@
return false;
}
- FactTemplateObjectType other = ( FactTemplateObjectType ) object;
-
+ final FactTemplateObjectType other = (FactTemplateObjectType) object;
+
return this.factTemplate.equals( other.factTemplate );
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/facttemplates/FieldTemplateImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/facttemplates/FieldTemplateImpl.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/facttemplates/FieldTemplateImpl.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -12,9 +12,9 @@
private final int index;
private final ValueType valueType;
- public FieldTemplateImpl(String name,
- int index,
- Class clazz) {
+ public FieldTemplateImpl(final String name,
+ final int index,
+ final Class clazz) {
this.name = name;
this.index = index;
this.valueType = ValueType.determineValueType( clazz );
@@ -50,19 +50,18 @@
return result;
}
- public boolean equals(Object object) {
+ public boolean equals(final Object object) {
if ( this == object ) {
return true;
}
-
+
if ( object == null || getClass() != object.getClass() ) {
return false;
}
-
+
final FieldTemplateImpl other = (FieldTemplateImpl) object;
-
+
return this.index == other.index && this.name.equals( other.name ) && this.valueType.equals( other.valueType );
}
-
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/AlphaMemory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/AlphaMemory.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/AlphaMemory.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -1,32 +1,35 @@
package org.drools.leaps;
+import org.apache.commons.collections.map.IdentityMap;
import org.drools.WorkingMemory;
import org.drools.common.InternalFactHandle;
import org.drools.spi.AlphaNodeFieldConstraint;
import org.drools.spi.Tuple;
-import org.drools.util.IdentityMap;
class AlphaMemory {
- private IdentityMap alphaChecks = new IdentityMap( );
+ private final IdentityMap alphaChecks = new IdentityMap();
AlphaMemory() {
}
- boolean checkAlpha( final AlphaNodeFieldConstraint alpha,
- final InternalFactHandle factHandle,
- final Tuple tuple,
- final WorkingMemory workingMemory ) {
+ boolean checkAlpha(final AlphaNodeFieldConstraint alpha,
+ final InternalFactHandle factHandle,
+ final Tuple tuple,
+ final WorkingMemory workingMemory) {
Boolean ret = (Boolean) this.alphaChecks.get( factHandle );
- if (ret == null) {
- ret = new Boolean( alpha.isAllowed( factHandle.getObject(), tuple, workingMemory ) );
- this.alphaChecks.put( factHandle, ret );
+ if ( ret == null ) {
+ ret = new Boolean( alpha.isAllowed( factHandle.getObject(),
+ tuple,
+ workingMemory ) );
+ this.alphaChecks.put( factHandle,
+ ret );
}
- return ret.booleanValue( );
+ return ret.booleanValue();
}
-
- boolean isAlphaBeenChecked(final InternalFactHandle factHandle){
+
+ boolean isAlphaBeenChecked(final InternalFactHandle factHandle) {
return this.alphaChecks != null && this.alphaChecks.containsKey( factHandle );
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/Builder.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/Builder.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/Builder.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -83,7 +83,8 @@
evalConditions.add( eval );
} else {
if ( object instanceof Column ) {
- constraints = Builder.processColumn( (Column) object, true );
+ constraints = Builder.processColumn( (Column) object,
+ true );
// create column constraints
} else {
// NOTS and EXISTS
@@ -91,7 +92,8 @@
while ( !(ce.getChildren().get( 0 ) instanceof Column) ) {
ce = (GroupElement) ce.getChildren().get( 0 );
}
- constraints = Builder.processColumn( (Column) ce.getChildren().get( 0 ) , false);
+ constraints = Builder.processColumn( (Column) ce.getChildren().get( 0 ),
+ false );
}
if ( object instanceof Not ) {
notCols.add( constraints );
@@ -156,40 +158,41 @@
* @return leaps packaged ColumnConstraints
*/
final private static ColumnConstraints processColumn(final Column column,
- final boolean removeIdentities ) {
+ final boolean removeIdentities) {
BetaConstraints binder;
- final List alphaConstraints = new ArrayList( );
- final List predicateConstraints = new ArrayList( );
+ final List alphaConstraints = new ArrayList();
+ final List predicateConstraints = new ArrayList();
- final List constraints = column.getConstraints( );
+ final List constraints = column.getConstraints();
- Map declarations = new HashMap( );
+ final Map declarations = new HashMap();
- if (column.getDeclaration( ) != null) {
- final Declaration declaration = column.getDeclaration( );
+ if ( column.getDeclaration() != null ) {
+ final Declaration declaration = column.getDeclaration();
// Add the declaration the map of previously bound declarations
- declarations.put( declaration.getIdentifier( ), declaration );
+ declarations.put( declaration.getIdentifier(),
+ declaration );
}
- for (final Iterator it = constraints.iterator( ); it.hasNext( );) {
- final Object object = it.next( );
+ for ( final Iterator it = constraints.iterator(); it.hasNext(); ) {
+ final Object object = it.next();
// Check if its a declaration
- if (object instanceof Declaration) {
+ if ( object instanceof Declaration ) {
final Declaration declaration = (Declaration) object;
// Add the declaration the map of previously bound declarations
- declarations.put( declaration.getIdentifier( ), declaration );
+ declarations.put( declaration.getIdentifier(),
+ declaration );
continue;
}
final AlphaNodeFieldConstraint fieldConstraint = (AlphaNodeFieldConstraint) object;
if ( fieldConstraint.getRequiredDeclarations().length == 0 ) {
- alphaConstraints.add( fieldConstraint);
+ alphaConstraints.add( fieldConstraint );
} else {
predicateConstraints.add( fieldConstraint );
}
}
-
if ( !predicateConstraints.isEmpty() ) {
binder = new DefaultBetaConstraints( (AlphaNodeFieldConstraint[]) predicateConstraints.toArray( new AlphaNodeFieldConstraint[predicateConstraints.size()] ) );
} else {
@@ -200,13 +203,15 @@
alphaConstraints,
binder );
}
+
/**
* Make sure the required declarations are previously bound
*
* @param declarations
* @throws InvalidPatternException
*/
- private static void checkUnboundDeclarations(final Map declarations, final Declaration[] requiredDeclarations) throws InvalidPatternException {
+ private static void checkUnboundDeclarations(final Map declarations,
+ final Declaration[] requiredDeclarations) throws InvalidPatternException {
final List list = new ArrayList();
for ( int i = 0, length = requiredDeclarations.length; i < length; i++ ) {
if ( declarations.get( requiredDeclarations[i].getIdentifier() ) == null ) {
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/ColumnConstraints.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/ColumnConstraints.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/ColumnConstraints.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -32,16 +32,18 @@
* @author Alexander Bagerman
*
*/
-public class ColumnConstraints implements Serializable {
- private Object classType;
+public class ColumnConstraints
+ implements
+ Serializable {
+ private Object classType;
private final AlphaNodeFieldConstraint[] alphaConstraints;
- private final boolean alphaPresent;
+ private final boolean alphaPresent;
- private final BetaConstraints beta;
+ private final BetaConstraints beta;
- private final boolean betaPresent;
+ private final boolean betaPresent;
public ColumnConstraints(final Column column,
final List alpha,
@@ -110,12 +112,12 @@
protected final boolean isAlphaPresent() {
return this.alphaPresent;
}
-
+
protected AlphaNodeFieldConstraint[] getAlphaContraints() {
return this.alphaConstraints;
}
-
+
protected AlphaNodeFieldConstraint[] getBetaContraints() {
- return this.beta.getConstraints( );
+ return this.beta.getConstraints();
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/ConflictResolver.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/ConflictResolver.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/ConflictResolver.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -26,7 +26,9 @@
* @author Alexander Bagerman
*
*/
-public interface ConflictResolver extends Serializable {
+public interface ConflictResolver
+ extends
+ Serializable {
public Comparator getFactConflictResolver();
public Comparator getRuleConflictResolver();
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/FactHandleTupleAssembly.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/FactHandleTupleAssembly.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/FactHandleTupleAssembly.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -28,17 +28,16 @@
*/
class FactHandleTupleAssembly {
- final LeapsTuple tuple;
+ final LeapsTuple tuple;
- final int index;
-
- final int type;
+ final int index;
+ final int type;
+
public final static int EXISTS = 1;
-
- public final static int NOT = 2;
-
-
+
+ public final static int NOT = 2;
+
FactHandleTupleAssembly(final int type,
final LeapsTuple tuple,
final int index) {
@@ -56,6 +55,6 @@
}
public int getType() {
- return type;
+ return this.type;
}
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/FactTable.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/FactTable.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/FactTable.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -19,13 +19,13 @@
import java.util.Comparator;
import java.util.Iterator;
+import org.apache.commons.collections.map.IdentityMap;
import org.drools.common.DefaultFactHandle;
import org.drools.common.PropagationContextImpl;
import org.drools.leaps.util.Table;
import org.drools.leaps.util.TableIterator;
import org.drools.spi.PropagationContext;
import org.drools.spi.Tuple;
-import org.drools.util.IdentityMap;
/**
* Implementation of a container to store data elements used throughout the
@@ -66,11 +66,11 @@
* @param ruleConflictResolver
*/
public FactTable(final ConflictResolver conflictResolver) {
- super( conflictResolver.getFactConflictResolver( ) );
- this.rules = new RuleTable( conflictResolver.getRuleConflictResolver( ) );
+ super( conflictResolver.getFactConflictResolver() );
+ this.rules = new RuleTable( conflictResolver.getRuleConflictResolver() );
this.tuples = new IdentityMap();
- this.comparator = conflictResolver.getFactConflictResolver( );
- this.notAndExistsHashedTables = new IdentityMap( );
+ this.comparator = conflictResolver.getFactConflictResolver();
+ this.notAndExistsHashedTables = new IdentityMap();
}
/**
@@ -79,9 +79,9 @@
* @param workingMemory
* @param ruleHandle
*/
- public void addRule( final LeapsWorkingMemory workingMemory,
- final LeapsRuleHandle ruleHandle ) {
- if (!this.rules.contains( ruleHandle )) {
+ public void addRule(final LeapsWorkingMemory workingMemory,
+ final LeapsRuleHandle ruleHandle) {
+ if ( !this.rules.contains( ruleHandle ) ) {
this.rules.add( ruleHandle );
// push facts back to stack if needed
this.checkAndAddFactsToStack( workingMemory );
@@ -93,13 +93,13 @@
*
* @param ruleHandle
*/
- public void removeRule( final LeapsWorkingMemory workingMemory,
- final LeapsRuleHandle ruleHandle ) {
+ public void removeRule(final LeapsWorkingMemory workingMemory,
+ final LeapsRuleHandle ruleHandle) {
this.rules.remove( ruleHandle );
// remove tuples that are still there
- for (final Iterator it = this.getTuplesIterator( ); it.hasNext( );) {
- final LeapsTuple tuple = (LeapsTuple) it.next( );
- if (ruleHandle.getLeapsRule( ).getRule( ) == tuple.getLeapsRule( ).getRule( )) {
+ for ( final Iterator it = this.getTuplesIterator(); it.hasNext(); ) {
+ final LeapsTuple tuple = (LeapsTuple) it.next();
+ if ( ruleHandle.getLeapsRule().getRule() == tuple.getLeapsRule().getRule() ) {
this.tuples.remove( tuple );
}
}
@@ -114,24 +114,26 @@
* memory
*
*/
- private void checkAndAddFactsToStack( final LeapsWorkingMemory workingMemory ) {
- if (this.reseededStack) {
+ private void checkAndAddFactsToStack(final LeapsWorkingMemory workingMemory) {
+ if ( this.reseededStack ) {
this.setReseededStack( false );
- final PropagationContextImpl context = new PropagationContextImpl( workingMemory.nextPropagationIdCounter( ),
+ final PropagationContextImpl context = new PropagationContextImpl( workingMemory.nextPropagationIdCounter(),
PropagationContext.ASSERTION,
null,
null );
// let's only add facts below waterline - added before rule is added
// rest would be added to stack automatically
- final DefaultFactHandle startFactHandle = new DefaultFactHandle( workingMemory.getIdLastFireAllAt( ),
- new Object( ) );
- for (final Iterator it = this.iteratorFromPositionToTableStart( startFactHandle, startFactHandle ); it.hasNext( );) {
- final LeapsFactHandle handle = (LeapsFactHandle) it.next( );
- workingMemory.pushTokenOnStack( handle, new Token( workingMemory,
- handle,
- context ) );
+ final DefaultFactHandle startFactHandle = new DefaultFactHandle( workingMemory.getIdLastFireAllAt(),
+ new Object() );
+ for ( final Iterator it = this.iteratorFromPositionToTableStart( startFactHandle,
+ startFactHandle ); it.hasNext(); ) {
+ final LeapsFactHandle handle = (LeapsFactHandle) it.next();
+ workingMemory.pushTokenOnStack( handle,
+ new Token( workingMemory,
+ handle,
+ context ) );
}
}
}
@@ -142,7 +144,7 @@
* @param new
* value
*/
- public void setReseededStack( final boolean reseeded ) {
+ public void setReseededStack(final boolean reseeded) {
this.reseededStack = reseeded;
}
@@ -153,106 +155,108 @@
* @return iterator of positive rule handles
*/
public Iterator getRulesIterator() {
- return this.rules.iterator( );
+ return this.rules.iterator();
}
/**
* @see java.lang.Object
*/
public String toString() {
- final StringBuffer ret = new StringBuffer( );
+ final StringBuffer ret = new StringBuffer();
- for (final Iterator it = this.iterator( ); it.hasNext( );) {
- final LeapsFactHandle handle = (LeapsFactHandle) it.next( );
- ret.append( "\n" + handle + "[" + handle.getObject( ) + "]" );
+ for ( final Iterator it = this.iterator(); it.hasNext(); ) {
+ final LeapsFactHandle handle = (LeapsFactHandle) it.next();
+ ret.append( "\n" + handle + "[" + handle.getObject() + "]" );
}
ret.append( "\nTuples :" );
- for (final Iterator it = this.tuples.values( ).iterator( ); it.hasNext( );) {
- ret.append( "\n" + it.next( ) );
+ for ( final Iterator it = this.tuples.values().iterator(); it.hasNext(); ) {
+ ret.append( "\n" + it.next() );
}
ret.append( "\nRules :" );
- for (final Iterator it = this.rules.iterator( ); it.hasNext( );) {
- final LeapsRuleHandle handle = (LeapsRuleHandle) it.next( );
- ret.append( "\n\t" + handle.getLeapsRule( ).getRule( ).getName( )
- + "[dominant - " + handle.getDominantPosition( ) + "]" );
+ for ( final Iterator it = this.rules.iterator(); it.hasNext(); ) {
+ final LeapsRuleHandle handle = (LeapsRuleHandle) it.next();
+ ret.append( "\n\t" + handle.getLeapsRule().getRule().getName() + "[dominant - " + handle.getDominantPosition() + "]" );
}
- return ret.toString( );
+ return ret.toString();
}
protected Iterator getTuplesIterator() {
- return this.tuples.values( ).iterator( );
+ return this.tuples.values().iterator();
}
- protected void addTuple( final LeapsTuple tuple ) {
- this.tuples.put( tuple,tuple );
+ protected void addTuple(final LeapsTuple tuple) {
+ this.tuples.put( tuple,
+ tuple );
}
- protected void removeTuple( final LeapsTuple tuple ) {
+ protected void removeTuple(final LeapsTuple tuple) {
this.tuples.remove( tuple );
}
-
+
private final IdentityMap notAndExistsHashedTables;
private final Comparator comparator;
-
- public void add( Object object ) {
+
+ public void add(final Object object) {
super.add( object );
- for (Iterator it = this.notAndExistsHashedTables.values( ).iterator( ); it.hasNext( );) {
+ for ( final Iterator it = this.notAndExistsHashedTables.values().iterator(); it.hasNext(); ) {
// this will also add link to hash into the leapsfacthandle
- ((HashedTableComponent)it.next( )).add( (LeapsFactHandle)object );
+ ((HashedTableComponent) it.next()).add( (LeapsFactHandle) object );
}
}
- public void remove( Object object ) {
+ public void remove(final Object object) {
super.remove( object );
// during modify we need to directly remove facts from participating
// hashes because modify can throw us off
- ((LeapsFactHandle)object ).removeFromHash();
+ ((LeapsFactHandle) object).removeFromHash();
}
- protected void createHashedSubTable(ColumnConstraints constraint) {
- this.notAndExistsHashedTables.put( constraint, new HashedTableComponent( constraint,
- this.comparator ) );
+ protected void createHashedSubTable(final ColumnConstraints constraint) {
+ this.notAndExistsHashedTables.put( constraint,
+ new HashedTableComponent( constraint,
+ this.comparator ) );
}
- protected TableIterator reverseOrderIterator( Tuple tuple, ColumnConstraints constraint ) {
- TableIterator ret = ( (HashedTableComponent) this.notAndExistsHashedTables.get( constraint ) ).reverseOrderIterator( tuple );
- if (ret == null){
- ret = Table.emptyIterator( );
+ protected TableIterator reverseOrderIterator(final Tuple tuple,
+ final ColumnConstraints constraint) {
+ TableIterator ret = ((HashedTableComponent) this.notAndExistsHashedTables.get( constraint )).reverseOrderIterator( tuple );
+ if ( ret == null ) {
+ ret = Table.emptyIterator();
}
return ret;
}
- protected TableIterator iteratorFromPositionToTableStart( Tuple tuple,
- ColumnConstraints constraint,
- LeapsFactHandle startFactHandle,
- LeapsFactHandle currentFactHandle ) {
- TableIterator ret = ( (HashedTableComponent) this.notAndExistsHashedTables.get( constraint ) ).iteratorFromPositionToTableStart( tuple,
- startFactHandle,
- currentFactHandle );
- if (ret == null) {
- ret = Table.emptyIterator( );
+ protected TableIterator iteratorFromPositionToTableStart(final Tuple tuple,
+ final ColumnConstraints constraint,
+ final LeapsFactHandle startFactHandle,
+ final LeapsFactHandle currentFactHandle) {
+ TableIterator ret = ((HashedTableComponent) this.notAndExistsHashedTables.get( constraint )).iteratorFromPositionToTableStart( tuple,
+ startFactHandle,
+ currentFactHandle );
+ if ( ret == null ) {
+ ret = Table.emptyIterator();
}
return ret;
}
- protected TableIterator iteratorFromPositionToTableEnd( Tuple tuple,
- ColumnConstraints constraint,
- LeapsFactHandle startFactHandle ) {
- TableIterator ret = ( (HashedTableComponent) this.notAndExistsHashedTables.get( constraint ) ).iteratorFromPositionToTableEnd( tuple,
- startFactHandle );
- if (ret == null) {
- ret = Table.emptyIterator( );
+ protected TableIterator iteratorFromPositionToTableEnd(final Tuple tuple,
+ final ColumnConstraints constraint,
+ final LeapsFactHandle startFactHandle) {
+ TableIterator ret = ((HashedTableComponent) this.notAndExistsHashedTables.get( constraint )).iteratorFromPositionToTableEnd( tuple,
+ startFactHandle );
+ if ( ret == null ) {
+ ret = Table.emptyIterator();
}
return ret;
}
-
- protected Iterator getHashedConstraints(){
- return this.notAndExistsHashedTables.keySet( ).iterator( );
+
+ protected Iterator getHashedConstraints() {
+ return this.notAndExistsHashedTables.keySet().iterator();
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/FromConstraint.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/FromConstraint.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/FromConstraint.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -9,17 +9,16 @@
public class FromConstraint extends ColumnConstraints {
private final DataProvider provider;
- public FromConstraint(Column column,
- DataProvider provider,
- ColumnConstraints constraints) {
+ public FromConstraint(final Column column,
+ final DataProvider provider,
+ final ColumnConstraints constraints) {
super( column,
- ( constraints.getAlphaContraints( ) == null || constraints.getAlphaContraints( ).length == 0 ) ? Arrays.asList( new FromConstraint[0] )
- : Arrays.asList( constraints.getAlphaContraints( ) ),
- new DefaultBetaConstraints( constraints.getBetaContraints( ) ) );
+ (constraints.getAlphaContraints() == null || constraints.getAlphaContraints().length == 0) ? Arrays.asList( new FromConstraint[0] ) : Arrays.asList( constraints.getAlphaContraints() ),
+ new DefaultBetaConstraints( constraints.getBetaContraints() ) );
this.provider = provider;
}
public DataProvider getProvider() {
- return provider;
+ return this.provider;
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/HashedTableComponent.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/HashedTableComponent.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/HashedTableComponent.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -12,7 +12,9 @@
import org.drools.rule.VariableConstraint;
import org.drools.spi.Tuple;
-public class HashedTableComponent implements Serializable{
+public class HashedTableComponent
+ implements
+ Serializable {
private final ColumnConstraints constraints;
private final int numberOfVariableConstraints;
@@ -22,130 +24,120 @@
private final Comparator comparator;
private final static Integer DEFAULT_HASH = new Integer( 0 );
-
- private final Table noConstraintsTable;
- public HashedTableComponent(ColumnConstraints constraints, Comparator comparator) {
+ private final Table noConstraintsTable;
+
+ public HashedTableComponent(final ColumnConstraints constraints,
+ final Comparator comparator) {
this.constraints = constraints;
this.comparator = comparator;
- this.buckets = new HashMap( );
- this.numberOfVariableConstraints = this.constraints.getBetaContraints( ).length;
- this.noConstraintsTable = new Table(this.comparator);
+ this.buckets = new HashMap();
+ this.numberOfVariableConstraints = this.constraints.getBetaContraints().length;
+ this.noConstraintsTable = new Table( this.comparator );
}
- public void add( LeapsFactHandle factHandle ) {
- Table table = this.getTable( factHandle);
- if (table != null) {
+ public void add(final LeapsFactHandle factHandle) {
+ final Table table = this.getTable( factHandle );
+ if ( table != null ) {
table.add( factHandle );
- factHandle.addHash(table);
+ factHandle.addHash( table );
}
}
- public TableIterator reverseOrderIterator( Tuple tuple ) {
- Table table = this.getTable( tuple );
- if (table != null) {
- return table.reverseOrderIterator( );
- }
- else {
+ public TableIterator reverseOrderIterator(final Tuple tuple) {
+ final Table table = this.getTable( tuple );
+ if ( table != null ) {
+ return table.reverseOrderIterator();
+ } else {
return null;
}
}
- public TableIterator iteratorFromPositionToTableEnd( Tuple tuple,
- LeapsFactHandle startFactHandle ) {
- Table table = this.getTable( tuple );
- if (table != null) {
+ public TableIterator iteratorFromPositionToTableEnd(final Tuple tuple,
+ final LeapsFactHandle startFactHandle) {
+ final Table table = this.getTable( tuple );
+ if ( table != null ) {
return table.iteratorFromPositionToTableEnd( startFactHandle );
- }
- else {
+ } else {
return null;
}
}
- public TableIterator iteratorFromPositionToTableStart( Tuple tuple,
- LeapsFactHandle startFactHandle,
- LeapsFactHandle currentFactHandle ) {
- Table table = this.getTable( tuple );
- if (table != null) {
+ public TableIterator iteratorFromPositionToTableStart(final Tuple tuple,
+ final LeapsFactHandle startFactHandle,
+ final LeapsFactHandle currentFactHandle) {
+ final Table table = this.getTable( tuple );
+ if ( table != null ) {
return table.iteratorFromPositionToTableStart( startFactHandle,
currentFactHandle );
- }
- else {
+ } else {
return null;
}
}
- private Table getTable( Tuple tuple ) {
+ private Table getTable(final Tuple tuple) {
Table ret = null;
- if (this.numberOfVariableConstraints > 0) {
+ if ( this.numberOfVariableConstraints > 0 ) {
Map currentMap = this.buckets;
- for (int i = 0; ( i < this.numberOfVariableConstraints )
- && ( currentMap != null ); i++) {
- Integer hash = DEFAULT_HASH;
- if (this.constraints.getBetaContraints( )[i] instanceof VariableConstraint
- && ( (VariableConstraint) this.constraints.getBetaContraints( )[i] ).getEvaluator( )
- .getOperator( ) == Operator.EQUAL) {
- Declaration declaration = this.constraints.getBetaContraints( )[i].getRequiredDeclarations( )[0];
- final Object select = declaration.getValue( tuple.get( declaration.getColumn( )
- .getFactIndex( ) )
- .getObject( ) );
- if (select != null) {
- hash = new Integer( select.hashCode( ) );
+ for ( int i = 0; (i < this.numberOfVariableConstraints) && (currentMap != null); i++ ) {
+ Integer hash = HashedTableComponent.DEFAULT_HASH;
+ if ( this.constraints.getBetaContraints()[i] instanceof VariableConstraint && ((VariableConstraint) this.constraints.getBetaContraints()[i]).getEvaluator().getOperator() == Operator.EQUAL ) {
+ final Declaration declaration = this.constraints.getBetaContraints()[i].getRequiredDeclarations()[0];
+ final Object select = declaration.getValue( tuple.get( declaration.getColumn().getFactIndex() ).getObject() );
+ if ( select != null ) {
+ hash = new Integer( select.hashCode() );
}
}
// put facts at the very bottom / last instance
- if (i != ( this.numberOfVariableConstraints - 1 )) {
+ if ( i != (this.numberOfVariableConstraints - 1) ) {
// we can not have null as a value to the key
currentMap = (Map) currentMap.get( hash );
- }
- else {
+ } else {
ret = (Table) currentMap.get( hash );
}
}
- }
- else {
+ } else {
ret = this.noConstraintsTable;
}
return ret;
}
- private Table getTable( LeapsFactHandle factHandle ) {
+ private Table getTable(final LeapsFactHandle factHandle) {
Table ret = null;
Map currentMap = this.buckets;
- if (this.constraints.isAllowedAlpha( factHandle, null, null )) {
- if (this.numberOfVariableConstraints > 0) {
- for (int i = 0; i < this.numberOfVariableConstraints; i++) {
- Integer hash = DEFAULT_HASH;
- if (this.constraints.getBetaContraints( )[i] instanceof VariableConstraint
- && ( (VariableConstraint) this.constraints.getBetaContraints( )[i] ).getEvaluator( )
- .getOperator( ) == Operator.EQUAL) {
- final Object select = ( (VariableConstraint) this.constraints.getBetaContraints( )[i] ).getFieldExtractor( )
- .getValue( factHandle.getObject( ) );
- if (select != null) {
- hash = new Integer( select.hashCode( ) );
+ if ( this.constraints.isAllowedAlpha( factHandle,
+ null,
+ null ) ) {
+ if ( this.numberOfVariableConstraints > 0 ) {
+ for ( int i = 0; i < this.numberOfVariableConstraints; i++ ) {
+ Integer hash = HashedTableComponent.DEFAULT_HASH;
+ if ( this.constraints.getBetaContraints()[i] instanceof VariableConstraint && ((VariableConstraint) this.constraints.getBetaContraints()[i]).getEvaluator().getOperator() == Operator.EQUAL ) {
+ final Object select = ((VariableConstraint) this.constraints.getBetaContraints()[i]).getFieldExtractor().getValue( factHandle.getObject() );
+ if ( select != null ) {
+ hash = new Integer( select.hashCode() );
}
}
// put facts at the very bottom / last instance
- if (i != ( this.numberOfVariableConstraints - 1 )) {
+ if ( i != (this.numberOfVariableConstraints - 1) ) {
// we can not have null as a value to the key
Map map = (Map) currentMap.get( hash );
- if (map == null) {
- map = new HashMap( );
- currentMap.put( hash, map );
+ if ( map == null ) {
+ map = new HashMap();
+ currentMap.put( hash,
+ map );
}
currentMap = map;
- }
- else {
+ } else {
Table table = (Table) currentMap.get( hash );
- if (table == null) {
+ if ( table == null ) {
table = new Table( this.comparator );
- currentMap.put( hash, table );
+ currentMap.put( hash,
+ table );
}
ret = table;
}
}
- }
- else {
+ } else {
return this.noConstraintsTable;
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/LeapsAgenda.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/LeapsAgenda.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/LeapsAgenda.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -41,17 +41,15 @@
this.workingMemory = workingMemory;
}
- public synchronized void fireActivation( final Activation activation )
- throws ConsequenceException {
- if (activation.getRule( ) instanceof Query) {
+ public synchronized void fireActivation(final Activation activation) throws ConsequenceException {
+ if ( activation.getRule() instanceof Query ) {
// put query results to the working memory location
- this.workingMemory.addToQueryResults( activation.getRule( ).getName( ),
- activation.getTuple( ) );
- }
- else {
+ this.workingMemory.addToQueryResults( activation.getRule().getName(),
+ activation.getTuple() );
+ } else {
// fire regular rule
super.fireActivation( activation );
- ( (LeapsTuple) activation.getTuple( ) ).setWasFired( true );
+ ((LeapsTuple) activation.getTuple()).setWasFired( true );
}
}
@@ -63,7 +61,7 @@
*
*/
public Activation[] getActivations() {
- final List list = this.workingMemory.getActivations( );
- return (Activation[]) list.toArray( new Activation[list.size( )] );
+ final List list = this.workingMemory.getActivations();
+ return (Activation[]) list.toArray( new Activation[list.size()] );
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/LeapsBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/LeapsBuilder.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/LeapsBuilder.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -87,29 +87,27 @@
evalConditions.add( eval );
} else {
if ( object instanceof Column ) {
- constraints = LeapsBuilder.processColumn( (Column) object );
+ constraints = LeapsBuilder.processColumn( (Column) object );
// create column constraints
- } else if ( object instanceof From ){
- constraints = LeapsBuilder.processColumn( ((From) object).getColumn( ) );
- }
- else {
+ } else if ( object instanceof From ) {
+ constraints = LeapsBuilder.processColumn( ((From) object).getColumn() );
+ } else {
// NOTS and EXISTS
GroupElement ce = (GroupElement) object;
while ( !(ce.getChildren().get( 0 ) instanceof Column) ) {
ce = (GroupElement) ce.getChildren().get( 0 );
}
- constraints = LeapsBuilder.processColumn( (Column) ce.getChildren().get( 0 ) );
+ constraints = LeapsBuilder.processColumn( (Column) ce.getChildren().get( 0 ) );
}
- if (object.getClass( ) == Not.class) {
+ if ( object.getClass() == Not.class ) {
notCols.add( constraints );
- }
- else if (object.getClass( ) == Exists.class) {
+ } else if ( object.getClass() == Exists.class ) {
existsCols.add( constraints );
- }
- else if (object.getClass( ) == From.class) {
- cols.add( new FromConstraint(((From)object).getColumn( ), ((From)object).getDataProvider( ), constraints ));
- }
- else {
+ } else if ( object.getClass() == From.class ) {
+ cols.add( new FromConstraint( ((From) object).getColumn(),
+ ((From) object).getDataProvider(),
+ constraints ) );
+ } else {
cols.add( constraints );
}
}
@@ -123,7 +121,7 @@
cols,
notCols,
existsCols,
- evalConditions) );
+ evalConditions ) );
return leapsRules;
}
@@ -167,34 +165,36 @@
* @param and
* @return leaps packaged ColumnConstraints
*/
- final private static ColumnConstraints processColumn(final Column column ) {
+ final private static ColumnConstraints processColumn(final Column column) {
BetaConstraints binder;
- final List alphaConstraints = new ArrayList( );
- final List predicateConstraints = new ArrayList( );
+ final List alphaConstraints = new ArrayList();
+ final List predicateConstraints = new ArrayList();
- final List constraints = column.getConstraints( );
+ final List constraints = column.getConstraints();
- Map declarations = new HashMap( );
+ final Map declarations = new HashMap();
- if (column.getDeclaration( ) != null) {
- final Declaration declaration = column.getDeclaration( );
+ if ( column.getDeclaration() != null ) {
+ final Declaration declaration = column.getDeclaration();
// Add the declaration the map of previously bound declarations
- declarations.put( declaration.getIdentifier( ), declaration );
+ declarations.put( declaration.getIdentifier(),
+ declaration );
}
- for (final Iterator it = constraints.iterator( ); it.hasNext( );) {
- final Object object = it.next( );
+ for ( final Iterator it = constraints.iterator(); it.hasNext(); ) {
+ final Object object = it.next();
// Check if its a declaration
- if (object instanceof Declaration) {
+ if ( object instanceof Declaration ) {
final Declaration declaration = (Declaration) object;
// Add the declaration the map of previously bound declarations
- declarations.put( declaration.getIdentifier( ), declaration );
+ declarations.put( declaration.getIdentifier(),
+ declaration );
continue;
}
final AlphaNodeFieldConstraint fieldConstraint = (AlphaNodeFieldConstraint) object;
if ( fieldConstraint.getRequiredDeclarations().length == 0 ) {
- alphaConstraints.add( fieldConstraint);
+ alphaConstraints.add( fieldConstraint );
} else {
predicateConstraints.add( fieldConstraint );
}
@@ -210,13 +210,15 @@
alphaConstraints,
binder );
}
+
/**
* Make sure the required declarations are previously bound
*
* @param declarations
* @throws InvalidPatternException
*/
- private static void checkUnboundDeclarations(final Map declarations, final Declaration[] requiredDeclarations) throws InvalidPatternException {
+ private static void checkUnboundDeclarations(final Map declarations,
+ final Declaration[] requiredDeclarations) throws InvalidPatternException {
final List list = new ArrayList();
for ( int i = 0, length = requiredDeclarations.length; i < length; i++ ) {
if ( declarations.get( requiredDeclarations[i].getIdentifier() ) == null ) {
@@ -236,21 +238,19 @@
}
}
-
- public static Object getLeapsClassType(Object o) {
- if(o instanceof org.drools.facttemplates.Fact) {
- return ((org.drools.facttemplates.Fact)o).getFactTemplate( ).getName( );
+
+ public static Object getLeapsClassType(final Object o) {
+ if ( o instanceof org.drools.facttemplates.Fact ) {
+ return ((org.drools.facttemplates.Fact) o).getFactTemplate().getName();
+ } else {
+ return o.getClass();
}
- else {
- return o.getClass( );
- }
}
-
- public static Object getLeapsClassType(ObjectType ot) {
- if(ot.getClass( ) == FactTemplateObjectType.class) {
- return ((FactTemplateObjectType) ot).getFactTemplate( ).getName( );
- }
- else {
+
+ public static Object getLeapsClassType(final ObjectType ot) {
+ if ( ot.getClass() == FactTemplateObjectType.class ) {
+ return ((FactTemplateObjectType) ot).getFactTemplate().getName();
+ } else {
// we assume that it's classobject type
return ((ClassObjectType) ot).getClassType();
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/LeapsFactHandle.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/LeapsFactHandle.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/LeapsFactHandle.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -37,78 +37,87 @@
private List existsTuples = null;
- public LeapsFactHandle(final long id, final Object object) {
- super( id, object );
+ public LeapsFactHandle(final long id,
+ final Object object) {
+ super( id,
+ object );
}
- protected void addActivatedTuple( final LeapsTuple tuple ) {
- if (this.activatedTuples == null) {
- this.activatedTuples = new LinkedList( );
+ protected void addActivatedTuple(final LeapsTuple tuple) {
+ if ( this.activatedTuples == null ) {
+ this.activatedTuples = new LinkedList();
}
this.activatedTuples.add( tuple );
}
- protected void addNotTuple( final LeapsTuple tuple, final int index ) {
- if (this.notTuples == null) {
- this.notTuples = new LinkedList( );
+ protected void addNotTuple(final LeapsTuple tuple,
+ final int index) {
+ if ( this.notTuples == null ) {
+ this.notTuples = new LinkedList();
}
- this.notTuples.add( new FactHandleTupleAssembly( FactHandleTupleAssembly.NOT, tuple, index ) );
+ this.notTuples.add( new FactHandleTupleAssembly( FactHandleTupleAssembly.NOT,
+ tuple,
+ index ) );
}
- protected void addExistsTuple( final LeapsTuple tuple, final int index ) {
- if (this.existsTuples == null) {
- this.existsTuples = new LinkedList( );
+ protected void addExistsTuple(final LeapsTuple tuple,
+ final int index) {
+ if ( this.existsTuples == null ) {
+ this.existsTuples = new LinkedList();
}
- this.existsTuples.add( new FactHandleTupleAssembly( FactHandleTupleAssembly.EXISTS, tuple, index ) );
+ this.existsTuples.add( new FactHandleTupleAssembly( FactHandleTupleAssembly.EXISTS,
+ tuple,
+ index ) );
}
protected Iterator getActivatedTuples() {
- if (this.activatedTuples != null) {
- return this.activatedTuples.iterator( );
+ if ( this.activatedTuples != null ) {
+ return this.activatedTuples.iterator();
}
return null;
}
protected Iterator getNotTupleAssemblies() {
- if (this.notTuples != null) {
- return this.notTuples.iterator( );
+ if ( this.notTuples != null ) {
+ return this.notTuples.iterator();
}
return null;
}
protected Iterator getExistsTupleAssemblies() {
- if (this.existsTuples != null) {
- return this.existsTuples.iterator( );
+ if ( this.existsTuples != null ) {
+ return this.existsTuples.iterator();
}
return null;
}
-
+
protected void clearActivatedTuples() {
this.activatedTuples = null;
}
-
+
protected void clearExistsTuples() {
this.existsTuples = null;
}
-
+
protected void clearNotTuples() {
this.notTuples = null;
}
-
+
private LinkedList hashes = null;
- protected void addHash(Table table){
- if(this.hashes == null){
+
+ protected void addHash(final Table table) {
+ if ( this.hashes == null ) {
this.hashes = new LinkedList();
}
this.hashes.add( table );
}
-
+
protected void removeFromHash() {
- if(this.hashes!= null){
- for(Iterator it = this.hashes.iterator( ); it.hasNext( );){
- ((Table)it.next( )).remove( this );
+ if ( this.hashes != null ) {
+ for ( final Iterator it = this.hashes.iterator(); it.hasNext(); ) {
+ ((Table) it.next()).remove( this );
}
- this.hashes.clear( );
+ this.hashes.clear();
}
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/LeapsFactHandleFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/LeapsFactHandleFactory.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/LeapsFactHandleFactory.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -24,7 +24,9 @@
* @author Alexander Bagerman
*
*/
-class LeapsFactHandleFactory implements FactHandleFactory {
+class LeapsFactHandleFactory
+ implements
+ FactHandleFactory {
private static final long serialVersionUID = 8510623248591449450L;
private long counter;
@@ -39,8 +41,9 @@
*
* @see org.drools.reteoo.FactHandleFactory
*/
- public final InternalFactHandle newFactHandle( final Object object ) {
- return new LeapsFactHandle( this.getNextId( ), object );
+ public final InternalFactHandle newFactHandle(final Object object) {
+ return new LeapsFactHandle( this.getNextId(),
+ object );
}
/**
@@ -49,7 +52,8 @@
* @param object
* @return leaps handle
*/
- public final InternalFactHandle newFactHandle( final long newId, final Object object ) {
+ public final InternalFactHandle newFactHandle(final long newId,
+ final Object object) {
return newFactHandle( object );
}
@@ -66,8 +70,8 @@
*
* @see org.drools.reteoo.FactHandleFactory
*/
- public final void increaseFactHandleRecency( final InternalFactHandle factHandle ) {
- factHandle.setRecency( this.getNextId( ) );
+ public final void increaseFactHandleRecency(final InternalFactHandle factHandle) {
+ factHandle.setRecency( this.getNextId() );
}
/**
@@ -76,7 +80,7 @@
*
* @see org.drools.reteoo.FactHandleFactory
*/
- public void destroyFactHandle( final InternalFactHandle factHandle ) {
+ public void destroyFactHandle(final InternalFactHandle factHandle) {
factHandle.setEqualityKey( new EqualityKey( factHandle ) );
}
@@ -84,7 +88,7 @@
* @see org.drools.reteoo.FactHandleFactory
*/
public FactHandleFactory newInstance() {
- return new LeapsFactHandleFactory( );
+ return new LeapsFactHandleFactory();
}
public Class getFactHandleType() {
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/LeapsRule.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/LeapsRule.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/LeapsRule.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -30,7 +30,9 @@
* @author Alexander Bagerman
*
*/
-class LeapsRule implements Serializable {
+class LeapsRule
+ implements
+ Serializable {
Rule rule;
final ColumnConstraints[] columnConstraints;
@@ -50,28 +52,28 @@
final Class[] existsNotsClasses;
public LeapsRule(final Rule rule,
- final ArrayList columns,
- final ArrayList notColumns,
- final ArrayList existsColumns,
- final ArrayList evalConditions) {
+ final ArrayList columns,
+ final ArrayList notColumns,
+ final ArrayList existsColumns,
+ final ArrayList evalConditions) {
this.rule = rule;
this.columnConstraints = (ColumnConstraints[]) columns.toArray( new ColumnConstraints[0] );
this.notColumnConstraints = (ColumnConstraints[]) notColumns.toArray( new ColumnConstraints[0] );
this.existsColumnConstraints = (ColumnConstraints[]) existsColumns.toArray( new ColumnConstraints[0] );
this.evalConditions = (EvalCondition[]) evalConditions.toArray( new EvalCondition[0] );
- this.notColumnsPresent = ( this.notColumnConstraints.length != 0 );
- this.existsColumnsPresent = ( this.existsColumnConstraints.length != 0 );
- this.evalCoditionsPresent = ( this.evalConditions.length != 0 );
+ this.notColumnsPresent = (this.notColumnConstraints.length != 0);
+ this.existsColumnsPresent = (this.existsColumnConstraints.length != 0);
+ this.evalCoditionsPresent = (this.evalConditions.length != 0);
- final ArrayList classes = new ArrayList( );
- for (int i = 0; i < this.notColumnConstraints.length; i++) {
- if (!classes.contains( this.notColumnConstraints[i].getClassType( ) )) {
- classes.add( this.notColumnConstraints[i].getClassType( ) );
+ final ArrayList classes = new ArrayList();
+ for ( int i = 0; i < this.notColumnConstraints.length; i++ ) {
+ if ( !classes.contains( this.notColumnConstraints[i].getClassType() ) ) {
+ classes.add( this.notColumnConstraints[i].getClassType() );
}
}
- for (int i = 0; i < this.existsColumnConstraints.length; i++) {
- if (!classes.contains( this.existsColumnConstraints[i].getClassType( ) )) {
- classes.add( this.existsColumnConstraints[i].getClassType( ) );
+ for ( int i = 0; i < this.existsColumnConstraints.length; i++ ) {
+ if ( !classes.contains( this.existsColumnConstraints[i].getClassType() ) ) {
+ classes.add( this.existsColumnConstraints[i].getClassType() );
}
}
@@ -98,11 +100,11 @@
return this.evalConditions.length;
}
- Object getColumnClassObjectTypeAtPosition( final int idx ) {
- return this.columnConstraints[idx].getClassType( );
+ Object getColumnClassObjectTypeAtPosition(final int idx) {
+ return this.columnConstraints[idx].getClassType();
}
- ColumnConstraints getColumnConstraintsAtPosition( final int idx ) {
+ ColumnConstraints getColumnConstraintsAtPosition(final int idx) {
return this.columnConstraints[idx];
}
@@ -131,10 +133,10 @@
}
public int hashCode() {
- return this.rule.hashCode( );
+ return this.rule.hashCode();
}
- public boolean equals( final Object that ) {
+ public boolean equals(final Object that) {
return this == that;
}
@@ -153,7 +155,7 @@
return this.agendaGroup;
}
- public void setAgendaGroup( final AgendaGroupImpl agendaGroup ) {
+ public void setAgendaGroup(final AgendaGroupImpl agendaGroup) {
this.agendaGroup = agendaGroup;
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/LeapsRuleBase.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/LeapsRuleBase.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/LeapsRuleBase.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -67,8 +67,8 @@
this( id,
null,
new LeapsFactHandleFactory() );
- }
-
+ }
+
/**
* Construct.
*
@@ -103,7 +103,7 @@
* @see RuleBase
*/
public WorkingMemory newWorkingMemory(final boolean keepReference) {
- final LeapsWorkingMemory workingMemory = new LeapsWorkingMemory( this.workingMemoryCounter++,
+ final LeapsWorkingMemory workingMemory = new LeapsWorkingMemory( this.workingMemoryCounter++,
this );
// add all rules added so far
for ( final Iterator it = this.leapsRules.values().iterator(); it.hasNext(); ) {
@@ -168,9 +168,9 @@
ClassNotFoundException {
doReadExternal( stream,
new Object[0] );
-
+
this.leapsRules = new HashMap();
-
+
for ( int i = 0; i < this.getPackages().length; i++ ) {
final Rule[] rules = this.getPackages()[i].getRules();
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/LeapsRuleHandle.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/LeapsRuleHandle.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/LeapsRuleHandle.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -32,11 +32,13 @@
public class LeapsRuleHandle extends DefaultFactHandle {
// ce position for which handle is created
- private final int dominantPosition;
+ private final int dominantPosition;
- public LeapsRuleHandle(final long id, final LeapsRule rule,
+ public LeapsRuleHandle(final long id,
+ final LeapsRule rule,
final int dominantPosition) {
- super( id, rule );
+ super( id,
+ rule );
this.dominantPosition = dominantPosition;
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/LeapsTuple.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/LeapsTuple.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/LeapsTuple.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -34,11 +34,11 @@
implements
Tuple,
Serializable {
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = 1L;
- private PropagationContext context;
+ private PropagationContext context;
- private boolean readyForActivation;
+ private boolean readyForActivation;
private final LeapsFactHandle[] factHandles;
@@ -46,11 +46,12 @@
private LeapsFactHandle[] existsFactHandles = null;
- private Activation activation;
+ private Activation activation;
private final LeapsRule leapsRule;
private boolean wasFired = false;
+
/**
* agendaItem parts
*/
@@ -275,10 +276,10 @@
}
public boolean isWasFired() {
- return wasFired;
+ return this.wasFired;
}
- public void setWasFired( boolean wasFired ) {
+ public void setWasFired(final boolean wasFired) {
this.wasFired = wasFired;
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/LeapsWorkingMemory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/LeapsWorkingMemory.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/LeapsWorkingMemory.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -27,14 +27,13 @@
import java.util.Map;
import java.util.Set;
+import org.apache.commons.collections.map.IdentityMap;
import org.drools.FactException;
-import org.drools.FactHandle;
import org.drools.QueryResults;
import org.drools.WorkingMemory;
import org.drools.common.AbstractWorkingMemory;
import org.drools.common.AgendaGroupImpl;
import org.drools.common.AgendaItem;
-import org.drools.common.EqualityKey;
import org.drools.common.EventSupport;
import org.drools.common.InternalFactHandle;
import org.drools.common.InternalRuleBase;
@@ -50,8 +49,6 @@
import org.drools.spi.Duration;
import org.drools.spi.PropagationContext;
import org.drools.spi.Tuple;
-import org.drools.util.FastMap;
-import org.drools.util.IdentityMap;
import org.drools.util.IteratorChain;
/**
@@ -66,17 +63,19 @@
* @see java.io.Serializable
*
*/
-class LeapsWorkingMemory extends AbstractWorkingMemory implements EventSupport,
- PropertyChangeListener {
+class LeapsWorkingMemory extends AbstractWorkingMemory
+ implements
+ EventSupport,
+ PropertyChangeListener {
private static final long serialVersionUID = 320;
private final Map queryResults;
- private final IdentityMap leapsRulesToHandlesMap = new IdentityMap( );
+ private final IdentityMap leapsRulesToHandlesMap = new IdentityMap();
- private final IdentityMap rulesActivationsMap = new IdentityMap( );
+ private final IdentityMap rulesActivationsMap = new IdentityMap();
- private final LinkedList noPositiveColumnsRules = new LinkedList( );
+ private final LinkedList noPositiveColumnsRules = new LinkedList();
/**
* Construct.
@@ -84,85 +83,92 @@
* @param ruleBase
* The backing rule-base.
*/
- public LeapsWorkingMemory(final int id, final InternalRuleBase ruleBase) {
- super( id, ruleBase, ruleBase.newFactHandleFactory( ) );
- this.queryResults = new HashMap( );
+ public LeapsWorkingMemory(final int id,
+ final InternalRuleBase ruleBase) {
+ super( id,
+ ruleBase,
+ ruleBase.newFactHandleFactory() );
+ this.queryResults = new HashMap();
this.agenda = new LeapsAgenda( this );
}
- public void doAssertObject( final InternalFactHandle factHandle,
- final Object object,
- final PropagationContext propagationContext )
- throws FactException {
+ public void doAssertObject(final InternalFactHandle factHandle,
+ final Object object,
+ final PropagationContext propagationContext) throws FactException {
- this.pushTokenOnStack( factHandle, new Token( this, factHandle, propagationContext ) );
+ this.pushTokenOnStack( factHandle,
+ new Token( this,
+ factHandle,
+ propagationContext ) );
// determine what classes it belongs to put it into the "table" on
// class name key
- List tuplesToAssert = new LinkedList( );
+ final List tuplesToAssert = new LinkedList();
final Object objectClass = LeapsBuilder.getLeapsClassType( object );
- for (final Iterator tables = this.getFactTablesList( objectClass ).iterator( ); tables.hasNext( );) {
- tuplesToAssert.clear( );
- final FactTable factTable = (FactTable) tables.next( );
+ for ( final Iterator tables = this.getFactTablesList( objectClass ).iterator(); tables.hasNext(); ) {
+ tuplesToAssert.clear();
+ final FactTable factTable = (FactTable) tables.next();
// adding fact to container
factTable.add( factHandle );
// iterate through unsatisfied exists
- for (final Iterator tuples = factTable.getTuplesIterator( ); tuples.hasNext( );) {
- final LeapsTuple tuple = (LeapsTuple) tuples.next( );
+ for ( final Iterator tuples = factTable.getTuplesIterator(); tuples.hasNext(); ) {
+ final LeapsTuple tuple = (LeapsTuple) tuples.next();
- TokenEvaluator.evaluateExistsConditions( tuple, tuple.getLeapsRule( ), this );
+ TokenEvaluator.evaluateExistsConditions( tuple,
+ tuple.getLeapsRule(),
+ this );
// check and see if we need activate
// activate only if tuple was not ready for it before
- if (tuple.isReadyForActivation( )) {
+ if ( tuple.isReadyForActivation() ) {
// ready to activate
tuplesToAssert.add( tuple );
}
}
- for (final Iterator it = tuplesToAssert.iterator( ); it.hasNext( );) {
+ for ( final Iterator it = tuplesToAssert.iterator(); it.hasNext(); ) {
// ready to activate
- final LeapsTuple tuple = (LeapsTuple) it.next( );
+ final LeapsTuple tuple = (LeapsTuple) it.next();
factTable.removeTuple( tuple );
- tuple.setContext( new PropagationContextImpl( nextPropagationIdCounter( ),
+ tuple.setContext( new PropagationContextImpl( nextPropagationIdCounter(),
PropagationContext.ASSERTION,
- tuple.getLeapsRule( )
- .getRule( ),
+ tuple.getLeapsRule().getRule(),
null ) );
this.assertTuple( tuple );
}
}
// inspect all tuples for not conditions and activate
// deactivate agenda items
- Activation[] activations = this.agenda.getActivations( );
- for (int k = 0; k < activations.length; k++) {
+ final Activation[] activations = this.agenda.getActivations();
+ for ( int k = 0; k < activations.length; k++ ) {
boolean deActivate = false;
- LeapsTuple tuple = (LeapsTuple) activations[k].getTuple( );
- final ColumnConstraints[] not = tuple.getLeapsRule( ).getNotColumnConstraints( );
- for (int i = 0, length = not.length; !deActivate && i < length; i++) {
+ final LeapsTuple tuple = (LeapsTuple) activations[k].getTuple();
+ final ColumnConstraints[] not = tuple.getLeapsRule().getNotColumnConstraints();
+ for ( int i = 0, length = not.length; !deActivate && i < length; i++ ) {
final ColumnConstraints constraint = not[i];
- final Object columnClassObject = constraint.getClassType( );
- if (( ( objectClass.getClass( ) == Class.class
- && columnClassObject.getClass( ) == Class.class && ( (Class) columnClassObject ).isAssignableFrom( (Class) objectClass ) ) || ( objectClass.getClass( ) != Class.class
- && columnClassObject.getClass( ) != Class.class && columnClassObject.equals( objectClass ) ) )
- && constraint.isAllowed( factHandle, tuple, this )) {
- tuple.setBlockingNotFactHandle( (LeapsFactHandle) factHandle, i );
- ( (LeapsFactHandle) factHandle ).addNotTuple( tuple, i );
+ final Object columnClassObject = constraint.getClassType();
+ if ( ((objectClass.getClass() == Class.class && columnClassObject.getClass() == Class.class && ((Class) columnClassObject).isAssignableFrom( (Class) objectClass )) || (objectClass.getClass() != Class.class
+ && columnClassObject.getClass() != Class.class && columnClassObject.equals( objectClass )))
+ && constraint.isAllowed( factHandle,
+ tuple,
+ this ) ) {
+ tuple.setBlockingNotFactHandle( (LeapsFactHandle) factHandle,
+ i );
+ ((LeapsFactHandle) factHandle).addNotTuple( tuple,
+ i );
deActivate = true;
}
}
// check and see if we need de-activate
- if (deActivate) {
- tuple.setContext( new PropagationContextImpl( nextPropagationIdCounter( ),
+ if ( deActivate ) {
+ tuple.setContext( new PropagationContextImpl( nextPropagationIdCounter(),
PropagationContext.ASSERTION,
- tuple.getLeapsRule( )
- .getRule( ),
+ tuple.getLeapsRule().getRule(),
null ) );
- if (tuple.getLeapsRule( ).getRule( ) instanceof Query) {
+ if ( tuple.getLeapsRule().getRule() instanceof Query ) {
// put query results to the working memory
// location
- removeFromQueryResults( tuple.getLeapsRule( ).getRule( ).getName( ),
+ removeFromQueryResults( tuple.getLeapsRule().getRule().getName(),
tuple );
- }
- else {
+ } else {
// time to pull from agenda
invalidateActivation( tuple );
}
@@ -177,69 +183,67 @@
*
* @see WorkingMemory
*/
- public void doRetract( final InternalFactHandle factHandle,
- final PropagationContext propagationContext ) {
+ public void doRetract(final InternalFactHandle factHandle,
+ final PropagationContext propagationContext) {
/*
* leaps specific actions
*/
// remove fact from all relevant fact tables container
- final Object objectClass = LeapsBuilder.getLeapsClassType( factHandle.getObject( ) );
- for (final Iterator it = this.getFactTablesList( objectClass ).iterator( ); it.hasNext( );) {
- ( (FactTable) it.next( ) ).remove( factHandle );
+ final Object objectClass = LeapsBuilder.getLeapsClassType( factHandle.getObject() );
+ for ( final Iterator it = this.getFactTablesList( objectClass ).iterator(); it.hasNext(); ) {
+ ((FactTable) it.next()).remove( factHandle );
}
// 0. remove activated tuples
- final Iterator tuples = ( (LeapsFactHandle) factHandle ).getActivatedTuples( );
- for (; tuples != null && tuples.hasNext( );) {
- final LeapsTuple tuple = (LeapsTuple) tuples.next( );
- if (tuple.getLeapsRule( ).getRule( ) instanceof Query) {
+ final Iterator tuples = ((LeapsFactHandle) factHandle).getActivatedTuples();
+ for ( ; tuples != null && tuples.hasNext(); ) {
+ final LeapsTuple tuple = (LeapsTuple) tuples.next();
+ if ( tuple.getLeapsRule().getRule() instanceof Query ) {
// put query results to the working memory location
- removeFromQueryResults( tuple.getLeapsRule( ).getRule( ).getName( ), tuple );
- }
- else {
+ removeFromQueryResults( tuple.getLeapsRule().getRule().getName(),
+ tuple );
+ } else {
// time to pull from agenda
invalidateActivation( tuple );
}
}
- ( (LeapsFactHandle) factHandle ).clearActivatedTuples( );
+ ((LeapsFactHandle) factHandle).clearActivatedTuples();
// assert all tuples that are ready for activation or cancel ones
// that are no longer
Iterator it;
- final IteratorChain chain = new IteratorChain( );
- it = ( (LeapsFactHandle) factHandle ).getNotTupleAssemblies( );
- if (it != null) {
+ final IteratorChain chain = new IteratorChain();
+ it = ((LeapsFactHandle) factHandle).getNotTupleAssemblies();
+ if ( it != null ) {
chain.addIterator( it );
}
- it = ( (LeapsFactHandle) factHandle ).getExistsTupleAssemblies( );
- if (it != null) {
+ it = ((LeapsFactHandle) factHandle).getExistsTupleAssemblies();
+ if ( it != null ) {
chain.addIterator( it );
}
- for (; chain.hasNext( );) {
- FactHandleTupleAssembly tupleAssembly = ( (FactHandleTupleAssembly) chain.next( ) );
- final LeapsTuple tuple = tupleAssembly.getTuple( );
- if (tupleAssembly.getType( ) == FactHandleTupleAssembly.NOT) {
- tuple.removeBlockingNotFactHandle( tupleAssembly.getIndex( ) );
+ for ( ; chain.hasNext(); ) {
+ final FactHandleTupleAssembly tupleAssembly = ((FactHandleTupleAssembly) chain.next());
+ final LeapsTuple tuple = tupleAssembly.getTuple();
+ if ( tupleAssembly.getType() == FactHandleTupleAssembly.NOT ) {
+ tuple.removeBlockingNotFactHandle( tupleAssembly.getIndex() );
+ } else {
+ tuple.removeExistsFactHandle( tupleAssembly.getIndex() );
}
- else {
- tuple.removeExistsFactHandle( tupleAssembly.getIndex( ) );
- }
// can assert only tuples that were not eligible for activation
// before retraction
- if (!TokenEvaluator.processAfterAllPositiveConstraintOk( tuple,
- tuple.getLeapsRule( ),
- this )) {
+ if ( !TokenEvaluator.processAfterAllPositiveConstraintOk( tuple,
+ tuple.getLeapsRule(),
+ this ) ) {
// deactivate tuple that was activated inside of
// processAfterAllPositive
// bad design, need to rethink it
invalidateActivation( tuple );
- }
- else {
+ } else {
this.assertTuple( tuple );
}
}
- ( (LeapsFactHandle) factHandle ).clearExistsTuples( );
- ( (LeapsFactHandle) factHandle ).clearNotTuples( );
+ ((LeapsFactHandle) factHandle).clearExistsTuples();
+ ((LeapsFactHandle) factHandle).clearNotTuples();
// remove it from stack
this.removeTokenFromStack( (LeapsFactHandle) factHandle );
}
@@ -250,25 +254,24 @@
*
* @param tuple
*/
- private final void invalidateActivation( final LeapsTuple tuple ) {
- final Activation activation = tuple.getActivation( );
+ private final void invalidateActivation(final LeapsTuple tuple) {
+ final Activation activation = tuple.getActivation();
// tuple can already loose activation if another fact or exists fact was retracted
// or not fact added
- if (activation != null) {
- if (activation.isActivated( )) {
- activation.remove( );
- this.getAgendaEventSupport( ).fireActivationCancelled( activation );
+ if ( activation != null ) {
+ if ( activation.isActivated() ) {
+ activation.remove();
+ this.getAgendaEventSupport().fireActivationCancelled( activation );
}
- this.getTruthMaintenanceSystem( )
- .removeLogicalDependencies( activation,
- tuple.getContext( ),
- tuple.getLeapsRule( ).getRule( ) );
+ this.getTruthMaintenanceSystem().removeLogicalDependencies( activation,
+ tuple.getContext(),
+ tuple.getLeapsRule().getRule() );
//
tuple.setActivation( null );
// remove from rule / activaitons map
- FastMap activations = (FastMap) this.rulesActivationsMap.get( activation.getRule( ) );
- if (activations != null) {
+ FastMap activations = (FastMap) this.rulesActivationsMap.get( activation.getRule() );
+ if ( activations != null ) {
activations.remove( activation );
}
}
@@ -277,14 +280,14 @@
/**
* ************* leaps section *********************
*/
- private long idLastFireAllAt = -1;
-
- private boolean rulesAddedSinceLastFireAll = false;
+ private long idLastFireAllAt = -1;
+ private boolean rulesAddedSinceLastFireAll = false;
+
/**
* algorithm stack.
*/
- private final TokenStack mainStack = new TokenStack( );
+ private final TokenStack mainStack = new TokenStack();
/**
* generates or just return List of internal factTables that correspond a
@@ -292,24 +295,23 @@
*
* @return
*/
- protected final List getFactTablesList( final Object objectClass ) {
- final ArrayList list = new ArrayList( );
- if (objectClass.getClass( ) == Class.class) {
+ protected final List getFactTablesList(final Object objectClass) {
+ final ArrayList list = new ArrayList();
+ if ( objectClass.getClass() == Class.class ) {
// interfaces
- final Class[] interfaces = ( (Class) objectClass ).getInterfaces( );
- for (int i = 0; i < interfaces.length; i++) {
+ final Class[] interfaces = ((Class) objectClass).getInterfaces();
+ for ( int i = 0; i < interfaces.length; i++ ) {
list.add( this.getFactTable( interfaces[i] ) );
}
// classes
Class bufClass = (Class) objectClass;
- while (bufClass != null) {
+ while ( bufClass != null ) {
//
list.add( this.getFactTable( bufClass ) );
// and get the next class on the list
- bufClass = bufClass.getSuperclass( );
+ bufClass = bufClass.getSuperclass();
}
- }
- else {
+ } else {
list.add( this.getFactTable( objectClass ) );
}
return list;
@@ -322,8 +324,8 @@
* handle
* @param token
*/
- protected final void pushTokenOnStack( final InternalFactHandle factHandle,
- final Token token ) {
+ protected final void pushTokenOnStack(final InternalFactHandle factHandle,
+ final Token token) {
this.mainStack.push( token );
}
@@ -333,8 +335,8 @@
* @param fact
* handle
*/
- protected final void removeTokenFromStack( final LeapsFactHandle factHandle ) {
- this.mainStack.remove( factHandle.getId( ) );
+ protected final void removeTokenFromStack(final LeapsFactHandle factHandle) {
+ this.mainStack.remove( factHandle.getId() );
}
/**
@@ -344,7 +346,7 @@
* handle
*/
protected final Token peekTokenOnTop() {
- return (Token) this.mainStack.peek( );
+ return (Token) this.mainStack.peek();
}
/**
@@ -354,28 +356,27 @@
* of objects
* @return fact table of requested class type
*/
- protected FactTable getFactTable( final Object objectClass ) {
+ protected FactTable getFactTable(final Object objectClass) {
FactTable table;
- if (this.factTables.containsKey( objectClass )) {
+ if ( this.factTables.containsKey( objectClass ) ) {
table = (FactTable) this.factTables.get( objectClass );
- }
- else {
- table = new FactTable( DefaultConflictResolver.getInstance( ) );
- this.factTables.put( objectClass, table );
+ } else {
+ table = new FactTable( DefaultConflictResolver.getInstance() );
+ this.factTables.put( objectClass,
+ table );
// review existing rules and assign to the fact table if needed
- for (final Iterator iter = this.leapsRulesToHandlesMap.keySet( ).iterator( ); iter.hasNext( );) {
- final LeapsRule leapsRule = (LeapsRule) iter.next( );
- if (leapsRule.getNumberOfColumns( ) > 0) {
+ for ( final Iterator iter = this.leapsRulesToHandlesMap.keySet().iterator(); iter.hasNext(); ) {
+ final LeapsRule leapsRule = (LeapsRule) iter.next();
+ if ( leapsRule.getNumberOfColumns() > 0 ) {
final List rulesHandles = (List) this.leapsRulesToHandlesMap.get( leapsRule );
- for (final Iterator handles = rulesHandles.iterator( ); handles.hasNext( );) {
- final LeapsRuleHandle handle = (LeapsRuleHandle) handles.next( );
- final Object columnClassObject = leapsRule.getColumnClassObjectTypeAtPosition( handle.getDominantPosition( ) );
- if (( objectClass.getClass( ) == Class.class
- && columnClassObject.getClass( ) == Class.class && ( (Class) columnClassObject ).isAssignableFrom( (Class) objectClass ) )
- // on template name
- || ( objectClass.getClass( ) != Class.class
- && columnClassObject.getClass( ) != Class.class && columnClassObject.equals( objectClass ) )) {
- table.addRule( this, handle );
+ for ( final Iterator handles = rulesHandles.iterator(); handles.hasNext(); ) {
+ final LeapsRuleHandle handle = (LeapsRuleHandle) handles.next();
+ final Object columnClassObject = leapsRule.getColumnClassObjectTypeAtPosition( handle.getDominantPosition() );
+ if ( (objectClass.getClass() == Class.class && columnClassObject.getClass() == Class.class && ((Class) columnClassObject).isAssignableFrom( (Class) objectClass ))
+ // on template name
+ || (objectClass.getClass() != Class.class && columnClassObject.getClass() != Class.class && columnClassObject.equals( objectClass )) ) {
+ table.addRule( this,
+ handle );
}
}
}
@@ -390,160 +391,154 @@
*
* @param rules
*/
- protected void addLeapsRules( final List rules ) {
- this.getLock( ).lock( );
+ protected void addLeapsRules(final List rules) {
+ this.getLock().lock();
try {
this.rulesAddedSinceLastFireAll = true;
-
+
ArrayList ruleHandlesList;
LeapsRule rule;
LeapsRuleHandle ruleHandle;
- for (final Iterator it = rules.iterator( ); it.hasNext( );) {
- rule = (LeapsRule) it.next( );
+ for ( final Iterator it = rules.iterator(); it.hasNext(); ) {
+ rule = (LeapsRule) it.next();
// create hashed entries for not and exists
// check for NOT and EXISTS and create new hashed entry
ColumnConstraints constraint;
- for (int i = 0; i < rule.getNumberOfNotColumns( ); i++) {
- constraint = rule.getNotColumnConstraints( )[i];
- this.getFactTable( constraint.getClassType( ) )
- .createHashedSubTable( constraint );
+ for ( int i = 0; i < rule.getNumberOfNotColumns(); i++ ) {
+ constraint = rule.getNotColumnConstraints()[i];
+ this.getFactTable( constraint.getClassType() ).createHashedSubTable( constraint );
}
- for (int i = 0; i < rule.getNumberOfExistsColumns( ); i++) {
- constraint = rule.getExistsColumnConstraints( )[i];
- this.getFactTable( constraint.getClassType( ) )
- .createHashedSubTable( constraint );
+ for ( int i = 0; i < rule.getNumberOfExistsColumns(); i++ ) {
+ constraint = rule.getExistsColumnConstraints()[i];
+ this.getFactTable( constraint.getClassType() ).createHashedSubTable( constraint );
}
// some times rules do not have "normal" constraints and only
// not and exists
- if (rule.getNumberOfColumns( ) > 0) {
- ruleHandlesList = new ArrayList( );
- for (int i = 0; i < rule.getNumberOfColumns( ); i++) {
- ruleHandle = new LeapsRuleHandle( ( (LeapsFactHandleFactory) this.handleFactory ).getNextId( ),
+ if ( rule.getNumberOfColumns() > 0 ) {
+ ruleHandlesList = new ArrayList();
+ for ( int i = 0; i < rule.getNumberOfColumns(); i++ ) {
+ ruleHandle = new LeapsRuleHandle( ((LeapsFactHandleFactory) this.handleFactory).getNextId(),
rule,
i );
//
- if (rule.getColumnConstraintsAtPosition( i ).getClass( ) != FromConstraint.class) {
- this.getFactTable( rule.getColumnClassObjectTypeAtPosition( i ) )
- .addRule( this, ruleHandle );
+ if ( rule.getColumnConstraintsAtPosition( i ).getClass() != FromConstraint.class ) {
+ this.getFactTable( rule.getColumnClassObjectTypeAtPosition( i ) ).addRule( this,
+ ruleHandle );
//
- }
- else {
- FactTable table = this.getFactTable( FromConstraintFactDriver.class );
- table.addRule( this, ruleHandle );
- if (table.isEmpty( )) {
- this.assertObject( new FromConstraintFactDriver( ) );
+ } else {
+ final FactTable table = this.getFactTable( FromConstraintFactDriver.class );
+ table.addRule( this,
+ ruleHandle );
+ if ( table.isEmpty() ) {
+ this.assertObject( new FromConstraintFactDriver() );
}
}
ruleHandlesList.add( ruleHandle );
}
- this.leapsRulesToHandlesMap.put( rule, ruleHandlesList );
- }
- else {
- this.noPositiveColumnsRules.add( new LeapsRuleHandle( ( (LeapsFactHandleFactory) this.handleFactory ).getNextId( ),
+ this.leapsRulesToHandlesMap.put( rule,
+ ruleHandlesList );
+ } else {
+ this.noPositiveColumnsRules.add( new LeapsRuleHandle( ((LeapsFactHandleFactory) this.handleFactory).getNextId(),
rule,
0 ) );
}
}
+ } finally {
+ this.getLock().unlock();
}
- finally {
- this.getLock( ).unlock( );
- }
}
- protected void removeRule( final List rules ) {
- this.getLock( ).lock( );
+ protected void removeRule(final List rules) {
+ this.getLock().lock();
try {
ArrayList ruleHandlesList;
LeapsRule leapsRule;
LeapsRuleHandle ruleHandle;
- for (final Iterator it = rules.iterator( ); it.hasNext( );) {
- leapsRule = (LeapsRule) it.next( );
+ for ( final Iterator it = rules.iterator(); it.hasNext(); ) {
+ leapsRule = (LeapsRule) it.next();
// some times rules do not have "normal" constraints and only
// not and exists
- if (leapsRule.getNumberOfColumns( ) > 0) {
+ if ( leapsRule.getNumberOfColumns() > 0 ) {
ruleHandlesList = (ArrayList) this.leapsRulesToHandlesMap.remove( leapsRule );
- for (int i = 0; i < ruleHandlesList.size( ); i++) {
+ for ( int i = 0; i < ruleHandlesList.size(); i++ ) {
ruleHandle = (LeapsRuleHandle) ruleHandlesList.get( i );
//
- this.getFactTable( leapsRule.getColumnClassObjectTypeAtPosition( i ) )
- .removeRule( this, ruleHandle );
+ this.getFactTable( leapsRule.getColumnClassObjectTypeAtPosition( i ) ).removeRule( this,
+ ruleHandle );
}
}
//
}
- final Rule rule = ( (LeapsRule) rules.get( 0 ) ).getRule( );
+ final Rule rule = ((LeapsRule) rules.get( 0 )).getRule();
final FastMap activations = (FastMap) this.rulesActivationsMap.remove( rule );
- if (activations != null) {
- for (final Iterator activationsIt = activations.keySet( ).iterator( ); activationsIt.hasNext( );) {
- final Activation activation = (Activation) activationsIt.next( );
- ( (LeapsTuple) activation.getTuple( ) ).setActivation( null );
+ if ( activations != null ) {
+ for ( final Iterator activationsIt = activations.keySet().iterator(); activationsIt.hasNext(); ) {
+ final Activation activation = (Activation) activationsIt.next();
+ ((LeapsTuple) activation.getTuple()).setActivation( null );
this.tms.removeLogicalDependencies( activation,
- activation.getPropagationContext( ),
+ activation.getPropagationContext(),
rule );
}
}
- propagateQueuedActions( );
+ propagateQueuedActions();
+ } finally {
+ this.getLock().unlock();
}
- finally {
- this.getLock( ).unlock( );
- }
}
/**
* main loop
*
*/
- public final synchronized void fireAllRules( final AgendaFilter agendaFilter )
- throws FactException {
+ public final synchronized void fireAllRules(final AgendaFilter agendaFilter) throws FactException {
// If we're already firing a rule, then it'll pick up
// the firing for any other assertObject(..) that get
// nested inside, avoiding concurrent-modification
// exceptions, depending on code paths of the actions.
- if (!this.firing) {
+ if ( !this.firing ) {
try {
this.firing = true;
-
+
boolean nothingToProcess = false;
- while (!nothingToProcess) {
+ while ( !nothingToProcess ) {
// check for the initial fact
- for (Iterator rulesIt = this.noPositiveColumnsRules.iterator( ); rulesIt.hasNext( );) {
- LeapsRule rule = ( (LeapsRuleHandle) rulesIt.next( ) ).getLeapsRule( );
- final PropagationContextImpl context = new PropagationContextImpl( nextPropagationIdCounter( ),
+ for ( final Iterator rulesIt = this.noPositiveColumnsRules.iterator(); rulesIt.hasNext(); ) {
+ final LeapsRule rule = ((LeapsRuleHandle) rulesIt.next()).getLeapsRule();
+ final PropagationContextImpl context = new PropagationContextImpl( nextPropagationIdCounter(),
PropagationContext.ASSERTION,
null, //rule.getRule( ),
null );
final LeapsTuple tuple = new LeapsTuple( new LeapsFactHandle[0],
rule,
context );
- if (TokenEvaluator.processAfterAllPositiveConstraintOk( tuple,
- rule,
- this )) {
+ if ( TokenEvaluator.processAfterAllPositiveConstraintOk( tuple,
+ rule,
+ this ) ) {
this.assertTuple( tuple );
}
}
- this.noPositiveColumnsRules.clear( );
+ this.noPositiveColumnsRules.clear();
// normal rules with required columns
- while (!this.mainStack.empty( )) {
- final Token token = this.peekTokenOnTop( );
+ while ( !this.mainStack.empty() ) {
+ final Token token = this.peekTokenOnTop();
boolean done = false;
- while (!done) {
- if (!token.isResume( )) {
- if (token.hasNextRuleHandle( )) {
- token.nextRuleHandle( );
- }
- else {
+ while ( !done ) {
+ if ( !token.isResume() ) {
+ if ( token.hasNextRuleHandle() ) {
+ token.nextRuleHandle();
+ } else {
// we do not pop because something might get
// asserted
// and placed on hte top of the stack during
// firing
- this.removeTokenFromStack( (LeapsFactHandle) token.getDominantFactHandle( ) );
+ this.removeTokenFromStack( (LeapsFactHandle) token.getDominantFactHandle() );
done = true;
}
}
- if (!done) {
+ if ( !done ) {
try {
// ok. now we have tuple, dominant fact
// and
@@ -554,23 +549,20 @@
TokenEvaluator.evaluate( token );
// something was found so set marks for
// resume processing
- if (token.getDominantFactHandle( ) != null) {
- if (token.getDominantFactHandle( )
- .getObject( )
- .getClass( ) != FromConstraintFactDriver.class) {
+ if ( token.getDominantFactHandle() != null ) {
+ if ( token.getDominantFactHandle().getObject().getClass() != FromConstraintFactDriver.class ) {
token.setResume( true );
}
done = true;
}
- }
- catch (final NoMatchesFoundException ex) {
+ } catch ( final NoMatchesFoundException ex ) {
token.setResume( false );
}
}
// we put everything on agenda
// and if there is no modules or anything like it
// it would fire just activated rule
- while (this.agenda.fireNextItem( agendaFilter )) {
+ while ( this.agenda.fireNextItem( agendaFilter ) ) {
;
}
}
@@ -578,24 +570,23 @@
// pick activations generated by retraction or assert
// can generate activations off exists and not pending
// tuples
- while (this.agenda.fireNextItem( agendaFilter )) {
+ while ( this.agenda.fireNextItem( agendaFilter ) ) {
;
}
- if (this.mainStack.empty( )) {
+ if ( this.mainStack.empty() ) {
nothingToProcess = true;
}
}
// mark when method was called last time
this.rulesAddedSinceLastFireAll = false;
- this.idLastFireAllAt = ( (LeapsFactHandleFactory) this.handleFactory ).getNextId( );
+ this.idLastFireAllAt = ((LeapsFactHandleFactory) this.handleFactory).getNextId();
// set all factTables to be reseeded
- for (final Iterator it = this.factTables.values( ).iterator( ); it.hasNext( );) {
- ( (FactTable) it.next( ) ).setReseededStack( true );
+ for ( final Iterator it = this.factTables.values().iterator(); it.hasNext(); ) {
+ ((FactTable) it.next()).setReseededStack( true );
}
// clear table that is used to trigger From constraints
- this.getFactTable( FromConstraintFactDriver.class ).clear( );
- }
- finally {
+ this.getFactTable( FromConstraintFactDriver.class ).clear();
+ } finally {
this.firing = false;
}
}
@@ -604,7 +595,7 @@
protected final boolean isRulesAddedSinceLastFireAll() {
return this.rulesAddedSinceLastFireAll;
}
-
+
protected final long getIdLastFireAllAt() {
return this.idLastFireAllAt;
}
@@ -614,14 +605,14 @@
Object key;
ret = ret + "\n" + "Working memory";
ret = ret + "\n" + "Fact Tables by types:";
- for (final Iterator it = this.factTables.keySet( ).iterator( ); it.hasNext( );) {
- key = it.next( );
+ for ( final Iterator it = this.factTables.keySet().iterator(); it.hasNext(); ) {
+ key = it.next();
ret = ret + "\n" + "****************** " + key;
- ret = ret + ( (FactTable) this.factTables.get( key ) ).toString( );
+ ret = ret + ((FactTable) this.factTables.get( key )).toString();
}
ret = ret + "\n" + "Stack:";
- for (final Iterator it = this.mainStack.iterator( ); it.hasNext( );) {
- ret = ret + "\n" + "\t" + it.next( );
+ for ( final Iterator it = this.mainStack.iterator(); it.hasNext(); ) {
+ ret = ret + "\n" + "\t" + it.next();
}
return ret;
}
@@ -636,20 +627,20 @@
* @throws AssertionException
* If an error occurs while asserting.
*/
- public final void assertTuple( final LeapsTuple tuple ) {
- final PropagationContext context = tuple.getContext( );
- final Rule rule = tuple.getLeapsRule( ).getRule( );
+ public final void assertTuple(final LeapsTuple tuple) {
+ final PropagationContext context = tuple.getContext();
+ final Rule rule = tuple.getLeapsRule().getRule();
// if the current Rule is no-loop and the origin rule is the same then
// return
- if (rule.getNoLoop( ) && rule.equals( context.getRuleOrigin( ) )) {
+ if ( rule.getNoLoop() && rule.equals( context.getRuleOrigin() ) ) {
return;
}
//
- final Duration dur = rule.getDuration( );
+ final Duration dur = rule.getDuration();
Activation agendaItem;
- if (dur != null && dur.getDuration( tuple ) > 0) {
- agendaItem = new ScheduledAgendaItem( context.getPropagationNumber( ),
+ if ( dur != null && dur.getDuration( tuple ) > 0 ) {
+ agendaItem = new ScheduledAgendaItem( context.getPropagationNumber(),
tuple,
this.agenda,
context,
@@ -657,28 +648,25 @@
this.agenda.scheduleItem( (ScheduledAgendaItem) agendaItem );
tuple.setActivation( agendaItem );
agendaItem.setActivated( true );
- this.getAgendaEventSupport( ).fireActivationCreated( agendaItem );
- }
- else {
- final LeapsRule leapsRule = tuple.getLeapsRule( );
- AgendaGroupImpl agendaGroup = leapsRule.getAgendaGroup( );
- if (agendaGroup == null) {
- if (rule.getAgendaGroup( ) == null || rule.getAgendaGroup( ).equals( "" )
- || rule.getAgendaGroup( ).equals( AgendaGroup.MAIN )) {
+ this.getAgendaEventSupport().fireActivationCreated( agendaItem );
+ } else {
+ final LeapsRule leapsRule = tuple.getLeapsRule();
+ AgendaGroupImpl agendaGroup = leapsRule.getAgendaGroup();
+ if ( agendaGroup == null ) {
+ if ( rule.getAgendaGroup() == null || rule.getAgendaGroup().equals( "" ) || rule.getAgendaGroup().equals( AgendaGroup.MAIN ) ) {
// Is the Rule AgendaGroup undefined? If it is use MAIN,
// which is added to the Agenda by default
agendaGroup = (AgendaGroupImpl) this.agenda.getAgendaGroup( AgendaGroup.MAIN );
- }
- else {
+ } else {
// AgendaGroup is defined, so try and get the AgendaGroup
// from the Agenda
- agendaGroup = (AgendaGroupImpl) this.agenda.getAgendaGroup( rule.getAgendaGroup( ) );
+ agendaGroup = (AgendaGroupImpl) this.agenda.getAgendaGroup( rule.getAgendaGroup() );
}
- if (agendaGroup == null) {
+ if ( agendaGroup == null ) {
// The AgendaGroup is defined but not yet added to the
// Agenda, so create the AgendaGroup and add to the Agenda.
- agendaGroup = new AgendaGroupImpl( rule.getAgendaGroup( ) );
+ agendaGroup = new AgendaGroupImpl( rule.getAgendaGroup() );
this.agenda.addAgendaGroup( agendaGroup );
}
@@ -686,11 +674,11 @@
}
// set the focus if rule autoFocus is true
- if (rule.getAutoFocus( )) {
+ if ( rule.getAutoFocus() ) {
this.agenda.setFocus( agendaGroup );
}
- agendaItem = new AgendaItem( context.getPropagationNumber( ),
+ agendaItem = new AgendaItem( context.getPropagationNumber(),
tuple,
context,
rule );
@@ -699,28 +687,30 @@
tuple.setActivation( agendaItem );
agendaItem.setActivated( true );
- this.getAgendaEventSupport( ).fireActivationCreated( agendaItem );
+ this.getAgendaEventSupport().fireActivationCreated( agendaItem );
}
// retract support
- final LeapsFactHandle[] factHandles = (LeapsFactHandle[]) tuple.getFactHandles( );
- for (int i = 0; i < factHandles.length; i++) {
+ final LeapsFactHandle[] factHandles = (LeapsFactHandle[]) tuple.getFactHandles();
+ for ( int i = 0; i < factHandles.length; i++ ) {
factHandles[i].addActivatedTuple( tuple );
}
// rules remove support
FastMap activations = (FastMap) this.rulesActivationsMap.get( rule );
- if (activations == null) {
- activations = new FastMap( );
- this.rulesActivationsMap.put( rule, activations );
+ if ( activations == null ) {
+ activations = new FastMap();
+ this.rulesActivationsMap.put( rule,
+ activations );
}
- activations.put( agendaItem, agendaItem );
+ activations.put( agendaItem,
+ agendaItem );
}
List getActivations() {
- List ret = new ArrayList( );
- for (final Iterator it = this.rulesActivationsMap.values( ).iterator( ); it.hasNext( );) {
- ret.addAll( ( (FastMap) it.next( ) ).values( ) );
+ final List ret = new ArrayList();
+ for ( final Iterator it = this.rulesActivationsMap.values().iterator(); it.hasNext(); ) {
+ ret.addAll( ((FastMap) it.next()).values() );
}
return ret;
@@ -730,38 +720,42 @@
return ++this.propagationIdCounter;
}
- public QueryResults getQueryResults( final String queryName ) {
+ public QueryResults getQueryResults(final String queryName) {
final IdentityMap map = (IdentityMap) this.queryResults.get( queryName );
- if (map == null) {
+ if ( map == null ) {
return null;
}
- final LinkedList list = new LinkedList( );
- for (final Iterator it = map.keySet( ).iterator( ); it.hasNext( );) {
- list.add( it.next( ) );
+ final LinkedList list = new LinkedList();
+ for ( final Iterator it = map.keySet().iterator(); it.hasNext(); ) {
+ list.add( it.next() );
}
- if (!list.isEmpty( )) {
- final Query queryRule = (Query) ( (LeapsTuple) list.get( 0 ) ).getLeapsRule( )
- .getRule( );
- return new LeapsQueryResults( list, queryRule, this );
- }
- else {
+ if ( !list.isEmpty() ) {
+ final Query queryRule = (Query) ((LeapsTuple) list.get( 0 )).getLeapsRule().getRule();
+ return new LeapsQueryResults( list,
+ queryRule,
+ this );
+ } else {
return null;
}
}
- void addToQueryResults( final String query, final Tuple tuple ) {
+ void addToQueryResults(final String query,
+ final Tuple tuple) {
IdentityMap map = (IdentityMap) this.queryResults.get( query );
- if (map == null) {
- map = new IdentityMap( );
- this.queryResults.put( query, map );
+ if ( map == null ) {
+ map = new IdentityMap();
+ this.queryResults.put( query,
+ map );
}
- map.put( tuple, tuple );
+ map.put( tuple,
+ tuple );
}
- void removeFromQueryResults( final String query, final Tuple tuple ) {
+ void removeFromQueryResults(final String query,
+ final Tuple tuple) {
final IdentityMap map = (IdentityMap) this.queryResults.get( query );
- if (map != null) {
+ if ( map != null ) {
map.remove( tuple );
}
}
@@ -769,31 +763,34 @@
/**
* to store facts to cursor over it
*/
- private final Map factTables = new FactTables( );
+ private final Map factTables = new FactTables();
- class FactTables implements Map, Serializable {
- private LinkedList tables = new LinkedList( );
+ class FactTables
+ implements
+ Map,
+ Serializable {
+ private final LinkedList tables = new LinkedList();
- private HashMap map = new HashMap( );
+ private final HashMap map = new HashMap();
public int size() {
- return this.tables.size( );
+ return this.tables.size();
}
public void clear() {
- this.tables.clear( );
- this.map.clear( );
+ this.tables.clear();
+ this.map.clear();
}
public boolean isEmpty() {
- return this.tables.isEmpty( );
+ return this.tables.isEmpty();
}
- public boolean containsKey( Object key ) {
+ public boolean containsKey(final Object key) {
return this.map.containsKey( key );
}
- public boolean containsValue( Object value ) {
+ public boolean containsValue(final Object value) {
return this.map.containsValue( value );
}
@@ -801,37 +798,41 @@
return this.tables;
}
- public void putAll( Map t ) {
- this.tables.addAll( t.values( ) );
+ public void putAll(final Map t) {
+ this.tables.addAll( t.values() );
this.map.putAll( t );
}
public Set entrySet() {
- return this.map.entrySet( );
+ return this.map.entrySet();
}
public Set keySet() {
- return this.map.keySet( );
+ return this.map.keySet();
}
- public Object get( Object key ) {
+ public Object get(final Object key) {
return this.map.get( key );
}
- public Object remove( Object key ) {
- Object ret = this.map.remove( key );
+ public Object remove(final Object key) {
+ final Object ret = this.map.remove( key );
this.tables.remove( ret );
return ret;
}
- public Object put( Object key, Object value ) {
+ public Object put(final Object key,
+ final Object value) {
this.tables.add( value );
- this.map.put( key, value );
+ this.map.put( key,
+ value );
return value;
}
}
- private class FromConstraintFactDriver implements Serializable {
+ private class FromConstraintFactDriver
+ implements
+ Serializable {
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/Token.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/Token.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/Token.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -60,27 +60,25 @@
*
*/
public Token(final LeapsWorkingMemory workingMemory,
- final InternalFactHandle factHandle,
- final PropagationContext propagationContext) {
+ final InternalFactHandle factHandle,
+ final PropagationContext propagationContext) {
this.workingMemory = workingMemory;
this.dominantFactHandle = factHandle;
this.propagationContext = propagationContext;
}
private Iterator rulesIterator() {
- if (this.rules == null) {
- if (this.dominantFactHandle != null) {
- this.rules = this.workingMemory.getFactTable( LeapsBuilder.getLeapsClassType( this.dominantFactHandle.getObject( ) ) )
- .getRulesIterator( );
+ if ( this.rules == null ) {
+ if ( this.dominantFactHandle != null ) {
+ this.rules = this.workingMemory.getFactTable( LeapsBuilder.getLeapsClassType( this.dominantFactHandle.getObject() ) ).getRulesIterator();
}
}
return this.rules;
}
public LeapsRuleHandle nextRuleHandle() {
- this.currentRuleHandle = (LeapsRuleHandle) this.rules.next( );
- this.currentFactHandles = new LeapsFactHandle[this.currentRuleHandle.getLeapsRule( )
- .getNumberOfColumns( )];
+ this.currentRuleHandle = (LeapsRuleHandle) this.rules.next();
+ this.currentFactHandles = new LeapsFactHandle[this.currentRuleHandle.getLeapsRule().getNumberOfColumns()];
return this.currentRuleHandle;
}
@@ -95,28 +93,23 @@
if ( this.rulesIterator() != null ) {
// starting with calling rulesIterator() to make sure that we picks
// rules because fact can be asserted before rules added
- final long levelId = ( this.workingMemory.isRulesAddedSinceLastFireAll( ) ) ? this.workingMemory.getIdLastFireAllAt( )
- : -1;
-
- if (this.dominantFactHandle == null
- || this.dominantFactHandle.getRecency( ) >= levelId) {
- ret = this.rules.hasNext( );
- }
- else {
+ final long levelId = (this.workingMemory.isRulesAddedSinceLastFireAll()) ? this.workingMemory.getIdLastFireAllAt() : -1;
+
+ if ( this.dominantFactHandle == null || this.dominantFactHandle.getRecency() >= levelId ) {
+ ret = this.rules.hasNext();
+ } else {
// then we need to skip rules that have id lower than
// workingMemory.idLastFireAllAt
boolean done = false;
- while (!done) {
- if (this.rules.hasNext( )) {
- if (( (LeapsRuleHandle) ( (TableIterator) this.rules ).peekNext( ) ).getRecency( ) > levelId) {
+ while ( !done ) {
+ if ( this.rules.hasNext() ) {
+ if ( ((LeapsRuleHandle) ((TableIterator) this.rules).peekNext()).getRecency() > levelId ) {
ret = true;
done = true;
+ } else {
+ this.rules.next();
}
- else {
- this.rules.next( );
- }
- }
- else {
+ } else {
ret = false;
done = true;
}
@@ -135,7 +128,8 @@
}
}
- public void set( final int idx, final LeapsFactHandle factHandle ) {
+ public void set(final int idx,
+ final LeapsFactHandle factHandle) {
this.currentFactHandles[idx] = factHandle;
}
@@ -160,8 +154,8 @@
*
* @see Object
*/
- public boolean equals( final Object that ) {
- return this.dominantFactHandle.getId( ) == ( (Token) that ).dominantFactHandle.getId( );
+ public boolean equals(final Object that) {
+ return this.dominantFactHandle.getId() == ((Token) that).dominantFactHandle.getId();
}
/**
@@ -171,15 +165,15 @@
* @return The currently bound <code>Object</code> value.
* @see org.drools.spi.Tuple
*/
- public InternalFactHandle get( final int idx ) {
+ public InternalFactHandle get(final int idx) {
return this.currentFactHandles[idx];
}
/**
* @see org.drools.spi.Tuple
*/
- public InternalFactHandle get( final Declaration declaration ) {
- return this.get( declaration.getColumn( ).getFactIndex() );
+ public InternalFactHandle get(final Declaration declaration) {
+ return this.get( declaration.getColumn().getFactIndex() );
}
/**
@@ -207,14 +201,10 @@
* @see java.lang.Object
*/
public String toString() {
- String ret = "TOKEN [" + this.dominantFactHandle + "]\n" + "\tRULE : "
- + this.currentRuleHandle + "\n";
- if (this.currentFactHandles != null) {
- for (int i = 0, length = this.currentFactHandles.length; i < length; i++) {
- ret = ret
- + ( ( i == this.currentRuleHandle.getDominantPosition( ) ) ? "***"
- : "" ) + "\t" + i + " -> "
- + this.currentFactHandles[i].getObject( ) + "\n";
+ String ret = "TOKEN [" + this.dominantFactHandle + "]\n" + "\tRULE : " + this.currentRuleHandle + "\n";
+ if ( this.currentFactHandles != null ) {
+ for ( int i = 0, length = this.currentFactHandles.length; i < length; i++ ) {
+ ret = ret + ((i == this.currentRuleHandle.getDominantPosition()) ? "***" : "") + "\t" + i + " -> " + this.currentFactHandles[i].getObject() + "\n";
}
}
return ret;
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/TokenEvaluator.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/TokenEvaluator.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/TokenEvaluator.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -43,49 +43,43 @@
* @throws Exception
* @throws InvalidRuleException
*/
- final static protected void evaluate( final Token token )
- throws NoMatchesFoundException, InvalidRuleException {
- final LeapsWorkingMemory workingMemory = (LeapsWorkingMemory) token.getWorkingMemory( );
- final LeapsRule leapsRule = token.getCurrentRuleHandle( ).getLeapsRule( );
+ final static protected void evaluate(final Token token) throws NoMatchesFoundException,
+ InvalidRuleException {
+ final LeapsWorkingMemory workingMemory = (LeapsWorkingMemory) token.getWorkingMemory();
+ final LeapsRule leapsRule = token.getCurrentRuleHandle().getLeapsRule();
// sometimes there is no normal conditions, only not and exists
- final int numberOfColumns = leapsRule.getNumberOfColumns( );
+ final int numberOfColumns = leapsRule.getNumberOfColumns();
// if (numberOfColumns > 0) {
- final int dominantFactPosition = token.getCurrentRuleHandle( )
- .getDominantPosition( );
- final InternalFactHandle dominantFactHandle = token.getDominantFactHandle( );
- if (leapsRule.getColumnConstraintsAtPosition( dominantFactPosition )
- .isAllowedAlpha( dominantFactHandle, token, workingMemory )) {
+ final int dominantFactPosition = token.getCurrentRuleHandle().getDominantPosition();
+ final InternalFactHandle dominantFactHandle = token.getDominantFactHandle();
+ if ( leapsRule.getColumnConstraintsAtPosition( dominantFactPosition ).isAllowedAlpha( dominantFactHandle,
+ token,
+ workingMemory ) ) {
final Object dominantClass = leapsRule.getColumnClassObjectTypeAtPosition( dominantFactPosition );
final TableIterator[] iterators = new TableIterator[numberOfColumns];
// getting iterators first
- for (int i = 0; i < numberOfColumns; i++) {
+ for ( int i = 0; i < numberOfColumns; i++ ) {
final Object columnClass = leapsRule.getColumnClassObjectTypeAtPosition( i );
final ColumnConstraints constraints = leapsRule.getColumnConstraintsAtPosition( i );
// we do not need iterators for From constraint
- if (constraints.getClass( ) != FromConstraint.class) {
- if (i == dominantFactPosition) {
+ if ( constraints.getClass() != FromConstraint.class ) {
+ if ( i == dominantFactPosition ) {
iterators[i] = Table.singleItemIterator( dominantFactHandle );
- }
- else {
+ } else {
final FactTable factTable = workingMemory.getFactTable( columnClass );
- final LeapsFactHandle startFactHandle = ( dominantClass == columnClass ) ? new LeapsFactHandle( dominantFactHandle.getRecency( ) - 1,
- new Object( ) )
- : (LeapsFactHandle) dominantFactHandle;
- if (i > 0 && constraints.isAlphaPresent( )) {
+ final LeapsFactHandle startFactHandle = (dominantClass == columnClass) ? new LeapsFactHandle( dominantFactHandle.getRecency() - 1,
+ new Object() ) : (LeapsFactHandle) dominantFactHandle;
+ if ( i > 0 && constraints.isAlphaPresent() ) {
iterators[i] = factTable.constrainedIteratorFromPositionToTableStart( workingMemory,
constraints,
startFactHandle,
- ( token.isResume( ) ? (LeapsFactHandle) token.get( i )
- : startFactHandle ) );
- }
- else {
+ (token.isResume() ? (LeapsFactHandle) token.get( i ) : startFactHandle) );
+ } else {
iterators[i] = factTable.iteratorFromPositionToTableStart( startFactHandle,
- ( token.isResume( ) ? (LeapsFactHandle) token.get( i )
- : startFactHandle ) );
+ (token.isResume() ? (LeapsFactHandle) token.get( i ) : startFactHandle) );
}
}
- }
- else {
+ } else {
// we do not need iterator for from constraint
// it has its own
iterators[i] = null;
@@ -96,19 +90,17 @@
// check if we resume and any starting facts disappeared than we
// do not do skip on resume
boolean doReset = false;
- boolean skip = token.isResume( );
+ boolean skip = token.isResume();
TableIterator currentIterator;
- for (int i = 0; i < numberOfColumns; i++) {
+ for ( int i = 0; i < numberOfColumns; i++ ) {
currentIterator = iterators[i];
- if (currentIterator != null) {
+ if ( currentIterator != null ) {
// check if one of them is empty and immediate return
- if (currentIterator.isEmpty( )) {
- throw new NoMatchesFoundException( );
- }
- else {
- if (!doReset) {
- if (skip && currentIterator.hasNext( )
- && !currentIterator.peekNext( ).equals( token.get( i ) )) {
+ if ( currentIterator.isEmpty() ) {
+ throw new NoMatchesFoundException();
+ } else {
+ if ( !doReset ) {
+ if ( skip && currentIterator.hasNext() && !currentIterator.peekNext().equals( token.get( i ) ) ) {
// we tried to resume but our fact handle at
// marker
// disappear no need to resume just reset all
@@ -118,10 +110,9 @@
skip = false;
doReset = true;
}
+ } else {
+ currentIterator.reset();
}
- else {
- currentIterator.reset( );
- }
}
}
}
@@ -131,77 +122,71 @@
int jj = 0;
boolean done = false;
final int stopIteratingCount = numberOfColumns - 1;
- while (!done) {
+ while ( !done ) {
currentIterator = iterators[jj];
// if it's not From and does not have next
- if (currentIterator != null && !currentIterator.hasNext( )) {
- if (jj == 0) {
+ if ( currentIterator != null && !currentIterator.hasNext() ) {
+ if ( jj == 0 ) {
done = true;
- }
- else {
+ } else {
// nothing for this column, go back and check next
// on the one level up in nested loop
- currentIterator.reset( );
+ currentIterator.reset();
jj = jj - 1;
- if (skip) {
+ if ( skip ) {
skip = false;
}
}
- }
- else {
+ } else {
boolean localMatch = false;
LeapsFactHandle currentFactHandle = null;
- if (currentIterator != null) {
- currentFactHandle = (LeapsFactHandle) currentIterator.next( );
+ if ( currentIterator != null ) {
+ currentFactHandle = (LeapsFactHandle) currentIterator.next();
// check if match found we need to check only beta for
// dominant fact
// alpha was already checked
- if (!skip) {
- if (jj != 0 || jj == dominantFactPosition) {
- localMatch = leapsRule.getColumnConstraintsAtPosition( jj )
- .isAllowedBeta( currentFactHandle,
- token,
- workingMemory );
+ if ( !skip ) {
+ if ( jj != 0 || jj == dominantFactPosition ) {
+ localMatch = leapsRule.getColumnConstraintsAtPosition( jj ).isAllowedBeta( currentFactHandle,
+ token,
+ workingMemory );
+ } else {
+ localMatch = leapsRule.getColumnConstraintsAtPosition( jj ).isAllowed( currentFactHandle,
+ token,
+ workingMemory );
}
- else {
- localMatch = leapsRule.getColumnConstraintsAtPosition( jj )
- .isAllowed( currentFactHandle,
- token,
- workingMemory );
- }
}
- }
- else {
- Object fromMatch = TokenEvaluator.evaluateFrom( (FromConstraint) leapsRule.getColumnConstraintsAtPosition( jj ),
+ } else {
+ final Object fromMatch = TokenEvaluator.evaluateFrom( (FromConstraint) leapsRule.getColumnConstraintsAtPosition( jj ),
token,
leapsRule,
workingMemory );
- if (fromMatch != null) {
+ if ( fromMatch != null ) {
localMatch = true;
// this is not a real fact. just to make it work with
// token / tuple
- currentFactHandle = new LeapsFactHandle( -1, fromMatch );
+ currentFactHandle = new LeapsFactHandle( -1,
+ fromMatch );
}
}
- if (localMatch || skip) {
- token.set( jj, currentFactHandle );
+ if ( localMatch || skip ) {
+ token.set( jj,
+ currentFactHandle );
// start iteratating next iterator or for the last
// one check negative conditions and fire consequence
- if (jj == stopIteratingCount) {
- if (!skip) {
- final LeapsTuple tuple = token.getTuple( );
- if (processAfterAllPositiveConstraintOk( tuple,
- leapsRule,
- workingMemory )) {
+ if ( jj == stopIteratingCount ) {
+ if ( !skip ) {
+ final LeapsTuple tuple = token.getTuple();
+ if ( processAfterAllPositiveConstraintOk( tuple,
+ leapsRule,
+ workingMemory ) ) {
workingMemory.assertTuple( tuple );
return;
}
- }
- else {
+ } else {
skip = false;
}
- }
- else {
+ } else {
jj = jj + 1;
}
}
@@ -209,7 +194,7 @@
}
}
// nothing was found. inform caller about it
- throw new NoMatchesFoundException( );
+ throw new NoMatchesFoundException();
}
/**
@@ -222,21 +207,26 @@
* @return
* @throws Exception
*/
- final static boolean processAfterAllPositiveConstraintOk( final LeapsTuple tuple,
- final LeapsRule leapsRule,
- final LeapsWorkingMemory workingMemory ) {
- if (leapsRule.containsEvalConditions( )
- && !TokenEvaluator.evaluateEvalConditions( tuple, leapsRule, workingMemory )) {
+ final static boolean processAfterAllPositiveConstraintOk(final LeapsTuple tuple,
+ final LeapsRule leapsRule,
+ final LeapsWorkingMemory workingMemory) {
+ if ( leapsRule.containsEvalConditions() && !TokenEvaluator.evaluateEvalConditions( tuple,
+ leapsRule,
+ workingMemory ) ) {
return false;
}
- if (leapsRule.containsExistsColumns( )) {
- TokenEvaluator.evaluateExistsConditions( tuple, leapsRule, workingMemory );
+ if ( leapsRule.containsExistsColumns() ) {
+ TokenEvaluator.evaluateExistsConditions( tuple,
+ leapsRule,
+ workingMemory );
}
- if (tuple.isReadyForActivation( ) && leapsRule.containsNotColumns( )) {
- TokenEvaluator.evaluateNotConditions( tuple, leapsRule, workingMemory );
+ if ( tuple.isReadyForActivation() && leapsRule.containsNotColumns() ) {
+ TokenEvaluator.evaluateNotConditions( tuple,
+ leapsRule,
+ workingMemory );
}
//
- return tuple.isReadyForActivation( );
+ return tuple.isReadyForActivation();
}
/**
@@ -248,13 +238,18 @@
* @return
* @throws Exception
*/
- private final static Object evaluateFrom( final FromConstraint from,
- final Tuple tuple,
- final LeapsRule leapsRule,
- final LeapsWorkingMemory workingMemory ) {
- for (Iterator it = from.getProvider( ).getResults( tuple, workingMemory, null ); it.hasNext( );) {
- Object object = it.next( );
- if (from.isAllowed( new DefaultFactHandle( -1, object ), tuple, workingMemory )) {
+ private final static Object evaluateFrom(final FromConstraint from,
+ final Tuple tuple,
+ final LeapsRule leapsRule,
+ final LeapsWorkingMemory workingMemory) {
+ for ( final Iterator it = from.getProvider().getResults( tuple,
+ workingMemory,
+ null ); it.hasNext(); ) {
+ final Object object = it.next();
+ if ( from.isAllowed( new DefaultFactHandle( -1,
+ object ),
+ tuple,
+ workingMemory ) ) {
return object;
}
}
@@ -270,12 +265,13 @@
* @return
* @throws Exception
*/
- private final static boolean evaluateEvalConditions( final LeapsTuple tuple,
- final LeapsRule leapsRule,
- final LeapsWorkingMemory workingMemory ) {
- final EvalCondition[] evals = leapsRule.getEvalConditions( );
- for (int i = 0; i < evals.length; i++) {
- if (!evals[i].isAllowed( tuple, workingMemory )) {
+ private final static boolean evaluateEvalConditions(final LeapsTuple tuple,
+ final LeapsRule leapsRule,
+ final LeapsWorkingMemory workingMemory) {
+ final EvalCondition[] evals = leapsRule.getEvalConditions();
+ for ( int i = 0; i < evals.length; i++ ) {
+ if ( !evals[i].isAllowed( tuple,
+ workingMemory ) ) {
return false;
}
}
@@ -291,23 +287,27 @@
* @return success
* @throws Exception
*/
- final static void evaluateNotConditions( final LeapsTuple tuple,
- final LeapsRule rule,
- final LeapsWorkingMemory workingMemory ) {
+ final static void evaluateNotConditions(final LeapsTuple tuple,
+ final LeapsRule rule,
+ final LeapsWorkingMemory workingMemory) {
// stops if exists
boolean done = false;
- final ColumnConstraints[] not = rule.getNotColumnConstraints( );
- for (int i = 0, length = not.length; i < length && !done; i++) {
+ final ColumnConstraints[] not = rule.getNotColumnConstraints();
+ for ( int i = 0, length = not.length; i < length && !done; i++ ) {
final ColumnConstraints constraint = not[i];
// scan table starting at start fact handle
- final TableIterator tableIterator = workingMemory.getFactTable( constraint.getClassType( ) )
- .reverseOrderIterator( tuple, constraint );
- while (!done && tableIterator.hasNext( )) {
- final LeapsFactHandle factHandle = (LeapsFactHandle) tableIterator.next( );
+ final TableIterator tableIterator = workingMemory.getFactTable( constraint.getClassType() ).reverseOrderIterator( tuple,
+ constraint );
+ while ( !done && tableIterator.hasNext() ) {
+ final LeapsFactHandle factHandle = (LeapsFactHandle) tableIterator.next();
// check constraint conditions
- if (constraint.isAllowed( factHandle, tuple, workingMemory )) {
- tuple.setBlockingNotFactHandle( factHandle, i );
- factHandle.addNotTuple( tuple, i );
+ if ( constraint.isAllowed( factHandle,
+ tuple,
+ workingMemory ) ) {
+ tuple.setBlockingNotFactHandle( factHandle,
+ i );
+ factHandle.addNotTuple( tuple,
+ i );
done = true;
}
}
@@ -321,34 +321,36 @@
* @param memory
* @throws Exception
*/
- public final static void evaluateExistsConditions( final LeapsTuple tuple,
- final LeapsRule rule,
- final LeapsWorkingMemory workingMemory ) {
+ public final static void evaluateExistsConditions(final LeapsTuple tuple,
+ final LeapsRule rule,
+ final LeapsWorkingMemory workingMemory) {
// stop if exists
boolean notFound = false;
boolean done = false;
- final ColumnConstraints[] exists = rule.getExistsColumnConstraints( );
- for (int i = 0, length = exists.length; !notFound && i < length; i++) {
+ final ColumnConstraints[] exists = rule.getExistsColumnConstraints();
+ for ( int i = 0, length = exists.length; !notFound && i < length; i++ ) {
final ColumnConstraints constraint = exists[i];
- if (!tuple.isExistsFactHandle( i )) {
+ if ( !tuple.isExistsFactHandle( i ) ) {
// scan table starting at start fact handle
- final TableIterator tableIterator = workingMemory.getFactTable( constraint.getClassType( ) )
- .reverseOrderIterator( tuple,
- constraint );
+ final TableIterator tableIterator = workingMemory.getFactTable( constraint.getClassType() ).reverseOrderIterator( tuple,
+ constraint );
done = false;
- while (!done && tableIterator.hasNext( )) {
- final LeapsFactHandle factHandle = (LeapsFactHandle) tableIterator.next( );
+ while ( !done && tableIterator.hasNext() ) {
+ final LeapsFactHandle factHandle = (LeapsFactHandle) tableIterator.next();
// check constraint conditions
- if (constraint.isAllowed( factHandle, tuple, workingMemory )) {
- tuple.setExistsFactHandle( factHandle, i );
- factHandle.addExistsTuple( tuple, i );
+ if ( constraint.isAllowed( factHandle,
+ tuple,
+ workingMemory ) ) {
+ tuple.setExistsFactHandle( factHandle,
+ i );
+ factHandle.addExistsTuple( tuple,
+ i );
done = true;
}
}
- if (!done) {
+ if ( !done ) {
notFound = true;
- workingMemory.getFactTable( constraint.getClassType( ) )
- .addTuple( tuple );
+ workingMemory.getFactTable( constraint.getClassType() ).addTuple( tuple );
}
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/conflict/CompositeConflictResolver.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/conflict/CompositeConflictResolver.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/conflict/CompositeConflictResolver.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -49,8 +49,11 @@
public final Comparator getFactConflictResolver() {
return new FactConflictResolver();
}
-
- class FactConflictResolver implements Comparator, Serializable {
+
+ class FactConflictResolver
+ implements
+ Comparator,
+ Serializable {
public int compare(final Object o1,
final Object o2) {
int ret = 0;
@@ -61,14 +64,17 @@
}
}
return ret;
- }
+ }
}
public final Comparator getRuleConflictResolver() {
return new RuleConflictResolver();
}
-
- class RuleConflictResolver implements Comparator, Serializable {
+
+ class RuleConflictResolver
+ implements
+ Comparator,
+ Serializable {
public int compare(final Object o1,
final Object o2) {
int ret = 0;
@@ -79,7 +85,7 @@
}
}
return ret;
- }
+ }
}
-
+
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/ConstrainedIteratorFromPositionToTableStart.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/ConstrainedIteratorFromPositionToTableStart.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/ConstrainedIteratorFromPositionToTableStart.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -40,29 +40,28 @@
private TableRecord currentTableRecord;
protected ConstrainedIteratorFromPositionToTableStart(final WorkingMemory workingMemory,
- final ColumnConstraints constraints,
- final TableRecord startRecord,
- final TableRecord currentRecord) {
+ final ColumnConstraints constraints,
+ final TableRecord startRecord,
+ final TableRecord currentRecord) {
super( null );
this.workingMemory = workingMemory;
this.constraints = constraints;
this.currentTableRecord = startRecord;
boolean done = false;
boolean reachCurrentRecord = false;
- while (!done && this.currentTableRecord != null && !this.finishInitialPass) {
- if (!reachCurrentRecord && this.currentTableRecord == currentRecord) {
+ while ( !done && this.currentTableRecord != null && !this.finishInitialPass ) {
+ if ( !reachCurrentRecord && this.currentTableRecord == currentRecord ) {
reachCurrentRecord = true;
- }
- else {
- if (this.constraints.isAllowedAlpha( (InternalFactHandle) this.currentTableRecord.object,
- null,
- this.workingMemory )) {
+ } else {
+ if ( this.constraints.isAllowedAlpha( (InternalFactHandle) this.currentTableRecord.object,
+ null,
+ this.workingMemory ) ) {
this.add( this.currentTableRecord.object );
}
- if (reachCurrentRecord && !this.isEmpty( )) {
+ if ( reachCurrentRecord && !this.isEmpty() ) {
done = true;
}
- if (this.currentTableRecord.right == null) {
+ if ( this.currentTableRecord.right == null ) {
this.finishInitialPass = true;
}
this.currentTableRecord = this.currentTableRecord.right;
@@ -70,13 +69,12 @@
}
}
- private void add( final Object object ) {
+ private void add(final Object object) {
final TableRecord record = new TableRecord( object );
- if (this.firstRecord == null) {
+ if ( this.firstRecord == null ) {
this.firstRecord = record;
this.currentRecord = record;
- }
- else {
+ } else {
this.currentRecord.right = record;
record.left = this.currentRecord;
this.currentRecord = record;
@@ -86,30 +84,28 @@
}
public boolean hasNext() {
- if (!this.finishInitialPass) {
- if (this.nextRecord == null) {
+ if ( !this.finishInitialPass ) {
+ if ( this.nextRecord == null ) {
boolean found = false;
- while (!found && this.currentTableRecord != null) {
- if (this.constraints.isAllowedAlpha( (InternalFactHandle) this.currentTableRecord.object,
- null,
- this.workingMemory )) {
+ while ( !found && this.currentTableRecord != null ) {
+ if ( this.constraints.isAllowedAlpha( (InternalFactHandle) this.currentTableRecord.object,
+ null,
+ this.workingMemory ) ) {
this.add( this.currentTableRecord.object );
found = true;
}
- if (this.currentTableRecord == null) {
+ if ( this.currentTableRecord == null ) {
this.finishInitialPass = true;
}
this.currentTableRecord = this.currentTableRecord.right;
}
return found;
- }
- else {
+ } else {
return true;
}
+ } else {
+ return super.hasNext();
}
- else {
- return super.hasNext( );
- }
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/IteratorFromPositionToTableEnd.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/IteratorFromPositionToTableEnd.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/IteratorFromPositionToTableEnd.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -37,8 +37,9 @@
* @see IteratorFromPositionToTableStart
*/
protected IteratorFromPositionToTableEnd(final TableRecord startRecord,
- final TableRecord currentRecord) {
- super( startRecord, currentRecord );
+ final TableRecord currentRecord) {
+ super( startRecord,
+ currentRecord );
}
/**
@@ -51,10 +52,9 @@
public Object next() {
this.currentRecord = this.nextRecord;
- if (this.currentRecord != null) {
+ if ( this.currentRecord != null ) {
this.nextRecord = this.currentRecord.left;
- }
- else {
+ } else {
throw new NoSuchElementException( "No more elements to return" );
}
return this.currentRecord.object;
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/IteratorFromPositionToTableStart.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/IteratorFromPositionToTableStart.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/IteratorFromPositionToTableStart.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -25,7 +25,9 @@
* @author Alexander Bagerman
*
*/
-public class IteratorFromPositionToTableStart implements TableIterator {
+public class IteratorFromPositionToTableStart
+ implements
+ TableIterator {
/**
* interator that was not initialized as "empty" iterator (one or another
* record was submitted to constractor) will set it to false
@@ -51,7 +53,7 @@
}
public IteratorFromPositionToTableStart(final TableRecord startRecord,
- final TableRecord currentRecord) {
+ final TableRecord currentRecord) {
this.firstRecord = startRecord;
this.nextRecord = currentRecord;
this.currentRecord = null;
@@ -72,10 +74,9 @@
public Object next() {
this.currentRecord = this.nextRecord;
- if (this.currentRecord != null) {
+ if ( this.currentRecord != null ) {
this.nextRecord = this.currentRecord.right;
- }
- else {
+ } else {
throw new NoSuchElementException( "No more elements to return" );
}
return this.currentRecord.object;
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/RecordComparator.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/RecordComparator.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/RecordComparator.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -16,7 +16,6 @@
* limitations under the License.
*/
-
import java.io.Serializable;
import java.util.Comparator;
@@ -28,16 +27,20 @@
*
*/
-class RecordComparator implements Comparator, Serializable {
+class RecordComparator
+ implements
+ Comparator,
+ Serializable {
private Comparator objectComparator;
- RecordComparator(Comparator objectComparator) {
+ RecordComparator(final Comparator objectComparator) {
this.objectComparator = objectComparator;
}
- public int compare( Object record1, Object record2 ) {
- return this.objectComparator.compare( ( (TableRecord) record1 ).object,
- ( (TableRecord) record2 ).object );
+ public int compare(final Object record1,
+ final Object record2) {
+ return this.objectComparator.compare( ((TableRecord) record1).object,
+ ((TableRecord) record2).object );
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/Table.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/Table.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/Table.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -32,7 +32,9 @@
* @author Alexander Bagerman
*
*/
-public class Table implements Serializable {
+public class Table
+ implements
+ Serializable {
/**
*
@@ -50,42 +52,39 @@
private int count = 0;
public Table(final Comparator comparator) {
- this.set = new TreeSet( new RecordComparator(comparator) );
+ this.set = new TreeSet( new RecordComparator( comparator ) );
}
public void clear() {
this.headRecord = null;
this.empty = true;
this.count = 0;
- this.set.clear( );
+ this.set.clear();
}
/**
* @param object
* to add
*/
- public void add( final Object object ) {
+ public void add(final Object object) {
final TableRecord newRecord = new TableRecord( object );
- if (this.empty) {
+ if ( this.empty ) {
this.headRecord = newRecord;
this.empty = false;
- }
- else {
+ } else {
try {
// check on first key should work faster than check on empty
// but logically we check on empty
// if map empty it will throw exception
- final TableRecord bufRec = (TableRecord) this.set.headSet( newRecord )
- .last( );
- if (bufRec.right != null) {
+ final TableRecord bufRec = (TableRecord) this.set.headSet( newRecord ).last();
+ if ( bufRec.right != null ) {
bufRec.right.left = newRecord;
}
newRecord.right = bufRec.right;
bufRec.right = newRecord;
newRecord.left = bufRec;
- }
- catch (final NoSuchElementException nsee) {
+ } catch ( final NoSuchElementException nsee ) {
// means sub map is empty
this.headRecord.left = newRecord;
newRecord.right = this.headRecord;
@@ -94,7 +93,7 @@
}
// check if the new record was added at the end of the list
// and assign new value to the tail record
- if (newRecord.right == null) {
+ if ( newRecord.right == null ) {
this.tailRecord = newRecord;
}
//
@@ -109,47 +108,41 @@
* @param object
* to remove from the table
*/
- public void remove( final Object object ) {
- if (!this.empty) {
+ public void remove(final Object object) {
+ if ( !this.empty ) {
try {
- final TableRecord record = (TableRecord) this.set.tailSet( new TableRecord( object ) )
- .first( );
- if (record != null && record.object == object) {
- if (record == this.headRecord ) {
- if (record.right != null) {
+ final TableRecord record = (TableRecord) this.set.tailSet( new TableRecord( object ) ).first();
+ if ( record != null && record.object == object ) {
+ if ( record == this.headRecord ) {
+ if ( record.right != null ) {
this.headRecord = record.right;
this.headRecord.left = null;
- }
- else {
+ } else {
// single element in table being valid
// table is empty now
this.headRecord = null;
this.tailRecord = null;
this.empty = true;
}
- }
- else if (record == this.tailRecord) {
+ } else if ( record == this.tailRecord ) {
// single element in the table case is being solved
// above in check for headRecord match
this.tailRecord = record.left;
this.tailRecord.right = null;
- }
- else {
+ } else {
// left
record.left.right = record.right;
record.right.left = record.left;
}
record.left = null;
record.right = null;
- }
- else {
+ } else {
throw new NoSuchElementException();
}
this.count--;
//
this.set.remove( record );
- }
- catch (final NoSuchElementException nsee) {
+ } catch ( final NoSuchElementException nsee ) {
throw nsee;
}
}
@@ -159,9 +152,9 @@
* @param object
* @return indicator of presence of given object in the table
*/
- public boolean contains( final Object object ) {
+ public boolean contains(final Object object) {
boolean ret = false;
- if (!this.empty) {
+ if ( !this.empty ) {
ret = this.set.contains( new TableRecord( object ) );
}
return ret;
@@ -174,23 +167,25 @@
*/
public TableIterator iterator() {
TableIterator ret;
- if (this.empty) {
- ret = new IteratorFromPositionToTableStart( null, null );
+ if ( this.empty ) {
+ ret = new IteratorFromPositionToTableStart( null,
+ null );
+ } else {
+ ret = new IteratorFromPositionToTableStart( this.headRecord,
+ this.headRecord );
}
- else {
- ret = new IteratorFromPositionToTableStart( this.headRecord, this.headRecord );
- }
return ret;
}
public TableIterator reverseOrderIterator() {
TableIterator ret;
- if (this.empty) {
- ret = new IteratorFromPositionToTableEnd( null, null );
+ if ( this.empty ) {
+ ret = new IteratorFromPositionToTableEnd( null,
+ null );
+ } else {
+ ret = new IteratorFromPositionToTableEnd( this.tailRecord,
+ this.tailRecord );
}
- else {
- ret = new IteratorFromPositionToTableEnd( this.tailRecord, this.tailRecord );
- }
return ret;
}
@@ -205,10 +200,10 @@
* @return leaps table iterator
* @throws TableOutOfBoundException
*/
- public TableIterator constrainedIteratorFromPositionToTableStart( final WorkingMemory workingMemory,
- final ColumnConstraints constraints,
- final Object objectAtStart,
- final Object objectAtPosition ) {
+ public TableIterator constrainedIteratorFromPositionToTableStart(final WorkingMemory workingMemory,
+ final ColumnConstraints constraints,
+ final Object objectAtStart,
+ final Object objectAtPosition) {
return getIteratorFromPositionToTableStart( true,
workingMemory,
constraints,
@@ -227,8 +222,8 @@
* @return leaps table iterator
* @throws TableOutOfBoundException
*/
- public TableIterator iteratorFromPositionToTableStart( final Object objectAtStart,
- final Object objectAtPosition ) {
+ public TableIterator iteratorFromPositionToTableStart(final Object objectAtStart,
+ final Object objectAtPosition) {
return getIteratorFromPositionToTableStart( false,
null,
null,
@@ -247,16 +242,15 @@
* @return leaps table iterator
* @throws TableOutOfBoundException
*/
- public TableIterator iteratorFromPositionToTableEnd( final Object objectAtStart ) {
+ public TableIterator iteratorFromPositionToTableEnd(final Object objectAtStart) {
TableRecord record = null;
try {
- record = (TableRecord) this.set.headSet( new TableRecord( objectAtStart ) )
- .last( );
+ record = (TableRecord) this.set.headSet( new TableRecord( objectAtStart ) ).last();
+ } catch ( final NoSuchElementException nsee ) {
}
- catch (final NoSuchElementException nsee) {
- }
- return new IteratorFromPositionToTableEnd( record, record );
+ return new IteratorFromPositionToTableEnd( record,
+ record );
}
/**
@@ -266,51 +260,47 @@
* upper boundary of the iteration
* @return Markers structure
*/
- private TableIterator getIteratorFromPositionToTableStart( final boolean isConstraint,
- final WorkingMemory workingMemory,
- final ColumnConstraints constraints,
- final Object objectAtStart,
- final Object objectAtPosition ) {
+ private TableIterator getIteratorFromPositionToTableStart(final boolean isConstraint,
+ final WorkingMemory workingMemory,
+ final ColumnConstraints constraints,
+ final Object objectAtStart,
+ final Object objectAtPosition) {
TableRecord startRecord = null;
TableRecord currentRecord = null;
- TableRecord recordAtStart = new TableRecord( objectAtStart );
- if (!this.empty) {
+ final TableRecord recordAtStart = new TableRecord( objectAtStart );
+ if ( !this.empty ) {
try {
// check on first key should work faster than check
// to see if set has no elements
// if set is empty it will throw exception
- startRecord = (TableRecord) this.set.tailSet( recordAtStart ).first( );
- if (objectAtStart == objectAtPosition) {
+ startRecord = (TableRecord) this.set.tailSet( recordAtStart ).first();
+ if ( objectAtStart == objectAtPosition ) {
currentRecord = startRecord;
- }
- else {
+ } else {
// rewind to position
try {
// check on first key should work faster than check
// to see if set has no elements
// if set is empty it will throw exception
- currentRecord = (TableRecord) this.set.tailSet( new TableRecord( objectAtPosition ) )
- .first( );
- }
- catch (final NoSuchElementException nsee) {
+ currentRecord = (TableRecord) this.set.tailSet( new TableRecord( objectAtPosition ) ).first();
+ } catch ( final NoSuchElementException nsee ) {
currentRecord = startRecord;
}
}
+ } catch ( final NoSuchElementException nsee ) {
}
- catch (final NoSuchElementException nsee) {
- }
}
- if (isConstraint ) {
+ if ( isConstraint ) {
return new ConstrainedIteratorFromPositionToTableStart( workingMemory,
- constraints,
- startRecord,
- currentRecord );
+ constraints,
+ startRecord,
+ currentRecord );
+ } else {
+ return new IteratorFromPositionToTableStart( startRecord,
+ currentRecord );
}
- else {
- return new IteratorFromPositionToTableStart( startRecord, currentRecord );
- }
}
/**
@@ -325,8 +315,8 @@
public String toString() {
String ret = "";
- for (final Iterator it = this.iterator( ); it.hasNext( );) {
- ret = ret + it.next( ) + "\n";
+ for ( final Iterator it = this.iterator(); it.hasNext(); ) {
+ ret = ret + it.next() + "\n";
}
return ret;
}
@@ -343,11 +333,12 @@
return this.tailRecord.object;
}
- public static TableIterator singleItemIterator( final Object object ) {
+ public static TableIterator singleItemIterator(final Object object) {
return new IteratorFromPositionToTableStart( new TableRecord( object ) );
}
public static TableIterator emptyIterator() {
- return new IteratorFromPositionToTableStart( null, null );
+ return new IteratorFromPositionToTableStart( null,
+ null );
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/TableIterator.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/TableIterator.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/TableIterator.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -25,7 +25,9 @@
* @author Alexander Bagerman
*
*/
-public interface TableIterator extends Iterator {
+public interface TableIterator
+ extends
+ Iterator {
/**
* single object iterator
*
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/TableRecord.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/TableRecord.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/TableRecord.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -23,7 +23,9 @@
* @author Alexander Bagerman
*
*/
-public class TableRecord implements Serializable {
+public class TableRecord
+ implements
+ Serializable {
/**
*
*/
@@ -45,14 +47,13 @@
}
public int hashCode() {
- return this.object.hashCode( );
+ return this.object.hashCode();
}
- public boolean equals( final Object that ) {
- if (this.object != null) {
- return this.object.equals( ( (TableRecord) that ).object );
- }
- else {
+ public boolean equals(final Object that) {
+ if ( this.object != null ) {
+ return this.object.equals( ((TableRecord) that).object );
+ } else {
return that == null;
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/TokenStack.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/TokenStack.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/util/TokenStack.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -31,11 +31,13 @@
*
*/
-public class TokenStack implements Serializable {
+public class TokenStack
+ implements
+ Serializable {
protected TableRecord tailRecord = null;
- private final PrimitiveLongMap map = new PrimitiveLongMap( );
+ private final PrimitiveLongMap map = new PrimitiveLongMap();
public TokenStack() {
@@ -46,30 +48,28 @@
}
public Object peek() {
- if (this.tailRecord != null) {
+ if ( this.tailRecord != null ) {
return this.tailRecord.object;
+ } else {
+ throw new EmptyStackException();
}
- else {
- throw new EmptyStackException( );
- }
}
public Object pop() {
- if (this.tailRecord != null) {
+ if ( this.tailRecord != null ) {
final Object ret = this.tailRecord.object;
final TableRecord buf = this.tailRecord;
this.tailRecord = buf.left;
- if (buf.left != null) {
+ if ( buf.left != null ) {
this.tailRecord.right = null;
}
buf.left = null;
- this.map.remove( ( (Token) ret ).getDominantFactHandle( ).getId( ) );
+ this.map.remove( ((Token) ret).getDominantFactHandle().getId() );
return ret;
+ } else {
+ throw new EmptyStackException();
}
- else {
- throw new EmptyStackException( );
- }
}
/**
@@ -78,18 +78,18 @@
* @param object
* to remove from the table
*/
- public void remove( final long factId ) {
- if (this.tailRecord != null) {
+ public void remove(final long factId) {
+ if ( this.tailRecord != null ) {
final TableRecord record = (TableRecord) this.map.remove( factId );
- if (record != null) {
- if (record == this.tailRecord) {
+ if ( record != null ) {
+ if ( record == this.tailRecord ) {
this.tailRecord = record.left;
}
- if (record.left != null) {
+ if ( record.left != null ) {
record.left.right = record.right;
}
- if (record.right != null) {
+ if ( record.right != null ) {
record.right.left = record.left;
}
record.left = null;
@@ -98,24 +98,25 @@
}
}
- public Object push( final Object item ) {
+ public Object push(final Object item) {
final TableRecord record = new TableRecord( item );
- if (this.tailRecord != null) {
+ if ( this.tailRecord != null ) {
this.tailRecord.right = record;
record.left = this.tailRecord;
}
this.tailRecord = record;
- this.map.put( ( (Token) item ).getDominantFactHandle( ).getId( ), record );
+ this.map.put( ((Token) item).getDominantFactHandle().getId(),
+ record );
return item;
}
public Iterator iterator() {
- return new Iterator( ) {
- Iterator it = TokenStack.this.map.values( ).iterator( );
+ return new Iterator() {
+ Iterator it = TokenStack.this.map.values().iterator();
public boolean hasNext() {
- return this.it.hasNext( );
+ return this.it.hasNext();
}
public void remove() {
@@ -123,7 +124,7 @@
}
public Object next() {
- return this.it.next( );
+ return this.it.next();
}
};
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/AccumulateNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/AccumulateNode.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/AccumulateNode.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -42,11 +42,11 @@
*/
public class AccumulateNode extends BetaNode {
- private static final long serialVersionUID = -4081578178269297948L;
+ private static final long serialVersionUID = -4081578178269297948L;
- private final Accumulate accumulate;
- private final AlphaNodeFieldConstraint[] constraints;
- private final BetaConstraints resultsBinder;
+ private final Accumulate accumulate;
+ private final AlphaNodeFieldConstraint[] constraints;
+ private final BetaConstraints resultsBinder;
/**
* Construct.
@@ -108,9 +108,9 @@
* Object result = this.accumulator.accumulate( ... );
*
*/
- public void assertTuple(ReteTuple leftTuple,
- PropagationContext context,
- InternalWorkingMemory workingMemory) {
+ public void assertTuple(final ReteTuple leftTuple,
+ final PropagationContext context,
+ final InternalWorkingMemory workingMemory) {
final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
@@ -119,7 +119,7 @@
//final BetaNodeBinder binder = getJoinNodeBinder();
- List matchingObjects = new ArrayList();
+ final List matchingObjects = new ArrayList();
for ( final Iterator it = memory.rightObjectIterator( workingMemory,
leftTuple ); it.hasNext(); ) {
final ObjectMatches objectMatches = (ObjectMatches) it.next();
@@ -134,7 +134,7 @@
}
}
- Object result = this.accumulate.accumulate( leftTuple,
+ final Object result = this.accumulate.accumulate( leftTuple,
matchingObjects,
workingMemory );
@@ -149,7 +149,7 @@
}
}
if ( isAllowed ) {
- InternalFactHandle handle = workingMemory.getFactHandleFactory().newFactHandle( result );
+ final InternalFactHandle handle = workingMemory.getFactHandleFactory().newFactHandle( result );
if ( this.resultsBinder.isAllowed( handle,
leftTuple,
@@ -170,9 +170,9 @@
* a modify is really a retract + assert.
*
*/
- public void modifyTuple(ReteTuple leftTuple,
- PropagationContext context,
- InternalWorkingMemory workingMemory) {
+ public void modifyTuple(final ReteTuple leftTuple,
+ final PropagationContext context,
+ final InternalWorkingMemory workingMemory) {
this.retractTuple( leftTuple,
context,
@@ -190,9 +190,9 @@
* it must always also retreat it.
*
*/
- public void retractTuple(ReteTuple leftTuple,
- PropagationContext context,
- InternalWorkingMemory workingMemory) {
+ public void retractTuple(final ReteTuple leftTuple,
+ final PropagationContext context,
+ final InternalWorkingMemory workingMemory) {
final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
memory.remove( workingMemory,
leftTuple );
@@ -210,7 +210,7 @@
// if tuple was propagated
if ( (leftTuple.getChildEntries() != null) && (leftTuple.getChildEntries().size() > 0) ) {
// Need to store the accumulate result object for later disposal
- InternalFactHandle lastHandle = ((ReteTuple) ((LinkedListEntry) leftTuple.getChildEntries().getFirst()).getObject()).getLastHandle();
+ final InternalFactHandle lastHandle = ((ReteTuple) ((LinkedListEntry) leftTuple.getChildEntries().getFirst()).getObject()).getLastHandle();
leftTuple.retractChildEntries( context,
workingMemory );
@@ -229,9 +229,9 @@
* 2. For each matching tuple, call a modify tuple
*
*/
- public void assertObject(InternalFactHandle handle,
- PropagationContext context,
- InternalWorkingMemory workingMemory) {
+ public void assertObject(final InternalFactHandle handle,
+ final PropagationContext context,
+ final InternalWorkingMemory workingMemory) {
final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
memory.add( workingMemory,
@@ -264,9 +264,9 @@
* So, a modify object is in fact a retract+assert object.
*
*/
- public void modifyObject(InternalFactHandle handle,
- PropagationContext context,
- InternalWorkingMemory workingMemory) {
+ public void modifyObject(final InternalFactHandle handle,
+ final PropagationContext context,
+ final InternalWorkingMemory workingMemory) {
final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
// Remove the FactHandle from memory
@@ -291,9 +291,9 @@
* If an object is retract, call modify tuple for each
* tuple match.
*/
- public void retractObject(InternalFactHandle handle,
- PropagationContext context,
- InternalWorkingMemory workingMemory) {
+ public void retractObject(final InternalFactHandle handle,
+ final PropagationContext context,
+ final InternalWorkingMemory workingMemory) {
final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
// Remove the FactHandle from memory
@@ -313,8 +313,8 @@
/**
* @inheritDoc
*/
- public List getPropagatedTuples(InternalWorkingMemory workingMemory,
- TupleSink sink) {
+ public List getPropagatedTuples(final InternalWorkingMemory workingMemory,
+ final TupleSink sink) {
// FIXME
final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
final List propagatedTuples = new ArrayList();
@@ -323,7 +323,7 @@
final ReteTuple leftTuple = (ReteTuple) it.next();
final LinkedList linkedTuples = leftTuple.getChildEntries();
- LinkedListEntry wrapper = (LinkedListEntry) linkedTuples.getFirst();
+ final LinkedListEntry wrapper = (LinkedListEntry) linkedTuples.getFirst();
propagatedTuples.add( wrapper.getObject() );
}
return propagatedTuples;
@@ -332,8 +332,8 @@
/**
* @inheritDoc
*/
- public void updateNewNode(InternalWorkingMemory workingMemory,
- PropagationContext context) {
+ public void updateNewNode(final InternalWorkingMemory workingMemory,
+ final PropagationContext context) {
// FIXME
this.attachingNewNode = true;
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/AlphaNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/AlphaNode.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/AlphaNode.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -47,13 +47,13 @@
/**
*
*/
- private static final long serialVersionUID = 320L;
+ private static final long serialVersionUID = 320L;
/** The <code>FieldConstraint</code> */
private final AlphaNodeFieldConstraint constraint;
- private ObjectSinkNode previousObjectSinkNode;
- private ObjectSinkNode nextObjectSinkNode;
+ private ObjectSinkNode previousObjectSinkNode;
+ private ObjectSinkNode nextObjectSinkNode;
/**
* Construct an <code>AlphaNode</code> with a unique id using the provided
@@ -67,7 +67,10 @@
AlphaNode(final int id,
final AlphaNodeFieldConstraint constraint,
final ObjectSource objectSource) {
- this(id, constraint, objectSource, true);
+ this( id,
+ constraint,
+ objectSource,
+ true );
}
/**
@@ -138,7 +141,7 @@
memory.add( handle,
false );
}
- sink.propagateAssertObject( handle,
+ this.sink.propagateAssertObject( handle,
context,
workingMemory );
}
@@ -159,23 +162,25 @@
true );
}
}
-
- public void updateSink(ObjectSink sink,
- PropagationContext context,
- InternalWorkingMemory workingMemory) {
+
+ public void updateSink(final ObjectSink sink,
+ final PropagationContext context,
+ final InternalWorkingMemory workingMemory) {
FactHashTable memory = null;
-
+
if ( !hasMemory() ) {
// get the objects from the parent
- this.objectSource.updateSink( sink, context, workingMemory );
+ this.objectSource.updateSink( sink,
+ context,
+ workingMemory );
} else {
// if already has memory, just iterate and propagate
memory = (FactHashTable) workingMemory.getNodeMemory( this );
- Iterator it = memory.iterator();
- for ( FactEntry entry = ( FactEntry ) it.next(); entry != null; entry = ( FactEntry ) it.next() ) {
+ final Iterator it = memory.iterator();
+ for ( FactEntry entry = (FactEntry) it.next(); entry != null; entry = (FactEntry) it.next() ) {
sink.assertObject( entry.getFactHandle(),
context,
- workingMemory );
+ workingMemory );
}
}
}
@@ -244,7 +249,7 @@
* @param next
* The next ObjectSinkNode
*/
- public void setNextObjectSinkNode(ObjectSinkNode next) {
+ public void setNextObjectSinkNode(final ObjectSinkNode next) {
this.nextObjectSinkNode = next;
}
@@ -262,8 +267,8 @@
* @param previous
* The previous ObjectSinkNode
*/
- public void setPreviousObjectSinkNode(ObjectSinkNode previous) {
+ public void setPreviousObjectSinkNode(final ObjectSinkNode previous) {
this.previousObjectSinkNode = previous;
}
-
+
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/BetaMemory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/BetaMemory.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/BetaMemory.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -3,19 +3,20 @@
import org.drools.util.TupleHashTable;
public class BetaMemory {
- private TupleHashTable tupleMemory;
+ private TupleHashTable tupleMemory;
private ObjectHashTable objectMemory;
-
- public BetaMemory(TupleHashTable tupleMemory, ObjectHashTable objectMemory) {
- this.tupleMemory = tupleMemory;
+
+ public BetaMemory(final TupleHashTable tupleMemory,
+ final ObjectHashTable objectMemory) {
+ this.tupleMemory = tupleMemory;
this.objectMemory = objectMemory;
}
public ObjectHashTable getObjectMemory() {
- return objectMemory;
+ return this.objectMemory;
}
public TupleHashTable getTupleMemory() {
- return tupleMemory;
- }
+ return this.tupleMemory;
+ }
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/BetaNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/BetaNode.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/BetaNode.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -20,27 +20,16 @@
import java.util.List;
import org.drools.RuleBaseConfiguration;
-import org.drools.base.evaluators.Operator;
import org.drools.common.BaseNode;
import org.drools.common.BetaConstraints;
-import org.drools.common.DefaultBetaConstraints;
import org.drools.common.EmptyBetaConstraints;
-import org.drools.common.InternalFactHandle;
import org.drools.common.InternalWorkingMemory;
import org.drools.common.NodeMemory;
import org.drools.common.PropagationContextImpl;
-import org.drools.rule.LiteralConstraint;
-import org.drools.rule.VariableConstraint;
-import org.drools.spi.BetaNodeFieldConstraint;
-import org.drools.spi.Evaluator;
import org.drools.spi.AlphaNodeFieldConstraint;
-import org.drools.spi.FieldExtractor;
import org.drools.spi.PropagationContext;
-import org.drools.util.FactHashTable;
-import org.drools.util.FieldIndexHashTable;
import org.drools.util.LinkedList;
import org.drools.util.LinkedListEntry;
-import org.drools.util.TupleHashTable;
/**
* <code>BetaNode</code> provides the base abstract class for <code>JoinNode</code> and <code>NotNode</code>. It implements
@@ -64,18 +53,18 @@
// ------------------------------------------------------------
/** The left input <code>TupleSource</code>. */
- protected final TupleSource leftInput;
+ protected final TupleSource leftInput;
/** The right input <code>TupleSource</code>. */
- protected final ObjectSource rightInput;
+ protected final ObjectSource rightInput;
protected final BetaConstraints constraints;
- private TupleSinkNode previousTupleSinkNode;
- private TupleSinkNode nextTupleSinkNode;
+ private TupleSinkNode previousTupleSinkNode;
+ private TupleSinkNode nextTupleSinkNode;
- private ObjectSinkNode previousObjectSinkNode;
- private ObjectSinkNode nextObjectSinkNode;
+ private ObjectSinkNode previousObjectSinkNode;
+ private ObjectSinkNode nextObjectSinkNode;
// ------------------------------------------------------------
// Constructors
@@ -117,9 +106,9 @@
}
public AlphaNodeFieldConstraint[] getConstraints() {
- LinkedList constraints = this.constraints.getConstraints();
+ final LinkedList constraints = this.constraints.getConstraints();
- AlphaNodeFieldConstraint[] array = new AlphaNodeFieldConstraint[constraints.size()];
+ final AlphaNodeFieldConstraint[] array = new AlphaNodeFieldConstraint[constraints.size()];
int i = 0;
for ( LinkedListEntry entry = (LinkedListEntry) constraints.getFirst(); entry != null; entry = (LinkedListEntry) entry.getNext() ) {
array[i++] = (AlphaNodeFieldConstraint) entry.getObject();
@@ -136,9 +125,9 @@
}
public List getRules() {
- List list = new ArrayList();
+ final List list = new ArrayList();
- TupleSink[] sinks = this.sink.getSinks();
+ final TupleSink[] sinks = this.sink.getSinks();
for ( int i = 0, length = sinks.length; i < length; i++ ) {
if ( sinks[i].getClass() == TerminalNode.class ) {
list.add( ((TerminalNode) sinks[i]).getRule().getName() );
@@ -204,8 +193,8 @@
return "";
}
- public void dumpMemory(InternalWorkingMemory workingMemory) {
- MemoryVisitor visitor = new MemoryVisitor( workingMemory );
+ public void dumpMemory(final InternalWorkingMemory workingMemory) {
+ final MemoryVisitor visitor = new MemoryVisitor( workingMemory );
visitor.visit( this );
}
@@ -238,42 +227,42 @@
*/
public Object createMemory(final RuleBaseConfiguration config) {
return this.constraints.createBetaMemory();
-// // iterate over all the constraints untill we find one that is indexeable. When we find it we remove it from the list and create the
-// // BetaMemory for it. If we don't find one, we create a normal beta memory. We don't need the constraint as we can assume that
-// // anything returned by the memory already passes that test.
-// LinkedList constraints = this.constraints.getConstraints();
-// BetaMemory memory = null;
-//
-// if ( constraints != null ) {
-// for ( LinkedListEntry entry = (LinkedListEntry) constraints.getFirst(); entry != null; entry = (LinkedListEntry) entry.getNext() ) {
-// BetaNodeFieldConstraint constraint = (BetaNodeFieldConstraint) entry.getObject();
-// if ( constraint.getClass() == VariableConstraint.class ) {
-// VariableConstraint variableConstraint = (VariableConstraint) constraint;
-// FieldExtractor extractor = variableConstraint.getFieldExtractor();
-// Evaluator evaluator = variableConstraint.getEvaluator();
-// if ( evaluator.getOperator() == Operator.EQUAL ) {
-// // make suret the indexed constraint is first
-// if ( constraints.getFirst() != entry ) {
-// constraints.remove( entry );
-// constraints.insertAfter( null,
-// entry );
-// }
-// memory = new BetaMemory( new TupleHashTable(),
-// new FieldIndexHashTable( extractor,
-// variableConstraint.getRequiredDeclarations()[0] ) );
-// break;
-//
-// }
-// }
-// }
-// }
-//
-// if ( memory == null ) {
-// memory = new BetaMemory( new TupleHashTable(),
-// new FactHashTable() );
-// }
-//
-// return memory;
+ // // iterate over all the constraints untill we find one that is indexeable. When we find it we remove it from the list and create the
+ // // BetaMemory for it. If we don't find one, we create a normal beta memory. We don't need the constraint as we can assume that
+ // // anything returned by the memory already passes that test.
+ // LinkedList constraints = this.constraints.getConstraints();
+ // BetaMemory memory = null;
+ //
+ // if ( constraints != null ) {
+ // for ( LinkedListEntry entry = (LinkedListEntry) constraints.getFirst(); entry != null; entry = (LinkedListEntry) entry.getNext() ) {
+ // BetaNodeFieldConstraint constraint = (BetaNodeFieldConstraint) entry.getObject();
+ // if ( constraint.getClass() == VariableConstraint.class ) {
+ // VariableConstraint variableConstraint = (VariableConstraint) constraint;
+ // FieldExtractor extractor = variableConstraint.getFieldExtractor();
+ // Evaluator evaluator = variableConstraint.getEvaluator();
+ // if ( evaluator.getOperator() == Operator.EQUAL ) {
+ // // make suret the indexed constraint is first
+ // if ( constraints.getFirst() != entry ) {
+ // constraints.remove( entry );
+ // constraints.insertAfter( null,
+ // entry );
+ // }
+ // memory = new BetaMemory( new TupleHashTable(),
+ // new FieldIndexHashTable( extractor,
+ // variableConstraint.getRequiredDeclarations()[0] ) );
+ // break;
+ //
+ // }
+ // }
+ // }
+ // }
+ //
+ // if ( memory == null ) {
+ // memory = new BetaMemory( new TupleHashTable(),
+ // new FactHashTable() );
+ // }
+ //
+ // return memory;
}
/**
@@ -290,7 +279,7 @@
* @param next
* The next TupleSinkNode
*/
- public void setNextTupleSinkNode(TupleSinkNode next) {
+ public void setNextTupleSinkNode(final TupleSinkNode next) {
this.nextTupleSinkNode = next;
}
@@ -308,7 +297,7 @@
* @param previous
* The previous TupleSinkNode
*/
- public void setPreviousTupleSinkNode(TupleSinkNode previous) {
+ public void setPreviousTupleSinkNode(final TupleSinkNode previous) {
this.previousTupleSinkNode = previous;
}
@@ -326,7 +315,7 @@
* @param next
* The next ObjectSinkNode
*/
- public void setNextObjectSinkNode(ObjectSinkNode next) {
+ public void setNextObjectSinkNode(final ObjectSinkNode next) {
this.nextObjectSinkNode = next;
}
@@ -344,7 +333,7 @@
* @param previous
* The previous ObjectSinkNode
*/
- public void setPreviousObjectSinkNode(ObjectSinkNode previous) {
+ public void setPreviousObjectSinkNode(final ObjectSinkNode previous) {
this.previousObjectSinkNode = previous;
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/CollectNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/CollectNode.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/CollectNode.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -41,11 +41,11 @@
TupleSink,
ObjectSink {
- private static final long serialVersionUID = -8321568626178187047L;
+ private static final long serialVersionUID = -8321568626178187047L;
- private final Collect collect;
- private final AlphaNodeFieldConstraint[] resultConstraints;
- private final BetaConstraints resultsBinder;
+ private final Collect collect;
+ private final AlphaNodeFieldConstraint[] resultConstraints;
+ private final BetaConstraints resultsBinder;
/**
* Constructor.
@@ -119,9 +119,9 @@
* 4.2. Propagate the tuple
*
*/
- public void assertTuple(ReteTuple leftTuple,
- PropagationContext context,
- InternalWorkingMemory workingMemory) {
+ public void assertTuple(final ReteTuple leftTuple,
+ final PropagationContext context,
+ final InternalWorkingMemory workingMemory) {
final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
@@ -130,7 +130,7 @@
//final BetaNodeBinder binder = getJoinNodeBinder();
- Collection result = this.collect.instantiateResultObject();
+ final Collection result = this.collect.instantiateResultObject();
for ( final Iterator it = memory.rightObjectIterator( workingMemory,
leftTuple ); it.hasNext(); ) {
final ObjectMatches objectMatches = (ObjectMatches) it.next();
@@ -156,7 +156,7 @@
}
}
if ( isAllowed ) {
- InternalFactHandle handle = workingMemory.getFactHandleFactory().newFactHandle( result );
+ final InternalFactHandle handle = workingMemory.getFactHandleFactory().newFactHandle( result );
if ( this.resultsBinder.isAllowed( handle,
leftTuple,
@@ -177,9 +177,9 @@
* a modify is really a retract + assert.
*
*/
- public void modifyTuple(ReteTuple leftTuple,
- PropagationContext context,
- InternalWorkingMemory workingMemory) {
+ public void modifyTuple(final ReteTuple leftTuple,
+ final PropagationContext context,
+ final InternalWorkingMemory workingMemory) {
this.retractTuple( leftTuple,
context,
@@ -193,9 +193,9 @@
/**
* @inheritDoc
*/
- public void retractTuple(ReteTuple leftTuple,
- PropagationContext context,
- InternalWorkingMemory workingMemory) {
+ public void retractTuple(final ReteTuple leftTuple,
+ final PropagationContext context,
+ final InternalWorkingMemory workingMemory) {
final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
memory.remove( workingMemory,
leftTuple );
@@ -213,7 +213,7 @@
// if tuple was propagated
if ( (leftTuple.getChildEntries() != null) && (leftTuple.getChildEntries().size() > 0) ) {
// Need to store the collection result object for later disposal
- InternalFactHandle lastHandle = ((ReteTuple) ((LinkedListEntry) leftTuple.getChildEntries().getFirst()).getObject()).getLastHandle();
+ final InternalFactHandle lastHandle = ((ReteTuple) ((LinkedListEntry) leftTuple.getChildEntries().getFirst()).getObject()).getLastHandle();
leftTuple.retractChildEntries( context,
workingMemory );
@@ -232,9 +232,9 @@
* 2. For each matching tuple, call a modify tuple
*
*/
- public void assertObject(InternalFactHandle handle,
- PropagationContext context,
- InternalWorkingMemory workingMemory) {
+ public void assertObject(final InternalFactHandle handle,
+ final PropagationContext context,
+ final InternalWorkingMemory workingMemory) {
final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
memory.add( workingMemory,
@@ -267,9 +267,9 @@
* So, a modify object is in fact a retract+assert object.
*
*/
- public void modifyObject(InternalFactHandle handle,
- PropagationContext context,
- InternalWorkingMemory workingMemory) {
+ public void modifyObject(final InternalFactHandle handle,
+ final PropagationContext context,
+ final InternalWorkingMemory workingMemory) {
final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
// Remove the FactHandle from memory
@@ -294,9 +294,9 @@
* If an object is retract, call modify tuple for each
* tuple match.
*/
- public void retractObject(InternalFactHandle handle,
- PropagationContext context,
- InternalWorkingMemory workingMemory) {
+ public void retractObject(final InternalFactHandle handle,
+ final PropagationContext context,
+ final InternalWorkingMemory workingMemory) {
final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
// Remove the FactHandle from memory
@@ -316,8 +316,8 @@
/**
* @inheritDoc
*/
- public List getPropagatedTuples(InternalWorkingMemory workingMemory,
- TupleSink sink) {
+ public List getPropagatedTuples(final InternalWorkingMemory workingMemory,
+ final TupleSink sink) {
final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
final List propagatedTuples = new ArrayList();
@@ -325,7 +325,7 @@
final ReteTuple leftTuple = (ReteTuple) it.next();
final LinkedList linkedTuples = leftTuple.getChildEntries();
- LinkedListEntry wrapper = (LinkedListEntry) linkedTuples.getFirst();
+ final LinkedListEntry wrapper = (LinkedListEntry) linkedTuples.getFirst();
propagatedTuples.add( wrapper.getObject() );
}
return propagatedTuples;
@@ -334,8 +334,8 @@
/**
* @inheritDoc
*/
- public void updateNewNode(InternalWorkingMemory workingMemory,
- PropagationContext context) {
+ public void updateNewNode(final InternalWorkingMemory workingMemory,
+ final PropagationContext context) {
this.attachingNewNode = true;
final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/CompositeObjectSinkAdapter.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/CompositeObjectSinkAdapter.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/CompositeObjectSinkAdapter.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -6,7 +6,6 @@
import org.drools.base.evaluators.Operator;
import org.drools.common.InternalFactHandle;
import org.drools.common.InternalWorkingMemory;
-import org.drools.examples.manners.Context;
import org.drools.rule.LiteralConstraint;
import org.drools.spi.AlphaNodeFieldConstraint;
import org.drools.spi.Evaluator;
@@ -35,27 +34,27 @@
this.hashKey = new HashKey();
}
- public void addObjectSink(ObjectSink sink) {
+ public void addObjectSink(final ObjectSink sink) {
if ( sink.getClass() == AlphaNode.class ) {
- AlphaNode alphaNode = (AlphaNode) sink;
- AlphaNodeFieldConstraint fieldConstraint = alphaNode.getConstraint();
+ final AlphaNode alphaNode = (AlphaNode) sink;
+ final AlphaNodeFieldConstraint fieldConstraint = alphaNode.getConstraint();
if ( fieldConstraint.getClass() == LiteralConstraint.class ) {
- LiteralConstraint literalConstraint = (LiteralConstraint) fieldConstraint;
- Evaluator evaluator = literalConstraint.getEvaluator();
+ final LiteralConstraint literalConstraint = (LiteralConstraint) fieldConstraint;
+ final Evaluator evaluator = literalConstraint.getEvaluator();
if ( evaluator.getOperator() == Operator.EQUAL ) {
- int index = literalConstraint.getFieldExtractor().getIndex();
- FieldIndex fieldIndex = registerFieldIndex( index,
+ final int index = literalConstraint.getFieldExtractor().getIndex();
+ final FieldIndex fieldIndex = registerFieldIndex( index,
literalConstraint.getFieldExtractor() );
if ( fieldIndex.getCount() >= 3 ) {
if ( !fieldIndex.isHashed() ) {
hashSinks( fieldIndex );
}
- Object value = literalConstraint.getField().getValue();
+ final Object value = literalConstraint.getField().getValue();
// no need to check, we know the sink does not exist
- hashedSinkMap.put( new HashKey( index,
+ this.hashedSinkMap.put( new HashKey( index,
value ),
sink,
false );
@@ -78,24 +77,24 @@
this.otherSinks.add( (ObjectSinkNode) sink );
}
- public void removeObjectSink(ObjectSink sink) {
+ public void removeObjectSink(final ObjectSink sink) {
if ( sink.getClass() == AlphaNode.class ) {
- AlphaNode alphaNode = (AlphaNode) sink;
- AlphaNodeFieldConstraint fieldConstraint = alphaNode.getConstraint();
+ final AlphaNode alphaNode = (AlphaNode) sink;
+ final AlphaNodeFieldConstraint fieldConstraint = alphaNode.getConstraint();
if ( fieldConstraint.getClass() == LiteralConstraint.class ) {
- LiteralConstraint literalConstraint = (LiteralConstraint) fieldConstraint;
- Evaluator evaluator = literalConstraint.getEvaluator();
- Object value = literalConstraint.getField().getValue();
+ final LiteralConstraint literalConstraint = (LiteralConstraint) fieldConstraint;
+ final Evaluator evaluator = literalConstraint.getEvaluator();
+ final Object value = literalConstraint.getField().getValue();
if ( evaluator.getOperator() == Operator.EQUAL ) {
- int index = literalConstraint.getFieldExtractor().getIndex();
- FieldIndex fieldIndex = unregisterFieldIndex( index );
+ final int index = literalConstraint.getFieldExtractor().getIndex();
+ final FieldIndex fieldIndex = unregisterFieldIndex( index );
if ( fieldIndex.isHashed() ) {
this.hashKey.setIndex( index );
this.hashKey.setValue( value );
- hashedSinkMap.remove( this.hashKey );
+ this.hashedSinkMap.remove( this.hashKey );
if ( fieldIndex.getCount() <= 2 ) {
// we have less than three so unhash
unHashSinks( fieldIndex );
@@ -120,31 +119,31 @@
}
}
- public void hashSinks(FieldIndex fieldIndex) {
- int index = fieldIndex.getIndex();
+ public void hashSinks(final FieldIndex fieldIndex) {
+ final int index = fieldIndex.getIndex();
- List list = new ArrayList();
+ final List list = new ArrayList();
if ( this.hashedSinkMap == null ) {
this.hashedSinkMap = new ObjectHashMap();
}
for ( ObjectSinkNode sink = this.hashableSinks.getFirst(); sink != null; sink = sink.getNextObjectSinkNode() ) {
- AlphaNode alphaNode = (AlphaNode) sink;
- AlphaNodeFieldConstraint fieldConstraint = alphaNode.getConstraint();
- LiteralConstraint literalConstraint = (LiteralConstraint) fieldConstraint;
- Evaluator evaluator = literalConstraint.getEvaluator();
+ final AlphaNode alphaNode = (AlphaNode) sink;
+ final AlphaNodeFieldConstraint fieldConstraint = alphaNode.getConstraint();
+ final LiteralConstraint literalConstraint = (LiteralConstraint) fieldConstraint;
+ final Evaluator evaluator = literalConstraint.getEvaluator();
if ( evaluator.getOperator() == Operator.EQUAL && index == literalConstraint.getFieldExtractor().getIndex() ) {
- Object value = literalConstraint.getField().getValue();
+ final Object value = literalConstraint.getField().getValue();
list.add( sink );
- hashedSinkMap.put( new HashKey( index,
+ this.hashedSinkMap.put( new HashKey( index,
value ),
sink );
}
}
- for ( java.util.Iterator it = list.iterator(); it.hasNext(); ) {
- ObjectSinkNode sink = (ObjectSinkNode) it.next();
+ for ( final java.util.Iterator it = list.iterator(); it.hasNext(); ) {
+ final ObjectSinkNode sink = (ObjectSinkNode) it.next();
this.hashableSinks.remove( sink );
}
@@ -155,20 +154,20 @@
fieldIndex.setHashed( true );
}
- public void unHashSinks(FieldIndex fieldIndex) {
- int index = fieldIndex.getIndex();
+ public void unHashSinks(final FieldIndex fieldIndex) {
+ final int index = fieldIndex.getIndex();
for ( ObjectSinkNode sink = this.hashableSinks.getFirst(); sink != null; sink = sink.getNextObjectSinkNode() ) {
- AlphaNode alphaNode = (AlphaNode) sink;
- AlphaNodeFieldConstraint fieldConstraint = alphaNode.getConstraint();
- LiteralConstraint literalConstraint = (LiteralConstraint) fieldConstraint;
- Evaluator evaluator = literalConstraint.getEvaluator();
+ final AlphaNode alphaNode = (AlphaNode) sink;
+ final AlphaNodeFieldConstraint fieldConstraint = alphaNode.getConstraint();
+ final LiteralConstraint literalConstraint = (LiteralConstraint) fieldConstraint;
+ final Evaluator evaluator = literalConstraint.getEvaluator();
if ( evaluator.getOperator() == Operator.EQUAL && index == literalConstraint.getFieldExtractor().getIndex() ) {
- Object value = literalConstraint.getField();
+ final Object value = literalConstraint.getField();
this.hashKey.setIndex( index );
this.hashKey.setValue( value );
this.hashableSinks.add( sink );
- hashedSinkMap.remove( this.hashKey );
+ this.hashedSinkMap.remove( this.hashKey );
}
}
@@ -185,12 +184,12 @@
* @param fieldExtractor
* @return
*/
- private FieldIndex registerFieldIndex(int index,
- FieldExtractor fieldExtractor) {
+ private FieldIndex registerFieldIndex(final int index,
+ final FieldExtractor fieldExtractor) {
FieldIndex fieldIndex = null;
// is linkedlist null, if so create and add
- if ( hashedFieldIndexes == null ) {
+ if ( this.hashedFieldIndexes == null ) {
this.hashedFieldIndexes = new LinkedList();
fieldIndex = new FieldIndex( index,
fieldExtractor );
@@ -214,8 +213,8 @@
return fieldIndex;
}
- private FieldIndex unregisterFieldIndex(int index) {
- FieldIndex fieldIndex = findFieldIndex( index );
+ private FieldIndex unregisterFieldIndex(final int index) {
+ final FieldIndex fieldIndex = findFieldIndex( index );
fieldIndex.decreaseCounter();
// if the fieldcount is 0 then remove it from the linkedlist
@@ -231,7 +230,7 @@
return fieldIndex;
}
- private FieldIndex findFieldIndex(int index) {
+ private FieldIndex findFieldIndex(final int index) {
for ( FieldIndex node = (FieldIndex) this.hashedFieldIndexes.getFirst(); node != null; node = (FieldIndex) node.getNext() ) {
if ( node.getIndex() == index ) {
return node;
@@ -241,20 +240,20 @@
return null;
}
- public void propagateAssertObject(InternalFactHandle handle,
- PropagationContext context,
- InternalWorkingMemory workingMemory) {
- Object object = handle.getObject();
-
+ public void propagateAssertObject(final InternalFactHandle handle,
+ final PropagationContext context,
+ final InternalWorkingMemory workingMemory) {
+ final Object object = handle.getObject();
+
if ( this.hashedFieldIndexes != null ) {
// Iterate the FieldIndexes to see if any are hashed
for ( FieldIndex fieldIndex = (FieldIndex) this.hashedFieldIndexes.getFirst(); fieldIndex != null && fieldIndex.isHashed(); fieldIndex = (FieldIndex) fieldIndex.getNext() ) {
// this field is hashed so set the existing hashKey and see if there is a sink for it
- int index = fieldIndex.getIndex();
- FieldExtractor extractor = fieldIndex.getFieldExtactor();
+ final int index = fieldIndex.getIndex();
+ final FieldExtractor extractor = fieldIndex.getFieldExtactor();
this.hashKey.setIndex( index );
this.hashKey.setValue( extractor.getValue( object ) );
- ObjectSink sink = (ObjectSink) this.hashedSinkMap.get( this.hashKey );
+ final ObjectSink sink = (ObjectSink) this.hashedSinkMap.get( this.hashKey );
if ( sink != null ) {
// The sink exists so propagate
sink.assertObject( handle,
@@ -284,21 +283,21 @@
}
- public void propagateRetractObject(InternalFactHandle handle,
- PropagationContext context,
- InternalWorkingMemory workingMemory,
- boolean useHash) {
+ public void propagateRetractObject(final InternalFactHandle handle,
+ final PropagationContext context,
+ final InternalWorkingMemory workingMemory,
+ final boolean useHash) {
if ( this.hashedFieldIndexes != null ) {
if ( useHash && this.hashedSinkMap != null ) {
- Object object = handle.getObject();
+ final Object object = handle.getObject();
// Iterate the FieldIndexes to see if any are hashed
for ( FieldIndex fieldIndex = (FieldIndex) this.hashedFieldIndexes.getFirst(); fieldIndex != null && fieldIndex.isHashed(); fieldIndex = (FieldIndex) fieldIndex.getNext() ) {
// this field is hashed so set the existing hashKey and see if there is a sink for it
- int index = fieldIndex.getIndex();
- FieldExtractor extractor = fieldIndex.getFieldExtactor();
+ final int index = fieldIndex.getIndex();
+ final FieldExtractor extractor = fieldIndex.getFieldExtactor();
this.hashKey.setIndex( index );
this.hashKey.setValue( extractor.getValue( object ) );
- ObjectSink sink = (ObjectSink) this.hashedSinkMap.get( this.hashKey );
+ final ObjectSink sink = (ObjectSink) this.hashedSinkMap.get( this.hashKey );
if ( sink != null ) {
// The sink exists so propagate
sink.retractObject( handle,
@@ -307,9 +306,9 @@
}
}
} else if ( this.hashedSinkMap != null ) {
- Iterator it = this.hashedSinkMap.iterator();
+ final Iterator it = this.hashedSinkMap.iterator();
for ( ObjectEntry entry = (ObjectEntry) it.next(); entry != null; entry = (ObjectEntry) it.next() ) {
- ObjectSink sink = (ObjectSink) entry.getValue();
+ final ObjectSink sink = (ObjectSink) entry.getValue();
sink.retractObject( handle,
context,
workingMemory );
@@ -337,29 +336,29 @@
}
public ObjectSink[] getSinks() {
- List list = new ArrayList();
-
+ final List list = new ArrayList();
+
if ( this.otherSinks != null ) {
for ( ObjectSinkNode sink = this.otherSinks.getFirst(); sink != null; sink = sink.getNextObjectSinkNode() ) {
list.add( sink );
}
}
-
+
if ( this.hashableSinks != null ) {
for ( ObjectSinkNode sink = this.hashableSinks.getFirst(); sink != null; sink = sink.getNextObjectSinkNode() ) {
list.add( sink );
}
- }
-
+ }
+
if ( this.hashedSinkMap != null ) {
- Iterator it = this.hashedSinkMap.iterator();
+ final Iterator it = this.hashedSinkMap.iterator();
for ( ObjectEntry entry = (ObjectEntry) it.next(); entry != null; entry = (ObjectEntry) it.next() ) {
- ObjectSink sink = (ObjectSink) entry.getValue();
+ final ObjectSink sink = (ObjectSink) entry.getValue();
list.add( sink );
}
}
- return ( ObjectSink[] ) list.toArray( new ObjectSink[ list.size() ] );
+ return (ObjectSink[]) list.toArray( new ObjectSink[list.size()] );
}
public int size() {
@@ -374,8 +373,8 @@
}
- public HashKey(int index,
- Object value) {
+ public HashKey(final int index,
+ final Object value) {
super();
this.index = index;
this.value = value;
@@ -385,7 +384,7 @@
return this.index;
}
- public void setIndex(int index) {
+ public void setIndex(final int index) {
this.index = index;
}
@@ -393,7 +392,7 @@
return this.value;
}
- public void setValue(Object value) {
+ public void setValue(final Object value) {
this.value = value;
}
@@ -405,7 +404,7 @@
return result;
}
- public boolean equals(Object object) {
+ public boolean equals(final Object object) {
final HashKey other = (HashKey) object;
return this.index == other.index && this.value.equals( other.value );
@@ -426,8 +425,8 @@
private LinkedListNode previous;
private LinkedListNode next;
- public FieldIndex(int index,
- FieldExtractor fieldExtractor) {
+ public FieldIndex(final int index,
+ final FieldExtractor fieldExtractor) {
this.index = index;
this.fieldExtactor = fieldExtractor;
}
@@ -452,7 +451,7 @@
return this.hashed;
}
- public void setHashed(boolean hashed) {
+ public void setHashed(final boolean hashed) {
this.hashed = hashed;
}
@@ -472,12 +471,12 @@
return this.previous;
}
- public void setNext(LinkedListNode next) {
+ public void setNext(final LinkedListNode next) {
this.next = next;
}
- public void setPrevious(LinkedListNode previous) {
+ public void setPrevious(final LinkedListNode previous) {
this.previous = previous;
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/CompositeTupleSinkAdapter.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/CompositeTupleSinkAdapter.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/CompositeTupleSinkAdapter.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -13,18 +13,18 @@
this.sinks = new TupleSinkNodeList();
}
- public void addTupleSink(TupleSink sink) {
+ public void addTupleSink(final TupleSink sink) {
this.sinks.add( (TupleSinkNode) sink );
}
- public void removeTupleSink(TupleSink sink) {
+ public void removeTupleSink(final TupleSink sink) {
this.sinks.remove( (TupleSinkNode) sink );
}
- public void propagateAssertTuple(ReteTuple tuple,
- InternalFactHandle handle,
- PropagationContext context,
- InternalWorkingMemory workingMemory) {
+ public void propagateAssertTuple(final ReteTuple tuple,
+ final InternalFactHandle handle,
+ final PropagationContext context,
+ final InternalWorkingMemory workingMemory) {
for ( TupleSinkNode sink = this.sinks.getFirst(); sink != null; sink = sink.getNextTupleSinkNode() ) {
sink.assertTuple( new ReteTuple( tuple,
@@ -34,20 +34,20 @@
}
}
- public void propagateAssertTuple(ReteTuple tuple,
- PropagationContext context,
- InternalWorkingMemory workingMemory) {
+ public void propagateAssertTuple(final ReteTuple tuple,
+ final PropagationContext context,
+ final InternalWorkingMemory workingMemory) {
for ( TupleSinkNode sink = this.sinks.getFirst(); sink != null; sink = sink.getNextTupleSinkNode() ) {
sink.assertTuple( new ReteTuple( tuple ),
context,
workingMemory );
}
- }
+ }
- public void propagateRetractTuple(ReteTuple tuple,
- InternalFactHandle handle,
- PropagationContext context,
- InternalWorkingMemory workingMemory) {
+ public void propagateRetractTuple(final ReteTuple tuple,
+ final InternalFactHandle handle,
+ final PropagationContext context,
+ final InternalWorkingMemory workingMemory) {
for ( TupleSinkNode sink = this.sinks.getFirst(); sink != null; sink = sink.getNextTupleSinkNode() ) {
sink.retractTuple( new ReteTuple( tuple,
handle ),
@@ -55,22 +55,22 @@
workingMemory );
}
}
-
- public void propagateRetractTuple(ReteTuple tuple,
- PropagationContext context,
- InternalWorkingMemory workingMemory) {
+
+ public void propagateRetractTuple(final ReteTuple tuple,
+ final PropagationContext context,
+ final InternalWorkingMemory workingMemory) {
for ( TupleSinkNode sink = this.sinks.getFirst(); sink != null; sink = sink.getNextTupleSinkNode() ) {
sink.retractTuple( new ReteTuple( tuple ),
context,
workingMemory );
}
- }
+ }
- public ReteTuple createAndPropagateAssertTuple(InternalFactHandle handle,
- PropagationContext context,
- InternalWorkingMemory workingMemory) {
+ public ReteTuple createAndPropagateAssertTuple(final InternalFactHandle handle,
+ final PropagationContext context,
+ final InternalWorkingMemory workingMemory) {
// This is the root fact, so we don't need to clone it.
- ReteTuple tuple = new ReteTuple( handle );
+ final ReteTuple tuple = new ReteTuple( handle );
for ( TupleSinkNode sink = this.sinks.getFirst(); sink != null; sink = sink.getNextTupleSinkNode() ) {
sink.assertTuple( tuple,
context,
@@ -79,18 +79,18 @@
return tuple;
}
- public void createAndPropagateRetractTuple(ReteTuple tuple,
- PropagationContext context,
- InternalWorkingMemory workingMemory) {
+ public void createAndPropagateRetractTuple(final ReteTuple tuple,
+ final PropagationContext context,
+ final InternalWorkingMemory workingMemory) {
for ( TupleSinkNode sink = this.sinks.getFirst(); sink != null; sink = sink.getNextTupleSinkNode() ) {
sink.retractTuple( tuple,
context,
workingMemory );
}
}
-
+
public TupleSink[] getSinks() {
- TupleSink[] sinkArray = new TupleSink[this.sinks.size()];
+ final TupleSink[] sinkArray = new TupleSink[this.sinks.size()];
int i = 0;
for ( TupleSinkNode sink = this.sinks.getFirst(); sink != null; sink = sink.getNextTupleSinkNode() ) {
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/EvalConditionNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/EvalConditionNode.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/EvalConditionNode.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -183,13 +183,15 @@
memory.add( tuple );
if ( !exists ) {
this.sink.propagateAssertTuple( tuple,
- context,
- workingMemory );
+ context,
+ workingMemory );
} else {
- tuple.modifyChildEntries( context, workingMemory );
+ tuple.modifyChildEntries( context,
+ workingMemory );
}
} else {
- tuple.retractChildEntries( context, workingMemory );
+ tuple.retractChildEntries( context,
+ workingMemory );
}
}
@@ -252,14 +254,14 @@
final ReteTuple leftTuple = (ReteTuple) it.next();
final LinkedList linkedTuples = leftTuple.getChildEntries();
- LinkedListEntry wrapper = (LinkedListEntry) linkedTuples.getFirst();
+ final LinkedListEntry wrapper = (LinkedListEntry) linkedTuples.getFirst();
propagatedTuples.add( wrapper.getObject() );
}
return propagatedTuples;
}
- public void remove(BaseNode node,
- InternalWorkingMemory[] workingMemories) {
+ public void remove(final BaseNode node,
+ final InternalWorkingMemory[] workingMemories) {
// FIXME
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/FromNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/FromNode.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/FromNode.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -13,8 +13,8 @@
import org.drools.common.InternalWorkingMemory;
import org.drools.common.NodeMemory;
import org.drools.common.PropagationContextImpl;
+import org.drools.spi.AlphaNodeFieldConstraint;
import org.drools.spi.DataProvider;
-import org.drools.spi.AlphaNodeFieldConstraint;
import org.drools.spi.PropagationContext;
public class FromNode extends TupleSource
@@ -24,12 +24,12 @@
/**
*
*/
- private static final long serialVersionUID = 320;
+ private static final long serialVersionUID = 320;
- private DataProvider dataProvider;
- private TupleSource tupleSource;
- private AlphaNodeFieldConstraint[] constraints;
- private BetaConstraints binder;
+ private DataProvider dataProvider;
+ private TupleSource tupleSource;
+ private AlphaNodeFieldConstraint[] constraints;
+ private BetaConstraints binder;
public FromNode(final int id,
final DataProvider dataProvider,
@@ -53,18 +53,18 @@
* need refactoring, I've used the standard join node mechanism for now.
*
*/
- public void assertTuple(ReteTuple leftTuple,
- PropagationContext context,
- InternalWorkingMemory workingMemory) {
+ public void assertTuple(final ReteTuple leftTuple,
+ final PropagationContext context,
+ final InternalWorkingMemory workingMemory) {
final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
memory.add( workingMemory,
leftTuple );
- for ( Iterator it = this.dataProvider.getResults( leftTuple,
+ for ( final Iterator it = this.dataProvider.getResults( leftTuple,
workingMemory,
context ); it.hasNext(); ) {
- Object object = it.next();
+ final Object object = it.next();
// First alpha node filters
boolean isAllowed = true;
@@ -84,7 +84,7 @@
final InternalFactHandle handle = workingMemory.getFactHandleFactory().newFactHandle( object );
final ObjectMatches objectMatches = new ObjectMatches( (DefaultFactHandle) handle );
- if ( binder.isAllowed( handle,
+ if ( this.binder.isAllowed( handle,
leftTuple,
workingMemory ) ) {
final TupleMatch tupleMatch = new CompositeTupleMatch( leftTuple,
@@ -107,9 +107,9 @@
* If it isn't then we can continue to just propagate as a normal modify, without having to retrieve and check values
* from the DataProvider.
*/
- public void modifyTuple(ReteTuple leftTuple,
- PropagationContext context,
- InternalWorkingMemory workingMemory) {
+ public void modifyTuple(final ReteTuple leftTuple,
+ final PropagationContext context,
+ final InternalWorkingMemory workingMemory) {
final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
// We remove the tuple as now its modified it needs to go to the top of
@@ -144,9 +144,9 @@
}
}
- public void retractTuple(ReteTuple leftTuple,
- PropagationContext context,
- InternalWorkingMemory workingMemory) {
+ public void retractTuple(final ReteTuple leftTuple,
+ final PropagationContext context,
+ final InternalWorkingMemory workingMemory) {
final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
memory.remove( workingMemory,
leftTuple );
@@ -156,14 +156,15 @@
if ( !matches.isEmpty() ) {
for ( final Iterator it = matches.values().iterator(); it.hasNext(); ) {
final TupleMatch tupleMatch = (TupleMatch) it.next();
- tupleMatch.getTuple().retractChildEntries( context, workingMemory );
+ tupleMatch.getTuple().retractChildEntries( context,
+ workingMemory );
workingMemory.getFactHandleFactory().destroyFactHandle( tupleMatch.getObjectMatches().getFactHandle() );
}
}
}
- public List getPropagatedTuples(InternalWorkingMemory workingMemory,
- TupleSink sink) {
+ public List getPropagatedTuples(final InternalWorkingMemory workingMemory,
+ final TupleSink sink) {
// TODO Auto-generated method stub
return null;
}
@@ -172,7 +173,7 @@
this.tupleSource.addTupleSink( this );
}
- public void attach(InternalWorkingMemory[] workingMemories) {
+ public void attach(final InternalWorkingMemory[] workingMemories) {
attach();
for ( int i = 0, length = workingMemories.length; i < length; i++ ) {
@@ -186,25 +187,25 @@
}
}
- public void remove(BaseNode node,
- InternalWorkingMemory[] workingMemories) {
+ public void remove(final BaseNode node,
+ final InternalWorkingMemory[] workingMemories) {
// FIXME
-// if ( !node.isInUse() ) {
-// getTupleSinks().remove( node );
-// }
-// removeShare();
-//
-// if ( !this.isInUse() ) {
-// for ( int i = 0, length = workingMemories.length; i < length; i++ ) {
-// workingMemories[i].clearNodeMemory( this );
-// }
-// }
-// this.tupleSource.remove( this,
-// workingMemories );
+ // if ( !node.isInUse() ) {
+ // getTupleSinks().remove( node );
+ // }
+ // removeShare();
+ //
+ // if ( !this.isInUse() ) {
+ // for ( int i = 0, length = workingMemories.length; i < length; i++ ) {
+ // workingMemories[i].clearNodeMemory( this );
+ // }
+ // }
+ // this.tupleSource.remove( this,
+ // workingMemories );
}
- public void updateNewNode(InternalWorkingMemory workingMemory,
- PropagationContext context) {
+ public void updateNewNode(final InternalWorkingMemory workingMemory,
+ final PropagationContext context) {
this.attachingNewNode = true;
final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
@@ -232,7 +233,7 @@
this.attachingNewNode = false;
}
- public Object createMemory(RuleBaseConfiguration config) {
+ public Object createMemory(final RuleBaseConfiguration config) {
return new BetaMemory( config,
this.binder );
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/JoinNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/JoinNode.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/JoinNode.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -107,15 +107,18 @@
final InternalWorkingMemory workingMemory) {
final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
memory.getTupleMemory().add( leftTuple );
-
- Iterator it = memory.getObjectMemory().iterator( leftTuple );
+
+ final Iterator it = memory.getObjectMemory().iterator( leftTuple );
this.constraints.updateFromTuple( leftTuple );
- for ( FactEntry entry = ( FactEntry ) it.next(); entry != null; entry = ( FactEntry ) it.next() ) {
- InternalFactHandle handle = entry.getFactHandle();
- if ( this.constraints.isAllowedCachedLeft(handle.getObject()) ) {
- sink.propagateAssertTuple( leftTuple, handle, context, workingMemory );
+ for ( FactEntry entry = (FactEntry) it.next(); entry != null; entry = (FactEntry) it.next() ) {
+ final InternalFactHandle handle = entry.getFactHandle();
+ if ( this.constraints.isAllowedCachedLeft( handle.getObject() ) ) {
+ this.sink.propagateAssertTuple( leftTuple,
+ handle,
+ context,
+ workingMemory );
}
- }
+ }
}
/**
@@ -141,12 +144,15 @@
final InternalWorkingMemory workingMemory) {
final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
memory.getObjectMemory().add( handle );
-
- Iterator it = memory.getTupleMemory().iterator();
+
+ final Iterator it = memory.getTupleMemory().iterator();
this.constraints.updateFromFactHandle( handle );
- for ( ReteTuple tuple = ( ReteTuple ) it.next(); tuple != null; tuple = ( ReteTuple ) it.next() ) {
+ for ( ReteTuple tuple = (ReteTuple) it.next(); tuple != null; tuple = (ReteTuple) it.next() ) {
if ( this.constraints.isAllowedCachedRight( tuple ) ) {
- sink.propagateAssertTuple( tuple, handle, context, workingMemory );
+ this.sink.propagateAssertTuple( tuple,
+ handle,
+ context,
+ workingMemory );
}
}
}
@@ -169,12 +175,15 @@
if ( !memory.getObjectMemory().remove( handle ) ) {
return;
}
-
- Iterator it = memory.getTupleMemory().iterator();
+
+ final Iterator it = memory.getTupleMemory().iterator();
this.constraints.updateFromFactHandle( handle );
- for ( ReteTuple tuple = ( ReteTuple ) it.next(); tuple != null; tuple = ( ReteTuple ) it.next() ) {
+ for ( ReteTuple tuple = (ReteTuple) it.next(); tuple != null; tuple = (ReteTuple) it.next() ) {
if ( this.constraints.isAllowedCachedRight( tuple ) ) {
- sink.propagateRetractTuple( tuple, handle, context, workingMemory );
+ this.sink.propagateRetractTuple( tuple,
+ handle,
+ context,
+ workingMemory );
}
}
}
@@ -195,23 +204,26 @@
final PropagationContext context,
final InternalWorkingMemory workingMemory) {
final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
- ReteTuple tuple = ( ReteTuple ) memory.getTupleMemory().remove( leftTuple );
- if ( tuple == null) {
+ final ReteTuple tuple = (ReteTuple) memory.getTupleMemory().remove( leftTuple );
+ if ( tuple == null ) {
leftTuple.release();
return;
}
-
- Iterator it = memory.getObjectMemory().iterator( leftTuple );
+
+ final Iterator it = memory.getObjectMemory().iterator( leftTuple );
this.constraints.updateFromTuple( leftTuple );
- for ( FactEntry entry = ( FactEntry ) it.next(); entry != null; entry = ( FactEntry ) it.next() ) {
- InternalFactHandle handle = entry.getFactHandle();
+ for ( FactEntry entry = (FactEntry) it.next(); entry != null; entry = (FactEntry) it.next() ) {
+ final InternalFactHandle handle = entry.getFactHandle();
if ( this.constraints.isAllowedCachedLeft( handle.getObject() ) ) {
- sink.propagateRetractTuple( leftTuple, handle, context, workingMemory );
+ this.sink.propagateRetractTuple( leftTuple,
+ handle,
+ context,
+ workingMemory );
}
- }
+ }
tuple.release();
leftTuple.release();
- }
+ }
/* (non-Javadoc)
* @see org.drools.reteoo.BaseNode#updateNewNode(org.drools.reteoo.WorkingMemoryImpl, org.drools.spi.PropagationContext)
@@ -222,25 +234,28 @@
final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
- Iterator tupleIter = memory.getTupleMemory().iterator();
- for ( ReteTuple tuple = ( ReteTuple ) tupleIter.next(); tuple != null; tuple = ( ReteTuple ) tupleIter.next() ) {
- Iterator objectIter = memory.getObjectMemory().iterator( tuple );
+ final Iterator tupleIter = memory.getTupleMemory().iterator();
+ for ( ReteTuple tuple = (ReteTuple) tupleIter.next(); tuple != null; tuple = (ReteTuple) tupleIter.next() ) {
+ final Iterator objectIter = memory.getObjectMemory().iterator( tuple );
this.constraints.updateFromTuple( tuple );
- for ( FactEntry entry = ( FactEntry ) objectIter.next(); entry != null; entry = ( FactEntry ) objectIter.next() ) {
- InternalFactHandle handle = entry.getFactHandle();
+ for ( FactEntry entry = (FactEntry) objectIter.next(); entry != null; entry = (FactEntry) objectIter.next() ) {
+ final InternalFactHandle handle = entry.getFactHandle();
if ( this.constraints.isAllowedCachedLeft( handle.getObject() ) ) {
- sink.assertTuple( new ReteTuple( tuple, handle), context, workingMemory );
+ sink.assertTuple( new ReteTuple( tuple,
+ handle ),
+ context,
+ workingMemory );
}
- }
+ }
}
- }
-
+ }
+
public String toString() {
ObjectSource source = this.rightInput;
while ( source.getClass() != ObjectTypeNode.class ) {
source = source.objectSource;
}
-
- return "[JoinNode - " + ((ObjectTypeNode)source).getObjectType()+ "]";
+
+ return "[JoinNode - " + ((ObjectTypeNode) source).getObjectType() + "]";
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/LeftInputAdapterNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/LeftInputAdapterNode.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/LeftInputAdapterNode.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -16,25 +16,14 @@
* limitations under the License.
*/
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
import org.drools.RuleBaseConfiguration;
import org.drools.common.BaseNode;
-import org.drools.common.DefaultBetaConstraints;
import org.drools.common.InternalFactHandle;
import org.drools.common.InternalWorkingMemory;
import org.drools.common.NodeMemory;
import org.drools.common.PropagationContextImpl;
-import org.drools.spi.AlphaNodeFieldConstraint;
import org.drools.spi.PropagationContext;
import org.drools.util.Iterator;
-import org.drools.util.LinkedList;
-import org.drools.util.LinkedListNode;
-import org.drools.util.LinkedListEntry;
import org.drools.util.ObjectHashMap;
import org.drools.util.ObjectHashMap.ObjectEntry;
@@ -56,26 +45,27 @@
/**
*
*/
- private static final long serialVersionUID = 320L;
- private final ObjectSource objectSource;
-// private final AlphaNodeFieldConstraint constraints;
+ private static final long serialVersionUID = 320L;
+ private final ObjectSource objectSource;
-// /**
-// * Constructus a LeftInputAdapterNode with a unique id that receives <code>FactHandle</code> from a
-// * parent <code>ObjectSource</code> and adds it to a given column in the resulting Tuples.
-// *
-// * @param id
-// * The unique id of this node in the current Rete network
-// * @param source
-// * The parent node, where Facts are propagated from
-// */
-// public LeftInputAdapterNode(final int id,
-// final ObjectSource source) {
-// this( id,
-// source,
-// null );
-// }
+ // private final AlphaNodeFieldConstraint constraints;
+ // /**
+ // * Constructus a LeftInputAdapterNode with a unique id that receives <code>FactHandle</code> from a
+ // * parent <code>ObjectSource</code> and adds it to a given column in the resulting Tuples.
+ // *
+ // * @param id
+ // * The unique id of this node in the current Rete network
+ // * @param source
+ // * The parent node, where Facts are propagated from
+ // */
+ // public LeftInputAdapterNode(final int id,
+ // final ObjectSource source) {
+ // this( id,
+ // source,
+ // null );
+ // }
+
/**
* Constructus a LeftInputAdapterNode with a unique id that receives <code>FactHandle</code> from a
* parent <code>ObjectSource</code> and adds it to a given column in the resulting Tuples.
@@ -96,16 +86,16 @@
setHasMemory( false );
}
-// public AlphaNodeFieldConstraint[] getConstraints() {
-// LinkedList constraints = this.constraints.getConstraints();
-//
-// AlphaNodeFieldConstraint[] array = new AlphaNodeFieldConstraint[constraints.size()];
-// int i = 0;
-// for ( LinkedListEntry entry = (LinkedListEntry) constraints.getFirst(); entry != null; entry = (LinkedListEntry) entry.getNext() ) {
-// array[i++] = (AlphaNodeFieldConstraint) entry.getObject();
-// }
-// return array;
-// }
+ // public AlphaNodeFieldConstraint[] getConstraints() {
+ // LinkedList constraints = this.constraints.getConstraints();
+ //
+ // AlphaNodeFieldConstraint[] array = new AlphaNodeFieldConstraint[constraints.size()];
+ // int i = 0;
+ // for ( LinkedListEntry entry = (LinkedListEntry) constraints.getFirst(); entry != null; entry = (LinkedListEntry) entry.getNext() ) {
+ // array[i++] = (AlphaNodeFieldConstraint) entry.getObject();
+ // }
+ // return array;
+ // }
/* (non-Javadoc)
* @see org.drools.reteoo.BaseNode#attach()
@@ -143,18 +133,18 @@
public void assertObject(final InternalFactHandle handle,
final PropagationContext context,
final InternalWorkingMemory workingMemory) {
-// if ( (this.constraints == null) || (this.constraints.isAllowed( handle.getObject(),
-// workingMemory )) ) {
- ReteTuple tuple = this.sink.createAndPropagateAssertTuple( handle,
- context,
- workingMemory );
+ // if ( (this.constraints == null) || (this.constraints.isAllowed( handle.getObject(),
+ // workingMemory )) ) {
+ final ReteTuple tuple = this.sink.createAndPropagateAssertTuple( handle,
+ context,
+ workingMemory );
- if ( this.hasMemory ) {
- ObjectHashMap map = (ObjectHashMap) workingMemory.getNodeMemory( this );
- map.put( handle,
- tuple,
- false );
-// }
+ if ( this.hasMemory ) {
+ final ObjectHashMap map = (ObjectHashMap) workingMemory.getNodeMemory( this );
+ map.put( handle,
+ tuple,
+ false );
+ // }
}
}
@@ -174,34 +164,34 @@
final InternalWorkingMemory workingMemory) {
ReteTuple tuple = null;
if ( this.hasMemory ) {
- ObjectHashMap map = (ObjectHashMap) workingMemory.getNodeMemory( this );
- tuple = ( ReteTuple ) map.remove( handle );
+ final ObjectHashMap map = (ObjectHashMap) workingMemory.getNodeMemory( this );
+ tuple = (ReteTuple) map.remove( handle );
} else {
- tuple = new ReteTuple( handle );
+ tuple = new ReteTuple( handle );
}
-
+
this.sink.createAndPropagateRetractTuple( tuple,
context,
workingMemory );
tuple.release();
}
- public void updateSink(TupleSink sink,
- PropagationContext context,
- InternalWorkingMemory workingMemory) {
+ public void updateSink(final TupleSink sink,
+ final PropagationContext context,
+ final InternalWorkingMemory workingMemory) {
if ( this.hasMemory ) {
// We have memory so iterate over all entries
- ObjectHashMap map = (ObjectHashMap) workingMemory.getNodeMemory( this );
- Iterator it = map.iterator();
- for ( ObjectEntry entry = (ObjectEntry) it.next(); entry != null; it.next() ) {
- InternalFactHandle handle = (InternalFactHandle) entry.getKey();
- ReteTuple tuple = (ReteTuple) entry.getValue();
+ final ObjectHashMap map = (ObjectHashMap) workingMemory.getNodeMemory( this );
+ final Iterator it = map.iterator();
+ for ( final ObjectEntry entry = (ObjectEntry) it.next(); entry != null; it.next() ) {
+ final InternalFactHandle handle = (InternalFactHandle) entry.getKey();
+ final ReteTuple tuple = (ReteTuple) entry.getValue();
sink.assertTuple( tuple,
context,
workingMemory );
}
} else {
- ObjectSinkAdapter adapter = new ObjectSinkAdapter( sink );
+ final ObjectSinkAdapter adapter = new ObjectSinkAdapter( sink );
this.objectSource.updateSink( adapter,
context,
workingMemory );
@@ -237,14 +227,14 @@
}
final LeftInputAdapterNode other = (LeftInputAdapterNode) object;
-// if ( this.constraints == null ) {
-// return this.objectSource.equals( other.objectSource ) && other.constraints == null;
-// } else {
- return this.objectSource.equals( other.objectSource ); //&& this.constraints.equals( other.constraints );
-// }
+ // if ( this.constraints == null ) {
+ // return this.objectSource.equals( other.objectSource ) && other.constraints == null;
+ // } else {
+ return this.objectSource.equals( other.objectSource ); //&& this.constraints.equals( other.constraints );
+ // }
}
- public Object createMemory(RuleBaseConfiguration config) {
+ public Object createMemory(final RuleBaseConfiguration config) {
return new ObjectHashMap();
}
@@ -259,28 +249,28 @@
ObjectSink {
private TupleSink sink;
- public ObjectSinkAdapter(TupleSink sink) {
+ public ObjectSinkAdapter(final TupleSink sink) {
this.sink = sink;
}
- public void assertObject(InternalFactHandle handle,
- PropagationContext context,
- InternalWorkingMemory workingMemory) {
- ReteTuple tuple = new ReteTuple( handle );
+ public void assertObject(final InternalFactHandle handle,
+ final PropagationContext context,
+ final InternalWorkingMemory workingMemory) {
+ final ReteTuple tuple = new ReteTuple( handle );
this.sink.assertTuple( tuple,
context,
workingMemory );
}
- public void modifyObject(InternalFactHandle handle,
- PropagationContext context,
- InternalWorkingMemory workingMemory) {
+ public void modifyObject(final InternalFactHandle handle,
+ final PropagationContext context,
+ final InternalWorkingMemory workingMemory) {
throw new UnsupportedOperationException( "ObjectSinkAdapter onlys supports assertObject method calls" );
}
- public void retractObject(InternalFactHandle handle,
- PropagationContext context,
- InternalWorkingMemory workingMemory) {
+ public void retractObject(final InternalFactHandle handle,
+ final PropagationContext context,
+ final InternalWorkingMemory workingMemory) {
throw new UnsupportedOperationException( "ObjectSinkAdapter onlys supports assertObject method calls" );
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/MemoryVisitor.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/MemoryVisitor.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/MemoryVisitor.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -3,31 +3,28 @@
import java.lang.reflect.Field;
import org.drools.base.ClassObjectType;
-import org.drools.common.BaseNode;
import org.drools.common.InternalWorkingMemory;
import org.drools.examples.manners.Context;
import org.drools.reteoo.TerminalNode.TerminalNodeMemory;
import org.drools.util.AbstractHashTable;
-import org.drools.util.CompositeFieldIndexHashTable;
import org.drools.util.Entry;
import org.drools.util.FactHashTable;
-//import org.drools.util.FieldIndexHashTable;
+import org.drools.util.FieldIndexHashTable;
import org.drools.util.Iterator;
import org.drools.util.ObjectHashMap;
import org.drools.util.ReflectiveVisitor;
import org.drools.util.TupleHashTable;
-import org.drools.util.AbstractHashTable.FactEntry;
-import org.drools.util.CompositeFieldIndexHashTable.FieldIndexEntry;
+import org.drools.util.FieldIndexHashTable.FieldIndexEntry;
import org.drools.util.ObjectHashMap.ObjectEntry;
public class MemoryVisitor extends ReflectiveVisitor {
private InternalWorkingMemory workingMemory;
- private int indent = 0;
+ private int indent = 0;
/**
* Constructor.
*/
- public MemoryVisitor(InternalWorkingMemory workingMemory) {
+ public MemoryVisitor(final InternalWorkingMemory workingMemory) {
this.workingMemory = workingMemory;
}
@@ -42,9 +39,9 @@
* Rete visits each of its ObjectTypeNodes.
*/
public void visitRete(final Rete rete) {
- ObjectHashMap map = rete.getObjectTypeNodes();
+ final ObjectHashMap map = rete.getObjectTypeNodes();
- Iterator it = map.iterator();
+ final Iterator it = map.iterator();
for ( ObjectEntry entry = (ObjectEntry) it.next(); entry != null; entry = (ObjectEntry) it.next() ) {
visit( entry.getValue() );
}
@@ -64,234 +61,232 @@
// }
}
- public void visitObjectTypeNode(final ObjectTypeNode node) {
- if ( Context.class != ( ( ClassObjectType ) node.getObjectType() ).getClassType() ){
+ public void visitObjectTypeNode(final ObjectTypeNode node) {
+ if ( Context.class != ((ClassObjectType) node.getObjectType()).getClassType() ) {
return;
}
- System.out.println( indent() + node );
-
- FactHashTable memory = ( FactHashTable ) this.workingMemory.getNodeMemory( node );
- checkObjectHashTable(memory);
+ System.out.println( indent() + node );
- indent++;
+ final FactHashTable memory = (FactHashTable) this.workingMemory.getNodeMemory( node );
+ checkObjectHashTable( memory );
+
+ this.indent++;
try {
- Field field = ObjectSource.class.getDeclaredField( "sink" );
+ final Field field = ObjectSource.class.getDeclaredField( "sink" );
field.setAccessible( true );
- ObjectSinkPropagator sink = (ObjectSinkPropagator) field.get( node );
- ObjectSink[] sinks = sink.getSinks();
+ final ObjectSinkPropagator sink = (ObjectSinkPropagator) field.get( node );
+ final ObjectSink[] sinks = sink.getSinks();
for ( int i = 0, length = sinks.length; i < length; i++ ) {
visit( sinks[i] );
}
- } catch ( Exception e ) {
+ } catch ( final Exception e ) {
e.printStackTrace();
}
- indent--;
+ this.indent--;
}
public void visitAlphaNode(final AlphaNode node) {
System.out.println( indent() + node );
-
- FactHashTable memory = ( FactHashTable ) this.workingMemory.getNodeMemory( node );
- checkObjectHashTable(memory);
-
- indent++;
+ final FactHashTable memory = (FactHashTable) this.workingMemory.getNodeMemory( node );
+ checkObjectHashTable( memory );
+
+ this.indent++;
try {
- Field field = ObjectSource.class.getDeclaredField( "sink" );
+ final Field field = ObjectSource.class.getDeclaredField( "sink" );
field.setAccessible( true );
- ObjectSinkPropagator sink = (ObjectSinkPropagator) field.get( node );
- ObjectSink[] sinks = sink.getSinks();
+ final ObjectSinkPropagator sink = (ObjectSinkPropagator) field.get( node );
+ final ObjectSink[] sinks = sink.getSinks();
for ( int i = 0, length = sinks.length; i < length; i++ ) {
visit( sinks[i] );
}
- } catch ( Exception e ) {
+ } catch ( final Exception e ) {
e.printStackTrace();
}
- indent--;
+ this.indent--;
}
public void visitLeftInputAdapterNode(final LeftInputAdapterNode node) {
System.out.println( indent() + node );
- indent++;
+ this.indent++;
try {
- Field field = TupleSource.class.getDeclaredField( "sink" );
+ final Field field = TupleSource.class.getDeclaredField( "sink" );
field.setAccessible( true );
- TupleSinkPropagator sink = (TupleSinkPropagator) field.get( node );
- TupleSink[] sinks = sink.getSinks();
+ final TupleSinkPropagator sink = (TupleSinkPropagator) field.get( node );
+ final TupleSink[] sinks = sink.getSinks();
for ( int i = 0, length = sinks.length; i < length; i++ ) {
visit( sinks[i] );
}
- } catch ( Exception e ) {
+ } catch ( final Exception e ) {
e.printStackTrace();
}
- indent--;
+ this.indent--;
}
public void visitJoinNode(final JoinNode node) {
System.out.println( indent() + node );
-
-
+
try {
- BetaMemory memory = ( BetaMemory ) this.workingMemory.getNodeMemory( node );
- checkObjectHashTable( memory.getObjectMemory() );
+ final BetaMemory memory = (BetaMemory) this.workingMemory.getNodeMemory( node );
+ checkObjectHashTable( memory.getObjectMemory() );
checkTupleMemory( memory.getTupleMemory() );
- } catch ( Exception e ) {
+ } catch ( final Exception e ) {
e.printStackTrace();
}
-
- indent++;
+
+ this.indent++;
try {
- Field field = TupleSource.class.getDeclaredField( "sink" );
+ final Field field = TupleSource.class.getDeclaredField( "sink" );
field.setAccessible( true );
- TupleSinkPropagator sink = (TupleSinkPropagator) field.get( node );
- TupleSink[] sinks = sink.getSinks();
+ final TupleSinkPropagator sink = (TupleSinkPropagator) field.get( node );
+ final TupleSink[] sinks = sink.getSinks();
for ( int i = 0, length = sinks.length; i < length; i++ ) {
visit( sinks[i] );
}
- } catch ( Exception e ) {
+ } catch ( final Exception e ) {
e.printStackTrace();
}
- indent--;
+ this.indent--;
}
public void visitNotNode(final NotNode node) {
System.out.println( indent() + node );
try {
- BetaMemory memory = ( BetaMemory ) this.workingMemory.getNodeMemory( node );
- checkObjectHashTable( memory.getObjectMemory() );
+ final BetaMemory memory = (BetaMemory) this.workingMemory.getNodeMemory( node );
+ checkObjectHashTable( memory.getObjectMemory() );
checkTupleMemory( memory.getTupleMemory() );
- } catch ( Exception e ) {
+ } catch ( final Exception e ) {
e.printStackTrace();
}
- indent++;
+ this.indent++;
try {
- Field field = TupleSource.class.getDeclaredField( "sink" );
+ final Field field = TupleSource.class.getDeclaredField( "sink" );
field.setAccessible( true );
- TupleSinkPropagator sink = (TupleSinkPropagator) field.get( node );
- TupleSink[] sinks = sink.getSinks();
+ final TupleSinkPropagator sink = (TupleSinkPropagator) field.get( node );
+ final TupleSink[] sinks = sink.getSinks();
for ( int i = 0, length = sinks.length; i < length; i++ ) {
visit( sinks[i] );
}
- } catch ( Exception e ) {
+ } catch ( final Exception e ) {
e.printStackTrace();
}
- indent--;
+ this.indent--;
}
public void visitTerminalNode(final TerminalNode node) {
System.out.println( indent() + node );
- TerminalNodeMemory memory = ( TerminalNodeMemory ) this.workingMemory.getNodeMemory( node );
- checkTupleMemory( memory.getTupleMemory() );
+ final TerminalNodeMemory memory = (TerminalNodeMemory) this.workingMemory.getNodeMemory( node );
+ checkTupleMemory( memory.getTupleMemory() );
}
-
- private void checkObjectHashMap(ObjectHashMap map) {
- Entry[] entries = map.getTable();
+
+ private void checkObjectHashMap(final ObjectHashMap map) {
+ final Entry[] entries = map.getTable();
int count = 0;
- for( int i = 0, length = entries.length; i < length; i++ ) {
+ for ( int i = 0, length = entries.length; i < length; i++ ) {
if ( entries[i] != null ) {
count++;
}
}
-
- System.out.println( "ObjectHashMap: "+ indent() + map.size() + ":" + count);
+
+ System.out.println( "ObjectHashMap: " + indent() + map.size() + ":" + count );
if ( map.size() != count ) {
System.out.println( indent() + "error" );
- }
+ }
}
-
- private void checkObjectHashTable(ObjectHashTable memory) {
- if ( memory instanceof FactHashTable) {
- checkFactHashTable( (FactHashTable )memory);
- } else if ( memory instanceof CompositeFieldIndexHashTable ) {
- checkFieldIndexHashTable( ( CompositeFieldIndexHashTable )memory);
+
+ private void checkObjectHashTable(final ObjectHashTable memory) {
+ if ( memory instanceof FactHashTable ) {
+ checkFactHashTable( (FactHashTable) memory );
+ } else if ( memory instanceof FieldIndexHashTable ) {
+ checkFieldIndexHashTable( (FieldIndexHashTable) memory );
} else {
throw new RuntimeException( memory.getClass() + " should not be here" );
}
}
-
- private void checkFactHashTable(FactHashTable memory) {
- Entry[] entries = memory.getTable();
+
+ private void checkFactHashTable(final FactHashTable memory) {
+ final Entry[] entries = memory.getTable();
int count = 0;
- for( int i = 0, length = entries.length; i < length; i++ ) {
- if ( entries[i] != null ) {
+ for ( int i = 0, length = entries.length; i < length; i++ ) {
+ if ( entries[i] != null ) {
Entry entry = entries[i];
- while ( entry != null ) {
+ while ( entry != null ) {
count++;
entry = entry.getNext();
}
}
}
-
- System.out.println( indent() + "FactHashTable: " + memory.size() + ":" + count);
+
+ System.out.println( indent() + "FactHashTable: " + memory.size() + ":" + count );
if ( memory.size() != count ) {
System.out.println( indent() + "error" );
- }
+ }
}
-
- private void checkFieldIndexHashTable(CompositeFieldIndexHashTable memory) {
- Entry[] entries = memory.getTable();
+
+ private void checkFieldIndexHashTable(final FieldIndexHashTable memory) {
+ final Entry[] entries = memory.getTable();
int factCount = 0;
int bucketCount = 0;
- for( int i = 0, length = entries.length; i < length; i++ ) {
+ for ( int i = 0, length = entries.length; i < length; i++ ) {
if ( entries[i] != null ) {
- FieldIndexEntry fieldIndexEntry = ( FieldIndexEntry ) entries[i];
- while ( fieldIndexEntry != null ) {
+ FieldIndexEntry fieldIndexEntry = (FieldIndexEntry) entries[i];
+ while ( fieldIndexEntry != null ) {
if ( fieldIndexEntry.getFirst() != null ) {
Entry entry = fieldIndexEntry.getFirst();
- while ( entry != null ) {
+ while ( entry != null ) {
entry = entry.getNext();
factCount++;
}
} else {
System.out.println( "error : fieldIndexHashTable cannot have empty FieldIndexEntry objects" );
}
- fieldIndexEntry = ( FieldIndexEntry ) fieldIndexEntry.getNext();
+ fieldIndexEntry = (FieldIndexEntry) fieldIndexEntry.getNext();
bucketCount++;
}
}
}
-
+
try {
- Field field = AbstractHashTable.class.getDeclaredField( "size" );
- field.setAccessible( true );
- System.out.println( indent() + "FieldIndexBuckets: "+ ( ( Integer ) field.get( memory ) ).intValue() + ":" + bucketCount );
- if ( ( ( Integer ) field.get( memory ) ).intValue() != bucketCount ) {
- System.out.println( indent() + "error" );
+ final Field field = AbstractHashTable.class.getDeclaredField( "size" );
+ field.setAccessible( true );
+ System.out.println( indent() + "FieldIndexBuckets: " + ((Integer) field.get( memory )).intValue() + ":" + bucketCount );
+ if ( ((Integer) field.get( memory )).intValue() != bucketCount ) {
+ System.out.println( indent() + "error" );
}
- } catch ( Exception e ) {
+ } catch ( final Exception e ) {
e.printStackTrace();
}
-
- System.out.println( indent() + "FieldIndexFacts: " + memory.size() + ":" + factCount);
+
+ System.out.println( indent() + "FieldIndexFacts: " + memory.size() + ":" + factCount );
if ( memory.size() != factCount ) {
System.out.println( indent() + "error" );
- }
- }
-
- private void checkTupleMemory(TupleHashTable memory){
- Entry[] entries = memory.getTable();
+ }
+ }
+
+ private void checkTupleMemory(final TupleHashTable memory) {
+ final Entry[] entries = memory.getTable();
int count = 0;
- for( int i = 0, length = entries.length; i < length; i++ ) {
- if ( entries[i] != null ) {
+ for ( int i = 0, length = entries.length; i < length; i++ ) {
+ if ( entries[i] != null ) {
Entry entry = entries[i];
- while ( entry != null ) {
+ while ( entry != null ) {
count++;
entry = entry.getNext();
}
}
}
-
- System.out.println( indent() + "TupleMemory: " + memory.size() + ":" + count);
+
+ System.out.println( indent() + "TupleMemory: " + memory.size() + ":" + count );
if ( memory.size() != count ) {
System.out.println( indent() + "error" );
- }
+ }
}
-
- private String indent() {
- StringBuffer buffer = new StringBuffer();
- for ( int i = 0; i < indent; i++ ) {
+
+ private String indent() {
+ final StringBuffer buffer = new StringBuffer();
+ for ( int i = 0; i < this.indent; i++ ) {
buffer.append( " " );
}
return buffer.toString();
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/NotNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/NotNode.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/NotNode.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -16,22 +16,12 @@
* limitations under the License.
*/
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
import org.drools.common.BetaConstraints;
-import org.drools.common.DefaultBetaConstraints;
-import org.drools.common.DefaultFactHandle;
import org.drools.common.EmptyBetaConstraints;
import org.drools.common.InternalFactHandle;
import org.drools.common.InternalWorkingMemory;
import org.drools.spi.PropagationContext;
import org.drools.util.Iterator;
-import org.drools.util.LinkedList;
-import org.drools.util.LinkedListNode;
-import org.drools.util.LinkedListEntry;
import org.drools.util.AbstractHashTable.FactEntry;
/**
@@ -58,7 +48,7 @@
private static final long serialVersionUID = 320L;
static int notAssertObject = 0;
static int notAssertTuple = 0;
-
+
// ------------------------------------------------------------
// Instance methods
// ------------------------------------------------------------
@@ -115,19 +105,19 @@
final InternalWorkingMemory workingMemory) {
final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
memory.getTupleMemory().add( leftTuple );
-
- Iterator it = memory.getObjectMemory().iterator( leftTuple );
+
+ final Iterator it = memory.getObjectMemory().iterator( leftTuple );
this.constraints.updateFromTuple( leftTuple );
int matches = 0;
- for ( FactEntry entry = ( FactEntry ) it.next(); entry != null; entry = ( FactEntry ) it.next() ) {
- InternalFactHandle handle = entry.getFactHandle();
+ for ( FactEntry entry = (FactEntry) it.next(); entry != null; entry = (FactEntry) it.next() ) {
+ final InternalFactHandle handle = entry.getFactHandle();
if ( this.constraints.isAllowedCachedLeft( handle.getObject() ) ) {
matches++;
}
}
-
+
leftTuple.setMatches( matches );
-
+
if ( matches == 0 ) {
this.sink.propagateAssertTuple( leftTuple,
context,
@@ -152,17 +142,19 @@
final InternalWorkingMemory workingMemory) {
final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
memory.getObjectMemory().add( handle );
-
- Iterator it = memory.getTupleMemory().iterator();
+
+ final Iterator it = memory.getTupleMemory().iterator();
this.constraints.updateFromFactHandle( handle );
- for ( ReteTuple tuple = ( ReteTuple ) it.next(); tuple != null; tuple = ( ReteTuple ) it.next() ) {
+ for ( ReteTuple tuple = (ReteTuple) it.next(); tuple != null; tuple = (ReteTuple) it.next() ) {
if ( this.constraints.isAllowedCachedRight( tuple ) ) {
- int matches = tuple.getMatches();
+ final int matches = tuple.getMatches();
tuple.setMatches( matches + 1 );
- this.sink.propagateRetractTuple( tuple, context, workingMemory );
-// if ( matches == 0 ) {
-// this.sink.propagateRetractTuple( tuple, context, workingMemory );
-// }
+ this.sink.propagateRetractTuple( tuple,
+ context,
+ workingMemory );
+ // if ( matches == 0 ) {
+ // this.sink.propagateRetractTuple( tuple, context, workingMemory );
+ // }
}
}
}
@@ -187,17 +179,19 @@
if ( !memory.getObjectMemory().remove( handle ) ) {
return;
}
-
- Iterator it = memory.getTupleMemory().iterator();
+
+ final Iterator it = memory.getTupleMemory().iterator();
this.constraints.updateFromFactHandle( handle );
- for ( ReteTuple tuple = ( ReteTuple ) it.next(); tuple != null; tuple = ( ReteTuple ) it.next() ) {
+ for ( ReteTuple tuple = (ReteTuple) it.next(); tuple != null; tuple = (ReteTuple) it.next() ) {
if ( this.constraints.isAllowedCachedRight( tuple ) ) {
tuple.setMatches( tuple.getMatches() - 1 );
if ( tuple.getMatches() == 0 ) {
- this.sink.propagateAssertTuple( tuple, context, workingMemory );
+ this.sink.propagateAssertTuple( tuple,
+ context,
+ workingMemory );
}
}
- }
+ }
}
/**
@@ -215,23 +209,23 @@
final PropagationContext context,
final InternalWorkingMemory workingMemory) {
final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
-
+
// Must use the tuple in memory as it has the tuple matches count
- ReteTuple tuple = ( ReteTuple ) memory.getTupleMemory().remove( leftTuple );
+ final ReteTuple tuple = (ReteTuple) memory.getTupleMemory().remove( leftTuple );
if ( tuple == null ) {
leftTuple.release();
return;
- }
-
- if ( tuple.getMatches() == 0) {
+ }
+
+ if ( tuple.getMatches() == 0 ) {
this.sink.propagateRetractTuple( leftTuple,
context,
- workingMemory );
- }
+ workingMemory );
+ }
tuple.release();
- leftTuple.release();
- }
-
+ leftTuple.release();
+ }
+
/* (non-Javadoc)
* @see org.drools.reteoo.BaseNode#updateNewNode(org.drools.reteoo.WorkingMemoryImpl, org.drools.spi.PropagationContext)
*/
@@ -255,13 +249,13 @@
//
// this.attachingNewNode = true;
}
-
+
public String toString() {
ObjectSource source = this.rightInput;
while ( source.getClass() != ObjectTypeNode.class ) {
source = source.objectSource;
}
-
- return "[NotNode - " + ((ObjectTypeNode)source).getObjectType()+ "]";
+
+ return "[NotNode - " + ((ObjectTypeNode) source).getObjectType() + "]";
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectHashTable.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectHashTable.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectHashTable.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -6,17 +6,22 @@
public interface ObjectHashTable {
public Iterator iterator();
+
public Iterator iterator(ReteTuple tuple);
-
- public boolean add(InternalFactHandle handle, boolean checkExists);
+
+ public boolean add(InternalFactHandle handle,
+ boolean checkExists);
+
public boolean add(InternalFactHandle handle);
+
public boolean remove(InternalFactHandle handle);
+
public boolean contains(InternalFactHandle handle);
-
+
public boolean isIndexed();
-
+
public int size();
-
+
public Entry[] getTable();
-
+
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectSink.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectSink.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectSink.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -58,5 +58,5 @@
*/
void retractObject(InternalFactHandle handle,
PropagationContext context,
- InternalWorkingMemory workingMemory);
+ InternalWorkingMemory workingMemory);
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectSinkNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectSinkNode.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectSinkNode.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -16,8 +16,6 @@
* limitations under the License.
*/
-import java.io.Serializable;
-
/**
* Items placed in a <code>LinkedList<code> must implement this interface .
*
@@ -26,7 +24,9 @@
* @author <a href="mailto:mark.proctor at jboss.com">Mark Proctor</a>
* @author <a href="mailto:bob at werken.com">Bob McWhirter</a>
*/
-public interface ObjectSinkNode extends ObjectSink {
+public interface ObjectSinkNode
+ extends
+ ObjectSink {
/**
* Returns the next node
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectSinkNodeList.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectSinkNodeList.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectSinkNodeList.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -4,8 +4,6 @@
import java.util.Iterator;
import java.util.NoSuchElementException;
-import org.drools.util.LinkedListNode;
-
/*
* Copyright 2005 JBoss Inc
*
@@ -45,14 +43,16 @@
* @author <a href="mailto:bob at werken.com">Bob McWhirter</a>
*
*/
-public class ObjectSinkNodeList implements Serializable {
+public class ObjectSinkNodeList
+ implements
+ Serializable {
private static final long serialVersionUID = 320;
-
- private ObjectSinkNode firstNode;
- private ObjectSinkNode lastNode;
- private int size;
+ private ObjectSinkNode firstNode;
+ private ObjectSinkNode lastNode;
+ private int size;
+
/**
* Construct an empty <code>LinkedList</code>
*/
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectSinkPropagator.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectSinkPropagator.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectSinkPropagator.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -1,7 +1,5 @@
package org.drools.reteoo;
-import java.util.Map;
-
import org.drools.common.InternalFactHandle;
import org.drools.common.InternalWorkingMemory;
import org.drools.spi.PropagationContext;
@@ -16,5 +14,5 @@
InternalWorkingMemory workingMemory,
boolean useHash);
- public ObjectSink[] getSinks();
+ public ObjectSink[] getSinks();
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectSource.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectSource.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectSource.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -46,9 +46,9 @@
/** The destination for <code>FactHandleImpl</code>. */
protected ObjectSinkPropagator sink;
-
- protected ObjectSource objectSource;
+ protected ObjectSource objectSource;
+
// ------------------------------------------------------------
// Constructors
// ------------------------------------------------------------
@@ -91,12 +91,12 @@
if ( this.sink == null ) {
this.sink = new SingleObjectSinkAdapter( objectSink );
} else if ( this.sink.getClass() == SingleObjectSinkAdapter.class ) {
- CompositeObjectSinkAdapter sinkAdapter = ( CompositeObjectSinkAdapter ) new CompositeObjectSinkAdapter();
+ final CompositeObjectSinkAdapter sinkAdapter = new CompositeObjectSinkAdapter();
sinkAdapter.addObjectSink( this.sink.getSinks()[0] );
sinkAdapter.addObjectSink( objectSink );
this.sink = sinkAdapter;
} else {
- ( (CompositeObjectSinkAdapter) sink ).addObjectSink( objectSink );
+ ((CompositeObjectSinkAdapter) this.sink).addObjectSink( objectSink );
}
}
@@ -119,9 +119,11 @@
}
}
}
-
- public abstract void updateSink(ObjectSink sink, PropagationContext context, InternalWorkingMemory workingMemory);
-
+
+ public abstract void updateSink(ObjectSink sink,
+ PropagationContext context,
+ InternalWorkingMemory workingMemory);
+
public ObjectSinkPropagator getSinkPropagator() {
return this.sink;
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectTypeNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectTypeNode.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectTypeNode.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -136,21 +136,24 @@
final PropagationContext context,
final InternalWorkingMemory workingMemory) {
final FactHashTable memory = (FactHashTable) workingMemory.getNodeMemory( this );
-
+
// checks if shadow is enabled
- if(this.objectType.isShadowEnabled()) {
+ if ( this.objectType.isShadowEnabled() ) {
// need to improve this
- if( ! ( handle.getObject() instanceof ShadowProxy) ) {
+ if ( !(handle.getObject() instanceof ShadowProxy) ) {
// replaces the actual object by its shadow before propagating
handle.setObject( this.objectType.getShadow( handle.getObject() ) );
} else {
- ((ShadowProxy)handle.getObject()).updateProxy();
+ ((ShadowProxy) handle.getObject()).updateProxy();
}
}
// we do not need to check if the fact exists already
- memory.add( handle, false );
-
- this.sink.propagateAssertObject( handle, context, workingMemory );
+ memory.add( handle,
+ false );
+
+ this.sink.propagateAssertObject( handle,
+ context,
+ workingMemory );
}
/**
@@ -170,16 +173,23 @@
final FactHashTable memory = (FactHashTable) workingMemory.getNodeMemory( this );
memory.remove( handle );
- this.sink.propagateRetractObject( handle, context, workingMemory, true );
- }
-
- public void updateSink(ObjectSink sink, PropagationContext context, InternalWorkingMemory workingMemory) {
- final FactHashTable memory = (FactHashTable) workingMemory.getNodeMemory( this );
- Iterator it = memory.iterator();
- for ( FactEntry entry = ( FactEntry ) it.next(); entry != null; entry = ( FactEntry ) it.next() ) {
- sink.assertObject( entry.getFactHandle(), context, workingMemory );
+ this.sink.propagateRetractObject( handle,
+ context,
+ workingMemory,
+ true );
+ }
+
+ public void updateSink(final ObjectSink sink,
+ final PropagationContext context,
+ final InternalWorkingMemory workingMemory) {
+ final FactHashTable memory = (FactHashTable) workingMemory.getNodeMemory( this );
+ final Iterator it = memory.iterator();
+ for ( FactEntry entry = (FactEntry) it.next(); entry != null; entry = (FactEntry) it.next() ) {
+ sink.assertObject( entry.getFactHandle(),
+ context,
+ workingMemory );
}
- }
+ }
/**
* Rete needs to know that this ObjectTypeNode has been added
@@ -208,8 +218,8 @@
public void remove(final BaseNode node,
final InternalWorkingMemory[] workingMemories) {
- if( !node.isInUse()) {
- removeObjectSink( ( ObjectSink ) node );
+ if ( !node.isInUse() ) {
+ removeObjectSink( (ObjectSink) node );
}
removeShare();
if ( !this.isInUse() ) {
@@ -238,7 +248,7 @@
}
public String toString() {
- return "[ObjectTypeNode("+this.id+") objectType=" + this.objectType + "]";
+ return "[ObjectTypeNode(" + this.id + ") objectType=" + this.objectType + "]";
}
/**
@@ -261,5 +271,5 @@
return this.objectType.equals( other.objectType );
}
-
+
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/Rete.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/Rete.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/Rete.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -21,19 +21,14 @@
import java.util.List;
import org.drools.FactException;
-import org.drools.FactHandle;
import org.drools.RuleBaseConfiguration;
-import org.drools.base.ShadowProxy;
import org.drools.common.BaseNode;
import org.drools.common.InternalFactHandle;
import org.drools.common.InternalWorkingMemory;
import org.drools.common.NodeMemory;
import org.drools.facttemplates.Fact;
import org.drools.facttemplates.FactImpl;
-import org.drools.rule.Rule;
-import org.drools.spi.Activation;
import org.drools.spi.PropagationContext;
-import org.drools.util.FactHashTable;
import org.drools.util.Iterator;
import org.drools.util.ObjectHashMap;
import org.drools.util.ObjectHashMap.ObjectEntry;
@@ -69,9 +64,9 @@
/**
*
*/
- private static final long serialVersionUID = 320L;
+ private static final long serialVersionUID = 320L;
/** The <code>Map</code> of <code>ObjectTypeNodes</code>. */
- private final ObjectHashMap objectTypeNodes;
+ private final ObjectHashMap objectTypeNodes;
// ------------------------------------------------------------
// Constructors
@@ -85,7 +80,7 @@
// ------------------------------------------------------------
// Instance methods
// ------------------------------------------------------------
-
+
/**
* This is the entry point into the network for all asserted Facts. Iterates a cache
* of matching <code>ObjectTypdeNode</code>s asserting the Fact. If the cache does not
@@ -104,15 +99,15 @@
final ObjectHashMap memory = (ObjectHashMap) workingMemory.getNodeMemory( this );
final Object object = handle.getObject();
-
+
Object key = null;
-
- if ( object.getClass() == FactImpl.class ) {
- key = ( ( Fact ) object ).getFactTemplate().getName();
+
+ if ( object.getClass() == FactImpl.class ) {
+ key = ((Fact) object).getFactTemplate().getName();
} else {
key = object.getClass();
}
-
+
ObjectTypeNode[] cachedNodes = (ObjectTypeNode[]) memory.get( key );
if ( cachedNodes == null ) {
cachedNodes = getMatchingNodes( object );
@@ -145,12 +140,12 @@
final Object object = handle.getObject();
// @todo : this is a nasty hack to make manners run, fix asap!!!
- ObjectTypeNode[] cachedNodes = (ObjectTypeNode[]) memory.get( object.getClass().getSuperclass() );
+ final ObjectTypeNode[] cachedNodes = (ObjectTypeNode[]) memory.get( object.getClass().getSuperclass() );
if ( cachedNodes == null ) {
// it is possible that there are no ObjectTypeNodes for an object being retracted
return;
}
-
+
for ( int i = 0; i < cachedNodes.length; i++ ) {
cachedNodes[i].retractObject( handle,
context,
@@ -161,16 +156,16 @@
private ObjectTypeNode[] getMatchingNodes(final Object object) throws FactException {
final List cache = new ArrayList();
- Iterator it = this.objectTypeNodes.iterator();
- for ( ObjectEntry entry = (ObjectEntry)it.next(); entry != null; entry = (ObjectEntry)it.next() ) {
+ final Iterator it = this.objectTypeNodes.iterator();
+ for ( ObjectEntry entry = (ObjectEntry) it.next(); entry != null; entry = (ObjectEntry) it.next() ) {
final ObjectTypeNode node = (ObjectTypeNode) entry.getValue();
if ( node.matches( object ) ) {
cache.add( node );
- }
+ }
}
-
+
return (ObjectTypeNode[]) cache.toArray( new ObjectTypeNode[cache.size()] );
- }
+ }
/**
* Adds the <code>TupleSink</code> so that it may receive
@@ -181,7 +176,7 @@
* <code>Tuples</code>.
*/
protected void addObjectSink(final ObjectSink objectSink) {
- ObjectTypeNode node = ( ObjectTypeNode ) objectSink;
+ final ObjectTypeNode node = (ObjectTypeNode) objectSink;
this.objectTypeNodes.put( node.getObjectType(),
node,
true );
@@ -192,20 +187,20 @@
}
public void attach() {
- throw new UnsupportedOperationException( "cannot call attach() from the root Rete node");
+ throw new UnsupportedOperationException( "cannot call attach() from the root Rete node" );
}
public void attach(final InternalWorkingMemory[] workingMemories) {
- throw new UnsupportedOperationException( "cannot call attach() from the root Rete node");
+ throw new UnsupportedOperationException( "cannot call attach() from the root Rete node" );
}
public void remove(final BaseNode node,
final InternalWorkingMemory[] workingMemories) {
- final ObjectTypeNode objectTypeNode = (ObjectTypeNode) node;
+ final ObjectTypeNode objectTypeNode = (ObjectTypeNode) node;
removeObjectSink( objectTypeNode );
//@todo: we really should attempt to clear the memory cache for this ObjectTypeNode
}
-
+
public ObjectHashMap getObjectTypeNodes() {
return this.objectTypeNodes;
}
@@ -231,19 +226,19 @@
return this.objectTypeNodes.equals( other.objectTypeNodes );
}
- public void updateSink(ObjectSink sink,
- PropagationContext context,
- InternalWorkingMemory workingMemory) {
- ObjectTypeNode node = ( ObjectTypeNode) sink;
+ public void updateSink(final ObjectSink sink,
+ final PropagationContext context,
+ final InternalWorkingMemory workingMemory) {
+ final ObjectTypeNode node = (ObjectTypeNode) sink;
for ( final java.util.Iterator i = workingMemory.getFactHandleMap().entrySet().iterator(); i.hasNext(); ) {
final java.util.Map.Entry entry = (java.util.Map.Entry) i.next();
final InternalFactHandle handle = (InternalFactHandle) entry.getValue();
- if ( node.matches( handle.getObject() ) ) {
+ if ( node.matches( handle.getObject() ) ) {
node.assertObject( handle,
context,
workingMemory );
}
- }
+ }
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteTuple.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteTuple.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteTuple.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -13,7 +13,7 @@
implements
Tuple,
Entry {
- private static final long serialVersionUID = 320L;
+ private static final long serialVersionUID = 320L;
private int index;
@@ -23,16 +23,16 @@
private Activation activation;
- private long recency;
-
- private int hashCode;
-
+ private long recency;
+
+ private int hashCode;
+
private boolean fieldIndexed;
-
+
private int matches;
-
- private Entry next;
+ private Entry next;
+
// ------------------------------------------------------------
// Constructors
// ------------------------------------------------------------
@@ -63,44 +63,44 @@
this.parent = parentTuple;
this.recency = parentTuple.recency + handle.getRecency();
this.handle = handle;
- this.hashCode = parentTuple.hashCode ^( handle.hashCode() * 31 );
+ this.hashCode = parentTuple.hashCode ^ (handle.hashCode() * 31);
}
- public InternalFactHandle get(int index) {
+ public InternalFactHandle get(final int index) {
ReteTuple entry = this;
while ( entry.index != index ) {
entry = entry.parent;
}
return entry.handle;
- }
-
- public void setNext(Entry next) {
+ }
+
+ public void setNext(final Entry next) {
this.next = next;
}
public Entry getNext() {
return this.next;
- }
-
- public void release() {
+ }
+
+ public void release() {
this.parent = null;
this.activation = null;
setNext( null );
- }
-
+ }
+
public boolean isFieldIndexed() {
- return fieldIndexed;
+ return this.fieldIndexed;
}
- public void setIsFieldIndexHashCode(boolean fieldIndexed) {
+ public void setIsFieldIndexHashCode(final boolean fieldIndexed) {
this.fieldIndexed = fieldIndexed;
- }
+ }
public int getMatches() {
- return matches;
+ return this.matches;
}
- public void setMatches(int matches) {
+ public void setMatches(final int matches) {
this.matches = matches;
}
@@ -108,7 +108,7 @@
return this.handle;
}
- public InternalFactHandle get(Declaration declaration) {
+ public InternalFactHandle get(final Declaration declaration) {
return get( declaration.getColumn().getIndex() );
}
@@ -117,7 +117,7 @@
}
public InternalFactHandle[] getFactHandles() {
- List list = new ArrayList();
+ final List list = new ArrayList();
ReteTuple entry = this;
while ( entry != null ) {
list.add( entry.handle );
@@ -131,18 +131,17 @@
return this.recency;
}
- public void setActivation(Activation activation) {
+ public void setActivation(final Activation activation) {
this.activation = activation;
}
-
-
+
public int hashCode() {
return this.hashCode;
}
-
+
public String toString() {
- StringBuffer buffer = new StringBuffer();
-
+ final StringBuffer buffer = new StringBuffer();
+
ReteTuple entry = this;
while ( entry != null ) {
//buffer.append( entry.handle );
@@ -151,36 +150,36 @@
}
return buffer.toString();
}
-
+
/**
* We use this equals method to avoid the cast
* @param tuple
* @return
*/
- public boolean equals(ReteTuple other) {
+ public boolean equals(final ReteTuple other) {
// we know the object is never null and always of the type ReteTuple
if ( other == this ) {
return true;
}
-
+
// A ReteTuple is only the same if it has the same hashCode, factId and parent
if ( this.hashCode != other.hashCode ) {
return false;
}
-
+
if ( this.handle != other.handle ) {
return false;
}
-
- if( this.parent == null ) {
- return ( other.parent == null );
+
+ if ( this.parent == null ) {
+ return (other.parent == null);
} else {
- return this.parent.equals( other.parent );
- }
+ return this.parent.equals( other.parent );
+ }
}
-
- public boolean equals(Object object) {
+
+ public boolean equals(final Object object) {
// we know the object is never null and always of the type ReteTuple
- return equals((ReteTuple)object);
+ return equals( (ReteTuple) object );
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteooBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteooBuilder.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteooBuilder.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -368,8 +368,8 @@
}
private BetaConstraints attachColumn(final Column column,
- final GroupElement parent,
- final boolean removeIdentities) throws InvalidPatternException {
+ final GroupElement parent,
+ final boolean removeIdentities) throws InvalidPatternException {
// Adjusting offset in case a previous Initial-Fact was added to the network
column.adjustOffset( this.currentOffsetAdjustment );
@@ -384,8 +384,8 @@
final List predicates = attachAlphaNodes( column,
removeIdentities );
- BetaConstraints binder = createBetaNodeConstraint( predicates );
-
+ final BetaConstraints binder = createBetaNodeConstraint( predicates );
+
return binder;
}
@@ -407,7 +407,7 @@
final Map.Entry entry = (Map.Entry) it.next();
final Class previousClass = ((ClassObjectType) entry.getKey()).getClassType();
if ( thisClass.isAssignableFrom( previousClass ) ) {
- betaConstraints.add( new InstanceNotEqualsConstraint( (Column) entry.getValue()) );
+ betaConstraints.add( new InstanceNotEqualsConstraint( (Column) entry.getValue() ) );
}
}
@@ -428,13 +428,13 @@
}
final Constraint constraint = (Constraint) object;
- if ( constraint.getRequiredDeclarations().length == 0) {
+ if ( constraint.getRequiredDeclarations().length == 0 ) {
this.objectSource = attachNode( new AlphaNode( this.id++,
(AlphaNodeFieldConstraint) constraint,
this.objectSource ) );
} else {
checkUnboundDeclarations( ((BetaNodeFieldConstraint) constraint).getRequiredDeclarations() );
- betaConstraints.add( (BetaNodeFieldConstraint) constraint );
+ betaConstraints.add( constraint );
}
}
@@ -487,7 +487,7 @@
column.getFactIndex(),
notNode ) );
- BetaConstraints identityBinder = new DefaultBetaConstraints( new InstanceEqualsConstraint( column ) );
+ final BetaConstraints identityBinder = new DefaultBetaConstraints( new InstanceEqualsConstraint( column ) );
notNode = (NotNode) attachNode( new NotNode( this.id++,
tupleSource,
adapter,
@@ -556,7 +556,7 @@
private void attachFrom(final TupleSource tupleSource,
final From from) {
- Column column = from.getColumn();
+ final Column column = from.getColumn();
// If a tupleSource does not exist then we need to adapt an
// InitialFact into a a TupleSource using LeftInputAdapterNode
@@ -608,9 +608,9 @@
}
}
- BetaConstraints binder = createBetaNodeConstraint( betaConstraints );
+ final BetaConstraints binder = createBetaNodeConstraint( betaConstraints );
- this.tupleSource = attachNode( new FromNode( id++,
+ this.tupleSource = attachNode( new FromNode( this.id++,
from.getDataProvider(),
this.tupleSource,
(AlphaNodeFieldConstraint[]) alphaConstraints.toArray( new AlphaNodeFieldConstraint[alphaConstraints.size()] ),
@@ -637,10 +637,10 @@
final Column sourceColumn = accumulate.getSourceColumn();
final BetaConstraints sourceBinder = attachColumn( sourceColumn,
- parent,
- true );
+ parent,
+ true );
- Column column = accumulate.getResultColumn();
+ final Column column = accumulate.getResultColumn();
// Adjusting offset in case a previous Initial-Fact was added to the network
column.adjustOffset( this.currentOffsetAdjustment );
@@ -677,9 +677,9 @@
}
}
- BetaConstraints resultsBinder = createBetaNodeConstraint( betaConstraints );
+ final BetaConstraints resultsBinder = createBetaNodeConstraint( betaConstraints );
- this.tupleSource = attachNode( new AccumulateNode( id++,
+ this.tupleSource = attachNode( new AccumulateNode( this.id++,
this.tupleSource,
this.objectSource,
(AlphaNodeFieldConstraint[]) alphaConstraints.toArray( new AlphaNodeFieldConstraint[alphaConstraints.size()] ),
@@ -707,10 +707,10 @@
final Column sourceColumn = collect.getSourceColumn();
final BetaConstraints sourceBinder = attachColumn( sourceColumn,
- parent,
- true );
+ parent,
+ true );
- Column column = collect.getResultColumn();
+ final Column column = collect.getResultColumn();
// Adjusting offset in case a previous Initial-Fact was added to the network
column.adjustOffset( this.currentOffsetAdjustment );
@@ -747,9 +747,9 @@
}
}
- BetaConstraints resultsBinder = createBetaNodeConstraint( betaConstraints );
+ final BetaConstraints resultsBinder = createBetaNodeConstraint( betaConstraints );
- this.tupleSource = attachNode( new CollectNode( id++,
+ this.tupleSource = attachNode( new CollectNode( this.id++,
this.tupleSource,
this.objectSource,
(AlphaNodeFieldConstraint[]) alphaConstraints.toArray( new AlphaNodeFieldConstraint[alphaConstraints.size()] ),
@@ -826,24 +826,24 @@
throw new InvalidPatternException( "Required Declarations not bound: '" + buffer );
}
}
-
- public static BetaConstraints createBetaNodeConstraint(List list){
+
+ public static BetaConstraints createBetaNodeConstraint(final List list) {
BetaConstraints constraints;
- switch (list.size()) {
- case 0:
+ switch ( list.size() ) {
+ case 0 :
constraints = EmptyBetaConstraints.getInstance();
break;
- case 1:
- constraints = new SingleBetaConstraints( (BetaNodeFieldConstraint) list.get( 0 ) );
+ case 1 :
+ constraints = new SingleBetaConstraints( (BetaNodeFieldConstraint) list.get( 0 ) );
break;
- case 2:
+ case 2 :
constraints = new DoubleBetaConstraints( (BetaNodeFieldConstraint[]) list.toArray( new BetaNodeFieldConstraint[list.size()] ) );
break;
- case 3:
+ case 3 :
constraints = new TripleBetaConstraints( (BetaNodeFieldConstraint[]) list.toArray( new BetaNodeFieldConstraint[list.size()] ) );
break;
- default:
- constraints = new DefaultBetaConstraints( (BetaNodeFieldConstraint[]) list.toArray( new BetaNodeFieldConstraint[list.size()] ) );
+ default :
+ constraints = new DefaultBetaConstraints( (BetaNodeFieldConstraint[]) list.toArray( new BetaNodeFieldConstraint[list.size()] ) );
}
return constraints;
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteooFactHandleFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteooFactHandleFactory.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteooFactHandleFactory.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -22,7 +22,7 @@
import org.drools.spi.FactHandleFactory;
public class ReteooFactHandleFactory extends AbstractFactHandleFactory {
-
+
private static final long serialVersionUID = 300;
/* (non-Javadoc)
@@ -42,7 +42,7 @@
public FactHandleFactory newInstance() {
return new ReteooFactHandleFactory();
}
-
+
public Class getFactHandleType() {
return DefaultFactHandle.class;
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteooRuleBase.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteooRuleBase.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteooRuleBase.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -106,7 +106,7 @@
* @param rete
* The rete network.
*/
- public ReteooRuleBase(String id,
+ public ReteooRuleBase(final String id,
final RuleBaseConfiguration config,
final FactHandleFactory factHandleFactory) {
super( id,
@@ -122,7 +122,7 @@
this.globals = new HashMap();
this.workingMemories = new WeakHashMap();
- this.rete = new Rete( );
+ this.rete = new Rete();
this.reteooBuilder = new ReteooBuilder( this );
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteooWorkingMemory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteooWorkingMemory.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteooWorkingMemory.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -23,11 +23,9 @@
import org.drools.FactException;
import org.drools.FactHandle;
import org.drools.QueryResults;
-import org.drools.WorkingMemory;
import org.drools.base.DroolsQuery;
import org.drools.common.AbstractWorkingMemory;
import org.drools.common.DefaultAgenda;
-import org.drools.common.EqualityKey;
import org.drools.common.InternalFactHandle;
import org.drools.common.InternalRuleBase;
import org.drools.common.PropagationContextImpl;
@@ -136,12 +134,12 @@
public void propagate() {
- PropagationContext context = new PropagationContextImpl( ReteooWorkingMemory.this.propagationIdCounter++,
+ final PropagationContext context = new PropagationContextImpl( ReteooWorkingMemory.this.propagationIdCounter++,
PropagationContext.ASSERTION,
this.ruleOrigin,
this.activationOrigin );
- ReteooWorkingMemory.this.ruleBase.assertObject( factHandle,
- factHandle.getObject(),
+ ReteooWorkingMemory.this.ruleBase.assertObject( this.factHandle,
+ this.factHandle.getObject(),
context,
ReteooWorkingMemory.this );
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/RightInputAdapterNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/RightInputAdapterNode.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/RightInputAdapterNode.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -16,12 +16,7 @@
* limitations under the License.
*/
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
import org.drools.common.BaseNode;
-import org.drools.common.DefaultFactHandle;
import org.drools.common.InternalFactHandle;
import org.drools.common.InternalWorkingMemory;
import org.drools.spi.PropagationContext;
@@ -80,7 +75,9 @@
public void assertTuple(final ReteTuple tuple,
final PropagationContext context,
final InternalWorkingMemory workingMemory) {
- this.sink.propagateAssertObject( (InternalFactHandle) tuple.get( this.column ), context, workingMemory );
+ this.sink.propagateAssertObject( tuple.get( this.column ),
+ context,
+ workingMemory );
}
/* (non-Javadoc)
@@ -89,7 +86,10 @@
public void retractTuple(final ReteTuple tuple,
final PropagationContext context,
final InternalWorkingMemory workingMemory) {
- this.sink.propagateRetractObject( (InternalFactHandle) tuple.get( this.column ), context, workingMemory, true );
+ this.sink.propagateRetractObject( tuple.get( this.column ),
+ context,
+ workingMemory,
+ true );
}
/* (non-Javadoc)
@@ -110,19 +110,22 @@
public void updateSink(final ObjectSink sink,
final PropagationContext context,
final InternalWorkingMemory workingMemory) {
- this.tupleSource.updateSink( new TupleSinkAdapter( sink, this.column), context, workingMemory );
+ this.tupleSource.updateSink( new TupleSinkAdapter( sink,
+ this.column ),
+ context,
+ workingMemory );
}
public void remove(final BaseNode node,
final InternalWorkingMemory[] workingMemories) {
- if( !node.isInUse() ) {
- removeObjectSink( (ObjectSink ) node );
+ if ( !node.isInUse() ) {
+ removeObjectSink( (ObjectSink) node );
}
removeShare();
this.tupleSource.remove( this,
workingMemories );
}
-
+
/**
* Used with the updateSink method, so that the parent ObjectSource
* can update the TupleSink
@@ -133,29 +136,32 @@
implements
TupleSink {
private ObjectSink sink;
- private int column;
+ private int column;
- public TupleSinkAdapter(ObjectSink sink, int column) {
+ public TupleSinkAdapter(final ObjectSink sink,
+ final int column) {
this.sink = sink;
- this.column = column;
+ this.column = column;
}
- public void assertTuple(ReteTuple tuple,
- PropagationContext context,
- InternalWorkingMemory workingMemory) {
- this.sink.assertObject( (InternalFactHandle) tuple.get( this.column ), context, workingMemory );
+ public void assertTuple(final ReteTuple tuple,
+ final PropagationContext context,
+ final InternalWorkingMemory workingMemory) {
+ this.sink.assertObject( tuple.get( this.column ),
+ context,
+ workingMemory );
}
- public void modifyTuple(ReteTuple tuple,
- PropagationContext context,
- InternalWorkingMemory workingMemory) {
+ public void modifyTuple(final ReteTuple tuple,
+ final PropagationContext context,
+ final InternalWorkingMemory workingMemory) {
throw new UnsupportedOperationException( "TupleSinkAdapter onlys supports assertObject method calls" );
}
- public void retractTuple(ReteTuple tuple,
- PropagationContext context,
- InternalWorkingMemory workingMemory) {
+ public void retractTuple(final ReteTuple tuple,
+ final PropagationContext context,
+ final InternalWorkingMemory workingMemory) {
throw new UnsupportedOperationException( "TupleSinkAdapter onlys supports assertObject method calls" );
- }
+ }
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/SingleObjectSinkAdapter.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/SingleObjectSinkAdapter.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/SingleObjectSinkAdapter.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -7,32 +7,34 @@
public class SingleObjectSinkAdapter
implements
ObjectSinkPropagator {
-
+
private ObjectSink sink;
-
- public SingleObjectSinkAdapter(ObjectSink sink) {
+
+ public SingleObjectSinkAdapter(final ObjectSink sink) {
this.sink = sink;
}
- public void propagateAssertObject(InternalFactHandle handle,
- PropagationContext context,
- InternalWorkingMemory workingMemory) {
- this.sink.assertObject( handle, context, workingMemory );
+ public void propagateAssertObject(final InternalFactHandle handle,
+ final PropagationContext context,
+ final InternalWorkingMemory workingMemory) {
+ this.sink.assertObject( handle,
+ context,
+ workingMemory );
}
-
- public void propagateRetractObject(InternalFactHandle handle,
- PropagationContext context,
- InternalWorkingMemory workingMemory,
- boolean useHash) {
- this.sink.retractObject( handle, context, workingMemory );
- }
+ public void propagateRetractObject(final InternalFactHandle handle,
+ final PropagationContext context,
+ final InternalWorkingMemory workingMemory,
+ final boolean useHash) {
+ this.sink.retractObject( handle,
+ context,
+ workingMemory );
+ }
+
public ObjectSink[] getSinks() {
- return new ObjectSink[] { this.sink };
+ return new ObjectSink[]{this.sink};
}
-
-
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/SingleTupleSinkAdapter.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/SingleTupleSinkAdapter.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/SingleTupleSinkAdapter.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -9,67 +9,67 @@
TupleSinkPropagator {
private TupleSink sink;
- public SingleTupleSinkAdapter(TupleSink sink) {
+ public SingleTupleSinkAdapter(final TupleSink sink) {
this.sink = sink;
}
-
- public void propagateAssertTuple(ReteTuple tuple,
- InternalFactHandle handle,
- PropagationContext context,
- InternalWorkingMemory workingMemory) {
+
+ public void propagateAssertTuple(final ReteTuple tuple,
+ final InternalFactHandle handle,
+ final PropagationContext context,
+ final InternalWorkingMemory workingMemory) {
this.sink.assertTuple( new ReteTuple( tuple,
handle ),
context,
workingMemory );
}
- public void propagateAssertTuple(ReteTuple tuple,
- PropagationContext context,
- InternalWorkingMemory workingMemory) {
+ public void propagateAssertTuple(final ReteTuple tuple,
+ final PropagationContext context,
+ final InternalWorkingMemory workingMemory) {
this.sink.assertTuple( new ReteTuple( tuple ),
context,
workingMemory );
- }
+ }
- public void propagateRetractTuple(ReteTuple tuple,
- InternalFactHandle handle,
- PropagationContext context,
- InternalWorkingMemory workingMemory) {
+ public void propagateRetractTuple(final ReteTuple tuple,
+ final InternalFactHandle handle,
+ final PropagationContext context,
+ final InternalWorkingMemory workingMemory) {
this.sink.retractTuple( new ReteTuple( tuple,
- handle ),
- context,
- workingMemory );
+ handle ),
+ context,
+ workingMemory );
}
-
- public void propagateRetractTuple(ReteTuple tuple,
- PropagationContext context,
- InternalWorkingMemory workingMemory) {
+
+ public void propagateRetractTuple(final ReteTuple tuple,
+ final PropagationContext context,
+ final InternalWorkingMemory workingMemory) {
this.sink.retractTuple( new ReteTuple( tuple ),
- context,
- workingMemory );
- }
+ context,
+ workingMemory );
+ }
- public ReteTuple createAndPropagateAssertTuple(InternalFactHandle handle,
- PropagationContext context,
- InternalWorkingMemory workingMemory) {
+ public ReteTuple createAndPropagateAssertTuple(final InternalFactHandle handle,
+ final PropagationContext context,
+ final InternalWorkingMemory workingMemory) {
// This is the root fact, so we don't need to clone it.
- ReteTuple tuple = new ReteTuple( handle );
+ final ReteTuple tuple = new ReteTuple( handle );
this.sink.assertTuple( tuple,
- context,
- workingMemory );
+ context,
+ workingMemory );
return tuple;
}
- public void createAndPropagateRetractTuple(ReteTuple tuple,
- PropagationContext context,
- InternalWorkingMemory workingMemory) {
+ public void createAndPropagateRetractTuple(final ReteTuple tuple,
+ final PropagationContext context,
+ final InternalWorkingMemory workingMemory) {
this.sink.retractTuple( tuple,
- context,
- workingMemory );
+ context,
+ workingMemory );
}
-
+
public TupleSink[] getSinks() {
- return new TupleSink[] { this.sink };
+ return new TupleSink[]{this.sink};
}
// public void propagateNewTupleSink(TupleMatch tupleMatch,
@@ -138,7 +138,6 @@
// }
public int size() {
- return ( this.sink != null ) ? 1 : 0;
+ return (this.sink != null) ? 1 : 0;
}
}
-
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/TerminalNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/TerminalNode.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/TerminalNode.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -34,7 +34,6 @@
import org.drools.spi.Duration;
import org.drools.spi.PropagationContext;
import org.drools.util.Iterator;
-import org.drools.util.ObjectHashMap;
import org.drools.util.TupleHashTable;
import org.drools.util.ObjectHashMap.ObjectEntry;
@@ -61,10 +60,10 @@
/** The rule to invoke upon match. */
private final Rule rule;
private final TupleSource tupleSource;
-
- private TupleSinkNode previousTupleSinkNode;
- private TupleSinkNode nextTupleSinkNode;
+ private TupleSinkNode previousTupleSinkNode;
+ private TupleSinkNode nextTupleSinkNode;
+
// ------------------------------------------------------------
// Constructors
// ------------------------------------------------------------
@@ -102,9 +101,9 @@
// org.drools.impl.TupleSink
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- public void assertTuple(ReteTuple tuple,
+ public void assertTuple(final ReteTuple tuple,
final PropagationContext context,
- final InternalWorkingMemory workingMemory) {
+ final InternalWorkingMemory workingMemory) {
assertTuple( tuple,
context,
workingMemory,
@@ -127,9 +126,8 @@
final InternalWorkingMemory workingMemory,
final boolean fireActivationCreated) {
//we only have to clone the head fact to make sure the graph is not affected during consequence reads after a modify
- ReteTuple cloned = new ReteTuple( tuple );
-
-
+ final ReteTuple cloned = new ReteTuple( tuple );
+
// if the current Rule is no-loop and the origin rule is the same then
// return
if ( this.rule.getNoLoop() && this.rule.equals( context.getRuleOrigin() ) ) {
@@ -146,7 +144,7 @@
context,
this.rule );
final TerminalNodeMemory memory = (TerminalNodeMemory) workingMemory.getNodeMemory( this );
- if ( this.rule.getActivationGroup() != null ) {
+ if ( this.rule.getActivationGroup() != null ) {
// Lazy cache activationGroup
if ( memory.getActivationGroup() == null ) {
memory.setActivationGroup( workingMemory.getAgenda().getActivationGroup( this.rule.getActivationGroup() ) );
@@ -157,7 +155,7 @@
agenda.scheduleItem( item );
tuple.setActivation( item );
memory.getTupleMemory().add( tuple );
-
+
item.setActivated( true );
workingMemory.getAgendaEventSupport().fireActivationCreated( item );
} else {
@@ -212,7 +210,7 @@
agendaGroup.add( item );
tuple.setActivation( item );
memory.getTupleMemory().add( tuple );
-
+
item.setActivated( true );
// We only want to fire an event on a truly new Activation and not on an Activation as a result of a modify
@@ -222,19 +220,19 @@
}
}
- public void retractTuple(ReteTuple leftTuple,
+ public void retractTuple(final ReteTuple leftTuple,
final PropagationContext context,
final InternalWorkingMemory workingMemory) {
- final TerminalNodeMemory memory = (TerminalNodeMemory) workingMemory.getNodeMemory( this );
- ReteTuple tuple = ( ReteTuple ) memory.getTupleMemory().remove( leftTuple );
+ final TerminalNodeMemory memory = (TerminalNodeMemory) workingMemory.getNodeMemory( this );
+ final ReteTuple tuple = (ReteTuple) memory.getTupleMemory().remove( leftTuple );
//an activation is null if the tuple was never propagated as an assert
- if ( tuple != null && tuple.getActivation() != null ){
- Activation activation = tuple.getActivation();
+ if ( tuple != null && tuple.getActivation() != null ) {
+ final Activation activation = tuple.getActivation();
if ( activation.isActivated() ) {
activation.remove();
workingMemory.getAgendaEventSupport().fireActivationCancelled( activation );
}
-
+
workingMemory.getTruthMaintenanceSystem().removeLogicalDependencies( activation,
context,
this.rule );
@@ -265,7 +263,7 @@
PropagationContext.RULE_ADDITION,
null,
null );
- this.tupleSource.updateSink( this,
+ this.tupleSource.updateSink( this,
propagationContext,
workingMemory );
}
@@ -276,9 +274,9 @@
for ( int i = 0, length = workingMemories.length; i < length; i++ ) {
final InternalWorkingMemory workingMemory = workingMemories[i];
- final TerminalNodeMemory memory = (TerminalNodeMemory) workingMemory.getNodeMemory( this );
- Iterator it = memory.getTupleMemory().iterator();
- for ( ObjectEntry entry = (ObjectEntry)it.next(); entry != null; entry = ( ObjectEntry ) it.next() ) {
+ final TerminalNodeMemory memory = (TerminalNodeMemory) workingMemory.getNodeMemory( this );
+ final Iterator it = memory.getTupleMemory().iterator();
+ for ( ObjectEntry entry = (ObjectEntry) it.next(); entry != null; entry = (ObjectEntry) it.next() ) {
final Activation activation = (Activation) entry.getValue();
if ( activation.isActivated() ) {
@@ -292,9 +290,9 @@
null );
workingMemory.getTruthMaintenanceSystem().removeLogicalDependencies( activation,
propagationContext,
- this.rule );
+ this.rule );
}
-
+
workingMemory.propagateQueuedActions();
}
@@ -305,7 +303,7 @@
public Object createMemory(final RuleBaseConfiguration config) {
return new TerminalNodeMemory();
}
-
+
/**
* Returns the next node
* @return
@@ -320,7 +318,7 @@
* @param next
* The next TupleSinkNode
*/
- public void setNextTupleSinkNode(TupleSinkNode next) {
+ public void setNextTupleSinkNode(final TupleSinkNode next) {
this.nextTupleSinkNode = next;
}
@@ -330,7 +328,7 @@
* The previous TupleSinkNode
*/
public TupleSinkNode getPreviousTupleSinkNode() {
- return this.previousTupleSinkNode;
+ return this.previousTupleSinkNode;
}
/**
@@ -338,9 +336,9 @@
* @param previous
* The previous TupleSinkNode
*/
- public void setPreviousTupleSinkNode(TupleSinkNode previous) {
+ public void setPreviousTupleSinkNode(final TupleSinkNode previous) {
this.previousTupleSinkNode = previous;
- }
+ }
public int hashCode() {
return this.rule.hashCode();
@@ -359,15 +357,17 @@
return this.rule.equals( other.rule );
}
- class TerminalNodeMemory implements Serializable {
+ class TerminalNodeMemory
+ implements
+ Serializable {
private static final long serialVersionUID = 320L;
- private AgendaGroupImpl agendaGroup;
+ private AgendaGroupImpl agendaGroup;
- private ActivationGroup activationGroup;
-
- private TupleHashTable tupleMemory;
-
+ private ActivationGroup activationGroup;
+
+ private TupleHashTable tupleMemory;
+
public TerminalNodeMemory() {
this.tupleMemory = new TupleHashTable();
}
@@ -387,7 +387,7 @@
public void setActivationGroup(final ActivationGroup activationGroup) {
this.activationGroup = activationGroup;
}
-
+
public TupleHashTable getTupleMemory() {
return this.tupleMemory;
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/TupleSink.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/TupleSink.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/TupleSink.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -18,11 +18,8 @@
import java.io.Serializable;
-import org.drools.common.InternalFactHandle;
import org.drools.common.InternalWorkingMemory;
import org.drools.spi.PropagationContext;
-import org.drools.spi.Tuple;
-import org.drools.util.LinkedListNode;
/**
* Receiver of propagated <code>ReteTuple</code>s from a
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/TupleSinkNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/TupleSinkNode.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/TupleSinkNode.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -16,8 +16,6 @@
* limitations under the License.
*/
-import java.io.Serializable;
-
/**
* Items placed in a <code>LinkedList<code> must implement this interface .
*
@@ -26,7 +24,9 @@
* @author <a href="mailto:mark.proctor at jboss.com">Mark Proctor</a>
* @author <a href="mailto:bob at werken.com">Bob McWhirter</a>
*/
-public interface TupleSinkNode extends TupleSink {
+public interface TupleSinkNode
+ extends
+ TupleSink {
/**
* Returns the next node
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/TupleSinkNodeList.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/TupleSinkNodeList.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/TupleSinkNodeList.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -4,8 +4,6 @@
import java.util.Iterator;
import java.util.NoSuchElementException;
-import org.drools.util.LinkedListNode;
-
/*
* Copyright 2005 JBoss Inc
*
@@ -45,14 +43,16 @@
* @author <a href="mailto:bob at werken.com">Bob McWhirter</a>
*
*/
-public class TupleSinkNodeList implements Serializable {
+public class TupleSinkNodeList
+ implements
+ Serializable {
private static final long serialVersionUID = 320;
-
- private TupleSinkNode firstNode;
- private TupleSinkNode lastNode;
- private int size;
+ private TupleSinkNode firstNode;
+ private TupleSinkNode lastNode;
+ private int size;
+
/**
* Construct an empty <code>LinkedList</code>
*/
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/TupleSinkPropagator.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/TupleSinkPropagator.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/TupleSinkPropagator.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -3,7 +3,6 @@
import org.drools.common.InternalFactHandle;
import org.drools.common.InternalWorkingMemory;
import org.drools.spi.PropagationContext;
-import org.drools.util.LinkedList;
public interface TupleSinkPropagator {
public void propagateAssertTuple(ReteTuple tuple,
@@ -14,20 +13,19 @@
public void propagateAssertTuple(ReteTuple tuple,
PropagationContext context,
InternalWorkingMemory workingMemory);
-
+
public void propagateRetractTuple(ReteTuple tuple,
InternalFactHandle handle,
PropagationContext context,
- InternalWorkingMemory workingMemory);
-
+ InternalWorkingMemory workingMemory);
+
public void propagateRetractTuple(ReteTuple tuple,
PropagationContext context,
- InternalWorkingMemory workingMemory);
+ InternalWorkingMemory workingMemory);
-
public ReteTuple createAndPropagateAssertTuple(InternalFactHandle handle,
- PropagationContext context,
- InternalWorkingMemory workingMemory);
+ PropagationContext context,
+ InternalWorkingMemory workingMemory);
public void createAndPropagateRetractTuple(ReteTuple tuple,
PropagationContext context,
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/TupleSource.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/TupleSource.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/TupleSource.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -17,17 +17,10 @@
*/
import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
import org.drools.common.BaseNode;
-import org.drools.common.DefaultBetaConstraints;
-import org.drools.common.DefaultFactHandle;
import org.drools.common.InternalWorkingMemory;
import org.drools.spi.PropagationContext;
-import org.drools.util.LinkedList;
-import org.drools.util.LinkedListNode;
-import org.drools.util.LinkedListEntry;
/**
* A source of <code>ReteTuple</code> s for a <code>TupleSink</code>.
@@ -77,16 +70,16 @@
* The <code>TupleSink</code> to receive propagated
* <code>Tuples</code>.
*/
- protected void addTupleSink(final TupleSink tupleSink) {
+ protected void addTupleSink(final TupleSink tupleSink) {
if ( this.sink == null ) {
this.sink = new SingleTupleSinkAdapter( tupleSink );
} else if ( this.sink.getClass() == SingleTupleSinkAdapter.class ) {
- CompositeTupleSinkAdapter sinkAdapter = ( CompositeTupleSinkAdapter ) new CompositeTupleSinkAdapter();
+ final CompositeTupleSinkAdapter sinkAdapter = new CompositeTupleSinkAdapter();
sinkAdapter.addTupleSink( this.sink.getSinks()[0] );
sinkAdapter.addTupleSink( tupleSink );
this.sink = sinkAdapter;
} else {
- ( (CompositeTupleSinkAdapter) sink ).addTupleSink( tupleSink );
+ ((CompositeTupleSinkAdapter) this.sink).addTupleSink( tupleSink );
}
}
@@ -99,15 +92,17 @@
protected void removeTupleSink(final TupleSink tupleSink) {
if ( this.sink.getClass() == SingleTupleSinkAdapter.class ) {
this.sink = null;
- } else {
- CompositeTupleSinkAdapter sinkAdapter = ( CompositeTupleSinkAdapter ) tupleSink;
+ } else {
+ final CompositeTupleSinkAdapter sinkAdapter = (CompositeTupleSinkAdapter) tupleSink;
sinkAdapter.removeTupleSink( tupleSink );
if ( sinkAdapter.size() == 1 ) {
this.sink = new SingleTupleSinkAdapter( sinkAdapter.getSinks()[0] );
}
- }
+ }
}
-
- public abstract void updateSink(TupleSink sink, PropagationContext context, InternalWorkingMemory workingMemory);
+ public abstract void updateSink(TupleSink sink,
+ PropagationContext context,
+ InternalWorkingMemory workingMemory);
+
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/AbstractCompositeRestriction.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/AbstractCompositeRestriction.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/AbstractCompositeRestriction.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -14,16 +14,16 @@
protected final Restriction[] restrictions;
- public AbstractCompositeRestriction(Restriction[] restriction) {
+ public AbstractCompositeRestriction(final Restriction[] restriction) {
this.restrictions = restriction;
}
public Declaration[] getRequiredDeclarations() {
// Iterate all restrictions building up a unique list of declarations
// No need to cache, as this should only be called once at build time
- Set set = new HashSet();
+ final Set set = new HashSet();
for ( int i = 0, ilength = this.restrictions.length; i < ilength; i++ ) {
- Declaration[] declarations = this.restrictions[i].getRequiredDeclarations();
+ final Declaration[] declarations = this.restrictions[i].getRequiredDeclarations();
for ( int j = 0, jlength = declarations.length; j < jlength; j++ ) {
set.add( declarations[j] );
}
@@ -32,9 +32,11 @@
return (Declaration[]) set.toArray( new Declaration[set.size()] );
}
- private static int hashCode(Object[] array) {
+ private static int hashCode(final Object[] array) {
final int PRIME = 31;
- if ( array == null ) return 0;
+ if ( array == null ) {
+ return 0;
+ }
int result = 1;
for ( int index = 0; index < array.length; index++ ) {
result = PRIME * result + (array[index] == null ? 0 : array[index].hashCode());
@@ -49,7 +51,7 @@
return result;
}
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if ( this == obj ) {
return true;
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/Accumulate.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/Accumulate.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/Accumulate.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -43,7 +43,7 @@
resultColumn,
new Declaration[0],
new Declaration[0],
- null);
+ null );
}
public Accumulate(final Column sourceColumn,
@@ -72,10 +72,10 @@
}
public Accumulator getAccumulator() {
- return accumulator;
+ return this.accumulator;
}
- public void setAccumulator(Accumulator accumulator) {
+ public void setAccumulator(final Accumulator accumulator) {
this.accumulator = accumulator;
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/AndCompositeRestriction.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/AndCompositeRestriction.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/AndCompositeRestriction.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -8,7 +8,7 @@
private static final long serialVersionUID = 320;
- public AndCompositeRestriction(Restriction[] restriction) {
+ public AndCompositeRestriction(final Restriction[] restriction) {
super( restriction );
}
@@ -17,7 +17,7 @@
final WorkingMemory workingMemory) {
for ( int i = 0, ilength = this.restrictions.length; i < ilength; i++ ) {
- if ( !restrictions[i].isAllowed( object,
+ if ( !this.restrictions[i].isAllowed( object,
tuple,
workingMemory ) ) {
return false;
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/Collect.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/Collect.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/Collect.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -45,24 +45,27 @@
}
public Column getResultColumn() {
- return resultColumn;
+ return this.resultColumn;
}
public Column getSourceColumn() {
- return sourceColumn;
+ return this.sourceColumn;
}
public Collection instantiateResultObject() throws RuntimeDroolsException {
try {
// Collect can only be used with a Collection implementation, so
// FactTemplateObject type is not allowed
- return (Collection) ((ClassObjectType)resultColumn.getObjectType()).getClassType().newInstance();
- } catch (ClassCastException cce) {
- throw new RuntimeDroolsException("Collect CE requires a Collection implementation as return type", cce);
- } catch ( InstantiationException e ) {
- throw new RuntimeDroolsException("Collect CE requires a non-argument constructor for the return type", e);
- } catch ( IllegalAccessException e ) {
- throw new RuntimeDroolsException("Collect CE requires an accessible constructor for the return type", e);
+ return (Collection) ((ClassObjectType) this.resultColumn.getObjectType()).getClassType().newInstance();
+ } catch ( final ClassCastException cce ) {
+ throw new RuntimeDroolsException( "Collect CE requires a Collection implementation as return type",
+ cce );
+ } catch ( final InstantiationException e ) {
+ throw new RuntimeDroolsException( "Collect CE requires a non-argument constructor for the return type",
+ e );
+ } catch ( final IllegalAccessException e ) {
+ throw new RuntimeDroolsException( "Collect CE requires an accessible constructor for the return type",
+ e );
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/Column.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/Column.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/Column.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -25,7 +25,6 @@
import org.drools.spi.ColumnExtractor;
import org.drools.spi.Constraint;
import org.drools.spi.Extractor;
-import org.drools.spi.AlphaNodeFieldConstraint;
import org.drools.spi.ObjectType;
public class Column
@@ -161,21 +160,21 @@
return result;
}
- public boolean equals(Object object) {
+ public boolean equals(final Object object) {
if ( this == object ) {
return true;
}
-
+
if ( object == null || getClass() != object.getClass() ) {
return false;
}
-
+
final Column other = (Column) object;
if ( !this.constraints.equals( other.constraints ) ) {
return false;
}
-
+
if ( this.declaration == null ) {
if ( other.declaration != null ) {
return false;
@@ -183,12 +182,11 @@
} else if ( !this.declaration.equals( other.declaration ) ) {
return false;
}
-
+
if ( this.index != other.index ) {
return false;
}
-
-
+
if ( !this.objectType.equals( other.objectType ) ) {
return false;
}
@@ -197,7 +195,5 @@
}
return true;
}
-
-
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/ContextEntry.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/ContextEntry.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/ContextEntry.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -2,17 +2,15 @@
import org.drools.common.InternalFactHandle;
import org.drools.reteoo.ReteTuple;
-import org.drools.util.Entry;
-import org.drools.util.LinkedListNode;
public interface ContextEntry {
-
+
public ContextEntry getNext();
-
- public void setNext(ContextEntry entry);
-
- public void updateFromTuple(ReteTuple tuple);
+ public void setNext(ContextEntry entry);
+
+ public void updateFromTuple(ReteTuple tuple);
+
public void updateFromFactHandle(InternalFactHandle handle);
-
+
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/Declaration.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/Declaration.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/Declaration.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -84,7 +84,7 @@
private final Extractor extractor;
- private Column column;
+ private Column column;
// ------------------------------------------------------------
// Constructors
@@ -170,7 +170,7 @@
result = PRIME * this.identifier.hashCode();
return result;
}
-
+
public boolean equals(final Object object) {
if ( this == object ) {
return true;
@@ -180,8 +180,8 @@
return false;
}
- final Declaration other = (Declaration) object;
-
+ final Declaration other = (Declaration) object;
+
return this.column.getFactIndex() == other.column.getFactIndex() && this.identifier.equals( other.identifier ) && this.extractor.equals( other.extractor );
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/From.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/From.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/From.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -4,11 +4,13 @@
import org.drools.spi.DataProvider;
-public class From extends ConditionalElement implements Serializable {
- private Column column;
-
+public class From extends ConditionalElement
+ implements
+ Serializable {
+ private Column column;
+
private DataProvider dataProvider;
-
+
public From(final Column column,
final DataProvider dataProvider) {
this.column = column;
@@ -16,15 +18,15 @@
}
public Column getColumn() {
- return column;
+ return this.column;
}
public DataProvider getDataProvider() {
- return dataProvider;
+ return this.dataProvider;
}
public Object clone() {
// TODO Auto-generated method stub
return null;
- }
+ }
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/LineMappings.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/LineMappings.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/LineMappings.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -2,32 +2,31 @@
public class LineMappings {
private String className;
- private int startLine;
- private int offset;
-
- public LineMappings(String className) {
+ private int startLine;
+ private int offset;
+
+ public LineMappings(final String className) {
this.className = className;
}
-
+
public String getClassName() {
return this.className;
}
-
- public void setStartLine(int startLine) {
+
+ public void setStartLine(final int startLine) {
this.startLine = startLine;
}
-
+
public int getStartLine() {
return this.startLine;
}
-
- public void setOffset(int offset) {
+
+ public void setOffset(final int offset) {
this.offset = offset;
- }
-
+ }
+
public int getOffset() {
- return this.offset;
- }
-
-
+ return this.offset;
+ }
+
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/LiteralConstraint.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/LiteralConstraint.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/LiteralConstraint.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -24,31 +24,32 @@
public class LiteralConstraint
implements
- AlphaNodeFieldConstraint{
+ AlphaNodeFieldConstraint {
/**
*
*/
- private static final long serialVersionUID = 320;
+ private static final long serialVersionUID = 320;
private final FieldExtractor extractor;
-
+
private final LiteralRestriction restriction;
-
+
private final static Declaration[] emptyDeclarations = new Declaration[]{};
public LiteralConstraint(final FieldExtractor extractor,
final Evaluator evaluator,
final FieldValue field) {
this.extractor = extractor;
- this.restriction = new LiteralRestriction(field, evaluator);
+ this.restriction = new LiteralRestriction( field,
+ evaluator );
}
-
+
public LiteralConstraint(final FieldExtractor extractor,
final LiteralRestriction restriction) {
this.extractor = extractor;
this.restriction = restriction;
- }
+ }
public Evaluator getEvaluator() {
return this.restriction.getEvaluator();
@@ -61,9 +62,9 @@
public FieldExtractor getFieldExtractor() {
return this.extractor;
}
-
- public Declaration[] getRDeclarations(){
- return emptyDeclarations;
+
+ public Declaration[] getRDeclarations() {
+ return LiteralConstraint.emptyDeclarations;
}
/**
@@ -77,9 +78,9 @@
public boolean isAllowed(final Object object,
final InternalWorkingMemory workingMemory) {
- return this.restriction.isAllowed( this.extractor,
- object,
- workingMemory );
+ return this.restriction.isAllowed( this.extractor,
+ object,
+ workingMemory );
}
public String toString() {
@@ -104,5 +105,5 @@
final LiteralConstraint other = (LiteralConstraint) object;
return this.extractor.equals( other.extractor ) && this.restriction.equals( other.restriction );
- }
+ }
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/LiteralRestriction.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/LiteralRestriction.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/LiteralRestriction.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -16,15 +16,12 @@
* limitations under the License.
*/
-import org.drools.WorkingMemory;
import org.drools.common.InternalWorkingMemory;
import org.drools.reteoo.ReteTuple;
-import org.drools.rule.VariableConstraint.VariableContextEntry;
import org.drools.spi.Evaluator;
import org.drools.spi.Extractor;
import org.drools.spi.FieldValue;
import org.drools.spi.Restriction;
-import org.drools.spi.Tuple;
public class LiteralRestriction
implements
@@ -54,21 +51,25 @@
public FieldValue getField() {
return this.field;
}
-
- public boolean isAllowed(Extractor extractor,
- Object object,
- InternalWorkingMemory workingMemoiry) {
- return this.evaluator.evaluate( extractor, object, field );
+
+ public boolean isAllowed(final Extractor extractor,
+ final Object object,
+ final InternalWorkingMemory workingMemoiry) {
+ return this.evaluator.evaluate( extractor,
+ object,
+ this.field );
}
-
- public boolean isAllowedCachedLeft(ContextEntry context, Object object) {
- throw new UnsupportedOperationException("cannot call isAllowed(ContextEntry context)");
- }
-
- public boolean isAllowedCachedRight(ReteTuple tuple, ContextEntry context) {
- throw new UnsupportedOperationException("cannot call isAllowed(ContextEntry context)");
- }
-
+
+ public boolean isAllowedCachedLeft(final ContextEntry context,
+ final Object object) {
+ throw new UnsupportedOperationException( "cannot call isAllowed(ContextEntry context)" );
+ }
+
+ public boolean isAllowedCachedRight(final ReteTuple tuple,
+ final ContextEntry context) {
+ throw new UnsupportedOperationException( "cannot call isAllowed(ContextEntry context)" );
+ }
+
/**
* Literal constraints cannot have required declarations, so always return an empty array.
* @return
@@ -78,8 +79,6 @@
return LiteralRestriction.requiredDeclarations;
}
-
-
public String toString() {
return "[LiteralRestriction evaluator=" + this.evaluator + " value=" + this.field + "]";
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/OrCompositeRestriction.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/OrCompositeRestriction.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/OrCompositeRestriction.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -8,7 +8,7 @@
private static final long serialVersionUID = 320;
- public OrCompositeRestriction(Restriction[] restriction) {
+ public OrCompositeRestriction(final Restriction[] restriction) {
super( restriction );
}
@@ -17,7 +17,7 @@
final WorkingMemory workingMemory) {
for ( int i = 0, ilength = this.restrictions.length; i < ilength; i++ ) {
- if ( restrictions[i].isAllowed( object,
+ if ( this.restrictions[i].isAllowed( object,
tuple,
workingMemory ) ) {
return true;
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/Package.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/Package.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/Package.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -35,7 +35,6 @@
import java.util.Map;
import org.drools.facttemplates.FactTemplate;
-import org.drools.spi.TypeResolver;
/**
* Collection of related <code>Rule</code>s.
@@ -69,7 +68,7 @@
private Map rules;
private List imports;
-
+
private List functions;
private List functionImports;
@@ -227,15 +226,15 @@
}
this.functionImports.add( functionImport );
}
-
- public void addFunction(String functionName) {
+
+ public void addFunction(final String functionName) {
if ( this.functions == Collections.EMPTY_LIST ) {
this.functions = new ArrayList( 1 );
}
-
+
this.functions.add( functionName );
- }
-
+ }
+
public List getFunctions() {
return this.functions;
}
@@ -274,7 +273,7 @@
return (FactTemplate) this.factTemplates.get( name );
}
- public void addFactTemplate(FactTemplate factTemplate) {
+ public void addFactTemplate(final FactTemplate factTemplate) {
if ( this.factTemplates == Collections.EMPTY_MAP ) {
this.factTemplates = new HashMap( 1 );
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/PackageCompilationData.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/PackageCompilationData.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/PackageCompilationData.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -54,12 +54,12 @@
private Object AST;
private Map store;
-
+
private Map lineMappings;
private transient PackageClassLoader classLoader;
- private transient ClassLoader parentClassLoader;
+ private transient ClassLoader parentClassLoader;
/**
* Default constructor - for Externalizable. This should never be used by a user, as it
@@ -263,17 +263,17 @@
public void removeInvoker(final String className) {
this.invokerLookups.remove( className );
}
-
+
public Map getLineMappings() {
return this.lineMappings;
}
-
- public void setLineMappings(Map lineMappings) {
+
+ public void setLineMappings(final Map lineMappings) {
this.lineMappings = lineMappings;
}
-
- public LineMappings getLineMappings(String className) {
- return ( LineMappings ) this.lineMappings.get( className );
+
+ public LineMappings getLineMappings(final String className) {
+ return (LineMappings) this.lineMappings.get( className );
}
public Object getAST() {
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/PredicateConstraint.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/PredicateConstraint.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/PredicateConstraint.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -81,9 +81,9 @@
}
public String toString() {
- return "[PredicateConstraint declarations=" + this.requiredDeclarations + "]";
- }
-
+ return "[PredicateConstraint declarations=" + this.requiredDeclarations + "]";
+ }
+
public boolean isAllowed(final Object object,
final Tuple tuple,
final WorkingMemory workingMemory) {
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/ReturnValueConstraint.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/ReturnValueConstraint.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/ReturnValueConstraint.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -17,8 +17,8 @@
*/
import org.drools.WorkingMemory;
+import org.drools.spi.AlphaNodeFieldConstraint;
import org.drools.spi.Evaluator;
-import org.drools.spi.AlphaNodeFieldConstraint;
import org.drools.spi.FieldExtractor;
import org.drools.spi.ReturnValueExpression;
import org.drools.spi.Tuple;
@@ -52,12 +52,12 @@
declarations,
evaluator );
}
-
+
public ReturnValueConstraint(final FieldExtractor fieldExtractor,
final ReturnValueRestriction restriction) {
this.fieldExtractor = fieldExtractor;
this.restriction = restriction;
- }
+ }
public Declaration[] getRequiredDeclarations() {
return this.restriction.getRequiredDeclarations();
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/ReturnValueRestriction.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/ReturnValueRestriction.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/ReturnValueRestriction.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -30,9 +30,11 @@
implements
Restriction {
- private static int hashCode(Object[] array) {
+ private static int hashCode(final Object[] array) {
final int PRIME = 31;
- if ( array == null ) return 0;
+ if ( array == null ) {
+ return 0;
+ }
int result = 1;
for ( int index = 0; index < array.length; index++ ) {
result = PRIME * result + (array[index] == null ? 0 : array[index].hashCode());
@@ -114,7 +116,7 @@
return result;
}
- public boolean equals(Object object) {
+ public boolean equals(final Object object) {
if ( object == this ) {
return true;
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/VariableConstraint.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/VariableConstraint.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/VariableConstraint.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -65,14 +65,14 @@
return this.restriction.getEvaluator();
}
- public boolean isAllowedCachedLeft(ContextEntry context,
- Object object) {
+ public boolean isAllowedCachedLeft(final ContextEntry context,
+ final Object object) {
return this.restriction.isAllowedCachedLeft( context,
object );
}
- public boolean isAllowedCachedRight(ReteTuple tuple,
- ContextEntry context) {
+ public boolean isAllowedCachedRight(final ReteTuple tuple,
+ final ContextEntry context) {
return this.restriction.isAllowedCachedRight( tuple,
context );
}
@@ -82,7 +82,7 @@
}
public ContextEntry getContextEntry() {
- Class classType = this.fieldExtractor.getValueType().getClassType();
+ final Class classType = this.fieldExtractor.getValueType().getClassType();
if ( classType.isPrimitive() ) {
if ( classType == Boolean.TYPE ) {
return new BooleanVariableContextEntry( this.fieldExtractor,
@@ -129,8 +129,8 @@
public Declaration declaration;
private ContextEntry entry;
- public VariableContextEntry(FieldExtractor extractor,
- Declaration declaration) {
+ public VariableContextEntry(final FieldExtractor extractor,
+ final Declaration declaration) {
this.extractor = extractor;
this.declaration = declaration;
}
@@ -139,7 +139,7 @@
return this.entry;
}
- public void setNext(ContextEntry entry) {
+ public void setNext(final ContextEntry entry) {
this.entry = entry;
}
}
@@ -148,17 +148,17 @@
public Object left;
public Object right;
- public ObjectVariableContextEntry(FieldExtractor extractor,
- Declaration declaration) {
+ public ObjectVariableContextEntry(final FieldExtractor extractor,
+ final Declaration declaration) {
super( extractor,
declaration );
}
- public void updateFromTuple(ReteTuple tuple) {
+ public void updateFromTuple(final ReteTuple tuple) {
this.left = this.declaration.getExtractor().getValue( tuple.get( this.declaration ).getObject() );
}
- public void updateFromFactHandle(InternalFactHandle handle) {
+ public void updateFromFactHandle(final InternalFactHandle handle) {
this.right = this.extractor.getValue( handle.getObject() );
}
}
@@ -167,17 +167,17 @@
public long left;
public long right;
- public LongVariableContextEntry(FieldExtractor extractor,
- Declaration declaration) {
+ public LongVariableContextEntry(final FieldExtractor extractor,
+ final Declaration declaration) {
super( extractor,
declaration );
}
- public void updateFromTuple(ReteTuple tuple) {
+ public void updateFromTuple(final ReteTuple tuple) {
this.left = this.declaration.getExtractor().getLongValue( tuple.get( this.declaration ).getObject() );
}
- public void updateFromFactHandle(InternalFactHandle handle) {
+ public void updateFromFactHandle(final InternalFactHandle handle) {
this.right = this.extractor.getLongValue( handle.getObject() );
}
}
@@ -186,17 +186,17 @@
public double left;
public double right;
- public DoubleVariableContextEntry(FieldExtractor extractor,
- Declaration declaration) {
+ public DoubleVariableContextEntry(final FieldExtractor extractor,
+ final Declaration declaration) {
super( extractor,
declaration );
}
- public void updateFromTuple(ReteTuple tuple) {
+ public void updateFromTuple(final ReteTuple tuple) {
this.left = this.declaration.getExtractor().getDoubleValue( tuple.get( this.declaration ).getObject() );
}
- public void updateFromFactHandle(InternalFactHandle handle) {
+ public void updateFromFactHandle(final InternalFactHandle handle) {
this.right = this.extractor.getDoubleValue( handle.getObject() );
}
}
@@ -205,17 +205,17 @@
public boolean left;
public boolean right;
- public BooleanVariableContextEntry(FieldExtractor extractor,
- Declaration declaration) {
+ public BooleanVariableContextEntry(final FieldExtractor extractor,
+ final Declaration declaration) {
super( extractor,
declaration );
}
- public void updateFromTuple(ReteTuple tuple) {
+ public void updateFromTuple(final ReteTuple tuple) {
this.left = this.declaration.getExtractor().getBooleanValue( tuple.get( this.declaration ).getObject() );
}
- public void updateFromFactHandle(InternalFactHandle handle) {
+ public void updateFromFactHandle(final InternalFactHandle handle) {
this.right = this.extractor.getBooleanValue( handle.getObject() );
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/VariableRestriction.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/VariableRestriction.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/VariableRestriction.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -53,24 +53,26 @@
public Evaluator getEvaluator() {
return this.evaluator;
- }
-
- public boolean isAllowedCachedLeft(ContextEntry context, Object object) {
-// return this.evaluator.evaluate( ((VariableContextEntry) context).left,
-// ((VariableContextEntry) context).extractor,
-// object );
+ }
+
+ public boolean isAllowedCachedLeft(final ContextEntry context,
+ final Object object) {
+ // return this.evaluator.evaluate( ((VariableContextEntry) context).left,
+ // ((VariableContextEntry) context).extractor,
+ // object );
return this.evaluator.evaluateCachedLeft( (VariableContextEntry) context,
- object );
- }
-
- public boolean isAllowedCachedRight(ReteTuple tuple, ContextEntry context) {
-// return this.evaluator.evaluate( this.declaration.getExtractor(),
-// tuple.get( this.declaration ).getObject(),
-// ((VariableContextEntry) context).right );
- return this.evaluator.evaluateCachedRight((VariableContextEntry) context,
- tuple.get( this.declaration ).getObject());
- }
+ object );
+ }
+ public boolean isAllowedCachedRight(final ReteTuple tuple,
+ final ContextEntry context) {
+ // return this.evaluator.evaluate( this.declaration.getExtractor(),
+ // tuple.get( this.declaration ).getObject(),
+ // ((VariableContextEntry) context).right );
+ return this.evaluator.evaluateCachedRight( (VariableContextEntry) context,
+ tuple.get( this.declaration ).getObject() );
+ }
+
public String toString() {
return "[VariableRestriction declaration=" + this.declaration + "]";
}
@@ -102,9 +104,9 @@
other.requiredDeclarations );
}
- public boolean isAllowed(Extractor extractor,
- Object object,
- InternalWorkingMemory workingMemoiry) {
- throw new UnsupportedOperationException("does not support method call isAllowed(Object object, InternalWorkingMemory workingMemoiry)" );
+ public boolean isAllowed(final Extractor extractor,
+ final Object object,
+ final InternalWorkingMemory workingMemoiry) {
+ throw new UnsupportedOperationException( "does not support method call isAllowed(Object object, InternalWorkingMemory workingMemoiry)" );
}
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/AgendaGroup.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/AgendaGroup.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/AgendaGroup.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -30,7 +30,9 @@
* @author <a href="mailto:bob at werken.com">Bob McWhirter</a>
*
*/
-public interface AgendaGroup extends Serializable {
+public interface AgendaGroup
+ extends
+ Serializable {
/**
* Static reference to determine the default <code>AgendaGroup</code> name.
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/AlphaNodeFieldConstraint.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/AlphaNodeFieldConstraint.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/AlphaNodeFieldConstraint.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -16,15 +16,12 @@
* limitations under the License.
*/
-import org.drools.WorkingMemory;
import org.drools.common.InternalWorkingMemory;
-import org.drools.rule.ContextEntry;
-import org.drools.rule.Declaration;
public interface AlphaNodeFieldConstraint
extends
Constraint {
-
+
public boolean isAllowed(Object object,
InternalWorkingMemory workingMemory);
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/AvailableVariables.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/AvailableVariables.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/AvailableVariables.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -6,28 +6,28 @@
public class AvailableVariables {
private Map[] maps;
-
- public AvailableVariables(Map[] maps) {
+
+ public AvailableVariables(final Map[] maps) {
this.maps = maps;
}
-
- public Class getType(String name) {
- for ( int i = 0, length = maps.length; i < length; i++ ) {
- Object object = maps[i].get( name );
- if ( object != null ) {
+
+ public Class getType(final String name) {
+ for ( int i = 0, length = this.maps.length; i < length; i++ ) {
+ final Object object = this.maps[i].get( name );
+ if ( object != null ) {
if ( object.getClass() == Declaration.class ) {
- return ( ( Declaration ) object ).getExtractor().getExtractToClass();
+ return ((Declaration) object).getExtractor().getExtractToClass();
} else {
- return ( Class ) object;
+ return (Class) object;
}
- }
- }
+ }
+ }
return null;
}
-
- public boolean available(String name) {
- for ( int i = 0, length = maps.length; i < length; i++ ) {
- if ( maps[i].containsKey( ( name ) ) ) {
+
+ public boolean available(final String name) {
+ for ( int i = 0, length = this.maps.length; i < length; i++ ) {
+ if ( this.maps[i].containsKey( (name) ) ) {
return true;
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/BetaNodeFieldConstraint.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/BetaNodeFieldConstraint.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/BetaNodeFieldConstraint.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -22,11 +22,13 @@
public interface BetaNodeFieldConstraint
extends
Constraint {
-
- public boolean isAllowedCachedLeft(ContextEntry context, Object object );
-
- public boolean isAllowedCachedRight(ReteTuple tuple, ContextEntry context);
-
+
+ public boolean isAllowedCachedLeft(ContextEntry context,
+ Object object);
+
+ public boolean isAllowedCachedRight(ReteTuple tuple,
+ ContextEntry context);
+
public ContextEntry getContextEntry();
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/ColumnExtractor.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/ColumnExtractor.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/ColumnExtractor.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -45,71 +45,71 @@
public Class getExtractToClass() {
// @todo : this is a bit nasty, but does the trick
- if ( objectType.getClass() == ClassObjectType.class ) {
- return ((ClassObjectType) objectType).getClassType();
+ if ( this.objectType.getClass() == ClassObjectType.class ) {
+ return ((ClassObjectType) this.objectType).getClassType();
} else {
return Fact.class;
}
}
public ValueType getValueType() {
- return objectType.getValueType();
+ return this.objectType.getValueType();
}
- public boolean getBooleanValue(Object object) {
- if( this.objectType.getValueType().isBoolean() ) {
- return ((Boolean)object).booleanValue();
+ public boolean getBooleanValue(final Object object) {
+ if ( this.objectType.getValueType().isBoolean() ) {
+ return ((Boolean) object).booleanValue();
}
- throw new RuntimeDroolsException("Conversion to boolean not supported for type: "+object.getClass());
+ throw new RuntimeDroolsException( "Conversion to boolean not supported for type: " + object.getClass() );
}
- public byte getByteValue(Object object) {
- if( this.objectType.getValueType().isNumber() ) {
- return ((Number)object).byteValue();
+ public byte getByteValue(final Object object) {
+ if ( this.objectType.getValueType().isNumber() ) {
+ return ((Number) object).byteValue();
}
- throw new RuntimeDroolsException("Conversion to byte not supported for type: "+object.getClass());
+ throw new RuntimeDroolsException( "Conversion to byte not supported for type: " + object.getClass() );
}
- public char getCharValue(Object object) {
- if( this.objectType.getValueType().isChar() ) {
- return ((Character)object).charValue();
+ public char getCharValue(final Object object) {
+ if ( this.objectType.getValueType().isChar() ) {
+ return ((Character) object).charValue();
}
- throw new RuntimeDroolsException("Conversion to char not supported for type: "+object.getClass());
+ throw new RuntimeDroolsException( "Conversion to char not supported for type: " + object.getClass() );
}
- public double getDoubleValue(Object object) {
- if( this.objectType.getValueType().isNumber() ) {
- return ((Number)object).doubleValue();
+ public double getDoubleValue(final Object object) {
+ if ( this.objectType.getValueType().isNumber() ) {
+ return ((Number) object).doubleValue();
}
- throw new RuntimeDroolsException("Conversion to double not supported for type: "+object.getClass());
+ throw new RuntimeDroolsException( "Conversion to double not supported for type: " + object.getClass() );
}
- public float getFloatValue(Object object) {
- if( this.objectType.getValueType().isNumber() ) {
- return ((Number)object).floatValue();
+ public float getFloatValue(final Object object) {
+ if ( this.objectType.getValueType().isNumber() ) {
+ return ((Number) object).floatValue();
}
- throw new RuntimeDroolsException("Conversion to float not supported for type: "+object.getClass());
+ throw new RuntimeDroolsException( "Conversion to float not supported for type: " + object.getClass() );
}
- public int getIntValue(Object object) {
- if( this.objectType.getValueType().isNumber() ) {
- return ((Number)object).intValue();
+ public int getIntValue(final Object object) {
+ if ( this.objectType.getValueType().isNumber() ) {
+ return ((Number) object).intValue();
}
- throw new RuntimeDroolsException("Conversion to int not supported for type: "+object.getClass());
+ throw new RuntimeDroolsException( "Conversion to int not supported for type: " + object.getClass() );
}
- public long getLongValue(Object object) {
- if( this.objectType.getValueType().isNumber() ) {
- return ((Number)object).longValue();
+ public long getLongValue(final Object object) {
+ if ( this.objectType.getValueType().isNumber() ) {
+ return ((Number) object).longValue();
}
- throw new RuntimeDroolsException("Conversion to long not supported for type: "+object.getClass());
+ throw new RuntimeDroolsException( "Conversion to long not supported for type: " + object.getClass() );
}
- public short getShortValue(Object object) {
- if( this.objectType.getValueType().isNumber() ) {
- return ((Number)object).shortValue();
+ public short getShortValue(final Object object) {
+ if ( this.objectType.getValueType().isNumber() ) {
+ return ((Number) object).shortValue();
}
- throw new RuntimeDroolsException("Conversion to short not supported for type: "+object.getClass());
+ throw new RuntimeDroolsException( "Conversion to short not supported for type: " + object.getClass() );
}
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/CompiledInvoker.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/CompiledInvoker.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/CompiledInvoker.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -11,7 +11,7 @@
public interface CompiledInvoker
extends
Invoker {
-
+
/**
* Generated code should be able to return a List which represents the bytecode.
* The elements in the list will be used to compare one semantic invoker
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/Constraint.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/Constraint.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/Constraint.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -1,6 +1,5 @@
package org.drools.spi;
-import org.drools.rule.ContextEntry;
import org.drools.rule.Declaration;
/*
@@ -22,6 +21,6 @@
public interface Constraint
extends
RuleComponent {
-
+
Declaration[] getRequiredDeclarations();
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/DataProvider.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/DataProvider.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/DataProvider.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -8,7 +8,9 @@
public interface DataProvider {
public Declaration[] getRequiredDeclarations();
-
- public Iterator getResults(Tuple tuple, WorkingMemory wm, PropagationContext ctx);
+ public Iterator getResults(Tuple tuple,
+ WorkingMemory wm,
+ PropagationContext ctx);
+
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/FactHandleFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/FactHandleFactory.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/FactHandleFactory.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -53,6 +53,6 @@
* @return a fresh instance of the fact handle factory, with any IDs reset etc.
*/
public FactHandleFactory newInstance();
-
+
public Class getFactHandleType();
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/FieldValue.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/FieldValue.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/FieldValue.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -39,6 +39,5 @@
public double getDoubleValue();
public boolean getBooleanValue();
-
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/FunctionResolver.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/FunctionResolver.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/FunctionResolver.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -2,14 +2,13 @@
import java.util.List;
-
public interface FunctionResolver {
public List getFunctionImports();
public void addFunctionImport(String functionImport);
-
+
public String resolveFunction(String functionName,
- String params);
+ String params);
public String resolveFunction(String functionName,
String params,
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/ObjectType.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/ObjectType.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/ObjectType.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -54,7 +54,7 @@
* if shadow facts are disabled
*/
Object getShadow(Object fact);
-
+
/**
* Returns true in case shadow facts are enabled
* @return true if shadow facts are enabled, false otherwise
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/PropagationContext.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/PropagationContext.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/PropagationContext.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -20,7 +20,9 @@
import org.drools.rule.Rule;
-public interface PropagationContext extends Serializable {
+public interface PropagationContext
+ extends
+ Serializable {
public static final int ASSERTION = 0;
public static final int RETRACTION = 1;
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/Restriction.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/Restriction.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/Restriction.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -2,19 +2,23 @@
import java.io.Serializable;
-import org.drools.WorkingMemory;
import org.drools.common.InternalWorkingMemory;
import org.drools.reteoo.ReteTuple;
import org.drools.rule.ContextEntry;
import org.drools.rule.Declaration;
-import org.drools.rule.VariableConstraint.VariableContextEntry;
-public interface Restriction extends Serializable {
+public interface Restriction
+ extends
+ Serializable {
Declaration[] getRequiredDeclarations();
-
- public boolean isAllowed(Extractor extractor, Object object, InternalWorkingMemory workingMemoiry);
-
- public boolean isAllowedCachedLeft(ContextEntry context, Object object);
-
- public boolean isAllowedCachedRight(ReteTuple tuple, ContextEntry context);
+
+ public boolean isAllowed(Extractor extractor,
+ Object object,
+ InternalWorkingMemory workingMemoiry);
+
+ public boolean isAllowedCachedLeft(ContextEntry context,
+ Object object);
+
+ public boolean isAllowedCachedRight(ReteTuple tuple,
+ ContextEntry context);
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/AbstractHashTable.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/AbstractHashTable.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/AbstractHashTable.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -19,44 +19,44 @@
protected ObjectComparator comparator;
protected Entry[] table;
-
- private HashTableIterator iterator;
-
+
+ private HashTableIterator iterator;
+
public AbstractHashTable() {
this( 16,
0.75f );
}
- public AbstractHashTable(int capacity,
- float loadFactor) {
+ public AbstractHashTable(final int capacity,
+ final float loadFactor) {
this.loadFactor = loadFactor;
this.threshold = (int) (capacity * loadFactor);
this.table = new Entry[capacity];
this.comparator = EqualityEquals.getInstance();
}
-
+
public Iterator iterator() {
if ( this.iterator == null ) {
- this.iterator = new HashTableIterator( this );
+ this.iterator = new HashTableIterator( this );
}
-
+
this.iterator.reset();
return this.iterator;
- }
+ }
- public void setComparator(ObjectComparator comparator) {
+ public void setComparator(final ObjectComparator comparator) {
this.comparator = comparator;
}
- protected void resize(int newCapacity) {
- Entry[] oldTable = this.table;
- int oldCapacity = oldTable.length;
- if ( oldCapacity == MAX_CAPACITY ) {
+ protected void resize(final int newCapacity) {
+ final Entry[] oldTable = this.table;
+ final int oldCapacity = oldTable.length;
+ if ( oldCapacity == AbstractHashTable.MAX_CAPACITY ) {
this.threshold = Integer.MAX_VALUE;
return;
}
- Entry[] newTable = new Entry[newCapacity];
+ final Entry[] newTable = new Entry[newCapacity];
for ( int i = 0; i < this.table.length; i++ ) {
Entry entry = this.table[i];
@@ -68,7 +68,7 @@
while ( entry != null ) {
next = entry.getNext();
- int index = indexOf( entry.hashCode(),
+ final int index = indexOf( entry.hashCode(),
newTable.length );
entry.setNext( newTable[index] );
newTable[index] = entry;
@@ -143,9 +143,9 @@
// return current;
// }
- public Entry getBucket(int hashCode) {
+ public Entry getBucket(final int hashCode) {
return this.table[indexOf( hashCode,
- table.length )];
+ this.table.length )];
}
public Entry[] getTable() {
@@ -155,74 +155,76 @@
public int size() {
return this.size;
}
-
+
public boolean isEmpty() {
return this.size == 0;
}
-// protected int indexOf(int hashCode,
-// int dataSize) {
-// int index = hashCode % dataSize;
-// if ( index < 0 ) {
-// index = index * -1;
-// }
-// return index;
-// }
-
- protected int indexOf(int hashCode,
- int dataSize) {
+ // protected int indexOf(int hashCode,
+ // int dataSize) {
+ // int index = hashCode % dataSize;
+ // if ( index < 0 ) {
+ // index = index * -1;
+ // }
+ // return index;
+ // }
+
+ protected int indexOf(final int hashCode,
+ final int dataSize) {
return hashCode & (dataSize - 1);
- }
-
+ }
+
public abstract Entry getBucket(Object object);
public interface ObjectComparator {
public int hashCodeOf(Object object);
-
+
public int rehash(int hashCode);
-
+
public boolean equal(Object object1,
Object object2);
}
-
+
/**
* Fast re-usable iterator
*
*/
- public static class HashTableIterator implements Iterator {
+ public static class HashTableIterator
+ implements
+ Iterator {
private AbstractHashTable hashTable;
- private Entry[] table;
- private int row;
- private int length;
- private Entry entry;
-
- public HashTableIterator(AbstractHashTable hashTable) {
+ private Entry[] table;
+ private int row;
+ private int length;
+ private Entry entry;
+
+ public HashTableIterator(final AbstractHashTable hashTable) {
this.hashTable = hashTable;
}
-
+
/* (non-Javadoc)
* @see org.drools.util.Iterator#next()
*/
- public Entry next() {
- if ( this.entry == null ) {
+ public Entry next() {
+ if ( this.entry == null ) {
// keep skipping rows until we come to the end, or find one that is populated
- while ( this.entry == null ) {
- row++;
- if ( row == length ) {
+ while ( this.entry == null ) {
+ this.row++;
+ if ( this.row == this.length ) {
return null;
}
- this.entry = this.table[row];
- }
+ this.entry = this.table[this.row];
+ }
} else {
this.entry = this.entry.getNext();
if ( this.entry == null ) {
this.entry = next();
}
}
-
+
return this.entry;
}
-
+
/* (non-Javadoc)
* @see org.drools.util.Iterator#reset()
*/
@@ -232,7 +234,7 @@
this.row = -1;
this.entry = null;
}
- }
+ }
public static class InstanceEquals
implements
@@ -240,27 +242,27 @@
public static ObjectComparator INSTANCE = new InstanceEquals();
public static ObjectComparator getInstance() {
- return INSTANCE;
+ return InstanceEquals.INSTANCE;
}
-
- public int hashCodeOf(Object key) {
- return rehash( key.hashCode() );
+
+ public int hashCodeOf(final Object key) {
+ return rehash( key.hashCode() );
}
-
+
public int rehash(int h) {
h += ~(h << 9);
h ^= (h >>> 14);
h += (h << 4);
h ^= (h >>> 10);
- return h;
+ return h;
}
private InstanceEquals() {
}
- public boolean equal(Object object1,
- Object object2) {
+ public boolean equal(final Object object1,
+ final Object object2) {
return object1 == object2;
}
}
@@ -271,27 +273,27 @@
public static ObjectComparator INSTANCE = new EqualityEquals();
public static ObjectComparator getInstance() {
- return INSTANCE;
+ return EqualityEquals.INSTANCE;
}
-
- public int hashCodeOf(Object key) {
+
+ public int hashCodeOf(final Object key) {
return rehash( key.hashCode() );
}
-
+
public int rehash(int h) {
h += ~(h << 9);
h ^= (h >>> 14);
h += (h << 4);
h ^= (h >>> 10);
- return h;
+ return h;
}
private EqualityEquals() {
}
- public boolean equal(Object object1,
- Object object2) {
+ public boolean equal(final Object object1,
+ final Object object2) {
return object1.equals( object2 );
}
}
@@ -304,47 +306,48 @@
public int hashCode;
public Entry next;
-
-// private LinkedList list;
- public FactEntry(InternalFactHandle handle) {
+ // private LinkedList list;
+
+ public FactEntry(final InternalFactHandle handle) {
this.handle = handle;
this.hashCode = handle.hashCode();
-// this.list = new LinkedList();
+ // this.list = new LinkedList();
}
- public FactEntry(InternalFactHandle handle,
- int hashCode) {
+ public FactEntry(final InternalFactHandle handle,
+ final int hashCode) {
this.handle = handle;
this.hashCode = hashCode;
-// this.list = new LinkedList();
+ // this.list = new LinkedList();
}
public InternalFactHandle getFactHandle() {
- return handle;
+ return this.handle;
}
public Entry getNext() {
return this.next;
}
- public void setNext(Entry next) {
+ public void setNext(final Entry next) {
this.next = next;
}
-//
-// void add(final LinkedListEntry tupleMatchEntry) {
-// this.list.add( tupleMatchEntry );
-// }
-// void remove(final LinkedListEntry tupleMatchEntry) {
-// this.list.remove( tupleMatchEntry );
-// }
+ //
+ // void add(final LinkedListEntry tupleMatchEntry) {
+ // this.list.add( tupleMatchEntry );
+ // }
+ // void remove(final LinkedListEntry tupleMatchEntry) {
+ // this.list.remove( tupleMatchEntry );
+ // }
+
public int hashCode() {
return this.hashCode;
}
- public boolean equals(Object object) {
- return ( object == this) || (this.handle == ((FactEntry)object).handle);
+ public boolean equals(final Object object) {
+ return (object == this) || (this.handle == ((FactEntry) object).handle);
}
}
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/BinaryHeapQueue.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/BinaryHeapQueue.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/BinaryHeapQueue.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -57,7 +57,7 @@
* @throws IllegalArgumentException if <code>capacity</code> is <= <code>0</code>
*/
public BinaryHeapQueue(final Comparator comparator,
- final int capacity) {
+ final int capacity) {
if ( capacity <= 0 ) {
throw new IllegalArgumentException( "invalid capacity" );
}
Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/CompositeFieldIndexHashTable.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/CompositeFieldIndexHashTable.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/CompositeFieldIndexHashTable.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -1,638 +0,0 @@
-/**
- *
- */
-package org.drools.util;
-
-import org.drools.common.InternalFactHandle;
-import org.drools.reteoo.ObjectHashTable;
-import org.drools.reteoo.ReteTuple;
-import org.drools.rule.Declaration;
-import org.drools.spi.FieldExtractor;
-import org.drools.util.ObjectHashMap.ObjectEntry;
-
-public class CompositeFieldIndexHashTable extends AbstractHashTable
- implements
- ObjectHashTable {
- public static final int PRIME = 31;
-
- private int startResult;
-
- private FieldIndexHashTableIterator tupleValueIterator;
-
- private int factSize;
-
- private Index index;
-
- public CompositeFieldIndexHashTable(FieldIndex[] index) {
- this( 16,
- 0.75f,
- index );
- }
-
- public CompositeFieldIndexHashTable(int capacity,
- float loadFactor,
- FieldIndex[] index) {
- super( capacity,
- loadFactor );
-
- this.startResult = PRIME;
- for ( int i = 0, length = index.length; i < length; i++ ) {
- this.startResult += PRIME * this.startResult + index[i].getExtractor().getIndex();
- }
-
- switch ( index.length ) {
- case 0 :
- throw new IllegalAccessError( "FieldIndexHashTable cannot use an index[] of length 0" );
- case 1 :
- this.index = new SingleIndex( index,
- this.startResult,
- this.comparator );
- break;
- case 2 :
- this.index = new DoubleCompositeIndex( index,
- this.startResult,
- this.comparator );
- break;
- case 3 :
- this.index = new TripleCompositeIndex( index,
- this.startResult,
- this.comparator );
- break;
- default :
- throw new IllegalAccessError( "FieldIndexHashTable cannot use an index[] of length great than 3" );
- }
- }
-
- public Iterator iterator() {
- throw new UnsupportedOperationException( "FieldIndexHashTable does not support iterator()" );
- }
-
- public Iterator iterator(ReteTuple tuple) {
- if ( this.tupleValueIterator == null ) {
- this.tupleValueIterator = new FieldIndexHashTableIterator();
- }
- FieldIndexEntry entry = (FieldIndexEntry) get( tuple );
- this.tupleValueIterator.reset( (entry != null) ? entry.first : null );
- return this.tupleValueIterator;
- }
-
- public boolean isIndexed() {
- return true;
- }
-
- public Entry getBucket(Object object) {
- int hashCode = this.index.hashCodeOf( object );
- int index = indexOf( hashCode,
- table.length );
-
- return (ObjectEntry) this.table[index];
- }
-
- /**
- * Fast re-usable iterator
- *
- */
- public static class FieldIndexHashTableIterator
- implements
- Iterator {
- private Entry entry;
-
- public FieldIndexHashTableIterator() {
-
- }
-
- /* (non-Javadoc)
- * @see org.drools.util.Iterator#next()
- */
- public Entry next() {
- Entry current = this.entry;
- this.entry = (this.entry != null) ? this.entry.getNext() : null;
- return current;
- }
-
- /* (non-Javadoc)
- * @see org.drools.util.Iterator#reset()
- */
- public void reset(Entry entry) {
- this.entry = entry;
- }
- }
-
- public boolean add(InternalFactHandle handle) {
- FieldIndexEntry entry = getOrCreate( handle.getObject() );
- entry.add( handle );
- this.factSize++;
- return true;
- }
-
- public boolean add(InternalFactHandle handle,
- boolean checkExists) {
- throw new UnsupportedOperationException( "FieldIndexHashTable does not support add(InternalFactHandle handle, boolean checkExists)" );
- }
-
- public boolean remove(InternalFactHandle handle) {
- Object object = handle.getObject();
- //this.index.setCachedValue( object );
- int hashCode = this.index.hashCodeOf( object );
-
- int index = indexOf( hashCode,
- table.length );
-
- // search the table for the Entry, we need to track previous and next, so if the
- // Entry is empty after its had the FactEntry removed, we must remove it from the table
- FieldIndexEntry previous = (FieldIndexEntry) this.table[index];
- FieldIndexEntry current = previous;
- while ( current != null ) {
- FieldIndexEntry next = (FieldIndexEntry) current.next;
- if ( current.matches( object,
- hashCode ) ) {
- current.remove( handle );
- this.factSize--;
- // If the FactEntryIndex is empty, then remove it from the hash table
- if ( current.first == null ) {
- if ( previous == current ) {
- this.table[index] = next;
- } else {
- previous.next = next;
- }
- current.next = null;
- this.size--;
- }
- return true;
- }
- previous = current;
- current = next;
- }
- return false;
- }
-
- public boolean contains(InternalFactHandle handle) {
- Object object = handle.getObject();
- //this.index.setCachedValue( object );
-
- int hashCode = this.index.hashCodeOf( object );
-
- int index = indexOf( hashCode,
- table.length );
-
- FieldIndexEntry current = (FieldIndexEntry) this.table[index];
- while ( current != null ) {
- if ( current.matches( object,
- hashCode ) ) {
- return true;
- }
- current = (FieldIndexEntry) current.next;
- }
- return false;
- }
-
- public FieldIndexEntry get(ReteTuple tuple) {
- //this.index.setCachedValue( tuple );
-
- int hashCode = this.index.hashCodeOf( tuple );
-
- int index = indexOf( hashCode,
- table.length );
- FieldIndexEntry entry = (FieldIndexEntry) this.table[index];
-
- while ( entry != null ) {
- if ( entry.matches( tuple,
- hashCode ) ) {
- return entry;
- }
- entry = (FieldIndexEntry) entry.getNext();
- }
-
- return entry;
- }
-
- /**
- * We use this method to aviod to table lookups for the same hashcode; which is what we would have to do if we did
- * a get and then a create if the value is null.
- *
- * @param value
- * @return
- */
- private FieldIndexEntry getOrCreate(Object object) {
- //this.index.setCachedValue( object );
-
- int hashCode = this.index.hashCodeOf( object );
-
- int index = indexOf( hashCode,
- table.length );
- FieldIndexEntry entry = (FieldIndexEntry) this.table[index];
-
- while ( entry != null ) {
- if ( entry.matches( object,
- hashCode ) ) {
- return entry;
- }
- entry = (FieldIndexEntry) entry.next;
- }
-
- if ( entry == null ) {
- entry = new FieldIndexEntry( this.index,
- hashCode );
- entry.next = this.table[index];
- this.table[index] = entry;
-
- if ( this.size++ >= this.threshold ) {
- resize( 2 * this.table.length );
- }
- }
- return entry;
- }
-
- public int size() {
- return this.factSize;
- }
-
- public static class FieldIndexEntry
- implements
- Entry {
- private Entry next;
- private FactEntry first;
- private final int hashCode;
- private Index index;
-
- public FieldIndexEntry(Index index,
- int hashCode) {
- this.index = index;
- this.hashCode = hashCode;
- }
-
- public Entry getNext() {
- return next;
- }
-
- public void setNext(Entry next) {
- this.next = next;
- }
-
- public FactEntry getFirst() {
- return this.first;
- }
-
- public void add(InternalFactHandle handle) {
- FactEntry entry = new FactEntry( handle );
- entry.next = this.first;
- this.first = entry;
- }
-
- public FactEntry get(InternalFactHandle handle) {
- long id = handle.getId();
- FactEntry current = first;
- while ( current != null ) {
- if ( current.handle.getId() == id ) {
- return current;
- }
- current = (FactEntry) current.next;
- }
- return null;
- }
-
- public FactEntry remove(InternalFactHandle handle) {
- long id = handle.getId();
-
- FactEntry previous = this.first;
- FactEntry current = previous;
- while ( current != null ) {
- FactEntry next = (FactEntry) current.next;
- if ( current.handle.getId() == id ) {
- if ( this.first == current ) {
- this.first = next;
- } else {
- previous.next = next;
- }
- current.next = null;
- return current;
- }
- previous = current;
- current = next;
- }
- return current;
- }
-
- // public boolean matches(int otherHashCode) {
- // return this.hashCode == otherHashCode && this.index.equal( this.first.getFactHandle().getObject() );
- // }
-
- public boolean matches(Object object,
- int objectHashCode) {
- return this.hashCode == objectHashCode && this.index.equal( this.first.getFactHandle().getObject(),
- object );
- }
-
- public boolean matches(ReteTuple tuple,
- int tupleHashCode) {
- return this.hashCode == tupleHashCode && this.index.equal( this.first.getFactHandle().getObject(),
- tuple );
- }
-
- public int hashCode() {
- return this.hashCode;
- }
-
- public boolean equals(Object object) {
- FieldIndexEntry other = (FieldIndexEntry) object;
- return this.hashCode == other.hashCode && this.index == other.index;
- }
- }
-
- private static interface Index {
- public int hashCodeOf(ReteTuple tuple);
-
- public int hashCodeOf(Object object);
-
- public boolean equal(Object object1,
- Object object2);
-
- public boolean equal(Object object1,
- ReteTuple tuple);
- }
-
- private static class SingleIndex
- implements
- Index {
- private FieldExtractor extractor;
- private Declaration declaration;
-
- private int startResult;
-
- private ObjectComparator comparator;
-
- private Object cachedValue;
-
- public SingleIndex(FieldIndex[] indexes,
- int startResult,
- ObjectComparator comparator) {
- this.startResult = startResult;
-
- this.extractor = indexes[0].extractor;
- this.declaration = indexes[0].declaration;
-
- this.comparator = comparator;
- }
-
- public int hashCodeOf(Object object) {
- int hashCode = startResult;
- Object value = extractor.getValue( object );
- hashCode += CompositeFieldIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
- return this.comparator.rehash( hashCode );
- }
-
- public int hashCodeOf(ReteTuple tuple) {
- int hashCode = startResult;
- Object value = declaration.getValue( tuple.get( declaration ).getObject() );
- hashCode += CompositeFieldIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
- return this.comparator.rehash( hashCode );
- }
-
- public boolean equal(Object object1,
- ReteTuple tuple) {
- Object value1 = this.extractor.getValue( object1 );
- Object value2 = this.declaration.getValue( tuple.get( this.declaration ).getObject() );
-
- return this.comparator.equal( value1,
- value2 );
- }
-
- public boolean equal(Object object1,
- Object object2) {
-
- Object value1 = this.extractor.getValue( object1 );
- Object value2 = this.extractor.getValue( object2 );
-
- return this.comparator.equal( value1,
- value2 );
- }
- }
-
- private static class DoubleCompositeIndex
- implements
- Index {
- private FieldIndex index0;
- private FieldIndex index1;
-
- private int startResult;
-
- private ObjectComparator comparator;
-
- public DoubleCompositeIndex(FieldIndex[] indexes,
- int startResult,
- ObjectComparator comparator) {
- this.startResult = startResult;
-
- this.index0 = indexes[0];
- this.index1 = indexes[1];
-
- this.comparator = comparator;
- }
-
- public int hashCodeOf(Object object) {
- int hashCode = startResult;
-
- Object value = index0.extractor.getValue( object );
- hashCode += CompositeFieldIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
-
- value = index1.extractor.getValue( object );
- hashCode += CompositeFieldIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
-
- return this.comparator.rehash( hashCode );
- }
-
- public int hashCodeOf(ReteTuple tuple) {
- int hashCode = startResult;
-
- Object value = index0.declaration.getValue( tuple.get( index0.declaration ).getObject() );
- hashCode += CompositeFieldIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode() );
-
- value = index1.declaration.getValue( tuple.get( index1.declaration ).getObject() );
- hashCode += CompositeFieldIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode() );
-
- return this.comparator.rehash( hashCode );
- }
-
- public boolean equal(Object object1,
- ReteTuple tuple) {
- Object value1 = index0.extractor.getValue( object1 );
- Object value2 = index0.declaration.getValue( tuple.get( index0.declaration ).getObject() );
-
- if ( !this.comparator.equal( value1,
- value2 ) ) {
- return false;
- }
-
- value1 = index1.extractor.getValue( object1 );
- value2 = index1.declaration.getValue( tuple.get( index1.declaration ).getObject() );
-
- if ( !this.comparator.equal( value1,
- value2 ) ) {
- return false;
- }
-
- return true;
- }
-
- public boolean equal(Object object1,
- Object object2) {
- Object value1 = index0.extractor.getValue( object1 );
- Object value2 = index0.extractor.getValue( object2 );
-
- if ( !this.comparator.equal( value1,
- value2 ) ) {
- return false;
- }
-
- value1 = index1.extractor.getValue( object1 );
- value2 = index1.extractor.getValue( object2 );
-
- if ( !this.comparator.equal( value1,
- value2 ) ) {
- return false;
- }
-
- return true;
- }
- }
-
- private static class TripleCompositeIndex
- implements
- Index {
- private FieldIndex index0;
- private FieldIndex index1;
- private FieldIndex index2;
-
- private int startResult;
-
- private ObjectComparator comparator;
-
- public TripleCompositeIndex(FieldIndex[] indexes,
- int startResult,
- ObjectComparator comparator) {
- this.startResult = startResult;
-
- this.index0 = indexes[0];
- this.index1 = indexes[1];
- this.index2 = indexes[2];
-
- this.comparator = comparator;
- }
-
- public int hashCodeOf(Object object) {
- int hashCode = startResult;
-
- Object value = index0.extractor.getValue( object );
- hashCode += CompositeFieldIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
-
- value = index1.extractor.getValue( object );
- hashCode += CompositeFieldIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
-
- value = index2.extractor.getValue( object );
- hashCode += CompositeFieldIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
-
- return this.comparator.rehash( hashCode );
- }
-
- public int hashCodeOf(ReteTuple tuple) {
- int hashCode = startResult;
-
- Object value = index0.declaration.getValue( tuple.get( index0.declaration ).getObject() );
- hashCode += CompositeFieldIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
-
- value = index1.declaration.getValue( tuple.get( index1.declaration ).getObject() );
- hashCode += CompositeFieldIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
-
- value = index2.declaration.getValue( tuple.get( index2.declaration ).getObject() );
- hashCode += CompositeFieldIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
-
- return this.comparator.rehash( hashCode );
- }
-
- public boolean equal(Object object1,
- ReteTuple tuple) {
- Object value1 = index0.extractor.getValue( object1 );
- Object value2 = index0.declaration.getValue( tuple.get( index0.declaration ).getObject() );
-
- if ( !this.comparator.equal( value1,
- value2 ) ) {
- return false;
- }
-
- value1 = index1.extractor.getValue( object1 );
- value2 = index1.declaration.getValue( tuple.get( index1.declaration ).getObject() );
-
- if ( !this.comparator.equal( value1,
- value2 ) ) {
- return false;
- }
-
- value1 = index2.extractor.getValue( object1 );
- value2 = index2.declaration.getValue( tuple.get( index2.declaration ).getObject() );
-
- if ( !this.comparator.equal( value1,
- value2 ) ) {
- return false;
- }
-
- return true;
- }
-
- public boolean equal(Object object1,
- Object object2) {
- Object value1 = index0.extractor.getValue( object1 );
- Object value2 = index0.extractor.getValue( object2 );
-
- if ( !this.comparator.equal( value1,
- value2 ) ) {
- return false;
- }
-
- value1 = index1.extractor.getValue( object1 );
- value2 = index1.extractor.getValue( object2 );
-
- if ( !this.comparator.equal( value1,
- value2 ) ) {
- return false;
- }
-
- value1 = index2.extractor.getValue( object1 );
- value2 = index2.extractor.getValue( object2 );
-
- if ( !this.comparator.equal( value1,
- value2 ) ) {
- return false;
- }
-
- return true;
- }
- }
-
- public static class FieldIndex {
- private FieldExtractor extractor;
- private Declaration declaration;
-
- public FieldIndex(FieldExtractor extractor,
- Declaration declaration) {
- super();
- this.extractor = extractor;
- this.declaration = declaration;
- }
-
- public Declaration getDeclaration() {
- return declaration;
- }
-
- public void setDeclaration(Declaration declaration) {
- this.declaration = declaration;
- }
-
- public FieldExtractor getExtractor() {
- return extractor;
- }
-
- public void setExtractor(FieldExtractor extractor) {
- this.extractor = extractor;
- }
- }
-}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/FactHashTable.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/FactHashTable.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/FactHashTable.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -18,30 +18,30 @@
0.75f );
}
- public FactHashTable(int capacity,
- float loadFactor) {
+ public FactHashTable(final int capacity,
+ final float loadFactor) {
super( capacity,
loadFactor );
}
- public Iterator iterator(int hashCode) {
+ public Iterator iterator(final int hashCode) {
throw new UnsupportedOperationException( "FactHashTable does not support the method iterator(int hashCode" );
}
- public Iterator iterator(ReteTuple tuple) {
+ public Iterator iterator(final ReteTuple tuple) {
return iterator();
}
- public boolean add(InternalFactHandle handle) {
+ public boolean add(final InternalFactHandle handle) {
return add( handle,
true );
}
- public boolean add(InternalFactHandle handle,
- boolean checkExists) {
- int hashCode = this.comparator.hashCodeOf( handle );
- int index = indexOf( hashCode,
- table.length );
+ public boolean add(final InternalFactHandle handle,
+ final boolean checkExists) {
+ final int hashCode = this.comparator.hashCodeOf( handle );
+ final int index = indexOf( hashCode,
+ this.table.length );
// scan the linked entries to see if it exists
if ( checkExists ) {
@@ -55,7 +55,7 @@
}
// We aren't checking the key exists, or it didn't find the key
- FactEntry entry = new FactEntry( handle,
+ final FactEntry entry = new FactEntry( handle,
hashCode );
entry.next = this.table[index];
this.table[index] = entry;
@@ -66,10 +66,10 @@
return true;
}
- public boolean contains(InternalFactHandle handle) {
- int hashCode = this.comparator.hashCodeOf( handle );
- int index = indexOf( hashCode,
- table.length );
+ public boolean contains(final InternalFactHandle handle) {
+ final int hashCode = this.comparator.hashCodeOf( handle );
+ final int index = indexOf( hashCode,
+ this.table.length );
FactEntry current = (FactEntry) this.table[index];
while ( current != null ) {
@@ -81,15 +81,15 @@
return false;
}
- public boolean remove(InternalFactHandle handle) {
- int hashCode = this.comparator.hashCodeOf( handle );
- int index = indexOf( hashCode,
- table.length );
+ public boolean remove(final InternalFactHandle handle) {
+ final int hashCode = this.comparator.hashCodeOf( handle );
+ final int index = indexOf( hashCode,
+ this.table.length );
FactEntry previous = (FactEntry) this.table[index];
FactEntry current = previous;
while ( current != null ) {
- FactEntry next = (FactEntry) current.getNext();
+ final FactEntry next = (FactEntry) current.getNext();
if ( hashCode == current.hashCode && handle.getId() == current.handle.getId() ) {
if ( previous == current ) {
this.table[index] = next;
@@ -106,20 +106,20 @@
return false;
}
- public Entry getBucket(Object object) {
- int hashCode = this.comparator.hashCodeOf( object );
- int index = indexOf( hashCode,
- table.length );
+ public Entry getBucket(final Object object) {
+ final int hashCode = this.comparator.hashCodeOf( object );
+ final int index = indexOf( hashCode,
+ this.table.length );
- return (ObjectEntry) this.table[index];
+ return this.table[index];
}
- public int hash(Object key) {
+ public int hash(final Object key) {
return key.hashCode();
}
- protected int indexOf(int hashCode,
- int dataSize) {
+ protected int indexOf(final int hashCode,
+ final int dataSize) {
return hashCode & (dataSize - 1);
}
Copied: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/FieldIndexHashTable.java (from rev 6906, labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/CompositeFieldIndexHashTable.java)
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/CompositeFieldIndexHashTable.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/FieldIndexHashTable.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -0,0 +1,636 @@
+/**
+ *
+ */
+package org.drools.util;
+
+import org.drools.common.InternalFactHandle;
+import org.drools.reteoo.ObjectHashTable;
+import org.drools.reteoo.ReteTuple;
+import org.drools.rule.Declaration;
+import org.drools.spi.FieldExtractor;
+import org.drools.util.ObjectHashMap.ObjectEntry;
+
+public class FieldIndexHashTable extends AbstractHashTable
+ implements
+ ObjectHashTable {
+ public static final int PRIME = 31;
+
+ private int startResult;
+
+ private FieldIndexHashTableIterator tupleValueIterator;
+
+ private int factSize;
+
+ private Index index;
+
+ public FieldIndexHashTable(final FieldIndex[] index) {
+ this( 16,
+ 0.75f,
+ index );
+ }
+
+ public FieldIndexHashTable(final int capacity,
+ final float loadFactor,
+ final FieldIndex[] index) {
+ super( capacity,
+ loadFactor );
+
+ this.startResult = FieldIndexHashTable.PRIME;
+ for ( int i = 0, length = index.length; i < length; i++ ) {
+ this.startResult += FieldIndexHashTable.PRIME * this.startResult + index[i].getExtractor().getIndex();
+ }
+
+ switch ( index.length ) {
+ case 0 :
+ throw new IllegalAccessError( "FieldIndexHashTable cannot use an index[] of length 0" );
+ case 1 :
+ this.index = new SingleIndex( index,
+ this.startResult,
+ this.comparator );
+ break;
+ case 2 :
+ this.index = new DoubleCompositeIndex( index,
+ this.startResult,
+ this.comparator );
+ break;
+ case 3 :
+ this.index = new TripleCompositeIndex( index,
+ this.startResult,
+ this.comparator );
+ break;
+ default :
+ throw new IllegalAccessError( "FieldIndexHashTable cannot use an index[] of length great than 3" );
+ }
+ }
+
+ public Iterator iterator() {
+ throw new UnsupportedOperationException( "FieldIndexHashTable does not support iterator()" );
+ }
+
+ public Iterator iterator(final ReteTuple tuple) {
+ if ( this.tupleValueIterator == null ) {
+ this.tupleValueIterator = new FieldIndexHashTableIterator();
+ }
+ final FieldIndexEntry entry = get( tuple );
+ this.tupleValueIterator.reset( (entry != null) ? entry.first : null );
+ return this.tupleValueIterator;
+ }
+
+ public boolean isIndexed() {
+ return true;
+ }
+
+ public Entry getBucket(final Object object) {
+ final int hashCode = this.index.hashCodeOf( object );
+ final int index = indexOf( hashCode,
+ this.table.length );
+
+ return this.table[index];
+ }
+
+ /**
+ * Fast re-usable iterator
+ *
+ */
+ public static class FieldIndexHashTableIterator
+ implements
+ Iterator {
+ private Entry entry;
+
+ public FieldIndexHashTableIterator() {
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.drools.util.Iterator#next()
+ */
+ public Entry next() {
+ final Entry current = this.entry;
+ this.entry = (this.entry != null) ? this.entry.getNext() : null;
+ return current;
+ }
+
+ /* (non-Javadoc)
+ * @see org.drools.util.Iterator#reset()
+ */
+ public void reset(final Entry entry) {
+ this.entry = entry;
+ }
+ }
+
+ public boolean add(final InternalFactHandle handle) {
+ final FieldIndexEntry entry = getOrCreate( handle.getObject() );
+ entry.add( handle );
+ this.factSize++;
+ return true;
+ }
+
+ public boolean add(final InternalFactHandle handle,
+ final boolean checkExists) {
+ throw new UnsupportedOperationException( "FieldIndexHashTable does not support add(InternalFactHandle handle, boolean checkExists)" );
+ }
+
+ public boolean remove(final InternalFactHandle handle) {
+ final Object object = handle.getObject();
+ //this.index.setCachedValue( object );
+ final int hashCode = this.index.hashCodeOf( object );
+
+ final int index = indexOf( hashCode,
+ this.table.length );
+
+ // search the table for the Entry, we need to track previous and next, so if the
+ // Entry is empty after its had the FactEntry removed, we must remove it from the table
+ FieldIndexEntry previous = (FieldIndexEntry) this.table[index];
+ FieldIndexEntry current = previous;
+ while ( current != null ) {
+ final FieldIndexEntry next = (FieldIndexEntry) current.next;
+ if ( current.matches( object,
+ hashCode ) ) {
+ current.remove( handle );
+ this.factSize--;
+ // If the FactEntryIndex is empty, then remove it from the hash table
+ if ( current.first == null ) {
+ if ( previous == current ) {
+ this.table[index] = next;
+ } else {
+ previous.next = next;
+ }
+ current.next = null;
+ this.size--;
+ }
+ return true;
+ }
+ previous = current;
+ current = next;
+ }
+ return false;
+ }
+
+ public boolean contains(final InternalFactHandle handle) {
+ final Object object = handle.getObject();
+ //this.index.setCachedValue( object );
+
+ final int hashCode = this.index.hashCodeOf( object );
+
+ final int index = indexOf( hashCode,
+ this.table.length );
+
+ FieldIndexEntry current = (FieldIndexEntry) this.table[index];
+ while ( current != null ) {
+ if ( current.matches( object,
+ hashCode ) ) {
+ return true;
+ }
+ current = (FieldIndexEntry) current.next;
+ }
+ return false;
+ }
+
+ public FieldIndexEntry get(final ReteTuple tuple) {
+ //this.index.setCachedValue( tuple );
+
+ final int hashCode = this.index.hashCodeOf( tuple );
+
+ final int index = indexOf( hashCode,
+ this.table.length );
+ FieldIndexEntry entry = (FieldIndexEntry) this.table[index];
+
+ while ( entry != null ) {
+ if ( entry.matches( tuple,
+ hashCode ) ) {
+ return entry;
+ }
+ entry = (FieldIndexEntry) entry.getNext();
+ }
+
+ return entry;
+ }
+
+ /**
+ * We use this method to aviod to table lookups for the same hashcode; which is what we would have to do if we did
+ * a get and then a create if the value is null.
+ *
+ * @param value
+ * @return
+ */
+ private FieldIndexEntry getOrCreate(final Object object) {
+ //this.index.setCachedValue( object );
+
+ final int hashCode = this.index.hashCodeOf( object );
+
+ final int index = indexOf( hashCode,
+ this.table.length );
+ FieldIndexEntry entry = (FieldIndexEntry) this.table[index];
+
+ while ( entry != null ) {
+ if ( entry.matches( object,
+ hashCode ) ) {
+ return entry;
+ }
+ entry = (FieldIndexEntry) entry.next;
+ }
+
+ if ( entry == null ) {
+ entry = new FieldIndexEntry( this.index,
+ hashCode );
+ entry.next = this.table[index];
+ this.table[index] = entry;
+
+ if ( this.size++ >= this.threshold ) {
+ resize( 2 * this.table.length );
+ }
+ }
+ return entry;
+ }
+
+ public int size() {
+ return this.factSize;
+ }
+
+ public static class FieldIndexEntry
+ implements
+ Entry {
+ private Entry next;
+ private FactEntry first;
+ private final int hashCode;
+ private Index index;
+
+ public FieldIndexEntry(final Index index,
+ final int hashCode) {
+ this.index = index;
+ this.hashCode = hashCode;
+ }
+
+ public Entry getNext() {
+ return this.next;
+ }
+
+ public void setNext(final Entry next) {
+ this.next = next;
+ }
+
+ public FactEntry getFirst() {
+ return this.first;
+ }
+
+ public void add(final InternalFactHandle handle) {
+ final FactEntry entry = new FactEntry( handle );
+ entry.next = this.first;
+ this.first = entry;
+ }
+
+ public FactEntry get(final InternalFactHandle handle) {
+ final long id = handle.getId();
+ FactEntry current = this.first;
+ while ( current != null ) {
+ if ( current.handle.getId() == id ) {
+ return current;
+ }
+ current = (FactEntry) current.next;
+ }
+ return null;
+ }
+
+ public FactEntry remove(final InternalFactHandle handle) {
+ final long id = handle.getId();
+
+ FactEntry previous = this.first;
+ FactEntry current = previous;
+ while ( current != null ) {
+ final FactEntry next = (FactEntry) current.next;
+ if ( current.handle.getId() == id ) {
+ if ( this.first == current ) {
+ this.first = next;
+ } else {
+ previous.next = next;
+ }
+ current.next = null;
+ return current;
+ }
+ previous = current;
+ current = next;
+ }
+ return current;
+ }
+
+ // public boolean matches(int otherHashCode) {
+ // return this.hashCode == otherHashCode && this.index.equal( this.first.getFactHandle().getObject() );
+ // }
+
+ public boolean matches(final Object object,
+ final int objectHashCode) {
+ return this.hashCode == objectHashCode && this.index.equal( this.first.getFactHandle().getObject(),
+ object );
+ }
+
+ public boolean matches(final ReteTuple tuple,
+ final int tupleHashCode) {
+ return this.hashCode == tupleHashCode && this.index.equal( this.first.getFactHandle().getObject(),
+ tuple );
+ }
+
+ public int hashCode() {
+ return this.hashCode;
+ }
+
+ public boolean equals(final Object object) {
+ final FieldIndexEntry other = (FieldIndexEntry) object;
+ return this.hashCode == other.hashCode && this.index == other.index;
+ }
+ }
+
+ private static interface Index {
+ public int hashCodeOf(ReteTuple tuple);
+
+ public int hashCodeOf(Object object);
+
+ public boolean equal(Object object1,
+ Object object2);
+
+ public boolean equal(Object object1,
+ ReteTuple tuple);
+ }
+
+ private static class SingleIndex
+ implements
+ Index {
+ private FieldExtractor extractor;
+ private Declaration declaration;
+
+ private int startResult;
+
+ private ObjectComparator comparator;
+
+ public SingleIndex(final FieldIndex[] indexes,
+ final int startResult,
+ final ObjectComparator comparator) {
+ this.startResult = startResult;
+
+ this.extractor = indexes[0].extractor;
+ this.declaration = indexes[0].declaration;
+
+ this.comparator = comparator;
+ }
+
+ public int hashCodeOf(final Object object) {
+ int hashCode = this.startResult;
+ final Object value = this.extractor.getValue( object );
+ hashCode += FieldIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
+ return this.comparator.rehash( hashCode );
+ }
+
+ public int hashCodeOf(final ReteTuple tuple) {
+ int hashCode = this.startResult;
+ final Object value = this.declaration.getValue( tuple.get( this.declaration ).getObject() );
+ hashCode += FieldIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
+ return this.comparator.rehash( hashCode );
+ }
+
+ public boolean equal(final Object object1,
+ final ReteTuple tuple) {
+ final Object value1 = this.extractor.getValue( object1 );
+ final Object value2 = this.declaration.getValue( tuple.get( this.declaration ).getObject() );
+
+ return this.comparator.equal( value1,
+ value2 );
+ }
+
+ public boolean equal(final Object object1,
+ final Object object2) {
+
+ final Object value1 = this.extractor.getValue( object1 );
+ final Object value2 = this.extractor.getValue( object2 );
+
+ return this.comparator.equal( value1,
+ value2 );
+ }
+ }
+
+ private static class DoubleCompositeIndex
+ implements
+ Index {
+ private FieldIndex index0;
+ private FieldIndex index1;
+
+ private int startResult;
+
+ private ObjectComparator comparator;
+
+ public DoubleCompositeIndex(final FieldIndex[] indexes,
+ final int startResult,
+ final ObjectComparator comparator) {
+ this.startResult = startResult;
+
+ this.index0 = indexes[0];
+ this.index1 = indexes[1];
+
+ this.comparator = comparator;
+ }
+
+ public int hashCodeOf(final Object object) {
+ int hashCode = this.startResult;
+
+ Object value = this.index0.extractor.getValue( object );
+ hashCode += FieldIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
+
+ value = this.index1.extractor.getValue( object );
+ hashCode += FieldIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
+
+ return this.comparator.rehash( hashCode );
+ }
+
+ public int hashCodeOf(final ReteTuple tuple) {
+ int hashCode = this.startResult;
+
+ Object value = this.index0.declaration.getValue( tuple.get( this.index0.declaration ).getObject() );
+ hashCode += FieldIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
+
+ value = this.index1.declaration.getValue( tuple.get( this.index1.declaration ).getObject() );
+ hashCode += FieldIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
+
+ return this.comparator.rehash( hashCode );
+ }
+
+ public boolean equal(final Object object1,
+ final ReteTuple tuple) {
+ Object value1 = this.index0.extractor.getValue( object1 );
+ Object value2 = this.index0.declaration.getValue( tuple.get( this.index0.declaration ).getObject() );
+
+ if ( !this.comparator.equal( value1,
+ value2 ) ) {
+ return false;
+ }
+
+ value1 = this.index1.extractor.getValue( object1 );
+ value2 = this.index1.declaration.getValue( tuple.get( this.index1.declaration ).getObject() );
+
+ if ( !this.comparator.equal( value1,
+ value2 ) ) {
+ return false;
+ }
+
+ return true;
+ }
+
+ public boolean equal(final Object object1,
+ final Object object2) {
+ Object value1 = this.index0.extractor.getValue( object1 );
+ Object value2 = this.index0.extractor.getValue( object2 );
+
+ if ( !this.comparator.equal( value1,
+ value2 ) ) {
+ return false;
+ }
+
+ value1 = this.index1.extractor.getValue( object1 );
+ value2 = this.index1.extractor.getValue( object2 );
+
+ if ( !this.comparator.equal( value1,
+ value2 ) ) {
+ return false;
+ }
+
+ return true;
+ }
+ }
+
+ private static class TripleCompositeIndex
+ implements
+ Index {
+ private FieldIndex index0;
+ private FieldIndex index1;
+ private FieldIndex index2;
+
+ private int startResult;
+
+ private ObjectComparator comparator;
+
+ public TripleCompositeIndex(final FieldIndex[] indexes,
+ final int startResult,
+ final ObjectComparator comparator) {
+ this.startResult = startResult;
+
+ this.index0 = indexes[0];
+ this.index1 = indexes[1];
+ this.index2 = indexes[2];
+
+ this.comparator = comparator;
+ }
+
+ public int hashCodeOf(final Object object) {
+ int hashCode = this.startResult;
+
+ Object value = this.index0.extractor.getValue( object );
+ hashCode += FieldIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
+
+ value = this.index1.extractor.getValue( object );
+ hashCode += FieldIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
+
+ value = this.index2.extractor.getValue( object );
+ hashCode += FieldIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
+
+ return this.comparator.rehash( hashCode );
+ }
+
+ public int hashCodeOf(final ReteTuple tuple) {
+ int hashCode = this.startResult;
+
+ Object value = this.index0.declaration.getValue( tuple.get( this.index0.declaration ).getObject() );
+ hashCode += FieldIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
+
+ value = this.index1.declaration.getValue( tuple.get( this.index1.declaration ).getObject() );
+ hashCode += FieldIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
+
+ value = this.index2.declaration.getValue( tuple.get( this.index2.declaration ).getObject() );
+ hashCode += FieldIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
+
+ return this.comparator.rehash( hashCode );
+ }
+
+ public boolean equal(final Object object1,
+ final ReteTuple tuple) {
+ Object value1 = this.index0.extractor.getValue( object1 );
+ Object value2 = this.index0.declaration.getValue( tuple.get( this.index0.declaration ).getObject() );
+
+ if ( !this.comparator.equal( value1,
+ value2 ) ) {
+ return false;
+ }
+
+ value1 = this.index1.extractor.getValue( object1 );
+ value2 = this.index1.declaration.getValue( tuple.get( this.index1.declaration ).getObject() );
+
+ if ( !this.comparator.equal( value1,
+ value2 ) ) {
+ return false;
+ }
+
+ value1 = this.index2.extractor.getValue( object1 );
+ value2 = this.index2.declaration.getValue( tuple.get( this.index2.declaration ).getObject() );
+
+ if ( !this.comparator.equal( value1,
+ value2 ) ) {
+ return false;
+ }
+
+ return true;
+ }
+
+ public boolean equal(final Object object1,
+ final Object object2) {
+ Object value1 = this.index0.extractor.getValue( object1 );
+ Object value2 = this.index0.extractor.getValue( object2 );
+
+ if ( !this.comparator.equal( value1,
+ value2 ) ) {
+ return false;
+ }
+
+ value1 = this.index1.extractor.getValue( object1 );
+ value2 = this.index1.extractor.getValue( object2 );
+
+ if ( !this.comparator.equal( value1,
+ value2 ) ) {
+ return false;
+ }
+
+ value1 = this.index2.extractor.getValue( object1 );
+ value2 = this.index2.extractor.getValue( object2 );
+
+ if ( !this.comparator.equal( value1,
+ value2 ) ) {
+ return false;
+ }
+
+ return true;
+ }
+ }
+
+ public static class FieldIndex {
+ private FieldExtractor extractor;
+ private Declaration declaration;
+
+ public FieldIndex(final FieldExtractor extractor,
+ final Declaration declaration) {
+ super();
+ this.extractor = extractor;
+ this.declaration = declaration;
+ }
+
+ public Declaration getDeclaration() {
+ return this.declaration;
+ }
+
+ public void setDeclaration(final Declaration declaration) {
+ this.declaration = declaration;
+ }
+
+ public FieldExtractor getExtractor() {
+ return this.extractor;
+ }
+
+ public void setExtractor(final FieldExtractor extractor) {
+ this.extractor = extractor;
+ }
+ }
+}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/LinkedList.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/LinkedList.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/LinkedList.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -4,8 +4,6 @@
import java.util.Iterator;
import java.util.NoSuchElementException;
-import org.drools.reteoo.CompositeObjectSinkAdapter.FieldIndex;
-
/*
* Copyright 2005 JBoss Inc
*
@@ -45,14 +43,16 @@
* @author <a href="mailto:bob at werken.com">Bob McWhirter</a>
*
*/
-public class LinkedList implements Serializable {
+public class LinkedList
+ implements
+ Serializable {
private static final long serialVersionUID = 320;
-
- private LinkedListNode firstNode;
- private LinkedListNode lastNode;
- private int size;
+ private LinkedListNode firstNode;
+ private LinkedListNode lastNode;
+ private int size;
+
/**
* Construct an empty <code>LinkedList</code>
*/
@@ -145,15 +145,16 @@
return node;
}
- public void insertAfter(LinkedListNode existingNode, LinkedListNode newNode) {
- if ( newNode.getPrevious() != null || newNode.getNext() != null ) {
+ public void insertAfter(final LinkedListNode existingNode,
+ final LinkedListNode newNode) {
+ if ( newNode.getPrevious() != null || newNode.getNext() != null ) {
//do nothing if this node is already inserted somewhere
return;
}
- if (existingNode == null ) {
+ if ( existingNode == null ) {
// if existing node is null, then insert it as a first node
- LinkedListNode node = this.firstNode;
+ final LinkedListNode node = this.firstNode;
node.setPrevious( newNode );
newNode.setNext( node );
this.firstNode = newNode;
@@ -165,7 +166,7 @@
}
this.size++;
}
-
+
/**
* Remove the last node from the list. The previous node then becomes the last node. If this is the last
* node then both first and last node references are set to null.
@@ -187,7 +188,7 @@
}
this.size--;
return node;
- }
+ }
/**
* @return
@@ -212,32 +213,32 @@
public final int size() {
return this.size;
}
-
- public int hashCode() {
+
+ public int hashCode() {
final int PRIME = 31;
int result = 1;
- for ( LinkedListNode node = this.firstNode; node != null; node = node.getNext() ) {
- result = PRIME * result + node.hashCode();
+ for ( LinkedListNode node = this.firstNode; node != null; node = node.getNext() ) {
+ result = PRIME * result + node.hashCode();
}
- return result;
+ return result;
}
-
- public boolean equals(Object object) {
+
+ public boolean equals(final Object object) {
if ( object == this ) {
- return true;
+ return true;
}
-
+
if ( object == null || object.getClass() != LinkedList.class ) {
return false;
}
-
- LinkedList other = ( LinkedList ) object;
-
+
+ final LinkedList other = (LinkedList) object;
+
if ( this.size() != other.size() ) {
return false;
}
-
- for ( LinkedListNode thisNode = this.firstNode, otherNode = other.firstNode; thisNode != null && otherNode != null; thisNode = thisNode.getNext(), otherNode = otherNode.getNext() ) {
+
+ for ( LinkedListNode thisNode = this.firstNode, otherNode = other.firstNode; thisNode != null && otherNode != null; thisNode = thisNode.getNext(), otherNode = otherNode.getNext() ) {
if ( !thisNode.equals( otherNode ) ) {
return false;
}
@@ -277,6 +278,6 @@
}
}
};
- }
+ }
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/LinkedListEntry.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/LinkedListEntry.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/LinkedListEntry.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -30,13 +30,13 @@
public Object getObject() {
return this.object;
- }
-
+ }
+
public int hashCode() {
- return object.hashCode();
+ return this.object.hashCode();
}
-
- public boolean equals(Object other) {
+
+ public boolean equals(final Object other) {
return this.object.equals( other );
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/LinkedListNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/LinkedListNode.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/LinkedListNode.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -26,7 +26,9 @@
* @author <a href="mailto:mark.proctor at jboss.com">Mark Proctor</a>
* @author <a href="mailto:bob at werken.com">Bob McWhirter</a>
*/
-public interface LinkedListNode extends Serializable {
+public interface LinkedListNode
+ extends
+ Serializable {
/**
* Returns the next node
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/ObjectHashMap.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/ObjectHashMap.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/ObjectHashMap.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -4,37 +4,39 @@
package org.drools.util;
public class ObjectHashMap extends AbstractHashTable {
-
+
public ObjectHashMap() {
this( 16,
0.75f );
}
- public ObjectHashMap(int capacity,
- float loadFactor) {
+ public ObjectHashMap(final int capacity,
+ final float loadFactor) {
super( capacity,
loadFactor );
}
-
- public Object put(Object key,
- Object value) {
- return put(key, value, true);
- }
- public Object put(Object key,
- Object value,
- boolean checkExists ) {
- int hashCode = this.comparator.hashCodeOf( key );
- int index = indexOf( hashCode,
- table.length );
+ public Object put(final Object key,
+ final Object value) {
+ return put( key,
+ value,
+ true );
+ }
+ public Object put(final Object key,
+ final Object value,
+ final boolean checkExists) {
+ final int hashCode = this.comparator.hashCodeOf( key );
+ final int index = indexOf( hashCode,
+ this.table.length );
+
// scan the linked entries to see if it exists
if ( checkExists ) {
ObjectEntry current = (ObjectEntry) this.table[index];
while ( current != null ) {
- if ( hashCode == current.hashCode && comparator.equal( key,
+ if ( hashCode == current.hashCode && this.comparator.equal( key,
current.key ) ) {
- Object oldValue = current.value;
+ final Object oldValue = current.value;
current.value = value;
return oldValue;
}
@@ -43,7 +45,7 @@
}
// We aren't checking the key exists, or it didn't find the key
- ObjectEntry entry = new ObjectEntry( key,
+ final ObjectEntry entry = new ObjectEntry( key,
value,
hashCode );
entry.next = this.table[index];
@@ -55,32 +57,32 @@
return null;
}
- public Object get(Object key) {
- int hashCode = this.comparator.hashCodeOf( key );
- int index = indexOf( hashCode,
- table.length );
+ public Object get(final Object key) {
+ final int hashCode = this.comparator.hashCodeOf( key );
+ final int index = indexOf( hashCode,
+ this.table.length );
ObjectEntry current = (ObjectEntry) this.table[index];
while ( current != null ) {
- if ( hashCode == current.hashCode && comparator.equal( key,
+ if ( hashCode == current.hashCode && this.comparator.equal( key,
current.key ) ) {
return current.value;
}
current = (ObjectEntry) current.getNext();
}
return null;
- }
+ }
- public Object remove(Object key) {
- int hashCode = this.comparator.hashCodeOf( key );
- int index = indexOf( hashCode,
- table.length );
+ public Object remove(final Object key) {
+ final int hashCode = this.comparator.hashCodeOf( key );
+ final int index = indexOf( hashCode,
+ this.table.length );
ObjectEntry previous = (ObjectEntry) this.table[index];
ObjectEntry current = previous;
while ( current != null ) {
- ObjectEntry next = (ObjectEntry) current.getNext();
- if ( hashCode == current.hashCode && comparator.equal( key,
+ final ObjectEntry next = (ObjectEntry) current.getNext();
+ if ( hashCode == current.hashCode && this.comparator.equal( key,
current.key ) ) {
if ( previous == current ) {
this.table[index] = next;
@@ -96,15 +98,15 @@
}
return null;
}
-
- public Entry getBucket(Object object) {
- int hashCode = this.comparator.hashCodeOf( object );
- int index = indexOf( hashCode,
- table.length );
- return (ObjectEntry) this.table[index];
- }
-
+ public Entry getBucket(final Object object) {
+ final int hashCode = this.comparator.hashCodeOf( object );
+ final int index = indexOf( hashCode,
+ this.table.length );
+
+ return this.table[index];
+ }
+
public static class ObjectEntry
implements
Entry {
@@ -114,30 +116,29 @@
private int hashCode;
- private Entry next;
+ private Entry next;
- public ObjectEntry(Object key,
- Object value,
- int hashCode) {
+ public ObjectEntry(final Object key,
+ final Object value,
+ final int hashCode) {
this.key = key;
this.value = value;
this.hashCode = hashCode;
}
public Object getValue() {
- return value;
+ return this.value;
}
-
public Object getKey() {
- return key;
+ return this.key;
}
public Entry getNext() {
return this.next;
}
- public void setNext(Entry next) {
+ public void setNext(final Entry next) {
this.next = next;
}
@@ -145,14 +146,14 @@
return this.key.hashCode() ^ this.value.hashCode();
}
- public boolean equals(Object object) {
+ public boolean equals(final Object object) {
if ( object == this ) {
return true;
}
// assumes we never have null or wrong class
- ObjectEntry other = (ObjectEntry) object;
+ final ObjectEntry other = (ObjectEntry) object;
return this.key.equals( other.key ) && this.value.equals( other.value );
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/ReflectiveVisitor.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/ReflectiveVisitor.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/ReflectiveVisitor.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -42,12 +42,13 @@
new Object[]{object} );
} else {
method = getClass().getMethod( "visitNull",
- (Class[]) null );
+ (Class[]) null );
method.invoke( this,
(Object[]) null );
}
} catch ( final Exception e ) {
- throw new RuntimeDroolsException(e.toString() + " : " + object, e.getCause());
+ throw new RuntimeDroolsException( e.toString() + " : " + object,
+ e.getCause() );
}
}
@@ -88,7 +89,8 @@
} catch ( final Exception e ) {
// Shouldn't happen as long as all Visitors extend this class
// and this class continues to implement visitObject(Object).
- throw new RuntimeDroolsException(e.toString() + " : " + clazz, e.getCause());
+ throw new RuntimeDroolsException( e.toString() + " : " + clazz,
+ e.getCause() );
}
}
return method;
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/TupleHashTable.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/TupleHashTable.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/TupleHashTable.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -11,16 +11,16 @@
0.75f );
}
- public TupleHashTable(int capacity,
- float loadFactor) {
+ public TupleHashTable(final int capacity,
+ final float loadFactor) {
super( capacity,
loadFactor );
}
- public Object add(ReteTuple tuple) {
- int hashCode = tuple.hashCode();
- int index = indexOf( hashCode,
- table.length );
+ public Object add(final ReteTuple tuple) {
+ final int hashCode = tuple.hashCode();
+ final int index = indexOf( hashCode,
+ this.table.length );
tuple.setNext( this.table[index] );
this.table[index] = tuple;
@@ -29,12 +29,12 @@
resize( 2 * this.table.length );
}
return null;
- }
+ }
- public Object get(ReteTuple tuple) {
- int hashCode = tuple.hashCode();
- int index = indexOf( hashCode,
- table.length );
+ public Object get(final ReteTuple tuple) {
+ final int hashCode = tuple.hashCode();
+ final int index = indexOf( hashCode,
+ this.table.length );
ReteTuple current = (ReteTuple) this.table[index];
while ( current != null ) {
@@ -44,17 +44,17 @@
current = (ReteTuple) current.getNext();
}
return null;
- }
+ }
- public Object remove(ReteTuple tuple) {
- int hashCode = tuple.hashCode();
- int index = indexOf( hashCode,
- table.length );
+ public Object remove(final ReteTuple tuple) {
+ final int hashCode = tuple.hashCode();
+ final int index = indexOf( hashCode,
+ this.table.length );
ReteTuple previous = (ReteTuple) this.table[index];
ReteTuple current = previous;
while ( current != null ) {
- ReteTuple next = (ReteTuple) current.getNext();
+ final ReteTuple next = (ReteTuple) current.getNext();
if ( hashCode == current.hashCode() && tuple.equals( current ) ) {
if ( previous == current ) {
this.table[index] = next;
@@ -69,17 +69,17 @@
current = next;
}
return current;
- }
+ }
- public Entry getBucket(Object object) {
- int hashCode = object.hashCode();
- int index = indexOf( hashCode,
- table.length );
+ public Entry getBucket(final Object object) {
+ final int hashCode = object.hashCode();
+ final int index = indexOf( hashCode,
+ this.table.length );
- return this.table[index];
+ return this.table[index];
}
-
- public boolean contains(ReteTuple tuple) {
- return (get(tuple) != null);
+
+ public boolean contains(final ReteTuple tuple) {
+ return (get( tuple ) != null);
}
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/UUID.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/UUID.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/UUID.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -43,31 +43,33 @@
*/
public class UUID
- implements Serializable, Cloneable, Comparable
-{
- private final static String kHexChars = "0123456789abcdefABCDEF";
+ implements
+ Serializable,
+ Cloneable,
+ Comparable {
+ private final static String kHexChars = "0123456789abcdefABCDEF";
- public final static byte INDEX_CLOCK_HI = 6;
- public final static byte INDEX_CLOCK_MID = 4;
- public final static byte INDEX_CLOCK_LO = 0;
+ public final static byte INDEX_CLOCK_HI = 6;
+ public final static byte INDEX_CLOCK_MID = 4;
+ public final static byte INDEX_CLOCK_LO = 0;
- public final static byte INDEX_TYPE = 6;
+ public final static byte INDEX_TYPE = 6;
// Clock seq. & variant are multiplexed...
- public final static byte INDEX_CLOCK_SEQUENCE = 8;
- public final static byte INDEX_VARIATION = 8;
+ public final static byte INDEX_CLOCK_SEQUENCE = 8;
+ public final static byte INDEX_VARIATION = 8;
- public final static byte TYPE_NULL = 0;
- public final static byte TYPE_TIME_BASED = 1;
- public final static byte TYPE_DCE = 2; // Not used
- public final static byte TYPE_NAME_BASED = 3;
- public final static byte TYPE_RANDOM_BASED = 4;
+ public final static byte TYPE_NULL = 0;
+ public final static byte TYPE_TIME_BASED = 1;
+ public final static byte TYPE_DCE = 2; // Not used
+ public final static byte TYPE_NAME_BASED = 3;
+ public final static byte TYPE_RANDOM_BASED = 4;
/* 'Standard' namespaces defined (suggested) by UUID specs:
*/
- public final static String NAMESPACE_DNS = "6ba7b810-9dad-11d1-80b4-00c04fd430c8";
- public final static String NAMESPACE_URL = "6ba7b811-9dad-11d1-80b4-00c04fd430c8";
- public final static String NAMESPACE_OID = "6ba7b812-9dad-11d1-80b4-00c04fd430c8";
- public final static String NAMESPACE_X500 = "6ba7b814-9dad-11d1-80b4-00c04fd430c8";
+ public final static String NAMESPACE_DNS = "6ba7b810-9dad-11d1-80b4-00c04fd430c8";
+ public final static String NAMESPACE_URL = "6ba7b811-9dad-11d1-80b4-00c04fd430c8";
+ public final static String NAMESPACE_OID = "6ba7b812-9dad-11d1-80b4-00c04fd430c8";
+ public final static String NAMESPACE_X500 = "6ba7b814-9dad-11d1-80b4-00c04fd430c8";
/* By default let's cache desc, can be turned off. For hash code
* there's no point in turning it off (since the int is already
@@ -75,7 +77,7 @@
* those 4 bytes (or possibly bit more if alignment is bad) just
* comment out hash caching.
*/
- private static boolean sDescCaching = true;
+ private static boolean sDescCaching = true;
/**
* The shared null UUID. Would be nice to do lazy instantiation, but
@@ -85,12 +87,12 @@
* assuming creation of the null UUID (plus wasted space if it's
* not needed) can be ignored.
*/
- private final static UUID sNullUUID = new UUID();
+ private final static UUID sNullUUID = new UUID();
- private final byte[] mId = new byte[16];
+ private final byte[] mId = new byte[16];
// Both string presentation and hash value may be cached...
- private transient String mDesc = null;
- private transient int mHashCode = 0;
+ private transient String mDesc = null;
+ private transient int mHashCode = 0;
/* *** Object creation: *** */
@@ -101,13 +103,12 @@
* Note that the clearing of array is actually unnecessary as
* JVMs are required to clear up the allocated arrays by default.
*/
- public UUID()
- {
+ public UUID() {
/*
- for (int i = 0; i < 16; ++i) {
- mId[i] = (byte)0;
- }
- */
+ for (int i = 0; i < 16; ++i) {
+ mId[i] = (byte)0;
+ }
+ */
}
/**
@@ -117,14 +118,13 @@
*
* @param data array that contains the binary representation of UUID
*/
- public UUID(byte[] data)
- {
+ public UUID(final byte[] data) {
/* Could call the other constructor... and/or use System.arraycopy.
* However, it's likely that those would make this slower to use,
* and initialization is really simple as is in any case.
*/
- for (int i = 0; i < 16; ++i) {
- mId[i] = data[i];
+ for ( int i = 0; i < 16; ++i ) {
+ this.mId[i] = data[i];
}
}
@@ -137,10 +137,10 @@
* @param data array that contains the binary representation of UUID
* @param start byte offset where UUID starts
*/
- public UUID(byte[] data, int start)
- {
- for (int i = 0; i < 16; ++i) {
- mId[i] = data[start + i];
+ public UUID(final byte[] data,
+ final int start) {
+ for ( int i = 0; i < 16; ++i ) {
+ this.mId[i] = data[start + i];
}
}
@@ -150,17 +150,17 @@
* @param type UUID type
* @param data 16 byte UUID contents
*/
- UUID(int type, byte[] data)
- {
- for (int i = 0; i < 16; ++i) {
- mId[i] = data[i];
+ UUID(final int type,
+ final byte[] data) {
+ for ( int i = 0; i < 16; ++i ) {
+ this.mId[i] = data[i];
}
// Type is multiplexed with time_hi:
- mId[INDEX_TYPE] &= (byte) 0x0F;
- mId[INDEX_TYPE] |= (byte) (type << 4);
+ this.mId[UUID.INDEX_TYPE] &= (byte) 0x0F;
+ this.mId[UUID.INDEX_TYPE] |= (byte) (type << 4);
// Variant masks first two bits of the clock_seq_hi:
- mId[INDEX_VARIATION] &= (byte) 0x3F;
- mId[INDEX_VARIATION] |= (byte) 0x80;
+ this.mId[UUID.INDEX_VARIATION] &= (byte) 0x3F;
+ this.mId[UUID.INDEX_VARIATION] |= (byte) 0x80;
}
/**
@@ -176,51 +176,49 @@
* Hex-chars may be in upper-case too; UUID class will always output
* them in lowercase.
*/
- public UUID(String id)
- throws NumberFormatException
- {
- if (id == null) {
+ public UUID(final String id) throws NumberFormatException {
+ if ( id == null ) {
throw new NullPointerException();
}
- if (id.length() != 36) {
- throw new NumberFormatException("UUID has to be represented by the standard 36-char representation");
+ if ( id.length() != 36 ) {
+ throw new NumberFormatException( "UUID has to be represented by the standard 36-char representation" );
}
- for (int i = 0, j = 0; i < 36; ++j) {
+ for ( int i = 0, j = 0; i < 36; ++j ) {
// Need to bypass hyphens:
- switch (i) {
- case 8:
- case 13:
- case 18:
- case 23:
- if (id.charAt(i) != '-') {
- throw new NumberFormatException("UUID has to be represented by the standard 36-char representation");
- }
- ++i;
+ switch ( i ) {
+ case 8 :
+ case 13 :
+ case 18 :
+ case 23 :
+ if ( id.charAt( i ) != '-' ) {
+ throw new NumberFormatException( "UUID has to be represented by the standard 36-char representation" );
+ }
+ ++i;
}
- int index;
- char c = id.charAt(i);
+ final int index;
+ char c = id.charAt( i );
- if (c >= '0' && c <= '9') {
- mId[j] = (byte) ((c - '0') << 4);
- } else if (c >= 'a' && c <= 'f') {
- mId[j] = (byte) ((c - 'a' + 10) << 4);
- } else if (c >= 'A' && c <= 'F') {
- mId[j] = (byte) ((c - 'A' + 10) << 4);
+ if ( c >= '0' && c <= '9' ) {
+ this.mId[j] = (byte) ((c - '0') << 4);
+ } else if ( c >= 'a' && c <= 'f' ) {
+ this.mId[j] = (byte) ((c - 'a' + 10) << 4);
+ } else if ( c >= 'A' && c <= 'F' ) {
+ this.mId[j] = (byte) ((c - 'A' + 10) << 4);
} else {
- throw new NumberFormatException("Non-hex character '"+c+"'");
+ throw new NumberFormatException( "Non-hex character '" + c + "'" );
}
- c = id.charAt(++i);
+ c = id.charAt( ++i );
- if (c >= '0' && c <= '9') {
- mId[j] |= (byte) (c - '0');
- } else if (c >= 'a' && c <= 'f') {
- mId[j] |= (byte) (c - 'a' + 10);
- } else if (c >= 'A' && c <= 'F') {
- mId[j] |= (byte) (c - 'A' + 10);
+ if ( c >= '0' && c <= '9' ) {
+ this.mId[j] |= (byte) (c - '0');
+ } else if ( c >= 'a' && c <= 'f' ) {
+ this.mId[j] |= (byte) (c - 'a' + 10);
+ } else if ( c >= 'A' && c <= 'F' ) {
+ this.mId[j] |= (byte) (c - 'A' + 10);
} else {
- throw new NumberFormatException("Non-hex character '"+c+"'");
+ throw new NumberFormatException( "Non-hex character '" + c + "'" );
}
++i;
}
@@ -232,20 +230,18 @@
* Could clear out cached string presentation, but there's
* probably no point in doing that.
*/
- public Object clone()
- {
+ public Object clone() {
try {
return super.clone();
- } catch (CloneNotSupportedException e) {
+ } catch ( final CloneNotSupportedException e ) {
// shouldn't happen
return null;
}
}
/* *** Configuration: *** */
- public static void setDescCaching(boolean state)
- {
- sDescCaching = state;
+ public static void setDescCaching(final boolean state) {
+ UUID.sDescCaching = state;
}
/* *** Accessors: *** */
@@ -255,23 +251,21 @@
*
* @return the shared null UUID
*/
- public static UUID getNullUUID()
- {
- return sNullUUID;
+ public static UUID getNullUUID() {
+ return UUID.sNullUUID;
}
- public boolean isNullUUID()
- {
+ public boolean isNullUUID() {
// Assuming null uuid is usually used for nulls:
- if (this == sNullUUID) {
+ if ( this == UUID.sNullUUID ) {
return true;
}
// Could also check hash code; null uuid has -1 as hash?
- byte[] data = mId;
- int i = mId.length;
- byte zero = (byte) 0;
- while (--i >= 0) {
- if (data[i] != zero) {
+ final byte[] data = this.mId;
+ int i = this.mId.length;
+ final byte zero = (byte) 0;
+ while ( --i >= 0 ) {
+ if ( data[i] != zero ) {
return false;
}
}
@@ -284,9 +278,8 @@
*
* @return UUID type
*/
- public int getType()
- {
- return (mId[INDEX_TYPE] & 0xFF) >> 4;
+ public int getType() {
+ return (this.mId[UUID.INDEX_TYPE] & 0xFF) >> 4;
}
/**
@@ -295,10 +288,9 @@
* @return 16-byte byte array that contains UUID bytes in the network
* byte order
*/
- public byte[] asByteArray()
- {
- byte[] result = new byte[16];
- toByteArray(result);
+ public byte[] asByteArray() {
+ final byte[] result = new byte[16];
+ toByteArray( result );
return result;
}
@@ -309,21 +301,26 @@
* @param dst Byte array to fill
* @param pos Offset in the array
*/
- public void toByteArray(byte[] dst, int pos)
- {
- byte[] src = mId;
- for (int i = 0; i < 16; ++i) {
- dst[pos+i] = src[i];
+ public void toByteArray(final byte[] dst,
+ final int pos) {
+ final byte[] src = this.mId;
+ for ( int i = 0; i < 16; ++i ) {
+ dst[pos + i] = src[i];
}
}
- public void toByteArray(byte[] dst) { toByteArray(dst, 0); }
+ public void toByteArray(final byte[] dst) {
+ toByteArray( dst,
+ 0 );
+ }
/**
* 'Synonym' for 'asByteArray'
*/
- public byte[] toByteArray() { return asByteArray(); }
-
+ public byte[] toByteArray() {
+ return asByteArray();
+ }
+
/* *** Standard methods from Object overridden: *** */
/**
@@ -339,24 +336,21 @@
* Is this a good hash? ... one of these days I better read more about
* basic hashing techniques I swear!
*/
- private final static int[] kShifts = {
- 3, 7, 17, 21, 29, 4, 9
- };
+ private final static int[] kShifts = {3, 7, 17, 21, 29, 4, 9};
- public int hashCode()
- {
- if (mHashCode == 0) {
+ public int hashCode() {
+ if ( this.mHashCode == 0 ) {
// Let's handle first and last byte separately:
- int result = mId[0] & 0xFF;
-
+ int result = this.mId[0] & 0xFF;
+
result |= (result << 16);
result |= (result << 8);
-
- for (int i = 1; i < 15; i += 2) {
- int curr = (mId[i] & 0xFF) << 8 | (mId[i+1] & 0xFF);
- int shift = kShifts[i >> 1];
-
- if (shift > 16) {
+
+ for ( int i = 1; i < 15; i += 2 ) {
+ final int curr = (this.mId[i] & 0xFF) << 8 | (this.mId[i + 1] & 0xFF);
+ final int shift = UUID.kShifts[i >> 1];
+
+ if ( shift > 16 ) {
result ^= (curr << shift) | (curr >>> (32 - shift));
} else {
result ^= (curr << shift);
@@ -364,60 +358,54 @@
}
// and then the last byte:
- int last = mId[15] & 0xFF;
+ final int last = this.mId[15] & 0xFF;
result ^= (last << 3);
result ^= (last << 13);
result ^= (last << 27);
// Let's not accept hash 0 as it indicates 'not hashed yet':
- if (result == 0) {
- mHashCode = -1;
+ if ( result == 0 ) {
+ this.mHashCode = -1;
} else {
- mHashCode = result;
+ this.mHashCode = result;
}
}
- return mHashCode;
+ return this.mHashCode;
}
- public String toString()
- {
+ public String toString() {
/* Could be synchronized, but there isn't much harm in just taking
* our chances (ie. in the worst case we'll form the string more
* than once... but result is the same)
*/
- if (mDesc == null) {
- StringBuffer b = new StringBuffer(36);
-
- for (int i = 0; i < 16; ++i) {
+ if ( this.mDesc == null ) {
+ final StringBuffer b = new StringBuffer( 36 );
+
+ for ( int i = 0; i < 16; ++i ) {
// Need to bypass hyphens:
- switch (i) {
- case 4:
- case 6:
- case 8:
- case 10:
- b.append('-');
+ switch ( i ) {
+ case 4 :
+ case 6 :
+ case 8 :
+ case 10 :
+ b.append( '-' );
}
- int hex = mId[i] & 0xFF;
- b.append(kHexChars.charAt(hex >> 4));
- b.append(kHexChars.charAt(hex & 0x0f));
+ final int hex = this.mId[i] & 0xFF;
+ b.append( UUID.kHexChars.charAt( hex >> 4 ) );
+ b.append( UUID.kHexChars.charAt( hex & 0x0f ) );
}
- if (!sDescCaching) {
+ if ( !UUID.sDescCaching ) {
return b.toString();
}
- mDesc = b.toString();
+ this.mDesc = b.toString();
}
- return mDesc;
+ return this.mDesc;
}
/* *** Comparison methods: *** */
- private final static int[] sTimeCompare = new int[] {
- INDEX_CLOCK_HI, INDEX_CLOCK_HI + 1,
- INDEX_CLOCK_MID, INDEX_CLOCK_MID + 1,
- INDEX_CLOCK_LO, INDEX_CLOCK_LO + 1,
- INDEX_CLOCK_LO + 2, INDEX_CLOCK_LO + 3,
- };
+ private final static int[] sTimeCompare = new int[]{UUID.INDEX_CLOCK_HI, UUID.INDEX_CLOCK_HI + 1, UUID.INDEX_CLOCK_MID, UUID.INDEX_CLOCK_MID + 1, UUID.INDEX_CLOCK_LO, UUID.INDEX_CLOCK_LO + 1, UUID.INDEX_CLOCK_LO + 2, UUID.INDEX_CLOCK_LO + 3,};
/**
* Let's also make UUIDs sortable. This will mostly/only be useful with
@@ -444,18 +432,17 @@
*
* @throws ClassCastException if o is not a UUID.
*/
- public int compareTo(Object o)
- {
- UUID other = (UUID) o;
+ public int compareTo(final Object o) {
+ final UUID other = (UUID) o;
- int thisType = getType();
- int thatType = other.getType();
+ final int thisType = getType();
+ final int thatType = other.getType();
/* Let's first order by type:
*/
- if (thisType > thatType) {
+ if ( thisType > thatType ) {
return 1;
- } else if (thisType < thatType) {
+ } else if ( thisType < thatType ) {
return -1;
}
@@ -463,24 +450,23 @@
* then the rest... For all other types, we'll just do straight
* byte-by-byte comparison.
*/
- byte[] thisId = mId;
- byte[] thatId = other.mId;
+ final byte[] thisId = this.mId;
+ final byte[] thatId = other.mId;
int i = 0;
- if (thisType == TYPE_TIME_BASED) {
- for (; i < 8; ++i) {
- int index = sTimeCompare[i];
- int cmp = (((int) thisId[index]) & 0xFF)
- - (((int) thatId[index]) & 0xFF);
- if (cmp != 0) {
+ if ( thisType == UUID.TYPE_TIME_BASED ) {
+ for ( ; i < 8; ++i ) {
+ final int index = UUID.sTimeCompare[i];
+ final int cmp = ((thisId[index]) & 0xFF) - ((thatId[index]) & 0xFF);
+ if ( cmp != 0 ) {
return cmp;
}
}
// Let's fall down to full comparison otherwise
}
- for (; i < 16; ++i) {
- int cmp = (((int) thisId[i]) & 0xFF) - (((int) thatId[i]) & 0xFF);
- if (cmp != 0) {
+ for ( ; i < 16; ++i ) {
+ final int cmp = ((thisId[i]) & 0xFF) - ((thatId[i]) & 0xFF);
+ if ( cmp != 0 ) {
return cmp;
}
}
@@ -492,15 +478,14 @@
* Checking equality of UUIDs is easy; just compare the 128-bit
* number.
*/
- public boolean equals(Object o)
- {
- if (!(o instanceof UUID)) {
+ public boolean equals(final Object o) {
+ if ( !(o instanceof UUID) ) {
return false;
}
- byte[] otherId = ((UUID) o).mId;
- byte[] thisId = mId;
- for (int i = 0; i < 16; ++i) {
- if (otherId[i] != thisId[i]) {
+ final byte[] otherId = ((UUID) o).mId;
+ final byte[] thisId = this.mId;
+ for ( int i = 0; i < 16; ++i ) {
+ if ( otherId[i] != thisId[i] ) {
return false;
}
}
@@ -519,10 +504,8 @@
*
* @throws NumberFormatException if 'id' is invalid UUID
*/
- public static UUID valueOf(String id)
- throws NumberFormatException
- {
- return new UUID(id);
+ public static UUID valueOf(final String id) throws NumberFormatException {
+ return new UUID( id );
}
/**
@@ -535,9 +518,10 @@
* @param src Byte array that contains the UUID definition
* @param start Offset in the array where the UUID starts
*/
- public static UUID valueOf(byte[] src, int start)
- {
- return new UUID(src, start);
+ public static UUID valueOf(final byte[] src,
+ final int start) {
+ return new UUID( src,
+ start );
}
/**
@@ -549,21 +533,19 @@
*
* @param src Byte array that contains the UUID definition
*/
- public static UUID valueOf(byte[] src)
- {
- return new UUID(src);
+ public static UUID valueOf(final byte[] src) {
+ return new UUID( src );
}
-
- private void copyFrom(UUID src)
- {
- byte[] srcB = src.mId;
- byte[] dstB = mId;
-
- for (int i = 0; i < 16; ++i) {
+
+ private void copyFrom(final UUID src) {
+ final byte[] srcB = src.mId;
+ final byte[] dstB = this.mId;
+
+ for ( int i = 0; i < 16; ++i ) {
dstB[i] = srcB[i];
}
- mDesc = sDescCaching ? src.mDesc : null;
+ this.mDesc = UUID.sDescCaching ? src.mDesc : null;
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/UUIDGenerator.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/UUIDGenerator.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/UUIDGenerator.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -1,4 +1,3 @@
-
/* JUG Java Uuid Generator
*
* Copyright (c) 2002- Tatu Saloranta, tatu.saloranta at iki.fi
@@ -26,46 +25,44 @@
*
* @see org.safehaus.jug
*/
-public final class UUIDGenerator
-{
+public final class UUIDGenerator {
private final static UUIDGenerator sSingleton = new UUIDGenerator();
/**
* Random-generator, used by various UUID-generation methods:
*/
- private Random mRnd = null;
+ private Random mRnd = null;
/**
* MD5 hasher for name-based digests:
*/
- private MessageDigest mHasher = null;
+ private MessageDigest mHasher = null;
/*
- /////////////////////////////////////////////////////
- // Life-cycle
- /////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////
+ // Life-cycle
+ /////////////////////////////////////////////////////
*/
/**
* Constructor is private to enforce singleton access.
*/
- private UUIDGenerator() { }
+ private UUIDGenerator() {
+ }
/**
* Method used for accessing the singleton generator instance.
*/
- public static UUIDGenerator getInstance()
- {
- return sSingleton;
+ public static UUIDGenerator getInstance() {
+ return UUIDGenerator.sSingleton;
}
-
+
/*
- /////////////////////////////////////////////////////
- // Configuration
- /////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////
+ // Configuration
+ /////////////////////////////////////////////////////
*/
-
/**
* Method for getting the shared random number generator used for
* generating the UUIDs. This way the initialization cost is only
@@ -73,17 +70,16 @@
* it has to, SecureRandom takes care of it); it might even be good
* for getting really 'random' stuff to get shared access...
*/
- public Random getRandomNumberGenerator()
- {
+ public Random getRandomNumberGenerator() {
/* Could be synchronized, but since side effects are trivial
* (ie. possibility of generating more than one SecureRandom,
* of which all but one are dumped) let's not add synchronization
* overhead:
*/
- if (mRnd == null) {
- mRnd = new SecureRandom();
+ if ( this.mRnd == null ) {
+ this.mRnd = new SecureRandom();
}
- return mRnd;
+ return this.mRnd;
}
/**
@@ -96,9 +92,8 @@
* of using {@link SecureRandom}, this method has to be called
* before generating the first random-number based UUID.
*/
- public void setRandomNumberGenerator(Random r)
- {
- mRnd = r;
+ public void setRandomNumberGenerator(final Random r) {
+ this.mRnd = r;
}
/* Method for getting the shared message digest (hash) algorithm.
@@ -106,27 +101,26 @@
* adds synchronization overhead (access has to be sync'ed), but
* using multiple separate digests wastes memory.
*/
- public MessageDigest getHashAlgorithm()
- {
+ public MessageDigest getHashAlgorithm() {
/* Similar to the shared random number generator, it's not necessary
* to synchronize initialization. However, use of the hash instance
* HAS to be synchronized by the caller to prevent problems with
* multiple threads updating digest etc.
*/
- if (mHasher == null) {
+ if ( this.mHasher == null ) {
try {
- mHasher = MessageDigest.getInstance("MD5");
- } catch (NoSuchAlgorithmException nex) {
- throw new Error("Couldn't instantiate an MD5 MessageDigest instance: "+nex.toString());
+ this.mHasher = MessageDigest.getInstance( "MD5" );
+ } catch ( final NoSuchAlgorithmException nex ) {
+ throw new Error( "Couldn't instantiate an MD5 MessageDigest instance: " + nex.toString() );
}
}
- return mHasher;
+ return this.mHasher;
}
/*
- /////////////////////////////////////////////////////
- // UUID generation methods
- /////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////
+ // UUID generation methods
+ /////////////////////////////////////////////////////
*/
/**
@@ -144,9 +138,8 @@
*
* @return UUID generated using (pseudo-)random based method
*/
- public UUID generateRandomBasedUUID()
- {
- return generateRandomBasedUUID(getRandomNumberGenerator());
+ public UUID generateRandomBasedUUID() {
+ return generateRandomBasedUUID( getRandomNumberGenerator() );
}
/**
@@ -161,12 +154,12 @@
*
* @return UUID generated using (pseudo-)random based method
*/
- public UUID generateRandomBasedUUID(Random randomGenerator)
- {
- byte[] rnd = new byte[16];
-
- randomGenerator.nextBytes(rnd);
-
- return new UUID(UUID.TYPE_RANDOM_BASED, rnd);
+ public UUID generateRandomBasedUUID(final Random randomGenerator) {
+ final byte[] rnd = new byte[16];
+
+ randomGenerator.nextBytes( rnd );
+
+ return new UUID( UUID.TYPE_RANDOM_BASED,
+ rnd );
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/asm/ClassFieldInspector.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/asm/ClassFieldInspector.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/asm/ClassFieldInspector.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -34,7 +34,6 @@
import org.drools.asm.FieldVisitor;
import org.drools.asm.MethodVisitor;
import org.drools.asm.Opcodes;
-import org.drools.asm.tree.MethodNode;
/**
* Visit a POJO user class, and extract the property getter methods that are public, in the
@@ -58,15 +57,19 @@
* @throws IOException
*/
public ClassFieldInspector(final Class clazz) throws IOException {
- this(clazz, true);
+ this( clazz,
+ true );
}
-
- public ClassFieldInspector(final Class clazz, final boolean includeFinalMethods) throws IOException {
- processClass( clazz, includeFinalMethods );
+
+ public ClassFieldInspector(final Class clazz,
+ final boolean includeFinalMethods) throws IOException {
+ processClass( clazz,
+ includeFinalMethods );
}
/** Walk up the inheritance hierarchy recursively, reading in fields */
- private void processClass(final Class clazz, final boolean includeFinalMethods) throws IOException {
+ private void processClass(final Class clazz,
+ final boolean includeFinalMethods) throws IOException {
final String name = getResourcePath( clazz );
final InputStream stream = clazz.getResourceAsStream( name );
final ClassReader reader = new ClassReader( stream );
@@ -76,12 +79,14 @@
reader.accept( visitor,
false );
if ( clazz.getSuperclass() != null ) {
- processClass( clazz.getSuperclass(), includeFinalMethods );
+ processClass( clazz.getSuperclass(),
+ includeFinalMethods );
}
if ( clazz.isInterface() ) {
final Class[] interfaces = clazz.getInterfaces();
for ( int i = 0; i < interfaces.length; i++ ) {
- processClass( interfaces[i], includeFinalMethods );
+ processClass( interfaces[i],
+ includeFinalMethods );
}
}
}
@@ -151,7 +156,7 @@
final String[] exceptions) {
//only want public methods
//and have no args, and return a value
- int mask = this.includeFinalMethods ? Opcodes.ACC_PUBLIC : Opcodes.ACC_PUBLIC | Opcodes.ACC_FINAL;
+ final int mask = this.includeFinalMethods ? Opcodes.ACC_PUBLIC : Opcodes.ACC_PUBLIC | Opcodes.ACC_FINAL;
if ( (access & mask) == Opcodes.ACC_PUBLIC ) {
if ( desc.startsWith( "()" ) && !(name.equals( "<init>" )) ) {// && ( name.startsWith("get") || name.startsWith("is") ) ) {
try {
@@ -161,11 +166,11 @@
final int fieldIndex = this.inspector.methods.size();
addToMapping( method,
fieldIndex );
- }
+ }
} catch ( final NoSuchMethodException e ) {
throw new IllegalStateException( "Error in getting field access method." );
}
- }
+ }
}
return null;
}
@@ -286,9 +291,9 @@
}
private String calcFieldName(String name,
- final int offset) {
+ final int offset) {
name = name.substring( offset );
- return Introspector.decapitalize(name);
+ return Introspector.decapitalize( name );
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/concurrent/locks/ReentrantLock.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/concurrent/locks/ReentrantLock.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/concurrent/locks/ReentrantLock.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -25,7 +25,9 @@
private final NonfairSync sync;
- final static class NonfairSync implements Serializable {
+ final static class NonfairSync
+ implements
+ Serializable {
private static final long serialVersionUID = 7316153563782823691L;
protected transient Thread owner_ = null;
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/Cheese.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/Cheese.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/Cheese.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -20,11 +20,13 @@
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
-public class Cheese implements CheeseInterface {
+public class Cheese
+ implements
+ CheeseInterface {
private String type;
private int price;
-
+
public Cheese() {
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/RuleBaseFactoryTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/RuleBaseFactoryTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/RuleBaseFactoryTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -26,36 +26,36 @@
final RuleBase rb = RuleBaseFactory.newRuleBase();
assertTrue( rb instanceof org.drools.reteoo.ReteooRuleBase );
- assertTrue( !"default".equals( ( ( InternalRuleBase ) rb).getId() ) );
- assertTrue( !"".equals( ( ( InternalRuleBase ) rb).getId() ) );
- assertNotNull( ( ( InternalRuleBase ) rb).getId() );
-
+ assertTrue( !"default".equals( ((InternalRuleBase) rb).getId() ) );
+ assertTrue( !"".equals( ((InternalRuleBase) rb).getId() ) );
+ assertNotNull( ((InternalRuleBase) rb).getId() );
+
final RuleBase rb2 = RuleBaseFactory.newRuleBase( RuleBase.RETEOO );
assertTrue( rb2 instanceof org.drools.reteoo.ReteooRuleBase );
assertNotSame( rb2,
rb );
-
- assertTrue( !"default".equals( ( ( InternalRuleBase ) rb2).getId() ) );
- assertTrue( !"".equals( ( ( InternalRuleBase ) rb2).getId() ) );
- assertNotNull( ( ( InternalRuleBase ) rb2).getId() );
+
+ assertTrue( !"default".equals( ((InternalRuleBase) rb2).getId() ) );
+ assertTrue( !"".equals( ((InternalRuleBase) rb2).getId() ) );
+ assertNotNull( ((InternalRuleBase) rb2).getId() );
}
public void testLeaps() {
final RuleBase rb = RuleBaseFactory.newRuleBase( RuleBase.LEAPS );
assertTrue( rb instanceof org.drools.leaps.LeapsRuleBase );
- assertTrue( !"default".equals( ( ( InternalRuleBase ) rb).getId() ) );
- assertTrue( !"".equals( ( ( InternalRuleBase ) rb).getId() ) );
- assertNotNull( ( ( InternalRuleBase ) rb).getId() );
-
+ assertTrue( !"default".equals( ((InternalRuleBase) rb).getId() ) );
+ assertTrue( !"".equals( ((InternalRuleBase) rb).getId() ) );
+ assertNotNull( ((InternalRuleBase) rb).getId() );
+
final RuleBase rb2 = RuleBaseFactory.newRuleBase( RuleBase.LEAPS );
assertTrue( rb2 instanceof org.drools.leaps.LeapsRuleBase );
assertNotSame( rb2,
rb );
-
- assertTrue( !"default".equals( ( ( InternalRuleBase ) rb2).getId() ) );
- assertTrue( !"".equals( ( ( InternalRuleBase ) rb2).getId() ) );
- assertNotNull( ( ( InternalRuleBase ) rb2).getId() );
+
+ assertTrue( !"default".equals( ((InternalRuleBase) rb2).getId() ) );
+ assertTrue( !"".equals( ((InternalRuleBase) rb2).getId() ) );
+ assertNotNull( ((InternalRuleBase) rb2).getId() );
}
-
+
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/ClassFieldExtractorFactoryTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/ClassFieldExtractorFactoryTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/ClassFieldExtractorFactoryTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -67,5 +67,5 @@
assertEquals( "hola",
ex.getValue( new BeanInherit() ) );
}
-
+
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/ClassFieldExtractorTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/ClassFieldExtractorTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/ClassFieldExtractorTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -29,7 +29,7 @@
public class ClassFieldExtractorTest extends TestCase {
public void testBasic() throws Exception {
- Object[] objArray = new Object[1];
+ final Object[] objArray = new Object[1];
final TestBean obj = new TestBean();
obj.setBlah( false );
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/EvaluatorFactoryTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/EvaluatorFactoryTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/EvaluatorFactoryTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -40,24 +40,10 @@
final List list = new ArrayList();
list.add( "foo" );
- final Object[][] data = {
- {"foo", "==", "bar", Boolean.FALSE},
- {"foo", "==", "foo", Boolean.TRUE},
- {"foo", "!=", "bar", Boolean.TRUE},
- {list, "contains", "foo", Boolean.TRUE},
- {list, "contains", "bar", Boolean.FALSE},
- {list, "==", null, Boolean.FALSE},
- {list, "!=", null, Boolean.TRUE},
- {null, "==", null, Boolean.TRUE},
- {null, "==", list, Boolean.FALSE},
- {null, "!=", list, Boolean.TRUE},
- {new BigDecimal( "42.42" ), "<", new BigDecimal( "43" ), Boolean.TRUE},
- {new BigDecimal( "42.42" ), ">", new BigDecimal( "43" ), Boolean.FALSE},
- {new BigDecimal( "42.42" ), "<=", new BigDecimal( "42.42" ), Boolean.TRUE},
- {new BigInteger( "42" ), ">=", new BigInteger( "43" ), Boolean.FALSE},
- {new BigInteger( "42" ), ">=", new BigInteger( "43" ), Boolean.FALSE},
- {list, "excludes", "baz", Boolean.TRUE},
- {list, "excludes", "foo", Boolean.FALSE}
+ final Object[][] data = {{"foo", "==", "bar", Boolean.FALSE}, {"foo", "==", "foo", Boolean.TRUE}, {"foo", "!=", "bar", Boolean.TRUE}, {list, "contains", "foo", Boolean.TRUE}, {list, "contains", "bar", Boolean.FALSE},
+ {list, "==", null, Boolean.FALSE}, {list, "!=", null, Boolean.TRUE}, {null, "==", null, Boolean.TRUE}, {null, "==", list, Boolean.FALSE}, {null, "!=", list, Boolean.TRUE},
+ {new BigDecimal( "42.42" ), "<", new BigDecimal( "43" ), Boolean.TRUE}, {new BigDecimal( "42.42" ), ">", new BigDecimal( "43" ), Boolean.FALSE}, {new BigDecimal( "42.42" ), "<=", new BigDecimal( "42.42" ), Boolean.TRUE},
+ {new BigInteger( "42" ), ">=", new BigInteger( "43" ), Boolean.FALSE}, {new BigInteger( "42" ), ">=", new BigInteger( "43" ), Boolean.FALSE}, {list, "excludes", "baz", Boolean.TRUE}, {list, "excludes", "foo", Boolean.FALSE}
};
@@ -70,17 +56,8 @@
final Object[] field = new Object[]{"foo", "bar"};
- final Object[][] data = {
- {field, "==", new Object[]{"foo"}, Boolean.FALSE},
- {field, "==", field, Boolean.TRUE},
- {field, "!=", new Object[]{"foo"}, Boolean.TRUE},
- {field, "contains", "foo", Boolean.TRUE},
- {field, "!=", null, Boolean.TRUE},
- {field, "==", null, Boolean.FALSE},
- {null, "==", field, Boolean.FALSE},
- {null, "==", null, Boolean.TRUE},
- {null, "!=", field, Boolean.TRUE},
- {null, "!=", null, Boolean.FALSE}};
+ final Object[][] data = {{field, "==", new Object[]{"foo"}, Boolean.FALSE}, {field, "==", field, Boolean.TRUE}, {field, "!=", new Object[]{"foo"}, Boolean.TRUE}, {field, "contains", "foo", Boolean.TRUE}, {field, "!=", null, Boolean.TRUE},
+ {field, "==", null, Boolean.FALSE}, {null, "==", field, Boolean.FALSE}, {null, "==", null, Boolean.TRUE}, {null, "!=", field, Boolean.TRUE}, {null, "!=", null, Boolean.FALSE}};
runEvaluatorTest( data,
ValueType.ARRAY_TYPE );
@@ -89,21 +66,9 @@
public void testString() {
- final Object[][] data = {
- {"foo", "==", "bar", Boolean.FALSE},
- {"foo", "==", "foo", Boolean.TRUE},
- {"foo", "!=", "bar", Boolean.TRUE},
- {"something foo", "matches", ".*foo", Boolean.TRUE},
- {"foo", "matches", ".*foo", Boolean.TRUE},
- {"foo", "matches", "bar", Boolean.FALSE},
- {null, "matches", ".*foo", Boolean.FALSE},
- {"foo", "==", null, Boolean.FALSE},
- {"foo", "!=", null, Boolean.TRUE},
- {null, "==", null, Boolean.TRUE},
- {"foo", "!=", null, Boolean.TRUE},
- {null, "!=", "foo", Boolean.TRUE},
- {null, "!=", null, Boolean.FALSE}
- };
+ final Object[][] data = {{"foo", "==", "bar", Boolean.FALSE}, {"foo", "==", "foo", Boolean.TRUE}, {"foo", "!=", "bar", Boolean.TRUE}, {"something foo", "matches", ".*foo", Boolean.TRUE}, {"foo", "matches", ".*foo", Boolean.TRUE},
+ {"foo", "matches", "bar", Boolean.FALSE}, {null, "matches", ".*foo", Boolean.FALSE}, {"foo", "==", null, Boolean.FALSE}, {"foo", "!=", null, Boolean.TRUE}, {null, "==", null, Boolean.TRUE}, {"foo", "!=", null, Boolean.TRUE},
+ {null, "!=", "foo", Boolean.TRUE}, {null, "!=", null, Boolean.FALSE}};
runEvaluatorTest( data,
ValueType.STRING_TYPE );
@@ -112,33 +77,23 @@
public void testInteger() {
- final Object[][] data = {
- {new Integer( 42 ), "==", new Integer( 42 ), Boolean.TRUE},
- {new Integer( 42 ), "<", new Integer( 43 ), Boolean.TRUE},
- {new Integer( 42 ), ">=", new Integer( 41 ), Boolean.TRUE},
- {new Integer( 42 ), "!=", new Integer( 41 ), Boolean.TRUE},
- {new Integer( 42 ), ">", new Integer( 41 ), Boolean.TRUE},
- {new Integer( 42 ), "<=", new Integer( 42 ), Boolean.TRUE},
- {new Integer( 42 ), ">", new Integer( 100 ), Boolean.FALSE},
- {new Integer( 42 ), "==", null, Boolean.FALSE},
- {new Integer( 42 ), "!=", null, Boolean.TRUE},
- {null, "==", null, Boolean.TRUE},
- {null, "==", new Integer( 42 ), Boolean.FALSE},
- {null, "!=", null, Boolean.FALSE},
- {null, "!=", new Integer( 42 ), Boolean.TRUE}};
+ final Object[][] data = {{new Integer( 42 ), "==", new Integer( 42 ), Boolean.TRUE}, {new Integer( 42 ), "<", new Integer( 43 ), Boolean.TRUE}, {new Integer( 42 ), ">=", new Integer( 41 ), Boolean.TRUE},
+ {new Integer( 42 ), "!=", new Integer( 41 ), Boolean.TRUE}, {new Integer( 42 ), ">", new Integer( 41 ), Boolean.TRUE}, {new Integer( 42 ), "<=", new Integer( 42 ), Boolean.TRUE},
+ {new Integer( 42 ), ">", new Integer( 100 ), Boolean.FALSE}, {new Integer( 42 ), "==", null, Boolean.FALSE}, {new Integer( 42 ), "!=", null, Boolean.TRUE}, {null, "==", null, Boolean.TRUE},
+ {null, "==", new Integer( 42 ), Boolean.FALSE}, {null, "!=", null, Boolean.FALSE}, {null, "!=", new Integer( 42 ), Boolean.TRUE}};
runEvaluatorTest( data,
ValueType.INTEGER_TYPE );
}
-
+
public void testBigDecimal() {
- ValueType type = ValueType.determineValueType(BigDecimal.class);
- assertSame(type, ValueType.BIG_DECIMAL_TYPE);
-
- final Object[][] data = {{new BigDecimal( 42 ), "==", new BigDecimal( 42 ), Boolean.TRUE},
- {new BigDecimal( 42 ), "<", new BigDecimal( 43 ), Boolean.TRUE}, {new BigDecimal( 42 ), ">=", new BigDecimal( 41 ), Boolean.TRUE},
+ final ValueType type = ValueType.determineValueType( BigDecimal.class );
+ assertSame( type,
+ ValueType.BIG_DECIMAL_TYPE );
+
+ final Object[][] data = {{new BigDecimal( 42 ), "==", new BigDecimal( 42 ), Boolean.TRUE}, {new BigDecimal( 42 ), "<", new BigDecimal( 43 ), Boolean.TRUE}, {new BigDecimal( 42 ), ">=", new BigDecimal( 41 ), Boolean.TRUE},
{new BigDecimal( 42 ), "!=", new BigDecimal( 41 ), Boolean.TRUE}, {new BigDecimal( 42 ), ">", new BigDecimal( 41 ), Boolean.TRUE}, {new BigDecimal( 42 ), "<=", new BigDecimal( 42 ), Boolean.TRUE},
{new BigDecimal( 42 ), ">", new BigDecimal( 100 ), Boolean.FALSE}, {new BigDecimal( 42 ), "==", null, Boolean.FALSE}, {new BigDecimal( 42 ), "!=", null, Boolean.TRUE}, {null, "==", new BigDecimal( 42 ), Boolean.FALSE},
{null, "!=", new BigDecimal( 42 ), Boolean.TRUE}};
@@ -146,17 +101,15 @@
runEvaluatorTest( data,
ValueType.BIG_DECIMAL_TYPE );
-
-
}
-
+
public void testBigInteger() {
- ValueType type = ValueType.determineValueType(BigInteger.class);
- assertSame(type, ValueType.BIG_INTEGER_TYPE);
-
- final Object[][] data = {{new BigInteger( "42" ), "==", new BigInteger( "42" ), Boolean.TRUE},
- {new BigInteger( "42" ), "<", new BigInteger( "43" ), Boolean.TRUE}, {new BigInteger( "42" ), ">=", new BigInteger( "41" ), Boolean.TRUE},
+ final ValueType type = ValueType.determineValueType( BigInteger.class );
+ assertSame( type,
+ ValueType.BIG_INTEGER_TYPE );
+
+ final Object[][] data = {{new BigInteger( "42" ), "==", new BigInteger( "42" ), Boolean.TRUE}, {new BigInteger( "42" ), "<", new BigInteger( "43" ), Boolean.TRUE}, {new BigInteger( "42" ), ">=", new BigInteger( "41" ), Boolean.TRUE},
{new BigInteger( "42" ), "!=", new BigInteger( "41" ), Boolean.TRUE}, {new BigInteger( "42" ), ">", new BigInteger( "41" ), Boolean.TRUE}, {new BigInteger( "42" ), "<=", new BigInteger( "42" ), Boolean.TRUE},
{new BigInteger( "42" ), ">", new BigInteger( "100" ), Boolean.FALSE}, {new BigInteger( "42" ), "==", null, Boolean.FALSE}, {new BigInteger( "42" ), "!=", null, Boolean.TRUE}, {null, "==", new BigInteger( "42" ), Boolean.FALSE},
{null, "!=", new BigInteger( "42" ), Boolean.TRUE}};
@@ -164,24 +117,14 @@
runEvaluatorTest( data,
ValueType.BIG_INTEGER_TYPE );
-
+ }
- }
-
-
public void testShort() {
//Test data: Obj1, Operand, Obj2
- final Object[][] data = {
- {new Short( (short) 42 ), "==", new Short( (short) 42 ), Boolean.TRUE},
- {new Short( (short) 42 ), "<", new Short( (short) 43 ), Boolean.TRUE},
- {new Short( (short) 42 ), ">=", new Short( (short) 41 ), Boolean.TRUE},
- {new Short( (short) 42 ), "!=", new Short( (short) 41 ), Boolean.TRUE},
- {new Short( (short) 42 ), "!=", null, Boolean.TRUE},
- {null, "==", null, Boolean.TRUE},
- {null, "==", new Short( (short) 42 ), Boolean.FALSE},
- {null, "!=", null, Boolean.FALSE},
- {null, "!=", new Short( (short) 42 ), Boolean.TRUE}};
+ final Object[][] data = {{new Short( (short) 42 ), "==", new Short( (short) 42 ), Boolean.TRUE}, {new Short( (short) 42 ), "<", new Short( (short) 43 ), Boolean.TRUE}, {new Short( (short) 42 ), ">=", new Short( (short) 41 ), Boolean.TRUE},
+ {new Short( (short) 42 ), "!=", new Short( (short) 41 ), Boolean.TRUE}, {new Short( (short) 42 ), "!=", null, Boolean.TRUE}, {null, "==", null, Boolean.TRUE}, {null, "==", new Short( (short) 42 ), Boolean.FALSE},
+ {null, "!=", null, Boolean.FALSE}, {null, "!=", new Short( (short) 42 ), Boolean.TRUE}};
runEvaluatorTest( data,
ValueType.SHORT_TYPE );
@@ -190,16 +133,9 @@
public void testBoolean() {
//Test data: Obj1, Operand, Obj2
- final Object[][] data = {
- {new Boolean( true ), "==", new Boolean( true ), Boolean.TRUE},
- {new Boolean( false ), "!=", new Boolean( true ), Boolean.TRUE},
- {new Boolean( true ), "==", new Boolean( false ), Boolean.FALSE},
- {new Boolean( true ), "!=", new Boolean( false ), Boolean.TRUE},
- {new Boolean( true ), "==", null, Boolean.FALSE},
- {new Boolean( true ), "!=", null, Boolean.TRUE},
- {null, "==", new Boolean( true ), Boolean.FALSE},
- {null, "!=", new Boolean( true ), Boolean.TRUE},
- {null, "==", null, Boolean.TRUE}
+ final Object[][] data = {{new Boolean( true ), "==", new Boolean( true ), Boolean.TRUE}, {new Boolean( false ), "!=", new Boolean( true ), Boolean.TRUE}, {new Boolean( true ), "==", new Boolean( false ), Boolean.FALSE},
+ {new Boolean( true ), "!=", new Boolean( false ), Boolean.TRUE}, {new Boolean( true ), "==", null, Boolean.FALSE}, {new Boolean( true ), "!=", null, Boolean.TRUE}, {null, "==", new Boolean( true ), Boolean.FALSE},
+ {null, "!=", new Boolean( true ), Boolean.TRUE}, {null, "==", null, Boolean.TRUE}
};
@@ -208,87 +144,40 @@
}
public void testDouble() {
- final Object[][] data = {
- {new Double( 42 ), "==", new Double( 42 ), Boolean.TRUE},
- {new Double( 42 ), "<", new Double( 43 ), Boolean.TRUE},
- {new Double( 42 ), ">=", new Double( 41 ), Boolean.TRUE},
- {new Double( 42 ), "!=", new Double( 41 ), Boolean.TRUE},
- {new Double( 42 ), ">", new Double( 41 ), Boolean.TRUE},
- {new Double( 42 ), ">=", new Double( 41 ), Boolean.TRUE},
- {new Double( 42 ), ">=", new Double( 42 ), Boolean.TRUE},
- {new Double( 42 ), ">=", new Double( 100 ), Boolean.FALSE},
- {new Double( 42 ), "<", new Double( 1 ), Boolean.FALSE},
- {new Double( 42 ), "==", null, Boolean.FALSE},
- {new Double( 42 ), "!=", null, Boolean.TRUE},
- {null, "==", null, Boolean.TRUE},
- {null, "==", new Double( 42 ), Boolean.FALSE},
- {null, "!=", null, Boolean.FALSE},
- {null, "!=", new Double( 42 ), Boolean.TRUE}};
+ final Object[][] data = {{new Double( 42 ), "==", new Double( 42 ), Boolean.TRUE}, {new Double( 42 ), "<", new Double( 43 ), Boolean.TRUE}, {new Double( 42 ), ">=", new Double( 41 ), Boolean.TRUE},
+ {new Double( 42 ), "!=", new Double( 41 ), Boolean.TRUE}, {new Double( 42 ), ">", new Double( 41 ), Boolean.TRUE}, {new Double( 42 ), ">=", new Double( 41 ), Boolean.TRUE}, {new Double( 42 ), ">=", new Double( 42 ), Boolean.TRUE},
+ {new Double( 42 ), ">=", new Double( 100 ), Boolean.FALSE}, {new Double( 42 ), "<", new Double( 1 ), Boolean.FALSE}, {new Double( 42 ), "==", null, Boolean.FALSE}, {new Double( 42 ), "!=", null, Boolean.TRUE},
+ {null, "==", null, Boolean.TRUE}, {null, "==", new Double( 42 ), Boolean.FALSE}, {null, "!=", null, Boolean.FALSE}, {null, "!=", new Double( 42 ), Boolean.TRUE}};
runEvaluatorTest( data,
ValueType.DOUBLE_TYPE );
}
public void testFloat() {
- final Object[][] data = {
- {new Float( 42 ), "==", new Float( 42 ), Boolean.TRUE},
- {new Float( 42 ), "<", new Float( 43 ), Boolean.TRUE},
- {new Float( 42 ), ">=", new Float( 41 ), Boolean.TRUE},
- {new Float( 42 ), "!=", new Float( 41 ), Boolean.TRUE},
- {new Float( 42 ), ">", new Float( 41 ), Boolean.TRUE},
- {new Float( 42 ), ">=", new Float( 41 ), Boolean.TRUE},
- {new Float( 42 ), ">=", new Float( 42 ), Boolean.TRUE},
- {new Float( 42 ), ">=", new Float( 100 ), Boolean.FALSE},
- {new Float( 42 ), "<", new Float( 1 ), Boolean.FALSE},
- {new Float( 42 ), "==", null, Boolean.FALSE},
- {new Float( 42 ), "!=", null, Boolean.TRUE},
- {null, "==", null, Boolean.TRUE},
- {null, "==", new Float( 42 ), Boolean.FALSE},
- {null, "!=", null, Boolean.FALSE},
- {null, "!=", new Float( 42 ), Boolean.TRUE}};
+ final Object[][] data = {{new Float( 42 ), "==", new Float( 42 ), Boolean.TRUE}, {new Float( 42 ), "<", new Float( 43 ), Boolean.TRUE}, {new Float( 42 ), ">=", new Float( 41 ), Boolean.TRUE},
+ {new Float( 42 ), "!=", new Float( 41 ), Boolean.TRUE}, {new Float( 42 ), ">", new Float( 41 ), Boolean.TRUE}, {new Float( 42 ), ">=", new Float( 41 ), Boolean.TRUE}, {new Float( 42 ), ">=", new Float( 42 ), Boolean.TRUE},
+ {new Float( 42 ), ">=", new Float( 100 ), Boolean.FALSE}, {new Float( 42 ), "<", new Float( 1 ), Boolean.FALSE}, {new Float( 42 ), "==", null, Boolean.FALSE}, {new Float( 42 ), "!=", null, Boolean.TRUE},
+ {null, "==", null, Boolean.TRUE}, {null, "==", new Float( 42 ), Boolean.FALSE}, {null, "!=", null, Boolean.FALSE}, {null, "!=", new Float( 42 ), Boolean.TRUE}};
runEvaluatorTest( data,
ValueType.FLOAT_TYPE );
}
public void testLong() {
- final Object[][] data = {
- {new Long( 42 ), "==", new Long( 42 ), Boolean.TRUE},
- {new Long( 42 ), "<", new Long( 43 ), Boolean.TRUE},
- {new Long( 42 ), ">=", new Long( 41 ), Boolean.TRUE},
- {new Long( 42 ), "!=", new Long( 41 ), Boolean.TRUE},
- {new Long( 42 ), ">", new Long( 41 ), Boolean.TRUE},
- {new Long( 42 ), ">=", new Long( 41 ), Boolean.TRUE},
- {new Long( 42 ), ">=", new Long( 42 ), Boolean.TRUE},
- {new Long( 42 ), ">=", new Long( 100 ), Boolean.FALSE},
- {new Long( 42 ), "<", new Long( 1 ), Boolean.FALSE},
- {new Long( 42 ), "==", null, Boolean.FALSE},
- {new Long( 42 ), "!=", null, Boolean.TRUE},
- {null, "==", null, Boolean.TRUE},
- {null, "==", new Long( 42 ), Boolean.FALSE},
- {null, "!=", null, Boolean.FALSE},
- {null, "!=", new Long( 42 ), Boolean.TRUE}};
+ final Object[][] data = {{new Long( 42 ), "==", new Long( 42 ), Boolean.TRUE}, {new Long( 42 ), "<", new Long( 43 ), Boolean.TRUE}, {new Long( 42 ), ">=", new Long( 41 ), Boolean.TRUE}, {new Long( 42 ), "!=", new Long( 41 ), Boolean.TRUE},
+ {new Long( 42 ), ">", new Long( 41 ), Boolean.TRUE}, {new Long( 42 ), ">=", new Long( 41 ), Boolean.TRUE}, {new Long( 42 ), ">=", new Long( 42 ), Boolean.TRUE}, {new Long( 42 ), ">=", new Long( 100 ), Boolean.FALSE},
+ {new Long( 42 ), "<", new Long( 1 ), Boolean.FALSE}, {new Long( 42 ), "==", null, Boolean.FALSE}, {new Long( 42 ), "!=", null, Boolean.TRUE}, {null, "==", null, Boolean.TRUE}, {null, "==", new Long( 42 ), Boolean.FALSE},
+ {null, "!=", null, Boolean.FALSE}, {null, "!=", new Long( 42 ), Boolean.TRUE}};
runEvaluatorTest( data,
ValueType.LONG_TYPE );
}
public void testCharacter() {
- final Object[][] data = {
- {new Character( 'a' ), "==", new Character( 'a' ), Boolean.TRUE},
- {new Character( 'a' ), "<", new Character( 'b' ), Boolean.TRUE},
- {new Character( 'a' ), ">=", new Character( 'a' ), Boolean.TRUE},
- {new Character( 'a' ), "!=", new Character( 'Z' ), Boolean.TRUE},
- {new Character( 'z' ), ">", new Character( 'a' ), Boolean.TRUE},
- {new Character( 'z' ), ">=", new Character( 'z' ), Boolean.TRUE},
- {new Character( 'z' ), ">=", new Character( 'a' ), Boolean.TRUE},
- {new Character( 'a' ), ">=", new Character( 'z' ), Boolean.FALSE},
- {new Character( 'z' ), "<", new Character( 'a' ), Boolean.FALSE},
- {new Character( 'z' ), "==", null, Boolean.FALSE},
- {new Character( 'z' ), "!=", null, Boolean.TRUE},
- {null, "==", null, Boolean.TRUE},
- {null, "==", new Character( 'z' ), Boolean.FALSE},
- {null, "!=", null, Boolean.FALSE},
+ final Object[][] data = {{new Character( 'a' ), "==", new Character( 'a' ), Boolean.TRUE}, {new Character( 'a' ), "<", new Character( 'b' ), Boolean.TRUE}, {new Character( 'a' ), ">=", new Character( 'a' ), Boolean.TRUE},
+ {new Character( 'a' ), "!=", new Character( 'Z' ), Boolean.TRUE}, {new Character( 'z' ), ">", new Character( 'a' ), Boolean.TRUE}, {new Character( 'z' ), ">=", new Character( 'z' ), Boolean.TRUE},
+ {new Character( 'z' ), ">=", new Character( 'a' ), Boolean.TRUE}, {new Character( 'a' ), ">=", new Character( 'z' ), Boolean.FALSE}, {new Character( 'z' ), "<", new Character( 'a' ), Boolean.FALSE},
+ {new Character( 'z' ), "==", null, Boolean.FALSE}, {new Character( 'z' ), "!=", null, Boolean.TRUE}, {null, "==", null, Boolean.TRUE}, {null, "==", new Character( 'z' ), Boolean.FALSE}, {null, "!=", null, Boolean.FALSE},
{null, "!=", new Character( 'z' ), Boolean.TRUE}};
runEvaluatorTest( data,
ValueType.CHAR_TYPE );
@@ -300,46 +189,21 @@
Locale.ENGLISH );
//note that strings are also allowed on the right
- final Object[][] data = {
- {df.parse( "10-Jul-1974" ), "==", df.parse( "10-Jul-1974" ), Boolean.TRUE},
- {df.parse( "10-Jul-1974" ), "<", df.parse( "11-Jul-1974" ), Boolean.TRUE},
- {df.parse( "10-Jul-1974" ), ">=", df.parse( "10-Jul-1974" ), Boolean.TRUE},
- {df.parse( "10-Jul-1974" ), "!=", df.parse( "11-Jul-1974" ), Boolean.TRUE},
- {df.parse( "10-Jul-2000" ), ">", df.parse( "10-Jul-1974" ), Boolean.TRUE},
- {df.parse( "10-Jul-1974" ), ">=", df.parse( "10-Jul-1974" ), Boolean.TRUE},
- {df.parse( "11-Jul-1974" ), ">=", df.parse( "10-Jul-1974" ), Boolean.TRUE},
- {df.parse( "10-Jul-1974" ), ">=", df.parse( "11-Jul-1974" ), Boolean.FALSE},
- {df.parse( "10-Jul-2000" ), "<", df.parse( "10-Jul-1974" ), Boolean.FALSE},
- {df.parse( "10-Jul-1974" ), "<", "11-Jul-1974", Boolean.TRUE},
- {df.parse( "10-Jul-1974" ), ">=", "10-Jul-1974", Boolean.TRUE},
- {df.parse( "10-Jul-1974" ), "!=", "11-Jul-1974", Boolean.TRUE},
- {df.parse( "10-Jul-2000" ), ">", "10-Jul-1974", Boolean.TRUE},
- {df.parse( "10-Jul-1974" ), ">=", "10-Jul-1974", Boolean.TRUE},
- {df.parse( "11-Jul-1974" ), ">=", "10-Jul-1974", Boolean.TRUE},
- {df.parse( "10-Jul-1974" ), ">=", "11-Jul-1974", Boolean.FALSE},
- {df.parse( "10-Jul-1974" ), "==", null, Boolean.FALSE},
- {df.parse( "10-Jul-1974" ), "!=", null, Boolean.TRUE},
- {null, "==", null, Boolean.TRUE},
- {null, "==", df.parse( "10-Jul-1974" ), Boolean.FALSE},
- {null, "!=", null, Boolean.FALSE},
- {null, "!=", df.parse( "10-Jul-1974" ), Boolean.TRUE}};
+ final Object[][] data = {{df.parse( "10-Jul-1974" ), "==", df.parse( "10-Jul-1974" ), Boolean.TRUE}, {df.parse( "10-Jul-1974" ), "<", df.parse( "11-Jul-1974" ), Boolean.TRUE},
+ {df.parse( "10-Jul-1974" ), ">=", df.parse( "10-Jul-1974" ), Boolean.TRUE}, {df.parse( "10-Jul-1974" ), "!=", df.parse( "11-Jul-1974" ), Boolean.TRUE}, {df.parse( "10-Jul-2000" ), ">", df.parse( "10-Jul-1974" ), Boolean.TRUE},
+ {df.parse( "10-Jul-1974" ), ">=", df.parse( "10-Jul-1974" ), Boolean.TRUE}, {df.parse( "11-Jul-1974" ), ">=", df.parse( "10-Jul-1974" ), Boolean.TRUE}, {df.parse( "10-Jul-1974" ), ">=", df.parse( "11-Jul-1974" ), Boolean.FALSE},
+ {df.parse( "10-Jul-2000" ), "<", df.parse( "10-Jul-1974" ), Boolean.FALSE}, {df.parse( "10-Jul-1974" ), "<", "11-Jul-1974", Boolean.TRUE}, {df.parse( "10-Jul-1974" ), ">=", "10-Jul-1974", Boolean.TRUE},
+ {df.parse( "10-Jul-1974" ), "!=", "11-Jul-1974", Boolean.TRUE}, {df.parse( "10-Jul-2000" ), ">", "10-Jul-1974", Boolean.TRUE}, {df.parse( "10-Jul-1974" ), ">=", "10-Jul-1974", Boolean.TRUE},
+ {df.parse( "11-Jul-1974" ), ">=", "10-Jul-1974", Boolean.TRUE}, {df.parse( "10-Jul-1974" ), ">=", "11-Jul-1974", Boolean.FALSE}, {df.parse( "10-Jul-1974" ), "==", null, Boolean.FALSE},
+ {df.parse( "10-Jul-1974" ), "!=", null, Boolean.TRUE}, {null, "==", null, Boolean.TRUE}, {null, "==", df.parse( "10-Jul-1974" ), Boolean.FALSE}, {null, "!=", null, Boolean.FALSE}, {null, "!=", df.parse( "10-Jul-1974" ), Boolean.TRUE}};
runEvaluatorTest( data,
ValueType.DATE_TYPE );
}
public void testByte() {
- final Object[][] data = {
- {new Byte( "1" ), "==", new Byte( "1" ), Boolean.TRUE},
- {new Byte( "1" ), "==", new Byte( "2" ), Boolean.FALSE},
- {new Byte( "1" ), "!=", new Byte( "2" ), Boolean.TRUE},
- {new Byte( "1" ), "!=", new Byte( "1" ), Boolean.FALSE},
- {new Byte( "1" ), "<=", new Byte( "1" ), Boolean.TRUE},
- {new Byte( "1" ), "==", null, Boolean.FALSE},
- {new Byte( "1" ), "!=", null, Boolean.TRUE},
- {null, "==", null, Boolean.TRUE},
- {null, "==", new Byte( "1" ), Boolean.FALSE},
- {null, "!=", null, Boolean.FALSE},
- {null, "!=", new Byte( "1" ), Boolean.TRUE}};
+ final Object[][] data = {{new Byte( "1" ), "==", new Byte( "1" ), Boolean.TRUE}, {new Byte( "1" ), "==", new Byte( "2" ), Boolean.FALSE}, {new Byte( "1" ), "!=", new Byte( "2" ), Boolean.TRUE},
+ {new Byte( "1" ), "!=", new Byte( "1" ), Boolean.FALSE}, {new Byte( "1" ), "<=", new Byte( "1" ), Boolean.TRUE}, {new Byte( "1" ), "==", null, Boolean.FALSE}, {new Byte( "1" ), "!=", null, Boolean.TRUE},
+ {null, "==", null, Boolean.TRUE}, {null, "==", new Byte( "1" ), Boolean.FALSE}, {null, "!=", null, Boolean.FALSE}, {null, "!=", new Byte( "1" ), Boolean.TRUE}};
runEvaluatorTest( data,
ValueType.BYTE_TYPE );
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/FieldFactoryTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/FieldFactoryTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/FieldFactoryTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -9,16 +9,20 @@
public class FieldFactoryTest extends TestCase {
- public void testBigDecimal() {
- FieldValue val = FieldFactory.getFieldValue("42.42", ValueType.BIG_DECIMAL_TYPE);
- assertEquals(BigDecimal.class, val.getValue().getClass());
- assertTrue(val.getValue().equals(new BigDecimal("42.42")));
- }
-
- public void testBigInteger() {
- FieldValue val = FieldFactory.getFieldValue("424242", ValueType.BIG_INTEGER_TYPE);
- assertEquals(BigInteger.class, val.getValue().getClass());
- assertTrue(val.getValue().equals(new BigInteger("424242")));
- }
-
+ public void testBigDecimal() {
+ final FieldValue val = FieldFactory.getFieldValue( "42.42",
+ ValueType.BIG_DECIMAL_TYPE );
+ assertEquals( BigDecimal.class,
+ val.getValue().getClass() );
+ assertTrue( val.getValue().equals( new BigDecimal( "42.42" ) ) );
+ }
+
+ public void testBigInteger() {
+ final FieldValue val = FieldFactory.getFieldValue( "424242",
+ ValueType.BIG_INTEGER_TYPE );
+ assertEquals( BigInteger.class,
+ val.getValue().getClass() );
+ assertTrue( val.getValue().equals( new BigInteger( "424242" ) ) );
+ }
+
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/ShadowProxyFactoryTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/ShadowProxyFactoryTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/ShadowProxyFactoryTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -22,215 +22,261 @@
public void testProxyForClass() {
try {
// creating original object
- String originalType = "stilton";
- int originalPrice = 15;
- Cheese cheese = new Cheese(originalType, originalPrice);
-
+ final String originalType = "stilton";
+ final int originalPrice = 15;
+ final Cheese cheese = new Cheese( originalType,
+ originalPrice );
+
// creating proxy
- Class proxy = ShadowProxyFactory.getProxy( Cheese.class );
- Cheese cheeseProxy = (Cheese) proxy.getConstructor( new Class[] { Cheese.class } ).newInstance( new Object[] { cheese } );
+ final Class proxy = ShadowProxyFactory.getProxy( Cheese.class );
+ final Cheese cheeseProxy = (Cheese) proxy.getConstructor( new Class[]{Cheese.class} ).newInstance( new Object[]{cheese} );
// proxy is proxying the values
- Assert.assertEquals( originalType, cheeseProxy.getType() );
- Assert.assertEquals( originalPrice, cheeseProxy.getPrice() );
-
+ Assert.assertEquals( originalType,
+ cheeseProxy.getType() );
+ Assert.assertEquals( originalPrice,
+ cheeseProxy.getPrice() );
+
// changing original values
- String actualType = "rotten stilton";
- int actualPrice = 1;
+ final String actualType = "rotten stilton";
+ final int actualPrice = 1;
cheese.setType( actualType );
cheese.setPrice( actualPrice );
-
+
// proxy does not see changes
- Assert.assertEquals( actualType, cheese.getType() );
+ Assert.assertEquals( actualType,
+ cheese.getType() );
Assert.assertFalse( actualType.equals( cheeseProxy.getType() ) );
- Assert.assertEquals( originalType, cheeseProxy.getType() );
- Assert.assertEquals( actualPrice, cheese.getPrice() );
+ Assert.assertEquals( originalType,
+ cheeseProxy.getType() );
+ Assert.assertEquals( actualPrice,
+ cheese.getPrice() );
Assert.assertFalse( actualPrice == cheeseProxy.getPrice() );
- Assert.assertEquals( originalPrice, cheeseProxy.getPrice() );
-
+ Assert.assertEquals( originalPrice,
+ cheeseProxy.getPrice() );
+
// reseting proxy
((ShadowProxy) cheeseProxy).updateProxy();
-
+
// now proxy see changes
- Assert.assertEquals( actualType, cheese.getType() );
- Assert.assertEquals( actualType, cheeseProxy.getType() );
+ Assert.assertEquals( actualType,
+ cheese.getType() );
+ Assert.assertEquals( actualType,
+ cheeseProxy.getType() );
Assert.assertFalse( originalType.equals( cheeseProxy.getType() ) );
- Assert.assertEquals( actualPrice, cheese.getPrice() );
- Assert.assertEquals( actualPrice, cheeseProxy.getPrice() );
+ Assert.assertEquals( actualPrice,
+ cheese.getPrice() );
+ Assert.assertEquals( actualPrice,
+ cheeseProxy.getPrice() );
Assert.assertFalse( originalPrice == cheeseProxy.getPrice() );
-
- } catch ( Exception e ) {
- fail("Error: "+e.getMessage());
+
+ } catch ( final Exception e ) {
+ fail( "Error: " + e.getMessage() );
}
}
-
+
public void testProxyForInterface() {
try {
// creating original object
- String originalType = "stilton";
- int originalPrice = 15;
- Cheese cheese = new Cheese(originalType, originalPrice);
-
+ final String originalType = "stilton";
+ final int originalPrice = 15;
+ final Cheese cheese = new Cheese( originalType,
+ originalPrice );
+
// creating proxy
- Class proxy = ShadowProxyFactory.getProxy( CheeseInterface.class );
- CheeseInterface cheeseProxy = (CheeseInterface) proxy.getConstructor( new Class[] { CheeseInterface.class } ).newInstance( new Object[] { cheese } );
+ final Class proxy = ShadowProxyFactory.getProxy( CheeseInterface.class );
+ final CheeseInterface cheeseProxy = (CheeseInterface) proxy.getConstructor( new Class[]{CheeseInterface.class} ).newInstance( new Object[]{cheese} );
// proxy is proxying the values
- Assert.assertEquals( originalType, cheeseProxy.getType() );
- Assert.assertEquals( originalPrice, cheeseProxy.getPrice() );
-
+ Assert.assertEquals( originalType,
+ cheeseProxy.getType() );
+ Assert.assertEquals( originalPrice,
+ cheeseProxy.getPrice() );
+
// changing original values
- String actualType = "rotten stilton";
- int actualPrice = 1;
+ final String actualType = "rotten stilton";
+ final int actualPrice = 1;
cheese.setType( actualType );
cheese.setPrice( actualPrice );
-
+
// proxy does not see changes
- Assert.assertEquals( actualType, cheese.getType() );
+ Assert.assertEquals( actualType,
+ cheese.getType() );
Assert.assertFalse( actualType.equals( cheeseProxy.getType() ) );
- Assert.assertEquals( originalType, cheeseProxy.getType() );
- Assert.assertEquals( actualPrice, cheese.getPrice() );
+ Assert.assertEquals( originalType,
+ cheeseProxy.getType() );
+ Assert.assertEquals( actualPrice,
+ cheese.getPrice() );
Assert.assertFalse( actualPrice == cheeseProxy.getPrice() );
- Assert.assertEquals( originalPrice, cheeseProxy.getPrice() );
-
+ Assert.assertEquals( originalPrice,
+ cheeseProxy.getPrice() );
+
// reseting proxy
((ShadowProxy) cheeseProxy).updateProxy();
-
+
// now proxy see changes
- Assert.assertEquals( actualType, cheese.getType() );
- Assert.assertEquals( actualType, cheeseProxy.getType() );
+ Assert.assertEquals( actualType,
+ cheese.getType() );
+ Assert.assertEquals( actualType,
+ cheeseProxy.getType() );
Assert.assertFalse( originalType.equals( cheeseProxy.getType() ) );
- Assert.assertEquals( actualPrice, cheese.getPrice() );
- Assert.assertEquals( actualPrice, cheeseProxy.getPrice() );
+ Assert.assertEquals( actualPrice,
+ cheese.getPrice() );
+ Assert.assertEquals( actualPrice,
+ cheeseProxy.getPrice() );
Assert.assertFalse( originalPrice == cheeseProxy.getPrice() );
-
- } catch ( Exception e ) {
- fail("Error: "+e.getMessage());
+
+ } catch ( final Exception e ) {
+ fail( "Error: " + e.getMessage() );
}
}
-
+
public void testProxyForAPIClass() {
try {
// creating original object
- List list = new ArrayList();
-
+ final List list = new ArrayList();
+
// creating proxy
- Class proxy = ShadowProxyFactory.getProxy( ArrayList.class );
- List listProxy = (List) proxy.getConstructor( new Class[] { ArrayList.class } ).newInstance( new Object[] { list } );
+ final Class proxy = ShadowProxyFactory.getProxy( ArrayList.class );
+ final List listProxy = (List) proxy.getConstructor( new Class[]{ArrayList.class} ).newInstance( new Object[]{list} );
// proxy is proxying the values
- Assert.assertEquals( list, listProxy );
-
- } catch ( Exception e ) {
- fail("Error: "+e.getMessage());
+ Assert.assertEquals( list,
+ listProxy );
+
+ } catch ( final Exception e ) {
+ fail( "Error: " + e.getMessage() );
}
}
-
+
public void testEagerProxyForClass() {
try {
// creating original object
- String originalType = "stilton";
- int originalPrice = 15;
- Cheese cheese = new Cheese(originalType, originalPrice);
-
+ final String originalType = "stilton";
+ final int originalPrice = 15;
+ final Cheese cheese = new Cheese( originalType,
+ originalPrice );
+
// creating proxy
- Class proxy = ShadowProxyFactory.getEagerProxy( Cheese.class );
- Cheese cheeseProxy = (Cheese) proxy.getConstructor( new Class[] { Cheese.class } ).newInstance( new Object[] { cheese } );
+ final Class proxy = ShadowProxyFactory.getEagerProxy( Cheese.class );
+ final Cheese cheeseProxy = (Cheese) proxy.getConstructor( new Class[]{Cheese.class} ).newInstance( new Object[]{cheese} );
// proxy is proxying the values
- Assert.assertEquals( originalType, cheeseProxy.getType() );
- Assert.assertEquals( originalPrice, cheeseProxy.getPrice() );
-
+ Assert.assertEquals( originalType,
+ cheeseProxy.getType() );
+ Assert.assertEquals( originalPrice,
+ cheeseProxy.getPrice() );
+
// changing original values
- String actualType = "rotten stilton";
- int actualPrice = 1;
+ final String actualType = "rotten stilton";
+ final int actualPrice = 1;
cheese.setType( actualType );
cheese.setPrice( actualPrice );
-
+
// proxy does not see changes
- Assert.assertEquals( actualType, cheese.getType() );
+ Assert.assertEquals( actualType,
+ cheese.getType() );
Assert.assertFalse( actualType.equals( cheeseProxy.getType() ) );
- Assert.assertEquals( originalType, cheeseProxy.getType() );
- Assert.assertEquals( actualPrice, cheese.getPrice() );
+ Assert.assertEquals( originalType,
+ cheeseProxy.getType() );
+ Assert.assertEquals( actualPrice,
+ cheese.getPrice() );
Assert.assertFalse( actualPrice == cheeseProxy.getPrice() );
- Assert.assertEquals( originalPrice, cheeseProxy.getPrice() );
-
+ Assert.assertEquals( originalPrice,
+ cheeseProxy.getPrice() );
+
// reseting proxy
((ShadowProxy) cheeseProxy).updateProxy();
-
+
// now proxy see changes
- Assert.assertEquals( actualType, cheese.getType() );
- Assert.assertEquals( actualType, cheeseProxy.getType() );
+ Assert.assertEquals( actualType,
+ cheese.getType() );
+ Assert.assertEquals( actualType,
+ cheeseProxy.getType() );
Assert.assertFalse( originalType.equals( cheeseProxy.getType() ) );
- Assert.assertEquals( actualPrice, cheese.getPrice() );
- Assert.assertEquals( actualPrice, cheeseProxy.getPrice() );
+ Assert.assertEquals( actualPrice,
+ cheese.getPrice() );
+ Assert.assertEquals( actualPrice,
+ cheeseProxy.getPrice() );
Assert.assertFalse( originalPrice == cheeseProxy.getPrice() );
-
- } catch ( Exception e ) {
- fail("Error: "+e.getMessage());
+
+ } catch ( final Exception e ) {
+ fail( "Error: " + e.getMessage() );
}
}
-
+
public void testEagerProxyForInterface() {
try {
// creating original object
- String originalType = "stilton";
- int originalPrice = 15;
- Cheese cheese = new Cheese(originalType, originalPrice);
-
+ final String originalType = "stilton";
+ final int originalPrice = 15;
+ final Cheese cheese = new Cheese( originalType,
+ originalPrice );
+
// creating proxy
- Class proxy = ShadowProxyFactory.getEagerProxy( CheeseInterface.class );
- CheeseInterface cheeseProxy = (CheeseInterface) proxy.getConstructor( new Class[] { CheeseInterface.class } ).newInstance( new Object[] { cheese } );
+ final Class proxy = ShadowProxyFactory.getEagerProxy( CheeseInterface.class );
+ final CheeseInterface cheeseProxy = (CheeseInterface) proxy.getConstructor( new Class[]{CheeseInterface.class} ).newInstance( new Object[]{cheese} );
// proxy is proxying the values
- Assert.assertEquals( originalType, cheeseProxy.getType() );
- Assert.assertEquals( originalPrice, cheeseProxy.getPrice() );
-
+ Assert.assertEquals( originalType,
+ cheeseProxy.getType() );
+ Assert.assertEquals( originalPrice,
+ cheeseProxy.getPrice() );
+
// changing original values
- String actualType = "rotten stilton";
- int actualPrice = 1;
+ final String actualType = "rotten stilton";
+ final int actualPrice = 1;
cheese.setType( actualType );
cheese.setPrice( actualPrice );
-
+
// proxy does not see changes
- Assert.assertEquals( actualType, cheese.getType() );
+ Assert.assertEquals( actualType,
+ cheese.getType() );
Assert.assertFalse( actualType.equals( cheeseProxy.getType() ) );
- Assert.assertEquals( originalType, cheeseProxy.getType() );
- Assert.assertEquals( actualPrice, cheese.getPrice() );
+ Assert.assertEquals( originalType,
+ cheeseProxy.getType() );
+ Assert.assertEquals( actualPrice,
+ cheese.getPrice() );
Assert.assertFalse( actualPrice == cheeseProxy.getPrice() );
- Assert.assertEquals( originalPrice, cheeseProxy.getPrice() );
-
+ Assert.assertEquals( originalPrice,
+ cheeseProxy.getPrice() );
+
// reseting proxy
((ShadowProxy) cheeseProxy).updateProxy();
-
+
// now proxy see changes
- Assert.assertEquals( actualType, cheese.getType() );
- Assert.assertEquals( actualType, cheeseProxy.getType() );
+ Assert.assertEquals( actualType,
+ cheese.getType() );
+ Assert.assertEquals( actualType,
+ cheeseProxy.getType() );
Assert.assertFalse( originalType.equals( cheeseProxy.getType() ) );
- Assert.assertEquals( actualPrice, cheese.getPrice() );
- Assert.assertEquals( actualPrice, cheeseProxy.getPrice() );
+ Assert.assertEquals( actualPrice,
+ cheese.getPrice() );
+ Assert.assertEquals( actualPrice,
+ cheeseProxy.getPrice() );
Assert.assertFalse( originalPrice == cheeseProxy.getPrice() );
-
- } catch ( Exception e ) {
- fail("Error: "+e.getMessage());
+
+ } catch ( final Exception e ) {
+ fail( "Error: " + e.getMessage() );
}
}
-
+
public void testEagerProxyForAPIClass() {
try {
// creating original object
- List list = new ArrayList();
-
+ final List list = new ArrayList();
+
// creating proxy
- Class proxy = ShadowProxyFactory.getEagerProxy( ArrayList.class );
- List listProxy = (List) proxy.getConstructor( new Class[] { ArrayList.class } ).newInstance( new Object[] { list } );
+ final Class proxy = ShadowProxyFactory.getEagerProxy( ArrayList.class );
+ final List listProxy = (List) proxy.getConstructor( new Class[]{ArrayList.class} ).newInstance( new Object[]{list} );
// proxy is proxying the values
- Assert.assertEquals( list, listProxy );
-
- } catch ( Exception e ) {
- fail("Error: "+e.getMessage());
+ Assert.assertEquals( list,
+ listProxy );
+
+ } catch ( final Exception e ) {
+ fail( "Error: " + e.getMessage() );
}
}
-
+
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/TestBean.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/TestBean.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/TestBean.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -42,38 +42,38 @@
}
public boolean isBooleanAttr() {
- return booleanAttr;
+ return this.booleanAttr;
}
public byte getByteAttr() {
- return byteAttr;
+ return this.byteAttr;
}
public char getCharAttr() {
- return charAttr;
+ return this.charAttr;
}
public double getDoubleAttr() {
- return doubleAttr;
+ return this.doubleAttr;
}
public float getFloatAttr() {
- return floatAttr;
+ return this.floatAttr;
}
public int getIntAttr() {
- return intAttr;
+ return this.intAttr;
}
public List getListAttr() {
- return listAttr;
+ return this.listAttr;
}
public long getLongAttr() {
- return longAttr;
+ return this.longAttr;
}
public short getShortAttr() {
- return shortAttr;
+ return this.shortAttr;
}
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/ValueTypeTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/ValueTypeTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/ValueTypeTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -14,24 +14,24 @@
}
public void testIsBoolean() {
- Assert.assertTrue(ValueType.BOOLEAN_TYPE.isBoolean());
- Assert.assertTrue(ValueType.PBOOLEAN_TYPE.isBoolean());
+ Assert.assertTrue( ValueType.BOOLEAN_TYPE.isBoolean() );
+ Assert.assertTrue( ValueType.PBOOLEAN_TYPE.isBoolean() );
}
public void testIsNumber() {
- Assert.assertTrue(ValueType.PBYTE_TYPE.isNumber());
- Assert.assertTrue(ValueType.PSHORT_TYPE.isNumber());
- Assert.assertTrue(ValueType.PINTEGER_TYPE.isNumber());
- Assert.assertTrue(ValueType.PLONG_TYPE.isNumber());
- Assert.assertTrue(ValueType.PFLOAT_TYPE.isNumber());
- Assert.assertTrue(ValueType.PDOUBLE_TYPE.isNumber());
- Assert.assertTrue(ValueType.BYTE_TYPE.isNumber());
- Assert.assertTrue(ValueType.SHORT_TYPE.isNumber());
- Assert.assertTrue(ValueType.INTEGER_TYPE.isNumber());
- Assert.assertTrue(ValueType.LONG_TYPE.isNumber());
- Assert.assertTrue(ValueType.FLOAT_TYPE.isNumber());
- Assert.assertTrue(ValueType.DOUBLE_TYPE.isNumber());
-
+ Assert.assertTrue( ValueType.PBYTE_TYPE.isNumber() );
+ Assert.assertTrue( ValueType.PSHORT_TYPE.isNumber() );
+ Assert.assertTrue( ValueType.PINTEGER_TYPE.isNumber() );
+ Assert.assertTrue( ValueType.PLONG_TYPE.isNumber() );
+ Assert.assertTrue( ValueType.PFLOAT_TYPE.isNumber() );
+ Assert.assertTrue( ValueType.PDOUBLE_TYPE.isNumber() );
+ Assert.assertTrue( ValueType.BYTE_TYPE.isNumber() );
+ Assert.assertTrue( ValueType.SHORT_TYPE.isNumber() );
+ Assert.assertTrue( ValueType.INTEGER_TYPE.isNumber() );
+ Assert.assertTrue( ValueType.LONG_TYPE.isNumber() );
+ Assert.assertTrue( ValueType.FLOAT_TYPE.isNumber() );
+ Assert.assertTrue( ValueType.DOUBLE_TYPE.isNumber() );
+
}
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/dataproviders/MethodDataProviderTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/dataproviders/MethodDataProviderTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/dataproviders/MethodDataProviderTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -39,15 +39,15 @@
private Map globals;
protected void setUp() {
- context = new PropagationContextImpl( 0,
+ this.context = new PropagationContextImpl( 0,
PropagationContext.ASSERTION,
null,
null );
- workingMemory = new ReteooWorkingMemory( 1,
+ this.workingMemory = new ReteooWorkingMemory( 1,
(ReteooRuleBase) RuleBaseFactory.newRuleBase() );
- declarations = new HashMap();
- globals = new HashMap();
+ this.declarations = new HashMap();
+ this.globals = new HashMap();
}
public void testWithDeclarationsHelloWorld() throws Exception {
@@ -56,72 +56,72 @@
new ClassObjectType( Cheese.class ) );
Extractor ex = new ColumnExtractor( new ClassObjectType( TestVariable.class ) );
- Declaration varDec = new Declaration( "var",
+ final Declaration varDec = new Declaration( "var",
ex,
column );
- declarations.put( "var",
+ this.declarations.put( "var",
varDec );
column = new Column( 1,
new ClassObjectType( Cheese.class ) );
ex = new ColumnExtractor( new ClassObjectType( String.class ) );
- Declaration var2Dec = new Declaration( "var2",
+ final Declaration var2Dec = new Declaration( "var2",
ex,
column );
- declarations.put( "var2",
+ this.declarations.put( "var2",
var2Dec );
- List args = new ArrayList();
+ final List args = new ArrayList();
args.add( new LiteralValue( "boo" ) );
args.add( new LiteralValue( new Integer( 42 ) ) );
args.add( new DeclarationVariable( var2Dec ) );
- MethodInvoker invoker = new MethodInvoker( "helloWorld",
+ final MethodInvoker invoker = new MethodInvoker( "helloWorld",
new DeclarationVariable( varDec ),
(ValueHandler[]) args.toArray( new ValueHandler[args.size()] ) );
- MethodDataProvider prov = new MethodDataProvider( invoker );
+ final MethodDataProvider prov = new MethodDataProvider( invoker );
- TestVariable var = new TestVariable();
- FactHandle varHandle = workingMemory.assertObject( var );
- FactHandle var2Handle = workingMemory.assertObject( "hola" );
+ final TestVariable var = new TestVariable();
+ final FactHandle varHandle = this.workingMemory.assertObject( var );
+ final FactHandle var2Handle = this.workingMemory.assertObject( "hola" );
- Tuple tuple = new ReteTuple( new ReteTuple( (DefaultFactHandle) varHandle ),
- (DefaultFactHandle) var2Handle );
+ final Tuple tuple = new ReteTuple( new ReteTuple( (DefaultFactHandle) varHandle ),
+ (DefaultFactHandle) var2Handle );
- Iterator it = prov.getResults( tuple,
- workingMemory,
- context );
+ final Iterator it = prov.getResults( tuple,
+ this.workingMemory,
+ this.context );
- Object result = it.next();
+ final Object result = it.next();
assertEquals( "boo42hola",
result );
}
public void testWithGlobals() throws Exception {
- globals.put( "foo",
+ this.globals.put( "foo",
TestVariable.class );
- Package pkg = new Package( "nothing" );
+ final Package pkg = new Package( "nothing" );
pkg.addGlobal( "foo",
TestVariable.class );
- RuleBase rb = RuleBaseFactory.newRuleBase();
+ final RuleBase rb = RuleBaseFactory.newRuleBase();
rb.addPackage( pkg );
- WorkingMemory wm = rb.newWorkingMemory();
+ final WorkingMemory wm = rb.newWorkingMemory();
wm.setGlobal( "foo",
new TestVariable() );
- MethodInvoker invoker = new MethodInvoker( "otherMethod",
- new GlobalVariable( "foo", TestVariable.class ),
- new ValueHandler[0] );
-
-
- MethodDataProvider prov = new MethodDataProvider( invoker );
+ final MethodInvoker invoker = new MethodInvoker( "otherMethod",
+ new GlobalVariable( "foo",
+ TestVariable.class ),
+ new ValueHandler[0] );
- Iterator it = prov.getResults( null,
+ final MethodDataProvider prov = new MethodDataProvider( invoker );
+
+ final Iterator it = prov.getResults( null,
wm,
null );
assertTrue( it.hasNext() );
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/dataproviders/TestVariable.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/dataproviders/TestVariable.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/dataproviders/TestVariable.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -4,18 +4,19 @@
import java.util.List;
public class TestVariable {
-
-
- public String helloWorld(String a1, int a2, String a3) {
+
+ public String helloWorld(final String a1,
+ final int a2,
+ final String a3) {
return a1 + a2 + a3;
}
-
+
public List otherMethod() {
- List list = new ArrayList();
+ final List list = new ArrayList();
list.add( "boo" );
return list;
}
-
+
public String helloWorld() {
return "another one";
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/extractors/BooleanClassFieldExtractorTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/extractors/BooleanClassFieldExtractorTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/extractors/BooleanClassFieldExtractorTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -7,89 +7,91 @@
import org.drools.spi.Extractor;
public class BooleanClassFieldExtractorTest extends ClassFieldExtractorsBaseTest {
- Extractor extractor = ClassFieldExtractorFactory.getClassFieldExtractor( TestBean.class, "booleanAttr" );
- TestBean bean = new TestBean();
-
+ Extractor extractor = ClassFieldExtractorFactory.getClassFieldExtractor( TestBean.class,
+ "booleanAttr" );
+ TestBean bean = new TestBean();
+
protected void setUp() throws Exception {
super.setUp();
}
public void testGetBooleanValue() {
try {
- Assert.assertTrue( this.extractor.getBooleanValue( bean ) );
- } catch (Exception e) {
- fail("Should not throw exception");
+ Assert.assertTrue( this.extractor.getBooleanValue( this.bean ) );
+ } catch ( final Exception e ) {
+ fail( "Should not throw exception" );
}
}
public void testGetByteValue() {
try {
- this.extractor.getByteValue( bean );
- fail("Should have throw an exception");
- } catch (Exception e) {
+ this.extractor.getByteValue( this.bean );
+ fail( "Should have throw an exception" );
+ } catch ( final Exception e ) {
// success
}
}
public void testGetCharValue() {
try {
- this.extractor.getCharValue( bean );
- fail("Should have throw an exception");
- } catch (Exception e) {
+ this.extractor.getCharValue( this.bean );
+ fail( "Should have throw an exception" );
+ } catch ( final Exception e ) {
// success
}
}
public void testGetDoubleValue() {
try {
- this.extractor.getDoubleValue( bean );
- fail("Should have throw an exception");
- } catch (Exception e) {
+ this.extractor.getDoubleValue( this.bean );
+ fail( "Should have throw an exception" );
+ } catch ( final Exception e ) {
// success
}
}
public void testGetFloatValue() {
try {
- this.extractor.getFloatValue( bean );
- fail("Should have throw an exception");
- } catch (Exception e) {
+ this.extractor.getFloatValue( this.bean );
+ fail( "Should have throw an exception" );
+ } catch ( final Exception e ) {
// success
}
}
public void testGetIntValue() {
try {
- this.extractor.getIntValue( bean );
- fail("Should have throw an exception");
- } catch (Exception e) {
+ this.extractor.getIntValue( this.bean );
+ fail( "Should have throw an exception" );
+ } catch ( final Exception e ) {
// success
}
}
public void testGetLongValue() {
try {
- this.extractor.getLongValue( bean );
- fail("Should have throw an exception");
- } catch (Exception e) {
+ this.extractor.getLongValue( this.bean );
+ fail( "Should have throw an exception" );
+ } catch ( final Exception e ) {
// success
}
}
public void testGetShortValue() {
try {
- this.extractor.getShortValue( bean );
- fail("Should have throw an exception");
- } catch (Exception e) {
+ this.extractor.getShortValue( this.bean );
+ fail( "Should have throw an exception" );
+ } catch ( final Exception e ) {
// success
}
}
public void testGetValue() {
try {
- Assert.assertSame( Boolean.TRUE, this.extractor.getValue( bean ) );
- } catch (Exception e) {
- fail("Should not throw an exception");
+ Assert.assertSame( Boolean.TRUE,
+ this.extractor.getValue( this.bean ) );
+ } catch ( final Exception e ) {
+ fail( "Should not throw an exception" );
}
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/extractors/ByteClassFieldExtractorTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/extractors/ByteClassFieldExtractorTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/extractors/ByteClassFieldExtractorTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -7,85 +7,95 @@
import org.drools.spi.Extractor;
public class ByteClassFieldExtractorTest extends ClassFieldExtractorsBaseTest {
- Extractor extractor = ClassFieldExtractorFactory.getClassFieldExtractor( TestBean.class, "byteAttr" );
- TestBean bean = new TestBean();
-
+ Extractor extractor = ClassFieldExtractorFactory.getClassFieldExtractor( TestBean.class,
+ "byteAttr" );
+ TestBean bean = new TestBean();
+
protected void setUp() throws Exception {
super.setUp();
}
public void testGetBooleanValue() {
try {
- this.extractor.getBooleanValue( bean );
- fail("Should have throw an exception");
- } catch (Exception e) {
+ this.extractor.getBooleanValue( this.bean );
+ fail( "Should have throw an exception" );
+ } catch ( final Exception e ) {
// success
}
}
public void testGetByteValue() {
try {
- Assert.assertEquals( 1, this.extractor.getByteValue( bean ));
- } catch (Exception e) {
- fail("Should not throw an exception");
+ Assert.assertEquals( 1,
+ this.extractor.getByteValue( this.bean ) );
+ } catch ( final Exception e ) {
+ fail( "Should not throw an exception" );
}
}
public void testGetCharValue() {
try {
- this.extractor.getCharValue( bean );
- fail("Should have throw an exception");
- } catch (Exception e) {
+ this.extractor.getCharValue( this.bean );
+ fail( "Should have throw an exception" );
+ } catch ( final Exception e ) {
// success
}
}
public void testGetDoubleValue() {
try {
- Assert.assertEquals( 1.0, this.extractor.getDoubleValue( bean ), 0.01);
- } catch (Exception e) {
- fail("Should not throw an exception");
+ Assert.assertEquals( 1.0,
+ this.extractor.getDoubleValue( this.bean ),
+ 0.01 );
+ } catch ( final Exception e ) {
+ fail( "Should not throw an exception" );
}
}
public void testGetFloatValue() {
try {
- Assert.assertEquals( 1.0f, this.extractor.getFloatValue( bean ), 0.01);
- } catch (Exception e) {
- fail("Should not throw an exception");
+ Assert.assertEquals( 1.0f,
+ this.extractor.getFloatValue( this.bean ),
+ 0.01 );
+ } catch ( final Exception e ) {
+ fail( "Should not throw an exception" );
}
}
public void testGetIntValue() {
try {
- Assert.assertEquals( 1, this.extractor.getIntValue( bean ));
- } catch (Exception e) {
- fail("Should not throw an exception");
+ Assert.assertEquals( 1,
+ this.extractor.getIntValue( this.bean ) );
+ } catch ( final Exception e ) {
+ fail( "Should not throw an exception" );
}
}
public void testGetLongValue() {
try {
- Assert.assertEquals( 1, this.extractor.getLongValue( bean ));
- } catch (Exception e) {
- fail("Should not throw an exception");
+ Assert.assertEquals( 1,
+ this.extractor.getLongValue( this.bean ) );
+ } catch ( final Exception e ) {
+ fail( "Should not throw an exception" );
}
}
public void testGetShortValue() {
try {
- Assert.assertEquals( 1, this.extractor.getShortValue( bean ));
- } catch (Exception e) {
- fail("Should not throw an exception");
+ Assert.assertEquals( 1,
+ this.extractor.getShortValue( this.bean ) );
+ } catch ( final Exception e ) {
+ fail( "Should not throw an exception" );
}
}
public void testGetValue() {
try {
- Assert.assertEquals( new Byte((byte)1), this.extractor.getValue( bean ) );
- Assert.assertTrue( this.extractor.getValue( bean ) instanceof Byte );
- } catch (Exception e) {
- fail("Should not throw an exception");
+ Assert.assertEquals( new Byte( (byte) 1 ),
+ this.extractor.getValue( this.bean ) );
+ Assert.assertTrue( this.extractor.getValue( this.bean ) instanceof Byte );
+ } catch ( final Exception e ) {
+ fail( "Should not throw an exception" );
}
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/extractors/CharClassFieldExtractorTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/extractors/CharClassFieldExtractorTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/extractors/CharClassFieldExtractorTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -7,90 +7,93 @@
import org.drools.spi.Extractor;
public class CharClassFieldExtractorTest extends ClassFieldExtractorsBaseTest {
- Extractor extractor = ClassFieldExtractorFactory.getClassFieldExtractor( TestBean.class, "charAttr" );
- TestBean bean = new TestBean();
-
+ Extractor extractor = ClassFieldExtractorFactory.getClassFieldExtractor( TestBean.class,
+ "charAttr" );
+ TestBean bean = new TestBean();
+
protected void setUp() throws Exception {
super.setUp();
}
public void testGetBooleanValue() {
try {
- this.extractor.getBooleanValue( bean );
- fail("Should have throw an exception");
- } catch (Exception e) {
+ this.extractor.getBooleanValue( this.bean );
+ fail( "Should have throw an exception" );
+ } catch ( final Exception e ) {
// success
}
}
public void testGetByteValue() {
try {
- this.extractor.getByteValue( bean );
- fail("Should have throw an exception");
- } catch (Exception e) {
+ this.extractor.getByteValue( this.bean );
+ fail( "Should have throw an exception" );
+ } catch ( final Exception e ) {
// success
}
}
public void testGetCharValue() {
try {
- Assert.assertEquals( 'a', this.extractor.getCharValue( bean ) );
- } catch (Exception e) {
- fail("Should not throw exception");
+ Assert.assertEquals( 'a',
+ this.extractor.getCharValue( this.bean ) );
+ } catch ( final Exception e ) {
+ fail( "Should not throw exception" );
}
}
public void testGetDoubleValue() {
try {
- this.extractor.getDoubleValue( bean );
- fail("Should have throw an exception");
- } catch (Exception e) {
+ this.extractor.getDoubleValue( this.bean );
+ fail( "Should have throw an exception" );
+ } catch ( final Exception e ) {
// success
}
}
public void testGetFloatValue() {
try {
- this.extractor.getFloatValue( bean );
- fail("Should have throw an exception");
- } catch (Exception e) {
+ this.extractor.getFloatValue( this.bean );
+ fail( "Should have throw an exception" );
+ } catch ( final Exception e ) {
// success
}
}
public void testGetIntValue() {
try {
- this.extractor.getIntValue( bean );
- fail("Should have throw an exception");
- } catch (Exception e) {
+ this.extractor.getIntValue( this.bean );
+ fail( "Should have throw an exception" );
+ } catch ( final Exception e ) {
// success
}
}
public void testGetLongValue() {
try {
- this.extractor.getLongValue( bean );
- fail("Should have throw an exception");
- } catch (Exception e) {
+ this.extractor.getLongValue( this.bean );
+ fail( "Should have throw an exception" );
+ } catch ( final Exception e ) {
// success
}
}
public void testGetShortValue() {
try {
- this.extractor.getShortValue( bean );
- fail("Should have throw an exception");
- } catch (Exception e) {
+ this.extractor.getShortValue( this.bean );
+ fail( "Should have throw an exception" );
+ } catch ( final Exception e ) {
// success
}
}
public void testGetValue() {
try {
- Assert.assertEquals( new Character('a'), this.extractor.getValue( bean ) );
- Assert.assertTrue( this.extractor.getValue( bean ) instanceof Character );
- } catch (Exception e) {
- fail("Should not throw an exception");
+ Assert.assertEquals( new Character( 'a' ),
+ this.extractor.getValue( this.bean ) );
+ Assert.assertTrue( this.extractor.getValue( this.bean ) instanceof Character );
+ } catch ( final Exception e ) {
+ fail( "Should not throw an exception" );
}
}
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/extractors/ClassFieldExtractorsBaseTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/extractors/ClassFieldExtractorsBaseTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/extractors/ClassFieldExtractorsBaseTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -3,24 +3,23 @@
import junit.framework.TestCase;
public abstract class ClassFieldExtractorsBaseTest extends TestCase {
-
+
public abstract void testGetBooleanValue();
-
+
public abstract void testGetByteValue();
-
+
public abstract void testGetCharValue();
-
+
public abstract void testGetShortValue();
-
+
public abstract void testGetIntValue();
-
+
public abstract void testGetLongValue();
-
+
public abstract void testGetFloatValue();
-
+
public abstract void testGetDoubleValue();
-
+
public abstract void testGetValue();
-
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/extractors/DoubleClassFieldExtractorTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/extractors/DoubleClassFieldExtractorTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/extractors/DoubleClassFieldExtractorTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -7,87 +7,97 @@
import org.drools.spi.Extractor;
public class DoubleClassFieldExtractorTest extends ClassFieldExtractorsBaseTest {
- private static final double VALUE = 7;
-
- Extractor extractor = ClassFieldExtractorFactory.getClassFieldExtractor( TestBean.class, "doubleAttr" );
- TestBean bean = new TestBean();
-
+ private static final double VALUE = 7;
+
+ Extractor extractor = ClassFieldExtractorFactory.getClassFieldExtractor( TestBean.class,
+ "doubleAttr" );
+ TestBean bean = new TestBean();
+
protected void setUp() throws Exception {
super.setUp();
}
public void testGetBooleanValue() {
try {
- this.extractor.getBooleanValue( bean );
- fail("Should have throw an exception");
- } catch (Exception e) {
+ this.extractor.getBooleanValue( this.bean );
+ fail( "Should have throw an exception" );
+ } catch ( final Exception e ) {
// success
}
}
public void testGetByteValue() {
try {
- Assert.assertEquals( (byte) VALUE, this.extractor.getByteValue( bean ));
- } catch (Exception e) {
- fail("Should not throw an exception");
+ Assert.assertEquals( (byte) DoubleClassFieldExtractorTest.VALUE,
+ this.extractor.getByteValue( this.bean ) );
+ } catch ( final Exception e ) {
+ fail( "Should not throw an exception" );
}
}
public void testGetCharValue() {
try {
- this.extractor.getCharValue( bean );
- fail("Should have throw an exception");
- } catch (Exception e) {
+ this.extractor.getCharValue( this.bean );
+ fail( "Should have throw an exception" );
+ } catch ( final Exception e ) {
// success
}
}
public void testGetDoubleValue() {
try {
- Assert.assertEquals( VALUE, this.extractor.getDoubleValue( bean ), 0.01);
- } catch (Exception e) {
- fail("Should not throw an exception");
+ Assert.assertEquals( DoubleClassFieldExtractorTest.VALUE,
+ this.extractor.getDoubleValue( this.bean ),
+ 0.01 );
+ } catch ( final Exception e ) {
+ fail( "Should not throw an exception" );
}
}
public void testGetFloatValue() {
try {
- Assert.assertEquals( VALUE, this.extractor.getFloatValue( bean ), 0.01);
- } catch (Exception e) {
- fail("Should not throw an exception");
+ Assert.assertEquals( DoubleClassFieldExtractorTest.VALUE,
+ this.extractor.getFloatValue( this.bean ),
+ 0.01 );
+ } catch ( final Exception e ) {
+ fail( "Should not throw an exception" );
}
}
public void testGetIntValue() {
try {
- Assert.assertEquals( (int) VALUE, this.extractor.getIntValue( bean ));
- } catch (Exception e) {
- fail("Should not throw an exception");
+ Assert.assertEquals( (int) DoubleClassFieldExtractorTest.VALUE,
+ this.extractor.getIntValue( this.bean ) );
+ } catch ( final Exception e ) {
+ fail( "Should not throw an exception" );
}
}
public void testGetLongValue() {
try {
- Assert.assertEquals( (long) VALUE, this.extractor.getLongValue( bean ));
- } catch (Exception e) {
- fail("Should not throw an exception");
+ Assert.assertEquals( (long) DoubleClassFieldExtractorTest.VALUE,
+ this.extractor.getLongValue( this.bean ) );
+ } catch ( final Exception e ) {
+ fail( "Should not throw an exception" );
}
}
public void testGetShortValue() {
try {
- Assert.assertEquals( (short) VALUE, this.extractor.getShortValue( bean ));
- } catch (Exception e) {
- fail("Should not throw an exception");
+ Assert.assertEquals( (short) DoubleClassFieldExtractorTest.VALUE,
+ this.extractor.getShortValue( this.bean ) );
+ } catch ( final Exception e ) {
+ fail( "Should not throw an exception" );
}
}
public void testGetValue() {
try {
- Assert.assertEquals( new Double((double)VALUE), this.extractor.getValue( bean ) );
- Assert.assertTrue( this.extractor.getValue( bean ) instanceof Double );
- } catch (Exception e) {
- fail("Should not throw an exception");
+ Assert.assertEquals( new Double( DoubleClassFieldExtractorTest.VALUE ),
+ this.extractor.getValue( this.bean ) );
+ Assert.assertTrue( this.extractor.getValue( this.bean ) instanceof Double );
+ } catch ( final Exception e ) {
+ fail( "Should not throw an exception" );
}
}
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/extractors/FloatClassFieldExtractorTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/extractors/FloatClassFieldExtractorTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/extractors/FloatClassFieldExtractorTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -7,87 +7,97 @@
import org.drools.spi.Extractor;
public class FloatClassFieldExtractorTest extends ClassFieldExtractorsBaseTest {
- private static final float VALUE = 6;
-
- Extractor extractor = ClassFieldExtractorFactory.getClassFieldExtractor( TestBean.class, "floatAttr" );
- TestBean bean = new TestBean();
-
+ private static final float VALUE = 6;
+
+ Extractor extractor = ClassFieldExtractorFactory.getClassFieldExtractor( TestBean.class,
+ "floatAttr" );
+ TestBean bean = new TestBean();
+
protected void setUp() throws Exception {
super.setUp();
}
public void testGetBooleanValue() {
try {
- this.extractor.getBooleanValue( bean );
- fail("Should have throw an exception");
- } catch (Exception e) {
+ this.extractor.getBooleanValue( this.bean );
+ fail( "Should have throw an exception" );
+ } catch ( final Exception e ) {
// success
}
}
public void testGetByteValue() {
try {
- Assert.assertEquals( (byte) VALUE, this.extractor.getByteValue( bean ));
- } catch (Exception e) {
- fail("Should not throw an exception");
+ Assert.assertEquals( (byte) FloatClassFieldExtractorTest.VALUE,
+ this.extractor.getByteValue( this.bean ) );
+ } catch ( final Exception e ) {
+ fail( "Should not throw an exception" );
}
}
public void testGetCharValue() {
try {
- this.extractor.getCharValue( bean );
- fail("Should have throw an exception");
- } catch (Exception e) {
+ this.extractor.getCharValue( this.bean );
+ fail( "Should have throw an exception" );
+ } catch ( final Exception e ) {
// success
}
}
public void testGetDoubleValue() {
try {
- Assert.assertEquals( VALUE, this.extractor.getDoubleValue( bean ), 0.01);
- } catch (Exception e) {
- fail("Should not throw an exception");
+ Assert.assertEquals( FloatClassFieldExtractorTest.VALUE,
+ this.extractor.getDoubleValue( this.bean ),
+ 0.01 );
+ } catch ( final Exception e ) {
+ fail( "Should not throw an exception" );
}
}
public void testGetFloatValue() {
try {
- Assert.assertEquals( VALUE, this.extractor.getFloatValue( bean ), 0.01);
- } catch (Exception e) {
- fail("Should not throw an exception");
+ Assert.assertEquals( FloatClassFieldExtractorTest.VALUE,
+ this.extractor.getFloatValue( this.bean ),
+ 0.01 );
+ } catch ( final Exception e ) {
+ fail( "Should not throw an exception" );
}
}
public void testGetIntValue() {
try {
- Assert.assertEquals( (int) VALUE, this.extractor.getIntValue( bean ));
- } catch (Exception e) {
- fail("Should not throw an exception");
+ Assert.assertEquals( (int) FloatClassFieldExtractorTest.VALUE,
+ this.extractor.getIntValue( this.bean ) );
+ } catch ( final Exception e ) {
+ fail( "Should not throw an exception" );
}
}
public void testGetLongValue() {
try {
- Assert.assertEquals( (long) VALUE, this.extractor.getLongValue( bean ));
- } catch (Exception e) {
- fail("Should not throw an exception");
+ Assert.assertEquals( (long) FloatClassFieldExtractorTest.VALUE,
+ this.extractor.getLongValue( this.bean ) );
+ } catch ( final Exception e ) {
+ fail( "Should not throw an exception" );
}
}
public void testGetShortValue() {
try {
- Assert.assertEquals( (short) VALUE, this.extractor.getShortValue( bean ));
- } catch (Exception e) {
- fail("Should not throw an exception");
+ Assert.assertEquals( (short) FloatClassFieldExtractorTest.VALUE,
+ this.extractor.getShortValue( this.bean ) );
+ } catch ( final Exception e ) {
+ fail( "Should not throw an exception" );
}
}
public void testGetValue() {
try {
- Assert.assertEquals( new Float((float)VALUE), this.extractor.getValue( bean ) );
- Assert.assertTrue( this.extractor.getValue( bean ) instanceof Float );
- } catch (Exception e) {
- fail("Should not throw an exception");
+ Assert.assertEquals( new Float( FloatClassFieldExtractorTest.VALUE ),
+ this.extractor.getValue( this.bean ) );
+ Assert.assertTrue( this.extractor.getValue( this.bean ) instanceof Float );
+ } catch ( final Exception e ) {
+ fail( "Should not throw an exception" );
}
}
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/extractors/IntClassFieldExtractorTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/extractors/IntClassFieldExtractorTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/extractors/IntClassFieldExtractorTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -7,87 +7,97 @@
import org.drools.spi.Extractor;
public class IntClassFieldExtractorTest extends ClassFieldExtractorsBaseTest {
- private static final int VALUE = 4;
-
- Extractor extractor = ClassFieldExtractorFactory.getClassFieldExtractor( TestBean.class, "intAttr" );
- TestBean bean = new TestBean();
-
+ private static final int VALUE = 4;
+
+ Extractor extractor = ClassFieldExtractorFactory.getClassFieldExtractor( TestBean.class,
+ "intAttr" );
+ TestBean bean = new TestBean();
+
protected void setUp() throws Exception {
super.setUp();
}
public void testGetBooleanValue() {
try {
- this.extractor.getBooleanValue( bean );
- fail("Should have throw an exception");
- } catch (Exception e) {
+ this.extractor.getBooleanValue( this.bean );
+ fail( "Should have throw an exception" );
+ } catch ( final Exception e ) {
// success
}
}
public void testGetByteValue() {
try {
- Assert.assertEquals( VALUE, this.extractor.getByteValue( bean ));
- } catch (Exception e) {
- fail("Should not throw an exception");
+ Assert.assertEquals( IntClassFieldExtractorTest.VALUE,
+ this.extractor.getByteValue( this.bean ) );
+ } catch ( final Exception e ) {
+ fail( "Should not throw an exception" );
}
}
public void testGetCharValue() {
try {
- this.extractor.getCharValue( bean );
- fail("Should have throw an exception");
- } catch (Exception e) {
+ this.extractor.getCharValue( this.bean );
+ fail( "Should have throw an exception" );
+ } catch ( final Exception e ) {
// success
}
}
public void testGetDoubleValue() {
try {
- Assert.assertEquals( VALUE, this.extractor.getDoubleValue( bean ), 0.01);
- } catch (Exception e) {
- fail("Should not throw an exception");
+ Assert.assertEquals( IntClassFieldExtractorTest.VALUE,
+ this.extractor.getDoubleValue( this.bean ),
+ 0.01 );
+ } catch ( final Exception e ) {
+ fail( "Should not throw an exception" );
}
}
public void testGetFloatValue() {
try {
- Assert.assertEquals( VALUE, this.extractor.getFloatValue( bean ), 0.01);
- } catch (Exception e) {
- fail("Should not throw an exception");
+ Assert.assertEquals( IntClassFieldExtractorTest.VALUE,
+ this.extractor.getFloatValue( this.bean ),
+ 0.01 );
+ } catch ( final Exception e ) {
+ fail( "Should not throw an exception" );
}
}
public void testGetIntValue() {
try {
- Assert.assertEquals( VALUE, this.extractor.getIntValue( bean ));
- } catch (Exception e) {
- fail("Should not throw an exception");
+ Assert.assertEquals( IntClassFieldExtractorTest.VALUE,
+ this.extractor.getIntValue( this.bean ) );
+ } catch ( final Exception e ) {
+ fail( "Should not throw an exception" );
}
}
public void testGetLongValue() {
try {
- Assert.assertEquals( VALUE, this.extractor.getLongValue( bean ));
- } catch (Exception e) {
- fail("Should not throw an exception");
+ Assert.assertEquals( IntClassFieldExtractorTest.VALUE,
+ this.extractor.getLongValue( this.bean ) );
+ } catch ( final Exception e ) {
+ fail( "Should not throw an exception" );
}
}
public void testGetShortValue() {
try {
- Assert.assertEquals( VALUE, this.extractor.getShortValue( bean ));
- } catch (Exception e) {
- fail("Should not throw an exception");
+ Assert.assertEquals( IntClassFieldExtractorTest.VALUE,
+ this.extractor.getShortValue( this.bean ) );
+ } catch ( final Exception e ) {
+ fail( "Should not throw an exception" );
}
}
public void testGetValue() {
try {
- Assert.assertEquals( new Integer((int)VALUE), this.extractor.getValue( bean ) );
- Assert.assertTrue( this.extractor.getValue( bean ) instanceof Integer );
- } catch (Exception e) {
- fail("Should not throw an exception");
+ Assert.assertEquals( new Integer( IntClassFieldExtractorTest.VALUE ),
+ this.extractor.getValue( this.bean ) );
+ Assert.assertTrue( this.extractor.getValue( this.bean ) instanceof Integer );
+ } catch ( final Exception e ) {
+ fail( "Should not throw an exception" );
}
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/extractors/LongClassFieldExtractorTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/extractors/LongClassFieldExtractorTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/extractors/LongClassFieldExtractorTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -7,87 +7,97 @@
import org.drools.spi.Extractor;
public class LongClassFieldExtractorTest extends ClassFieldExtractorsBaseTest {
- private static final long VALUE = 5;
-
- Extractor extractor = ClassFieldExtractorFactory.getClassFieldExtractor( TestBean.class, "longAttr" );
- TestBean bean = new TestBean();
-
+ private static final long VALUE = 5;
+
+ Extractor extractor = ClassFieldExtractorFactory.getClassFieldExtractor( TestBean.class,
+ "longAttr" );
+ TestBean bean = new TestBean();
+
protected void setUp() throws Exception {
super.setUp();
}
public void testGetBooleanValue() {
try {
- this.extractor.getBooleanValue( bean );
- fail("Should have throw an exception");
- } catch (Exception e) {
+ this.extractor.getBooleanValue( this.bean );
+ fail( "Should have throw an exception" );
+ } catch ( final Exception e ) {
// success
}
}
public void testGetByteValue() {
try {
- Assert.assertEquals( VALUE, this.extractor.getByteValue( bean ));
- } catch (Exception e) {
- fail("Should not throw an exception");
+ Assert.assertEquals( LongClassFieldExtractorTest.VALUE,
+ this.extractor.getByteValue( this.bean ) );
+ } catch ( final Exception e ) {
+ fail( "Should not throw an exception" );
}
}
public void testGetCharValue() {
try {
- this.extractor.getCharValue( bean );
- fail("Should have throw an exception");
- } catch (Exception e) {
+ this.extractor.getCharValue( this.bean );
+ fail( "Should have throw an exception" );
+ } catch ( final Exception e ) {
// success
}
}
public void testGetDoubleValue() {
try {
- Assert.assertEquals( VALUE, this.extractor.getDoubleValue( bean ), 0.01);
- } catch (Exception e) {
- fail("Should not throw an exception");
+ Assert.assertEquals( LongClassFieldExtractorTest.VALUE,
+ this.extractor.getDoubleValue( this.bean ),
+ 0.01 );
+ } catch ( final Exception e ) {
+ fail( "Should not throw an exception" );
}
}
public void testGetFloatValue() {
try {
- Assert.assertEquals( VALUE, this.extractor.getFloatValue( bean ), 0.01);
- } catch (Exception e) {
- fail("Should not throw an exception");
+ Assert.assertEquals( LongClassFieldExtractorTest.VALUE,
+ this.extractor.getFloatValue( this.bean ),
+ 0.01 );
+ } catch ( final Exception e ) {
+ fail( "Should not throw an exception" );
}
}
public void testGetIntValue() {
try {
- Assert.assertEquals( VALUE, this.extractor.getIntValue( bean ));
- } catch (Exception e) {
- fail("Should not throw an exception");
+ Assert.assertEquals( LongClassFieldExtractorTest.VALUE,
+ this.extractor.getIntValue( this.bean ) );
+ } catch ( final Exception e ) {
+ fail( "Should not throw an exception" );
}
}
public void testGetLongValue() {
try {
- Assert.assertEquals( VALUE, this.extractor.getLongValue( bean ));
- } catch (Exception e) {
- fail("Should not throw an exception");
+ Assert.assertEquals( LongClassFieldExtractorTest.VALUE,
+ this.extractor.getLongValue( this.bean ) );
+ } catch ( final Exception e ) {
+ fail( "Should not throw an exception" );
}
}
public void testGetShortValue() {
try {
- Assert.assertEquals( VALUE, this.extractor.getShortValue( bean ));
- } catch (Exception e) {
- fail("Should not throw an exception");
+ Assert.assertEquals( LongClassFieldExtractorTest.VALUE,
+ this.extractor.getShortValue( this.bean ) );
+ } catch ( final Exception e ) {
+ fail( "Should not throw an exception" );
}
}
public void testGetValue() {
try {
- Assert.assertEquals( new Long((short)VALUE), this.extractor.getValue( bean ) );
- Assert.assertTrue( this.extractor.getValue( bean ) instanceof Long );
- } catch (Exception e) {
- fail("Should not throw an exception");
+ Assert.assertEquals( new Long( (short) LongClassFieldExtractorTest.VALUE ),
+ this.extractor.getValue( this.bean ) );
+ Assert.assertTrue( this.extractor.getValue( this.bean ) instanceof Long );
+ } catch ( final Exception e ) {
+ fail( "Should not throw an exception" );
}
}
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/extractors/ObjectClassFieldExtractorTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/extractors/ObjectClassFieldExtractorTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/extractors/ObjectClassFieldExtractorTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -10,91 +10,93 @@
import org.drools.spi.Extractor;
public class ObjectClassFieldExtractorTest extends ClassFieldExtractorsBaseTest {
- Extractor extractor = ClassFieldExtractorFactory.getClassFieldExtractor( TestBean.class, "listAttr" );
- TestBean bean = new TestBean();
-
+ Extractor extractor = ClassFieldExtractorFactory.getClassFieldExtractor( TestBean.class,
+ "listAttr" );
+ TestBean bean = new TestBean();
+
protected void setUp() throws Exception {
super.setUp();
}
public void testGetBooleanValue() {
try {
- this.extractor.getBooleanValue( bean );
- fail("Should have throw an exception");
- } catch (Exception e) {
+ this.extractor.getBooleanValue( this.bean );
+ fail( "Should have throw an exception" );
+ } catch ( final Exception e ) {
// success
}
}
public void testGetByteValue() {
try {
- this.extractor.getByteValue( bean );
- fail("Should have throw an exception");
- } catch (Exception e) {
+ this.extractor.getByteValue( this.bean );
+ fail( "Should have throw an exception" );
+ } catch ( final Exception e ) {
// success
}
}
public void testGetCharValue() {
try {
- this.extractor.getCharValue( bean );
- fail("Should have throw an exception");
- } catch (Exception e) {
+ this.extractor.getCharValue( this.bean );
+ fail( "Should have throw an exception" );
+ } catch ( final Exception e ) {
// success
}
}
public void testGetDoubleValue() {
try {
- this.extractor.getDoubleValue( bean );
- fail("Should have throw an exception");
- } catch (Exception e) {
+ this.extractor.getDoubleValue( this.bean );
+ fail( "Should have throw an exception" );
+ } catch ( final Exception e ) {
// success
}
}
public void testGetFloatValue() {
try {
- this.extractor.getFloatValue( bean );
- fail("Should have throw an exception");
- } catch (Exception e) {
+ this.extractor.getFloatValue( this.bean );
+ fail( "Should have throw an exception" );
+ } catch ( final Exception e ) {
// success
}
}
public void testGetIntValue() {
try {
- this.extractor.getIntValue( bean );
- fail("Should have throw an exception");
- } catch (Exception e) {
+ this.extractor.getIntValue( this.bean );
+ fail( "Should have throw an exception" );
+ } catch ( final Exception e ) {
// success
}
}
public void testGetLongValue() {
try {
- this.extractor.getLongValue( bean );
- fail("Should have throw an exception");
- } catch (Exception e) {
+ this.extractor.getLongValue( this.bean );
+ fail( "Should have throw an exception" );
+ } catch ( final Exception e ) {
// success
}
}
public void testGetShortValue() {
try {
- this.extractor.getShortValue( bean );
- fail("Should have throw an exception");
- } catch (Exception e) {
+ this.extractor.getShortValue( this.bean );
+ fail( "Should have throw an exception" );
+ } catch ( final Exception e ) {
// success
}
}
public void testGetValue() {
try {
- Assert.assertEquals( Collections.EMPTY_LIST, this.extractor.getValue( bean ) );
- Assert.assertTrue( this.extractor.getValue( bean ) instanceof List );
- } catch (Exception e) {
- fail("Should not throw an exception");
+ Assert.assertEquals( Collections.EMPTY_LIST,
+ this.extractor.getValue( this.bean ) );
+ Assert.assertTrue( this.extractor.getValue( this.bean ) instanceof List );
+ } catch ( final Exception e ) {
+ fail( "Should not throw an exception" );
}
}
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/extractors/ShortClassFieldExtractorTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/extractors/ShortClassFieldExtractorTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/extractors/ShortClassFieldExtractorTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -7,87 +7,97 @@
import org.drools.spi.Extractor;
public class ShortClassFieldExtractorTest extends ClassFieldExtractorsBaseTest {
- private static final short VALUE = 3;
-
- Extractor extractor = ClassFieldExtractorFactory.getClassFieldExtractor( TestBean.class, "shortAttr" );
- TestBean bean = new TestBean();
-
+ private static final short VALUE = 3;
+
+ Extractor extractor = ClassFieldExtractorFactory.getClassFieldExtractor( TestBean.class,
+ "shortAttr" );
+ TestBean bean = new TestBean();
+
protected void setUp() throws Exception {
super.setUp();
}
public void testGetBooleanValue() {
try {
- this.extractor.getBooleanValue( bean );
- fail("Should have throw an exception");
- } catch (Exception e) {
+ this.extractor.getBooleanValue( this.bean );
+ fail( "Should have throw an exception" );
+ } catch ( final Exception e ) {
// success
}
}
public void testGetByteValue() {
try {
- Assert.assertEquals( VALUE, this.extractor.getByteValue( bean ));
- } catch (Exception e) {
- fail("Should not throw an exception");
+ Assert.assertEquals( ShortClassFieldExtractorTest.VALUE,
+ this.extractor.getByteValue( this.bean ) );
+ } catch ( final Exception e ) {
+ fail( "Should not throw an exception" );
}
}
public void testGetCharValue() {
try {
- this.extractor.getCharValue( bean );
- fail("Should have throw an exception");
- } catch (Exception e) {
+ this.extractor.getCharValue( this.bean );
+ fail( "Should have throw an exception" );
+ } catch ( final Exception e ) {
// success
}
}
public void testGetDoubleValue() {
try {
- Assert.assertEquals( VALUE, this.extractor.getDoubleValue( bean ), 0.01);
- } catch (Exception e) {
- fail("Should not throw an exception");
+ Assert.assertEquals( ShortClassFieldExtractorTest.VALUE,
+ this.extractor.getDoubleValue( this.bean ),
+ 0.01 );
+ } catch ( final Exception e ) {
+ fail( "Should not throw an exception" );
}
}
public void testGetFloatValue() {
try {
- Assert.assertEquals( VALUE, this.extractor.getFloatValue( bean ), 0.01);
- } catch (Exception e) {
- fail("Should not throw an exception");
+ Assert.assertEquals( ShortClassFieldExtractorTest.VALUE,
+ this.extractor.getFloatValue( this.bean ),
+ 0.01 );
+ } catch ( final Exception e ) {
+ fail( "Should not throw an exception" );
}
}
public void testGetIntValue() {
try {
- Assert.assertEquals( VALUE, this.extractor.getIntValue( bean ));
- } catch (Exception e) {
- fail("Should not throw an exception");
+ Assert.assertEquals( ShortClassFieldExtractorTest.VALUE,
+ this.extractor.getIntValue( this.bean ) );
+ } catch ( final Exception e ) {
+ fail( "Should not throw an exception" );
}
}
public void testGetLongValue() {
try {
- Assert.assertEquals( VALUE, this.extractor.getLongValue( bean ));
- } catch (Exception e) {
- fail("Should not throw an exception");
+ Assert.assertEquals( ShortClassFieldExtractorTest.VALUE,
+ this.extractor.getLongValue( this.bean ) );
+ } catch ( final Exception e ) {
+ fail( "Should not throw an exception" );
}
}
public void testGetShortValue() {
try {
- Assert.assertEquals( VALUE, this.extractor.getShortValue( bean ));
- } catch (Exception e) {
- fail("Should not throw an exception");
+ Assert.assertEquals( ShortClassFieldExtractorTest.VALUE,
+ this.extractor.getShortValue( this.bean ) );
+ } catch ( final Exception e ) {
+ fail( "Should not throw an exception" );
}
}
public void testGetValue() {
try {
- Assert.assertEquals( new Short((short)VALUE), this.extractor.getValue( bean ) );
- Assert.assertTrue( this.extractor.getValue( bean ) instanceof Short );
- } catch (Exception e) {
- fail("Should not throw an exception");
+ Assert.assertEquals( new Short( ShortClassFieldExtractorTest.VALUE ),
+ this.extractor.getValue( this.bean ) );
+ Assert.assertTrue( this.extractor.getValue( this.bean ) instanceof Short );
+ } catch ( final Exception e ) {
+ fail( "Should not throw an exception" );
}
}
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/resolvers/DeclarationVariableTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/resolvers/DeclarationVariableTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/resolvers/DeclarationVariableTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -16,21 +16,21 @@
public class DeclarationVariableTest extends TestCase {
public void testDeclaration() throws Exception {
- RuleBase rb = RuleBaseFactory.newRuleBase();
- Package pkg = new Package( "org.test" );
+ final RuleBase rb = RuleBaseFactory.newRuleBase();
+ final Package pkg = new Package( "org.test" );
rb.addPackage( pkg );
- WorkingMemory wm = rb.newWorkingMemory();
+ final WorkingMemory wm = rb.newWorkingMemory();
- Column column = new Column( 0,
+ final Column column = new Column( 0,
new ClassObjectType( Cheese.class ),
"stilton" );
- DeclarationVariable declaration = new DeclarationVariable( column.getDeclaration() );
+ final DeclarationVariable declaration = new DeclarationVariable( column.getDeclaration() );
- Cheese stilton = new Cheese( "stilton",
+ final Cheese stilton = new Cheese( "stilton",
20 );
- FactHandle stiltonHandle = wm.assertObject( stilton );
+ final FactHandle stiltonHandle = wm.assertObject( stilton );
- Tuple tuple = new ReteTuple( (DefaultFactHandle) stiltonHandle );
+ final Tuple tuple = new ReteTuple( (DefaultFactHandle) stiltonHandle );
assertEquals( stilton,
declaration.getValue( tuple,
wm ) );
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/resolvers/GlobalVariableTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/resolvers/GlobalVariableTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/resolvers/GlobalVariableTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -17,22 +17,23 @@
public class GlobalVariableTest extends TestCase {
public void testGlobal() throws Exception {
- RuleBase rb = RuleBaseFactory.newRuleBase();
- Package pkg = new Package( "org.test" );
+ final RuleBase rb = RuleBaseFactory.newRuleBase();
+ final Package pkg = new Package( "org.test" );
pkg.addGlobal( "list",
List.class );
rb.addPackage( pkg );
- WorkingMemory wm = rb.newWorkingMemory();
+ final WorkingMemory wm = rb.newWorkingMemory();
- GlobalVariable global = new GlobalVariable( "list", List.class );
+ final GlobalVariable global = new GlobalVariable( "list",
+ List.class );
- Cheese stilton = new Cheese( "stilton",
+ final Cheese stilton = new Cheese( "stilton",
20 );
- FactHandle stiltonHandle = wm.assertObject( stilton );
+ final FactHandle stiltonHandle = wm.assertObject( stilton );
- Tuple tuple = new ReteTuple( (DefaultFactHandle) stiltonHandle );
+ final Tuple tuple = new ReteTuple( (DefaultFactHandle) stiltonHandle );
- List list = new ArrayList();
+ final List list = new ArrayList();
wm.setGlobal( "list",
list );
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/resolvers/ListValueTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/resolvers/ListValueTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/resolvers/ListValueTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -4,6 +4,8 @@
import java.util.List;
import java.util.Map;
+import junit.framework.TestCase;
+
import org.drools.Cheese;
import org.drools.FactHandle;
import org.drools.RuleBase;
@@ -16,88 +18,96 @@
import org.drools.rule.Package;
import org.drools.spi.Tuple;
-import junit.framework.TestCase;
-
public class ListValueTest extends TestCase {
public void testList() throws Exception {
- RuleBase rb = RuleBaseFactory.newRuleBase();
- Package pkg = new Package( "org.test" );
+ final RuleBase rb = RuleBaseFactory.newRuleBase();
+ final Package pkg = new Package( "org.test" );
pkg.addGlobal( "list",
List.class );
rb.addPackage( pkg );
- WorkingMemory wm = rb.newWorkingMemory();
-
- List list = new ArrayList();
+ final WorkingMemory wm = rb.newWorkingMemory();
+
+ final List list = new ArrayList();
wm.setGlobal( "list",
- list );
-
- LiteralValue literal = new LiteralValue( "literal" );
-
- Column column = new Column( 0,
+ list );
+
+ final LiteralValue literal = new LiteralValue( "literal" );
+
+ final Column column = new Column( 0,
new ClassObjectType( Cheese.class ),
"stilton" );
- DeclarationVariable declaration = new DeclarationVariable( column.getDeclaration() );
-
- GlobalVariable global = new GlobalVariable( "list", List.class );
-
- LiteralValue literalKey = new LiteralValue( "literalKey" );
- LiteralValue literalValue = new LiteralValue( "literalValue" );
- MapValue.KeyValuePair literalPair = new MapValue.KeyValuePair( literalKey,
+ final DeclarationVariable declaration = new DeclarationVariable( column.getDeclaration() );
+
+ final GlobalVariable global = new GlobalVariable( "list",
+ List.class );
+
+ final LiteralValue literalKey = new LiteralValue( "literalKey" );
+ final LiteralValue literalValue = new LiteralValue( "literalValue" );
+ final MapValue.KeyValuePair literalPair = new MapValue.KeyValuePair( literalKey,
literalValue );
- MapValue mapValue = new MapValue( new MapValue.KeyValuePair[]{literalPair} );
-
- List listValueHandlers = new ArrayList();
+ final MapValue mapValue = new MapValue( new MapValue.KeyValuePair[]{literalPair} );
+
+ final List listValueHandlers = new ArrayList();
listValueHandlers.add( literal );
listValueHandlers.add( declaration );
listValueHandlers.add( mapValue );
listValueHandlers.add( global );
-
- ListValue listValue = new ListValue( listValueHandlers );
-
- Cheese stilton = new Cheese( "stilton",
+
+ final ListValue listValue = new ListValue( listValueHandlers );
+
+ final Cheese stilton = new Cheese( "stilton",
20 );
- FactHandle stiltonHandle = wm.assertObject( stilton );
+ final FactHandle stiltonHandle = wm.assertObject( stilton );
- Tuple tuple = new ReteTuple( (DefaultFactHandle) stiltonHandle );
-
- List values = ( List ) listValue.getValue( tuple, wm );
- assertEquals( "literal", values.get( 0 ) );
- assertEquals( stilton, values.get( 1 ) );
+ final Tuple tuple = new ReteTuple( (DefaultFactHandle) stiltonHandle );
- Map map = ( Map ) values.get( 2 );
- assertEquals( "literalValue", map.get( "literalKey" ) );
-
- assertEquals( list, values.get( 3 ) );
+ final List values = (List) listValue.getValue( tuple,
+ wm );
+ assertEquals( "literal",
+ values.get( 0 ) );
+ assertEquals( stilton,
+ values.get( 1 ) );
+
+ final Map map = (Map) values.get( 2 );
+ assertEquals( "literalValue",
+ map.get( "literalKey" ) );
+
+ assertEquals( list,
+ values.get( 3 ) );
}
-
+
public void testNestedList() {
- RuleBase rb = RuleBaseFactory.newRuleBase();
- WorkingMemory wm = rb.newWorkingMemory();
-
- LiteralValue literal = new LiteralValue( "literal" );
- List nestedListValueHandlers = new ArrayList();
- nestedListValueHandlers.add( literal );
- ListValue nestedListValue = new ListValue( nestedListValueHandlers );
-
- List listValueHandlers = new ArrayList();
- listValueHandlers.add( nestedListValue );
- ListValue listValue = new ListValue( listValueHandlers );
-
- Cheese stilton = new Cheese( "stilton",
+ final RuleBase rb = RuleBaseFactory.newRuleBase();
+ final WorkingMemory wm = rb.newWorkingMemory();
+
+ final LiteralValue literal = new LiteralValue( "literal" );
+ final List nestedListValueHandlers = new ArrayList();
+ nestedListValueHandlers.add( literal );
+ final ListValue nestedListValue = new ListValue( nestedListValueHandlers );
+
+ final List listValueHandlers = new ArrayList();
+ listValueHandlers.add( nestedListValue );
+ final ListValue listValue = new ListValue( listValueHandlers );
+
+ final Cheese stilton = new Cheese( "stilton",
20 );
- FactHandle stiltonHandle = wm.assertObject( stilton );
+ final FactHandle stiltonHandle = wm.assertObject( stilton );
- Tuple tuple = new ReteTuple( (DefaultFactHandle) stiltonHandle );
-
- List list = ( List ) listValue.getValue( tuple, wm );
- assertEquals( 1, list.size() );
-
- List nestedList = ( List ) list.get( 0 );
-
- assertEquals( 1, nestedList.size() );
-
- assertEquals( "literal", nestedList.get( 0 ) );
-
+ final Tuple tuple = new ReteTuple( (DefaultFactHandle) stiltonHandle );
+
+ final List list = (List) listValue.getValue( tuple,
+ wm );
+ assertEquals( 1,
+ list.size() );
+
+ final List nestedList = (List) list.get( 0 );
+
+ assertEquals( 1,
+ nestedList.size() );
+
+ assertEquals( "literal",
+ nestedList.get( 0 ) );
+
}
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/resolvers/LiteralValueTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/resolvers/LiteralValueTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/resolvers/LiteralValueTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -14,18 +14,18 @@
public class LiteralValueTest extends TestCase {
public void testLiteral() throws Exception {
- RuleBase rb = RuleBaseFactory.newRuleBase();
- Package pkg = new Package( "org.test" );
+ final RuleBase rb = RuleBaseFactory.newRuleBase();
+ final Package pkg = new Package( "org.test" );
rb.addPackage( pkg );
- WorkingMemory wm = rb.newWorkingMemory();
+ final WorkingMemory wm = rb.newWorkingMemory();
- LiteralValue literal = new LiteralValue( "literal" );
+ final LiteralValue literal = new LiteralValue( "literal" );
- Cheese stilton = new Cheese( "stilton",
+ final Cheese stilton = new Cheese( "stilton",
20 );
- FactHandle stiltonHandle = wm.assertObject( stilton );
+ final FactHandle stiltonHandle = wm.assertObject( stilton );
- Tuple tuple = new ReteTuple( (DefaultFactHandle) stiltonHandle );
+ final Tuple tuple = new ReteTuple( (DefaultFactHandle) stiltonHandle );
assertEquals( "literal",
literal.getValue( tuple,
wm ) );
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/resolvers/MapValueTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/resolvers/MapValueTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/resolvers/MapValueTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -20,55 +20,56 @@
public class MapValueTest extends TestCase {
public void testFlatMap() throws Exception {
- RuleBase rb = RuleBaseFactory.newRuleBase();
- Package pkg = new Package( "org.test" );
+ final RuleBase rb = RuleBaseFactory.newRuleBase();
+ final Package pkg = new Package( "org.test" );
pkg.addGlobal( "list",
List.class );
rb.addPackage( pkg );
- WorkingMemory wm = rb.newWorkingMemory();
+ final WorkingMemory wm = rb.newWorkingMemory();
// Make a literal key/value pair
- LiteralValue literalKey = new LiteralValue( "literalKey1" );
- LiteralValue literalValue = new LiteralValue( "literalValue" );
- MapValue.KeyValuePair literalPair = new MapValue.KeyValuePair( literalKey,
+ final LiteralValue literalKey = new LiteralValue( "literalKey1" );
+ final LiteralValue literalValue = new LiteralValue( "literalValue" );
+ final MapValue.KeyValuePair literalPair = new MapValue.KeyValuePair( literalKey,
literalValue );
// Make a declaration/literal key/value pair
- Column column = new Column( 0,
+ final Column column = new Column( 0,
new ClassObjectType( Cheese.class ),
"stilton" );
- DeclarationVariable declaration = new DeclarationVariable( column.getDeclaration() );
- MapValue.KeyValuePair declarationLiteralPair = new MapValue.KeyValuePair( declaration,
+ final DeclarationVariable declaration = new DeclarationVariable( column.getDeclaration() );
+ final MapValue.KeyValuePair declarationLiteralPair = new MapValue.KeyValuePair( declaration,
literalValue );
// Make a literal/declaration key/value pair
- LiteralValue literalKey2 = new LiteralValue( "literalKey2" );
- MapValue.KeyValuePair literalDeclarationPair = new MapValue.KeyValuePair( literalKey2,
+ final LiteralValue literalKey2 = new LiteralValue( "literalKey2" );
+ final MapValue.KeyValuePair literalDeclarationPair = new MapValue.KeyValuePair( literalKey2,
declaration );
// Make a global/declaration key/value pair
- GlobalVariable global = new GlobalVariable( "list", List.class );
- MapValue.KeyValuePair globalDeclarationPair = new MapValue.KeyValuePair( global,
+ final GlobalVariable global = new GlobalVariable( "list",
+ List.class );
+ final MapValue.KeyValuePair globalDeclarationPair = new MapValue.KeyValuePair( global,
declaration );
// Make a literal/global key/value pair
- LiteralValue literalKey3 = new LiteralValue( "literalKey3" );
- MapValue.KeyValuePair LiteralGlobalPair = new MapValue.KeyValuePair( literalKey3,
+ final LiteralValue literalKey3 = new LiteralValue( "literalKey3" );
+ final MapValue.KeyValuePair LiteralGlobalPair = new MapValue.KeyValuePair( literalKey3,
global );
- MapValue mapValue = new MapValue( new MapValue.KeyValuePair[]{literalPair, globalDeclarationPair, LiteralGlobalPair, declarationLiteralPair, literalDeclarationPair} );
+ final MapValue mapValue = new MapValue( new MapValue.KeyValuePair[]{literalPair, globalDeclarationPair, LiteralGlobalPair, declarationLiteralPair, literalDeclarationPair} );
- Cheese stilton = new Cheese( "stilton",
+ final Cheese stilton = new Cheese( "stilton",
20 );
- FactHandle stiltonHandle = wm.assertObject( stilton );
+ final FactHandle stiltonHandle = wm.assertObject( stilton );
- Tuple tuple = new ReteTuple( (DefaultFactHandle) stiltonHandle );
+ final Tuple tuple = new ReteTuple( (DefaultFactHandle) stiltonHandle );
- List list = new ArrayList();
+ final List list = new ArrayList();
wm.setGlobal( "list",
list );
- Map map = (Map) mapValue.getValue( tuple,
+ final Map map = (Map) mapValue.getValue( tuple,
wm );
assertEquals( "literalValue",
map.get( "literalKey1" ) );
@@ -85,32 +86,32 @@
}
public void testNestedMap() {
- RuleBase rb = RuleBaseFactory.newRuleBase();
- WorkingMemory wm = rb.newWorkingMemory();
+ final RuleBase rb = RuleBaseFactory.newRuleBase();
+ final WorkingMemory wm = rb.newWorkingMemory();
// Make a literal key/value pair
- LiteralValue literalKey1 = new LiteralValue( "literalKey1" );
- LiteralValue literalValue1 = new LiteralValue( "literalValue1" );
- MapValue.KeyValuePair literalPair = new MapValue.KeyValuePair( literalKey1,
+ final LiteralValue literalKey1 = new LiteralValue( "literalKey1" );
+ final LiteralValue literalValue1 = new LiteralValue( "literalValue1" );
+ final MapValue.KeyValuePair literalPair = new MapValue.KeyValuePair( literalKey1,
literalValue1 );
- MapValue nestedMapValue = new MapValue( new MapValue.KeyValuePair[]{literalPair} );
+ final MapValue nestedMapValue = new MapValue( new MapValue.KeyValuePair[]{literalPair} );
- LiteralValue literalKey2 = new LiteralValue( "literalKey2" );
- MapValue.KeyValuePair nestedMapPair = new MapValue.KeyValuePair( literalKey2,
+ final LiteralValue literalKey2 = new LiteralValue( "literalKey2" );
+ final MapValue.KeyValuePair nestedMapPair = new MapValue.KeyValuePair( literalKey2,
nestedMapValue );
- MapValue mapValue = new MapValue( new MapValue.KeyValuePair[]{nestedMapPair} );
+ final MapValue mapValue = new MapValue( new MapValue.KeyValuePair[]{nestedMapPair} );
- Cheese stilton = new Cheese( "stilton",
+ final Cheese stilton = new Cheese( "stilton",
20 );
- FactHandle stiltonHandle = wm.assertObject( stilton );
+ final FactHandle stiltonHandle = wm.assertObject( stilton );
- Tuple tuple = new ReteTuple( (DefaultFactHandle) stiltonHandle );
+ final Tuple tuple = new ReteTuple( (DefaultFactHandle) stiltonHandle );
- Map map = (Map) mapValue.getValue( tuple,
+ final Map map = (Map) mapValue.getValue( tuple,
wm );
- Map nestedMap = (Map) map.get( "literalKey2" );
+ final Map nestedMap = (Map) map.get( "literalKey2" );
assertEquals( "literalValue1",
nestedMap.get( "literalKey1" ) );
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/BaseMannersTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/BaseMannersTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/BaseMannersTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -85,6 +85,7 @@
private Evaluator integerEqualEvaluator;
//private Evaluator integerNotEqualEvaluator;
private Evaluator booleanEqualEvaluator;
+
//private Evaluator booleanNotEqualEvaluator;
protected void setUp() throws Exception {
@@ -175,7 +176,7 @@
contextColumn.addConstraint( getLiteralConstraint( contextColumn,
"state",
- Context.START_UP ,
+ Context.START_UP,
this.integerEqualEvaluator ) );
rule.addPattern( contextColumn );
@@ -308,7 +309,7 @@
contextColumn.addConstraint( getLiteralConstraint( contextColumn,
"state",
- Context.ASSIGN_SEATS ,
+ Context.ASSIGN_SEATS,
this.integerEqualEvaluator ) );
rule.addPattern( contextColumn );
@@ -572,7 +573,7 @@
contextColumn.addConstraint( getLiteralConstraint( contextColumn,
"state",
- Context.MAKE_PATH ,
+ Context.MAKE_PATH,
this.integerEqualEvaluator ) );
rule.addPattern( contextColumn );
@@ -712,7 +713,7 @@
contextColumn.addConstraint( getLiteralConstraint( contextColumn,
"state",
- Context.MAKE_PATH ,
+ Context.MAKE_PATH,
this.integerEqualEvaluator ) );
rule.addPattern( contextColumn );
@@ -805,7 +806,7 @@
contextColumn.addConstraint( getLiteralConstraint( contextColumn,
"state",
- Context.CHECK_DONE ,
+ Context.CHECK_DONE,
this.integerEqualEvaluator ) );
rule.addPattern( contextColumn );
@@ -895,7 +896,7 @@
contextColumn.addConstraint( getLiteralConstraint( contextColumn,
"state",
- Context.CHECK_DONE ,
+ Context.CHECK_DONE,
this.integerEqualEvaluator ) );
rule.addPattern( contextColumn );
@@ -1151,9 +1152,9 @@
}
private BetaNodeFieldConstraint getBoundVariableConstraint(final Column column,
- final String fieldName,
- final Declaration declaration,
- final Evaluator evaluator) throws IntrospectionException {
+ final String fieldName,
+ final Declaration declaration,
+ final Evaluator evaluator) throws IntrospectionException {
final Class clazz = ((ClassObjectType) column.getObjectType()).getClassType();
final FieldExtractor extractor = new ClassFieldExtractor( clazz,
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/Chosen.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/Chosen.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/Chosen.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -26,16 +26,16 @@
*/
private static final long serialVersionUID = -169447202790860427L;
- private int id;
+ private int id;
- private String guestName;
+ private String guestName;
- private Hobby hobby;
+ private Hobby hobby;
public Chosen() {
-
+
}
-
+
public Chosen(final int id,
final String guestName,
final Hobby hobby) {
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/Context.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/Context.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/Context.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -34,7 +34,7 @@
public static final String[] stateStrings = {"START_UP", "ASSIGN_SEATS", "MAKE_PATH", "CHECK_DONE", "PRINT_RESULTS"};
private int state;
-
+
public Context() {
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/Count.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/Count.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/Count.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -17,7 +17,7 @@
public class Count {
private int value;
-
+
public Count() {
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/Guest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/Guest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/Guest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -25,12 +25,12 @@
*/
private static final long serialVersionUID = 7806377320634586221L;
- private String name;
+ private String name;
- private Sex sex;
+ private Sex sex;
- private Hobby hobby;
-
+ private Hobby hobby;
+
public Guest() {
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/Hobby.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/Hobby.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/Hobby.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -30,15 +30,15 @@
public static final Hobby H4 = new Hobby( 4 );
public static final Hobby H5 = new Hobby( 5 );
- private String hobbyStr;
- private int hobbyIndex;
-
+ private String hobbyStr;
+ private int hobbyIndex;
+
public Hobby() {
}
private Hobby(final int hobby) {
this.hobbyIndex = hobby - 1;
- this.hobbyStr = Hobby.hobbyStrings[this.hobbyIndex];
+ this.hobbyStr = Hobby.hobbyStrings[this.hobbyIndex];
}
public String getHobby() {
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/LastSeat.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/LastSeat.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/LastSeat.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -24,11 +24,11 @@
*
*/
private static final long serialVersionUID = -3331801742327121724L;
- private int seat;
+ private int seat;
public LastSeat() {
}
-
+
public LastSeat(final int seat) {
this.seat = seat;
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/Path.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/Path.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/Path.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -22,7 +22,7 @@
public Path() {
}
-
+
public Path(final int id,
final int seat,
final String guestName) {
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/ReteooMannersTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/ReteooMannersTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/ReteooMannersTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -34,37 +34,38 @@
final RuleBase ruleBase = RuleBaseFactory.newRuleBase( RuleBase.RETEOO );
ruleBase.addPackage( this.pkg );
- final WorkingMemory workingMemory = ruleBase.newWorkingMemory();
+ final WorkingMemory workingMemory = ruleBase.newWorkingMemory();
- DefaultAgendaEventListener listener =new DefaultAgendaEventListener() {
- private int counter = 0;
-// public void activationCreated(ActivationCreatedEvent event) {
-// super.activationCreated( event );
-// System.out.println( event );
-// }
-//
-// public void activationCancelled(ActivationCancelledEvent event) {
-// super.activationCancelled( event );
-// System.out.println( event );
-// }
-//
-// public void beforeActivationFired(BeforeActivationFiredEvent event) {
-// super.beforeActivationFired( event );
-// System.out.println( event );
-// }
-
- public void afterActivationFired(AfterActivationFiredEvent event) {
- counter++;
- //super.afterActivationFired( event );
- //System.out.println( event );
- }
-
- public String toString() {
- return "fired : " + this.counter;
- }
-
+ final DefaultAgendaEventListener listener = new DefaultAgendaEventListener() {
+ private int counter = 0;
+
+ // public void activationCreated(ActivationCreatedEvent event) {
+ // super.activationCreated( event );
+ // System.out.println( event );
+ // }
+ //
+ // public void activationCancelled(ActivationCancelledEvent event) {
+ // super.activationCancelled( event );
+ // System.out.println( event );
+ // }
+ //
+ // public void beforeActivationFired(BeforeActivationFiredEvent event) {
+ // super.beforeActivationFired( event );
+ // System.out.println( event );
+ // }
+
+ public void afterActivationFired(AfterActivationFiredEvent event) {
+ this.counter++;
+ //super.afterActivationFired( event );
+ //System.out.println( event );
+ }
+
+ public String toString() {
+ return "fired : " + this.counter;
+ }
+
};
-
+
//workingMemory.addEventListener(listener );
final InputStream is = getClass().getResourceAsStream( "/manners128.dat" );
final List list = getInputObjects( is );
@@ -78,17 +79,17 @@
final long start = System.currentTimeMillis();
workingMemory.fireAllRules();
System.err.println( System.currentTimeMillis() - start );
-
+
//System.out.println( listener );
-
-// while (1==1){
-// Thread.yield();
-// Thread.sleep( 2000 );
-// }
-
- MemoryVisitor visitor = new MemoryVisitor( ( InternalWorkingMemory ) workingMemory );
- visitor.visit( ruleBase );
+ // while (1==1){
+ // Thread.yield();
+ // Thread.sleep( 2000 );
+ // }
+
+ final MemoryVisitor visitor = new MemoryVisitor( (InternalWorkingMemory) workingMemory );
+ visitor.visit( ruleBase );
+
// final ReteooJungViewer viewer = new ReteooJungViewer(ruleBase);
//
// javax.swing.SwingUtilities.invokeLater(new Runnable() {
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/Seating.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/Seating.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/Seating.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -25,17 +25,17 @@
*/
private static final long serialVersionUID = -21267542036195318L;
- private int id, pid;
+ private int id, pid;
- private int leftSeat, rightSeat;
+ private int leftSeat, rightSeat;
- private String leftGuestName, rightGuestName;
+ private String leftGuestName, rightGuestName;
private boolean pathDone;
public Seating() {
}
-
+
public Seating(final int id,
final int pid,
final boolean pathDone,
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/Sex.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/Sex.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/Sex.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -23,8 +23,8 @@
public static final String stringF = "f";
public static final String[] sexList = new String[]{Sex.stringM, Sex.stringF};
- private int sex;
-
+ private int sex;
+
public Sex() {
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/waltz/BaseWaltzTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/waltz/BaseWaltzTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/waltz/BaseWaltzTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -42,10 +42,10 @@
import org.drools.rule.Package;
import org.drools.rule.Rule;
import org.drools.rule.VariableConstraint;
+import org.drools.spi.AlphaNodeFieldConstraint;
import org.drools.spi.Consequence;
import org.drools.spi.ConsequenceException;
import org.drools.spi.Evaluator;
-import org.drools.spi.AlphaNodeFieldConstraint;
import org.drools.spi.FieldExtractor;
import org.drools.spi.KnowledgeHelper;
import org.drools.spi.MockField;
@@ -89,15 +89,15 @@
this.edgeType = new ClassObjectType( Edge.class );
this.junctionType = new ClassObjectType( Junction.class );
// evaluators
-
+
this.integerEqualEvaluator = ValueType.INTEGER_TYPE.getEvaluator( Operator.EQUAL );
this.integerNotEqualEvaluator = ValueType.INTEGER_TYPE.getEvaluator( Operator.NOT_EQUAL );
this.integerGreaterEvaluator = ValueType.INTEGER_TYPE.getEvaluator( Operator.GREATER );
- this.integerLessEvaluator = ValueType.INTEGER_TYPE.getEvaluator( Operator.LESS );
+ this.integerLessEvaluator = ValueType.INTEGER_TYPE.getEvaluator( Operator.LESS );
this.objectEqualEvaluator = ValueType.OBJECT_TYPE.getEvaluator( Operator.EQUAL );
this.objectNotEqualEvaluator = ValueType.OBJECT_TYPE.getEvaluator( Operator.NOT_EQUAL );
this.booleanEqualEvaluator = ValueType.BOOLEAN_TYPE.getEvaluator( Operator.EQUAL );
- this.booleanNotEqualEvaluator = ValueType.BOOLEAN_TYPE.getEvaluator( Operator.NOT_EQUAL );
+ this.booleanNotEqualEvaluator = ValueType.BOOLEAN_TYPE.getEvaluator( Operator.NOT_EQUAL );
// rules
this.pkg = new Package( "Waltz" );
@@ -3742,9 +3742,9 @@
}
private AlphaNodeFieldConstraint getLiteralConstraint(final Column column,
- final String fieldName,
- final Object fieldValue,
- final Evaluator evaluator) throws IntrospectionException {
+ final String fieldName,
+ final Object fieldValue,
+ final Evaluator evaluator) throws IntrospectionException {
final Class clazz = ((ClassObjectType) column.getObjectType()).getClassType();
final FieldExtractor extractor = ClassFieldExtractorFactory.getClassFieldExtractor( clazz,
@@ -3770,16 +3770,16 @@
}
private AlphaNodeFieldConstraint getBoundVariableConstraint(final Column column,
- final String fieldName,
- final Declaration declaration,
- final Evaluator evaluator) throws IntrospectionException {
+ final String fieldName,
+ final Declaration declaration,
+ final Evaluator evaluator) throws IntrospectionException {
final Class clazz = ((ClassObjectType) column.getObjectType()).getClassType();
final FieldExtractor extractor = ClassFieldExtractorFactory.getClassFieldExtractor( clazz,
fieldName );
return new VariableConstraint( extractor,
- declaration,
- evaluator );
+ declaration,
+ evaluator );
}
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/facttemplates/FactTemplateFieldExtractorTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/facttemplates/FactTemplateFieldExtractorTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/facttemplates/FactTemplateFieldExtractorTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -2,8 +2,6 @@
import junit.framework.TestCase;
-import org.drools.Cheese;
-import org.drools.base.ClassObjectType;
import org.drools.rule.Column;
import org.drools.rule.Declaration;
import org.drools.rule.Package;
@@ -11,25 +9,25 @@
public class FactTemplateFieldExtractorTest extends TestCase {
public void testExtractor() {
- Package pkg = new Package( "org.store" );
+ final Package pkg = new Package( "org.store" );
- FieldTemplate cheeseName = new FieldTemplateImpl( "name",
+ final FieldTemplate cheeseName = new FieldTemplateImpl( "name",
0,
String.class );
- FieldTemplate cheesePrice = new FieldTemplateImpl( "price",
+ final FieldTemplate cheesePrice = new FieldTemplateImpl( "price",
1,
Integer.class );
- FieldTemplate[] fields = new FieldTemplate[]{cheeseName, cheesePrice};
- FactTemplate cheese = new FactTemplateImpl( pkg,
+ final FieldTemplate[] fields = new FieldTemplate[]{cheeseName, cheesePrice};
+ final FactTemplate cheese = new FactTemplateImpl( pkg,
"Cheese",
fields );
- Extractor extractName = new FactTemplateFieldExtractor( cheese,
+ final Extractor extractName = new FactTemplateFieldExtractor( cheese,
0 );
- Extractor extractPrice = new FactTemplateFieldExtractor( cheese,
+ final Extractor extractPrice = new FactTemplateFieldExtractor( cheese,
1 );
- Fact stilton = cheese.createFact( 10 );
+ final Fact stilton = cheese.createFact( 10 );
stilton.setFieldValue( "name",
"stilton" );
stilton.setFieldValue( "price",
@@ -41,7 +39,7 @@
assertEquals( new Integer( 200 ),
extractPrice.getValue( stilton ) );
- Fact brie = cheese.createFact( 12 );
+ final Fact brie = cheese.createFact( 12 );
brie.setFieldValue( "name",
"brie" );
brie.setFieldValue( "price",
@@ -55,29 +53,30 @@
}
public void testDeclaration() {
- Package pkg = new Package( "org.store" );
+ final Package pkg = new Package( "org.store" );
- FieldTemplate cheeseName = new FieldTemplateImpl( "name",
+ final FieldTemplate cheeseName = new FieldTemplateImpl( "name",
0,
String.class );
- FieldTemplate cheesePrice = new FieldTemplateImpl( "price",
+ final FieldTemplate cheesePrice = new FieldTemplateImpl( "price",
1,
Integer.class );
- FieldTemplate[] fields = new FieldTemplate[]{cheeseName, cheesePrice};
- FactTemplate cheese = new FactTemplateImpl( pkg,
+ final FieldTemplate[] fields = new FieldTemplate[]{cheeseName, cheesePrice};
+ final FactTemplate cheese = new FactTemplateImpl( pkg,
"Cheese",
fields );
- Extractor extractName = new FactTemplateFieldExtractor( cheese,
+ final Extractor extractName = new FactTemplateFieldExtractor( cheese,
0 );
- Column column = new Column(0, new FactTemplateObjectType( cheese ) );
-
+ final Column column = new Column( 0,
+ new FactTemplateObjectType( cheese ) );
+
final Declaration declaration = new Declaration( "typeOfCheese",
extractName,
column );
- Fact brie = cheese.createFact( 12 );
+ final Fact brie = cheese.createFact( 12 );
brie.setFieldValue( "name",
"brie" );
brie.setFieldValue( "price",
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/facttemplates/FactTemplateTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/facttemplates/FactTemplateTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/facttemplates/FactTemplateTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -6,15 +6,15 @@
public class FactTemplateTest extends TestCase {
public void testFieldsAndGetters() {
- Package pkg = new Package( "org.store" );
- FieldTemplate cheeseName = new FieldTemplateImpl( "name",
+ final Package pkg = new Package( "org.store" );
+ final FieldTemplate cheeseName = new FieldTemplateImpl( "name",
0,
String.class );
- FieldTemplate cheesePrice = new FieldTemplateImpl( "price",
+ final FieldTemplate cheesePrice = new FieldTemplateImpl( "price",
1,
Integer.class );
- FieldTemplate[] fields = new FieldTemplate[]{cheeseName, cheesePrice};
- FactTemplate cheese = new FactTemplateImpl( pkg,
+ final FieldTemplate[] fields = new FieldTemplate[]{cheeseName, cheesePrice};
+ final FactTemplate cheese = new FactTemplateImpl( pkg,
"Cheese",
fields );
@@ -46,85 +46,96 @@
}
public void testEqualsAndHashCode() {
- Package pkg = new Package( "org.store" );
-
+ final Package pkg = new Package( "org.store" );
+
// Create cheese1 with name and price fields
- FieldTemplate cheeseName = new FieldTemplateImpl( "name",
+ final FieldTemplate cheeseName = new FieldTemplateImpl( "name",
0,
String.class );
- FieldTemplate cheesePrice = new FieldTemplateImpl( "price",
+ final FieldTemplate cheesePrice = new FieldTemplateImpl( "price",
1,
Integer.class );
- FieldTemplate[] fields1 = new FieldTemplate[]{cheeseName, cheesePrice};
- FactTemplate cheese1 = new FactTemplateImpl( pkg,
+ final FieldTemplate[] fields1 = new FieldTemplate[]{cheeseName, cheesePrice};
+ final FactTemplate cheese1 = new FactTemplateImpl( pkg,
"Cheese",
fields1 );
// Create cheese2 with type and price fields
- FieldTemplate cheeseType = new FieldTemplateImpl( "type",
+ final FieldTemplate cheeseType = new FieldTemplateImpl( "type",
0,
String.class );
- FieldTemplate[] fields2 = new FieldTemplate[]{cheeseType, cheesePrice};
- FactTemplate cheese2 = new FactTemplateImpl( pkg,
+ final FieldTemplate[] fields2 = new FieldTemplate[]{cheeseType, cheesePrice};
+ final FactTemplate cheese2 = new FactTemplateImpl( pkg,
"Cheese",
fields2 );
- assertNotSame( cheese1, cheese2 );
-
+ assertNotSame( cheese1,
+ cheese2 );
+
assertFalse( cheese1.equals( cheese2 ) );
-
+
assertFalse( cheese1.hashCode() == cheese2.hashCode() );
-
-
-
+
// create cheese3 with name and price fields, using new instances
- FieldTemplate cheeseName2 = new FieldTemplateImpl( "name",
+ final FieldTemplate cheeseName2 = new FieldTemplateImpl( "name",
0,
String.class );
- FieldTemplate cheesePrice2 = new FieldTemplateImpl( "price",
+ final FieldTemplate cheesePrice2 = new FieldTemplateImpl( "price",
1,
Integer.class );
- FieldTemplate[] fields3 = new FieldTemplate[]{cheeseName2, cheesePrice2};
- FactTemplate cheese3 = new FactTemplateImpl( pkg,
+ final FieldTemplate[] fields3 = new FieldTemplate[]{cheeseName2, cheesePrice2};
+ final FactTemplate cheese3 = new FactTemplateImpl( pkg,
"Cheese",
fields3 );
-
- assertNotSame( cheese1, cheese3 );
- assertNotSame( cheese1.getAllFieldTemplates(), cheese3.getAllFieldTemplates() );
- assertEquals( cheese1, cheese3 );
- assertEquals( cheese1.hashCode(), cheese3.hashCode() );
+
+ assertNotSame( cheese1,
+ cheese3 );
+ assertNotSame( cheese1.getAllFieldTemplates(),
+ cheese3.getAllFieldTemplates() );
+ assertEquals( cheese1,
+ cheese3 );
+ assertEquals( cheese1.hashCode(),
+ cheese3.hashCode() );
}
-
+
public void testFacts() {
- Package pkg = new Package( "org.store" );
- FieldTemplate cheeseName = new FieldTemplateImpl( "name",
+ final Package pkg = new Package( "org.store" );
+ final FieldTemplate cheeseName = new FieldTemplateImpl( "name",
0,
String.class );
- FieldTemplate cheesePrice = new FieldTemplateImpl( "price",
+ final FieldTemplate cheesePrice = new FieldTemplateImpl( "price",
1,
Integer.class );
- FieldTemplate[] fields1 = new FieldTemplate[]{cheeseName, cheesePrice};
- FactTemplate cheese1 = new FactTemplateImpl( pkg,
+ final FieldTemplate[] fields1 = new FieldTemplate[]{cheeseName, cheesePrice};
+ final FactTemplate cheese1 = new FactTemplateImpl( pkg,
"Cheese",
- fields1 );
-
- Fact stilton1 = cheese1.createFact( 10 );
- stilton1.setFieldValue( "name", "stilton" );
- stilton1.setFieldValue( "price", new Integer( 200 ) );
+ fields1 );
- Fact stilton2 = cheese1.createFact( 11 );
- stilton2.setFieldValue( 0, "stilton" );
- stilton2.setFieldValue( 1, new Integer( 200 ) );
-
- assertEquals( stilton1, stilton2 );
- assertEquals( stilton1.hashCode(), stilton2.hashCode() );
-
- Fact brie = cheese1.createFact( 12 );
- brie.setFieldValue( "name", "brie" );
- brie.setFieldValue( "price", new Integer( 55 ) );
-
- assertFalse( stilton1.equals( brie ));
- assertFalse( stilton1.hashCode() == brie.hashCode() );
-
+ final Fact stilton1 = cheese1.createFact( 10 );
+ stilton1.setFieldValue( "name",
+ "stilton" );
+ stilton1.setFieldValue( "price",
+ new Integer( 200 ) );
+
+ final Fact stilton2 = cheese1.createFact( 11 );
+ stilton2.setFieldValue( 0,
+ "stilton" );
+ stilton2.setFieldValue( 1,
+ new Integer( 200 ) );
+
+ assertEquals( stilton1,
+ stilton2 );
+ assertEquals( stilton1.hashCode(),
+ stilton2.hashCode() );
+
+ final Fact brie = cheese1.createFact( 12 );
+ brie.setFieldValue( "name",
+ "brie" );
+ brie.setFieldValue( "price",
+ new Integer( 55 ) );
+
+ assertFalse( stilton1.equals( brie ) );
+ assertFalse( stilton1.hashCode() == brie.hashCode() );
+
}
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/facttemplates/FieldTemplateTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/facttemplates/FieldTemplateTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/facttemplates/FieldTemplateTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -5,11 +5,16 @@
import org.drools.base.ValueType;
public class FieldTemplateTest extends TestCase {
- public void testFieldTemplate() {
- FieldTemplate cheeseName = new FieldTemplateImpl("name", 5, String.class);
- assertEquals( "name", cheeseName.getName() );
- assertEquals( ValueType.STRING_TYPE, cheeseName.getValueType() );
- assertEquals( 5, cheeseName.getIndex() );
-
+ public void testFieldTemplate() {
+ final FieldTemplate cheeseName = new FieldTemplateImpl( "name",
+ 5,
+ String.class );
+ assertEquals( "name",
+ cheeseName.getName() );
+ assertEquals( ValueType.STRING_TYPE,
+ cheeseName.getValueType() );
+ assertEquals( 5,
+ cheeseName.getIndex() );
+
}
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/ColumnConstraintsTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/ColumnConstraintsTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/ColumnConstraintsTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -31,8 +31,8 @@
import org.drools.examples.manners.Context;
import org.drools.rule.Column;
import org.drools.rule.LiteralConstraint;
+import org.drools.spi.AlphaNodeFieldConstraint;
import org.drools.spi.Evaluator;
-import org.drools.spi.AlphaNodeFieldConstraint;
import org.drools.spi.FieldExtractor;
import org.drools.spi.FieldValue;
import org.drools.spi.MockField;
@@ -90,7 +90,7 @@
null,
null );
assertTrue( columnConstraints.isAllowed( new LeapsFactHandle( 23,
- new Context( Context.START_UP ) ),
+ new Context( Context.START_UP ) ),
tuple,
ruleBase.newWorkingMemory() ) );
}
@@ -128,16 +128,16 @@
null );
assertFalse( columnConstraints.isAllowed( new LeapsFactHandle( 23,
- new Context( Context.START_UP ) ),
+ new Context( Context.START_UP ) ),
null,
ruleBase.newWorkingMemory() ) );
}
private AlphaNodeFieldConstraint getLiteralConstraint(final Column column,
- final String fieldName,
- final Object fieldValue,
- final Evaluator evaluator) throws IntrospectionException {
+ final String fieldName,
+ final Object fieldValue,
+ final Evaluator evaluator) throws IntrospectionException {
final Class clazz = ((ClassObjectType) column.getObjectType()).getClassType();
final FieldValue field = new MockField( fieldValue );
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/HandleFactoryTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/HandleFactoryTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/HandleFactoryTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -84,7 +84,7 @@
final long nextId = this.factory.getNextId() + 1;
assertEquals( nextId,
((DefaultFactHandle) this.factory.newFactHandle( 984393L,
- new Object() )).getId() );
+ new Object() )).getId() );
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/HandleTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/HandleTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/HandleTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -30,7 +30,7 @@
*/
public void testGetId() {
final LeapsFactHandle handle = new LeapsFactHandle( 123456789,
- new String( "test124" ) );
+ new String( "test124" ) );
assertEquals( handle.getId(),
123456789 );
assertEquals( handle.getObject(),
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/HashedTableComponentTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/HashedTableComponentTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/HashedTableComponentTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -19,11 +19,9 @@
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
-import java.util.ArrayList;
import java.util.Iterator;
import org.drools.DroolsTestCase;
-import org.drools.FactHandle;
import org.drools.RuleBase;
import org.drools.RuleBaseFactory;
import org.drools.WorkingMemory;
@@ -31,14 +29,7 @@
import org.drools.base.ClassObjectType;
import org.drools.base.ValueType;
import org.drools.base.evaluators.Operator;
-import org.drools.common.DefaultFactHandle;
-import org.drools.examples.manners.Chosen;
-import org.drools.examples.manners.Context;
-import org.drools.examples.manners.Count;
-import org.drools.examples.manners.Guest;
-import org.drools.examples.manners.LastSeat;
import org.drools.examples.manners.Path;
-import org.drools.examples.manners.Seating;
import org.drools.rule.Column;
import org.drools.rule.Declaration;
import org.drools.rule.InvalidRuleException;
@@ -47,10 +38,10 @@
import org.drools.rule.Package;
import org.drools.rule.Rule;
import org.drools.rule.VariableConstraint;
+import org.drools.spi.AlphaNodeFieldConstraint;
import org.drools.spi.Consequence;
import org.drools.spi.ConsequenceException;
import org.drools.spi.Evaluator;
-import org.drools.spi.AlphaNodeFieldConstraint;
import org.drools.spi.FieldExtractor;
import org.drools.spi.FieldValue;
import org.drools.spi.KnowledgeHelper;
@@ -66,10 +57,8 @@
protected Package pkg;
-
private ClassObjectType pathType;
-
private Evaluator objectEqualEvaluator;
private Evaluator integerEqualEvaluator;
@@ -86,11 +75,21 @@
protected void setUp() throws Exception {
- this.p1Alex = new Path( 1, 1, "Alex" );
- this.p2John = new Path( 2, 1, "John" );
- this.p3Mike = new Path( 3, 1, "Mike" );
- this.p4Alex = new Path( 4, 1, "Alex" );
- this.p5Alex = new Path( 1, 4, "Alex" );
+ this.p1Alex = new Path( 1,
+ 1,
+ "Alex" );
+ this.p2John = new Path( 2,
+ 1,
+ "John" );
+ this.p3Mike = new Path( 3,
+ 1,
+ "Mike" );
+ this.p4Alex = new Path( 4,
+ 1,
+ "Alex" );
+ this.p5Alex = new Path( 1,
+ 4,
+ "Alex" );
this.pathType = new ClassObjectType( Path.class );
this.integerEqualEvaluator = ValueType.INTEGER_TYPE.getEvaluator( Operator.EQUAL );
@@ -106,11 +105,11 @@
*/
public void testHashedTableComponentNoAlpha() throws Exception {
- Rule r = this.getMakePathNoAlpha( );
+ final Rule r = this.getMakePathNoAlpha();
this.pkg.addRule( r );
final RuleBase ruleBase = RuleBaseFactory.newRuleBase( RuleBase.LEAPS );
ruleBase.addPackage( this.pkg );
- final LeapsWorkingMemory wm = (LeapsWorkingMemory) ruleBase.newWorkingMemory( );
+ final LeapsWorkingMemory wm = (LeapsWorkingMemory) ruleBase.newWorkingMemory();
wm.assertObject( this.p1Alex );
wm.assertObject( this.p2John );
wm.assertObject( this.p3Mike );
@@ -119,30 +118,39 @@
Iterator it;
Tuple tuple;
- FactTable ft = wm.getFactTable( Path.class );
- ColumnConstraints notConstraint = (ColumnConstraints) ft.getHashedConstraints( )
- .next( );
- LeapsFactHandle[] fh = new LeapsFactHandle[1];
- fh[0] = new LeapsFactHandle( 99, p1Alex );
- tuple = new LeapsTuple( fh, null, null );
+ final FactTable ft = wm.getFactTable( Path.class );
+ final ColumnConstraints notConstraint = (ColumnConstraints) ft.getHashedConstraints().next();
+ final LeapsFactHandle[] fh = new LeapsFactHandle[1];
+ fh[0] = new LeapsFactHandle( 99,
+ this.p1Alex );
+ tuple = new LeapsTuple( fh,
+ null,
+ null );
- it = ft.reverseOrderIterator( tuple, notConstraint );
+ it = ft.reverseOrderIterator( tuple,
+ notConstraint );
assertSame( "Expected matching",
- ( (LeapsFactHandle) it.next( ) ).getObject( ),
- p1Alex );
+ ((LeapsFactHandle) it.next()).getObject(),
+ this.p1Alex );
assertSame( "Expected matching",
- ( (LeapsFactHandle) it.next( ) ).getObject( ),
- p5Alex );
- assertFalse( "Did not expect any more data", it.hasNext( ) );
+ ((LeapsFactHandle) it.next()).getObject(),
+ this.p5Alex );
+ assertFalse( "Did not expect any more data",
+ it.hasNext() );
- fh[0] = new LeapsFactHandle( 99, p3Mike );
- tuple = new LeapsTuple( fh, null, null );
+ fh[0] = new LeapsFactHandle( 99,
+ this.p3Mike );
+ tuple = new LeapsTuple( fh,
+ null,
+ null );
- it = ft.reverseOrderIterator( tuple, notConstraint );
+ it = ft.reverseOrderIterator( tuple,
+ notConstraint );
assertSame( "Expected matching",
- ( (LeapsFactHandle) it.next( ) ).getObject( ),
- p3Mike );
- assertFalse( "Did not expect any more data", it.hasNext( ) );
+ ((LeapsFactHandle) it.next()).getObject(),
+ this.p3Mike );
+ assertFalse( "Did not expect any more data",
+ it.hasNext() );
}
/*
@@ -152,11 +160,11 @@
*/
public void testHashedTableComponentAlpha() throws Exception {
- Rule r = this.getMakePathAlpha( );
+ final Rule r = this.getMakePathAlpha();
this.pkg.addRule( r );
final RuleBase ruleBase = RuleBaseFactory.newRuleBase( RuleBase.LEAPS );
ruleBase.addPackage( this.pkg );
- final LeapsWorkingMemory wm = (LeapsWorkingMemory) ruleBase.newWorkingMemory( );
+ final LeapsWorkingMemory wm = (LeapsWorkingMemory) ruleBase.newWorkingMemory();
wm.assertObject( this.p1Alex );
wm.assertObject( this.p2John );
@@ -166,24 +174,33 @@
Iterator it;
Tuple tuple;
- FactTable ft = wm.getFactTable( Path.class );
- ColumnConstraints notConstraint = (ColumnConstraints) ft.getHashedConstraints( )
- .next( );
- LeapsFactHandle[] fh = new LeapsFactHandle[1];
- fh[0] = new LeapsFactHandle( 99, p1Alex );
- tuple = new LeapsTuple( fh, null, null );
+ final FactTable ft = wm.getFactTable( Path.class );
+ final ColumnConstraints notConstraint = (ColumnConstraints) ft.getHashedConstraints().next();
+ final LeapsFactHandle[] fh = new LeapsFactHandle[1];
+ fh[0] = new LeapsFactHandle( 99,
+ this.p1Alex );
+ tuple = new LeapsTuple( fh,
+ null,
+ null );
- it = ft.reverseOrderIterator( tuple, notConstraint );
- assertFalse( "Did not expect any more data", it.hasNext( ) );
+ it = ft.reverseOrderIterator( tuple,
+ notConstraint );
+ assertFalse( "Did not expect any more data",
+ it.hasNext() );
- fh[0] = new LeapsFactHandle( 99, p3Mike );
- tuple = new LeapsTuple( fh, null, null );
+ fh[0] = new LeapsFactHandle( 99,
+ this.p3Mike );
+ tuple = new LeapsTuple( fh,
+ null,
+ null );
- it = ft.reverseOrderIterator( tuple, notConstraint );
+ it = ft.reverseOrderIterator( tuple,
+ notConstraint );
assertSame( "Expected matching",
- ( (LeapsFactHandle) it.next( ) ).getObject( ),
- p3Mike );
- assertFalse( "Did not expect any more data", it.hasNext( ) );
+ ((LeapsFactHandle) it.next()).getObject(),
+ this.p3Mike );
+ assertFalse( "Did not expect any more data",
+ it.hasNext() );
}
/**
@@ -206,15 +223,21 @@
* @throws IntrospectionException
* @throws InvalidRuleException
*/
- private Rule getMakePathAlpha() throws IntrospectionException, InvalidRuleException {
+ private Rule getMakePathAlpha() throws IntrospectionException,
+ InvalidRuleException {
final Rule rule = new Rule( "makePathNoAlpha" );
// -----------
// Path( id == seatingPid, pathGuestName:guestName, pathSeat:seat )
// -----------
- final Column pathColumn = new Column( 0, this.pathType );
- setFieldDeclaration( pathColumn, "id", "pathId" );
+ final Column pathColumn = new Column( 0,
+ this.pathType );
+ setFieldDeclaration( pathColumn,
+ "id",
+ "pathId" );
- setFieldDeclaration( pathColumn, "guestName", "pathGuestName" );
+ setFieldDeclaration( pathColumn,
+ "guestName",
+ "pathGuestName" );
rule.addPattern( pathColumn );
@@ -223,7 +246,8 @@
// -------------
// (not Path( id == seatingId, guestName == pathGuestName )
// -------------
- final Column notPathColumn = new Column( 3, this.pathType );
+ final Column notPathColumn = new Column( 3,
+ this.pathType );
notPathColumn.addConstraint( getLiteralConstraint( notPathColumn,
"guestName",
@@ -239,7 +263,7 @@
pathGuestNameDeclaration,
this.objectEqualEvaluator ) );
- final Not not = new Not( );
+ final Not not = new Not();
not.addChild( notPathColumn );
@@ -248,10 +272,10 @@
// ------------
// drools.assert( new Path( id, pathName, pathSeat ) );
// ------------
- final Consequence consequence = new Consequence( ) {
+ final Consequence consequence = new Consequence() {
- public void evaluate( KnowledgeHelper drools, WorkingMemory workingMemory )
- throws ConsequenceException {
+ public void evaluate(KnowledgeHelper drools,
+ WorkingMemory workingMemory) throws ConsequenceException {
// empty
}
};
@@ -281,15 +305,21 @@
* @throws IntrospectionException
* @throws InvalidRuleException
*/
- private Rule getMakePathNoAlpha() throws IntrospectionException, InvalidRuleException {
+ private Rule getMakePathNoAlpha() throws IntrospectionException,
+ InvalidRuleException {
final Rule rule = new Rule( "makePathNoAlpha" );
// -----------
// Path( id == seatingPid, pathGuestName:guestName, pathSeat:seat )
// -----------
- final Column pathColumn = new Column( 0, this.pathType );
- setFieldDeclaration( pathColumn, "id", "pathId" );
+ final Column pathColumn = new Column( 0,
+ this.pathType );
+ setFieldDeclaration( pathColumn,
+ "id",
+ "pathId" );
- setFieldDeclaration( pathColumn, "guestName", "pathGuestName" );
+ setFieldDeclaration( pathColumn,
+ "guestName",
+ "pathGuestName" );
rule.addPattern( pathColumn );
@@ -298,7 +328,8 @@
// -------------
// (not Path( id == seatingId, guestName == pathGuestName )
// -------------
- final Column notPathColumn = new Column( 3, this.pathType );
+ final Column notPathColumn = new Column( 3,
+ this.pathType );
notPathColumn.addConstraint( getBoundVariableConstraint( notPathColumn,
"id",
@@ -309,7 +340,7 @@
pathGuestNameDeclaration,
this.objectEqualEvaluator ) );
- final Not not = new Not( );
+ final Not not = new Not();
not.addChild( notPathColumn );
@@ -318,10 +349,10 @@
// ------------
// drools.assert( new Path( id, pathName, pathSeat ) );
// ------------
- final Consequence consequence = new Consequence( ) {
+ final Consequence consequence = new Consequence() {
- public void evaluate( KnowledgeHelper drools, WorkingMemory workingMemory )
- throws ConsequenceException {
+ public void evaluate(KnowledgeHelper drools,
+ WorkingMemory workingMemory) throws ConsequenceException {
// empty
}
};
@@ -331,53 +362,57 @@
return rule;
}
- public static int getIndex( final Class clazz, final String name )
- throws IntrospectionException {
- final PropertyDescriptor[] descriptors = Introspector.getBeanInfo( clazz )
- .getPropertyDescriptors( );
- for (int i = 0; i < descriptors.length; i++) {
- if (descriptors[i].getName( ).equals( name )) {
+ public static int getIndex(final Class clazz,
+ final String name) throws IntrospectionException {
+ final PropertyDescriptor[] descriptors = Introspector.getBeanInfo( clazz ).getPropertyDescriptors();
+ for ( int i = 0; i < descriptors.length; i++ ) {
+ if ( descriptors[i].getName().equals( name ) ) {
return i;
}
}
return -1;
}
- private AlphaNodeFieldConstraint getLiteralConstraint( final Column column,
- final String fieldName,
- final Object fieldValue,
- final Evaluator evaluator )
- throws IntrospectionException {
- final Class clazz = ( (ClassObjectType) column.getObjectType( ) ).getClassType( );
+ private AlphaNodeFieldConstraint getLiteralConstraint(final Column column,
+ final String fieldName,
+ final Object fieldValue,
+ final Evaluator evaluator) throws IntrospectionException {
+ final Class clazz = ((ClassObjectType) column.getObjectType()).getClassType();
- final FieldExtractor extractor = new ClassFieldExtractor( clazz, fieldName );
+ final FieldExtractor extractor = new ClassFieldExtractor( clazz,
+ fieldName );
final FieldValue field = new MockField( fieldValue );
- return new LiteralConstraint( extractor, evaluator, field );
+ return new LiteralConstraint( extractor,
+ evaluator,
+ field );
}
- private void setFieldDeclaration( final Column column,
- final String fieldName,
- final String identifier )
- throws IntrospectionException {
- final Class clazz = ( (ClassObjectType) column.getObjectType( ) ).getClassType( );
+ private void setFieldDeclaration(final Column column,
+ final String fieldName,
+ final String identifier) throws IntrospectionException {
+ final Class clazz = ((ClassObjectType) column.getObjectType()).getClassType();
- final FieldExtractor extractor = new ClassFieldExtractor( clazz, fieldName );
+ final FieldExtractor extractor = new ClassFieldExtractor( clazz,
+ fieldName );
- column.addDeclaration( identifier, extractor );
+ column.addDeclaration( identifier,
+ extractor );
}
- private AlphaNodeFieldConstraint getBoundVariableConstraint( final Column column,
- final String fieldName,
- final Declaration declaration,
- final Evaluator evaluator )
- throws IntrospectionException {
- final Class clazz = ( (ClassObjectType) column.getObjectType( ) ).getClassType( );
+ private AlphaNodeFieldConstraint getBoundVariableConstraint(final Column column,
+ final String fieldName,
+ final Declaration declaration,
+ final Evaluator evaluator) throws IntrospectionException {
+ final Class clazz = ((ClassObjectType) column.getObjectType()).getClassType();
- final FieldExtractor extractor = new ClassFieldExtractor( clazz, fieldName );
+ final FieldExtractor extractor = new ClassFieldExtractor( clazz,
+ fieldName );
- return new VariableConstraint( extractor, declaration, evaluator );
+ return new VariableConstraint( extractor,
+ declaration,
+ evaluator );
}
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/LeapsFactHandleTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/LeapsFactHandleTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/LeapsFactHandleTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -30,7 +30,7 @@
*/
public void testGetId() {
final LeapsFactHandle handle = new LeapsFactHandle( 123456789,
- new String( "test124" ) );
+ new String( "test124" ) );
assertEquals( handle.getId(),
123456789 );
assertEquals( handle.getObject(),
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/LeapsRuleBaseTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/LeapsRuleBaseTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/LeapsRuleBaseTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -31,10 +31,10 @@
import org.drools.rule.Declaration;
import org.drools.rule.LiteralConstraint;
import org.drools.rule.Rule;
+import org.drools.spi.AlphaNodeFieldConstraint;
import org.drools.spi.Consequence;
import org.drools.spi.ConsequenceException;
import org.drools.spi.Evaluator;
-import org.drools.spi.AlphaNodeFieldConstraint;
import org.drools.spi.FieldExtractor;
import org.drools.spi.FieldValue;
import org.drools.spi.KnowledgeHelper;
@@ -383,9 +383,9 @@
}
private AlphaNodeFieldConstraint getLiteralConstraint(final Column column,
- final String fieldName,
- final Object fieldValue,
- final Evaluator evaluator) {
+ final String fieldName,
+ final Object fieldValue,
+ final Evaluator evaluator) {
final Class clazz = ((ClassObjectType) column.getObjectType()).getClassType();
final FieldExtractor extractor = new ClassFieldExtractor( clazz,
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/LeapsTupleTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/LeapsTupleTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/LeapsTupleTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -26,7 +26,7 @@
*/
public class LeapsTupleTest extends TestCase {
- LeapsTuple tuple;
+ LeapsTuple tuple;
LeapsFactHandle h1;
@@ -41,20 +41,20 @@
protected void setUp() throws Exception {
super.setUp();
this.h1 = new LeapsFactHandle( 1,
- "one" );
+ "one" );
this.h2 = new LeapsFactHandle( 2,
- "two" );
+ "two" );
this.h3 = new LeapsFactHandle( 3,
- "three" );
+ "three" );
this.h4 = new LeapsFactHandle( 4,
- "four" );
+ "four" );
final LeapsFactHandle arr[] = {this.h1, this.h2, this.h3, this.h4};
this.tuple = new LeapsTuple( arr,
null,
null );
this.hOutsider = new LeapsFactHandle( 9876,
- "outsider" );
+ "outsider" );
}
/*
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/LeapsWorkingMemoryTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/LeapsWorkingMemoryTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/LeapsWorkingMemoryTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -14,51 +14,55 @@
* @see JBRULES-356
*/
public void testBasicWorkingMemoryActions() {
- LeapsWorkingMemory workingMemory = (LeapsWorkingMemory) RuleBaseFactory.newRuleBase( RuleBase.LEAPS ).newWorkingMemory();
- TruthMaintenanceSystem tms = workingMemory.getTruthMaintenanceSystem();
- String string = "test";
- FactHandle fd = workingMemory.assertObject(string);
-
- assertEquals(1,
- tms.getAssertMap().size() );
+ final LeapsWorkingMemory workingMemory = (LeapsWorkingMemory) RuleBaseFactory.newRuleBase( RuleBase.LEAPS ).newWorkingMemory();
+ final TruthMaintenanceSystem tms = workingMemory.getTruthMaintenanceSystem();
+ final String string = "test";
+ FactHandle fd = workingMemory.assertObject( string );
+
+ assertEquals( 1,
+ tms.getAssertMap().size() );
EqualityKey key = tms.get( string );
- assertSame( fd, key.getFactHandle() );
+ assertSame( fd,
+ key.getFactHandle() );
assertNull( key.getOtherFactHandle() );
-
- workingMemory.modifyObject(fd, string);
-
- assertEquals(1,
- tms.getAssertMap().size() );
+
+ workingMemory.modifyObject( fd,
+ string );
+
+ assertEquals( 1,
+ tms.getAssertMap().size() );
key = tms.get( string );
- assertSame( fd, key.getFactHandle() );
+ assertSame( fd,
+ key.getFactHandle() );
assertNull( key.getOtherFactHandle() );
-
- workingMemory.retractObject(fd);
-
- assertEquals(0,
- tms.getAssertMap().size() );
+
+ workingMemory.retractObject( fd );
+
+ assertEquals( 0,
+ tms.getAssertMap().size() );
key = tms.get( string );
assertNull( key );
-
- fd = workingMemory.assertObject(string);
- assertEquals(1,
- tms.getAssertMap().size() );
-
- assertEquals(1,
- tms.getAssertMap().size() );
+ fd = workingMemory.assertObject( string );
+
+ assertEquals( 1,
+ tms.getAssertMap().size() );
+
+ assertEquals( 1,
+ tms.getAssertMap().size() );
key = tms.get( string );
- assertSame( fd, key.getFactHandle() );
+ assertSame( fd,
+ key.getFactHandle() );
assertNull( key.getOtherFactHandle() );
}
-
+
public void testId() {
- LeapsRuleBase ruleBase = (LeapsRuleBase) RuleBaseFactory.newRuleBase( RuleBase.LEAPS );
+ final LeapsRuleBase ruleBase = (LeapsRuleBase) RuleBaseFactory.newRuleBase( RuleBase.LEAPS );
InternalWorkingMemory workingMemory = (InternalWorkingMemory) ruleBase.newWorkingMemory();
assertEquals( 0,
workingMemory.getId() );
workingMemory = (InternalWorkingMemory) ruleBase.newWorkingMemory();
assertEquals( 1,
- workingMemory.getId() );
+ workingMemory.getId() );
}
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/LogicalAssertionTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/LogicalAssertionTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/LogicalAssertionTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -71,7 +71,7 @@
new ArrayList(),
new ArrayList(),
new ArrayList(),
- new ArrayList() );
+ new ArrayList() );
final LeapsFactHandle[] factHandles = new LeapsFactHandle[1];
PropagationContext context1;
@@ -130,7 +130,7 @@
final LeapsRule leapsRule1 = new LeapsRule( rule1,
new ArrayList(),
new ArrayList(),
- new ArrayList(),
+ new ArrayList(),
new ArrayList() );
final LeapsFactHandle[] factHandles = new LeapsFactHandle[1];
@@ -152,23 +152,26 @@
false,
true,
null,
- this.workingMemory.getAgenda( )
- .getActivations( )[0] );
+ this.workingMemory.getAgenda().getActivations()[0] );
String logicalString2 = new String( "logical" );
FactHandle logicalHandle2 = this.workingMemory.assertObject( logicalString2 );
// Should keep the same handle when overriding
- assertSame( logicalHandle1, logicalHandle2 );
+ assertSame( logicalHandle1,
+ logicalHandle2 );
// so while new STATED assertion is equal
- assertEquals( logicalString1, this.workingMemory.getObject( logicalHandle2 ) );
+ assertEquals( logicalString1,
+ this.workingMemory.getObject( logicalHandle2 ) );
// they are not - not identity same - leaps can not store two objects if
// handles are the same
- assertNotSame( logicalString1, this.workingMemory.getObject( logicalHandle2 ) );
-
- assertSame( logicalString2, this.workingMemory.getObject( logicalHandle2 ) );
+ assertNotSame( logicalString1,
+ this.workingMemory.getObject( logicalHandle2 ) );
+ assertSame( logicalString2,
+ this.workingMemory.getObject( logicalHandle2 ) );
+
// Test that a logical assertion cannot override a STATED assertion
factHandles[0] = (LeapsFactHandle) logicalHandle2;
tuple1 = new LeapsTuple( factHandles,
@@ -225,7 +228,7 @@
final LeapsRule leapsRule1 = new LeapsRule( rule1,
new ArrayList(),
new ArrayList(),
- new ArrayList(),
+ new ArrayList(),
new ArrayList() );
final LeapsFactHandle tuple1FactHandle = (LeapsFactHandle) this.workingMemory.assertObject( "tuple1 object" );
@@ -298,7 +301,7 @@
final LeapsRule leapsRule1 = new LeapsRule( rule1,
new ArrayList(),
new ArrayList(),
- new ArrayList(),
+ new ArrayList(),
new ArrayList() );
final LeapsFactHandle tuple1Fact = (LeapsFactHandle) this.workingMemory.assertObject( "tuple1 object" );
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/QueryResultsTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/QueryResultsTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/QueryResultsTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -32,8 +32,8 @@
import org.drools.rule.Column;
import org.drools.rule.LiteralConstraint;
import org.drools.rule.Query;
+import org.drools.spi.AlphaNodeFieldConstraint;
import org.drools.spi.Evaluator;
-import org.drools.spi.AlphaNodeFieldConstraint;
import org.drools.spi.FieldExtractor;
import org.drools.spi.FieldValue;
import org.drools.spi.MockField;
@@ -186,9 +186,9 @@
}
private AlphaNodeFieldConstraint getLiteralConstraint(final Column column,
- final String fieldName,
- final Object fieldValue,
- final Evaluator evaluator) {
+ final String fieldName,
+ final Object fieldValue,
+ final Evaluator evaluator) {
final Class clazz = ((ClassObjectType) column.getObjectType()).getClassType();
final FieldExtractor extractor = new ClassFieldExtractor( clazz,
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/QueryTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/QueryTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/QueryTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -32,10 +32,10 @@
import org.drools.rule.LiteralConstraint;
import org.drools.rule.Query;
import org.drools.rule.Rule;
+import org.drools.spi.AlphaNodeFieldConstraint;
import org.drools.spi.Consequence;
import org.drools.spi.ConsequenceException;
import org.drools.spi.Evaluator;
-import org.drools.spi.AlphaNodeFieldConstraint;
import org.drools.spi.FieldExtractor;
import org.drools.spi.FieldValue;
import org.drools.spi.KnowledgeHelper;
@@ -155,9 +155,9 @@
}
private AlphaNodeFieldConstraint getLiteralConstraint(final Column column,
- final String fieldName,
- final Object fieldValue,
- final Evaluator evaluator) {
+ final String fieldName,
+ final Object fieldValue,
+ final Evaluator evaluator) {
final Class clazz = ((ClassObjectType) column.getObjectType()).getClassType();
final FieldExtractor extractor = new ClassFieldExtractor( clazz,
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/SchedulerTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/SchedulerTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/SchedulerTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -36,7 +36,7 @@
public class SchedulerTest extends DroolsTestCase {
public void testScheduledActivation() throws Exception {
- final RuleBase ruleBase = (LeapsRuleBase) RuleBaseFactory.newRuleBase( RuleBase.LEAPS );
+ final RuleBase ruleBase = RuleBaseFactory.newRuleBase( RuleBase.LEAPS );
final LeapsWorkingMemory workingMemory = (LeapsWorkingMemory) ruleBase.newWorkingMemory();
@@ -97,7 +97,7 @@
}
public void testDoLoopScheduledActivation() throws Exception {
- final RuleBase ruleBase = (LeapsRuleBase) RuleBaseFactory.newRuleBase( RuleBase.LEAPS );
+ final RuleBase ruleBase = RuleBaseFactory.newRuleBase( RuleBase.LEAPS );
final LeapsWorkingMemory workingMemory = (LeapsWorkingMemory) ruleBase.newWorkingMemory();
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/util/TableIteratorTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/util/TableIteratorTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/util/TableIteratorTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -37,18 +37,18 @@
DefaultFactHandle h10;
- Table testTable;
+ Table testTable;
protected void setUp() {
this.testTable = new Table( LoadOrderConflictResolver.getInstance() );
this.h1 = new DefaultFactHandle( 1,
- "1" );
+ "1" );
this.h1000 = new DefaultFactHandle( 1000,
- "1000" );
+ "1000" );
this.h100 = new DefaultFactHandle( 100,
- "100" );
+ "100" );
this.h10 = new DefaultFactHandle( 10,
- "10" );
+ "10" );
}
/*
@@ -57,7 +57,7 @@
*/
public void testTableIterator() {
final IteratorFromPositionToTableStart it = new IteratorFromPositionToTableStart( null,
- null );
+ null );
assertFalse( it.hasNext() );
assertTrue( it.isEmpty() );
}
@@ -93,7 +93,7 @@
public void testTableIteratorTableRecordTableRecordTableRecord() {
this.testTable.add( this.h1 );
IteratorFromPositionToTableStart it = new IteratorFromPositionToTableStart( this.testTable.headRecord,
- this.testTable.tailRecord );
+ this.testTable.tailRecord );
assertTrue( it.hasNext() );
assertFalse( it.isEmpty() );
assertEquals( this.h1,
@@ -106,7 +106,7 @@
this.testTable.add( this.h10 );
this.testTable.add( this.h100 );
it = new IteratorFromPositionToTableStart( this.testTable.headRecord,
- this.testTable.headRecord );
+ this.testTable.headRecord );
assertFalse( it.isEmpty() );
assertTrue( it.hasNext() );
assertEquals( this.h1000,
@@ -127,7 +127,7 @@
this.testTable.add( this.h10 );
this.testTable.add( this.h100 );
it = new IteratorFromPositionToTableStart( this.testTable.headRecord,
- this.testTable.tailRecord );
+ this.testTable.tailRecord );
assertFalse( it.isEmpty() );
assertTrue( it.hasNext() );
assertTrue( it.hasNext() );
@@ -143,7 +143,7 @@
public void testIsEmpty() {
this.testTable.add( this.h1 );
IteratorFromPositionToTableStart it = new IteratorFromPositionToTableStart( this.testTable.headRecord,
- this.testTable.tailRecord );
+ this.testTable.tailRecord );
assertFalse( it.isEmpty() );
this.testTable.clear();
this.testTable.add( this.h1 );
@@ -151,13 +151,13 @@
this.testTable.add( this.h10 );
this.testTable.add( this.h100 );
it = new IteratorFromPositionToTableStart( this.testTable.headRecord,
- this.testTable.headRecord );
+ this.testTable.headRecord );
assertFalse( it.isEmpty() );
it = new IteratorFromPositionToTableStart( this.testTable.tailRecord,
- this.testTable.headRecord );
+ this.testTable.headRecord );
assertFalse( it.isEmpty() );
it = new IteratorFromPositionToTableStart( null,
- null );
+ null );
assertTrue( it.isEmpty() );
}
@@ -168,7 +168,7 @@
public void testReset() {
this.testTable.add( this.h1 );
IteratorFromPositionToTableStart it = new IteratorFromPositionToTableStart( this.testTable.headRecord,
- this.testTable.tailRecord );
+ this.testTable.tailRecord );
assertEquals( this.h1,
it.next() );
it.reset();
@@ -180,7 +180,7 @@
this.testTable.add( this.h10 );
this.testTable.add( this.h100 );
it = new IteratorFromPositionToTableStart( this.testTable.headRecord,
- this.testTable.headRecord );
+ this.testTable.headRecord );
assertEquals( this.h1000,
it.next() );
it.reset();
@@ -197,7 +197,7 @@
this.testTable.add( this.h10 );
this.testTable.add( this.h100 );
it = new IteratorFromPositionToTableStart( this.testTable.headRecord,
- this.testTable.tailRecord );
+ this.testTable.tailRecord );
it.reset();
assertEquals( this.h1000,
it.next() );
@@ -216,7 +216,7 @@
public void testHasNext() {
this.testTable.add( this.h1 );
IteratorFromPositionToTableStart it = new IteratorFromPositionToTableStart( this.testTable.headRecord,
- this.testTable.tailRecord );
+ this.testTable.tailRecord );
assertTrue( it.hasNext() );
assertFalse( it.isEmpty() );
assertEquals( this.h1,
@@ -229,7 +229,7 @@
this.testTable.add( this.h10 );
this.testTable.add( this.h100 );
it = new IteratorFromPositionToTableStart( this.testTable.headRecord,
- this.testTable.headRecord );
+ this.testTable.headRecord );
assertTrue( it.hasNext() );
this.testTable.clear();
this.testTable.add( this.h1 );
@@ -237,10 +237,10 @@
this.testTable.add( this.h10 );
this.testTable.add( this.h100 );
it = new IteratorFromPositionToTableStart( this.testTable.headRecord,
- this.testTable.tailRecord );
+ this.testTable.tailRecord );
assertTrue( it.hasNext() );
it = new IteratorFromPositionToTableStart( null,
- null );
+ null );
assertFalse( it.hasNext() );
it = new IteratorFromPositionToTableStart( new TableRecord( this.h1 ) );
assertTrue( it.hasNext() );
@@ -253,7 +253,7 @@
public void testNext() {
this.testTable.add( this.h1 );
IteratorFromPositionToTableStart it = new IteratorFromPositionToTableStart( this.testTable.headRecord,
- this.testTable.tailRecord );
+ this.testTable.tailRecord );
assertEquals( this.h1,
it.next() );
this.testTable.clear();
@@ -262,7 +262,7 @@
this.testTable.add( this.h10 );
this.testTable.add( this.h100 );
it = new IteratorFromPositionToTableStart( this.testTable.headRecord,
- this.testTable.headRecord );
+ this.testTable.headRecord );
assertEquals( this.h1000,
it.next() );
this.testTable.clear();
@@ -271,7 +271,7 @@
this.testTable.add( this.h10 );
this.testTable.add( this.h100 );
it = new IteratorFromPositionToTableStart( this.testTable.headRecord,
- this.testTable.tailRecord );
+ this.testTable.tailRecord );
assertEquals( this.h1,
it.next() );
it = new IteratorFromPositionToTableStart( new TableRecord( this.h1 ) );
@@ -285,7 +285,7 @@
public void testCurrent() {
this.testTable.add( this.h1 );
IteratorFromPositionToTableStart it = new IteratorFromPositionToTableStart( this.testTable.headRecord,
- this.testTable.tailRecord );
+ this.testTable.tailRecord );
assertEquals( this.h1,
it.next() );
this.testTable.clear();
@@ -294,7 +294,7 @@
this.testTable.add( this.h10 );
this.testTable.add( this.h100 );
it = new IteratorFromPositionToTableStart( this.testTable.headRecord,
- this.testTable.headRecord );
+ this.testTable.headRecord );
assertEquals( this.h1000,
it.next() );
this.testTable.clear();
@@ -303,7 +303,7 @@
this.testTable.add( this.h10 );
this.testTable.add( this.h100 );
it = new IteratorFromPositionToTableStart( this.testTable.headRecord,
- this.testTable.tailRecord );
+ this.testTable.tailRecord );
assertEquals( this.h1,
it.next() );
it = new IteratorFromPositionToTableStart( new TableRecord( this.h1 ) );
@@ -317,7 +317,7 @@
public void testPeekNext() {
this.testTable.add( this.h1 );
IteratorFromPositionToTableStart it = new IteratorFromPositionToTableStart( this.testTable.headRecord,
- this.testTable.tailRecord );
+ this.testTable.tailRecord );
assertEquals( this.h1,
it.peekNext() );
assertEquals( this.h1,
@@ -328,7 +328,7 @@
this.testTable.add( this.h10 );
this.testTable.add( this.h100 );
it = new IteratorFromPositionToTableStart( this.testTable.headRecord,
- this.testTable.headRecord );
+ this.testTable.headRecord );
assertEquals( this.h1000,
it.peekNext() );
assertEquals( this.h1000,
@@ -339,7 +339,7 @@
this.testTable.add( this.h10 );
this.testTable.add( this.h100 );
it = new IteratorFromPositionToTableStart( this.testTable.headRecord,
- this.testTable.tailRecord );
+ this.testTable.tailRecord );
assertEquals( this.h1,
it.peekNext() );
assertEquals( this.h1,
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/util/TableTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/util/TableTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/util/TableTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -44,11 +44,15 @@
Table testTable;
protected void setUp() {
- this.testTable = new Table( LoadOrderConflictResolver.getInstance( ) );
- this.h1 = new DefaultFactHandle( 1, "1" );
- this.h1000 = new DefaultFactHandle( 1000, "1000" );
- this.h100 = new DefaultFactHandle( 100, "100" );
- this.h10 = new DefaultFactHandle( 10, "10" );
+ this.testTable = new Table( LoadOrderConflictResolver.getInstance() );
+ this.h1 = new DefaultFactHandle( 1,
+ "1" );
+ this.h1000 = new DefaultFactHandle( 1000,
+ "1000" );
+ this.h100 = new DefaultFactHandle( 100,
+ "100" );
+ this.h10 = new DefaultFactHandle( 10,
+ "10" );
}
/*
@@ -82,33 +86,34 @@
assertTrue( this.testTable.contains( this.h1 ) );
this.testTable.remove( this.h1 );
assertFalse( this.testTable.contains( this.h1 ) );
- final Iterator it = this.testTable.iterator( );
- assertTrue( it.hasNext( ) );
- assertEquals( it.next( ), this.h10 );
+ final Iterator it = this.testTable.iterator();
+ assertTrue( it.hasNext() );
+ assertEquals( it.next(),
+ this.h10 );
}
/*
* Test method for 'org.drools..util.Table.isEmpty()'
*/
public void testIsEmpty() {
- assertTrue( this.testTable.isEmpty( ) );
+ assertTrue( this.testTable.isEmpty() );
this.testTable.add( this.h1 );
- assertFalse( this.testTable.isEmpty( ) );
+ assertFalse( this.testTable.isEmpty() );
this.testTable.remove( this.h1 );
- assertTrue( this.testTable.isEmpty( ) );
+ assertTrue( this.testTable.isEmpty() );
this.testTable.add( this.h1 );
this.testTable.add( this.h1000 );
this.testTable.add( this.h100 );
this.testTable.add( this.h10 );
- assertFalse( this.testTable.isEmpty( ) );
+ assertFalse( this.testTable.isEmpty() );
this.testTable.remove( this.h100 );
- assertFalse( this.testTable.isEmpty( ) );
+ assertFalse( this.testTable.isEmpty() );
this.testTable.remove( this.h1000 );
- assertFalse( this.testTable.isEmpty( ) );
+ assertFalse( this.testTable.isEmpty() );
this.testTable.remove( this.h1 );
- assertFalse( this.testTable.isEmpty( ) );
+ assertFalse( this.testTable.isEmpty() );
this.testTable.remove( this.h10 );
- assertTrue( this.testTable.isEmpty( ) );
+ assertTrue( this.testTable.isEmpty() );
}
/*
@@ -116,11 +121,13 @@
*/
public void testHeadObject() {
this.testTable.add( this.h1 );
- assertEquals( this.h1, this.testTable.headRecord.object );
+ assertEquals( this.h1,
+ this.testTable.headRecord.object );
this.testTable.add( this.h1000 );
this.testTable.add( this.h100 );
this.testTable.add( this.h10 );
- assertEquals( this.h1000, this.testTable.headRecord.object );
+ assertEquals( this.h1000,
+ this.testTable.headRecord.object );
}
/*
@@ -128,11 +135,13 @@
*/
public void testTailObject() {
this.testTable.add( this.h1 );
- assertEquals( this.testTable.tailRecord.object, this.h1 );
+ assertEquals( this.testTable.tailRecord.object,
+ this.h1 );
this.testTable.add( this.h1000 );
this.testTable.add( this.h100 );
this.testTable.add( this.h10 );
- assertEquals( this.testTable.tailRecord.object, this.h1 );
+ assertEquals( this.testTable.tailRecord.object,
+ this.h1 );
}
/*
@@ -141,28 +150,33 @@
public void testIterator() {
Iterator it;
// empty iterator
- it = this.testTable.iterator( );
- assertFalse( it.hasNext( ) );
+ it = this.testTable.iterator();
+ assertFalse( it.hasNext() );
// iterate over a single element
this.testTable.add( this.h1 );
- it = this.testTable.iterator( );
- assertTrue( it.hasNext( ) );
- assertEquals( it.next( ), this.h1 );
- assertFalse( it.hasNext( ) );
+ it = this.testTable.iterator();
+ assertTrue( it.hasNext() );
+ assertEquals( it.next(),
+ this.h1 );
+ assertFalse( it.hasNext() );
// several items iterator
this.testTable.add( this.h1000 );
this.testTable.add( this.h100 );
this.testTable.add( this.h10 );
- it = this.testTable.iterator( );
- assertTrue( it.hasNext( ) );
- assertEquals( it.next( ), this.h1000 );
- assertTrue( it.hasNext( ) );
- assertEquals( it.next( ), this.h100 );
- assertTrue( it.hasNext( ) );
- assertEquals( it.next( ), this.h10 );
- assertTrue( it.hasNext( ) );
- assertEquals( it.next( ), this.h1 );
- assertFalse( it.hasNext( ) );
+ it = this.testTable.iterator();
+ assertTrue( it.hasNext() );
+ assertEquals( it.next(),
+ this.h1000 );
+ assertTrue( it.hasNext() );
+ assertEquals( it.next(),
+ this.h100 );
+ assertTrue( it.hasNext() );
+ assertEquals( it.next(),
+ this.h10 );
+ assertTrue( it.hasNext() );
+ assertEquals( it.next(),
+ this.h1 );
+ assertFalse( it.hasNext() );
}
public void testTailIterator() {
@@ -173,21 +187,26 @@
TableIterator it = this.testTable.iteratorFromPositionToTableStart( this.h100,
this.h10 );
- assertTrue( it.hasNext( ) );
- assertEquals( it.next( ), this.h10 );
- assertTrue( it.hasNext( ) );
- assertEquals( it.next( ), this.h1 );
- assertFalse( it.hasNext( ) );
- it.reset( );
- assertTrue( it.hasNext( ) );
- assertEquals( it.next( ), this.h100 );
- assertTrue( it.hasNext( ) );
- assertEquals( it.next( ), this.h10 );
- assertTrue( it.hasNext( ) );
- assertEquals( it.next( ), this.h1 );
- assertFalse( it.hasNext( ) );
+ assertTrue( it.hasNext() );
+ assertEquals( it.next(),
+ this.h10 );
+ assertTrue( it.hasNext() );
+ assertEquals( it.next(),
+ this.h1 );
+ assertFalse( it.hasNext() );
+ it.reset();
+ assertTrue( it.hasNext() );
+ assertEquals( it.next(),
+ this.h100 );
+ assertTrue( it.hasNext() );
+ assertEquals( it.next(),
+ this.h10 );
+ assertTrue( it.hasNext() );
+ assertEquals( it.next(),
+ this.h1 );
+ assertFalse( it.hasNext() );
- this.testTable.clear( );
+ this.testTable.clear();
final DefaultFactHandle fh1 = new DefaultFactHandle( 1,
new Guest( "1",
Sex.resolve( "m" ),
@@ -204,14 +223,17 @@
new Guest( "3",
Sex.resolve( "f" ),
Hobby.resolve( "h2" ) ) );
- final DefaultFactHandle fhC = new DefaultFactHandle( 5, new Context( "start" ) );
+ final DefaultFactHandle fhC = new DefaultFactHandle( 5,
+ new Context( "start" ) );
this.testTable.add( fh1 );
this.testTable.add( fh2 );
this.testTable.add( fh3 );
this.testTable.add( fh4 );
- it = this.testTable.iteratorFromPositionToTableStart( fhC, fhC );
- assertTrue( it.hasNext( ) );
- assertEquals( it.next( ), fh4 );
+ it = this.testTable.iteratorFromPositionToTableStart( fhC,
+ fhC );
+ assertTrue( it.hasNext() );
+ assertEquals( it.next(),
+ fh4 );
}
public void testHeadIterator() {
@@ -220,12 +242,15 @@
this.testTable.add( this.h100 );
this.testTable.add( this.h10 );
final TableIterator it = this.testTable.iteratorFromPositionToTableEnd( this.h1 );
- assertTrue( it.hasNext( ) );
- assertEquals( it.next( ), this.h10 );
- assertTrue( it.hasNext( ) );
- assertEquals( it.next( ), this.h100 );
- assertTrue( it.hasNext( ) );
- assertEquals( it.next( ), this.h1000 );
- assertFalse( it.hasNext( ) );
+ assertTrue( it.hasNext() );
+ assertEquals( it.next(),
+ this.h10 );
+ assertTrue( it.hasNext() );
+ assertEquals( it.next(),
+ this.h100 );
+ assertTrue( it.hasNext() );
+ assertEquals( it.next(),
+ this.h1000 );
+ assertFalse( it.hasNext() );
}
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/util/TokenStackTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/util/TokenStackTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/leaps/util/TokenStackTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -15,7 +15,7 @@
assertTrue( stack.empty() );
final Token token = new Token( null,
new LeapsFactHandle( 3,
- new Object() ),
+ new Object() ),
null );
stack.push( token );
assertFalse( stack.empty() );
@@ -30,37 +30,37 @@
final Object object = new Object();
final Token token1 = new Token( null,
new LeapsFactHandle( 1,
- object ),
+ object ),
null );
stack.push( token1 );
final Token token2 = new Token( null,
new LeapsFactHandle( 2,
- object ),
+ object ),
null );
stack.push( token2 );
final Token token10 = new Token( null,
new LeapsFactHandle( 10,
- object ),
+ object ),
null );
stack.push( token10 );
final Token token8 = new Token( null,
new LeapsFactHandle( 8,
- object ),
+ object ),
null );
stack.push( token8 );
final Token token6 = new Token( null,
new LeapsFactHandle( 6,
- object ),
+ object ),
null );
stack.push( token6 );
final Token token3 = new Token( null,
new LeapsFactHandle( 3,
- object ),
+ object ),
null );
stack.push( token3 );
final Token token4 = new Token( null,
new LeapsFactHandle( 4,
- object ),
+ object ),
null );
stack.push( token4 );
@@ -80,37 +80,37 @@
final Object object = new Object();
final Token token1 = new Token( null,
new LeapsFactHandle( 1,
- object ),
+ object ),
null );
stack.push( token1 );
final Token token2 = new Token( null,
new LeapsFactHandle( 2,
- object ),
+ object ),
null );
stack.push( token2 );
final Token token10 = new Token( null,
new LeapsFactHandle( 10,
- object ),
+ object ),
null );
stack.push( token10 );
final Token token8 = new Token( null,
new LeapsFactHandle( 8,
- object ),
+ object ),
null );
stack.push( token8 );
final Token token6 = new Token( null,
new LeapsFactHandle( 6,
- object ),
+ object ),
null );
stack.push( token6 );
final Token token3 = new Token( null,
new LeapsFactHandle( 3,
- object ),
+ object ),
null );
stack.push( token3 );
final Token token4 = new Token( null,
new LeapsFactHandle( 4,
- object ),
+ object ),
null );
stack.push( token4 );
@@ -140,37 +140,37 @@
final Object object = new Object();
final Token token1 = new Token( null,
new LeapsFactHandle( 1,
- object ),
+ object ),
null );
stack.push( token1 );
final Token token2 = new Token( null,
new LeapsFactHandle( 2,
- object ),
+ object ),
null );
stack.push( token2 );
final Token token10 = new Token( null,
new LeapsFactHandle( 10,
- object ),
+ object ),
null );
stack.push( token10 );
final Token token8 = new Token( null,
new LeapsFactHandle( 8,
- object ),
+ object ),
null );
stack.push( token8 );
final Token token6 = new Token( null,
new LeapsFactHandle( 6,
- object ),
+ object ),
null );
stack.push( token6 );
final Token token3 = new Token( null,
new LeapsFactHandle( 3,
- object ),
+ object ),
null );
stack.push( token3 );
final Token token4 = new Token( null,
new LeapsFactHandle( 4,
- object ),
+ object ),
null );
stack.push( token4 );
@@ -198,37 +198,37 @@
final Object object = new Object();
final Token token1 = new Token( null,
new LeapsFactHandle( 1,
- object ),
+ object ),
null );
stack.push( token1 );
final Token token2 = new Token( null,
new LeapsFactHandle( 2,
- object ),
+ object ),
null );
stack.push( token2 );
final Token token10 = new Token( null,
new LeapsFactHandle( 10,
- object ),
+ object ),
null );
stack.push( token10 );
final Token token8 = new Token( null,
new LeapsFactHandle( 8,
- object ),
+ object ),
null );
stack.push( token8 );
final Token token6 = new Token( null,
new LeapsFactHandle( 6,
- object ),
+ object ),
null );
stack.push( token6 );
final Token token3 = new Token( null,
new LeapsFactHandle( 3,
- object ),
+ object ),
null );
stack.push( token3 );
final Token token4 = new Token( null,
new LeapsFactHandle( 4,
- object ),
+ object ),
null );
stack.push( token4 );
@@ -258,37 +258,37 @@
final Object object = new Object();
final Token token1 = new Token( null,
new LeapsFactHandle( 1,
- object ),
+ object ),
null );
stack.push( token1 );
final Token token2 = new Token( null,
new LeapsFactHandle( 2,
- object ),
+ object ),
null );
stack.push( token2 );
final Token token10 = new Token( null,
new LeapsFactHandle( 10,
- object ),
+ object ),
null );
stack.push( token10 );
final Token token8 = new Token( null,
new LeapsFactHandle( 8,
- object ),
+ object ),
null );
stack.push( token8 );
final Token token6 = new Token( null,
new LeapsFactHandle( 6,
- object ),
+ object ),
null );
stack.push( token6 );
final Token token3 = new Token( null,
new LeapsFactHandle( 3,
- object ),
+ object ),
null );
stack.push( token3 );
final Token token4 = new Token( null,
new LeapsFactHandle( 4,
- object ),
+ object ),
null );
stack.push( token4 );
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/AccumulateNodeTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/AccumulateNodeTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/AccumulateNodeTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -73,11 +73,11 @@
this.accumulator = new MockAccumulator();
- ObjectType srcObjType = new ClassObjectType( String.class );
- Column sourceColumn = new Column( 0,
+ final ObjectType srcObjType = new ClassObjectType( String.class );
+ final Column sourceColumn = new Column( 0,
srcObjType );
- ObjectType resultObjType = new ClassObjectType( String.class );
- Column resultColumn = new Column( 1,
+ final ObjectType resultObjType = new ClassObjectType( String.class );
+ final Column resultColumn = new Column( 1,
resultObjType );
this.accumulate = new Accumulate( sourceColumn,
resultColumn,
@@ -112,18 +112,18 @@
* Test method for {@link org.drools.reteoo.AccumulateNode#updateNewNode(InternalWorkingMemory, org.drools.spi.PropagationContext)}.
*/
public void testUpdateNewNode() {
- this.node.updateNewNode( workingMemory,
- context );
+ this.node.updateNewNode( this.workingMemory,
+ this.context );
Assert.assertEquals( "No tuple should be propagated",
0,
this.sink.getAsserted().size() );
- this.node.assertTuple( new ReteTuple( (DefaultFactHandle) workingMemory.getFactHandleFactory().newFactHandle( "cheese" ) ),
- context,
- workingMemory );
- this.node.assertTuple( new ReteTuple( (DefaultFactHandle) workingMemory.getFactHandleFactory().newFactHandle( "other cheese" ) ),
- context,
- workingMemory );
+ this.node.assertTuple( new ReteTuple( this.workingMemory.getFactHandleFactory().newFactHandle( "cheese" ) ),
+ this.context,
+ this.workingMemory );
+ this.node.assertTuple( new ReteTuple( this.workingMemory.getFactHandleFactory().newFactHandle( "other cheese" ) ),
+ this.context,
+ this.workingMemory );
Assert.assertEquals( "Two tuples should have been propagated",
2,
@@ -132,8 +132,8 @@
final MockTupleSink otherSink = new MockTupleSink();
this.node.addTupleSink( otherSink );
- this.node.updateNewNode( workingMemory,
- context );
+ this.node.updateNewNode( this.workingMemory,
+ this.context );
Assert.assertEquals( "Two tuples should have been propagated",
2,
@@ -145,12 +145,12 @@
*/
public void testGetPropagatedTuples() {
- this.node.assertTuple( new ReteTuple( (DefaultFactHandle) workingMemory.getFactHandleFactory().newFactHandle( "cheese" ) ),
- context,
- workingMemory );
- this.node.assertTuple( new ReteTuple( (DefaultFactHandle) workingMemory.getFactHandleFactory().newFactHandle( "other cheese" ) ),
- context,
- workingMemory );
+ this.node.assertTuple( new ReteTuple( this.workingMemory.getFactHandleFactory().newFactHandle( "cheese" ) ),
+ this.context,
+ this.workingMemory );
+ this.node.assertTuple( new ReteTuple( this.workingMemory.getFactHandleFactory().newFactHandle( "other cheese" ) ),
+ this.context,
+ this.workingMemory );
Assert.assertEquals( "Two tuples should have been propagated",
2,
@@ -159,8 +159,8 @@
final Tuple t1 = (Tuple) ((Object[]) this.sink.getAsserted().get( 0 ))[0];
final Tuple t2 = (Tuple) ((Object[]) this.sink.getAsserted().get( 1 ))[0];
- List propagated = this.node.getPropagatedTuples( workingMemory,
- sink );
+ final List propagated = this.node.getPropagatedTuples( this.workingMemory,
+ this.sink );
Assert.assertEquals( "Wrong Tuple propagated",
t1,
propagated.get( 0 ) );
@@ -174,7 +174,7 @@
* Test method for {@link org.drools.reteoo.AccumulateNode#assertTuple(org.drools.reteoo.ReteTuple, org.drools.spi.PropagationContext, org.drools.reteoo.ReteooWorkingMemory)}.
*/
public void testAssertTuple() {
- final DefaultFactHandle f0 = (DefaultFactHandle) workingMemory.getFactHandleFactory().newFactHandle( "cheese" );
+ final DefaultFactHandle f0 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "cheese" );
final ReteTuple tuple0 = new ReteTuple( f0 );
// assert tuple, should add one to left memory
@@ -190,7 +190,7 @@
this.accumulator.getMatchingObjects().isEmpty() );
// assert tuple, should add left memory
- final DefaultFactHandle f1 = (DefaultFactHandle) workingMemory.getFactHandleFactory().newFactHandle( "other cheese" );
+ final DefaultFactHandle f1 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "other cheese" );
final ReteTuple tuple1 = new ReteTuple( f1 );
this.node.assertTuple( tuple1,
@@ -217,17 +217,17 @@
* Test method for {@link org.drools.reteoo.AccumulateNode#assertTuple(org.drools.reteoo.ReteTuple, org.drools.spi.PropagationContext, org.drools.reteoo.ReteooWorkingMemory)}.
*/
public void testAssertTupleWithObjects() {
- final DefaultFactHandle f0 = (DefaultFactHandle) workingMemory.getFactHandleFactory().newFactHandle( "cheese" );
- final DefaultFactHandle f1 = (DefaultFactHandle) workingMemory.getFactHandleFactory().newFactHandle( "other cheese" );
+ final DefaultFactHandle f0 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "cheese" );
+ final DefaultFactHandle f1 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "other cheese" );
final ReteTuple tuple0 = new ReteTuple( f0 );
this.node.assertObject( f0,
- context,
- workingMemory );
+ this.context,
+ this.workingMemory );
this.node.assertObject( f1,
- context,
- workingMemory );
+ this.context,
+ this.workingMemory );
// assert tuple, should add one to left memory
this.node.assertTuple( tuple0,
@@ -269,8 +269,8 @@
* Test method for {@link org.drools.reteoo.AccumulateNode#modifyTuple(org.drools.reteoo.ReteTuple, org.drools.spi.PropagationContext, org.drools.reteoo.ReteooWorkingMemory)}.
*/
public void testModifyTuple() {
- final DefaultFactHandle f0 = (DefaultFactHandle) workingMemory.getFactHandleFactory().newFactHandle( "cheese" );
-
+ final DefaultFactHandle f0 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "cheese" );
+
final ReteTuple tuple0 = new ReteTuple( f0 );
// assert tuple, should add one to left memory
@@ -302,7 +302,7 @@
* Test method for {@link org.drools.reteoo.AccumulateNode#retractTuple(org.drools.reteoo.ReteTuple, org.drools.spi.PropagationContext, org.drools.reteoo.ReteooWorkingMemory)}.
*/
public void testRetractTuple() {
- final DefaultFactHandle f0 = (DefaultFactHandle) workingMemory.getFactHandleFactory().newFactHandle( "cheese" );
+ final DefaultFactHandle f0 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "cheese" );
final ReteTuple tuple0 = new ReteTuple( f0 );
@@ -333,9 +333,9 @@
* Test method for {@link org.drools.reteoo.AccumulateNode#assertObject(InternalFactHandle, org.drools.spi.PropagationContext, InternalWorkingMemory)}.
*/
public void testAssertObject() {
- final DefaultFactHandle f0 = (DefaultFactHandle) workingMemory.getFactHandleFactory().newFactHandle( "cheese" );
- final DefaultFactHandle f1 = (DefaultFactHandle) workingMemory.getFactHandleFactory().newFactHandle( "other cheese" );
-
+ final DefaultFactHandle f0 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "cheese" );
+ final DefaultFactHandle f1 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "other cheese" );
+
final ReteTuple tuple0 = new ReteTuple( f0 );
// assert tuple, should add one to left memory
@@ -352,8 +352,8 @@
this.accumulator.getMatchingObjects().size() );
this.node.assertObject( f0,
- context,
- workingMemory );
+ this.context,
+ this.workingMemory );
assertEquals( 1,
this.memory.getRightObjectMemory().size() );
assertEquals( 2,
@@ -362,8 +362,8 @@
this.accumulator.getMatchingObjects().size() );
this.node.assertObject( f1,
- context,
- workingMemory );
+ this.context,
+ this.workingMemory );
assertEquals( 2,
this.memory.getRightObjectMemory().size() );
@@ -378,17 +378,17 @@
* Test method for {@link org.drools.reteoo.AccumulateNode#modifyObject(InternalFactHandle, org.drools.spi.PropagationContext, InternalWorkingMemory)}.
*/
public void testModifyObject() {
- final DefaultFactHandle f0 = (DefaultFactHandle) workingMemory.getFactHandleFactory().newFactHandle( "cheese" );
- final DefaultFactHandle f1 = (DefaultFactHandle) workingMemory.getFactHandleFactory().newFactHandle( "other cheese" );
-
+ final DefaultFactHandle f0 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "cheese" );
+ final DefaultFactHandle f1 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "other cheese" );
+
final ReteTuple tuple0 = new ReteTuple( f0 );
this.node.assertObject( f0,
- context,
- workingMemory );
+ this.context,
+ this.workingMemory );
this.node.assertObject( f1,
- context,
- workingMemory );
+ this.context,
+ this.workingMemory );
// assert tuple, should add one to left memory
this.node.assertTuple( tuple0,
@@ -422,7 +422,7 @@
this.accumulator.getMatchingObjects().size() );
final Tuple tuple = (Tuple) this.memory.getLeftTupleMemory().iterator( this.workingMemory,
- f0 ).next();
+ f0 ).next();
assertEquals( tuple0,
tuple );
@@ -432,17 +432,17 @@
* Test method for {@link org.drools.reteoo.AccumulateNode#retractObject(InternalFactHandle, org.drools.spi.PropagationContext, InternalWorkingMemory)}.
*/
public void testRetractObject() {
- final DefaultFactHandle f0 = (DefaultFactHandle) workingMemory.getFactHandleFactory().newFactHandle( "cheese" );
- final DefaultFactHandle f1 = (DefaultFactHandle) workingMemory.getFactHandleFactory().newFactHandle( "other cheese" );
-
+ final DefaultFactHandle f0 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "cheese" );
+ final DefaultFactHandle f1 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "other cheese" );
+
final ReteTuple tuple0 = new ReteTuple( f0 );
this.node.assertObject( f0,
- context,
- workingMemory );
+ this.context,
+ this.workingMemory );
this.node.assertObject( f1,
- context,
- workingMemory );
+ this.context,
+ this.workingMemory );
assertEquals( 2,
this.memory.getRightObjectMemory().size() );
@@ -462,8 +462,8 @@
this.accumulator.getMatchingObjects().size() );
this.node.retractObject( f1,
- context,
- workingMemory );
+ this.context,
+ this.workingMemory );
assertEquals( 1,
this.memory.getRightObjectMemory().size() );
assertEquals( 1,
@@ -474,8 +474,8 @@
this.accumulator.getMatchingObjects().size() );
this.node.retractObject( f0,
- context,
- workingMemory );
+ this.context,
+ this.workingMemory );
assertEquals( 0,
this.memory.getRightObjectMemory().size() );
assertEquals( 2,
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/AlphaNodeTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/AlphaNodeTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/AlphaNodeTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -501,7 +501,7 @@
}
public void testUpdateSinkWithoutMemory() throws FactException,
- IntrospectionException {
+ IntrospectionException {
// An AlphaNode without memory should try and repropagate from its source
final ReteooWorkingMemory workingMemory = new ReteooWorkingMemory( 1,
(ReteooRuleBase) RuleBaseFactory.newRuleBase() );
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/CollectNodeTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/CollectNodeTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/CollectNodeTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -68,11 +68,11 @@
this.objectSource = new MockObjectSource( 4 );
this.sink = new MockTupleSink();
- ObjectType srcObjType = new ClassObjectType( String.class );
- Column sourceColumn = new Column( 0,
+ final ObjectType srcObjType = new ClassObjectType( String.class );
+ final Column sourceColumn = new Column( 0,
srcObjType );
- ObjectType resultObjType = new ClassObjectType( LinkedList.class );
- Column resultColumn = new Column( 1,
+ final ObjectType resultObjType = new ClassObjectType( LinkedList.class );
+ final Column resultColumn = new Column( 1,
resultObjType );
this.collect = new Collect( sourceColumn,
resultColumn );
@@ -101,18 +101,18 @@
}
public void testUpdateNewNode() {
- this.node.updateNewNode( workingMemory,
- context );
+ this.node.updateNewNode( this.workingMemory,
+ this.context );
Assert.assertEquals( "No tuple should be propagated",
0,
this.sink.getAsserted().size() );
- this.node.assertTuple( new ReteTuple( (DefaultFactHandle) workingMemory.getFactHandleFactory().newFactHandle( "cheese" ) ),
- context,
- workingMemory );
- this.node.assertTuple( new ReteTuple( (DefaultFactHandle) workingMemory.getFactHandleFactory().newFactHandle( "other cheese" ) ),
- context,
- workingMemory );
+ this.node.assertTuple( new ReteTuple( this.workingMemory.getFactHandleFactory().newFactHandle( "cheese" ) ),
+ this.context,
+ this.workingMemory );
+ this.node.assertTuple( new ReteTuple( this.workingMemory.getFactHandleFactory().newFactHandle( "other cheese" ) ),
+ this.context,
+ this.workingMemory );
Assert.assertEquals( "Two tuples should have been propagated",
2,
@@ -121,8 +121,8 @@
final MockTupleSink otherSink = new MockTupleSink();
this.node.addTupleSink( otherSink );
- this.node.updateNewNode( workingMemory,
- context );
+ this.node.updateNewNode( this.workingMemory,
+ this.context );
Assert.assertEquals( "Two tuples should have been propagated",
2,
@@ -131,12 +131,12 @@
public void testGetPropagatedTuples() {
- this.node.assertTuple( new ReteTuple( (DefaultFactHandle) workingMemory.getFactHandleFactory().newFactHandle( "cheese" ) ),
- context,
- workingMemory );
- this.node.assertTuple( new ReteTuple( (DefaultFactHandle) workingMemory.getFactHandleFactory().newFactHandle( "other cheese" ) ),
- context,
- workingMemory );
+ this.node.assertTuple( new ReteTuple( this.workingMemory.getFactHandleFactory().newFactHandle( "cheese" ) ),
+ this.context,
+ this.workingMemory );
+ this.node.assertTuple( new ReteTuple( this.workingMemory.getFactHandleFactory().newFactHandle( "other cheese" ) ),
+ this.context,
+ this.workingMemory );
Assert.assertEquals( "Two tuples should have been propagated",
2,
@@ -145,8 +145,8 @@
final Tuple t1 = (Tuple) ((Object[]) this.sink.getAsserted().get( 0 ))[0];
final Tuple t2 = (Tuple) ((Object[]) this.sink.getAsserted().get( 1 ))[0];
- List propagated = this.node.getPropagatedTuples( workingMemory,
- sink );
+ final List propagated = this.node.getPropagatedTuples( this.workingMemory,
+ this.sink );
Assert.assertEquals( "Wrong Tuple propagated",
t1,
propagated.get( 0 ) );
@@ -157,7 +157,7 @@
}
public void testAssertTuple() {
- final DefaultFactHandle f0 = (DefaultFactHandle) workingMemory.getFactHandleFactory().newFactHandle( "cheese" );
+ final DefaultFactHandle f0 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "cheese" );
final ReteTuple tuple0 = new ReteTuple( f0 );
// assert tuple, should add one to left memory
@@ -170,10 +170,10 @@
assertEquals( 0,
this.memory.getRightObjectMemory().size() );
Assert.assertTrue( "An empty collection should be propagated",
- ((Collection) ((DefaultFactHandle)((Tuple) ((Object[])this.sink.getAsserted().get( 0 ))[0]).get( 1 )).getObject()).isEmpty() );
+ ((Collection) ((DefaultFactHandle) ((Tuple) ((Object[]) this.sink.getAsserted().get( 0 ))[0]).get( 1 )).getObject()).isEmpty() );
// assert tuple, should add left memory
- final DefaultFactHandle f1 = (DefaultFactHandle) workingMemory.getFactHandleFactory().newFactHandle( "other cheese" );
+ final DefaultFactHandle f1 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "other cheese" );
final ReteTuple tuple1 = new ReteTuple( f1 );
this.node.assertTuple( tuple1,
@@ -182,7 +182,7 @@
assertEquals( 2,
this.memory.getLeftTupleMemory().size() );
Assert.assertTrue( "An empty collection should be propagated",
- ((Collection) ((DefaultFactHandle)((Tuple) ((Object[])this.sink.getAsserted().get( 1 ))[0]).get( 1 )).getObject()).isEmpty() );
+ ((Collection) ((DefaultFactHandle) ((Tuple) ((Object[]) this.sink.getAsserted().get( 1 ))[0]).get( 1 )).getObject()).isEmpty() );
final ReteTuple tuple = (ReteTuple) this.memory.getLeftTupleMemory().iterator( this.workingMemory,
f0 ).next();
@@ -197,17 +197,17 @@
}
public void testAssertTupleWithObjects() {
- final DefaultFactHandle f0 = (DefaultFactHandle) workingMemory.getFactHandleFactory().newFactHandle( "cheese" );
- final DefaultFactHandle f1 = (DefaultFactHandle) workingMemory.getFactHandleFactory().newFactHandle( "other cheese" );
+ final DefaultFactHandle f0 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "cheese" );
+ final DefaultFactHandle f1 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "other cheese" );
final ReteTuple tuple0 = new ReteTuple( f0 );
this.node.assertObject( f0,
- context,
- workingMemory );
+ this.context,
+ this.workingMemory );
this.node.assertObject( f1,
- context,
- workingMemory );
+ this.context,
+ this.workingMemory );
// assert tuple, should add one to left memory
this.node.assertTuple( tuple0,
@@ -220,7 +220,7 @@
this.memory.getRightObjectMemory().size() );
Assert.assertEquals( "Wrong number of elements in matching objects list ",
2,
- ((Collection) ((DefaultFactHandle)((Tuple) ((Object[])this.sink.getAsserted().get( 0 ))[0]).get( 1 )).getObject()).size() );
+ ((Collection) ((DefaultFactHandle) ((Tuple) ((Object[]) this.sink.getAsserted().get( 0 ))[0]).get( 1 )).getObject()).size() );
// assert tuple, should add left memory
final ReteTuple tuple1 = new ReteTuple( f1 );
@@ -231,7 +231,7 @@
this.memory.getLeftTupleMemory().size() );
Assert.assertEquals( "Wrong number of elements in matching objects list ",
2,
- ((Collection) ((DefaultFactHandle)((Tuple) ((Object[])this.sink.getAsserted().get( 1 ))[0]).get( 1 )).getObject()).size() );
+ ((Collection) ((DefaultFactHandle) ((Tuple) ((Object[]) this.sink.getAsserted().get( 1 ))[0]).get( 1 )).getObject()).size() );
final ReteTuple tuple = (ReteTuple) this.memory.getLeftTupleMemory().iterator( this.workingMemory,
f0 ).next();
@@ -246,7 +246,7 @@
}
public void testModifyTuple() {
- final DefaultFactHandle f0 = (DefaultFactHandle) workingMemory.getFactHandleFactory().newFactHandle( "cheese" );
+ final DefaultFactHandle f0 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "cheese" );
final ReteTuple tuple0 = new ReteTuple( f0 );
@@ -260,7 +260,7 @@
assertEquals( 0,
this.memory.getRightObjectMemory().size() );
Assert.assertTrue( "An empty collection should be propagated",
- ((Collection) ((DefaultFactHandle)((Tuple) ((Object[])this.sink.getAsserted().get( 0 ))[0]).get( 1 )).getObject()).isEmpty() );
+ ((Collection) ((DefaultFactHandle) ((Tuple) ((Object[]) this.sink.getAsserted().get( 0 ))[0]).get( 1 )).getObject()).isEmpty() );
this.node.modifyTuple( tuple0,
this.context,
@@ -272,11 +272,11 @@
assertEquals( 2,
this.sink.getAsserted().size() );
Assert.assertTrue( "An empty collection should be propagated",
- ((Collection) ((DefaultFactHandle)((Tuple) ((Object[])this.sink.getAsserted().get( 1 ))[0]).get( 1 )).getObject()).isEmpty() );
+ ((Collection) ((DefaultFactHandle) ((Tuple) ((Object[]) this.sink.getAsserted().get( 1 ))[0]).get( 1 )).getObject()).isEmpty() );
}
public void testRetractTuple() {
- final DefaultFactHandle f0 = (DefaultFactHandle) workingMemory.getFactHandleFactory().newFactHandle( "cheese" );
+ final DefaultFactHandle f0 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "cheese" );
final ReteTuple tuple0 = new ReteTuple( f0 );
@@ -290,7 +290,7 @@
assertEquals( 0,
this.memory.getRightObjectMemory().size() );
Assert.assertTrue( "An empty collection should be propagated",
- ((Collection) ((DefaultFactHandle)((Tuple) ((Object[])this.sink.getAsserted().get( 0 ))[0]).get( 1 )).getObject()).isEmpty() );
+ ((Collection) ((DefaultFactHandle) ((Tuple) ((Object[]) this.sink.getAsserted().get( 0 ))[0]).get( 1 )).getObject()).isEmpty() );
this.node.retractTuple( tuple0,
this.context,
@@ -304,8 +304,8 @@
}
public void testAssertObject() {
- final DefaultFactHandle f0 = (DefaultFactHandle) workingMemory.getFactHandleFactory().newFactHandle( "cheese" );
- final DefaultFactHandle f1 = (DefaultFactHandle) workingMemory.getFactHandleFactory().newFactHandle( "other cheese" );
+ final DefaultFactHandle f0 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "cheese" );
+ final DefaultFactHandle f1 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "other cheese" );
final ReteTuple tuple0 = new ReteTuple( f0 );
@@ -320,22 +320,22 @@
assertEquals( 1,
this.sink.getAsserted().size() );
Assert.assertTrue( "An empty collection should be propagated",
- ((Collection) ((DefaultFactHandle)((Tuple) ((Object[])this.sink.getAsserted().get( 0 ))[0]).get( 1 )).getObject()).isEmpty() );
+ ((Collection) ((DefaultFactHandle) ((Tuple) ((Object[]) this.sink.getAsserted().get( 0 ))[0]).get( 1 )).getObject()).isEmpty() );
this.node.assertObject( f0,
- context,
- workingMemory );
+ this.context,
+ this.workingMemory );
assertEquals( 1,
this.memory.getRightObjectMemory().size() );
assertEquals( 2,
this.sink.getAsserted().size() );
Assert.assertEquals( "Wrong number of elements in matching objects list ",
1,
- ((Collection) ((DefaultFactHandle)((Tuple) ((Object[])this.sink.getAsserted().get( 1 ))[0]).get( 1 )).getObject()).size() );
+ ((Collection) ((DefaultFactHandle) ((Tuple) ((Object[]) this.sink.getAsserted().get( 1 ))[0]).get( 1 )).getObject()).size() );
this.node.assertObject( f1,
- context,
- workingMemory );
+ this.context,
+ this.workingMemory );
assertEquals( 2,
this.memory.getRightObjectMemory().size() );
@@ -343,22 +343,22 @@
this.sink.getAsserted().size() );
Assert.assertEquals( "Wrong number of elements in matching objects list ",
2,
- ((Collection) ((DefaultFactHandle)((Tuple) ((Object[])this.sink.getAsserted().get( 2 ))[0]).get( 1 )).getObject()).size() );
+ ((Collection) ((DefaultFactHandle) ((Tuple) ((Object[]) this.sink.getAsserted().get( 2 ))[0]).get( 1 )).getObject()).size() );
}
public void testModifyObject() {
- final DefaultFactHandle f0 = (DefaultFactHandle) workingMemory.getFactHandleFactory().newFactHandle( "cheese" );
- final DefaultFactHandle f1 = (DefaultFactHandle) workingMemory.getFactHandleFactory().newFactHandle( "other cheese" );
+ final DefaultFactHandle f0 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "cheese" );
+ final DefaultFactHandle f1 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "other cheese" );
final ReteTuple tuple0 = new ReteTuple( f0 );
this.node.assertObject( f0,
- context,
- workingMemory );
+ this.context,
+ this.workingMemory );
this.node.assertObject( f1,
- context,
- workingMemory );
+ this.context,
+ this.workingMemory );
// assert tuple, should add one to left memory
this.node.assertTuple( tuple0,
@@ -375,7 +375,7 @@
this.sink.getRetracted().size() );
Assert.assertEquals( "Wrong number of elements in matching objects list ",
2,
- ((Collection) ((DefaultFactHandle)((Tuple) ((Object[])this.sink.getAsserted().get( 0 ))[0]).get( 1 )).getObject()).size() );
+ ((Collection) ((DefaultFactHandle) ((Tuple) ((Object[]) this.sink.getAsserted().get( 0 ))[0]).get( 1 )).getObject()).size() );
// assert tuple, should add left memory
this.node.modifyObject( f0,
@@ -389,27 +389,27 @@
this.sink.getRetracted().size() );
Assert.assertEquals( "Wrong number of elements in matching objects list ",
2,
- ((Collection) ((DefaultFactHandle)((Tuple) ((Object[])this.sink.getAsserted().get( 1 ))[0]).get( 1 )).getObject()).size() );
+ ((Collection) ((DefaultFactHandle) ((Tuple) ((Object[]) this.sink.getAsserted().get( 1 ))[0]).get( 1 )).getObject()).size() );
final Tuple tuple = (Tuple) this.memory.getLeftTupleMemory().iterator( this.workingMemory,
- f0 ).next();
+ f0 ).next();
assertEquals( tuple0,
tuple );
}
public void testRetractObject() {
- final DefaultFactHandle f0 = (DefaultFactHandle) workingMemory.getFactHandleFactory().newFactHandle( "cheese" );
- final DefaultFactHandle f1 = (DefaultFactHandle) workingMemory.getFactHandleFactory().newFactHandle( "other cheese" );
+ final DefaultFactHandle f0 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "cheese" );
+ final DefaultFactHandle f1 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "other cheese" );
final ReteTuple tuple0 = new ReteTuple( f0 );
this.node.assertObject( f0,
- context,
- workingMemory );
+ this.context,
+ this.workingMemory );
this.node.assertObject( f1,
- context,
- workingMemory );
+ this.context,
+ this.workingMemory );
assertEquals( 2,
this.memory.getRightObjectMemory().size() );
@@ -427,11 +427,11 @@
this.sink.getAsserted().size() );
Assert.assertEquals( "Wrong number of elements in matching objects list ",
2,
- ((Collection) ((DefaultFactHandle)((Tuple) ((Object[])this.sink.getAsserted().get( 0 ))[0]).get( 1 )).getObject()).size() );
+ ((Collection) ((DefaultFactHandle) ((Tuple) ((Object[]) this.sink.getAsserted().get( 0 ))[0]).get( 1 )).getObject()).size() );
this.node.retractObject( f1,
- context,
- workingMemory );
+ this.context,
+ this.workingMemory );
assertEquals( 1,
this.memory.getRightObjectMemory().size() );
assertEquals( 1,
@@ -440,11 +440,11 @@
this.sink.getAsserted().size() );
Assert.assertEquals( "Wrong number of elements in matching objects list ",
1,
- ((Collection) ((DefaultFactHandle)((Tuple) ((Object[])this.sink.getAsserted().get( 1 ))[0]).get( 1 )).getObject()).size() );
+ ((Collection) ((DefaultFactHandle) ((Tuple) ((Object[]) this.sink.getAsserted().get( 1 ))[0]).get( 1 )).getObject()).size() );
this.node.retractObject( f0,
- context,
- workingMemory );
+ this.context,
+ this.workingMemory );
assertEquals( 0,
this.memory.getRightObjectMemory().size() );
assertEquals( 2,
@@ -453,7 +453,7 @@
this.sink.getAsserted().size() );
Assert.assertEquals( "Wrong number of elements in matching objects list ",
0,
- ((Collection) ((DefaultFactHandle)((Tuple) ((Object[])this.sink.getAsserted().get( 2 ))[0]).get( 1 )).getObject()).size() );
+ ((Collection) ((DefaultFactHandle) ((Tuple) ((Object[]) this.sink.getAsserted().get( 2 ))[0]).get( 1 )).getObject()).size() );
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/FactHandleTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/FactHandleTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/FactHandleTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -70,9 +70,9 @@
"cheese" );
assertEquals( "cheese".hashCode(),
f0.getObjectHashCode() );
-
+
assertEquals( 234,
- f0.hashCode() );
+ f0.hashCode() );
}
public void testToExternalForm() {
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/FromNodeTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/FromNodeTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/FromNodeTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -21,8 +21,8 @@
import org.drools.rule.Declaration;
import org.drools.rule.LiteralConstraint;
import org.drools.rule.VariableConstraint;
+import org.drools.spi.AlphaNodeFieldConstraint;
import org.drools.spi.DataProvider;
-import org.drools.spi.AlphaNodeFieldConstraint;
import org.drools.spi.FieldValue;
import org.drools.spi.MockField;
import org.drools.spi.PropagationContext;
@@ -45,27 +45,27 @@
ValueType.STRING_TYPE.getEvaluator( Operator.EQUAL ),
field );
- List list = new ArrayList();
- Cheese cheese1 = new Cheese( "cheddar",
+ final List list = new ArrayList();
+ final Cheese cheese1 = new Cheese( "cheddar",
20 );
- Cheese cheese2 = new Cheese( "brie",
+ final Cheese cheese2 = new Cheese( "brie",
20 );
list.add( cheese1 );
list.add( cheese2 );
- MockDataProvider dataProvider = new MockDataProvider( list );
+ final MockDataProvider dataProvider = new MockDataProvider( list );
- FromNode from = new FromNode( 3,
+ final FromNode from = new FromNode( 3,
dataProvider,
null,
new AlphaNodeFieldConstraint[]{constraint},
null );
- MockTupleSink sink = new MockTupleSink( 5 );
+ final MockTupleSink sink = new MockTupleSink( 5 );
from.addTupleSink( sink );
- Person person1 = new Person( "xxx1",
+ final Person person1 = new Person( "xxx1",
30 );
- FactHandle person1Handle = workingMemory.assertObject( person1 );
- ReteTuple tuple1 = new ReteTuple( (DefaultFactHandle) person1Handle );
+ final FactHandle person1Handle = workingMemory.assertObject( person1 );
+ final ReteTuple tuple1 = new ReteTuple( (DefaultFactHandle) person1Handle );
from.assertTuple( tuple1,
context,
workingMemory );
@@ -76,15 +76,15 @@
//Set cheese1 to stilton and it should now propagate
cheese1.setType( "stilton" );
- Person person2 = new Person( "xxx2",
+ final Person person2 = new Person( "xxx2",
30 );
- FactHandle person2Handle = workingMemory.assertObject( person2 );
- ReteTuple tuple2 = new ReteTuple( (DefaultFactHandle) person2Handle );
+ final FactHandle person2Handle = workingMemory.assertObject( person2 );
+ final ReteTuple tuple2 = new ReteTuple( (DefaultFactHandle) person2Handle );
from.assertTuple( tuple2,
context,
workingMemory );
- List asserted = sink.getAsserted();
+ final List asserted = sink.getAsserted();
assertEquals( 1,
asserted.size() );
Tuple tuple = (Tuple) ((Object[]) asserted.get( 0 ))[0];
@@ -94,10 +94,10 @@
tuple.getFactHandles()[1].getObject() );
cheese2.setType( "stilton" );
- Person person3 = new Person( "xxx2",
+ final Person person3 = new Person( "xxx2",
30 );
- FactHandle person3Handle = workingMemory.assertObject( person3 );
- ReteTuple tuple3 = new ReteTuple( (DefaultFactHandle) person3Handle );
+ final FactHandle person3Handle = workingMemory.assertObject( person3 );
+ final ReteTuple tuple3 = new ReteTuple( (DefaultFactHandle) person3Handle );
from.assertTuple( tuple3,
context,
workingMemory );
@@ -133,38 +133,39 @@
final ClassFieldExtractor ageExtractor = new ClassFieldExtractor( Person.class,
"age" );
-
- Column column = new Column(0, new ClassObjectType( Person.class ) );
- Declaration declaration = new Declaration( "age",
+ final Column column = new Column( 0,
+ new ClassObjectType( Person.class ) );
+
+ final Declaration declaration = new Declaration( "age",
ageExtractor,
column );
- VariableConstraint variableConstraint = new VariableConstraint( priceExtractor,
+ final VariableConstraint variableConstraint = new VariableConstraint( priceExtractor,
declaration,
ValueType.INTEGER_TYPE.getEvaluator( Operator.EQUAL ) );
- List list = new ArrayList();
- Cheese cheese1 = new Cheese( "cheddar",
+ final List list = new ArrayList();
+ final Cheese cheese1 = new Cheese( "cheddar",
18 );
- Cheese cheese2 = new Cheese( "brie",
+ final Cheese cheese2 = new Cheese( "brie",
12 );
list.add( cheese1 );
list.add( cheese2 );
- MockDataProvider dataProvider = new MockDataProvider( list );
+ final MockDataProvider dataProvider = new MockDataProvider( list );
- FromNode from = new FromNode( 3,
+ final FromNode from = new FromNode( 3,
dataProvider,
null,
new AlphaNodeFieldConstraint[]{variableConstraint},
null );
- MockTupleSink sink = new MockTupleSink( 5 );
+ final MockTupleSink sink = new MockTupleSink( 5 );
from.addTupleSink( sink );
- Person person1 = new Person( "xxx1",
+ final Person person1 = new Person( "xxx1",
30 );
- FactHandle person1Handle = workingMemory.assertObject( person1 );
- ReteTuple tuple1 = new ReteTuple( (DefaultFactHandle) person1Handle );
+ final FactHandle person1Handle = workingMemory.assertObject( person1 );
+ final ReteTuple tuple1 = new ReteTuple( (DefaultFactHandle) person1Handle );
from.assertTuple( tuple1,
context,
workingMemory );
@@ -175,15 +176,15 @@
//Set cheese1 to stilton and it should now propagate
cheese1.setPrice( 30 );
- Person person2 = new Person( "xxx2",
+ final Person person2 = new Person( "xxx2",
30 );
- FactHandle person2Handle = workingMemory.assertObject( person2 );
- ReteTuple tuple2 = new ReteTuple( (DefaultFactHandle) person2Handle );
+ final FactHandle person2Handle = workingMemory.assertObject( person2 );
+ final ReteTuple tuple2 = new ReteTuple( (DefaultFactHandle) person2Handle );
from.assertTuple( tuple2,
context,
workingMemory );
- List asserted = sink.getAsserted();
+ final List asserted = sink.getAsserted();
assertEquals( 1,
asserted.size() );
Tuple tuple = (Tuple) ((Object[]) asserted.get( 0 ))[0];
@@ -193,10 +194,10 @@
tuple.getFactHandles()[1].getObject() );
cheese2.setPrice( 30 );
- Person person3 = new Person( "xxx2",
+ final Person person3 = new Person( "xxx2",
30 );
- FactHandle person3Handle = workingMemory.assertObject( person3 );
- ReteTuple tuple3 = new ReteTuple( (DefaultFactHandle) person3Handle );
+ final FactHandle person3Handle = workingMemory.assertObject( person3 );
+ final ReteTuple tuple3 = new ReteTuple( (DefaultFactHandle) person3Handle );
from.assertTuple( tuple3,
context,
workingMemory );
@@ -234,28 +235,28 @@
field );
List list = new ArrayList();
- Cheese cheese1 = new Cheese( "stilton",
+ final Cheese cheese1 = new Cheese( "stilton",
5 );
- Cheese cheese2 = new Cheese( "stilton",
+ final Cheese cheese2 = new Cheese( "stilton",
15 );
list.add( cheese1 );
list.add( cheese2 );
- MockDataProvider dataProvider = new MockDataProvider( list );
+ final MockDataProvider dataProvider = new MockDataProvider( list );
- FromNode from = new FromNode( 3,
+ final FromNode from = new FromNode( 3,
dataProvider,
null,
new AlphaNodeFieldConstraint[]{constraint},
null );
- MockTupleSink sink = new MockTupleSink( 5 );
+ final MockTupleSink sink = new MockTupleSink( 5 );
from.addTupleSink( sink );
- List asserted = sink.getAsserted();
+ final List asserted = sink.getAsserted();
- Person person1 = new Person( "xxx2",
+ final Person person1 = new Person( "xxx2",
30 );
- FactHandle person1Handle = workingMemory.assertObject( person1 );
- ReteTuple tuple = new ReteTuple( (DefaultFactHandle) person1Handle );
+ final FactHandle person1Handle = workingMemory.assertObject( person1 );
+ final ReteTuple tuple = new ReteTuple( (DefaultFactHandle) person1Handle );
from.assertTuple( tuple,
context,
workingMemory );
@@ -263,7 +264,7 @@
assertEquals( 2,
asserted.size() );
- BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( from );
+ final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( from );
assertEquals( 1,
memory.getLeftTupleMemory().size() );
assertEquals( 0,
@@ -272,7 +273,7 @@
tuple.getTupleMatches().size() );
list = new ArrayList();
- for ( Iterator it = tuple.getTupleMatches().values().iterator(); it.hasNext(); ) {
+ for ( final Iterator it = tuple.getTupleMatches().values().iterator(); it.hasNext(); ) {
TupleMatch tupleMatch = (TupleMatch) it.next();
list.add( tupleMatch.getObjectMatches().getFactHandle().getObject() );
}
@@ -305,27 +306,27 @@
ValueType.STRING_TYPE.getEvaluator( Operator.EQUAL ),
field );
- List list = new ArrayList();
- Cheese cheese1 = new Cheese( "cheddar",
+ final List list = new ArrayList();
+ final Cheese cheese1 = new Cheese( "cheddar",
20 );
- Cheese cheese2 = new Cheese( "brie",
+ final Cheese cheese2 = new Cheese( "brie",
20 );
list.add( cheese1 );
list.add( cheese2 );
- MockDataProvider dataProvider = new MockDataProvider( list );
+ final MockDataProvider dataProvider = new MockDataProvider( list );
- FromNode from = new FromNode( 3,
+ final FromNode from = new FromNode( 3,
dataProvider,
null,
new AlphaNodeFieldConstraint[]{constraint},
null );
- MockTupleSink sink = new MockTupleSink( 5 );
+ final MockTupleSink sink = new MockTupleSink( 5 );
from.addTupleSink( sink );
- Person person1 = new Person( "xxx1",
+ final Person person1 = new Person( "xxx1",
30 );
- FactHandle person1Handle = workingMemory.assertObject( person1 );
- ReteTuple tuple1 = new ReteTuple( (DefaultFactHandle) person1Handle );
+ final FactHandle person1Handle = workingMemory.assertObject( person1 );
+ final ReteTuple tuple1 = new ReteTuple( (DefaultFactHandle) person1Handle );
from.assertTuple( tuple1,
context,
workingMemory );
@@ -339,7 +340,7 @@
from.modifyTuple( tuple1,
context,
workingMemory );
- List asserted = sink.getAsserted();
+ final List asserted = sink.getAsserted();
assertEquals( 1,
asserted.size() );
Tuple tuple = (Tuple) ((Object[]) asserted.get( 0 ))[0];
@@ -347,38 +348,40 @@
tuple.getFactHandles()[0].getObject() );
assertSame( cheese1,
tuple.getFactHandles()[1].getObject() );
-
- cheese2.setType( "stilton" );
+
+ cheese2.setType( "stilton" );
from.modifyTuple( tuple1,
context,
- workingMemory );
+ workingMemory );
// A modify when using from involves a retract and an assert - so make sure there was a retraction and no modify propagations
- assertEquals( 0 , sink.getModified().size() );
- assertEquals( 1, sink.getRetracted().size() );
-
+ assertEquals( 0,
+ sink.getModified().size() );
+ assertEquals( 1,
+ sink.getRetracted().size() );
+
assertEquals( 3,
asserted.size() );
tuple = (Tuple) ((Object[]) asserted.get( 1 ))[0];
assertSame( person1,
tuple.getFactHandles()[0].getObject() );
assertSame( cheese1,
- tuple.getFactHandles()[1].getObject() );
-
+ tuple.getFactHandles()[1].getObject() );
+
tuple = (Tuple) ((Object[]) asserted.get( 2 ))[0];
assertSame( person1,
tuple.getFactHandles()[0].getObject() );
assertSame( cheese2,
- tuple.getFactHandles()[1].getObject() );
-
+ tuple.getFactHandles()[1].getObject() );
+
// Double check the nodes memory
- BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( from );
+ final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( from );
assertEquals( 1,
memory.getLeftTupleMemory().size() );
assertEquals( 0,
memory.getRightObjectMemory().size() );
assertEquals( 2,
- tuple1.getTupleMatches().size() );
+ tuple1.getTupleMatches().size() );
}
public static class MockDataProvider
@@ -391,11 +394,13 @@
return null;
}
- public MockDataProvider(Collection collection) {
+ public MockDataProvider(final Collection collection) {
this.collection = collection;
}
- public Iterator getResults(Tuple tuple, WorkingMemory wm, PropagationContext ctx) {
+ public Iterator getResults(final Tuple tuple,
+ final WorkingMemory wm,
+ final PropagationContext ctx) {
return this.collection.iterator();
}
}
@@ -404,19 +409,19 @@
private String name;
private int age;
- public Person(String name,
- int age) {
+ public Person(final String name,
+ final int age) {
super();
this.name = name;
this.age = age;
}
public int getAge() {
- return age;
+ return this.age;
}
public String getName() {
- return name;
+ return this.name;
}
}
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/InstrumentedReteTuple.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/InstrumentedReteTuple.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/InstrumentedReteTuple.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -19,7 +19,6 @@
import org.drools.FactHandle;
import org.drools.common.DefaultFactHandle;
import org.drools.common.InternalFactHandle;
-import org.drools.spi.Tuple;
public class InstrumentedReteTuple extends ReteTuple {
/**
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/JoinNodeTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/JoinNodeTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/JoinNodeTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -27,11 +27,9 @@
import org.drools.common.InternalFactHandle;
import org.drools.common.PropagationContextImpl;
import org.drools.rule.Rule;
-import org.drools.spi.AlphaNodeFieldConstraint;
import org.drools.spi.BetaNodeFieldConstraint;
import org.drools.spi.MockConstraint;
import org.drools.spi.PropagationContext;
-import org.drools.spi.Tuple;
import org.drools.util.Iterator;
import org.drools.util.AbstractHashTable.FactEntry;
@@ -80,14 +78,14 @@
}
public void testAttach() throws Exception {
- Field objectFfield = ObjectSource.class.getDeclaredField( "sink" );
+ final Field objectFfield = ObjectSource.class.getDeclaredField( "sink" );
objectFfield.setAccessible( true );
- ObjectSinkPropagator objectSink = ( ObjectSinkPropagator ) objectFfield.get( this.objectSource );
+ ObjectSinkPropagator objectSink = (ObjectSinkPropagator) objectFfield.get( this.objectSource );
- Field tupleField = TupleSource.class.getDeclaredField( "sink" );
+ final Field tupleField = TupleSource.class.getDeclaredField( "sink" );
tupleField.setAccessible( true );
- TupleSinkPropagator tupleSink = ( TupleSinkPropagator ) tupleField.get( this.tupleSource );
-
+ TupleSinkPropagator tupleSink = (TupleSinkPropagator) tupleField.get( this.tupleSource );
+
assertEquals( 15,
this.node.getId() );
@@ -96,9 +94,9 @@
this.node.attach();
- objectSink = ( ObjectSinkPropagator ) objectFfield.get( this.objectSource );
- tupleSink = ( TupleSinkPropagator ) tupleField.get( this.tupleSource );
-
+ objectSink = (ObjectSinkPropagator) objectFfield.get( this.objectSource );
+ tupleSink = (TupleSinkPropagator) tupleField.get( this.tupleSource );
+
assertEquals( 1,
objectSink.getSinks().length );
@@ -106,7 +104,7 @@
tupleSink.getSinks().length );
assertSame( this.node,
- objectSink.getSinks()[0]);
+ objectSink.getSinks()[0] );
assertSame( this.node,
tupleSink.getSinks()[0] );
@@ -156,9 +154,9 @@
this.context,
this.workingMemory );
assertEquals( 2,
- this.memory.getTupleMemory().size() );
-
- Iterator it = this.memory.getTupleMemory().iterator();
+ this.memory.getTupleMemory().size() );
+
+ final Iterator it = this.memory.getTupleMemory().iterator();
assertEquals( tuple0,
it.next() );
assertEquals( tuple1,
@@ -220,36 +218,43 @@
this.node.assertTuple( tuple1,
this.context,
this.workingMemory );
-
- assertEquals( 1, this.sink.getAsserted().size() );
- assertEquals( new ReteTuple( tuple1, f0), ((Object[]) this.sink.getAsserted().get( 0 ))[0]);
-
-
+ assertEquals( 1,
+ this.sink.getAsserted().size() );
+
+ assertEquals( new ReteTuple( tuple1,
+ f0 ),
+ ((Object[]) this.sink.getAsserted().get( 0 ))[0] );
+
final DefaultFactHandle f2 = new DefaultFactHandle( 2,
"cheese" );
final ReteTuple tuple2 = new ReteTuple( f2 );
this.node.assertTuple( tuple2,
this.context,
this.workingMemory );
-
- assertEquals( 2, this.sink.getAsserted().size() );
- assertEquals( new ReteTuple( tuple2, f0), ((Object[]) this.sink.getAsserted().get( 1 ))[0]);
-
+ assertEquals( 2,
+ this.sink.getAsserted().size() );
+ assertEquals( new ReteTuple( tuple2,
+ f0 ),
+ ((Object[]) this.sink.getAsserted().get( 1 ))[0] );
+
final DefaultFactHandle f3 = (DefaultFactHandle) this.workingMemory.assertObject( "test2" );
this.node.assertObject( f3,
this.context,
this.workingMemory );
-
- assertEquals( 4, this.sink.getAsserted().size() );
-
- List tuples = new ArrayList();
+
+ assertEquals( 4,
+ this.sink.getAsserted().size() );
+
+ final List tuples = new ArrayList();
tuples.add( ((Object[]) this.sink.getAsserted().get( 2 ))[0] );
tuples.add( ((Object[]) this.sink.getAsserted().get( 3 ))[0] );
-
- assertTrue( tuples.contains( new ReteTuple( tuple1, f3) ) );
- assertTrue( tuples.contains( new ReteTuple( tuple2, f3) ) );
+
+ assertTrue( tuples.contains( new ReteTuple( tuple1,
+ f3 ) ) );
+ assertTrue( tuples.contains( new ReteTuple( tuple2,
+ f3 ) ) );
}
/**
@@ -290,41 +295,43 @@
assertLength( 6,
this.sink.getAsserted() );
-
// Double check the item is in memory
- BetaMemory memory = ( BetaMemory ) this.workingMemory.getNodeMemory( this.node );
+ final BetaMemory memory = (BetaMemory) this.workingMemory.getNodeMemory( this.node );
assertTrue( memory.getObjectMemory().contains( f0 ) );
-
+
// Retract an object, check propagations and memory
this.node.retractObject( f0,
this.context,
this.workingMemory );
assertLength( 2,
this.sink.getRetracted() );
-
- List tuples = new ArrayList();
+
+ List tuples = new ArrayList();
tuples.add( ((Object[]) this.sink.getRetracted().get( 0 ))[0] );
tuples.add( ((Object[]) this.sink.getRetracted().get( 1 ))[0] );
-
- assertTrue( tuples.contains( new ReteTuple( tuple1, f0) ) );
- assertTrue( tuples.contains( new ReteTuple( tuple1, f0) ) );
-
+
+ assertTrue( tuples.contains( new ReteTuple( tuple1,
+ f0 ) ) );
+ assertTrue( tuples.contains( new ReteTuple( tuple1,
+ f0 ) ) );
+
// Now check the item is no longer in memory
assertFalse( memory.getObjectMemory().contains( f0 ) );
-
this.node.retractTuple( tuple2,
this.context,
this.workingMemory );
assertEquals( 4,
- this.sink.getRetracted().size() );
-
- tuples = new ArrayList();
+ this.sink.getRetracted().size() );
+
+ tuples = new ArrayList();
tuples.add( ((Object[]) this.sink.getRetracted().get( 2 ))[0] );
tuples.add( ((Object[]) this.sink.getRetracted().get( 3 ))[0] );
-
- assertTrue( tuples.contains( new ReteTuple( tuple2, f3) ) );
- assertTrue( tuples.contains( new ReteTuple( tuple2, f4) ) );
+
+ assertTrue( tuples.contains( new ReteTuple( tuple2,
+ f3 ) ) );
+ assertTrue( tuples.contains( new ReteTuple( tuple2,
+ f4 ) ) );
}
public void testConstraintPropagations() throws Exception {
@@ -346,13 +353,13 @@
// Should be no assertions
assertLength( 0,
this.sink.getAsserted() );
-
+
this.node.retractObject( f0,
this.context,
this.workingMemory );
// We still propagate all joins for a retract. Later we might apply tests first.
assertLength( 1,
- this.sink.getRetracted() );
+ this.sink.getRetracted() );
}
public void testUpdateSink() {
@@ -396,7 +403,7 @@
joinNode.updateSink( sink2,
this.context,
- workingMemory);
+ workingMemory );
assertLength( 1,
sink2.getAsserted() );
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/LeftInputAdapterNodeTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/LeftInputAdapterNodeTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/LeftInputAdapterNodeTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -18,7 +18,6 @@
import java.lang.reflect.Field;
import java.util.List;
-import java.util.Map;
import org.drools.DroolsTestCase;
import org.drools.RuleBaseFactory;
@@ -27,8 +26,6 @@
import org.drools.common.PropagationContextImpl;
import org.drools.spi.PropagationContext;
import org.drools.spi.Tuple;
-import org.drools.util.LinkedList;
-import org.drools.util.LinkedListEntry;
import org.drools.util.ObjectHashMap;
public class LeftInputAdapterNodeTest extends DroolsTestCase {
@@ -56,19 +53,18 @@
final LeftInputAdapterNode liaNode = new LeftInputAdapterNode( 1,
source );
- Field field = ObjectSource.class.getDeclaredField( "sink" );
+ final Field field = ObjectSource.class.getDeclaredField( "sink" );
field.setAccessible( true );
- ObjectSinkPropagator sink = ( ObjectSinkPropagator ) field.get( source );
-
+ ObjectSinkPropagator sink = (ObjectSinkPropagator) field.get( source );
assertEquals( 1,
liaNode.getId() );
assertNull( sink );
liaNode.attach();
-
- sink = ( ObjectSinkPropagator ) field.get( source );
+ sink = (ObjectSinkPropagator) field.get( source );
+
assertEquals( 1,
sink.getSinks().length );
@@ -127,16 +123,17 @@
(ReteooRuleBase) RuleBaseFactory.newRuleBase() );
final LeftInputAdapterNode liaNode = new LeftInputAdapterNode( 1,
- new MockObjectSource( 15 ) );
-
+ new MockObjectSource( 15 ) );
+
final MockTupleSink sink = new MockTupleSink();
liaNode.addTupleSink( sink );
-
+
//force liaNode to have memory
- Field field = BaseNode.class.getDeclaredField( "hasMemory" );
+ final Field field = BaseNode.class.getDeclaredField( "hasMemory" );
field.setAccessible( true );
- field.set( liaNode, new Boolean( true ) );
-
+ field.set( liaNode,
+ new Boolean( true ) );
+
final Object string1 = "cheese";
// assert object
@@ -173,8 +170,8 @@
assertNotSame( tuple0,
tuple1 );
- }
-
+ }
+
/**
* Tests the retractions from a LeftInputAdapterNode.
* Object Assertions result in tuple propagations, so we
@@ -211,12 +208,12 @@
workingMemory );
assertEquals( tuple,
- ((Object[]) sink.getRetracted().get( 0 ))[0] );
+ ((Object[]) sink.getRetracted().get( 0 ))[0] );
assertNotSame( tuple,
- ((Object[]) sink.getRetracted().get( 0 ))[0] );
+ ((Object[]) sink.getRetracted().get( 0 ))[0] );
}
-
+
public void testRetractObjectWithMemory() throws Exception {
final PropagationContext context = new PropagationContextImpl( 0,
PropagationContext.ASSERTION,
@@ -231,10 +228,11 @@
final LeftInputAdapterNode liaNode = new LeftInputAdapterNode( 1,
source );
//force liaNode to have memory
- Field field = BaseNode.class.getDeclaredField( "hasMemory" );
+ final Field field = BaseNode.class.getDeclaredField( "hasMemory" );
field.setAccessible( true );
- field.set( liaNode, new Boolean( true ) );
-
+ field.set( liaNode,
+ new Boolean( true ) );
+
final MockTupleSink sink = new MockTupleSink();
liaNode.addTupleSink( sink );
@@ -244,22 +242,22 @@
liaNode.assertObject( f0,
context,
workingMemory );
-
+
final Tuple tuple = (Tuple) ((Object[]) sink.getAsserted().get( 0 ))[0];
-
+
final ObjectHashMap map = (ObjectHashMap) workingMemory.getNodeMemory( liaNode );
- assertSame( tuple, map.get( f0 ) );
+ assertSame( tuple,
+ map.get( f0 ) );
liaNode.retractObject( f0,
context,
workingMemory );
-
assertNull( map.get( f0 ) );
assertSame( tuple,
((Object[]) sink.getRetracted().get( 0 ))[0] );
- }
+ }
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/MockAccumulator.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/MockAccumulator.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/MockAccumulator.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -32,21 +32,21 @@
public class MockAccumulator
implements
Accumulator {
-
+
private static final long serialVersionUID = 8959310397185256783L;
-
- private Tuple leftTuple = null;
- private List matchingObjects = Collections.EMPTY_LIST;
- private WorkingMemory workingMemory = null;
+ private Tuple leftTuple = null;
+ private List matchingObjects = Collections.EMPTY_LIST;
+ private WorkingMemory workingMemory = null;
+
/* (non-Javadoc)
* @see org.drools.reteoo.Accumulator#accumulate(org.drools.reteoo.ReteTuple, java.util.List, org.drools.WorkingMemory)
*/
- public Object accumulate(Tuple leftTuple,
- List matchingObjects,
- Declaration[] declarations,
- Declaration[] inner,
- WorkingMemory workingMemory) {
+ public Object accumulate(final Tuple leftTuple,
+ final List matchingObjects,
+ final Declaration[] declarations,
+ final Declaration[] inner,
+ final WorkingMemory workingMemory) {
this.leftTuple = leftTuple;
this.matchingObjects = matchingObjects;
this.workingMemory = workingMemory;
@@ -54,15 +54,15 @@
}
public Tuple getLeftTuple() {
- return leftTuple;
+ return this.leftTuple;
}
public List getMatchingObjects() {
- return matchingObjects;
+ return this.matchingObjects;
}
public WorkingMemory getWorkingMemory() {
- return workingMemory;
+ return this.workingMemory;
}
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/MockObjectSink.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/MockObjectSink.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/MockObjectSink.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -23,15 +23,15 @@
import org.drools.common.InternalWorkingMemory;
import org.drools.spi.PropagationContext;
-public class MockObjectSink
+public class MockObjectSink
implements
ObjectSinkNode {
- private final List asserted = new ArrayList();
- private final List retracted = new ArrayList();
+ private final List asserted = new ArrayList();
+ private final List retracted = new ArrayList();
- private ObjectSinkNode previousObjectSinkNode;
- private ObjectSinkNode nextObjectSinkNode;
-
+ private ObjectSinkNode previousObjectSinkNode;
+ private ObjectSinkNode nextObjectSinkNode;
+
public void assertObject(final InternalFactHandle handle,
final PropagationContext context,
final InternalWorkingMemory workingMemory) {
@@ -66,7 +66,7 @@
* @param next
* The next ObjectSinkNode
*/
- public void setNextObjectSinkNode(ObjectSinkNode next) {
+ public void setNextObjectSinkNode(final ObjectSinkNode next) {
this.nextObjectSinkNode = next;
}
@@ -84,7 +84,7 @@
* @param previous
* The previous ObjectSinkNode
*/
- public void setPreviousObjectSinkNode(ObjectSinkNode previous) {
+ public void setPreviousObjectSinkNode(final ObjectSinkNode previous) {
this.previousObjectSinkNode = previous;
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/MockObjectSource.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/MockObjectSource.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/MockObjectSource.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -34,7 +34,7 @@
private int attached;
private int updated;
-
+
private List facts;
public MockObjectSource(final int id) {
@@ -54,8 +54,8 @@
public int getUdated() {
return this.updated;
}
-
- public void addFact(InternalFactHandle handle) {
+
+ public void addFact(final InternalFactHandle handle) {
this.facts.add( handle );
}
@@ -63,9 +63,11 @@
final PropagationContext context,
final InternalWorkingMemory workingMemory) {
this.updated++;
- for(Iterator it = this.facts.iterator(); it.hasNext(); ) {
- InternalFactHandle handle = (InternalFactHandle) it.next();
- sink.assertObject( handle, context, workingMemory );
+ for ( final Iterator it = this.facts.iterator(); it.hasNext(); ) {
+ final InternalFactHandle handle = (InternalFactHandle) it.next();
+ sink.assertObject( handle,
+ context,
+ workingMemory );
}
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/MockTupleSink.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/MockTupleSink.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/MockTupleSink.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -27,7 +27,6 @@
import org.drools.common.InternalWorkingMemory;
import org.drools.common.NodeMemory;
import org.drools.spi.PropagationContext;
-import org.drools.spi.Tuple;
public class MockTupleSink extends TupleSource
implements
@@ -39,7 +38,6 @@
private static final long serialVersionUID = -5292603482246485028L;
private final List asserted = new ArrayList();
private final List retracted = new ArrayList();
-
public MockTupleSink() {
super( 0 );
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/MockTupleSource.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/MockTupleSource.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/MockTupleSource.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -50,7 +50,7 @@
return this.updated;
}
- public void updateSink(TupleSink sink,
+ public void updateSink(final TupleSink sink,
final PropagationContext context,
final InternalWorkingMemory workingMemory) {
this.updated++;
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/NotNodeTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/NotNodeTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/NotNodeTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -64,16 +64,15 @@
this.sink = new MockTupleSink();
this.node.addTupleSink( this.sink );
-
-
-// this.ria = new RightInputAdapterNode( 2,
-// 0,
-// this.node );
-// this.ria.attach();
-//
-// this.sink = new MockObjectSink();
-// this.ria.addObjectSink( this.sink );
+ // this.ria = new RightInputAdapterNode( 2,
+ // 0,
+ // this.node );
+ // this.ria.attach();
+ //
+ // this.sink = new MockObjectSink();
+ // this.ria.addObjectSink( this.sink );
+
this.memory = (BetaMemory) this.workingMemory.getNodeMemory( this.node );
}
@@ -101,7 +100,7 @@
assertLength( 0,
this.sink.getRetracted() );
- assertEquals( new ReteTuple( f0 ) ,
+ assertEquals( new ReteTuple( f0 ),
((Object[]) this.sink.getAsserted().get( 0 ))[0] );
// assert will match, so propagated tuple should be retracted
@@ -183,7 +182,7 @@
assertLength( 0,
this.sink.getRetracted() );
- assertEquals( new ReteTuple( f0 ),
+ assertEquals( new ReteTuple( f0 ),
((Object[]) this.sink.getAsserted().get( 0 ))[0] );
// assert will not match, so activation should stay propagated
@@ -256,8 +255,8 @@
this.context,
this.workingMemory );
this.node.assertObject( f1,
- this.context,
- this.workingMemory );
+ this.context,
+ this.workingMemory );
// Memory should not change
assertEquals( 1,
this.memory.getObjectMemory().size() );
@@ -275,8 +274,8 @@
// simulate modify
this.node.retractTuple( tuple1,
- this.context,
- this.workingMemory );
+ this.context,
+ this.workingMemory );
this.node.assertTuple( tuple1,
this.context,
this.workingMemory );
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/ObjectSourceTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/ObjectSourceTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/ObjectSourceTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -19,12 +19,6 @@
import java.lang.reflect.Field;
import org.drools.DroolsTestCase;
-import org.drools.FactHandle;
-import org.drools.RuleBaseFactory;
-import org.drools.common.DefaultFactHandle;
-import org.drools.common.PropagationContextImpl;
-import org.drools.rule.Rule;
-import org.drools.spi.PropagationContext;
public class ObjectSourceTest extends DroolsTestCase {
@@ -42,43 +36,48 @@
public void testAddObjectSink() throws Exception {
final MockObjectSource source = new MockObjectSource( 15 );
-
+
// We need to re-assign this var each time the sink changes references
- Field field = ObjectSource.class.getDeclaredField( "sink" );
+ final Field field = ObjectSource.class.getDeclaredField( "sink" );
field.setAccessible( true );
- ObjectSinkPropagator sink = ( ObjectSinkPropagator ) field.get( source );
-
+ ObjectSinkPropagator sink = (ObjectSinkPropagator) field.get( source );
+
assertNull( sink );
- MockObjectSink sink1 = new MockObjectSink();
- source.addObjectSink( sink1 );
- sink = ( ObjectSinkPropagator ) field.get( source );
- assertSame( SingleObjectSinkAdapter.class, sink.getClass() );
+ final MockObjectSink sink1 = new MockObjectSink();
+ source.addObjectSink( sink1 );
+ sink = (ObjectSinkPropagator) field.get( source );
+ assertSame( SingleObjectSinkAdapter.class,
+ sink.getClass() );
assertEquals( 1,
sink.getSinks().length );
- MockObjectSink sink2 = new MockObjectSink();
+ final MockObjectSink sink2 = new MockObjectSink();
source.addObjectSink( sink2 );
- sink = ( ObjectSinkPropagator ) field.get( source );
- assertSame( CompositeObjectSinkAdapter.class, sink.getClass() );
+ sink = (ObjectSinkPropagator) field.get( source );
+ assertSame( CompositeObjectSinkAdapter.class,
+ sink.getClass() );
assertEquals( 2,
sink.getSinks().length );
-
- MockObjectSink sink3 = new MockObjectSink();
+
+ final MockObjectSink sink3 = new MockObjectSink();
source.addObjectSink( sink3 );
- assertSame( CompositeObjectSinkAdapter.class, sink.getClass() );
+ assertSame( CompositeObjectSinkAdapter.class,
+ sink.getClass() );
assertEquals( 3,
- sink.getSinks().length );
-
+ sink.getSinks().length );
+
source.removeObjectSink( sink2 );
- assertSame( CompositeObjectSinkAdapter.class, sink.getClass() );
+ assertSame( CompositeObjectSinkAdapter.class,
+ sink.getClass() );
assertEquals( 2,
- sink.getSinks().length );
-
+ sink.getSinks().length );
+
source.removeObjectSink( sink1 );
- sink = ( ObjectSinkPropagator ) field.get( source );
- assertSame( SingleObjectSinkAdapter.class, sink.getClass() );
+ sink = (ObjectSinkPropagator) field.get( source );
+ assertSame( SingleObjectSinkAdapter.class,
+ sink.getClass() );
assertEquals( 1,
- sink.getSinks().length );
+ sink.getSinks().length );
}
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/ObjectTypeNodeTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/ObjectTypeNodeTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/ObjectTypeNodeTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -48,10 +48,10 @@
assertEquals( 1,
objectTypeNode.getId() );
- Field field = Rete.class.getDeclaredField( "objectTypeNodes" );
+ final Field field = Rete.class.getDeclaredField( "objectTypeNodes" );
field.setAccessible( true );
- ObjectHashMap map = ( ObjectHashMap ) field.get( source );
-
+ final ObjectHashMap map = (ObjectHashMap) field.get( source );
+
assertEquals( 0,
map.size() );
@@ -70,7 +70,7 @@
null,
null );
- ReteooRuleBase ruleBase = (ReteooRuleBase) RuleBaseFactory.newRuleBase();
+ final ReteooRuleBase ruleBase = (ReteooRuleBase) RuleBaseFactory.newRuleBase();
final ReteooWorkingMemory workingMemory = new ReteooWorkingMemory( 1,
ruleBase );
@@ -259,20 +259,20 @@
sink2.getAsserted().size() );
}
-
+
public void testAssertObjectWithShadowEnabled() throws Exception {
final PropagationContext context = new PropagationContextImpl( 0,
PropagationContext.ASSERTION,
null,
null );
- ReteooRuleBase ruleBase = (ReteooRuleBase) RuleBaseFactory.newRuleBase();
+ final ReteooRuleBase ruleBase = (ReteooRuleBase) RuleBaseFactory.newRuleBase();
final ReteooWorkingMemory workingMemory = new ReteooWorkingMemory( 1,
ruleBase );
final Rete source = ruleBase.getRete();
- Class shadowClass = ShadowProxyFactory.getProxy( Cheese.class );
+ final Class shadowClass = ShadowProxyFactory.getProxy( Cheese.class );
final ObjectTypeNode objectTypeNode = new ObjectTypeNode( 1,
new ClassObjectType( Cheese.class,
shadowClass ),
@@ -281,7 +281,8 @@
final MockObjectSink sink = new MockObjectSink();
objectTypeNode.addObjectSink( sink );
- final Object cheese = new Cheese("muzzarela", 5);
+ final Object cheese = new Cheese( "muzzarela",
+ 5 );
final InternalFactHandle handle1 = (InternalFactHandle) workingMemory.assertObject( cheese );
@@ -305,6 +306,4 @@
assertTrue( memory.contains( handle1 ) );
}
-
-
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/ReteTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/ReteTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/ReteTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -55,9 +55,9 @@
rete );
stringTypeNode.attach();
- Field field = Rete.class.getDeclaredField( "objectTypeNodes" );
+ final Field field = Rete.class.getDeclaredField( "objectTypeNodes" );
field.setAccessible( true );
- ObjectHashMap map = ( ObjectHashMap ) field.get( rete );
+ final ObjectHashMap map = (ObjectHashMap) field.get( rete );
// Check the ObjectTypeNodes are correctly added to Rete
assertEquals( 2,
@@ -85,14 +85,14 @@
objectTypeNode.attach();
MockObjectSink sink = new MockObjectSink();
objectTypeNode.addObjectSink( sink );
-
+
objectTypeNode = new ObjectTypeNode( 1,
new ClassObjectType( Collection.class ),
rete );
objectTypeNode.attach();
sink = new MockObjectSink();
- objectTypeNode.addObjectSink( sink );
-
+ objectTypeNode.addObjectSink( sink );
+
objectTypeNode = new ObjectTypeNode( 1,
new ClassObjectType( ArrayList.class ),
rete );
@@ -138,7 +138,7 @@
new ClassObjectType( List.class ),
rete );
objectTypeNode.attach();
- MockObjectSink sink1 = new MockObjectSink();
+ final MockObjectSink sink1 = new MockObjectSink();
objectTypeNode.addObjectSink( sink1 );
// There are no String ObjectTypeNodes, make sure its not propagated
@@ -187,7 +187,7 @@
new ClassObjectType( List.class ),
rete );
objectTypeNode.attach();
- MockObjectSink sink1 = new MockObjectSink();
+ final MockObjectSink sink1 = new MockObjectSink();
objectTypeNode.addObjectSink( sink1 );
// There are no String ObjectTypeNodes, make sure its not propagated
@@ -210,7 +210,7 @@
rete.assertObject( h2,
null,
workingMemory );
-
+
rete.retractObject( h2,
null,
workingMemory );
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/ReteooRuleBaseTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/ReteooRuleBaseTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/ReteooRuleBaseTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -186,6 +186,5 @@
this.ruleBase.getGlobals().values() );
}
-
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/ReteooWorkingMemoryTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/ReteooWorkingMemoryTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/ReteooWorkingMemoryTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -17,69 +17,77 @@
* @see JBRULES-356
*/
public void testBasicWorkingMemoryActions() {
- ReteooWorkingMemory workingMemory = (ReteooWorkingMemory) RuleBaseFactory.newRuleBase().newWorkingMemory();
- TruthMaintenanceSystem tms = workingMemory.getTruthMaintenanceSystem();
- String string = "test";
- FactHandle fd = workingMemory.assertObject(string);
-
- assertEquals(1,
- tms.getAssertMap().size() );
+ final ReteooWorkingMemory workingMemory = (ReteooWorkingMemory) RuleBaseFactory.newRuleBase().newWorkingMemory();
+ final TruthMaintenanceSystem tms = workingMemory.getTruthMaintenanceSystem();
+ final String string = "test";
+ FactHandle fd = workingMemory.assertObject( string );
+
+ assertEquals( 1,
+ tms.getAssertMap().size() );
EqualityKey key = tms.get( string );
- assertSame( fd, key.getFactHandle() );
+ assertSame( fd,
+ key.getFactHandle() );
assertNull( key.getOtherFactHandle() );
-
- workingMemory.modifyObject(fd, string);
-
- assertEquals(1,
- tms.getAssertMap().size() );
+
+ workingMemory.modifyObject( fd,
+ string );
+
+ assertEquals( 1,
+ tms.getAssertMap().size() );
key = tms.get( string );
- assertSame( fd, key.getFactHandle() );
+ assertSame( fd,
+ key.getFactHandle() );
assertNull( key.getOtherFactHandle() );
-
- workingMemory.retractObject(fd);
-
- assertEquals(0,
- tms.getAssertMap().size() );
+
+ workingMemory.retractObject( fd );
+
+ assertEquals( 0,
+ tms.getAssertMap().size() );
key = tms.get( string );
assertNull( key );
-
- fd = workingMemory.assertObject(string);
- assertEquals(1,
- tms.getAssertMap().size() );
-
- assertEquals(1,
- tms.getAssertMap().size() );
+ fd = workingMemory.assertObject( string );
+
+ assertEquals( 1,
+ tms.getAssertMap().size() );
+
+ assertEquals( 1,
+ tms.getAssertMap().size() );
key = tms.get( string );
- assertSame( fd, key.getFactHandle() );
+ assertSame( fd,
+ key.getFactHandle() );
assertNull( key.getOtherFactHandle() );
}
-
+
public void testId() {
- ReteooRuleBase ruleBase = (ReteooRuleBase) RuleBaseFactory.newRuleBase();
+ final ReteooRuleBase ruleBase = (ReteooRuleBase) RuleBaseFactory.newRuleBase();
InternalWorkingMemory workingMemory = (InternalWorkingMemory) ruleBase.newWorkingMemory();
assertEquals( 0,
workingMemory.getId() );
workingMemory = (InternalWorkingMemory) ruleBase.newWorkingMemory();
assertEquals( 1,
- workingMemory.getId() );
+ workingMemory.getId() );
}
-
+
public void testGlobalResolver() {
final Map map = new HashMap();
- map.put( "global1", "value1" );
- map.put( "global2", "value2" );
- GlobalResolver resolver = new GlobalResolver() {
-
+ map.put( "global1",
+ "value1" );
+ map.put( "global2",
+ "value2" );
+ final GlobalResolver resolver = new GlobalResolver() {
+
public Object resolve(String name) {
return map.get( name );
}
-
+
};
- ReteooRuleBase ruleBase = (ReteooRuleBase) RuleBaseFactory.newRuleBase();
- InternalWorkingMemory workingMemory = (InternalWorkingMemory) ruleBase.newWorkingMemory();
+ final ReteooRuleBase ruleBase = (ReteooRuleBase) RuleBaseFactory.newRuleBase();
+ final InternalWorkingMemory workingMemory = (InternalWorkingMemory) ruleBase.newWorkingMemory();
workingMemory.setGlobalResolver( resolver );
- assertEquals( "value1", workingMemory.getGlobal( "global1" ) );
- assertEquals( "value2", workingMemory.getGlobal( "global2" ) );
+ assertEquals( "value1",
+ workingMemory.getGlobal( "global1" ) );
+ assertEquals( "value2",
+ workingMemory.getGlobal( "global2" ) );
}
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/TupleSourceTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/TupleSourceTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/TupleSourceTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -19,12 +19,6 @@
import java.lang.reflect.Field;
import org.drools.DroolsTestCase;
-import org.drools.RuleBaseFactory;
-import org.drools.common.DefaultFactHandle;
-import org.drools.common.PropagationContextImpl;
-import org.drools.rule.Rule;
-import org.drools.spi.PropagationContext;
-import org.drools.spi.Tuple;
public class TupleSourceTest extends DroolsTestCase {
@@ -42,44 +36,49 @@
public void testAddTupleSink() throws Exception {
final MockTupleSource source = new MockTupleSource( 15 );
-
+
// We need to re-assign this var each time the sink changes references
- Field field = TupleSource.class.getDeclaredField( "sink" );
+ final Field field = TupleSource.class.getDeclaredField( "sink" );
field.setAccessible( true );
- TupleSinkPropagator sink = ( TupleSinkPropagator ) field.get( source );
-
+ TupleSinkPropagator sink = (TupleSinkPropagator) field.get( source );
+
assertNull( sink );
- MockTupleSink sink1 = new MockTupleSink();
- source.addTupleSink( sink1 );
- sink = ( TupleSinkPropagator ) field.get( source );
- assertSame( SingleTupleSinkAdapter.class, sink.getClass() );
+ final MockTupleSink sink1 = new MockTupleSink();
+ source.addTupleSink( sink1 );
+ sink = (TupleSinkPropagator) field.get( source );
+ assertSame( SingleTupleSinkAdapter.class,
+ sink.getClass() );
assertEquals( 1,
sink.getSinks().length );
- MockTupleSink sink2 = new MockTupleSink();
+ final MockTupleSink sink2 = new MockTupleSink();
source.addTupleSink( sink2 );
- sink = ( TupleSinkPropagator ) field.get( source );
- assertSame( CompositeTupleSinkAdapter.class, sink.getClass() );
+ sink = (TupleSinkPropagator) field.get( source );
+ assertSame( CompositeTupleSinkAdapter.class,
+ sink.getClass() );
assertEquals( 2,
sink.getSinks().length );
-
- MockTupleSink sink3 = new MockTupleSink();
+
+ final MockTupleSink sink3 = new MockTupleSink();
source.addTupleSink( sink3 );
- assertSame( CompositeTupleSinkAdapter.class, sink.getClass() );
+ assertSame( CompositeTupleSinkAdapter.class,
+ sink.getClass() );
assertEquals( 3,
- sink.getSinks().length );
-
+ sink.getSinks().length );
+
source.removeTupleSink( sink2 );
- assertSame( CompositeTupleSinkAdapter.class, sink.getClass() );
+ assertSame( CompositeTupleSinkAdapter.class,
+ sink.getClass() );
assertEquals( 2,
- sink.getSinks().length );
-
+ sink.getSinks().length );
+
source.removeTupleSink( sink1 );
- sink = ( TupleSinkPropagator ) field.get( source );
- assertSame( SingleTupleSinkAdapter.class, sink.getClass() );
+ sink = (TupleSinkPropagator) field.get( source );
+ assertSame( SingleTupleSinkAdapter.class,
+ sink.getClass() );
assertEquals( 1,
- sink.getSinks().length );
+ sink.getSinks().length );
}
-
+
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/rule/ColumnTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/rule/ColumnTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/rule/ColumnTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -16,48 +16,55 @@
public class ColumnTest extends TestCase {
public void testDeclarationsObjectType() throws Exception {
- ObjectType type = new ClassObjectType(Cheese.class);
- Column col = new Column(0, type, "foo");
- Declaration dec = col.getDeclaration();
- Extractor ext = dec.getExtractor();
- assertEquals(Cheese.class, ext.getExtractToClass());
-
- Cheese stilton = new Cheese("stilton", 42);
-
- assertEquals(stilton, dec.getValue( stilton ));
-
-
-
+ final ObjectType type = new ClassObjectType( Cheese.class );
+ final Column col = new Column( 0,
+ type,
+ "foo" );
+ final Declaration dec = col.getDeclaration();
+ final Extractor ext = dec.getExtractor();
+ assertEquals( Cheese.class,
+ ext.getExtractToClass() );
+
+ final Cheese stilton = new Cheese( "stilton",
+ 42 );
+
+ assertEquals( stilton,
+ dec.getValue( stilton ) );
+
}
-
+
public void testDeclarationsFactTemplate() throws Exception {
-
-
- Package pkg = new Package( "org.store" );
- FieldTemplate cheeseName = new FieldTemplateImpl( "name",
+
+ final Package pkg = new Package( "org.store" );
+ final FieldTemplate cheeseName = new FieldTemplateImpl( "name",
0,
String.class );
- FieldTemplate cheesePrice = new FieldTemplateImpl( "price",
+ final FieldTemplate cheesePrice = new FieldTemplateImpl( "price",
1,
Integer.class );
- FieldTemplate[] fields = new FieldTemplate[]{cheeseName, cheesePrice};
- FactTemplate cheese = new FactTemplateImpl( pkg,
+ final FieldTemplate[] fields = new FieldTemplate[]{cheeseName, cheesePrice};
+ final FactTemplate cheese = new FactTemplateImpl( pkg,
"Cheese",
fields );
-
- ObjectType type = new FactTemplateObjectType(cheese);
-
- Column col = new Column(0, type, "foo");
- Declaration dec = col.getDeclaration();
- Extractor ext = dec.getExtractor();
- assertEquals(Fact.class, ext.getExtractToClass());
-
- Fact stilton = cheese.createFact( 10 );
- stilton.setFieldValue( "name", "stilton" );
- stilton.setFieldValue( "price", new Integer( 200 ) );
-
- assertEquals(stilton, dec.getValue( stilton ));
+
+ final ObjectType type = new FactTemplateObjectType( cheese );
+
+ final Column col = new Column( 0,
+ type,
+ "foo" );
+ final Declaration dec = col.getDeclaration();
+ final Extractor ext = dec.getExtractor();
+ assertEquals( Fact.class,
+ ext.getExtractToClass() );
+
+ final Fact stilton = cheese.createFact( 10 );
+ stilton.setFieldValue( "name",
+ "stilton" );
+ stilton.setFieldValue( "price",
+ new Integer( 200 ) );
+
+ assertEquals( stilton,
+ dec.getValue( stilton ) );
}
-
-
+
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/rule/DeclarationTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/rule/DeclarationTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/rule/DeclarationTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -32,9 +32,10 @@
public void testDeclaration() throws IntrospectionException {
final FieldExtractor extractor = new ClassFieldExtractor( Cheese.class,
"type" );
-
- Column column = new Column(5, new ClassObjectType( Cheese.class ) );
-
+
+ final Column column = new Column( 5,
+ new ClassObjectType( Cheese.class ) );
+
// Bind the extractor to a decleration
// Declarations know the column they derive their value from
final Declaration declaration = new Declaration( "typeOfCheese",
@@ -59,8 +60,9 @@
final FieldExtractor extractor = new ClassFieldExtractor( Cheese.class,
"type" );
- Column column = new Column(5, new ClassObjectType( Cheese.class ) );
-
+ final Column column = new Column( 5,
+ new ClassObjectType( Cheese.class ) );
+
// Bind the extractor to a decleration
// Declarations know the column they derive their value from
final Declaration declaration = new Declaration( "typeOfCheese",
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/rule/FieldConstraintTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/rule/FieldConstraintTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/rule/FieldConstraintTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -68,8 +68,8 @@
final FieldValue field = new MockField( "cheddar" );
- Evaluator evaluator = ValueType.STRING_TYPE.getEvaluator( Operator.EQUAL );
-
+ final Evaluator evaluator = ValueType.STRING_TYPE.getEvaluator( Operator.EQUAL );
+
final LiteralConstraint constraint = new LiteralConstraint( extractor,
evaluator,
field );
@@ -111,10 +111,10 @@
final ClassFieldExtractor extractor = new ClassFieldExtractor( Cheese.class,
"price" );
- final FieldValue field = new MockField( new Integer(5) );
+ final FieldValue field = new MockField( new Integer( 5 ) );
- Evaluator evaluator = ValueType.PINTEGER_TYPE.getEvaluator( Operator.EQUAL );
-
+ final Evaluator evaluator = ValueType.PINTEGER_TYPE.getEvaluator( Operator.EQUAL );
+
final LiteralConstraint constraint = new LiteralConstraint( extractor,
evaluator,
field );
@@ -157,17 +157,18 @@
final FieldExtractor priceExtractor = new ClassFieldExtractor( Cheese.class,
"price" );
- Column column = new Column(0, new ClassObjectType( Cheese.class ) );
-
+ Column column = new Column( 0,
+ new ClassObjectType( Cheese.class ) );
+
// Bind the extractor to a decleration
// Declarations know the column they derive their value form
final Declaration price1Declaration = new Declaration( "price1",
priceExtractor,
column );
-
- column = new Column(1, new ClassObjectType( Cheese.class ) );
-
+ column = new Column( 1,
+ new ClassObjectType( Cheese.class ) );
+
// Bind the extractor to a decleration
// Declarations know the column they derive their value form
final Declaration price2Declaration = new Declaration( "price2",
@@ -181,7 +182,7 @@
*/
private static final long serialVersionUID = -7805842671538257493L;
- public boolean evaluate(Object object,
+ public boolean evaluate(Object object,
Tuple tuple,
Declaration declaration,
Declaration[] declarations,
@@ -234,9 +235,10 @@
final FieldExtractor priceExtractor = new ClassFieldExtractor( Cheese.class,
"price" );
-
- Column column = new Column(0, new ClassObjectType( Cheese.class ) );
+ final Column column = new Column( 0,
+ new ClassObjectType( Cheese.class ) );
+
// Bind the extractor to a decleration
// Declarations know the column they derive their value form
final Declaration priceDeclaration = new Declaration( "price1",
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/rule/OrTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/rule/OrTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/rule/OrTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -32,10 +32,10 @@
import org.drools.examples.waltz.Edge;
import org.drools.examples.waltz.Stage;
import org.drools.leaps.LeapsRuleBase;
+import org.drools.spi.AlphaNodeFieldConstraint;
import org.drools.spi.Consequence;
import org.drools.spi.ConsequenceException;
import org.drools.spi.Evaluator;
-import org.drools.spi.AlphaNodeFieldConstraint;
import org.drools.spi.FieldExtractor;
import org.drools.spi.FieldValue;
import org.drools.spi.KnowledgeHelper;
@@ -143,7 +143,7 @@
this.pkg.addRule( this.getWorkingButCanNotResolveOrObjectInConsequenceOrder() );
- final org.drools.leaps.LeapsRuleBase ruleBase =(LeapsRuleBase) RuleBaseFactory.newRuleBase( RuleBase.LEAPS );
+ final org.drools.leaps.LeapsRuleBase ruleBase = (LeapsRuleBase) RuleBaseFactory.newRuleBase( RuleBase.LEAPS );
ruleBase.addPackage( this.pkg );
final WorkingMemory workingMemory = ruleBase.newWorkingMemory();
workingMemory.assertObject( new Stage( Stage.LABELING ) );
@@ -379,9 +379,9 @@
}
private AlphaNodeFieldConstraint getLiteralConstraint(final Column column,
- final String fieldName,
- final Object fieldValue,
- final Evaluator evaluator) throws IntrospectionException {
+ final String fieldName,
+ final Object fieldValue,
+ final Evaluator evaluator) throws IntrospectionException {
final Class clazz = ((ClassObjectType) column.getObjectType()).getClassType();
final int index = getIndex( clazz,
@@ -398,17 +398,17 @@
}
private AlphaNodeFieldConstraint getBoundVariableConstraint(final Column column,
- final String fieldName,
- final Declaration declaration,
- final Evaluator evaluator) throws IntrospectionException {
+ final String fieldName,
+ final Declaration declaration,
+ final Evaluator evaluator) throws IntrospectionException {
final Class clazz = ((ClassObjectType) column.getObjectType()).getClassType();
final FieldExtractor extractor = new ClassFieldExtractor( clazz,
fieldName );
return new VariableConstraint( extractor,
- declaration,
- evaluator );
+ declaration,
+ evaluator );
}
public static int getIndex(final Class clazz,
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/spi/MockObjectType.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/spi/MockObjectType.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/spi/MockObjectType.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -78,8 +78,8 @@
public ValueType getValueType() {
return ValueType.OBJECT_TYPE;
}
-
- public Object getShadow(Object fact) {
+
+ public Object getShadow(final Object fact) {
return null;
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/BinaryHeapPriorityQueueTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/BinaryHeapPriorityQueueTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/BinaryHeapPriorityQueueTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -31,7 +31,7 @@
final List items = new LinkedList();
final Queue queue = new BinaryHeapQueue( NaturalComparator.INSTANCE,
- 100000 );
+ 100000 );
for ( int i = 0; i < 100000; ++i ) {
items.add( new LongQueueable( random.nextLong() ) );
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/FactHashTableTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/FactHashTableTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/FactHashTableTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -6,9 +6,9 @@
public class FactHashTableTest extends TestCase {
public void testEmptyIterator() {
- FactHashTable map = new FactHashTable();
- Iterator it = map.iterator();
- for( ObjectEntry entry = ( ObjectEntry ) it.next(); entry != null; entry = ( ObjectEntry ) it.next() ) {
+ final FactHashTable map = new FactHashTable();
+ final Iterator it = map.iterator();
+ for ( ObjectEntry entry = (ObjectEntry) it.next(); entry != null; entry = (ObjectEntry) it.next() ) {
fail( "Map is empty, there should be no iteration" );
}
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/FieldIndexEntryTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/FieldIndexEntryTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/FieldIndexEntryTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -1,5 +1,7 @@
package org.drools.util;
+import junit.framework.TestCase;
+
import org.drools.Cheese;
import org.drools.base.ClassFieldExtractor;
import org.drools.common.DefaultFactHandle;
@@ -7,119 +9,162 @@
import org.drools.util.AbstractHashTable.FactEntry;
import org.drools.util.FieldIndexHashTable.FieldIndexEntry;
-import junit.framework.TestCase;
+public class FieldIndexEntryTest extends TestCase {
-public class FieldIndexEntryTest extends TestCase {
-
- public void testSingleEntry() {
- ClassFieldExtractor extractor = new ClassFieldExtractor(Cheese.class, "type");
-
- FieldIndexEntry index = new FieldIndexEntry( extractor, extractor.getIndex(), "stilton".hashCode() );
-
+ public void testSingleEntry() {
+ final ClassFieldExtractor extractor = new ClassFieldExtractor( Cheese.class,
+ "type" );
+
+ final FieldIndexEntry index = new FieldIndexEntry( extractor,
+ extractor.getIndex(),
+ "stilton".hashCode() );
+
// Test initial construction
- assertNull( index.getValue() );
+ assertNull( index.getValue() );
assertNull( index.getFirst() );
- assertEquals( "stilton".hashCode(), index.hashCode() );
-
- Cheese stilton1 = new Cheese("stilton", 35);
- InternalFactHandle h1 = new DefaultFactHandle( 1, stilton1 );
-
+ assertEquals( "stilton".hashCode(),
+ index.hashCode() );
+
+ final Cheese stilton1 = new Cheese( "stilton",
+ 35 );
+ final InternalFactHandle h1 = new DefaultFactHandle( 1,
+ stilton1 );
+
// test add
- index.add( h1 );
- assertEquals( "stilton", index.getValue() );
- FactEntry entry1 = index.getFirst();
- assertSame( h1, entry1.getFactHandle() );
- assertNull( entry1.getNext() );
- assertSame( entry1, index.get( h1 ) );
-
+ index.add( h1 );
+ assertEquals( "stilton",
+ index.getValue() );
+ final FactEntry entry1 = index.getFirst();
+ assertSame( h1,
+ entry1.getFactHandle() );
+ assertNull( entry1.getNext() );
+ assertSame( entry1,
+ index.get( h1 ) );
+
// test get
- FactEntry entry2 = ( FactEntry ) index.get( h1 );
- assertSame( entry1, entry2 );
-
+ final FactEntry entry2 = index.get( h1 );
+ assertSame( entry1,
+ entry2 );
+
// test remove
- index.remove( h1 );
+ index.remove( h1 );
assertNull( index.getFirst() );
- assertNull( index.getValue() );
+ assertNull( index.getValue() );
}
-
- public void testTwoEntries() {
- ClassFieldExtractor extractor = new ClassFieldExtractor(Cheese.class, "type");
- FieldIndexEntry index = new FieldIndexEntry( extractor, extractor.getIndex(), "stilton".hashCode() );
+ public void testTwoEntries() {
+ final ClassFieldExtractor extractor = new ClassFieldExtractor( Cheese.class,
+ "type" );
+ final FieldIndexEntry index = new FieldIndexEntry( extractor,
+ extractor.getIndex(),
+ "stilton".hashCode() );
- Cheese stilton1 = new Cheese("stilton", 35);
- InternalFactHandle h1 = new DefaultFactHandle( 1, stilton1 );
- Cheese stilton2 = new Cheese("stilton", 59);
- InternalFactHandle h2 = new DefaultFactHandle( 2, stilton2 );
-
+ final Cheese stilton1 = new Cheese( "stilton",
+ 35 );
+ final InternalFactHandle h1 = new DefaultFactHandle( 1,
+ stilton1 );
+ final Cheese stilton2 = new Cheese( "stilton",
+ 59 );
+ final InternalFactHandle h2 = new DefaultFactHandle( 2,
+ stilton2 );
+
// test add
index.add( h1 );
- index.add( h2 );
- assertEquals( h2, index.getFirst().getFactHandle() );
- assertEquals( h1, ( ( FactEntry ) index.getFirst().getNext() ).getFactHandle() );
-
+ index.add( h2 );
+ assertEquals( h2,
+ index.getFirst().getFactHandle() );
+ assertEquals( h1,
+ ((FactEntry) index.getFirst().getNext()).getFactHandle() );
+
// test get
- assertEquals( h1, index.get( h1 ).getFactHandle() );
- assertEquals( h2, index.get( h2 ).getFactHandle() );
+ assertEquals( h1,
+ index.get( h1 ).getFactHandle() );
+ assertEquals( h2,
+ index.get( h2 ).getFactHandle() );
// test removal for combinations
// remove first
index.remove( h2 );
- assertEquals( h1, index.getFirst().getFactHandle() );
-
+ assertEquals( h1,
+ index.getFirst().getFactHandle() );
+
// remove second
index.add( h2 );
index.remove( h1 );
- assertEquals( h2, index.getFirst().getFactHandle() );
-
+ assertEquals( h2,
+ index.getFirst().getFactHandle() );
+
// check index type does not change, as this fact is removed
stilton1.setType( "cheddar" );
- assertEquals( "stilton", index.getValue() );
- }
-
- public void testThreeEntries() {
- ClassFieldExtractor extractor = new ClassFieldExtractor(Cheese.class, "type");
- FieldIndexEntry index = new FieldIndexEntry( extractor, extractor.getIndex(), "stilton".hashCode() );
+ assertEquals( "stilton",
+ index.getValue() );
+ }
- Cheese stilton1 = new Cheese("stilton", 35);
- InternalFactHandle h1 = new DefaultFactHandle( 1, stilton1 );
- Cheese stilton2 = new Cheese("stilton", 59);
- InternalFactHandle h2 = new DefaultFactHandle( 2, stilton2 );
- Cheese stilton3 = new Cheese("stilton", 59);
- InternalFactHandle h3 = new DefaultFactHandle( 3, stilton3 );
-
+ public void testThreeEntries() {
+ final ClassFieldExtractor extractor = new ClassFieldExtractor( Cheese.class,
+ "type" );
+ final FieldIndexEntry index = new FieldIndexEntry( extractor,
+ extractor.getIndex(),
+ "stilton".hashCode() );
+
+ final Cheese stilton1 = new Cheese( "stilton",
+ 35 );
+ final InternalFactHandle h1 = new DefaultFactHandle( 1,
+ stilton1 );
+ final Cheese stilton2 = new Cheese( "stilton",
+ 59 );
+ final InternalFactHandle h2 = new DefaultFactHandle( 2,
+ stilton2 );
+ final Cheese stilton3 = new Cheese( "stilton",
+ 59 );
+ final InternalFactHandle h3 = new DefaultFactHandle( 3,
+ stilton3 );
+
// test add
index.add( h1 );
index.add( h2 );
- index.add( h3 );
- assertEquals( h3, index.getFirst().getFactHandle() );
- assertEquals( h2, ( ( FactEntry ) index.getFirst().getNext() ).getFactHandle() );
- assertEquals( h1, ( ( FactEntry ) index.getFirst().getNext().getNext() ).getFactHandle() );
-
+ index.add( h3 );
+ assertEquals( h3,
+ index.getFirst().getFactHandle() );
+ assertEquals( h2,
+ ((FactEntry) index.getFirst().getNext()).getFactHandle() );
+ assertEquals( h1,
+ ((FactEntry) index.getFirst().getNext().getNext()).getFactHandle() );
+
// test get
- assertEquals( h1, index.get( h1 ).getFactHandle() );
- assertEquals( h2, index.get( h2 ).getFactHandle() );
- assertEquals( h3, index.get( h3 ).getFactHandle() );
+ assertEquals( h1,
+ index.get( h1 ).getFactHandle() );
+ assertEquals( h2,
+ index.get( h2 ).getFactHandle() );
+ assertEquals( h3,
+ index.get( h3 ).getFactHandle() );
// test removal for combinations
//remove first
index.remove( h3 );
- assertEquals( h2, index.getFirst().getFactHandle() );
- assertEquals( h1, ( ( FactEntry ) index.getFirst().getNext() ).getFactHandle() );
-
+ assertEquals( h2,
+ index.getFirst().getFactHandle() );
+ assertEquals( h1,
+ ((FactEntry) index.getFirst().getNext()).getFactHandle() );
+
index.add( h3 );
index.remove( h2 );
- assertEquals( h3, index.getFirst().getFactHandle() );
- assertEquals( h1, ( ( FactEntry ) index.getFirst().getNext() ).getFactHandle() );
-
+ assertEquals( h3,
+ index.getFirst().getFactHandle() );
+ assertEquals( h1,
+ ((FactEntry) index.getFirst().getNext()).getFactHandle() );
+
index.add( h2 );
index.remove( h1 );
- assertEquals( h2, index.getFirst().getFactHandle() );
- assertEquals( h3, ( ( FactEntry ) index.getFirst().getNext() ).getFactHandle() );
+ assertEquals( h2,
+ index.getFirst().getFactHandle() );
+ assertEquals( h3,
+ ((FactEntry) index.getFirst().getNext()).getFactHandle() );
index.remove( index.getFirst().getFactHandle() );
// check index type does not change, as this fact is removed
stilton2.setType( "cheddar" );
- assertEquals( "stilton", index.getValue() );
- }
+ assertEquals( "stilton",
+ index.getValue() );
+ }
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/FieldIndexHashTableTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/FieldIndexHashTableTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/FieldIndexHashTableTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -25,28 +25,28 @@
final FieldExtractor extractor = new ClassFieldExtractor( Cheese.class,
"type" );
- Column column = new Column( 0,
+ final Column column = new Column( 0,
new ClassObjectType( Cheese.class ) );
final Declaration declaration = new Declaration( "typeOfCheese",
extractor,
column );
- FieldIndexHashTable map = new FieldIndexHashTable( extractor,
+ final FieldIndexHashTable map = new FieldIndexHashTable( extractor,
declaration );
- Cheese cheddar = new Cheese( "cheddar",
+ final Cheese cheddar = new Cheese( "cheddar",
10 );
- InternalFactHandle cheddarHandle1 = new DefaultFactHandle( 0,
+ final InternalFactHandle cheddarHandle1 = new DefaultFactHandle( 0,
cheddar );
assertEquals( 0,
map.size() );
assertNull( map.get( new ReteTuple( cheddarHandle1 ) ) );
- Cheese stilton1 = new Cheese( "stilton",
+ final Cheese stilton1 = new Cheese( "stilton",
35 );
- InternalFactHandle stiltonHandle1 = new DefaultFactHandle( 1,
+ final InternalFactHandle stiltonHandle1 = new DefaultFactHandle( 1,
stilton1 );
map.add( stiltonHandle1 );
@@ -55,12 +55,12 @@
assertEquals( 1,
tablePopulationSize( map ) );
- Cheese stilton2 = new Cheese( "stilton",
+ final Cheese stilton2 = new Cheese( "stilton",
80 );
- InternalFactHandle stiltonHandle2 = new DefaultFactHandle( 2,
+ final InternalFactHandle stiltonHandle2 = new DefaultFactHandle( 2,
stilton2 );
- FieldIndexEntry stiltonEntry = map.get( new ReteTuple( stiltonHandle2 ) );
+ final FieldIndexEntry stiltonEntry = map.get( new ReteTuple( stiltonHandle2 ) );
assertSame( stiltonHandle1,
stiltonEntry.getFirst().getFactHandle() );
assertNull( stiltonEntry.getFirst().getNext() );
@@ -70,28 +70,28 @@
final FieldExtractor extractor = new ClassFieldExtractor( Cheese.class,
"type" );
- Column column = new Column( 0,
+ final Column column = new Column( 0,
new ClassObjectType( Cheese.class ) );
final Declaration declaration = new Declaration( "typeOfCheese",
extractor,
column );
- FieldIndexHashTable map = new FieldIndexHashTable( extractor,
+ final FieldIndexHashTable map = new FieldIndexHashTable( extractor,
declaration );
assertEquals( 0,
map.size() );
- Cheese stilton1 = new Cheese( "stilton",
+ final Cheese stilton1 = new Cheese( "stilton",
35 );
- InternalFactHandle stiltonHandle1 = new DefaultFactHandle( 1,
+ final InternalFactHandle stiltonHandle1 = new DefaultFactHandle( 1,
stilton1 );
map.add( stiltonHandle1 );
- Cheese cheddar1 = new Cheese( "cheddar",
+ final Cheese cheddar1 = new Cheese( "cheddar",
35 );
- InternalFactHandle cheddarHandle1 = new DefaultFactHandle( 2,
+ final InternalFactHandle cheddarHandle1 = new DefaultFactHandle( 2,
cheddar1 );
map.add( cheddarHandle1 );
@@ -100,20 +100,20 @@
assertEquals( 2,
tablePopulationSize( map ) );
- Cheese stilton2 = new Cheese( "stilton",
+ final Cheese stilton2 = new Cheese( "stilton",
77 );
- InternalFactHandle stiltonHandle2 = new DefaultFactHandle( 2,
+ final InternalFactHandle stiltonHandle2 = new DefaultFactHandle( 2,
stilton2 );
- FieldIndexEntry stiltonEntry = map.get( new ReteTuple( stiltonHandle2 ) );
+ final FieldIndexEntry stiltonEntry = map.get( new ReteTuple( stiltonHandle2 ) );
assertSame( stiltonHandle1,
stiltonEntry.getFirst().getFactHandle() );
assertNull( stiltonEntry.getFirst().getNext() );
- Cheese cheddar2 = new Cheese( "cheddar",
+ final Cheese cheddar2 = new Cheese( "cheddar",
5 );
- InternalFactHandle cheddarHandle2 = new DefaultFactHandle( 2,
+ final InternalFactHandle cheddarHandle2 = new DefaultFactHandle( 2,
cheddar2 );
- FieldIndexEntry cheddarEntry = map.get( new ReteTuple( cheddarHandle2 ) );
+ final FieldIndexEntry cheddarEntry = map.get( new ReteTuple( cheddarHandle2 ) );
assertSame( cheddarHandle1,
cheddarEntry.getFirst().getFactHandle() );
assertNull( cheddarEntry.getFirst().getNext() );
@@ -123,34 +123,34 @@
final FieldExtractor extractor = new ClassFieldExtractor( Cheese.class,
"type" );
- Column column = new Column( 0,
+ final Column column = new Column( 0,
new ClassObjectType( Cheese.class ) );
final Declaration declaration = new Declaration( "typeOfCheese",
extractor,
column );
- FieldIndexHashTable map = new FieldIndexHashTable( extractor,
+ final FieldIndexHashTable map = new FieldIndexHashTable( extractor,
declaration );
assertEquals( 0,
map.size() );
- Cheese stilton1 = new Cheese( "stilton",
+ final Cheese stilton1 = new Cheese( "stilton",
35 );
- InternalFactHandle stiltonHandle1 = new DefaultFactHandle( 1,
+ final InternalFactHandle stiltonHandle1 = new DefaultFactHandle( 1,
stilton1 );
map.add( stiltonHandle1 );
- Cheese cheddar1 = new Cheese( "cheddar",
+ final Cheese cheddar1 = new Cheese( "cheddar",
35 );
- InternalFactHandle cheddarHandle1 = new DefaultFactHandle( 2,
+ final InternalFactHandle cheddarHandle1 = new DefaultFactHandle( 2,
cheddar1 );
map.add( cheddarHandle1 );
- Cheese stilton2 = new Cheese( "stilton",
+ final Cheese stilton2 = new Cheese( "stilton",
81 );
- InternalFactHandle stiltonHandle2 = new DefaultFactHandle( 3,
+ final InternalFactHandle stiltonHandle2 = new DefaultFactHandle( 3,
stilton2 );
map.add( stiltonHandle2 );
@@ -161,12 +161,12 @@
tablePopulationSize( map ) );
// Check they are correctly chained to the same FieldIndexEntry
- Cheese stilton3 = new Cheese( "stilton",
+ final Cheese stilton3 = new Cheese( "stilton",
89 );
- InternalFactHandle stiltonHandle3 = new DefaultFactHandle( 4,
+ final InternalFactHandle stiltonHandle3 = new DefaultFactHandle( 4,
stilton2 );
- FieldIndexEntry stiltonEntry = map.get( new ReteTuple( stiltonHandle3 ) );
+ final FieldIndexEntry stiltonEntry = map.get( new ReteTuple( stiltonHandle3 ) );
assertSame( stiltonHandle2,
stiltonEntry.getFirst().getFactHandle() );
assertSame( stiltonHandle1,
@@ -177,29 +177,29 @@
final FieldExtractor extractor = new ClassFieldExtractor( TestClass.class,
"object" );
- Column column = new Column( 0,
+ final Column column = new Column( 0,
new ClassObjectType( TestClass.class ) );
final Declaration declaration = new Declaration( "theObject",
extractor,
column );
- FieldIndexHashTable map = new FieldIndexHashTable( extractor,
+ final FieldIndexHashTable map = new FieldIndexHashTable( extractor,
declaration );
- TestClass c1 = new TestClass( 0,
+ final TestClass c1 = new TestClass( 0,
new TestClass( 20,
"stilton" ) );
- InternalFactHandle ch1 = new DefaultFactHandle( 1,
+ final InternalFactHandle ch1 = new DefaultFactHandle( 1,
c1 );
map.add( ch1 );
- TestClass c2 = new TestClass( 0,
+ final TestClass c2 = new TestClass( 0,
new TestClass( 20,
"cheddar" ) );
- InternalFactHandle ch2 = new DefaultFactHandle( 2,
+ final InternalFactHandle ch2 = new DefaultFactHandle( 2,
c2 );
map.add( ch2 );
@@ -212,7 +212,7 @@
tablePopulationSize( map ) );
// this table bucket will have two FieldIndexEntries, as they are actually two different values
- FieldIndexEntry entry = (FieldIndexEntry) getEntries( map )[0];
+ final FieldIndexEntry entry = (FieldIndexEntry) getEntries( map )[0];
assertEquals( c2.getObject(),
entry.getValue() );
@@ -224,34 +224,34 @@
final FieldExtractor extractor = new ClassFieldExtractor( Cheese.class,
"type" );
- Column column = new Column( 0,
+ final Column column = new Column( 0,
new ClassObjectType( Cheese.class ) );
final Declaration declaration = new Declaration( "typeOfCheese",
extractor,
column );
- FieldIndexHashTable map = new FieldIndexHashTable( extractor,
+ final FieldIndexHashTable map = new FieldIndexHashTable( extractor,
declaration );
assertEquals( 0,
map.size() );
- Cheese stilton1 = new Cheese( "stilton",
+ final Cheese stilton1 = new Cheese( "stilton",
35 );
- InternalFactHandle stiltonHandle1 = new DefaultFactHandle( 1,
+ final InternalFactHandle stiltonHandle1 = new DefaultFactHandle( 1,
stilton1 );
map.add( stiltonHandle1 );
- Cheese cheddar1 = new Cheese( "cheddar",
+ final Cheese cheddar1 = new Cheese( "cheddar",
35 );
- InternalFactHandle cheddarHandle1 = new DefaultFactHandle( 2,
+ final InternalFactHandle cheddarHandle1 = new DefaultFactHandle( 2,
cheddar1 );
map.add( cheddarHandle1 );
- Cheese stilton2 = new Cheese( "stilton",
+ final Cheese stilton2 = new Cheese( "stilton",
81 );
- InternalFactHandle stiltonHandle2 = new DefaultFactHandle( 3,
+ final InternalFactHandle stiltonHandle2 = new DefaultFactHandle( 3,
stilton2 );
map.add( stiltonHandle2 );
@@ -288,95 +288,95 @@
final FieldExtractor extractor = new ClassFieldExtractor( Cheese.class,
"type" );
- Column column = new Column( 0,
+ final Column column = new Column( 0,
new ClassObjectType( Cheese.class ) );
final Declaration declaration = new Declaration( "typeOfCheese",
extractor,
column );
- FieldIndexHashTable map = new FieldIndexHashTable( extractor,
+ final FieldIndexHashTable map = new FieldIndexHashTable( extractor,
declaration );
assertEquals( 0,
map.size() );
- Cheese stilton1 = new Cheese( "stilton",
+ final Cheese stilton1 = new Cheese( "stilton",
35 );
map.add( new DefaultFactHandle( 1,
stilton1 ) );
- Cheese stilton2 = new Cheese( "stilton",
+ final Cheese stilton2 = new Cheese( "stilton",
81 );
map.add( new DefaultFactHandle( 2,
stilton2 ) );
- Cheese cheddar1 = new Cheese( "cheddar",
+ final Cheese cheddar1 = new Cheese( "cheddar",
35 );
map.add( new DefaultFactHandle( 3,
cheddar1 ) );
- Cheese cheddar2 = new Cheese( "cheddar",
+ final Cheese cheddar2 = new Cheese( "cheddar",
38 );
map.add( new DefaultFactHandle( 4,
cheddar2 ) );
- Cheese brie = new Cheese( "brie",
+ final Cheese brie = new Cheese( "brie",
293 );
map.add( new DefaultFactHandle( 5,
brie ) );
- Cheese mozerella = new Cheese( "mozerella",
+ final Cheese mozerella = new Cheese( "mozerella",
15 );
map.add( new DefaultFactHandle( 6,
mozerella ) );
- Cheese dolcelatte = new Cheese( "dolcelatte",
+ final Cheese dolcelatte = new Cheese( "dolcelatte",
284 );
map.add( new DefaultFactHandle( 7,
dolcelatte ) );
- Cheese camembert1 = new Cheese( "camembert",
+ final Cheese camembert1 = new Cheese( "camembert",
924 );
map.add( new DefaultFactHandle( 8,
camembert1 ) );
- Cheese camembert2 = new Cheese( "camembert",
+ final Cheese camembert2 = new Cheese( "camembert",
765 );
map.add( new DefaultFactHandle( 9,
camembert2 ) );
- Cheese redLeicestor = new Cheese( "red leicestor",
+ final Cheese redLeicestor = new Cheese( "red leicestor",
23 );
map.add( new DefaultFactHandle( 10,
redLeicestor ) );
- Cheese wensleydale = new Cheese( "wensleydale",
+ final Cheese wensleydale = new Cheese( "wensleydale",
20 );
map.add( new DefaultFactHandle( 11,
wensleydale ) );
- Cheese edam = new Cheese( "edam",
+ final Cheese edam = new Cheese( "edam",
12 );
map.add( new DefaultFactHandle( 12,
edam ) );
- Cheese goude1 = new Cheese( "goude",
+ final Cheese goude1 = new Cheese( "goude",
93 );
map.add( new DefaultFactHandle( 13,
goude1 ) );
- Cheese goude2 = new Cheese( "goude",
+ final Cheese goude2 = new Cheese( "goude",
88 );
map.add( new DefaultFactHandle( 14,
goude2 ) );
- Cheese gruyere = new Cheese( "gruyere",
+ final Cheese gruyere = new Cheese( "gruyere",
82 );
map.add( new DefaultFactHandle( 15,
gruyere ) );
- Cheese emmental = new Cheese( "emmental",
+ final Cheese emmental = new Cheese( "emmental",
98 );
map.add( new DefaultFactHandle( 16,
emmental ) );
@@ -391,7 +391,7 @@
assertEquals( 16,
table.length );
- Cheese feta = new Cheese( "feta",
+ final Cheese feta = new Cheese( "feta",
48 );
map.add( new DefaultFactHandle( 2,
feta ) );
@@ -401,16 +401,16 @@
assertEquals( 13,
map.size() );
- table = (Entry[]) map.getTable();
+ table = map.getTable();
assertEquals( 32,
table.length );
- Cheese haloumi = new Cheese( "haloumi",
+ final Cheese haloumi = new Cheese( "haloumi",
48 );
map.add( new DefaultFactHandle( 2,
haloumi ) );
- Cheese chevre = new Cheese( "chevre",
+ final Cheese chevre = new Cheese( "chevre",
48 );
map.add( new DefaultFactHandle( 2,
chevre ) );
@@ -425,8 +425,8 @@
}
- public TestClass(int hashCode,
- Object object) {
+ public TestClass(final int hashCode,
+ final Object object) {
this.hashCode = hashCode;
this.object = object;
}
@@ -435,11 +435,11 @@
return this.object;
}
- public void setObject(Object object) {
+ public void setObject(final Object object) {
this.object = object;
}
- public void setHashCode(int hashCode) {
+ public void setHashCode(final int hashCode) {
this.hashCode = hashCode;
}
@@ -447,23 +447,33 @@
return this.hashCode;
}
- public boolean equals(Object obj) {
- if ( this == obj ) return true;
- if ( obj == null ) return false;
- if ( getClass() != obj.getClass() ) return false;
+ public boolean equals(final Object obj) {
+ if ( this == obj ) {
+ return true;
+ }
+ if ( obj == null ) {
+ return false;
+ }
+ if ( getClass() != obj.getClass() ) {
+ return false;
+ }
final TestClass other = (TestClass) obj;
if ( this.object == null ) {
- if ( other.object != null ) return false;
- } else if ( !this.object.equals( other.object ) ) return false;
+ if ( other.object != null ) {
+ return false;
+ }
+ } else if ( !this.object.equals( other.object ) ) {
+ return false;
+ }
return true;
}
}
- private int tablePopulationSize(AbstractHashTable map) throws Exception {
- Field field = AbstractHashTable.class.getDeclaredField( "table" );
+ private int tablePopulationSize(final AbstractHashTable map) throws Exception {
+ final Field field = AbstractHashTable.class.getDeclaredField( "table" );
field.setAccessible( true );
- Entry[] array = (Entry[]) field.get( map );
+ final Entry[] array = (Entry[]) field.get( map );
int size = 0;
for ( int i = 0, length = array.length; i < length; i++ ) {
if ( array[i] != null ) {
@@ -473,12 +483,12 @@
return size;
}
- private Entry[] getEntries(AbstractHashTable map) throws Exception {
- Field field = AbstractHashTable.class.getDeclaredField( "table" );
+ private Entry[] getEntries(final AbstractHashTable map) throws Exception {
+ final Field field = AbstractHashTable.class.getDeclaredField( "table" );
field.setAccessible( true );
- List list = new ArrayList();
+ final List list = new ArrayList();
- Entry[] array = (Entry[]) field.get( map );
+ final Entry[] array = (Entry[]) field.get( map );
for ( int i = 0, length = array.length; i < length; i++ ) {
if ( array[i] != null ) {
list.add( array[i] );
@@ -491,21 +501,22 @@
final FieldExtractor extractor = new ClassFieldExtractor( Cheese.class,
"type" );
- Column column = new Column( 0,
+ final Column column = new Column( 0,
new ClassObjectType( Cheese.class ) );
final Declaration declaration = new Declaration( "typeOfCheese",
extractor,
column );
- FieldIndexHashTable map = new FieldIndexHashTable( extractor,
+ final FieldIndexHashTable map = new FieldIndexHashTable( extractor,
declaration );
- Cheese stilton = new Cheese( "stilton", 55 );
- InternalFactHandle stiltonHandle = new DefaultFactHandle( 2,
- stilton );
-
- Iterator it = map.iterator( new ReteTuple( stiltonHandle ) );
+ final Cheese stilton = new Cheese( "stilton",
+ 55 );
+ final InternalFactHandle stiltonHandle = new DefaultFactHandle( 2,
+ stilton );
+
+ final Iterator it = map.iterator( new ReteTuple( stiltonHandle ) );
for ( ObjectEntry entry = (ObjectEntry) it.next(); entry != null; entry = (ObjectEntry) it.next() ) {
fail( "Map is empty, there should be no iteration" );
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/ObjectHashMapTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/ObjectHashMapTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/ObjectHashMapTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -6,82 +6,100 @@
import org.drools.util.ObjectHashMap.ObjectEntry;
public class ObjectHashMapTest extends TestCase {
- public void testChechExistsFalse() {
- ObjectHashMap map = new ObjectHashMap();
- Cheese stilton = new Cheese("stilton", 5);
- map.put(new Integer(1), stilton, false);
-
- Cheese c = (Cheese) map.get(new Integer(1));
- assertSame(stilton, c);
-
+ public void testChechExistsFalse() {
+ final ObjectHashMap map = new ObjectHashMap();
+ final Cheese stilton = new Cheese( "stilton",
+ 5 );
+ map.put( new Integer( 1 ),
+ stilton,
+ false );
+
+ Cheese c = (Cheese) map.get( new Integer( 1 ) );
+ assertSame( stilton,
+ c );
+
// we haven't told the map to check if the key exists, so we should end up with two entries.
// the second one is nolonger reacheable
- Cheese cheddar = new Cheese("cheddar", 5);
- map.put(new Integer(1), cheddar);
- c = (Cheese) map.get(new Integer(1));
- assertSame(cheddar, c);
-
- Entry entry = map.getBucket( new Integer(1).hashCode() );
+ final Cheese cheddar = new Cheese( "cheddar",
+ 5 );
+ map.put( new Integer( 1 ),
+ cheddar );
+ c = (Cheese) map.get( new Integer( 1 ) );
+ assertSame( cheddar,
+ c );
+
+ Entry entry = map.getBucket( new Integer( 1 ).hashCode() );
int size = 0;
while ( entry != null ) {
size++;
entry = entry.getNext();
}
-
- assertEquals( 2, size);
-
+
+ assertEquals( 2,
+ size );
+
// Check remove works, should leave one unreachable key
- map.remove( new Integer(1) );
- entry = map.getBucket( new Integer(1).hashCode() );
+ map.remove( new Integer( 1 ) );
+ entry = map.getBucket( new Integer( 1 ).hashCode() );
size = 0;
while ( entry != null ) {
size++;
entry = entry.getNext();
}
-
- assertEquals( 1, size);
- }
-
+
+ assertEquals( 1,
+ size );
+ }
+
public void testChechExistsTrue() {
- ObjectHashMap map = new ObjectHashMap();
- Cheese stilton = new Cheese("stilton", 5);
- map.put(new Integer(1), stilton, true);
-
- Cheese c = (Cheese) map.get(new Integer(1));
- assertSame(stilton, c);
-
+ final ObjectHashMap map = new ObjectHashMap();
+ final Cheese stilton = new Cheese( "stilton",
+ 5 );
+ map.put( new Integer( 1 ),
+ stilton,
+ true );
+
+ Cheese c = (Cheese) map.get( new Integer( 1 ) );
+ assertSame( stilton,
+ c );
+
// we haven't told the map to check if the key exists, so we should end up with two entries.
// the second one is nolonger reacheable
- Cheese cheddar = new Cheese("cheddar", 5);
- map.put(new Integer(1), cheddar);
- c = (Cheese) map.get(new Integer(1));
- assertSame(cheddar, c);
-
- Entry entry = map.getBucket( new Integer(1).hashCode() );
+ final Cheese cheddar = new Cheese( "cheddar",
+ 5 );
+ map.put( new Integer( 1 ),
+ cheddar );
+ c = (Cheese) map.get( new Integer( 1 ) );
+ assertSame( cheddar,
+ c );
+
+ Entry entry = map.getBucket( new Integer( 1 ).hashCode() );
int size = 0;
while ( entry != null ) {
size++;
entry = entry.getNext();
}
-
- assertEquals( 1, size);
-
+
+ assertEquals( 1,
+ size );
+
// Check remove works
- map.remove( new Integer(1) );
- entry = map.getBucket( new Integer(1).hashCode() );
+ map.remove( new Integer( 1 ) );
+ entry = map.getBucket( new Integer( 1 ).hashCode() );
size = 0;
while ( entry != null ) {
size++;
entry = entry.getNext();
}
-
- assertEquals( 0, size);
+
+ assertEquals( 0,
+ size );
}
-
+
public void testEmptyIterator() {
- ObjectHashMap map = new ObjectHashMap();
- Iterator it = map.iterator();
- for( ObjectEntry entry = ( ObjectEntry ) it.next(); entry != null; entry = ( ObjectEntry ) it.next() ) {
+ final ObjectHashMap map = new ObjectHashMap();
+ final Iterator it = map.iterator();
+ for ( ObjectEntry entry = (ObjectEntry) it.next(); entry != null; entry = (ObjectEntry) it.next() ) {
fail( "Map is empty, there should be no iteration" );
}
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/asm/AbstractClass.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/asm/AbstractClass.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/asm/AbstractClass.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -4,10 +4,10 @@
public String HTML;
public AbstractClass() {
-
+
}
-
- public AbstractClass(String HTML) {
+
+ public AbstractClass(final String HTML) {
super();
this.HTML = HTML;
}
@@ -22,10 +22,8 @@
/**
* @param uri the uRI to set
*/
- public void setHTML(String HTML) {
+ public void setHTML(final String HTML) {
this.HTML = HTML;
}
-
-
-
+
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/asm/ClassFieldInspectorTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/asm/ClassFieldInspectorTest.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/asm/ClassFieldInspectorTest.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -36,8 +36,7 @@
((Method) ext.getPropertyGetters().get( 1 )).getName() );
assertEquals( "getName",
((Method) ext.getPropertyGetters().get( 2 )).getName() );
-
-
+
final Map names = ext.getFieldNames();
assertNotNull( names );
assertEquals( 7,
@@ -49,7 +48,7 @@
assertEquals( 2,
((Integer) names.get( "name" )).intValue() );
assertNull( names.get( "nAme" ) );
-
+
}
public void testInterface() throws Exception {
@@ -96,18 +95,21 @@
ClassFieldInspector ext = new ClassFieldInspector( BeanInherit.class );
assertEquals( 5,
ext.getPropertyGetters().size() );
-
+
ext = new ClassFieldInspector( InterfaceChildImpl.class );
assertEquals( 8,
ext.getPropertyGetters().size() );
// test inheritence from abstract class
- assertEquals( 4, ( (Integer) ext.getFieldNames().get( "HTML" )).intValue() );
-
+ assertEquals( 4,
+ ((Integer) ext.getFieldNames().get( "HTML" )).intValue() );
+
// check normal field on child class
- assertEquals( 1, ( (Integer) ext.getFieldNames().get( "baz" )).intValue() );
-
+ assertEquals( 1,
+ ((Integer) ext.getFieldNames().get( "baz" )).intValue() );
+
// test inheritence from an interface
- assertEquals( 3, ( (Integer) ext.getFieldNames().get( "URI" )).intValue() );
+ assertEquals( 3,
+ ((Integer) ext.getFieldNames().get( "URI" )).intValue() );
}
public void testIntefaceInheritance() throws Exception {
@@ -115,7 +117,7 @@
final Map fields = ext.getFieldNames();
assertTrue( fields.containsKey( "foo" ) );
assertTrue( fields.containsKey( "bar" ) );
- assertTrue( fields.containsKey( "baz" ) );
+ assertTrue( fields.containsKey( "baz" ) );
assertTrue( fields.containsKey( "URI" ) );
}
@@ -161,7 +163,7 @@
assertEquals( "getName",
((Method) methods.get( "name" )).getName() );
// test case sensitive
- assertNull( methods.get( "nAme" ));
+ assertNull( methods.get( "nAme" ) );
assertEquals( "getAge",
((Method) methods.get( "age" )).getName() );
@@ -180,14 +182,14 @@
ext.getFieldTypes().get( "foo" ) );
}
-
+
public void testWierdCapsForField() throws Exception {
final ClassFieldInspector ext = new ClassFieldInspector( Person.class );
final Map methods = ext.getGetterMethods();
assertEquals( "getURI",
((Method) methods.get( "URI" )).getName() );
assertEquals( 7,
- methods.size() );
+ methods.size() );
}
static class NonGetter {
@@ -253,13 +255,13 @@
public String getAlsoBad(final String s) {
return "ignored";
}
-
+
//this should show up, as its a getter, but all CAPS
public String getURI() {
return this.URI;
}
-
- public void setURI(String URI) {
+
+ public void setURI(final String URI) {
this.URI = URI;
}
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/asm/InterfaceChildImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/asm/InterfaceChildImpl.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/asm/InterfaceChildImpl.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -3,71 +3,78 @@
public class InterfaceChildImpl extends AbstractClass
implements
InterfaceChild {
-
+
private String bar;
- private int foo;
- private int baz;
+ private int foo;
+ private int baz;
private String URI;
- public InterfaceChildImpl(String HTML,
- String bar,
- int foo,
- int baz,
- String uri) {
- super(HTML);
+
+ public InterfaceChildImpl(final String HTML,
+ final String bar,
+ final int foo,
+ final int baz,
+ final String uri) {
+ super( HTML );
this.bar = bar;
this.foo = foo;
this.baz = baz;
this.URI = uri;
}
+
/**
* @return the bar
*/
public String getBar() {
return this.bar;
}
+
/**
* @param bar the bar to set
*/
- public void setBar(String bar) {
+ public void setBar(final String bar) {
this.bar = bar;
}
+
/**
* @return the baz
*/
public int getBaz() {
return this.baz;
}
+
/**
* @param baz the baz to set
*/
- public void setBaz(int baz) {
+ public void setBaz(final int baz) {
this.baz = baz;
}
+
/**
* @return the foo
*/
public int getFoo() {
return this.foo;
}
+
/**
* @param foo the foo to set
*/
- public void setFoo(int foo) {
+ public void setFoo(final int foo) {
this.foo = foo;
}
+
/**
* @return the uRI
*/
public String getURI() {
return this.URI;
}
+
/**
* @param uri the uRI to set
*/
- public void setURI(String uri) {
+ public void setURI(final String uri) {
this.URI = uri;
}
-
-
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/asm/InterfaceParent2.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/asm/InterfaceParent2.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/asm/InterfaceParent2.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -19,7 +19,7 @@
public interface InterfaceParent2 {
public int getBaz();
-
+
public String getURI();
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/asm/TestBean.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/asm/TestBean.java 2006-10-19 00:19:48 UTC (rev 6906)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/asm/TestBean.java 2006-10-19 00:32:57 UTC (rev 6907)
@@ -18,9 +18,9 @@
public class TestBean {
- private String something;
- private int number;
- private boolean blah;
+ private String something;
+ private int number;
+ private boolean blah;
private Object[] objArray;
public boolean isBlah() {
@@ -60,10 +60,10 @@
}
public Object[] getObjArray() {
- return objArray;
+ return this.objArray;
}
- public void setObjArray(Object[] objArray) {
+ public void setObjArray(final Object[] objArray) {
this.objArray = objArray;
}
More information about the jboss-svn-commits
mailing list