[jboss-svn-commits] JBL Code SVN: r10952 - in labs/jbossrules/trunk/drools-core/src: main/java/org/drools and 48 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Apr 12 19:10:11 EDT 2007
Author: mark.proctor at jboss.com
Date: 2007-04-12 19:10:10 -0400 (Thu, 12 Apr 2007)
New Revision: 10952
Modified:
labs/jbossrules/trunk/drools-core/src/main/java/org/codehaus/jfdi/interpreter/ClassTypeResolver.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/Agenda.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/FactHandle.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/RuleBase.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/RuleBaseConfiguration.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/RuleBaseFactory.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/RuntimeDroolsException.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/WorkingMemoryFileLogger.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/audit/WorkingMemoryLogger.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/audit/event/ActivationLogEvent.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/audit/event/ObjectLogEvent.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/DelegateJavaFactHandler.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/ShadowProxyHelper.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/MVELDataProvider.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/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/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/extractors/SelfReferenceClassFieldExtractor.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/DroolsMVELFactory.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/DroolsMVELGlobalVariable.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/DroolsMVELLocalDeclarationVariable.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/DroolsMVELPreviousDeclarationVariable.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/MVELConsequence.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/MVELEvalExpression.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/MVELPredicateExpression.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/MVELReturnValueExpression.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/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/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/InternalRuleFlowGroup.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/LogicalDependency.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/ObjectInputStreamWithLoader.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/PropagationContextImpl.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/QuadroupleBetaConstraints.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/RuleFlowGroupImpl.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/RuleFlowGroupNode.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/TupleStartEqualsConstraint.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/conflict/TotalRecencyConflictResolver.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/event/AgendaEventListener.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/event/AgendaEventSupport.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/event/DebugAgendaEventListener.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/event/DefaultAgendaEventListener.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/facttemplates/FactTemplateFieldExtractor.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/EmptyObjectSinkAdapter.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/EmptyTupleSinkAdapter.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/ExistsNode.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/InitialFactImpl.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/ObjectSink.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/QueryTerminalNode.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/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/RuleTerminalNode.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/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/reteoo/builder/AccumulateBuilder.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/BuildContext.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/BuildUtils.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/CollectBuilder.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/ColumnBuilder.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/EvalBuilder.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/ForallBuilder.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/FromBuilder.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/GroupElementBuilder.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/ReteooComponentBuilder.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/ReteooRuleBuilder.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/CompositePackageClassLoader.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/ConditionalElement.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/EvalCondition.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/Forall.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/GroupElement.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/GroupElementFactory.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/LogicTransformer.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/MultiRestrictionFieldConstraint.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/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/Rule.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/RuleConditionElement.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/ruleflow/common/core/IProcess.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/core/impl/Process.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/datatype/IDataType.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/datatype/IDataTypeFactory.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/datatype/impl/InstanceDataTypeFactory.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/datatype/impl/NewInstanceDataTypeFactory.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/datatype/impl/type/BooleanDataType.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/datatype/impl/type/FloatDataType.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/datatype/impl/type/IntegerDataType.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/datatype/impl/type/ListDataType.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/datatype/impl/type/StringDataType.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/datatype/impl/type/UndefinedDataType.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/instance/IProcessInstance.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/instance/impl/ProcessInstance.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/IConnection.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/IConstraint.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/IEndNode.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/IJoin.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/INode.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/IRuleFlowProcess.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/IRuleFlowProcessValidationError.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/IRuleFlowProcessValidator.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/IRuleSetNode.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/ISplit.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/IStartNode.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/IVariable.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/Connection.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/Constraint.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/EndNode.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/Join.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/Node.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/RuleFlowProcess.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/RuleFlowProcessValidationError.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/RuleFlowProcessValidator.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/RuleSetNode.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/Split.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/StartNode.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/Variable.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/IRuleFlowNodeInstance.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/IRuleFlowProcessInstance.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/EndNodeInstance.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/RuleFlowJoinInstance.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/RuleFlowNodeInstance.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/RuleFlowProcessInstance.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/RuleFlowSequenceNodeInstance.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/RuleFlowSplitInstance.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/StartNodeInstance.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/Activation.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/ActivationGroup.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/ColumnExtractor.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/DeclarationScopeResolver.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/Evaluator.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/Extractor.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/GlobalExtractor.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/JavaFact.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/KnowledgeHelper.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/spi/RuleFlowGroup.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/Tuple.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/AbstractBaseLinkedListNode.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/Entry.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/FactHandleIndexHashTable.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/Iterator.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/ObjectHashMap.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/TupleIndexHashTable.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/asm/ClassFieldInspector.java
labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/Objenesis.java
labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/ObjenesisBase.java
labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/ObjenesisException.java
labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/ObjenesisHelper.java
labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/ObjenesisSerializer.java
labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/ObjenesisStd.java
labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/NullInstantiator.java
labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/ObjectInstantiator.java
labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/SerializationInstantiatorHelper.java
labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/basic/AccessibleInstantiator.java
labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/basic/ConstructorInstantiator.java
labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/basic/NewInstanceInstantiator.java
labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/basic/ObjectInputStreamInstantiator.java
labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/basic/ObjectStreamClassInstantiator.java
labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/gcj/GCJInstantiator.java
labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/gcj/GCJInstantiatorBase.java
labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/gcj/GCJSerializationInstantiator.java
labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/jrockit/JRockit131Instantiator.java
labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/jrockit/JRockitLegacyInstantiator.java
labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/sun/Sun13Instantiator.java
labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/sun/Sun13InstantiatorBase.java
labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/sun/Sun13SerializationInstantiator.java
labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/sun/SunReflectionFactoryInstantiator.java
labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/sun/SunReflectionFactorySerializationInstantiator.java
labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/strategy/BaseInstantiatorStrategy.java
labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/strategy/InstantiatorStrategy.java
labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/strategy/SerializingInstantiatorStrategy.java
labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/strategy/StdInstantiatorStrategy.java
labs/jbossrules/trunk/drools-core/src/test/java/org/codehaus/jfdi/interpreter/ClassTypeResolverTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/Cheese.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/Person.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/RuleBaseFactoryTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/BaseClassFieldExtractorFactoryTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/DelegateJavaFactHandlerTest.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/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/IntClassFieldExtractorTest.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/event/AgendaEventSupportTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/event/WorkingMemoryEventSupportTest.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/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/reteoo/AccumulateNodeTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/AgendaTest.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/BetaNodeTest.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/CompositeObjectSinkAdapterTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/CrossProductTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/EvalConditionNodeTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/ExistsNodeTest.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/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/LogicalAssertionTest.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/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/OtherwiseTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/PropertyChangeListenerTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/QueryTerminalNodeTest.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/RuleFlowGroupTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/SchedulerTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/TupleSourceTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/builder/ReteooRuleBuilderTest.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/GroupElementTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/rule/LogicTransformerTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/rule/RuleTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/spi/MockConstraint.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/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/ObjectHashMapTest2.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/asm/ClassFieldInspectorTest.java
Log:
core/compiler core reformat and tidy
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/codehaus/jfdi/interpreter/ClassTypeResolver.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/codehaus/jfdi/interpreter/ClassTypeResolver.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/codehaus/jfdi/interpreter/ClassTypeResolver.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -34,7 +34,7 @@
private Map cachedImports = new HashMap();
- private static Map internalNamesMap = new HashMap();
+ private static final Map internalNamesMap = new HashMap();
static {
internalNamesMap.put( "int",
"I" );
@@ -123,18 +123,18 @@
public Class resolveType(String className) throws ClassNotFoundException {
Class clazz = null;
boolean isArray = false;
- StringBuffer arrayClassName = new StringBuffer();
+ final StringBuffer arrayClassName = new StringBuffer();
//is the class a primitive type ?
if ( internalNamesMap.containsKey( className ) ) {
clazz = Class.forName( "[" + internalNamesMap.get( className ),
true,
- classLoader ).getComponentType();
+ this.classLoader ).getComponentType();
// Could also be a primitive array
} else if ( className.indexOf( '[' ) > 0 ) {
isArray = true;
int bracketIndex = className.indexOf( '[' );
- String componentName = className.substring( 0,
+ final String componentName = className.substring( 0,
bracketIndex );
arrayClassName.append( '[' );
while ( (bracketIndex = className.indexOf( '[',
@@ -210,7 +210,7 @@
}
try {
clazz = Class.forName( arrayClassName.toString() );
- } catch ( ClassNotFoundException e ) {
+ } catch ( final ClassNotFoundException e ) {
clazz = null;
}
}
@@ -270,8 +270,8 @@
return clazz;
}
- private Class defaultClass(String className) {
- String qualifiedClass = "java.lang." + className;
+ private Class defaultClass(final String className) {
+ final String qualifiedClass = "java.lang." + className;
Class clazz = null;
try {
clazz = this.classLoader.loadClass( qualifiedClass );
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/Agenda.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/Agenda.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/Agenda.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -18,9 +18,9 @@
public AgendaGroup getFocus();
public AgendaGroup getAgendaGroup(String name);
-
+
public RuleFlowGroup getRuleFlowGroup(String name);
-
+
/**
* Activates the <code>RuleFlowGroup</code> with the given name.
* All activations in the given <code>RuleFlowGroup</code> are added to the agenda.
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/FactHandle.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/FactHandle.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/FactHandle.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -35,5 +35,5 @@
*
* @return The external string form.
*/
- String toExternalForm();
+ String toExternalForm();
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/RuleBase.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -128,7 +128,7 @@
void addProcess(IProcess process);
void removeProcess(String id);
-
+
IProcess getProcess(String id);
void removeRule(String packageName,
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/RuleBaseConfiguration.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/RuleBaseConfiguration.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/RuleBaseConfiguration.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -56,8 +56,8 @@
private static final long serialVersionUID = 320L;
private boolean immutable;
-
- private boolean maintainTms;
+
+ private boolean maintainTms;
private boolean removeIdentities;
private boolean shareAlphaNodes;
private boolean shareBetaNodes;
@@ -73,14 +73,14 @@
this.immutable = false;
setMaintainTms( Boolean.valueOf( System.getProperty( "drools.maintainTms",
- "true" ) ).booleanValue() );
-
+ "true" ) ).booleanValue() );
+
setRemoveIdentities( Boolean.valueOf( System.getProperty( "drools.removeIdentities",
"false" ) ).booleanValue() );
-
+
setAlphaMemory( Boolean.valueOf( System.getProperty( "drools.alphaMemory",
"false" ) ).booleanValue() );
-
+
setShareAlphaNodes( Boolean.valueOf( System.getProperty( "drools.shareAlphaNodes",
"true" ) ).booleanValue() );
@@ -120,82 +120,81 @@
public boolean isImmutable() {
return this.immutable;
}
-
+
private void checkCanChange() {
if ( this.immutable ) {
throw new UnsupportedOperationException( "Can't set a property after configuration becomes immutable" );
}
}
-
-
+
public boolean getMaintainTms() {
return this.maintainTms;
}
-
- public void setMaintainTms(boolean maintainTms) {
+
+ public void setMaintainTms(final boolean maintainTms) {
checkCanChange(); // throws an exception if a change isn't possible;
this.maintainTms = maintainTms;
}
-
+
public boolean isRemoveIdentities() {
- return removeIdentities;
+ return this.removeIdentities;
}
- public void setRemoveIdentities(boolean removeIdentities) {
+ public void setRemoveIdentities(final boolean removeIdentities) {
checkCanChange(); // throws an exception if a change isn't possible;
- this.removeIdentities = removeIdentities;
+ this.removeIdentities = removeIdentities;
}
public boolean isAlphaMemory() {
- return alphaMemory;
+ return this.alphaMemory;
}
- public void setAlphaMemory(boolean alphaMemory) {
+ public void setAlphaMemory(final boolean alphaMemory) {
checkCanChange(); // throws an exception if a change isn't possible;
this.alphaMemory = alphaMemory;
}
public boolean isShareAlphaNodes() {
- return shareAlphaNodes;
+ return this.shareAlphaNodes;
}
- public void setShareAlphaNodes(boolean shareAlphaNodes) {
+ public void setShareAlphaNodes(final boolean shareAlphaNodes) {
checkCanChange(); // throws an exception if a change isn't possible;
this.shareAlphaNodes = shareAlphaNodes;
}
public boolean isShareBetaNodes() {
- return shareBetaNodes;
+ return this.shareBetaNodes;
}
- public void setShareBetaNodes(boolean shareBetaNodes) {
+ public void setShareBetaNodes(final boolean shareBetaNodes) {
checkCanChange(); // throws an exception if a change isn't possible;
- this.shareBetaNodes = shareBetaNodes;
+ this.shareBetaNodes = shareBetaNodes;
}
public int getAlphaNodeHashingThreshold() {
- return alphaNodeHashingThreshold;
+ return this.alphaNodeHashingThreshold;
}
- public void setAlphaNodeHashingThreshold(int alphaNodeHashingThreshold) {
+ public void setAlphaNodeHashingThreshold(final int alphaNodeHashingThreshold) {
checkCanChange(); // throws an exception if a change isn't possible;
this.alphaNodeHashingThreshold = alphaNodeHashingThreshold;
}
public AssertBehaviour getAssertBehaviour() {
- return assertBehaviour;
+ return this.assertBehaviour;
}
- public void setAssertBehaviour(AssertBehaviour assertBehaviour) {
+ public void setAssertBehaviour(final AssertBehaviour assertBehaviour) {
checkCanChange(); // throws an exception if a change isn't possible;
this.assertBehaviour = assertBehaviour;
}
public int getCompositeKeyDepth() {
- return compositeKeyDepth;
+ return this.compositeKeyDepth;
}
- public void setCompositeKeyDepth(int compositeKeyDepth) {
+ public void setCompositeKeyDepth(final int compositeKeyDepth) {
if ( !this.immutable ) {
if ( compositeKeyDepth > 3 ) {
throw new UnsupportedOperationException( "compositeKeyDepth cannot be greater than 3" );
@@ -207,28 +206,28 @@
}
public boolean isIndexLeftBetaMemory() {
- return indexLeftBetaMemory;
+ return this.indexLeftBetaMemory;
}
- public void setIndexLeftBetaMemory(boolean indexLeftBetaMemory) {
+ public void setIndexLeftBetaMemory(final boolean indexLeftBetaMemory) {
checkCanChange(); // throws an exception if a change isn't possible;
this.indexLeftBetaMemory = indexLeftBetaMemory;
}
public boolean isIndexRightBetaMemory() {
- return indexRightBetaMemory;
+ return this.indexRightBetaMemory;
}
- public void setIndexRightBetaMemory(boolean indexRightBetaMemory) {
+ public void setIndexRightBetaMemory(final boolean indexRightBetaMemory) {
checkCanChange(); // throws an exception if a change isn't possible;
this.indexRightBetaMemory = indexRightBetaMemory;
}
public LogicalOverride getLogicalOverride() {
- return logicalOverride;
+ return this.logicalOverride;
}
- public void setLogicalOverride(LogicalOverride logicalOverride) {
+ public void setLogicalOverride(final LogicalOverride logicalOverride) {
checkCanChange(); // throws an exception if a change isn't possible;
this.logicalOverride = logicalOverride;
}
@@ -243,11 +242,11 @@
private int value;
- private AssertBehaviour(int value) {
+ private AssertBehaviour(final int value) {
this.value = value;
}
- public static AssertBehaviour determineAssertBehaviour(String value) {
+ public static AssertBehaviour determineAssertBehaviour(final String value) {
if ( value.equals( "IDENTITY" ) ) {
return IDENTITY;
} else if ( value.equals( "EQUALITY" ) ) {
@@ -279,11 +278,11 @@
private int value;
- private LogicalOverride(int value) {
+ private LogicalOverride(final int value) {
this.value = value;
}
- public static LogicalOverride determineLogicalOverride(String value) {
+ public static LogicalOverride determineLogicalOverride(final String value) {
if ( value.equals( "PRESERVE" ) ) {
return PRESERVE;
} else if ( value.equals( "DISCARD" ) ) {
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/RuleBaseFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/RuleBaseFactory.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/RuleBaseFactory.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -36,18 +36,22 @@
/** Create a new default rule base (RETEOO type engine) */
public static RuleBase newRuleBase() {
- return RuleBaseFactory.newRuleBase( RuleBase.RETEOO, null );
+ return RuleBaseFactory.newRuleBase( RuleBase.RETEOO,
+ null );
}
public static RuleBase newRuleBase(final int type) {
- return RuleBaseFactory.newRuleBase( type, null );
+ return RuleBaseFactory.newRuleBase( type,
+ null );
}
/** Create a new RuleBase of the appropriate type */
- public static RuleBase newRuleBase(final int type, final RuleBaseConfiguration config) {
+ public static RuleBase newRuleBase(final int type,
+ final RuleBaseConfiguration config) {
switch ( type ) {
case RuleBase.RETEOO :
- return new org.drools.reteoo.ReteooRuleBase( UUIDGenerator.getInstance().generateRandomBasedUUID().toString(), config );
+ return new org.drools.reteoo.ReteooRuleBase( UUIDGenerator.getInstance().generateRandomBasedUUID().toString(),
+ config );
case RuleBase.LEAPS :
//@todo this needs to be reflection based now, as we do not know the module is in the classpath
//return new org.drools.leaps.LeapsRuleBase( UUIDGenerator.getInstance().generateRandomBasedUUID().toString() );
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/RuntimeDroolsException.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/RuntimeDroolsException.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/RuntimeDroolsException.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -52,7 +52,8 @@
*/
public RuntimeDroolsException(final String message,
final Throwable cause) {
- super( message, cause );
+ super( message,
+ cause );
}
/**
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/SynchronizedWorkingMemory.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -183,8 +183,8 @@
this.workingMemory.setGlobal( name,
value );
}
-
- public synchronized IProcessInstance startProcess(String processId) {
- return this.workingMemory.startProcess(processId);
+
+ public synchronized IProcessInstance startProcess(final String processId) {
+ return this.workingMemory.startProcess( processId );
}
}
\ No newline at end of file
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/WorkingMemory.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -228,7 +228,7 @@
*
* @throws IllegalArgumentException
* if no query named "query" is found in the rulebase
- */
+ */
public QueryResults getQueryResults(String query);
/**
@@ -299,7 +299,7 @@
*
*/
void dispose();
-
+
/**
* Starts a new process instance for the process with the given id.
*/
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/audit/WorkingMemoryFileLogger.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/audit/WorkingMemoryFileLogger.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/audit/WorkingMemoryFileLogger.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -24,9 +24,6 @@
import org.drools.WorkingMemory;
import org.drools.audit.event.LogEvent;
-import org.drools.event.AgendaGroupPoppedEvent;
-import org.drools.event.AgendaGroupPushedEvent;
-
import com.thoughtworks.xstream.XStream;
/**
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/audit/WorkingMemoryLogger.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -166,7 +166,8 @@
/**
* @see org.drools.event.AgendaEventListener
*/
- public void activationCreated(final ActivationCreatedEvent event, WorkingMemory workingMemory) {
+ public void activationCreated(final ActivationCreatedEvent event,
+ final WorkingMemory workingMemory) {
filterLogEvent( new ActivationLogEvent( LogEvent.ACTIVATION_CREATED,
getActivationId( event.getActivation() ),
event.getActivation().getRule().getName(),
@@ -176,7 +177,8 @@
/**
* @see org.drools.event.AgendaEventListener
*/
- public void activationCancelled(final ActivationCancelledEvent event, WorkingMemory workingMemory) {
+ public void activationCancelled(final ActivationCancelledEvent event,
+ final WorkingMemory workingMemory) {
filterLogEvent( new ActivationLogEvent( LogEvent.ACTIVATION_CANCELLED,
getActivationId( event.getActivation() ),
event.getActivation().getRule().getName(),
@@ -186,7 +188,8 @@
/**
* @see org.drools.event.AgendaEventListener
*/
- public void beforeActivationFired(final BeforeActivationFiredEvent event, WorkingMemory workingMemory) {
+ public void beforeActivationFired(final BeforeActivationFiredEvent event,
+ final WorkingMemory workingMemory) {
filterLogEvent( new ActivationLogEvent( LogEvent.BEFORE_ACTIVATION_FIRE,
getActivationId( event.getActivation() ),
event.getActivation().getRule().getName(),
@@ -196,7 +199,8 @@
/**
* @see org.drools.event.AgendaEventListener
*/
- public void afterActivationFired(final AfterActivationFiredEvent event, WorkingMemory workingMemory) {
+ public void afterActivationFired(final AfterActivationFiredEvent event,
+ final WorkingMemory workingMemory) {
filterLogEvent( new ActivationLogEvent( LogEvent.AFTER_ACTIVATION_FIRE,
getActivationId( event.getActivation() ),
event.getActivation().getRule().getName(),
@@ -270,14 +274,14 @@
}
return result.append( "]" ).toString();
}
-
- public void agendaGroupPopped(AgendaGroupPoppedEvent event,
- WorkingMemory workingMemory) {
+
+ public void agendaGroupPopped(final AgendaGroupPoppedEvent event,
+ final WorkingMemory workingMemory) {
// we don't audit this yet
}
- public void agendaGroupPushed(AgendaGroupPushedEvent event,
- WorkingMemory workingMemory) {
+ public void agendaGroupPushed(final AgendaGroupPushedEvent event,
+ final WorkingMemory workingMemory) {
// we don't audit this yet
- }
+ }
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/audit/event/ActivationLogEvent.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/audit/event/ActivationLogEvent.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/audit/event/ActivationLogEvent.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -87,9 +87,9 @@
public String getDeclarations() {
return this.declarations;
}
-
+
public String toString() {
-
+
String msg = null;
switch ( this.getType() ) {
case ACTIVATION_CANCELLED :
@@ -98,14 +98,14 @@
case ACTIVATION_CREATED :
msg = "ACTIVATION CREATED";
break;
-
+
case AFTER_ACTIVATION_FIRE :
msg = "AFTER ACTIVATION FIRED";
- break;
+ break;
case BEFORE_ACTIVATION_FIRE :
msg = "BEFORE ACTIVATION FIRED";
break;
}
- return msg + " rule:" + rule + " activationId:" + activationId + " declarations: " + declarations ;
- }
+ return msg + " rule:" + this.rule + " activationId:" + this.activationId + " declarations: " + this.declarations;
+ }
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/audit/event/ObjectLogEvent.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/audit/event/ObjectLogEvent.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/audit/event/ObjectLogEvent.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -63,7 +63,7 @@
public String getObjectToString() {
return this.objectToString;
}
-
+
public String toString() {
String msg = null;
switch ( this.getType() ) {
@@ -73,12 +73,12 @@
case OBJECT_MODIFIED :
msg = "OBJECT MODIFIED";
break;
-
+
case OBJECT_RETRACTED :
msg = "OBJECT RETRACTED";
- break;
+ break;
}
- return msg + " value:" + this.objectToString + " factId: " + factId;
-
- }
+ return msg + " value:" + this.objectToString + " factId: " + this.factId;
+
+ }
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/BaseClassFieldExtractor.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -41,8 +41,8 @@
* @param valueType
*/
protected BaseClassFieldExtractor(final int index,
- final Class fieldType,
- final ValueType valueType) {
+ final Class fieldType,
+ final ValueType valueType) {
this.index = index;
this.fieldType = fieldType;
this.valueType = valueType;
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/BaseEvaluator.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -51,7 +51,7 @@
if ( this == object ) {
return true;
}
- if ( object == null || !( object instanceof BaseEvaluator) ) {
+ if ( object == null || !(object instanceof BaseEvaluator) ) {
return false;
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/ClassFieldExtractor.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -100,7 +100,7 @@
return true;
}
- if ( object == null || !( object instanceof ClassFieldExtractor ) ) {
+ if ( object == null || !(object instanceof ClassFieldExtractor) ) {
return false;
}
@@ -140,12 +140,12 @@
public short getShortValue(final Object object) {
return this.extractor.getShortValue( object );
}
-
+
public Method getNativeReadMethod() {
return this.extractor.getNativeReadMethod();
}
- public int getHashCode(Object object) {
+ public int getHashCode(final Object object) {
return this.extractor.getHashCode( 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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/ClassFieldExtractorCache.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -26,9 +26,9 @@
return (ClassFieldExtractor) this.cache.get( key );
} else {
final ClassFieldExtractor ex = new ClassFieldExtractor( clazz,
- fieldName );
+ fieldName );
this.cache.put( key,
- ex );
+ 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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/ClassFieldExtractorFactory.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -101,9 +101,9 @@
bytes,
PROTECTION_DOMAIN );
// instantiating target class
- Integer index = (Integer) inspector.getFieldNames().get( fieldName );
- ValueType valueType = ValueType.determineValueType( fieldType );
- final Object[] params = { index, fieldType, valueType };
+ final Integer index = (Integer) inspector.getFieldNames().get( fieldName );
+ final ValueType valueType = ValueType.determineValueType( fieldType );
+ final Object[] params = {index, fieldType, valueType};
return (BaseClassFieldExtractor) newClass.getConstructors()[0].newInstance( params );
}
} catch ( final Exception e ) {
@@ -124,9 +124,9 @@
className,
cw );
-// buildConstructor( superClass,
-// className,
-// cw );
+ // buildConstructor( superClass,
+ // className,
+ // cw );
build3ArgConstructor( superClass,
className,
@@ -164,67 +164,67 @@
null );
}
-// /**
-// * Creates a constructor for the field extractor receiving
-// * the class instance and field name
-// *
-// * @param originalClassName
-// * @param className
-// * @param cw
-// */
-// private static void buildConstructor(final Class superClazz,
-// final String className,
-// final ClassWriter cw) {
-// MethodVisitor mv;
-// {
-// mv = cw.visitMethod( Opcodes.ACC_PUBLIC,
-// "<init>",
-// Type.getMethodDescriptor( Type.VOID_TYPE,
-// new Type[]{Type.getType( Class.class ), Type.getType( String.class )} ),
-// null,
-// null );
-// mv.visitCode();
-// final Label l0 = new Label();
-// mv.visitLabel( l0 );
-// mv.visitVarInsn( Opcodes.ALOAD,
-// 0 );
-// mv.visitVarInsn( Opcodes.ALOAD,
-// 1 );
-// mv.visitVarInsn( Opcodes.ALOAD,
-// 2 );
-// mv.visitMethodInsn( Opcodes.INVOKESPECIAL,
-// Type.getInternalName( superClazz ),
-// "<init>",
-// Type.getMethodDescriptor( Type.VOID_TYPE,
-// new Type[]{Type.getType( Class.class ), Type.getType( String.class )} ) );
-// final Label l1 = new Label();
-// mv.visitLabel( l1 );
-// mv.visitInsn( Opcodes.RETURN );
-// final Label l2 = new Label();
-// mv.visitLabel( l2 );
-// mv.visitLocalVariable( "this",
-// "L" + className + ";",
-// null,
-// l0,
-// l2,
-// 0 );
-// mv.visitLocalVariable( "clazz",
-// Type.getDescriptor( Class.class ),
-// null,
-// l0,
-// l2,
-// 1 );
-// mv.visitLocalVariable( "fieldName",
-// Type.getDescriptor( String.class ),
-// null,
-// l0,
-// l2,
-// 2 );
-// mv.visitMaxs( 0,
-// 0 );
-// mv.visitEnd();
-// }
-// }
+ // /**
+ // * Creates a constructor for the field extractor receiving
+ // * the class instance and field name
+ // *
+ // * @param originalClassName
+ // * @param className
+ // * @param cw
+ // */
+ // private static void buildConstructor(final Class superClazz,
+ // final String className,
+ // final ClassWriter cw) {
+ // MethodVisitor mv;
+ // {
+ // mv = cw.visitMethod( Opcodes.ACC_PUBLIC,
+ // "<init>",
+ // Type.getMethodDescriptor( Type.VOID_TYPE,
+ // new Type[]{Type.getType( Class.class ), Type.getType( String.class )} ),
+ // null,
+ // null );
+ // mv.visitCode();
+ // final Label l0 = new Label();
+ // mv.visitLabel( l0 );
+ // mv.visitVarInsn( Opcodes.ALOAD,
+ // 0 );
+ // mv.visitVarInsn( Opcodes.ALOAD,
+ // 1 );
+ // mv.visitVarInsn( Opcodes.ALOAD,
+ // 2 );
+ // mv.visitMethodInsn( Opcodes.INVOKESPECIAL,
+ // Type.getInternalName( superClazz ),
+ // "<init>",
+ // Type.getMethodDescriptor( Type.VOID_TYPE,
+ // new Type[]{Type.getType( Class.class ), Type.getType( String.class )} ) );
+ // final Label l1 = new Label();
+ // mv.visitLabel( l1 );
+ // mv.visitInsn( Opcodes.RETURN );
+ // final Label l2 = new Label();
+ // mv.visitLabel( l2 );
+ // mv.visitLocalVariable( "this",
+ // "L" + className + ";",
+ // null,
+ // l0,
+ // l2,
+ // 0 );
+ // mv.visitLocalVariable( "clazz",
+ // Type.getDescriptor( Class.class ),
+ // null,
+ // l0,
+ // l2,
+ // 1 );
+ // mv.visitLocalVariable( "fieldName",
+ // Type.getDescriptor( String.class ),
+ // null,
+ // l0,
+ // l2,
+ // 2 );
+ // mv.visitMaxs( 0,
+ // 0 );
+ // mv.visitEnd();
+ // }
+ // }
/**
* Creates a constructor for the field extractor receiving
@@ -435,7 +435,7 @@
public Class defineClass(final String name,
final byte[] bytes,
- ProtectionDomain domain) {
+ final ProtectionDomain domain) {
return defineClass( name,
bytes,
0,
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/ClassObjectType.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -104,9 +104,9 @@
*/
private void setDelegateFieldObject() {
try {
- delegate = this.shadowClass.getDeclaredField( ShadowProxyFactory.DELEGATE_FIELD_NAME );
- delegate.setAccessible( true );
- } catch ( Exception e ) {
+ this.delegate = this.shadowClass.getDeclaredField( ShadowProxyFactory.DELEGATE_FIELD_NAME );
+ this.delegate.setAccessible( true );
+ } catch ( final Exception e ) {
throw new RuntimeDroolsException( "Error retriving delegate field for shadow proxy class: " + this.shadowClass.getName(),
e );
}
@@ -151,14 +151,14 @@
ShadowProxy proxy = null;
if ( isShadowEnabled() ) {
try {
- if ( delegate == null ) {
+ if ( this.delegate == null ) {
this.setDelegateFieldObject();
}
- if ( instantiator == null ) {
+ if ( this.instantiator == null ) {
this.setInstantiator();
}
proxy = (ShadowProxy) this.instantiator.newInstance();
- delegate.set( proxy,
+ this.delegate.set( proxy,
fact );
} catch ( final Exception e ) {
throw new RuntimeDroolsException( "Error creating shadow fact for object: " + fact,
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/DefaultKnowledgeHelper.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -35,7 +35,7 @@
implements
KnowledgeHelper {
- private static final long serialVersionUID = 3692991484157215686L;
+ private static final long serialVersionUID = 3692991484157215686L;
private Rule rule;
private GroupElement subrule;
@@ -90,7 +90,7 @@
this.activation );
}
- public void modifyObject(FactHandle handle,
+ public void modifyObject(final FactHandle handle,
final Object newObject) throws FactException {
// only modify if this fact exists in the wm
this.workingMemory.modifyObject( handle,
@@ -158,8 +158,8 @@
public void setFocus(final AgendaGroup focus) {
this.workingMemory.setFocus( focus );
}
-
- public Declaration getDeclaration( String identifier ) {
+
+ public Declaration getDeclaration(final String identifier) {
return (Declaration) this.subrule.getOuterDeclarations().get( identifier );
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/DelegateJavaFactHandler.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/DelegateJavaFactHandler.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/DelegateJavaFactHandler.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -17,31 +17,31 @@
if ( workingMemory == null ) {
return false;
}
-
- if (isRegistered( workingMemory ) ) {
+
+ if ( isRegistered( workingMemory ) ) {
return false;
}
-
+
final JavaFactRegistryEntry[] newEntries;
int position;
if ( this.entries == null ) {
newEntries = new JavaFactRegistryEntry[1];
position = 0;
- } else {
- int newLength = this.entries.length + 1;
- newEntries = new JavaFactRegistryEntry[ newLength ];
+ } else {
+ final int newLength = this.entries.length + 1;
+ newEntries = new JavaFactRegistryEntry[newLength];
System.arraycopy( this.entries,
0,
newEntries,
0,
newLength - 1 );
- position = this.entries.length;
+ position = this.entries.length;
}
final FactHandle handle = workingMemory.assertObject( this );
newEntries[position] = new JavaFactRegistryEntry( workingMemory,
- handle );
+ handle );
this.entries = newEntries;
return true;
@@ -60,53 +60,51 @@
if ( this.entries == null ) {
return false;
}
-
// If there is only one entry, see if it matched and if so null
if ( this.entries.length == 1 && this.entries[0].getWorkingMemory() == workingMemory ) {
this.entries = null;
return true;
}
-
// try the first
if ( this.entries[0].getWorkingMemory() == workingMemory ) {
- final JavaFactRegistryEntry[] newEntries = new JavaFactRegistryEntry[this.entries.length - 1];
+ final JavaFactRegistryEntry[] newEntries = new JavaFactRegistryEntry[this.entries.length - 1];
System.arraycopy( this.entries,
1,
newEntries,
0,
- newEntries.length );
+ newEntries.length );
this.entries = newEntries;
return true;
}
-
+
// try the last
- if ( this.entries[this.entries.length-1].getWorkingMemory() == workingMemory ) {
- final JavaFactRegistryEntry[] newEntries = new JavaFactRegistryEntry[this.entries.length - 1];
+ if ( this.entries[this.entries.length - 1].getWorkingMemory() == workingMemory ) {
+ final JavaFactRegistryEntry[] newEntries = new JavaFactRegistryEntry[this.entries.length - 1];
System.arraycopy( this.entries,
0,
newEntries,
0,
- newEntries.length );
+ newEntries.length );
this.entries = newEntries;
- return true;
+ return true;
}
-
+
// try middle
for ( int i = 0, length = this.entries.length; i < length; i++ ) {
- if ( this.entries[i].getWorkingMemory() == workingMemory ) {
- final JavaFactRegistryEntry[] newEntries = new JavaFactRegistryEntry[this.entries.length - 1];
+ if ( this.entries[i].getWorkingMemory() == workingMemory ) {
+ final JavaFactRegistryEntry[] newEntries = new JavaFactRegistryEntry[this.entries.length - 1];
System.arraycopy( this.entries,
0,
newEntries,
0,
- i );
+ i );
System.arraycopy( this.entries,
- i+1,
+ i + 1,
newEntries,
i,
- newEntries.length -1 );
+ newEntries.length - 1 );
this.entries = newEntries;
return true;
}
@@ -118,9 +116,9 @@
if ( this.entries == null ) {
return false;
}
-
+
for ( int i = 0, length = this.entries.length; i < length; i++ ) {
- if ( this.entries[i].getWorkingMemory() == workingMemory ) {
+ if ( this.entries[i].getWorkingMemory() == workingMemory ) {
return true;
}
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/FieldFactory.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -106,21 +106,21 @@
if ( valueType == ValueType.NULL_TYPE ) {
field = new ObjectFieldImpl( null );
} else if ( valueType == ValueType.PCHAR_TYPE ) {
- field = new LongFieldImpl( ((Character)value).charValue() );
+ field = new LongFieldImpl( ((Character) value).charValue() );
} else if ( valueType == ValueType.PBYTE_TYPE ) {
- field = new LongFieldImpl( ((Number)value).byteValue() );
+ field = new LongFieldImpl( ((Number) value).byteValue() );
} else if ( valueType == ValueType.PSHORT_TYPE ) {
- field = new LongFieldImpl( ((Number)value).shortValue() );
+ field = new LongFieldImpl( ((Number) value).shortValue() );
} else if ( valueType == ValueType.PINTEGER_TYPE ) {
- field = new LongFieldImpl( ((Number)value).intValue() );
+ field = new LongFieldImpl( ((Number) value).intValue() );
} else if ( valueType == ValueType.PLONG_TYPE ) {
- field = new LongFieldImpl( ((Number)value).longValue() );
+ field = new LongFieldImpl( ((Number) value).longValue() );
} else if ( valueType == ValueType.PFLOAT_TYPE ) {
- field = new DoubleFieldImpl( ((Number)value).floatValue() );
+ field = new DoubleFieldImpl( ((Number) value).floatValue() );
} else if ( valueType == ValueType.PDOUBLE_TYPE ) {
- field = new DoubleFieldImpl( ((Number)value).doubleValue() );
+ field = new DoubleFieldImpl( ((Number) value).doubleValue() );
} else if ( valueType == ValueType.PBOOLEAN_TYPE ) {
- field = new BooleanFieldImpl( ((Boolean)value).booleanValue() );
+ field = new BooleanFieldImpl( ((Boolean) value).booleanValue() );
} else if ( valueType == ValueType.CHAR_TYPE ) {
field = new ObjectFieldImpl( value );
} else if ( valueType == ValueType.BYTE_TYPE ) {
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/ShadowProxy.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -22,7 +22,7 @@
public interface ShadowProxy {
public void updateProxy();
-
+
public Object getShadowedObject();
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/ShadowProxyFactory.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -36,25 +36,25 @@
* 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 );
+ private static final String BASE_INTERFACE = Type.getInternalName( ShadowProxy.class );
//private static final String FIELD_NAME_PREFIX = "__";
- public static final String FIELD_SET_FLAG = "IsSet";
+ public static final String FIELD_SET_FLAG = "IsSet";
- public static final String DELEGATE_FIELD_NAME = "delegate";
+ public static final String DELEGATE_FIELD_NAME = "delegate";
- public static final String HASHCACHE_FIELD_NAME = "__hashCache";
+ public static final String HASHCACHE_FIELD_NAME = "__hashCache";
public static Class getProxy(final Class clazz) {
try {
- if(( clazz.getModifiers() & Modifier.FINAL ) != 0 ) {
+ if ( (clazz.getModifiers() & Modifier.FINAL) != 0 ) {
return null;
}
- String className = getInternalProxyClassNameForClass( clazz );
+ final String className = getInternalProxyClassNameForClass( clazz );
// generating byte array to create target class
final byte[] bytes = dump( clazz,
className );
@@ -71,11 +71,11 @@
public static byte[] getProxyBytes(final Class clazz) {
try {
- if(( clazz.getModifiers() & Modifier.FINAL ) != 0 ) {
+ if ( (clazz.getModifiers() & Modifier.FINAL) != 0 ) {
return null;
}
- String className = getInternalProxyClassNameForClass( clazz );
+ final String className = getInternalProxyClassNameForClass( clazz );
// generating byte array to create target class
final byte[] bytes = dump( clazz,
className );
@@ -104,7 +104,7 @@
if ( clazz.getPackage().getName().startsWith( "java." ) || clazz.getPackage().getName().startsWith( "javax." ) ) {
className = "org.drools.shadow." + clazz.getName() + "ShadowProxy";
} else {
- className = clazz.getName() + "ShadowProxy";
+ className = clazz.getName() + "ShadowProxy";
}
return className;
}
@@ -122,7 +122,7 @@
Type.getDescriptor( clazz ),
cw );
- Method getShadowed = ShadowProxy.class.getDeclaredMethod( "getShadowedObject",
+ final Method getShadowed = ShadowProxy.class.getDeclaredMethod( "getShadowedObject",
new Class[]{} );
buildSimpleGetMethod( ShadowProxyFactory.DELEGATE_FIELD_NAME,
clazz,
@@ -134,7 +134,7 @@
final Map fieldTypes = new HashMap();
final Method[] methods = getMethods( clazz );
for ( int i = 0; i < methods.length; i++ ) {
- if ( (!Modifier.isFinal( methods[i].getModifiers() )) && Modifier.isPublic( methods[i].getModifiers() ) && (! Modifier.isStatic( methods[i].getModifiers()) ) ) {
+ if ( (!Modifier.isFinal( methods[i].getModifiers() )) && Modifier.isPublic( methods[i].getModifiers() ) && (!Modifier.isStatic( methods[i].getModifiers() )) ) {
if ( (!methods[i].getReturnType().equals( Void.TYPE )) && (methods[i].getParameterTypes().length == 0) && (!methods[i].getName().equals( "hashCode" )) && (!methods[i].getName().equals( "toString" )) ) {
final String fieldName = methods[i].getName();
@@ -176,11 +176,10 @@
className,
clazz,
fieldTypes );
-
-
+
buildField( ShadowProxyFactory.HASHCACHE_FIELD_NAME,
- Type.getDescriptor( int.class ),
- cw );
+ Type.getDescriptor( int.class ),
+ cw );
buildHashCode( cw,
className,
@@ -198,27 +197,28 @@
private static Method[] getMethods(final Class clazz) {
// to help filtering process, we will create a map of maps:
// Map< String methodName, Map< Class[] parameterTypes, Method method > >
- Map map = new HashMap();
- List helperList = new ArrayList();
+ final Map map = new HashMap();
+ final List helperList = new ArrayList();
final Method[] methods = clazz.getMethods();
- for( int i = 0; i < methods.length; i++ ) {
- Method previous = null;
+ for ( int i = 0; i < methods.length; i++ ) {
+ Method previous = null;
Map signatures = (Map) map.get( methods[i].getName() );
- ParametersWrapper key = new ParametersWrapper( methods[i].getParameterTypes() );
- if( signatures != null ) {
+ final ParametersWrapper key = new ParametersWrapper( methods[i].getParameterTypes() );
+ if ( signatures != null ) {
previous = (Method) signatures.get( key );
}
// if no previous method with the same name and parameter types is found
// or if the previous method's return type is a super class of the
// current method's return type, add current to the map
// overriding previous if it exists
- if( ( previous == null ) ||
- ( previous.getReturnType().isAssignableFrom( methods[i].getReturnType() ) ) ) {
- if( signatures == null ) {
+ if ( (previous == null) || (previous.getReturnType().isAssignableFrom( methods[i].getReturnType() )) ) {
+ if ( signatures == null ) {
signatures = new HashMap();
- map.put( methods[i].getName(), signatures );
+ map.put( methods[i].getName(),
+ signatures );
}
- if( signatures.put( key, methods[i] ) != null ) {
+ if ( signatures.put( key,
+ methods[i] ) != null ) {
helperList.remove( previous );
}
helperList.add( methods[i] );
@@ -226,29 +226,30 @@
}
return (Method[]) helperList.toArray( new Method[helperList.size()] );
}
-
+
private static class ParametersWrapper {
private Class[] parameters;
- public ParametersWrapper( Class[] parameters ) {
+
+ public ParametersWrapper(final Class[] parameters) {
this.parameters = parameters;
}
-
+
public int hashCode() {
return this.parameters.length;
}
-
- public boolean equals( Object o ) {
- if( !( o instanceof ParametersWrapper ) ) {
+
+ public boolean equals(final Object o) {
+ if ( !(o instanceof ParametersWrapper) ) {
return false;
}
- ParametersWrapper other = (ParametersWrapper) o;
-
- if( this.parameters.length != other.parameters.length ) {
+ final ParametersWrapper other = (ParametersWrapper) o;
+
+ if ( this.parameters.length != other.parameters.length ) {
return false;
}
-
- for( int i = 0; i < this.parameters.length; i++ ) {
- if( ! this.parameters[i].equals( other.parameters[i] )) {
+
+ for ( int i = 0; i < this.parameters.length; i++ ) {
+ if ( !this.parameters[i].equals( other.parameters[i] ) ) {
return false;
}
}
@@ -462,14 +463,15 @@
className,
fieldName,
Type.getDescriptor( fieldType ) );
-
+
// this.__hashCache = 0;
- mv.visitVarInsn(Opcodes.ALOAD, 0);
- mv.visitInsn(Opcodes.ICONST_0);
- mv.visitFieldInsn(Opcodes.PUTFIELD,
- className,
- ShadowProxyFactory.HASHCACHE_FIELD_NAME,
- Type.getDescriptor( int.class ));
+ mv.visitVarInsn( Opcodes.ALOAD,
+ 0 );
+ mv.visitInsn( Opcodes.ICONST_0 );
+ mv.visitFieldInsn( Opcodes.PUTFIELD,
+ className,
+ ShadowProxyFactory.HASHCACHE_FIELD_NAME,
+ Type.getDescriptor( int.class ) );
// }
// return __field;
@@ -512,7 +514,7 @@
final ClassWriter cw) {
final Class[] exceptionTypes = method.getExceptionTypes();
- String[] exceptions = getExceptionArrayAsString( exceptionTypes );
+ final String[] exceptions = getExceptionArrayAsString( exceptionTypes );
// method signature
final MethodVisitor mv = cw.visitMethod( Opcodes.ACC_PUBLIC,
method.getName(),
@@ -562,7 +564,7 @@
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) ((Method) entry.getValue()).getReturnType();
+ final Class fieldType = ((Method) entry.getValue()).getReturnType();
final Label l1 = new Label();
mv.visitLabel( l1 );
mv.visitVarInsn( Opcodes.ALOAD,
@@ -596,13 +598,14 @@
}
// this.__hashCache = 0;
- mv.visitVarInsn(Opcodes.ALOAD, 0);
- mv.visitInsn(Opcodes.ICONST_0);
- mv.visitFieldInsn(Opcodes.PUTFIELD,
- className,
- ShadowProxyFactory.HASHCACHE_FIELD_NAME,
- Type.getDescriptor( int.class ));
-
+ mv.visitVarInsn( Opcodes.ALOAD,
+ 0 );
+ mv.visitInsn( Opcodes.ICONST_0 );
+ mv.visitFieldInsn( Opcodes.PUTFIELD,
+ className,
+ ShadowProxyFactory.HASHCACHE_FIELD_NAME,
+ Type.getDescriptor( int.class ) );
+
final Label l4 = new Label();
mv.visitLabel( l4 );
mv.visitInsn( Opcodes.RETURN );
@@ -674,10 +677,10 @@
mv.visitEnd();
}
- protected static void buildEquals(ClassWriter cw,
- String className,
- final Class clazz,
- Map fieldTypes) {
+ protected static void buildEquals(final ClassWriter cw,
+ final String className,
+ final Class clazz,
+ final Map fieldTypes) {
MethodVisitor mv;
// Building equals method
{
@@ -688,7 +691,7 @@
null,
null );
mv.visitCode();
- Label l0 = new Label();
+ final Label l0 = new Label();
mv.visitLabel( l0 );
// if ( this == object )
@@ -696,7 +699,7 @@
0 );
mv.visitVarInsn( Opcodes.ALOAD,
1 );
- Label l1 = new Label();
+ final Label l1 = new Label();
mv.visitJumpInsn( Opcodes.IF_ACMPNE,
l1 );
// return true;
@@ -707,14 +710,14 @@
mv.visitLabel( l1 );
mv.visitVarInsn( Opcodes.ALOAD,
1 );
- Label l3 = new Label();
+ final Label l3 = new Label();
mv.visitJumpInsn( Opcodes.IFNULL,
l3 );
mv.visitVarInsn( Opcodes.ALOAD,
1 );
mv.visitTypeInsn( Opcodes.INSTANCEOF,
Type.getInternalName( clazz ) );
- Label l4 = new Label();
+ final Label l4 = new Label();
mv.visitJumpInsn( Opcodes.IFNE,
l4 );
@@ -734,14 +737,14 @@
// for each field:
int count = 0;
- for ( Iterator it = fieldTypes.entrySet().iterator(); it.hasNext(); ) {
- Map.Entry entry = (Map.Entry) it.next();
- String fieldName = (String) entry.getKey();
- Method method = (Method) entry.getValue();
- Class fieldType = method.getReturnType();
- String fieldFlag = fieldName + ShadowProxyFactory.FIELD_SET_FLAG;
+ for ( final Iterator it = fieldTypes.entrySet().iterator(); it.hasNext(); ) {
+ final Map.Entry entry = (Map.Entry) it.next();
+ final String fieldName = (String) entry.getKey();
+ final Method method = (Method) entry.getValue();
+ final Class fieldType = method.getReturnType();
+ final String fieldFlag = fieldName + ShadowProxyFactory.FIELD_SET_FLAG;
count++;
- Label goNext = new Label();
+ final Label goNext = new Label();
// if ( ! _fieldIsSet ) {
final Label l5 = new Label();
@@ -848,7 +851,7 @@
className,
fieldName,
Type.getDescriptor( fieldType ) );
- Label secondIfPart = new Label();
+ final Label secondIfPart = new Label();
mv.visitJumpInsn( Opcodes.IFNONNULL,
secondIfPart );
mv.visitVarInsn( Opcodes.ALOAD,
@@ -864,7 +867,7 @@
method.getName(),
Type.getMethodDescriptor( method ) );
}
- Label returnFalse = new Label();
+ final Label returnFalse = new Label();
mv.visitJumpInsn( Opcodes.IFNONNULL,
returnFalse );
mv.visitLabel( secondIfPart );
@@ -927,7 +930,7 @@
mv.visitInsn( Opcodes.ICONST_0 );
}
mv.visitInsn( Opcodes.IRETURN );
- Label lastLabel = new Label();
+ final Label lastLabel = new Label();
mv.visitLabel( lastLabel );
mv.visitLocalVariable( "this",
@@ -981,10 +984,10 @@
* @param clazz
* @param fieldTypes
*/
- protected static void buildHashCode(ClassWriter cw,
- String className,
- final Class clazz,
- Map fieldTypes) {
+ protected static void buildHashCode(final ClassWriter cw,
+ final String className,
+ final Class clazz,
+ final Map fieldTypes) {
MethodVisitor mv;
boolean hasDoubleAttr = false;
// Building hashcode method
@@ -998,28 +1001,30 @@
mv.visitCode();
// if( __hashCache != 0 ) {
- Label ls = new Label();
- mv.visitLabel(ls);
- mv.visitVarInsn(Opcodes.ALOAD, 0);
- mv.visitFieldInsn(Opcodes.GETFIELD,
- className,
- ShadowProxyFactory.HASHCACHE_FIELD_NAME,
- Type.getDescriptor( int.class ));
- Label afterIfCachedLabel = new Label();
- mv.visitJumpInsn(Opcodes.IFEQ, afterIfCachedLabel);
+ final Label ls = new Label();
+ mv.visitLabel( ls );
+ mv.visitVarInsn( Opcodes.ALOAD,
+ 0 );
+ mv.visitFieldInsn( Opcodes.GETFIELD,
+ className,
+ ShadowProxyFactory.HASHCACHE_FIELD_NAME,
+ Type.getDescriptor( int.class ) );
+ final Label afterIfCachedLabel = new Label();
+ mv.visitJumpInsn( Opcodes.IFEQ,
+ afterIfCachedLabel );
// return __hashCache;
// }
- mv.visitVarInsn(Opcodes.ALOAD, 0);
- mv.visitFieldInsn(Opcodes.GETFIELD,
- className,
- ShadowProxyFactory.HASHCACHE_FIELD_NAME,
- Type.getDescriptor( int.class ));
- mv.visitInsn(Opcodes.IRETURN);
- mv.visitLabel(afterIfCachedLabel);
-
-
+ mv.visitVarInsn( Opcodes.ALOAD,
+ 0 );
+ mv.visitFieldInsn( Opcodes.GETFIELD,
+ className,
+ ShadowProxyFactory.HASHCACHE_FIELD_NAME,
+ Type.getDescriptor( int.class ) );
+ mv.visitInsn( Opcodes.IRETURN );
+ mv.visitLabel( afterIfCachedLabel );
+
// final int PRIME = 31;
- Label l0 = new Label();
+ final Label l0 = new Label();
mv.visitLabel( l0 );
mv.visitIntInsn( Opcodes.BIPUSH,
31 );
@@ -1027,7 +1032,7 @@
1 );
// int result = 1;
- Label l1 = new Label();
+ final Label l1 = new Label();
mv.visitLabel( l1 );
mv.visitInsn( Opcodes.ICONST_1 );
mv.visitVarInsn( Opcodes.ISTORE,
@@ -1035,14 +1040,14 @@
// for each field:
int count = 0;
- for ( Iterator it = fieldTypes.entrySet().iterator(); it.hasNext(); ) {
- Map.Entry entry = (Map.Entry) it.next();
- String fieldName = (String) entry.getKey();
- Method method = (Method) entry.getValue();
- Class fieldType = method.getReturnType();
- String fieldFlag = fieldName + ShadowProxyFactory.FIELD_SET_FLAG;
+ for ( final Iterator it = fieldTypes.entrySet().iterator(); it.hasNext(); ) {
+ final Map.Entry entry = (Map.Entry) it.next();
+ final String fieldName = (String) entry.getKey();
+ final Method method = (Method) entry.getValue();
+ final Class fieldType = method.getReturnType();
+ final String fieldFlag = fieldName + ShadowProxyFactory.FIELD_SET_FLAG;
count++;
- Label goNext = new Label();
+ final Label goNext = new Label();
// if ( ! _fieldIsSet ) {
final Label l5 = new Label();
@@ -1101,7 +1106,7 @@
if ( fieldType.isPrimitive() ) {
// for primitive types
// result = PRIME * result + <att hashcode>
- Label l2 = new Label();
+ final Label l2 = new Label();
if ( fieldType == Double.TYPE ) {
hasDoubleAttr = true;
mv.visitVarInsn( Opcodes.ALOAD,
@@ -1136,12 +1141,12 @@
if ( fieldType == Boolean.TYPE ) {
// att_hashcode ::= ( boolean_attribute ) ? 1231 : 1237;
- Label z1 = new Label();
+ final Label z1 = new Label();
mv.visitJumpInsn( Opcodes.IFEQ,
z1 );
mv.visitIntInsn( Opcodes.SIPUSH,
1231 );
- Label z2 = new Label();
+ final Label z2 = new Label();
mv.visitJumpInsn( Opcodes.GOTO,
z2 );
mv.visitLabel( z1 );
@@ -1151,7 +1156,7 @@
} else if ( fieldType == Double.TYPE ) {
// long temp = Double.doubleToLongBits( doubleAttr );
// att_hashcode ::= (int) (temp ^ ( temp >>> 32 ) );
- Label d1 = new Label();
+ final Label d1 = new Label();
mv.visitLabel( d1 );
mv.visitVarInsn( Opcodes.LLOAD,
3 );
@@ -1191,7 +1196,7 @@
} else {
// for non primitive types
// result = PRIME * result + <att hashcode>
- Label l2 = new Label();
+ final Label l2 = new Label();
mv.visitLabel( l2 );
mv.visitIntInsn( Opcodes.BIPUSH,
31 );
@@ -1206,11 +1211,11 @@
fieldName,
Type.getDescriptor( fieldType ) );
- Label np1 = new Label();
+ final Label np1 = new Label();
mv.visitJumpInsn( Opcodes.IFNONNULL,
np1 );
mv.visitInsn( Opcodes.ICONST_0 );
- Label np2 = new Label();
+ final Label np2 = new Label();
mv.visitJumpInsn( Opcodes.GOTO,
np2 );
mv.visitLabel( np1 );
@@ -1238,20 +1243,22 @@
}
mv.visitLabel( goNext );
}
-
+
// __hashCache = result;
- mv.visitVarInsn(Opcodes.ALOAD, 0);
- mv.visitVarInsn(Opcodes.ILOAD, 2);
- mv.visitFieldInsn(Opcodes.PUTFIELD,
- className,
- ShadowProxyFactory.HASHCACHE_FIELD_NAME,
- Type.getDescriptor( int.class ));
-
+ mv.visitVarInsn( Opcodes.ALOAD,
+ 0 );
+ mv.visitVarInsn( Opcodes.ILOAD,
+ 2 );
+ mv.visitFieldInsn( Opcodes.PUTFIELD,
+ className,
+ ShadowProxyFactory.HASHCACHE_FIELD_NAME,
+ Type.getDescriptor( int.class ) );
+
// return result;
mv.visitVarInsn( Opcodes.ILOAD,
2 );
mv.visitInsn( Opcodes.IRETURN );
- Label lastLabel = new Label();
+ final Label lastLabel = new Label();
mv.visitLabel( lastLabel );
mv.visitLocalVariable( "this",
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/ShadowProxyHelper.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/ShadowProxyHelper.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/ShadowProxyHelper.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -27,30 +27,32 @@
*/
public class ShadowProxyHelper {
- public static void copyState(ShadowProxy from,
- ShadowProxy to) {
- Field[] fields = from.getClass().getDeclaredFields();
+ public static void copyState(final ShadowProxy from,
+ final ShadowProxy to) {
+ final Field[] fields = from.getClass().getDeclaredFields();
for ( int i = 0; i < fields.length; i++ ) {
if ( fields[i].getName().endsWith( ShadowProxyFactory.FIELD_SET_FLAG ) ) {
fields[i].setAccessible( true );
try {
if ( fields[i].getBoolean( from ) ) {
- String fieldName = fields[i].getName().substring( 0,
+ final String fieldName = fields[i].getName().substring( 0,
fields[i].getName().length() - ShadowProxyFactory.FIELD_SET_FLAG.length() );
- Field flag = to.getClass().getDeclaredField( fields[i].getName() );
- Field fieldFrom = from.getClass().getDeclaredField( fieldName );
- Field fieldTo = to.getClass().getDeclaredField( fieldName );
+ final Field flag = to.getClass().getDeclaredField( fields[i].getName() );
+ final Field fieldFrom = from.getClass().getDeclaredField( fieldName );
+ final Field fieldTo = to.getClass().getDeclaredField( fieldName );
flag.setAccessible( true );
fieldFrom.setAccessible( true );
fieldTo.setAccessible( true );
-
+
// we know it is set
- flag.setBoolean( to, true );
+ flag.setBoolean( to,
+ true );
// copy the value from "from" shadow proxy
- fieldTo.set( to, fieldFrom.get( from ) );
+ fieldTo.set( to,
+ fieldFrom.get( from ) );
}
- } catch ( Exception e ) {
- throw new RuntimeDroolsException("Unable to copy state from one shadow proxy to another");
+ } catch ( final Exception e ) {
+ throw new RuntimeDroolsException( "Unable to copy state from one shadow proxy to another" );
}
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/ValueType.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -144,7 +144,7 @@
this.classType = classType;
this.simpleType = simpleType;
this.evaluatorFactory = evaluatorFactory;
- }
+ }
private Object readResolve() throws java.io.ObjectStreamException {
return determineValueType( this.classType );
@@ -152,12 +152,12 @@
public String getName() {
return this.name;
- }
+ }
public Class getClassType() {
return this.classType;
}
-
+
public int getSimpleType() {
return this.simpleType;
}
@@ -243,43 +243,43 @@
}
public boolean isNumber() {
- return ( this.simpleType == SimpleValueType.INTEGER || this.simpleType == SimpleValueType.DECIMAL || this.simpleType == SimpleValueType.CHAR );
-// return (this.classType == Integer.TYPE) ||
-// (this.classType == Long.TYPE) ||
-// (this.classType == Float.TYPE) ||
-// (this.classType == Double.TYPE) ||
-// (this.classType == Byte.TYPE) ||
-// (this.classType == Short.TYPE) ||
-// (this.classType == Character.TYPE) ||
-// (this.classType == Character.class) ||
-// (Number.class.isAssignableFrom( this.classType ));
+ return (this.simpleType == SimpleValueType.INTEGER || this.simpleType == SimpleValueType.DECIMAL || this.simpleType == SimpleValueType.CHAR);
+ // return (this.classType == Integer.TYPE) ||
+ // (this.classType == Long.TYPE) ||
+ // (this.classType == Float.TYPE) ||
+ // (this.classType == Double.TYPE) ||
+ // (this.classType == Byte.TYPE) ||
+ // (this.classType == Short.TYPE) ||
+ // (this.classType == Character.TYPE) ||
+ // (this.classType == Character.class) ||
+ // (Number.class.isAssignableFrom( this.classType ));
}
public boolean isIntegerNumber() {
return this.simpleType == SimpleValueType.INTEGER;
-// return (this.classType == Integer.TYPE) ||
-// (this.classType == Long.TYPE) ||
-// (this.classType == Integer.class) ||
-// (this.classType == Long.class) ||
-// (this.classType == Character.class) ||
-// (this.classType == Character.TYPE) ||
-// (this.classType == Byte.TYPE) ||
-// (this.classType == Short.TYPE) ||
-// (this.classType == Byte.class) ||
-// (this.classType == Short.class);
+ // return (this.classType == Integer.TYPE) ||
+ // (this.classType == Long.TYPE) ||
+ // (this.classType == Integer.class) ||
+ // (this.classType == Long.class) ||
+ // (this.classType == Character.class) ||
+ // (this.classType == Character.TYPE) ||
+ // (this.classType == Byte.TYPE) ||
+ // (this.classType == Short.TYPE) ||
+ // (this.classType == Byte.class) ||
+ // (this.classType == Short.class);
}
public boolean isFloatNumber() {
return this.simpleType == SimpleValueType.DECIMAL;
-// return (this.classType == Float.TYPE) ||
-// (this.classType == Double.TYPE) ||
-// (this.classType == Float.class) ||
-// (this.classType == Double.class);
+ // return (this.classType == Float.TYPE) ||
+ // (this.classType == Double.TYPE) ||
+ // (this.classType == Float.class) ||
+ // (this.classType == Double.class);
}
public boolean isChar() {
return this.simpleType == SimpleValueType.CHAR;
-// return ((this.classType == Character.class) || (this.classType == Character.TYPE));
+ // return ((this.classType == Character.class) || (this.classType == Character.TYPE));
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/dataproviders/MVELDataProvider.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/dataproviders/MVELDataProvider.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/dataproviders/MVELDataProvider.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -7,20 +7,17 @@
import org.drools.WorkingMemory;
import org.drools.base.mvel.DroolsMVELFactory;
-import org.drools.reteoo.ReteTuple;
import org.drools.rule.Declaration;
import org.drools.spi.DataProvider;
import org.drools.spi.PropagationContext;
import org.drools.spi.Tuple;
-import org.mvel.CompiledExpression;
-import org.mvel.ExpressionParser;
import org.mvel.MVEL;
public class MVELDataProvider
implements
DataProvider {
//private final Expr expression;
- private final Serializable expression;
+ private final Serializable expression;
private final DroolsMVELFactory factory;
public MVELDataProvider(final Serializable expression,
@@ -30,17 +27,20 @@
}
public Declaration[] getRequiredDeclarations() {
- return new Declaration[] {};
+ return new Declaration[]{};
//return factory.getRequiredDeclarations();
}
public Iterator getResults(final Tuple tuple,
final WorkingMemory wm,
final PropagationContext ctx) {
- factory.setContext( tuple, null, wm );
-
+ this.factory.setContext( tuple,
+ null,
+ wm );
+
//this.expression.
- Object result = MVEL.executeExpression(this.expression, factory);
+ final Object result = MVEL.executeExpression( this.expression,
+ this.factory );
if ( result instanceof Collection ) {
return ((Collection) result).iterator();
} else if ( result instanceof Iterator ) {
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/ArrayFactory.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -101,10 +101,10 @@
return ((ObjectVariableContextEntry) context).left.equals( value );
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
final Object value1 = extractor1.getValue( object1 );
final Object value2 = extractor2.getValue( object2 );
if ( value1 == null ) {
@@ -160,10 +160,10 @@
return !((ObjectVariableContextEntry) context).left.equals( value );
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
final Object value1 = extractor1.getValue( object1 );
final Object value2 = extractor2.getValue( object2 );
if ( value1 == null ) {
@@ -214,15 +214,15 @@
value ) != -1;
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
final Object value = extractor2.getValue( object2 );
final Object[] array = (Object[]) extractor1.getValue( object1 );
return Arrays.binarySearch( array,
- value ) != -1 ;
+ value ) != -1;
}
public String toString() {
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/BigDecimalFactory.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -103,10 +103,10 @@
return ((ObjectVariableContextEntry) context).left.equals( value );
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
final Object value1 = extractor1.getValue( object1 );
final Object value2 = extractor2.getValue( object2 );
if ( value1 == null ) {
@@ -162,10 +162,10 @@
return !((ObjectVariableContextEntry) context).left.equals( value );
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
final Object value1 = extractor1.getValue( object1 );
final Object value2 = extractor2.getValue( object2 );
if ( value1 == null ) {
@@ -195,29 +195,29 @@
final Object object1,
final FieldValue object2) {
final BigDecimal comp = (BigDecimal) extractor.getValue( object1 );
- return comp.compareTo( ( BigDecimal ) object2.getValue() ) < 0;
+ return comp.compareTo( (BigDecimal) object2.getValue() ) < 0;
}
public boolean evaluateCachedRight(final VariableContextEntry context,
final Object left) {
final BigDecimal comp = (BigDecimal) ((ObjectVariableContextEntry) context).right;
- return comp.compareTo( ( BigDecimal ) context.declaration.getExtractor().getValue( left ) ) < 0;
+ return comp.compareTo( (BigDecimal) context.declaration.getExtractor().getValue( left ) ) < 0;
}
public boolean evaluateCachedLeft(final VariableContextEntry context,
final Object right) {
final BigDecimal comp = (BigDecimal) context.extractor.getValue( right );
- return comp.compareTo( ( BigDecimal ) ((ObjectVariableContextEntry) context).left ) < 0;
+ return comp.compareTo( (BigDecimal) ((ObjectVariableContextEntry) context).left ) < 0;
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
final BigDecimal comp = (BigDecimal) extractor1.getValue( object1 );
- return comp.compareTo( ( BigDecimal ) extractor2.getValue( object2 ) ) < 0;
+ return comp.compareTo( (BigDecimal) extractor2.getValue( object2 ) ) < 0;
}
-
+
public String toString() {
return "BigDecimal <";
}
@@ -239,29 +239,29 @@
final Object object1,
final FieldValue object2) {
final BigDecimal comp = (BigDecimal) extractor.getValue( object1 );
- return comp.compareTo( ( BigDecimal ) object2.getValue() ) <= 0;
+ return comp.compareTo( (BigDecimal) object2.getValue() ) <= 0;
}
public boolean evaluateCachedRight(final VariableContextEntry context,
final Object left) {
final BigDecimal comp = (BigDecimal) ((ObjectVariableContextEntry) context).right;
- return comp.compareTo( ( BigDecimal ) context.declaration.getExtractor().getValue( left ) ) <= 0;
+ return comp.compareTo( (BigDecimal) context.declaration.getExtractor().getValue( left ) ) <= 0;
}
public boolean evaluateCachedLeft(final VariableContextEntry context,
final Object right) {
final BigDecimal comp = (BigDecimal) context.extractor.getValue( right );
- return comp.compareTo( ( BigDecimal ) ((ObjectVariableContextEntry) context).left ) <= 0;
+ return comp.compareTo( (BigDecimal) ((ObjectVariableContextEntry) context).left ) <= 0;
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
final BigDecimal comp = (BigDecimal) extractor1.getValue( object1 );
- return comp.compareTo( ( BigDecimal ) extractor2.getValue( object2 ) ) <= 0;
+ return comp.compareTo( (BigDecimal) extractor2.getValue( object2 ) ) <= 0;
}
-
+
public String toString() {
return "BigDecimal <=";
}
@@ -283,29 +283,29 @@
final Object object1,
final FieldValue object2) {
final BigDecimal comp = (BigDecimal) extractor.getValue( object1 );
- return comp.compareTo( ( BigDecimal ) object2.getValue() ) > 0;
+ return comp.compareTo( (BigDecimal) object2.getValue() ) > 0;
}
public boolean evaluateCachedRight(final VariableContextEntry context,
final Object left) {
final BigDecimal comp = (BigDecimal) ((ObjectVariableContextEntry) context).right;
- return comp.compareTo( ( BigDecimal ) context.declaration.getExtractor().getValue( left ) ) > 0;
+ return comp.compareTo( (BigDecimal) context.declaration.getExtractor().getValue( left ) ) > 0;
}
public boolean evaluateCachedLeft(final VariableContextEntry context,
final Object right) {
final BigDecimal comp = (BigDecimal) context.extractor.getValue( right );
- return comp.compareTo( ( BigDecimal ) ((ObjectVariableContextEntry) context).left ) > 0;
+ return comp.compareTo( (BigDecimal) ((ObjectVariableContextEntry) context).left ) > 0;
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
final BigDecimal comp = (BigDecimal) extractor1.getValue( object1 );
- return comp.compareTo( ( BigDecimal ) extractor2.getValue( object2 ) ) > 0;
+ return comp.compareTo( (BigDecimal) extractor2.getValue( object2 ) ) > 0;
}
-
+
public String toString() {
return "BigDecimal >";
}
@@ -327,29 +327,29 @@
final Object object1,
final FieldValue object2) {
final BigDecimal comp = (BigDecimal) extractor.getValue( object1 );
- return comp.compareTo( ( BigDecimal ) object2.getValue() ) >= 0;
+ return comp.compareTo( (BigDecimal) object2.getValue() ) >= 0;
}
public boolean evaluateCachedRight(final VariableContextEntry context,
final Object left) {
final BigDecimal comp = (BigDecimal) ((ObjectVariableContextEntry) context).right;
- return comp.compareTo( ( BigDecimal ) context.declaration.getExtractor().getValue( left ) ) >= 0;
+ return comp.compareTo( (BigDecimal) context.declaration.getExtractor().getValue( left ) ) >= 0;
}
public boolean evaluateCachedLeft(final VariableContextEntry context,
final Object right) {
final BigDecimal comp = (BigDecimal) context.extractor.getValue( right );
- return comp.compareTo( ( BigDecimal ) ((ObjectVariableContextEntry) context).left ) >= 0;
+ return comp.compareTo( (BigDecimal) ((ObjectVariableContextEntry) context).left ) >= 0;
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
final BigDecimal comp = (BigDecimal) extractor1.getValue( object1 );
- return comp.compareTo( ( BigDecimal ) extractor2.getValue( object2 ) ) >= 0;
+ return comp.compareTo( (BigDecimal) extractor2.getValue( object2 ) ) >= 0;
}
-
+
public String toString() {
return "BigDecimal >=";
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/BigIntegerFactory.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -103,10 +103,10 @@
return ((ObjectVariableContextEntry) context).left.equals( value );
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
final Object value1 = extractor1.getValue( object1 );
final Object value2 = extractor2.getValue( object2 );
if ( value1 == null ) {
@@ -114,7 +114,7 @@
}
return value1.equals( value2 );
}
-
+
public String toString() {
return "BigInteger ==";
}
@@ -161,10 +161,10 @@
return !((ObjectVariableContextEntry) context).left.equals( value );
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
final Object value1 = extractor1.getValue( object1 );
final Object value2 = extractor2.getValue( object2 );
if ( value1 == null ) {
@@ -172,7 +172,7 @@
}
return !value1.equals( value2 );
}
-
+
public String toString() {
return "BigInteger !=";
}
@@ -194,29 +194,29 @@
final Object object1,
final FieldValue object2) {
final BigInteger comp = (BigInteger) extractor.getValue( object1 );
- return comp.compareTo( ( BigInteger ) object2.getValue() ) < 0;
+ return comp.compareTo( (BigInteger) object2.getValue() ) < 0;
}
public boolean evaluateCachedRight(final VariableContextEntry context,
final Object left) {
final BigInteger comp = (BigInteger) ((ObjectVariableContextEntry) context).right;
- return comp.compareTo( ( BigInteger ) context.declaration.getExtractor().getValue( left ) ) < 0;
+ return comp.compareTo( (BigInteger) context.declaration.getExtractor().getValue( left ) ) < 0;
}
public boolean evaluateCachedLeft(final VariableContextEntry context,
final Object right) {
final BigInteger comp = (BigInteger) context.extractor.getValue( right );
- return comp.compareTo( ( BigInteger ) ((ObjectVariableContextEntry) context).left ) < 0;
+ return comp.compareTo( (BigInteger) ((ObjectVariableContextEntry) context).left ) < 0;
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
final BigInteger comp = (BigInteger) extractor1.getValue( object1 );
- return comp.compareTo( ( BigInteger ) extractor2.getValue( object2 ) ) < 0;
+ return comp.compareTo( (BigInteger) extractor2.getValue( object2 ) ) < 0;
}
-
+
public String toString() {
return "BigInteger <";
}
@@ -238,29 +238,29 @@
final Object object1,
final FieldValue object2) {
final BigInteger comp = (BigInteger) extractor.getValue( object1 );
- return comp.compareTo( ( BigInteger ) object2.getValue() ) <= 0;
+ return comp.compareTo( (BigInteger) object2.getValue() ) <= 0;
}
public boolean evaluateCachedRight(final VariableContextEntry context,
final Object left) {
final BigInteger comp = (BigInteger) ((ObjectVariableContextEntry) context).right;
- return comp.compareTo( ( BigInteger ) context.declaration.getExtractor().getValue( left ) ) <= 0;
+ return comp.compareTo( (BigInteger) context.declaration.getExtractor().getValue( left ) ) <= 0;
}
public boolean evaluateCachedLeft(final VariableContextEntry context,
final Object right) {
final BigInteger comp = (BigInteger) context.extractor.getValue( right );
- return comp.compareTo( ( BigInteger ) ((ObjectVariableContextEntry) context).left ) <= 0;
+ return comp.compareTo( (BigInteger) ((ObjectVariableContextEntry) context).left ) <= 0;
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
final BigInteger comp = (BigInteger) extractor1.getValue( object1 );
- return comp.compareTo( ( BigInteger ) extractor2.getValue( object2 ) ) <= 0;
+ return comp.compareTo( (BigInteger) extractor2.getValue( object2 ) ) <= 0;
}
-
+
public String toString() {
return "BigInteger <=";
}
@@ -282,29 +282,29 @@
final Object object1,
final FieldValue object2) {
final BigInteger comp = (BigInteger) extractor.getValue( object1 );
- return comp.compareTo( ( BigInteger ) object2.getValue() ) > 0;
+ return comp.compareTo( (BigInteger) object2.getValue() ) > 0;
}
public boolean evaluateCachedRight(final VariableContextEntry context,
final Object left) {
final BigInteger comp = (BigInteger) ((ObjectVariableContextEntry) context).right;
- return comp.compareTo( ( BigInteger ) context.declaration.getExtractor().getValue( left ) ) > 0;
+ return comp.compareTo( (BigInteger) context.declaration.getExtractor().getValue( left ) ) > 0;
}
public boolean evaluateCachedLeft(final VariableContextEntry context,
final Object right) {
final BigInteger comp = (BigInteger) context.extractor.getValue( right );
- return comp.compareTo( ( BigInteger ) ((ObjectVariableContextEntry) context).left ) > 0;
+ return comp.compareTo( (BigInteger) ((ObjectVariableContextEntry) context).left ) > 0;
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
final BigInteger comp = (BigInteger) extractor1.getValue( object1 );
- return comp.compareTo( ( BigInteger ) extractor2.getValue( object2 ) ) > 0;
+ return comp.compareTo( (BigInteger) extractor2.getValue( object2 ) ) > 0;
}
-
+
public String toString() {
return "BigInteger >";
}
@@ -326,29 +326,29 @@
final Object object1,
final FieldValue object2) {
final BigInteger comp = (BigInteger) extractor.getValue( object1 );
- return comp.compareTo( ( BigInteger ) object2.getValue() ) >= 0;
+ return comp.compareTo( (BigInteger) object2.getValue() ) >= 0;
}
public boolean evaluateCachedRight(final VariableContextEntry context,
final Object left) {
final BigInteger comp = (BigInteger) ((ObjectVariableContextEntry) context).right;
- return comp.compareTo( ( BigInteger ) context.declaration.getExtractor().getValue( left ) ) >= 0;
+ return comp.compareTo( (BigInteger) context.declaration.getExtractor().getValue( left ) ) >= 0;
}
public boolean evaluateCachedLeft(final VariableContextEntry context,
final Object right) {
final BigInteger comp = (BigInteger) context.extractor.getValue( right );
- return comp.compareTo( ( BigInteger ) ((ObjectVariableContextEntry) context).left ) >= 0;
+ return comp.compareTo( (BigInteger) ((ObjectVariableContextEntry) context).left ) >= 0;
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
final BigInteger comp = (BigInteger) extractor1.getValue( object1 );
- return comp.compareTo( ( BigInteger ) extractor2.getValue( object2 ) ) >= 0;
+ return comp.compareTo( (BigInteger) extractor2.getValue( object2 ) ) >= 0;
}
-
+
public String toString() {
return "BigInteger >=";
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/BooleanFactory.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -80,10 +80,10 @@
return context.extractor.getBooleanValue( object2 ) == ((BooleanVariableContextEntry) context).left;
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
return extractor1.getBooleanValue( object1 ) == extractor2.getBooleanValue( object2 );
}
@@ -121,10 +121,10 @@
return context.extractor.getBooleanValue( object2 ) != ((BooleanVariableContextEntry) context).left;
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
return extractor1.getBooleanValue( object1 ) != extractor1.getBooleanValue( object2 );
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/ByteFactory.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -88,10 +88,10 @@
return ((LongVariableContextEntry) context).left == context.extractor.getByteValue( right );
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
return extractor1.getByteValue( object1 ) == extractor2.getByteValue( object2 );
}
@@ -129,10 +129,10 @@
return ((LongVariableContextEntry) context).left != context.extractor.getByteValue( right );
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
return extractor1.getByteValue( object1 ) != extractor2.getByteValue( object2 );
}
@@ -161,7 +161,7 @@
public boolean evaluateCachedRight(final VariableContextEntry context,
final Object left) {
- return ((LongVariableContextEntry) context).right < context.declaration.getExtractor().getByteValue( left );
+ return ((LongVariableContextEntry) context).right < context.declaration.getExtractor().getByteValue( left );
}
public boolean evaluateCachedLeft(final VariableContextEntry context,
@@ -169,10 +169,10 @@
return context.extractor.getByteValue( right ) < ((LongVariableContextEntry) context).left;
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
return extractor1.getByteValue( object1 ) < extractor2.getByteValue( object2 );
}
@@ -209,10 +209,10 @@
return context.extractor.getByteValue( right ) <= ((LongVariableContextEntry) context).left;
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
return extractor1.getByteValue( object1 ) <= extractor2.getByteValue( object2 );
}
@@ -249,10 +249,10 @@
return context.extractor.getByteValue( right ) > ((LongVariableContextEntry) context).left;
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
return extractor1.getByteValue( object1 ) > extractor2.getByteValue( object2 );
}
@@ -289,10 +289,10 @@
return context.extractor.getByteValue( right ) >= ((LongVariableContextEntry) context).left;
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
return extractor1.getByteValue( object1 ) >= extractor2.getByteValue( object2 );
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/CharacterFactory.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -88,10 +88,10 @@
return ((LongVariableContextEntry) context).left == context.extractor.getCharValue( right );
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
return extractor1.getCharValue( object1 ) == extractor2.getCharValue( object2 );
}
@@ -128,10 +128,10 @@
return ((LongVariableContextEntry) context).left != context.extractor.getCharValue( right );
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
return extractor1.getCharValue( object1 ) != extractor2.getCharValue( object2 );
}
@@ -165,13 +165,13 @@
public boolean evaluateCachedLeft(final VariableContextEntry context,
final Object right) {
- return context.extractor.getCharValue( right ) <((LongVariableContextEntry) context).left;
+ return context.extractor.getCharValue( right ) < ((LongVariableContextEntry) context).left;
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
return extractor1.getCharValue( object1 ) < extractor2.getCharValue( object2 );
}
@@ -208,10 +208,10 @@
return context.extractor.getCharValue( right ) <= ((LongVariableContextEntry) context).left;
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
return extractor1.getCharValue( object1 ) <= extractor2.getCharValue( object2 );
}
@@ -248,10 +248,10 @@
return context.extractor.getCharValue( right ) > ((LongVariableContextEntry) context).left;
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
return extractor1.getCharValue( object1 ) > extractor2.getCharValue( object2 );
}
@@ -288,10 +288,10 @@
return context.extractor.getCharValue( right ) >= ((LongVariableContextEntry) context).left;
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
return extractor1.getCharValue( object1 ) >= extractor2.getCharValue( object2 );
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/DateFactory.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -131,10 +131,10 @@
return value1.compareTo( getRightDate( value2 ) ) == 0;
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
final Date value1 = (Date) extractor1.getValue( object1 );
final Date value2 = (Date) extractor2.getValue( object2 );
if ( value1 == null ) {
@@ -204,10 +204,10 @@
return value1.compareTo( getRightDate( value2 ) ) != 0;
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
final Date value1 = (Date) extractor1.getValue( object1 );
final Date value2 = (Date) extractor2.getValue( object2 );
if ( value1 == null ) {
@@ -258,10 +258,10 @@
return getRightDate( value2 ).compareTo( value1 ) < 0;
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
final Date value1 = (Date) extractor1.getValue( object1 );
final Date value2 = (Date) extractor2.getValue( object2 );
if ( value1 == null ) {
@@ -309,10 +309,10 @@
return getRightDate( value2 ).compareTo( value1 ) <= 0;
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
final Date value1 = (Date) extractor1.getValue( object1 );
final Date value2 = (Date) extractor2.getValue( object2 );
if ( value1 == null ) {
@@ -360,10 +360,10 @@
return getRightDate( value2 ).compareTo( value1 ) > 0;
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
final Date value1 = (Date) extractor1.getValue( object1 );
final Date value2 = (Date) extractor2.getValue( object2 );
if ( value1 == null ) {
@@ -411,10 +411,10 @@
return getRightDate( value2 ).compareTo( value1 ) >= 0;
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
final Date value1 = (Date) extractor1.getValue( object1 );
final Date value2 = (Date) extractor2.getValue( object2 );
if ( value1 == null ) {
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/DoubleFactory.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -91,10 +91,10 @@
return ((DoubleVariableContextEntry) context).left == context.extractor.getDoubleValue( right );
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
// TODO: we are not handling delta right now... maybe we should
return extractor1.getDoubleValue( object1 ) == extractor2.getDoubleValue( object2 );
}
@@ -135,10 +135,10 @@
return ((DoubleVariableContextEntry) context).left != context.extractor.getDoubleValue( right );
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
// TODO: we are not handling delta right now... maybe we should
return extractor1.getDoubleValue( object1 ) != extractor2.getDoubleValue( object2 );
}
@@ -179,10 +179,10 @@
return context.extractor.getDoubleValue( right ) < ((DoubleVariableContextEntry) context).left;
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
// TODO: we are not handling delta right now... maybe we should
return extractor1.getDoubleValue( object1 ) < extractor2.getDoubleValue( object2 );
}
@@ -223,10 +223,10 @@
return context.extractor.getDoubleValue( right ) <= ((DoubleVariableContextEntry) context).left;
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
// TODO: we are not handling delta right now... maybe we should
return extractor1.getDoubleValue( object1 ) <= extractor2.getDoubleValue( object2 );
}
@@ -267,10 +267,10 @@
return context.extractor.getDoubleValue( right ) > ((DoubleVariableContextEntry) context).left;
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
// TODO: we are not handling delta right now... maybe we should
return extractor1.getDoubleValue( object1 ) > extractor2.getDoubleValue( object2 );
}
@@ -311,10 +311,10 @@
return context.extractor.getDoubleValue( right ) >= ((DoubleVariableContextEntry) context).left;
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
// TODO: we are not handling delta right now... maybe we should
return extractor1.getDoubleValue( object1 ) >= extractor2.getDoubleValue( object2 );
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/FactTemplateFactory.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -100,10 +100,10 @@
return ((ObjectVariableContextEntry) context).left.equals( value );
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
final Object value1 = extractor1.getValue( object1 );
final Object value2 = extractor2.getValue( object2 );
if ( value1 == null ) {
@@ -159,10 +159,10 @@
return !((ObjectVariableContextEntry) context).left.equals( value );
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
final Object value1 = extractor1.getValue( object1 );
final Object value2 = extractor2.getValue( object2 );
if ( value1 == 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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/FloatFactory.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -89,10 +89,10 @@
return ((DoubleVariableContextEntry) context).left == context.extractor.getFloatValue( right );
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
// TODO: we are not handling delta right now... maybe we should
return extractor1.getFloatValue( object1 ) == extractor2.getFloatValue( object2 );
}
@@ -133,10 +133,10 @@
return ((DoubleVariableContextEntry) context).left != context.extractor.getFloatValue( right );
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
// TODO: we are not handling delta right now... maybe we should
return extractor1.getFloatValue( object1 ) != extractor2.getFloatValue( object2 );
}
@@ -177,10 +177,10 @@
return context.extractor.getFloatValue( right ) < ((DoubleVariableContextEntry) context).left;
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
// TODO: we are not handling delta right now... maybe we should
return extractor1.getFloatValue( object1 ) < extractor2.getFloatValue( object2 );
}
@@ -212,7 +212,7 @@
public boolean evaluateCachedRight(final VariableContextEntry context,
final Object left) {
// TODO: we are not handling delta right now... maybe we should
- return ((DoubleVariableContextEntry) context).right <= context.declaration.getExtractor().getFloatValue( left );
+ return ((DoubleVariableContextEntry) context).right <= context.declaration.getExtractor().getFloatValue( left );
}
public boolean evaluateCachedLeft(final VariableContextEntry context,
@@ -221,10 +221,10 @@
return context.extractor.getFloatValue( right ) <= ((DoubleVariableContextEntry) context).left;
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
// TODO: we are not handling delta right now... maybe we should
return extractor1.getFloatValue( object1 ) <= extractor2.getFloatValue( object2 );
}
@@ -256,7 +256,7 @@
public boolean evaluateCachedRight(final VariableContextEntry context,
final Object left) {
// TODO: we are not handling delta right now... maybe we should
- return ((DoubleVariableContextEntry) context).right > context.declaration.getExtractor().getFloatValue( left );
+ return ((DoubleVariableContextEntry) context).right > context.declaration.getExtractor().getFloatValue( left );
}
public boolean evaluateCachedLeft(final VariableContextEntry context,
@@ -265,10 +265,10 @@
return context.extractor.getFloatValue( right ) > ((DoubleVariableContextEntry) context).left;
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
// TODO: we are not handling delta right now... maybe we should
return extractor1.getFloatValue( object1 ) > extractor2.getFloatValue( object2 );
}
@@ -309,10 +309,10 @@
return context.extractor.getFloatValue( right ) >= ((DoubleVariableContextEntry) context).left;
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
// TODO: we are not handling delta right now... maybe we should
return extractor1.getFloatValue( object1 ) >= extractor2.getFloatValue( object2 );
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/IntegerFactory.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -88,10 +88,10 @@
return context.extractor.getIntValue( object2 ) == ((LongVariableContextEntry) context).left;
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
return extractor1.getIntValue( object1 ) == extractor2.getIntValue( object2 );
}
@@ -129,10 +129,10 @@
return context.extractor.getIntValue( object2 ) != ((LongVariableContextEntry) context).left;
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
return extractor1.getIntValue( object1 ) != extractor2.getIntValue( object2 );
}
@@ -161,7 +161,7 @@
public boolean evaluateCachedRight(final VariableContextEntry context,
final Object left) {
- return ((LongVariableContextEntry) context).right < context.declaration.getExtractor().getIntValue( left );
+ return ((LongVariableContextEntry) context).right < context.declaration.getExtractor().getIntValue( left );
}
public boolean evaluateCachedLeft(final VariableContextEntry context,
@@ -169,10 +169,10 @@
return context.extractor.getIntValue( right ) < ((LongVariableContextEntry) context).left;
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
return extractor1.getIntValue( object1 ) < extractor2.getIntValue( object2 );
}
@@ -201,7 +201,7 @@
public boolean evaluateCachedRight(final VariableContextEntry context,
final Object left) {
- return ((LongVariableContextEntry) context).right <= context.declaration.getExtractor().getIntValue( left );
+ return ((LongVariableContextEntry) context).right <= context.declaration.getExtractor().getIntValue( left );
}
public boolean evaluateCachedLeft(final VariableContextEntry context,
@@ -209,10 +209,10 @@
return context.extractor.getIntValue( right ) <= ((LongVariableContextEntry) context).left;
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
return extractor1.getIntValue( object1 ) <= extractor2.getIntValue( object2 );
}
@@ -249,10 +249,10 @@
return context.extractor.getIntValue( right ) > ((LongVariableContextEntry) context).left;
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
return extractor1.getIntValue( object1 ) > extractor2.getIntValue( object2 );
}
@@ -289,10 +289,10 @@
return context.extractor.getIntValue( right ) >= ((LongVariableContextEntry) context).left;
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
return extractor1.getIntValue( object1 ) >= extractor2.getIntValue( object2 );
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/LongFactory.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -88,10 +88,10 @@
return ((LongVariableContextEntry) context).left == context.extractor.getLongValue( right );
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
return extractor1.getLongValue( object1 ) == extractor2.getLongValue( object2 );
}
@@ -128,10 +128,10 @@
return ((LongVariableContextEntry) context).left != context.extractor.getLongValue( right );
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
return extractor1.getLongValue( object1 ) != extractor2.getLongValue( object2 );
}
@@ -168,10 +168,10 @@
return context.extractor.getLongValue( right ) < ((LongVariableContextEntry) context).left;
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
return extractor1.getLongValue( object1 ) < extractor2.getLongValue( object2 );
}
@@ -200,7 +200,7 @@
public boolean evaluateCachedRight(final VariableContextEntry context,
final Object left) {
- return ((LongVariableContextEntry) context).right <= context.declaration.getExtractor().getLongValue( left );
+ return ((LongVariableContextEntry) context).right <= context.declaration.getExtractor().getLongValue( left );
}
public boolean evaluateCachedLeft(final VariableContextEntry context,
@@ -208,10 +208,10 @@
return context.extractor.getLongValue( right ) <= ((LongVariableContextEntry) context).left;
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
return extractor1.getLongValue( object1 ) <= extractor2.getLongValue( object2 );
}
@@ -248,10 +248,10 @@
return context.extractor.getLongValue( right ) > ((LongVariableContextEntry) context).left;
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
return extractor1.getLongValue( object1 ) > extractor2.getLongValue( object2 );
}
@@ -280,7 +280,7 @@
public boolean evaluateCachedRight(final VariableContextEntry context,
final Object left) {
- return ((LongVariableContextEntry) context).right >= context.declaration.getExtractor().getLongValue( left );
+ return ((LongVariableContextEntry) context).right >= context.declaration.getExtractor().getLongValue( left );
}
public boolean evaluateCachedLeft(final VariableContextEntry context,
@@ -288,10 +288,10 @@
return context.extractor.getLongValue( right ) >= ((LongVariableContextEntry) context).left;
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
return extractor1.getLongValue( object1 ) >= extractor2.getLongValue( object2 );
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/ObjectFactory.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -118,10 +118,10 @@
return ((ObjectVariableContextEntry) context).left.equals( value );
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
final Object value1 = extractor1.getValue( object1 );
final Object value2 = extractor2.getValue( object2 );
if ( value1 == null ) {
@@ -177,10 +177,10 @@
return !((ObjectVariableContextEntry) context).left.equals( value );
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
final Object value1 = extractor1.getValue( object1 );
final Object value2 = extractor2.getValue( object2 );
if ( value1 == null ) {
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/ShortFactory.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -64,8 +64,8 @@
/**
*
*/
- private static final long serialVersionUID = 320;
- private static final Evaluator INSTANCE = new ShortEqualEvaluator();
+ private static final long serialVersionUID = 320;
+ private static final Evaluator INSTANCE = new ShortEqualEvaluator();
private ShortEqualEvaluator() {
super( ValueType.PSHORT_TYPE,
@@ -88,10 +88,10 @@
return ((LongVariableContextEntry) context).left == context.extractor.getShortValue( right );
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
return extractor1.getShortValue( object1 ) == extractor2.getShortValue( object2 );
}
@@ -104,8 +104,8 @@
/**
*
*/
- private static final long serialVersionUID = 320;
- private static final Evaluator INSTANCE = new ShortNotEqualEvaluator();
+ private static final long serialVersionUID = 320;
+ private static final Evaluator INSTANCE = new ShortNotEqualEvaluator();
private ShortNotEqualEvaluator() {
super( ValueType.PSHORT_TYPE,
@@ -128,10 +128,10 @@
return ((LongVariableContextEntry) context).left != context.extractor.getShortValue( right );
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
return extractor1.getShortValue( object1 ) != extractor2.getShortValue( object2 );
}
@@ -144,8 +144,8 @@
/**
*
*/
- private static final long serialVersionUID = 320;
- private static final Evaluator INSTANCE = new ShortLessEvaluator();
+ private static final long serialVersionUID = 320;
+ private static final Evaluator INSTANCE = new ShortLessEvaluator();
private ShortLessEvaluator() {
super( ValueType.PSHORT_TYPE,
@@ -160,18 +160,18 @@
public boolean evaluateCachedRight(final VariableContextEntry context,
final Object left) {
- return ((LongVariableContextEntry) context).right < context.declaration.getExtractor().getShortValue( left );
+ return ((LongVariableContextEntry) context).right < context.declaration.getExtractor().getShortValue( left );
}
public boolean evaluateCachedLeft(final VariableContextEntry context,
final Object right) {
- return context.extractor.getShortValue( right ) < ((LongVariableContextEntry) context).left;
+ return context.extractor.getShortValue( right ) < ((LongVariableContextEntry) context).left;
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
return extractor1.getShortValue( object1 ) < extractor2.getShortValue( object2 );
}
@@ -184,8 +184,8 @@
/**
*
*/
- private static final long serialVersionUID = 320;
- private static final Evaluator INSTANCE = new ShortLessOrEqualEvaluator();
+ private static final long serialVersionUID = 320;
+ private static final Evaluator INSTANCE = new ShortLessOrEqualEvaluator();
private ShortLessOrEqualEvaluator() {
super( ValueType.PSHORT_TYPE,
@@ -200,18 +200,18 @@
public boolean evaluateCachedRight(final VariableContextEntry context,
final Object left) {
- return ((LongVariableContextEntry) context).right <= context.declaration.getExtractor().getShortValue( left );
+ return ((LongVariableContextEntry) context).right <= context.declaration.getExtractor().getShortValue( left );
}
public boolean evaluateCachedLeft(final VariableContextEntry context,
final Object right) {
- return context.extractor.getShortValue( right ) <= ((LongVariableContextEntry) context).left;
+ return context.extractor.getShortValue( right ) <= ((LongVariableContextEntry) context).left;
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
return extractor1.getShortValue( object1 ) <= extractor2.getShortValue( object2 );
}
@@ -224,8 +224,8 @@
/**
*
*/
- private static final long serialVersionUID = 320;
- private static final Evaluator INSTANCE = new ShortGreaterEvaluator();
+ private static final long serialVersionUID = 320;
+ private static final Evaluator INSTANCE = new ShortGreaterEvaluator();
private ShortGreaterEvaluator() {
super( ValueType.PSHORT_TYPE,
@@ -248,10 +248,10 @@
return context.extractor.getShortValue( right ) > ((LongVariableContextEntry) context).left;
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
return extractor1.getShortValue( object1 ) > extractor2.getShortValue( object2 );
}
@@ -264,8 +264,8 @@
/**
*
*/
- private static final long serialVersionUID = 320;
- private static final Evaluator INSTANCE = new ShortGreaterOrEqualEvaluator();
+ private static final long serialVersionUID = 320;
+ private static final Evaluator INSTANCE = new ShortGreaterOrEqualEvaluator();
private ShortGreaterOrEqualEvaluator() {
super( ValueType.PSHORT_TYPE,
@@ -280,7 +280,7 @@
public boolean evaluateCachedRight(final VariableContextEntry context,
final Object left) {
- return ((LongVariableContextEntry) context).right >= context.declaration.getExtractor().getShortValue( left );
+ return ((LongVariableContextEntry) context).right >= context.declaration.getExtractor().getShortValue( left );
}
public boolean evaluateCachedLeft(final VariableContextEntry context,
@@ -288,10 +288,10 @@
return context.extractor.getShortValue( right ) >= ((LongVariableContextEntry) context).left;
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
return extractor1.getShortValue( object1 ) >= extractor2.getShortValue( object2 );
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/StringFactory.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -102,10 +102,10 @@
return ((ObjectVariableContextEntry) context).left.equals( value );
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
final Object value1 = extractor1.getValue( object1 );
final Object value2 = extractor2.getValue( object2 );
if ( value1 == null ) {
@@ -161,10 +161,10 @@
return !((ObjectVariableContextEntry) context).left.equals( value );
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
final Object value1 = extractor1.getValue( object1 );
final Object value2 = extractor2.getValue( object2 );
if ( value1 == null ) {
@@ -216,13 +216,13 @@
if ( value == null ) {
return false;
}
- return value.matches( (String) ((ObjectVariableContextEntry) context).left);
+ return value.matches( (String) ((ObjectVariableContextEntry) context).left );
}
- public boolean evaluate(Extractor extractor1,
- Object object1,
- Extractor extractor2,
- Object object2) {
+ public boolean evaluate(final Extractor extractor1,
+ final Object object1,
+ final Extractor extractor2,
+ final Object object2) {
final Object value1 = extractor1.getValue( object1 );
final Object value2 = extractor2.getValue( object2 );
if ( value1 == null ) {
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/BaseBooleanClassFieldExtractor.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -91,13 +91,13 @@
try {
return this.getClass().getDeclaredMethod( "getBooleanValue",
new Class[]{Object.class} );
- } catch ( Exception e ) {
+ } catch ( final Exception e ) {
throw new RuntimeDroolsException( "This is a bug. Please report to development team: " + e.getMessage(),
e );
}
}
- public int getHashCode(Object object) {
+ public int getHashCode(final Object object) {
return getBooleanValue( object ) ? 1231 : 1237;
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/BaseByteClassFieldExtractor.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -46,8 +46,8 @@
* @param valueType
*/
protected BaseByteClassFieldExtractor(final int index,
- final Class fieldType,
- final ValueType valueType) {
+ final Class fieldType,
+ final ValueType valueType) {
super( index,
fieldType,
valueType );
@@ -86,16 +86,18 @@
public short getShortValue(final Object object) {
return getByteValue( object );
}
-
+
public Method getNativeReadMethod() {
try {
- return this.getClass().getDeclaredMethod( "getByteValue", new Class[] { Object.class } );
- } catch ( Exception e ) {
- throw new RuntimeDroolsException("This is a bug. Please report to development team: "+e.getMessage(), e);
+ return this.getClass().getDeclaredMethod( "getByteValue",
+ new Class[]{Object.class} );
+ } catch ( final Exception e ) {
+ throw new RuntimeDroolsException( "This is a bug. Please report to development team: " + e.getMessage(),
+ e );
}
}
- public int getHashCode(Object object) {
+ public int getHashCode(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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/BaseCharClassFieldExtractor.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -24,8 +24,8 @@
* @param valueType
*/
protected BaseCharClassFieldExtractor(final int index,
- final Class fieldType,
- final ValueType valueType) {
+ final Class fieldType,
+ final ValueType valueType) {
super( index,
fieldType,
valueType );
@@ -46,19 +46,19 @@
public abstract char getCharValue(Object object);
public double getDoubleValue(final Object object) {
- return (double) getCharValue( object );
+ return getCharValue( object );
}
public float getFloatValue(final Object object) {
- return (float) getCharValue( object );
+ return getCharValue( object );
}
public int getIntValue(final Object object) {
- return (int) getCharValue( object );
+ return getCharValue( object );
}
public long getLongValue(final Object object) {
- return (long) getCharValue( object );
+ return getCharValue( object );
}
public short getShortValue(final Object object) {
@@ -67,13 +67,15 @@
public Method getNativeReadMethod() {
try {
- return this.getClass().getDeclaredMethod( "getCharValue", new Class[] { Object.class } );
- } catch ( Exception e ) {
- throw new RuntimeDroolsException("This is a bug. Please report to development team: "+e.getMessage(), e);
+ return this.getClass().getDeclaredMethod( "getCharValue",
+ new Class[]{Object.class} );
+ } catch ( final Exception e ) {
+ throw new RuntimeDroolsException( "This is a bug. Please report to development team: " + e.getMessage(),
+ e );
}
}
- public int getHashCode(Object object) {
+ public int getHashCode(final Object object) {
return getCharValue( object );
}
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/BaseDoubleClassFieldExtractor.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -24,8 +24,8 @@
* @param valueType
*/
protected BaseDoubleClassFieldExtractor(final int index,
- final Class fieldType,
- final ValueType valueType) {
+ final Class fieldType,
+ final ValueType valueType) {
super( index,
fieldType,
valueType );
@@ -68,15 +68,17 @@
public Method getNativeReadMethod() {
try {
- return this.getClass().getDeclaredMethod( "getDoubleValue", new Class[] { Object.class } );
- } catch ( Exception e ) {
- throw new RuntimeDroolsException("This is a bug. Please report to development team: "+e.getMessage(), e);
+ return this.getClass().getDeclaredMethod( "getDoubleValue",
+ new Class[]{Object.class} );
+ } catch ( final Exception e ) {
+ throw new RuntimeDroolsException( "This is a bug. Please report to development team: " + e.getMessage(),
+ e );
}
}
-
- public int getHashCode(Object object) {
- long temp = Double.doubleToLongBits( getDoubleValue( object ) );
- return (int) ( temp ^ ( temp >>> 32) );
+
+ public int getHashCode(final Object object) {
+ final long temp = Double.doubleToLongBits( getDoubleValue( object ) );
+ return (int) (temp ^ (temp >>> 32));
}
-
+
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/BaseFloatClassFieldExtractor.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -24,8 +24,8 @@
* @param valueType
*/
protected BaseFloatClassFieldExtractor(final int index,
- final Class fieldType,
- final ValueType valueType) {
+ final Class fieldType,
+ final ValueType valueType) {
super( index,
fieldType,
valueType );
@@ -68,14 +68,16 @@
public Method getNativeReadMethod() {
try {
- return this.getClass().getDeclaredMethod( "getFloatValue", new Class[] { Object.class } );
- } catch ( Exception e ) {
- throw new RuntimeDroolsException("This is a bug. Please report to development team: "+e.getMessage(), e);
+ return this.getClass().getDeclaredMethod( "getFloatValue",
+ new Class[]{Object.class} );
+ } catch ( final Exception e ) {
+ throw new RuntimeDroolsException( "This is a bug. Please report to development team: " + e.getMessage(),
+ e );
}
}
-
- public int getHashCode(Object object) {
+
+ public int getHashCode(final Object object) {
return Float.floatToIntBits( 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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/BaseIntClassFieldExtractor.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -24,8 +24,8 @@
* @param valueType
*/
protected BaseIntClassFieldExtractor(final int index,
- final Class fieldType,
- final ValueType valueType) {
+ final Class fieldType,
+ final ValueType valueType) {
super( index,
fieldType,
valueType );
@@ -68,13 +68,15 @@
public Method getNativeReadMethod() {
try {
- return this.getClass().getDeclaredMethod( "getIntValue", new Class[] { Object.class } );
- } catch ( Exception e ) {
- throw new RuntimeDroolsException("This is a bug. Please report to development team: "+e.getMessage(), e);
+ return this.getClass().getDeclaredMethod( "getIntValue",
+ new Class[]{Object.class} );
+ } catch ( final Exception e ) {
+ throw new RuntimeDroolsException( "This is a bug. Please report to development team: " + e.getMessage(),
+ e );
}
}
- public int getHashCode(Object object) {
+ public int getHashCode(final Object object) {
return 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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/BaseLongClassFieldExtractors.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -24,8 +24,8 @@
* @param valueType
*/
protected BaseLongClassFieldExtractors(final int index,
- final Class fieldType,
- final ValueType valueType) {
+ final Class fieldType,
+ final ValueType valueType) {
super( index,
fieldType,
valueType );
@@ -68,15 +68,17 @@
public Method getNativeReadMethod() {
try {
- return this.getClass().getDeclaredMethod( "getLongValue", new Class[] { Object.class } );
- } catch ( Exception e ) {
- throw new RuntimeDroolsException("This is a bug. Please report to development team: "+e.getMessage(), e);
+ return this.getClass().getDeclaredMethod( "getLongValue",
+ new Class[]{Object.class} );
+ } catch ( final Exception e ) {
+ throw new RuntimeDroolsException( "This is a bug. Please report to development team: " + e.getMessage(),
+ e );
}
}
-
- public int getHashCode(Object object) {
- long temp = getLongValue( object );
- return (int) ( temp ^ ( temp >>> 32 ));
+
+ public int getHashCode(final Object object) {
+ final long temp = getLongValue( object );
+ return (int) (temp ^ (temp >>> 32));
}
-
+
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/BaseObjectClassFieldExtractor.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -110,14 +110,14 @@
try {
return this.getClass().getDeclaredMethod( "getValue",
new Class[]{Object.class} );
- } catch ( Exception e ) {
+ } catch ( final Exception e ) {
throw new RuntimeDroolsException( "This is a bug. Please report to development team: " + e.getMessage(),
e );
}
}
- public int getHashCode(Object object) {
- Object value = getValue( object );
+ public int getHashCode(final Object object) {
+ final Object value = getValue( object );
return (value != null) ? value.hashCode() : 0;
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/BaseShortClassFieldExtractor.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -24,8 +24,8 @@
* @param valueType
*/
protected BaseShortClassFieldExtractor(final int index,
- final Class fieldType,
- final ValueType valueType) {
+ final Class fieldType,
+ final ValueType valueType) {
super( index,
fieldType,
valueType );
@@ -68,13 +68,15 @@
public Method getNativeReadMethod() {
try {
- return this.getClass().getDeclaredMethod( "getShortValue", new Class[] { Object.class } );
- } catch ( Exception e ) {
- throw new RuntimeDroolsException("This is a bug. Please report to development team: "+e.getMessage(), e);
+ return this.getClass().getDeclaredMethod( "getShortValue",
+ new Class[]{Object.class} );
+ } catch ( final Exception e ) {
+ throw new RuntimeDroolsException( "This is a bug. Please report to development team: " + e.getMessage(),
+ e );
}
}
- public int getHashCode(Object object) {
+ public int getHashCode(final Object object) {
return getShortValue( object );
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/SelfReferenceClassFieldExtractor.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/SelfReferenceClassFieldExtractor.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/SelfReferenceClassFieldExtractor.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -28,15 +28,15 @@
private static final long serialVersionUID = 3258380877818552472L;
- public SelfReferenceClassFieldExtractor(Class clazz,
- String fieldName) {
+ public SelfReferenceClassFieldExtractor(final Class clazz,
+ final String fieldName) {
super( -1, // index
clazz, // fieldType
ValueType.determineValueType( clazz ) ); // value type
}
- public Object getValue(Object object) {
- return ( object instanceof ShadowProxy ) ? ((ShadowProxy)object).getShadowedObject() : object;
+ public Object getValue(final Object object) {
+ return (object instanceof ShadowProxy) ? ((ShadowProxy) object).getShadowedObject() : object;
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/DroolsMVELFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/DroolsMVELFactory.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/DroolsMVELFactory.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -27,47 +27,46 @@
this.resolvers = Collections.EMPTY_MAP;
}
- public DroolsMVELFactory(Map previousDeclarations,
- Map localDeclarations,
- Map globals) {
+ public DroolsMVELFactory(final Map previousDeclarations,
+ final Map localDeclarations,
+ final Map globals) {
}
- public void setPreviousDeclarationMap(Map declarations) {
+ public void setPreviousDeclarationMap(final Map declarations) {
this.previousDeclarations = declarations;
}
- public void setLocalDeclarationMap(Map declarations) {
+ public void setLocalDeclarationMap(final Map declarations) {
this.localDeclarations = declarations;
}
- public void setGlobalsMap(Map globals) {
+ public void setGlobalsMap(final Map globals) {
this.globals = globals;
}
-
public Object getObject() {
return this.object;
}
- public void setContext(Tuple tuple,
- Object object,
- WorkingMemory workingMemory) {
+ public void setContext(final Tuple tuple,
+ final Object object,
+ final WorkingMemory workingMemory) {
this.tuple = tuple;
this.object = object;
this.workingMemory = workingMemory;
}
- public Object getValue(Declaration declaration) {
- return tuple.get( declaration ).getObject();
+ public Object getValue(final Declaration declaration) {
+ return this.tuple.get( declaration ).getObject();
}
- public Object getValue(String identifier) {
+ public Object getValue(final String identifier) {
return this.workingMemory.getGlobal( identifier );
}
- public VariableResolver createVariable(String name,
- Object value) {
+ public VariableResolver createVariable(final String name,
+ final Object value) {
throw new UnsupportedOperationException( "Variables cannot be created here" );
}
@@ -75,15 +74,15 @@
return null;
}
- public VariableResolverFactory setNextFactory(VariableResolverFactory resolverFactory) {
+ public VariableResolverFactory setNextFactory(final VariableResolverFactory resolverFactory) {
throw new UnsupportedOperationException( "Chained factories are not support for DroolsMVELFactory" );
}
- public VariableResolver getVariableResolver(String name) {
+ public VariableResolver getVariableResolver(final String name) {
return (VariableResolver) this.resolvers.get( name );
}
- public boolean isResolveable(String name) {
+ public boolean isResolveable(final String name) {
//return this.declarations.containsKey( name ) || this.globals.containsKey( name );
if ( this.resolvers == Collections.EMPTY_MAP ) {
this.resolvers = new HashMap();
@@ -95,7 +94,7 @@
return true;
}
- if ( this.previousDeclarations != null && this.previousDeclarations.containsKey( name ) ) {
+ if ( this.previousDeclarations != null && this.previousDeclarations.containsKey( name ) ) {
resolver = new DroolsMVELPreviousDeclarationVariable( (Declaration) this.previousDeclarations.get( name ),
this );
} else if ( this.localDeclarations != null && this.localDeclarations.containsKey( name ) ) {
@@ -116,7 +115,7 @@
}
}
- public boolean isTarget(String name) {
+ public boolean isTarget(final String name) {
return this.resolvers.containsKey( name );
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/DroolsMVELGlobalVariable.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/DroolsMVELGlobalVariable.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/DroolsMVELGlobalVariable.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -5,19 +5,19 @@
public class DroolsMVELGlobalVariable
implements
VariableResolver {
-
- private String name;
- private Class knownType;
+
+ private String name;
+ private Class knownType;
private DroolsMVELFactory factory;
-
- public DroolsMVELGlobalVariable(String identifier,
- Class knownType,
- DroolsMVELFactory factory ) {
+
+ public DroolsMVELGlobalVariable(final String identifier,
+ final Class knownType,
+ final DroolsMVELFactory factory) {
this.name = identifier;
- this.factory = factory;
+ this.factory = factory;
this.knownType = knownType;
}
-
+
public String getName() {
return this.name;
}
@@ -30,12 +30,12 @@
return this.factory.getValue( this.name );
}
- public void setValue(Object value) {
+ public void setValue(final Object value) {
throw new UnsupportedOperationException( "External Variable identifer='" + getName() + "' type='" + getKnownType() + "' is final, it cannot be set" );
}
-
- public int getFlags() {
- return 0;
- }
+ public int getFlags() {
+ return 0;
+ }
+
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/DroolsMVELLocalDeclarationVariable.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/DroolsMVELLocalDeclarationVariable.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/DroolsMVELLocalDeclarationVariable.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -6,34 +6,34 @@
public class DroolsMVELLocalDeclarationVariable
implements
VariableResolver {
-
- private Declaration declaration;
+
+ private Declaration declaration;
private DroolsMVELFactory factory;
-
- public DroolsMVELLocalDeclarationVariable(Declaration declaration,
- DroolsMVELFactory factory ) {
+
+ public DroolsMVELLocalDeclarationVariable(final Declaration declaration,
+ final DroolsMVELFactory factory) {
this.declaration = declaration;
- this.factory = factory;
- }
-
+ this.factory = factory;
+ }
+
public String getName() {
return this.declaration.getIdentifier();
}
public Class getKnownType() {
- return declaration.getExtractor().getExtractToClass();
+ return this.declaration.getExtractor().getExtractToClass();
}
public Object getValue() {
- return declaration.getValue( this.factory.getObject() );
+ return this.declaration.getValue( this.factory.getObject() );
}
- public void setValue(Object value) {
- throw new UnsupportedOperationException( "External Variable identifer='" + getName() + "' type='" + getKnownType()+ "' is final, it cannot be set" );
+ public void setValue(final Object value) {
+ throw new UnsupportedOperationException( "External Variable identifer='" + getName() + "' type='" + getKnownType() + "' is final, it cannot be set" );
}
-
- public int getFlags() {
- return 0;
- }
+ public int getFlags() {
+ return 0;
+ }
+
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/DroolsMVELPreviousDeclarationVariable.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/DroolsMVELPreviousDeclarationVariable.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/DroolsMVELPreviousDeclarationVariable.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -6,34 +6,34 @@
public class DroolsMVELPreviousDeclarationVariable
implements
VariableResolver {
-
- private Declaration declaration;
+
+ private Declaration declaration;
private DroolsMVELFactory factory;
-
- public DroolsMVELPreviousDeclarationVariable(Declaration declaration,
- DroolsMVELFactory factory ) {
+
+ public DroolsMVELPreviousDeclarationVariable(final Declaration declaration,
+ final DroolsMVELFactory factory) {
this.declaration = declaration;
- this.factory = factory;
- }
-
+ this.factory = factory;
+ }
+
public String getName() {
return this.declaration.getIdentifier();
}
public Class getKnownType() {
- return declaration.getExtractor().getExtractToClass();
+ return this.declaration.getExtractor().getExtractToClass();
}
public Object getValue() {
- return declaration.getValue( this.factory.getValue( this.declaration ));
+ return this.declaration.getValue( this.factory.getValue( this.declaration ) );
}
- public void setValue(Object value) {
- throw new UnsupportedOperationException( "External Variable identifer='" + getName() + "' type='" + getKnownType()+ "' is final, it cannot be set" );
+ public void setValue(final Object value) {
+ throw new UnsupportedOperationException( "External Variable identifer='" + getName() + "' type='" + getKnownType() + "' is final, it cannot be set" );
}
-
- public int getFlags() {
- return 0;
- }
+ public int getFlags() {
+ return 0;
+ }
+
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/MVELConsequence.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/MVELConsequence.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/MVELConsequence.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -3,13 +3,8 @@
import java.io.Serializable;
import org.drools.WorkingMemory;
-import org.drools.rule.Declaration;
import org.drools.spi.Consequence;
-import org.drools.spi.FieldValue;
import org.drools.spi.KnowledgeHelper;
-import org.drools.spi.PredicateExpression;
-import org.drools.spi.ReturnValueExpression;
-import org.drools.spi.Tuple;
import org.mvel.MVEL;
public class MVELConsequence
@@ -26,10 +21,12 @@
this.factory = factory;
}
- public void evaluate(KnowledgeHelper knowledgeHelper,
- WorkingMemory workingMemory) throws Exception {
- this.factory.setContext( knowledgeHelper.getTuple(), null, workingMemory );
+ public void evaluate(final KnowledgeHelper knowledgeHelper,
+ final WorkingMemory workingMemory) throws Exception {
+ this.factory.setContext( knowledgeHelper.getTuple(),
+ null,
+ workingMemory );
MVEL.executeExpression( this.expr,
- factory );
- }
+ this.factory );
+ }
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/MVELEvalExpression.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/MVELEvalExpression.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/MVELEvalExpression.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -23,14 +23,14 @@
this.factory = factory;
}
- public boolean evaluate(Tuple tuple,
- Declaration[] requiredDeclarations,
- WorkingMemory workingMemory) throws Exception {
- factory.setContext( tuple,
+ public boolean evaluate(final Tuple tuple,
+ final Declaration[] requiredDeclarations,
+ final WorkingMemory workingMemory) throws Exception {
+ this.factory.setContext( tuple,
null,
workingMemory );
- Boolean result = (Boolean) MVEL.executeExpression( this.expr,
- factory );
+ final Boolean result = (Boolean) MVEL.executeExpression( this.expr,
+ this.factory );
return result.booleanValue();
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/MVELPredicateExpression.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/MVELPredicateExpression.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/MVELPredicateExpression.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -22,16 +22,16 @@
this.factory = factory;
}
- public boolean evaluate(Object object,
- Tuple tuple,
- Declaration[] previousDeclarations,
- Declaration[] requiredDeclarations,
- WorkingMemory workingMemory) throws Exception {
- factory.setContext( tuple,
+ public boolean evaluate(final Object object,
+ final Tuple tuple,
+ final Declaration[] previousDeclarations,
+ final Declaration[] requiredDeclarations,
+ final WorkingMemory workingMemory) throws Exception {
+ this.factory.setContext( tuple,
object,
workingMemory );
- Boolean result = (Boolean) MVEL.executeExpression( this.expr,
- factory );
+ final Boolean result = (Boolean) MVEL.executeExpression( this.expr,
+ this.factory );
return result.booleanValue();
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/MVELReturnValueExpression.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/MVELReturnValueExpression.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/MVELReturnValueExpression.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -5,7 +5,6 @@
import org.drools.WorkingMemory;
import org.drools.rule.Declaration;
import org.drools.spi.FieldValue;
-import org.drools.spi.PredicateExpression;
import org.drools.spi.ReturnValueExpression;
import org.drools.spi.Tuple;
import org.mvel.MVEL;
@@ -24,16 +23,16 @@
this.factory = factory;
}
- public FieldValue evaluate(Object object,
- Tuple tuple,
- Declaration[] previousDeclarations,
- Declaration[] requiredDeclarations,
- WorkingMemory workingMemory) throws Exception {
- factory.setContext( tuple,
+ public FieldValue evaluate(final Object object,
+ final Tuple tuple,
+ final Declaration[] previousDeclarations,
+ final Declaration[] requiredDeclarations,
+ final WorkingMemory workingMemory) throws Exception {
+ this.factory.setContext( tuple,
object,
workingMemory );
return org.drools.base.FieldFactory.getFieldValue( MVEL.executeExpression( this.expr,
- factory ) );
+ this.factory ) );
}
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractRuleBase.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -255,7 +255,7 @@
// in the working memory array
int lastAquiredLock = 0;
// get a snapshot of current working memories for locking
- AbstractWorkingMemory[] wms = (AbstractWorkingMemory[]) this.workingMemories.keySet().toArray( new AbstractWorkingMemory[this.workingMemories.size()] );
+ final AbstractWorkingMemory[] wms = (AbstractWorkingMemory[]) this.workingMemories.keySet().toArray( new AbstractWorkingMemory[this.workingMemories.size()] );
try {
// Iterate each workingMemory and lock it
@@ -279,9 +279,9 @@
for ( final Iterator it = newGlobals.keySet().iterator(); it.hasNext(); ) {
final String identifier = (String) it.next();
final Class type = (Class) newGlobals.get( identifier );
- boolean f = this.globals.containsKey( identifier );
+ final boolean f = this.globals.containsKey( identifier );
if ( f ) {
- boolean y = !this.globals.get( identifier ).equals( type );
+ final boolean y = !this.globals.get( identifier ).equals( type );
if ( f && y ) {
throw new PackageIntegrationException( pkg );
}
@@ -300,7 +300,7 @@
} finally {
// Iterate each workingMemory and attempt to fire any rules, that were activated as a result
// of the new rule addition. Unlock after fireAllRules();
-
+
// as per the INVARIANT defined above, we need to iterate from lastAquiredLock-1 to 0.
for ( lastAquiredLock--; lastAquiredLock > -1; lastAquiredLock-- ) {
wms[lastAquiredLock].fireAllRules();
@@ -372,7 +372,7 @@
// in the working memory array
int lastAquiredLock = 0;
// get a snapshot of current working memories for locking
- AbstractWorkingMemory[] wms = (AbstractWorkingMemory[]) this.workingMemories.keySet().toArray( new AbstractWorkingMemory[this.workingMemories.size()] );
+ final AbstractWorkingMemory[] wms = (AbstractWorkingMemory[]) this.workingMemories.keySet().toArray( new AbstractWorkingMemory[this.workingMemories.size()] );
try {
// Iterate each workingMemory and lock it
@@ -380,7 +380,7 @@
for ( lastAquiredLock = 0; lastAquiredLock < wms.length; lastAquiredLock++ ) {
wms[lastAquiredLock].getLock().lock();
}
-
+
final Rule[] rules = pkg.getRules();
for ( int i = 0; i < rules.length; ++i ) {
@@ -429,7 +429,7 @@
// in the working memory array
int lastAquiredLock = 0;
// get a snapshot of current working memories for locking
- AbstractWorkingMemory[] wms = (AbstractWorkingMemory[]) this.workingMemories.keySet().toArray( new AbstractWorkingMemory[this.workingMemories.size()] );
+ final AbstractWorkingMemory[] wms = (AbstractWorkingMemory[]) this.workingMemories.keySet().toArray( new AbstractWorkingMemory[this.workingMemories.size()] );
try {
// Iterate each workingMemory and lock it
@@ -437,7 +437,7 @@
for ( lastAquiredLock = 0; lastAquiredLock < wms.length; lastAquiredLock++ ) {
wms[lastAquiredLock].getLock().lock();
}
-
+
removeRule( rule );
pkg.removeRule( rule );
@@ -453,17 +453,18 @@
}
protected abstract void removeRule(Rule rule);
-
- public void addProcess(IProcess process) {
- processes.put(process.getId(), process);
+
+ public void addProcess(final IProcess process) {
+ this.processes.put( process.getId(),
+ process );
}
- public void removeProcess(String id) {
- processes.remove(id);
+ public void removeProcess(final String id) {
+ this.processes.remove( id );
}
-
- public IProcess getProcess(String id) {
- return (IProcess) processes.get(id);
+
+ public IProcess getProcess(final String id) {
+ return (IProcess) this.processes.get( id );
}
protected void addWorkingMemory(final WorkingMemory 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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -380,8 +380,8 @@
* If no items are fired, then it will assert a temporary "Otherwise"
* fact and allow any rules to fire to handle "otherwise" cases.
*/
- private void doOtherwise(AgendaFilter agendaFilter) {
- FactHandle handle = this.assertObject( new Otherwise() );
+ private void doOtherwise(final AgendaFilter agendaFilter) {
+ final FactHandle handle = this.assertObject( new Otherwise() );
if ( !this.factQueue.isEmpty() ) {
propagateQueuedActions();
}
@@ -437,7 +437,7 @@
this.lock.lock();
// Make sure the FactHandle is from this WorkingMemory
- InternalFactHandle internalHandle = (InternalFactHandle) this.assertMap.get( handle );
+ final InternalFactHandle internalHandle = (InternalFactHandle) this.assertMap.get( handle );
if ( internalHandle == null ) {
return null;
}
@@ -472,8 +472,8 @@
public List getFactHandles() {
try {
this.lock.lock();
- List list = new ArrayList( this.assertMap.size() );
- org.drools.util.Iterator it = this.assertMap.iterator();
+ final List list = new ArrayList( this.assertMap.size() );
+ final org.drools.util.Iterator it = this.assertMap.iterator();
for ( ObjectEntry entry = (ObjectEntry) it.next(); entry != null; entry = (ObjectEntry) it.next() ) {
list.add( entry.getKey() );
}
@@ -500,10 +500,10 @@
public List getObjects() {
final List list = new ArrayList( this.assertMap.size() );
- org.drools.util.Iterator it = this.assertMap.iterator();
+ final org.drools.util.Iterator it = this.assertMap.iterator();
for ( ObjectEntry entry = (ObjectEntry) it.next(); entry != null; entry = (ObjectEntry) it.next() ) {
- InternalFactHandle handle = (InternalFactHandle) entry.getKey();
- Object object = (handle.isShadowFact()) ? ((ShadowProxy) handle.getObject()).getShadowedObject() : handle.getObject();
+ final InternalFactHandle handle = (InternalFactHandle) entry.getKey();
+ final Object object = (handle.isShadowFact()) ? ((ShadowProxy) handle.getObject()).getShadowedObject() : handle.getObject();
list.add( object );
}
return list;
@@ -512,10 +512,10 @@
public List getObjects(final Class objectClass) {
final List list = new ArrayList( this.assertMap.size() );
- org.drools.util.Iterator it = this.assertMap.iterator();
+ final org.drools.util.Iterator it = this.assertMap.iterator();
for ( ObjectEntry entry = (ObjectEntry) it.next(); entry != null; entry = (ObjectEntry) it.next() ) {
- InternalFactHandle handle = (InternalFactHandle) entry.getKey();
- Object object = (handle.isShadowFact()) ? ((ShadowProxy) handle.getObject()).getShadowedObject() : handle.getObject();
+ final InternalFactHandle handle = (InternalFactHandle) entry.getKey();
+ final Object object = (handle.isShadowFact()) ? ((ShadowProxy) handle.getObject()).getShadowedObject() : handle.getObject();
if ( objectClass.isInstance( object ) ) {
list.add( object );
}
@@ -987,7 +987,7 @@
factHandle,
originalObject,
object );
-
+
propagationContext.clearRetractedTuples();
if ( !this.factQueue.isEmpty() ) {
@@ -1146,28 +1146,28 @@
this.activationOrigin );
}
}
-
+
public class RuleFlowDeactivateEvent {
-
+
public void propagate() {
-
+
}
}
-
- public IProcessInstance startProcess(String processId) {
- IProcess process = getRuleBase().getProcess(processId);
- if (process == null) {
- throw new IllegalArgumentException("Unknown process ID: " + processId);
- }
- if (process instanceof IRuleFlowProcess) {
- IRuleFlowProcessInstance processInstance = new RuleFlowProcessInstance();
- processInstance.setAgenda(agenda);
- processInstance.setProcess(process);
+
+ public IProcessInstance startProcess(final String processId) {
+ final IProcess process = getRuleBase().getProcess( processId );
+ if ( process == null ) {
+ throw new IllegalArgumentException( "Unknown process ID: " + processId );
+ }
+ if ( process instanceof IRuleFlowProcess ) {
+ final IRuleFlowProcessInstance processInstance = new RuleFlowProcessInstance();
+ processInstance.setAgenda( this.agenda );
+ processInstance.setProcess( process );
processInstance.start();
return processInstance;
- } else {
- throw new IllegalArgumentException("Unknown process type: " + process.getClass());
- }
+ } else {
+ throw new IllegalArgumentException( "Unknown process type: " + process.getClass() );
+ }
}
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AgendaGroupImpl.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -44,9 +44,9 @@
/** Items in the agenda. */
private final BinaryHeapQueue queue;
-
- private boolean active;
+ private boolean active;
+
/**
* Construct an <code>AgendaGroup</code> with the given name.
*
@@ -82,13 +82,13 @@
public Activation getNext() {
return (Activation) this.queue.dequeue();
- }
+ }
public boolean isActivate() {
- return active;
+ return this.active;
}
- public void setActive(boolean activate) {
+ public void setActive(final boolean activate) {
this.active = activate;
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AgendaItem.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -76,7 +76,7 @@
private ActivationGroupNode activationGroupNode;
- private RuleFlowGroupNode ruleFlowGroupNode;
+ private RuleFlowGroupNode ruleFlowGroupNode;
// ------------------------------------------------------------
// Constructors
@@ -215,18 +215,18 @@
}
public AgendaGroup getAgendaGroup() {
- return agendaGroup;
+ return this.agendaGroup;
}
- public void setAgendaGroup(AgendaGroupImpl agendaGroup) {
+ public void setAgendaGroup(final AgendaGroupImpl agendaGroup) {
this.agendaGroup = agendaGroup;
}
public RuleFlowGroupNode getRuleFlowGroupNode() {
- return ruleFlowGroupNode;
+ return this.ruleFlowGroupNode;
}
- public void setRuleFlowGroupNode(RuleFlowGroupNode ruleFlowGroupNode) {
+ public void setRuleFlowGroupNode(final RuleFlowGroupNode ruleFlowGroupNode) {
this.ruleFlowGroupNode = ruleFlowGroupNode;
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/BetaConstraints.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -6,11 +6,15 @@
import org.drools.reteoo.ReteTuple;
import org.drools.util.LinkedList;
-public interface BetaConstraints extends Serializable {
+public interface BetaConstraints
+ extends
+ Serializable {
- public void updateFromTuple(InternalWorkingMemory workingMemory, ReteTuple tuple);
+ public void updateFromTuple(InternalWorkingMemory workingMemory,
+ ReteTuple tuple);
- public void updateFromFactHandle(InternalWorkingMemory workingMemory, InternalFactHandle handle);
+ public void updateFromFactHandle(InternalWorkingMemory workingMemory,
+ InternalFactHandle handle);
public boolean isAllowedCachedLeft(Object object);
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/DefaultAgenda.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -166,15 +166,15 @@
public boolean setFocus(final AgendaGroup agendaGroup) {
// Set the focus to the agendaGroup if it doesn't already have the focus
if ( this.focusStack.getLast() != agendaGroup ) {
- ((AgendaGroupImpl)this.focusStack.getLast()).setActive( false );
+ ((AgendaGroupImpl) this.focusStack.getLast()).setActive( false );
this.focusStack.add( agendaGroup );
- ((AgendaGroupImpl)agendaGroup).setActive( true );
+ ((AgendaGroupImpl) agendaGroup).setActive( true );
final EventSupport eventsupport = (EventSupport) this.workingMemory;
- eventsupport.getAgendaEventSupport().fireAgendaGroupPushed( agendaGroup );
+ eventsupport.getAgendaEventSupport().fireAgendaGroupPushed( agendaGroup );
return true;
- } else {
- return false;
- }
+ } else {
+ return false;
+ }
}
/* (non-Javadoc)
@@ -212,9 +212,9 @@
// No populated queus found so pop the focusStack and repeat
if ( empty && (this.focusStack.size() > 1) ) {
agendaGroup.setActive( false );
- this.focusStack.removeLast();
+ this.focusStack.removeLast();
final EventSupport eventsupport = (EventSupport) this.workingMemory;
- eventsupport.getAgendaEventSupport().fireAgendaGroupPopped( agendaGroup );
+ eventsupport.getAgendaEventSupport().fireAgendaGroupPopped( agendaGroup );
} else {
agendaGroup = (empty) ? null : agendaGroup;
break;
@@ -222,7 +222,7 @@
}
if ( agendaGroup != null ) {
- agendaGroup.setActive( true );
+ agendaGroup.setActive( true );
}
return agendaGroup;
}
@@ -276,7 +276,7 @@
}
public RuleFlowGroup getRuleFlowGroup(final String name) {
- RuleFlowGroup ruleFlowGroup = (RuleFlowGroup) this.ruleFlowGroups.get( name );
+ RuleFlowGroup ruleFlowGroup = (RuleFlowGroup) this.ruleFlowGroups.get( name );
if ( ruleFlowGroup == null ) {
ruleFlowGroup = new RuleFlowGroupImpl( name );
this.ruleFlowGroups.put( name,
@@ -284,13 +284,13 @@
}
return ruleFlowGroup;
}
-
- public void activateRuleFlowGroup(String name) {
- ((InternalRuleFlowGroup) getRuleFlowGroup(name)).setActive(true);
+
+ public void activateRuleFlowGroup(final String name) {
+ ((InternalRuleFlowGroup) getRuleFlowGroup( name )).setActive( true );
}
-
- public void deactivateRuleFlowGroup(String name) {
- ((InternalRuleFlowGroup) getRuleFlowGroup(name)).setActive(false);
+
+ public void deactivateRuleFlowGroup(final String name) {
+ ((InternalRuleFlowGroup) getRuleFlowGroup( name )).setActive( false );
}
/* (non-Javadoc)
@@ -334,7 +334,7 @@
*/
public Activation[] getScheduledActivations() {
final List list = new ArrayList( this.scheduledActivations.size() );
- for ( LinkedListNode node = this.scheduledActivations.getFirst(); node != null; node = (LinkedListNode) node.getNext() ) {
+ for ( LinkedListNode node = this.scheduledActivations.getFirst(); node != null; node = node.getNext() ) {
list.add( node );
}
return (Activation[]) list.toArray( new Activation[list.size()] );
@@ -395,7 +395,8 @@
ruleFlowGroup.removeActivation( item );
}
- eventsupport.getAgendaEventSupport().fireActivationCancelled( item, this.workingMemory );
+ eventsupport.getAgendaEventSupport().fireActivationCancelled( item,
+ this.workingMemory );
}
((AgendaGroupImpl) agendaGroup).clear();
}
@@ -417,20 +418,21 @@
final EventSupport eventsupport = (EventSupport) this.workingMemory;
for ( final Iterator it = activationGroup.iterator(); it.hasNext(); ) {
- ActivationGroupNode node = (ActivationGroupNode) it.next();
+ final ActivationGroupNode node = (ActivationGroupNode) it.next();
final Activation activation = node.getActivation();
activation.setActivationGroupNode( null );
if ( activation.isActivated() ) {
activation.setActivated( false );
activation.remove();
-
+
if ( activation.getRuleFlowGroupNode() != null ) {
final InternalRuleFlowGroup ruleFlowGroup = activation.getRuleFlowGroupNode().getRuleFlowGroup();
ruleFlowGroup.removeActivation( activation );
}
- eventsupport.getAgendaEventSupport().fireActivationCancelled( activation, this.workingMemory );
+ eventsupport.getAgendaEventSupport().fireActivationCancelled( activation,
+ this.workingMemory );
}
}
activationGroup.clear();
@@ -475,7 +477,7 @@
// We do this first as if a node modifies a fact that causes a recursion on an empty pattern
// we need to make sure it re-activates
increaseDormantActivations();
-
+
final EventSupport eventsupport = (EventSupport) this.workingMemory;
eventsupport.getAgendaEventSupport().fireBeforeActivationFired( activation,
@@ -505,30 +507,30 @@
ruleFlowGroup.removeActivation( activation );
}
- eventsupport.getAgendaEventSupport().fireAfterActivationFired( activation );
+ eventsupport.getAgendaEventSupport().fireAfterActivationFired( activation );
}
-
+
public void increaseActiveActivations() {
this.activeActivations++;
}
-
+
public void decreaseActiveActivations() {
- this.activeActivations--;
+ this.activeActivations--;
}
-
+
public void increaseDormantActivations() {
this.activeActivations--;
this.dormantActivations++;
}
-
+
public void decreaseDormantActivations() {
this.dormantActivations--;
}
-
+
public int getActiveActivations() {
return this.activeActivations;
}
-
+
public int getDormantActivations() {
return this.dormantActivations;
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/DefaultBetaConstraints.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -46,36 +46,36 @@
/**
*
*/
- 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 int indexed;
-
- private RuleBaseConfiguration conf;
+ private int indexed;
+ private RuleBaseConfiguration conf;
+
public DefaultBetaConstraints(final BetaNodeFieldConstraint[] constraints,
final RuleBaseConfiguration conf) {
- this.conf = conf;
+ this.conf = conf;
this.indexed = -1;
this.constraints = new LinkedList();
ContextEntry current = null;
- int depth = conf.getCompositeKeyDepth();
-
+ final int depth = conf.getCompositeKeyDepth();
+
// First create a LinkedList of constraints, with the indexed constraints first.
for ( int i = 0, length = constraints.length; i < length; i++ ) {
// Determine if this constraint is indexable
if ( isIndexable( constraints[i] ) ) {
- if ( depth >= 1 && indexed == -1 ) {
+ if ( depth >= 1 && this.indexed == -1 ) {
// first index, so just add to the front
this.constraints.insertAfter( null,
new LinkedListEntry( constraints[i] ) );
- indexed++;
- } else if ( depth >= this.indexed +1){ //this.indexed is zero based, so adjust
+ this.indexed++;
+ } else if ( depth >= this.indexed + 1 ) { //this.indexed is zero based, so adjust
// insert this index after the previous index
- this.constraints.insertAfter( findNode( indexed++ ),
+ this.constraints.insertAfter( findNode( this.indexed++ ),
new LinkedListEntry( constraints[i] ) );
}
} else {
@@ -86,7 +86,7 @@
// Now create the ContextEntries in the same order the constraints
for ( LinkedListEntry entry = (LinkedListEntry) this.constraints.getFirst(); entry != null; entry = (LinkedListEntry) entry.getNext() ) {
- BetaNodeFieldConstraint constraint = (BetaNodeFieldConstraint) entry.getObject();
+ final BetaNodeFieldConstraint constraint = (BetaNodeFieldConstraint) entry.getObject();
final ContextEntry context = constraint.getContextEntry();
if ( current == null ) {
current = context;
@@ -98,7 +98,7 @@
}
}
- private LinkedListEntry findNode(int pos) {
+ private LinkedListEntry findNode(final int pos) {
LinkedListEntry current = (LinkedListEntry) this.constraints.getFirst();
for ( int i = 0; i < pos; i++ ) {
current = (LinkedListEntry) current.getNext();
@@ -183,34 +183,34 @@
BetaMemory memory;
if ( this.indexed > 0 ) {
LinkedListEntry entry = (LinkedListEntry) this.constraints.getFirst();
- List list = new ArrayList();
-
+ final List list = new ArrayList();
+
for ( int pos = 0; pos < this.indexed; pos++ ) {
final Constraint constraint = (Constraint) entry.getObject();
final VariableConstraint variableConstraint = (VariableConstraint) constraint;
final FieldIndex index = new FieldIndex( variableConstraint.getFieldExtractor(),
variableConstraint.getRequiredDeclarations()[0],
- variableConstraint.getEvaluator());
+ variableConstraint.getEvaluator() );
list.add( index );
entry = (LinkedListEntry) entry.getNext();
}
-
- FieldIndex[] indexes = ( FieldIndex[] ) list.toArray( new FieldIndex[ list.size() ] );
+
+ final FieldIndex[] indexes = (FieldIndex[]) list.toArray( new FieldIndex[list.size()] );
TupleMemory tupleMemory;
- if ( conf.isIndexLeftBetaMemory() ) {
+ if ( this.conf.isIndexLeftBetaMemory() ) {
tupleMemory = new TupleIndexHashTable( indexes );
} else {
tupleMemory = new TupleHashTable();
}
FactHandleMemory factHandleMemory;
- if ( conf.isIndexRightBetaMemory() ) {
- factHandleMemory = new FactHandleIndexHashTable( indexes );
- } else {
+ if ( this.conf.isIndexRightBetaMemory() ) {
+ factHandleMemory = new FactHandleIndexHashTable( indexes );
+ } else {
factHandleMemory = new FactHashTable();
}
memory = new BetaMemory( tupleMemory,
- factHandleMemory );
+ factHandleMemory );
} else {
memory = new BetaMemory( new TupleHashTable(),
new FactHashTable() );
@@ -244,7 +244,7 @@
return true;
}
- if ( object == null || !( object instanceof DefaultBetaConstraints ) ) {
+ if ( object == null || !(object instanceof DefaultBetaConstraints) ) {
return false;
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/DefaultFactHandle.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -138,10 +138,10 @@
return this.shadowFact;
}
- public void setShadowFact(boolean shadowFact) {
- this.shadowFact = shadowFact;
- }
-
+ public void setShadowFact(final boolean shadowFact) {
+ this.shadowFact = shadowFact;
+ }
+
public Object getObject() {
return this.object;
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/DoubleBetaConstraints.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -55,29 +55,32 @@
private boolean indexed0;
private boolean indexed1;
-
+
private RuleBaseConfiguration conf;
-
- public DoubleBetaConstraints(final BetaNodeFieldConstraint[] constraints, RuleBaseConfiguration conf) {
- this.conf = conf;
- if (!conf.isIndexLeftBetaMemory() && !conf.isIndexRightBetaMemory()) {
+
+ public DoubleBetaConstraints(final BetaNodeFieldConstraint[] constraints,
+ final RuleBaseConfiguration conf) {
+ this.conf = conf;
+ if ( !conf.isIndexLeftBetaMemory() && !conf.isIndexRightBetaMemory() ) {
this.indexed0 = false;
this.indexed1 = false;
} else {
- int depth = conf.getCompositeKeyDepth();
+ final int depth = conf.getCompositeKeyDepth();
// Determine if this constraints are indexable
final boolean i0 = isIndexable( constraints[0] );
final boolean i1 = isIndexable( constraints[1] );
-
+
if ( depth >= 1 && i0 ) {
this.indexed0 = true;
}
-
+
if ( i1 ) {
- if ( depth >= 1 && !i0 ) {
+ if ( depth >= 1 && !i0 ) {
this.indexed0 = true;
- swap( constraints, 1, 0 );
+ swap( constraints,
+ 1,
+ 0 );
} else if ( depth >= 2 ) {
this.indexed1 = true;
}
@@ -90,13 +93,14 @@
this.constraint1 = constraints[1];
this.context1 = this.constraint1.getContextEntry();
}
-
- private void swap(BetaNodeFieldConstraint[] constraints, int p1, int p2) {
+
+ private void swap(final BetaNodeFieldConstraint[] constraints,
+ final int p1,
+ final int p2) {
final BetaNodeFieldConstraint temp = constraints[p2];
constraints[p2] = constraints[p1];
- constraints[p1] = temp;
+ constraints[p1] = temp;
}
-
private boolean isIndexable(final BetaNodeFieldConstraint constraint) {
if ( constraint instanceof VariableConstraint ) {
@@ -110,17 +114,23 @@
/* (non-Javadoc)
* @see org.drools.common.BetaNodeConstraints#updateFromTuple(org.drools.reteoo.ReteTuple)
*/
- public void updateFromTuple(final InternalWorkingMemory workingMemory, final ReteTuple tuple) {
- this.context0.updateFromTuple( workingMemory, tuple );
- this.context1.updateFromTuple( workingMemory, tuple );
+ public void updateFromTuple(final InternalWorkingMemory workingMemory,
+ final ReteTuple tuple) {
+ this.context0.updateFromTuple( workingMemory,
+ tuple );
+ this.context1.updateFromTuple( workingMemory,
+ tuple );
}
/* (non-Javadoc)
* @see org.drools.common.BetaNodeConstraints#updateFromFactHandle(org.drools.common.InternalFactHandle)
*/
- public void updateFromFactHandle(final InternalWorkingMemory workingMemory, final InternalFactHandle handle) {
- this.context0.updateFromFactHandle( workingMemory, handle );
- this.context1.updateFromFactHandle( workingMemory, handle );
+ public void updateFromFactHandle(final InternalWorkingMemory workingMemory,
+ final InternalFactHandle handle) {
+ this.context0.updateFromFactHandle( workingMemory,
+ handle );
+ this.context1.updateFromFactHandle( workingMemory,
+ handle );
}
/* (non-Javadoc)
@@ -138,7 +148,7 @@
public boolean isAllowedCachedRight(final ReteTuple tuple) {
return this.constraint0.isAllowedCachedRight( tuple,
this.context0 ) && this.constraint1.isAllowedCachedRight( tuple,
- this.context1 );
+ this.context1 );
}
public boolean isIndexed() {
@@ -156,8 +166,8 @@
if ( this.indexed0 ) {
final VariableConstraint variableConstraint = (VariableConstraint) this.constraint0;
final FieldIndex index = new FieldIndex( variableConstraint.getFieldExtractor(),
- variableConstraint.getRequiredDeclarations()[0],
- variableConstraint.getEvaluator());
+ variableConstraint.getRequiredDeclarations()[0],
+ variableConstraint.getEvaluator() );
list.add( index );
}
@@ -165,8 +175,8 @@
if ( this.indexed1 ) {
final VariableConstraint variableConstraint = (VariableConstraint) this.constraint1;
final FieldIndex index = new FieldIndex( variableConstraint.getFieldExtractor(),
- variableConstraint.getRequiredDeclarations()[0],
- variableConstraint.getEvaluator());
+ variableConstraint.getRequiredDeclarations()[0],
+ variableConstraint.getEvaluator() );
list.add( index );
}
@@ -174,20 +184,20 @@
final FieldIndex[] indexes = (FieldIndex[]) list.toArray( new FieldIndex[list.size()] );
TupleMemory tupleMemory;
- if ( conf.isIndexLeftBetaMemory() ) {
+ if ( this.conf.isIndexLeftBetaMemory() ) {
tupleMemory = new TupleIndexHashTable( indexes );
} else {
tupleMemory = new TupleHashTable();
}
FactHandleMemory factHandleMemory;
- if ( conf.isIndexRightBetaMemory() ) {
- factHandleMemory = new FactHandleIndexHashTable( indexes );
- } else {
+ if ( this.conf.isIndexRightBetaMemory() ) {
+ factHandleMemory = new FactHandleIndexHashTable( indexes );
+ } else {
factHandleMemory = new FactHashTable();
}
memory = new BetaMemory( tupleMemory,
- factHandleMemory );
+ factHandleMemory );
} else {
memory = new BetaMemory( new TupleHashTable(),
new FactHashTable() );
@@ -224,17 +234,17 @@
return true;
}
- if ( object == null || !( object instanceof DoubleBetaConstraints) ) {
+ if ( object == null || !(object instanceof DoubleBetaConstraints) ) {
return false;
}
final DoubleBetaConstraints other = (DoubleBetaConstraints) object;
- if ( this.constraint0 != other.constraint0 && ! this.constraint0.equals( other.constraint0 ) ) {
+ if ( this.constraint0 != other.constraint0 && !this.constraint0.equals( other.constraint0 ) ) {
return false;
}
- if ( this.constraint1 != other.constraint1 && ! this.constraint1.equals( other.constraint1 ) ) {
+ if ( this.constraint1 != other.constraint1 && !this.constraint1.equals( other.constraint1 ) ) {
return false;
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/EmptyBetaConstraints.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -46,13 +46,15 @@
/* (non-Javadoc)
* @see org.drools.common.BetaNodeConstraints#updateFromTuple(org.drools.reteoo.ReteTuple)
*/
- public void updateFromTuple(final InternalWorkingMemory workingMemory, final ReteTuple tuple) {
+ public void updateFromTuple(final InternalWorkingMemory workingMemory,
+ final ReteTuple tuple) {
}
/* (non-Javadoc)
* @see org.drools.common.BetaNodeConstraints#updateFromFactHandle(org.drools.common.InternalFactHandle)
*/
- public void updateFromFactHandle(final InternalWorkingMemory workingMemory, final InternalFactHandle handle) {
+ public void updateFromFactHandle(final InternalWorkingMemory workingMemory,
+ final InternalFactHandle handle) {
}
/* (non-Javadoc)
@@ -79,7 +81,7 @@
public BetaMemory createBetaMemory() {
final BetaMemory memory = new BetaMemory( new TupleHashTable(),
- new FactHashTable() );
+ new FactHashTable() );
return memory;
}
@@ -110,7 +112,7 @@
return true;
}
- return (object != null && ( object instanceof EmptyBetaConstraints ) );
+ return (object != null && (object instanceof EmptyBetaConstraints));
}
}
\ 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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/EqualityAssertMapComparator.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -28,7 +28,6 @@
*/
private static final long serialVersionUID = 320L;
-
public EqualityAssertMapComparator() {
}
@@ -57,10 +56,10 @@
return o1 == o2;
}
- InternalFactHandle handle = ((InternalFactHandle) o2);
-
- o2 = ( handle.isShadowFact() ) ? ((ShadowProxy) handle.getObject() ).getShadowedObject() : handle.getObject();
-
+ final InternalFactHandle handle = ((InternalFactHandle) o2);
+
+ o2 = (handle.isShadowFact()) ? ((ShadowProxy) handle.getObject()).getShadowedObject() : handle.getObject();
+
return o1 == o2 || o1.equals( o2 );
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/EqualityKey.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -147,7 +147,7 @@
return false;
}
- if ( object instanceof EqualityKey) {
+ if ( object instanceof EqualityKey ) {
return this == object;
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/IdentityAssertMapComparator.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -56,9 +56,9 @@
return ((InternalFactHandle) o1).getObject() == ((InternalFactHandle) o2).getObject();
}
- InternalFactHandle handle = ((InternalFactHandle) o2);
-
- return o1 == ( ( handle.isShadowFact() ) ? ((ShadowProxy) handle.getObject() ).getShadowedObject() : handle.getObject() );
+ final InternalFactHandle handle = ((InternalFactHandle) o2);
+
+ return o1 == ((handle.isShadowFact()) ? ((ShadowProxy) handle.getObject()).getShadowedObject() : handle.getObject());
}
public int compare(final Object o1,
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InstanceEqualsConstraint.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -93,13 +93,13 @@
ContextEntry {
private static final long serialVersionUID = 5841221599619051196L;
-
- public Object left;
- public Object right;
- private Column column;
- private ContextEntry entry;
+ public Object left;
+ public Object right;
+ private Column column;
+ private ContextEntry entry;
+
public InstanceEqualsConstraintContextEntry(final Column column) {
this.column = column;
}
@@ -112,11 +112,13 @@
this.entry = entry;
}
- public void updateFromTuple(final InternalWorkingMemory workingMemory, final ReteTuple tuple) {
+ public void updateFromTuple(final InternalWorkingMemory workingMemory,
+ final ReteTuple tuple) {
this.left = tuple.get( this.column.getOffset() ).getObject();
- }
+ }
- public void updateFromFactHandle(final InternalWorkingMemory workingMemory, final InternalFactHandle handle) {
+ public void updateFromFactHandle(final InternalWorkingMemory workingMemory,
+ 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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InstanceNotEqualsConstraint.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -76,7 +76,7 @@
return true;
}
- if ( object == null || !(object instanceof InstanceNotEqualsConstraint ) ) {
+ if ( object == null || !(object instanceof InstanceNotEqualsConstraint) ) {
return false;
}
@@ -89,11 +89,11 @@
ContextEntry {
private static final long serialVersionUID = -1229222687367782322L;
- public Object left;
- public Object right;
+ public Object left;
+ public Object right;
- private Column column;
- private ContextEntry entry;
+ private Column column;
+ private ContextEntry entry;
public InstanceNotEqualsConstraintContextEntry(final Column column) {
this.column = column;
@@ -107,11 +107,13 @@
this.entry = entry;
}
- public void updateFromTuple(final InternalWorkingMemory workingMemory, final ReteTuple tuple) {
+ public void updateFromTuple(final InternalWorkingMemory workingMemory,
+ final ReteTuple tuple) {
this.left = tuple.get( this.column.getOffset() ).getObject();
}
- public void updateFromFactHandle(final InternalWorkingMemory workingMemory, final InternalFactHandle handle) {
+ public void updateFromFactHandle(final InternalWorkingMemory workingMemory,
+ 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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalAgenda.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -19,17 +19,17 @@
public void scheduleItem(final ScheduledAgendaItem item);
public void addAgendaGroup(final AgendaGroup agendaGroup);
-
+
public void increaseActiveActivations();
-
+
public void decreaseActiveActivations();
-
+
public void increaseDormantActivations();
-
+
public void decreaseDormantActivations();
-
+
public int getActiveActivations();
-
+
public int getDormantActivations();
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalFactHandle.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -38,8 +38,8 @@
public void invalidate();
public int getObjectHashCode();
-
+
public boolean isShadowFact();
-
+
public void setShadowFact(boolean shadowFact);
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalRuleFlowGroup.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalRuleFlowGroup.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalRuleFlowGroup.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -3,12 +3,14 @@
import org.drools.spi.Activation;
import org.drools.spi.RuleFlowGroup;
-public interface InternalRuleFlowGroup extends RuleFlowGroup {
+public interface InternalRuleFlowGroup
+ extends
+ RuleFlowGroup {
void addActivation(Activation activation);
void removeActivation(Activation activation);
-
+
/**
* Activates or deactivates this <code>RuleFlowGroup</code>.
* When activating, all activations of this <code>RuleFlowGroup</code> are added
@@ -21,7 +23,7 @@
* its activations are not added to the agenda.
*/
void setActive(boolean active);
-
+
boolean isActive();
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalWorkingMemory.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,7 +1,5 @@
package org.drools.common;
-import java.util.Map;
-
import org.drools.FactException;
import org.drools.WorkingMemory;
import org.drools.event.AgendaEventSupport;
@@ -31,7 +29,7 @@
public void propagateQueuedActions();
public FactHandleFactory getFactHandleFactory();
-
+
public void removeLogicalDependencies(final Activation activation,
final PropagationContext context,
final Rule rule) throws FactException;
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/LogicalDependency.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/LogicalDependency.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/LogicalDependency.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -50,8 +50,8 @@
if ( this == object ) {
return true;
}
-
- if ( object == null || !(object instanceof LogicalDependency ) ) {
+
+ if ( object == null || !(object instanceof LogicalDependency) ) {
return false;
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/ObjectInputStreamWithLoader.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/ObjectInputStreamWithLoader.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/ObjectInputStreamWithLoader.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -10,20 +10,30 @@
import java.util.HashMap;
public class ObjectInputStreamWithLoader extends ObjectInputStream {
- private final ClassLoader classLoader;
-
+ private final ClassLoader classLoader;
+
/** table mapping primitive type names to corresponding class objects */
- private static final HashMap primClasses = new HashMap(8, 1.0F);
+ private static final HashMap primClasses = new HashMap( 8,
+ 1.0F );
static {
- primClasses.put("boolean", boolean.class);
- primClasses.put("byte", byte.class);
- primClasses.put("char", char.class);
- primClasses.put("short", short.class);
- primClasses.put("int", int.class);
- primClasses.put("long", long.class);
- primClasses.put("float", float.class);
- primClasses.put("double", double.class);
- primClasses.put("void", void.class);
+ primClasses.put( "boolean",
+ boolean.class );
+ primClasses.put( "byte",
+ byte.class );
+ primClasses.put( "char",
+ char.class );
+ primClasses.put( "short",
+ short.class );
+ primClasses.put( "int",
+ int.class );
+ primClasses.put( "long",
+ long.class );
+ primClasses.put( "float",
+ float.class );
+ primClasses.put( "double",
+ double.class );
+ primClasses.put( "void",
+ void.class );
}
public ObjectInputStreamWithLoader(final InputStream in,
@@ -40,10 +50,10 @@
} else {
final String name = desc.getName();
Class clazz = (Class) primClasses.get( name );
- if( clazz == null ) {
- try{
+ if ( clazz == null ) {
+ try {
clazz = this.classLoader.loadClass( name );
- } catch (ClassNotFoundException cnf) {
+ } catch ( final ClassNotFoundException cnf ) {
clazz = super.resolveClass( desc );
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/PropagationContextImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/PropagationContextImpl.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/PropagationContextImpl.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -16,10 +16,6 @@
* limitations under the License.
*/
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
import org.drools.reteoo.ReteTuple;
import org.drools.rule.Rule;
import org.drools.spi.Activation;
@@ -109,28 +105,31 @@
return this.dormantActivations;
}
- public void addRetractedTuple(Rule rule, ReteTuple tuple) {
+ public void addRetractedTuple(final Rule rule,
+ final ReteTuple tuple) {
if ( this.retracted == null ) {
this.retracted = new ObjectHashMap();
}
-
+
TupleHashTable tuples = (TupleHashTable) this.retracted.get( rule );
if ( tuples == null ) {
tuples = new TupleHashTable();
- this.retracted.put( rule, tuples );
+ this.retracted.put( rule,
+ tuples );
}
- tuples.add( tuple );
+ tuples.add( tuple );
}
-
- public ReteTuple removeRetractedTuple(Rule rule, ReteTuple tuple) {
- if ( this.retracted == null ) {
+
+ public ReteTuple removeRetractedTuple(final Rule rule,
+ final ReteTuple tuple) {
+ if ( this.retracted == null ) {
return null;
}
-
- TupleHashTable tuples = (TupleHashTable) this.retracted.get( rule );
- return tuples.remove( tuple );
+
+ final TupleHashTable tuples = (TupleHashTable) this.retracted.get( rule );
+ return tuples.remove( tuple );
}
-
+
public void clearRetractedTuples() {
this.retracted = null;
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/QuadroupleBetaConstraints.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/QuadroupleBetaConstraints.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/QuadroupleBetaConstraints.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -60,40 +60,40 @@
private boolean indexed0;
private boolean indexed1;
private boolean indexed2;
-
+
private RuleBaseConfiguration conf;
public QuadroupleBetaConstraints(final BetaNodeFieldConstraint[] constraints,
final RuleBaseConfiguration conf) {
- this.conf = conf;
- if (!conf.isIndexLeftBetaMemory() && !conf.isIndexRightBetaMemory()) {
+ this.conf = conf;
+ if ( !conf.isIndexLeftBetaMemory() && !conf.isIndexRightBetaMemory() ) {
this.indexed0 = false;
this.indexed1 = false;
this.indexed2 = false;
- } else {
- int depth = conf.getCompositeKeyDepth();
+ } else {
+ final int depth = conf.getCompositeKeyDepth();
// Determine if this constraints are indexable
final boolean i0 = isIndexable( constraints[0] );
final boolean i1 = isIndexable( constraints[1] );
final boolean i2 = isIndexable( constraints[2] );
final boolean i3 = isIndexable( constraints[3] );
-
- if ( depth >= 1 && i0 ) {
+
+ if ( depth >= 1 && i0 ) {
this.indexed0 = true;
}
-
+
if ( i1 ) {
if ( depth >= 1 && !this.indexed0 ) {
this.indexed0 = true;
swap( constraints,
1,
0 );
- } else if (depth >= 2 ) {
+ } else if ( depth >= 2 ) {
this.indexed1 = true;
}
}
-
+
if ( i2 ) {
if ( depth >= 1 && !this.indexed0 ) {
this.indexed0 = true;
@@ -109,19 +109,19 @@
this.indexed2 = true;
}
}
-
+
if ( i3 ) {
- if ( depth >= 1 && !this.indexed0 ) {
+ if ( depth >= 1 && !this.indexed0 ) {
this.indexed0 = true;
swap( constraints,
3,
0 );
- } else if ( depth >= 2 && this.indexed0 && !this.indexed1 ) {
+ } else if ( depth >= 2 && this.indexed0 && !this.indexed1 ) {
this.indexed1 = true;
swap( constraints,
3,
1 );
- } else if ( depth >= 3 && this.indexed0 && this.indexed1 && !this.indexed2 ) {
+ } else if ( depth >= 3 && this.indexed0 && this.indexed1 && !this.indexed2 ) {
this.indexed2 = true;
swap( constraints,
3,
@@ -131,7 +131,7 @@
}
}
}
-
+
this.constraint0 = constraints[0];
this.context0 = this.constraint0.getContextEntry();
@@ -145,9 +145,9 @@
this.context3 = this.constraint3.getContextEntry();
}
- private void swap(BetaNodeFieldConstraint[] constraints,
- int p1,
- int p2) {
+ private void swap(final BetaNodeFieldConstraint[] constraints,
+ final int p1,
+ final int p2) {
final BetaNodeFieldConstraint temp = constraints[p2];
constraints[p2] = constraints[p1];
constraints[p1] = temp;
@@ -237,7 +237,7 @@
final VariableConstraint variableConstraint = (VariableConstraint) this.constraint0;
final FieldIndex index = new FieldIndex( variableConstraint.getFieldExtractor(),
variableConstraint.getRequiredDeclarations()[0],
- variableConstraint.getEvaluator());
+ variableConstraint.getEvaluator() );
list.add( index );
}
@@ -246,7 +246,7 @@
final VariableConstraint variableConstraint = (VariableConstraint) this.constraint1;
final FieldIndex index = new FieldIndex( variableConstraint.getFieldExtractor(),
variableConstraint.getRequiredDeclarations()[0],
- variableConstraint.getEvaluator());
+ variableConstraint.getEvaluator() );
list.add( index );
}
@@ -254,27 +254,27 @@
final VariableConstraint variableConstraint = (VariableConstraint) this.constraint2;
final FieldIndex index = new FieldIndex( variableConstraint.getFieldExtractor(),
variableConstraint.getRequiredDeclarations()[0],
- variableConstraint.getEvaluator());
+ variableConstraint.getEvaluator() );
list.add( index );
}
if ( !list.isEmpty() ) {
final FieldIndex[] indexes = (FieldIndex[]) list.toArray( new FieldIndex[list.size()] );
TupleMemory tupleMemory;
- if ( conf.isIndexLeftBetaMemory() ) {
+ if ( this.conf.isIndexLeftBetaMemory() ) {
tupleMemory = new TupleIndexHashTable( indexes );
} else {
tupleMemory = new TupleHashTable();
}
FactHandleMemory factHandleMemory;
- if ( conf.isIndexRightBetaMemory() ) {
- factHandleMemory = new FactHandleIndexHashTable( indexes );
- } else {
+ if ( this.conf.isIndexRightBetaMemory() ) {
+ factHandleMemory = new FactHandleIndexHashTable( indexes );
+ } else {
factHandleMemory = new FactHashTable();
}
memory = new BetaMemory( tupleMemory,
- factHandleMemory );
+ factHandleMemory );
} else {
memory = new BetaMemory( new TupleHashTable(),
new FactHashTable() );
@@ -313,25 +313,25 @@
return true;
}
- if ( object == null || !(object instanceof QuadroupleBetaConstraints)) {
+ if ( object == null || !(object instanceof QuadroupleBetaConstraints) ) {
return false;
}
final QuadroupleBetaConstraints other = (QuadroupleBetaConstraints) object;
- if ( this.constraint0 != other.constraint0 && ! this.constraint0.equals( other.constraint0 ) ) {
+ if ( this.constraint0 != other.constraint0 && !this.constraint0.equals( other.constraint0 ) ) {
return false;
}
- if ( this.constraint1 != other.constraint1 && ! this.constraint1.equals( other.constraint1 ) ) {
+ if ( this.constraint1 != other.constraint1 && !this.constraint1.equals( other.constraint1 ) ) {
return false;
}
- if ( this.constraint2 != other.constraint2 && ! this.constraint2.equals( other.constraint2 ) ) {
+ if ( this.constraint2 != other.constraint2 && !this.constraint2.equals( other.constraint2 ) ) {
return false;
}
- if ( this.constraint3 != other.constraint3 && ! this.constraint3.equals( other.constraint3 ) ) {
+ if ( this.constraint3 != other.constraint3 && !this.constraint3.equals( other.constraint3 ) ) {
return false;
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/RuleFlowGroupImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/RuleFlowGroupImpl.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/RuleFlowGroupImpl.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,4 +1,5 @@
package org.drools.common;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -35,14 +36,16 @@
* @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
*
*/
-public class RuleFlowGroupImpl extends RuleFlowSequenceNodeInstance implements InternalRuleFlowGroup {
+public class RuleFlowGroupImpl extends RuleFlowSequenceNodeInstance
+ implements
+ InternalRuleFlowGroup {
private static final long serialVersionUID = 320L;
private final String name;
- private boolean active = false;
+ private boolean active = false;
private final LinkedList list;
- private boolean autoDeactivate = true;
+ private boolean autoDeactivate = true;
/**
* Construct a <code>RuleFlowGroupImpl</code> with the given name.
@@ -58,53 +61,53 @@
public String getName() {
return this.name;
}
-
- public void setActive(boolean active) {
- if (this.active == active) {
- return;
- }
- this.active = active;
- if (active) {
- triggerActivations();
- } else {
- LinkedListIterator it = this.list.iterator();
- for (RuleFlowGroupNode node = (RuleFlowGroupNode) it.next(); node != null; node = (RuleFlowGroupNode) it.next()) {
- Activation activation = node.getActivation();
+
+ public void setActive(final boolean active) {
+ if ( this.active == active ) {
+ return;
+ }
+ this.active = active;
+ if ( active ) {
+ triggerActivations();
+ } else {
+ final LinkedListIterator it = this.list.iterator();
+ for ( RuleFlowGroupNode node = (RuleFlowGroupNode) it.next(); node != null; node = (RuleFlowGroupNode) it.next() ) {
+ final Activation activation = node.getActivation();
activation.remove();
if ( activation.getActivationGroupNode() != null ) {
- activation.getActivationGroupNode().getActivationGroup().removeActivation( activation );
+ activation.getActivationGroupNode().getActivationGroup().removeActivation( activation );
}
}
- }
+ }
}
-
+
public boolean isActive() {
- return active;
+ return this.active;
}
-
+
public boolean isAutoDeactivate() {
- return autoDeactivate;
+ return this.autoDeactivate;
}
-
- public void setAutoDeactivate(boolean autoDeactivate) {
- this.autoDeactivate = autoDeactivate;
- if (autoDeactivate && active && list.isEmpty()) {
- active = false;
- }
+
+ public void setAutoDeactivate(final boolean autoDeactivate) {
+ this.autoDeactivate = autoDeactivate;
+ if ( autoDeactivate && this.active && this.list.isEmpty() ) {
+ this.active = false;
+ }
}
private void triggerActivations() {
// iterate all activations adding them to their AgendaGroups
- LinkedListIterator it = this.list.iterator();
- for (RuleFlowGroupNode node = (RuleFlowGroupNode) it.next(); node != null; node = (RuleFlowGroupNode) it.next()) {
- Activation activation = node.getActivation();
- ((AgendaGroupImpl) activation.getAgendaGroup()).add(activation);
+ final LinkedListIterator it = this.list.iterator();
+ for ( RuleFlowGroupNode node = (RuleFlowGroupNode) it.next(); node != null; node = (RuleFlowGroupNode) it.next() ) {
+ final Activation activation = node.getActivation();
+ ((AgendaGroupImpl) activation.getAgendaGroup()).add( activation );
}
}
public void clear() {
- LinkedListIterator it = this.list.iterator();
- for (RuleFlowGroupNode node = (RuleFlowGroupNode) it.next(); node != null; node = (RuleFlowGroupNode) it.next()) {
+ final LinkedListIterator it = this.list.iterator();
+ for ( RuleFlowGroupNode node = (RuleFlowGroupNode) it.next(); node != null; node = (RuleFlowGroupNode) it.next() ) {
node.getActivation().remove();
}
}
@@ -113,29 +116,30 @@
return this.list.size();
}
- public void addActivation(final Activation activation) {
- final RuleFlowGroupNode node = new RuleFlowGroupNode(activation, this);
- activation.setRuleFlowGroupNode(node);
- list.add( node );
-
- if ( active ) {
- ((AgendaGroupImpl) activation.getAgendaGroup()).add(activation);
+ public void addActivation(final Activation activation) {
+ final RuleFlowGroupNode node = new RuleFlowGroupNode( activation,
+ this );
+ activation.setRuleFlowGroupNode( node );
+ this.list.add( node );
+
+ if ( this.active ) {
+ ((AgendaGroupImpl) activation.getAgendaGroup()).add( activation );
}
}
public void removeActivation(final Activation activation) {
final RuleFlowGroupNode node = activation.getRuleFlowGroupNode();
- list.remove(node);
- activation.setActivationGroupNode(null);
- if (autoDeactivate) {
- if (list.isEmpty()) {
- this.active = false;
- // only trigger next node if this RuleFlowGroup was
- // triggered from inside a process instance
- if (getProcessInstance() != null) {
- triggerCompleted();
- }
- }
+ this.list.remove( node );
+ activation.setActivationGroupNode( null );
+ if ( this.autoDeactivate ) {
+ if ( this.list.isEmpty() ) {
+ this.active = false;
+ // only trigger next node if this RuleFlowGroup was
+ // triggered from inside a process instance
+ if ( getProcessInstance() != null ) {
+ triggerCompleted();
+ }
+ }
}
}
@@ -167,7 +171,7 @@
return this.name.hashCode();
}
- public void trigger(IRuleFlowNodeInstance parent) {
- setActive(true);
- }
+ public void trigger(final IRuleFlowNodeInstance parent) {
+ setActive( true );
+ }
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/RuleFlowGroupNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/RuleFlowGroupNode.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/RuleFlowGroupNode.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,4 +1,5 @@
package org.drools.common;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -20,9 +21,9 @@
public class RuleFlowGroupNode extends AbstractBaseLinkedListNode {
- private static final long serialVersionUID = -6507208076979260126L;
+ private static final long serialVersionUID = -6507208076979260126L;
- private Activation activation;
+ private Activation activation;
private InternalRuleFlowGroup ruleFlowGroup;
public RuleFlowGroupNode(final Activation activation,
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/ScheduledAgendaItem.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -70,7 +70,7 @@
private boolean activated;
- private ActivationGroupNode activationGroupNode;
+ private ActivationGroupNode activationGroupNode;
// ------------------------------------------------------------
// Constructors
@@ -89,7 +89,7 @@
final InternalAgenda agenda,
final PropagationContext context,
final Rule rule,
- final GroupElement subrule ) {
+ final GroupElement subrule) {
this.tuple = tuple;
this.context = context;
this.rule = rule;
@@ -186,19 +186,19 @@
public void setActivationGroupNode(final ActivationGroupNode activationGroupNode) {
this.activationGroupNode = activationGroupNode;
}
-
+
public RuleFlowGroupNode getRuleFlowGroupNode() {
return null;
}
- public void setRuleFlowGroupNode(RuleFlowGroupNode ruleFlowGroupNode) {
+ public void setRuleFlowGroupNode(final RuleFlowGroupNode ruleFlowGroupNode) {
throw new UnsupportedOperationException( "Scheduled activations cannot be in a Rule Flow Group" );
- }
+ }
public AgendaGroup getAgendaGroup() {
return null;
}
-
+
/*
* (non-Javadoc)
*
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/SingleBetaConstraints.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -18,7 +18,6 @@
import java.io.Serializable;
-import org.drools.RuleBase;
import org.drools.RuleBaseConfiguration;
import org.drools.base.evaluators.Operator;
import org.drools.reteoo.BetaMemory;
@@ -51,16 +50,16 @@
private ContextEntry context;
private boolean indexed;
-
+
private RuleBaseConfiguration conf;
public SingleBetaConstraints(final BetaNodeFieldConstraint constraint,
- RuleBaseConfiguration conf) {
+ final RuleBaseConfiguration conf) {
this.conf = conf;
if ( !conf.isIndexLeftBetaMemory() && !conf.isIndexRightBetaMemory() ) {
this.indexed = false;
} else {
- int depth = conf.getCompositeKeyDepth();
+ final int depth = conf.getCompositeKeyDepth();
// Determine if this constraint is indexable
this.indexed = depth >= 1 && isIndexable( constraint );
}
@@ -128,16 +127,16 @@
variableConstraint.getRequiredDeclarations()[0],
variableConstraint.getEvaluator() );
TupleMemory tupleMemory;
- if ( conf.isIndexLeftBetaMemory() ) {
+ if ( this.conf.isIndexLeftBetaMemory() ) {
tupleMemory = new TupleIndexHashTable( new FieldIndex[]{index} );
} else {
tupleMemory = new TupleHashTable();
}
FactHandleMemory factHandleMemory;
- if ( conf.isIndexRightBetaMemory() ) {
- factHandleMemory = new FactHandleIndexHashTable( new FieldIndex[]{index} );
- } else {
+ if ( this.conf.isIndexRightBetaMemory() ) {
+ factHandleMemory = new FactHandleIndexHashTable( new FieldIndex[]{index} );
+ } else {
factHandleMemory = new FactHashTable();
}
memory = new BetaMemory( tupleMemory,
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/TripleBetaConstraints.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -58,27 +58,28 @@
private boolean indexed0;
private boolean indexed1;
private boolean indexed2;
-
+
private RuleBaseConfiguration conf;
- public TripleBetaConstraints(final BetaNodeFieldConstraint[] constraints, RuleBaseConfiguration conf) {
- this.conf = conf;
- if (!conf.isIndexLeftBetaMemory() && !conf.isIndexRightBetaMemory()) {
+ public TripleBetaConstraints(final BetaNodeFieldConstraint[] constraints,
+ final RuleBaseConfiguration conf) {
+ this.conf = conf;
+ if ( !conf.isIndexLeftBetaMemory() && !conf.isIndexRightBetaMemory() ) {
this.indexed0 = false;
this.indexed1 = false;
this.indexed2 = false;
- } else {
- int depth = conf.getCompositeKeyDepth();
+ } else {
+ final int depth = conf.getCompositeKeyDepth();
// Determine if this constraints are indexable
final boolean i0 = isIndexable( constraints[0] );
final boolean i1 = isIndexable( constraints[1] );
final boolean i2 = isIndexable( constraints[2] );
-
+
if ( depth >= 1 && i0 ) {
this.indexed0 = true;
}
-
+
if ( i1 ) {
if ( depth >= 1 && !this.indexed0 ) {
this.indexed0 = true;
@@ -89,7 +90,7 @@
this.indexed1 = true;
}
}
-
+
if ( i2 ) {
if ( depth >= 1 && !this.indexed0 ) {
this.indexed0 = true;
@@ -101,7 +102,7 @@
swap( constraints,
2,
1 );
- } else if ( depth >= 3 ) {
+ } else if ( depth >= 3 ) {
this.indexed2 = true;
}
}
@@ -116,9 +117,9 @@
this.context2 = this.constraint2.getContextEntry();
}
- private void swap(BetaNodeFieldConstraint[] constraints,
- int p1,
- int p2) {
+ private void swap(final BetaNodeFieldConstraint[] constraints,
+ final int p1,
+ final int p2) {
final BetaNodeFieldConstraint temp = constraints[p2];
constraints[p2] = constraints[p1];
constraints[p1] = temp;
@@ -201,7 +202,7 @@
final VariableConstraint variableConstraint = (VariableConstraint) this.constraint0;
final FieldIndex index = new FieldIndex( variableConstraint.getFieldExtractor(),
variableConstraint.getRequiredDeclarations()[0],
- variableConstraint.getEvaluator());
+ variableConstraint.getEvaluator() );
list.add( index );
}
@@ -210,7 +211,7 @@
final VariableConstraint variableConstraint = (VariableConstraint) this.constraint1;
final FieldIndex index = new FieldIndex( variableConstraint.getFieldExtractor(),
variableConstraint.getRequiredDeclarations()[0],
- variableConstraint.getEvaluator());
+ variableConstraint.getEvaluator() );
list.add( index );
}
@@ -218,27 +219,27 @@
final VariableConstraint variableConstraint = (VariableConstraint) this.constraint2;
final FieldIndex index = new FieldIndex( variableConstraint.getFieldExtractor(),
variableConstraint.getRequiredDeclarations()[0],
- variableConstraint.getEvaluator());
+ variableConstraint.getEvaluator() );
list.add( index );
}
if ( !list.isEmpty() ) {
final FieldIndex[] indexes = (FieldIndex[]) list.toArray( new FieldIndex[list.size()] );
TupleMemory tupleMemory;
- if ( conf.isIndexLeftBetaMemory() ) {
+ if ( this.conf.isIndexLeftBetaMemory() ) {
tupleMemory = new TupleIndexHashTable( indexes );
} else {
tupleMemory = new TupleHashTable();
}
FactHandleMemory factHandleMemory;
- if ( conf.isIndexRightBetaMemory() ) {
- factHandleMemory = new FactHandleIndexHashTable( indexes );
- } else {
+ if ( this.conf.isIndexRightBetaMemory() ) {
+ factHandleMemory = new FactHandleIndexHashTable( indexes );
+ } else {
factHandleMemory = new FactHashTable();
}
memory = new BetaMemory( tupleMemory,
- factHandleMemory );
+ factHandleMemory );
} else {
memory = new BetaMemory( new TupleHashTable(),
new FactHashTable() );
@@ -282,15 +283,15 @@
final TripleBetaConstraints other = (TripleBetaConstraints) object;
- if ( this.constraint0 != other.constraint0 && ! this.constraint0.equals( other.constraint0 ) ) {
+ if ( this.constraint0 != other.constraint0 && !this.constraint0.equals( other.constraint0 ) ) {
return false;
}
- if ( this.constraint1 != other.constraint1 && ! this.constraint1.equals( other.constraint1 ) ) {
+ if ( this.constraint1 != other.constraint1 && !this.constraint1.equals( other.constraint1 ) ) {
return false;
}
- if ( this.constraint2 != other.constraint2 && ! this.constraint2.equals( other.constraint2 ) ) {
+ if ( this.constraint2 != other.constraint2 && !this.constraint2.equals( other.constraint2 ) ) {
return false;
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/TupleStartEqualsConstraint.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/TupleStartEqualsConstraint.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/TupleStartEqualsConstraint.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -46,17 +46,17 @@
public class TupleStartEqualsConstraint
implements
BetaNodeFieldConstraint {
-
- private static final long serialVersionUID = 7766998673828986129L;
-
- private final Declaration[] declarations = new Declaration[0];
-
- private static final TupleStartEqualsConstraint INSTANCE = new TupleStartEqualsConstraint();
+ private static final long serialVersionUID = 7766998673828986129L;
+
+ private final Declaration[] declarations = new Declaration[0];
+
+ private static final TupleStartEqualsConstraint INSTANCE = new TupleStartEqualsConstraint();
+
// this is a stateless constraint, so we can make it a singleton
private TupleStartEqualsConstraint() {
}
-
+
public static TupleStartEqualsConstraint getInstance() {
return INSTANCE;
}
@@ -72,13 +72,13 @@
public boolean isAllowedCachedLeft(final ContextEntry context,
final Object object) {
// object MUST be a ReteTuple
- ReteTuple tuple = ((ReteTuple)object).getSubTuple( ((TupleStartEqualsConstraintContextEntry) context).compareSize );
+ final ReteTuple tuple = ((ReteTuple) object).getSubTuple( ((TupleStartEqualsConstraintContextEntry) context).compareSize );
return ((TupleStartEqualsConstraintContextEntry) context).left.equals( tuple );
}
public boolean isAllowedCachedRight(final ReteTuple tuple,
final ContextEntry context) {
- return tuple.equals(((TupleStartEqualsConstraintContextEntry) context).right.getSubTuple( tuple.size() ));
+ return tuple.equals( ((TupleStartEqualsConstraintContextEntry) context).right.getSubTuple( tuple.size() ) );
}
public String toString() {
@@ -101,14 +101,14 @@
ContextEntry {
private static final long serialVersionUID = 5841221599619051196L;
-
- public ReteTuple left;
- public ReteTuple right;
-
+
+ public ReteTuple left;
+ public ReteTuple right;
+
// the size of the tuple to compare
- public int compareSize;
+ public int compareSize;
- private ContextEntry entry;
+ private ContextEntry entry;
public TupleStartEqualsConstraintContextEntry() {
}
@@ -121,12 +121,14 @@
this.entry = entry;
}
- public void updateFromTuple(final InternalWorkingMemory workingMemory, final ReteTuple tuple) {
+ public void updateFromTuple(final InternalWorkingMemory workingMemory,
+ final ReteTuple tuple) {
this.left = tuple;
this.compareSize = tuple.size();
- }
+ }
- public void updateFromFactHandle(final InternalWorkingMemory workingMemory, final InternalFactHandle handle) {
+ public void updateFromFactHandle(final InternalWorkingMemory workingMemory,
+ final InternalFactHandle handle) {
// if it is not a rete tuple, then there is a bug in the engine...
// it MUST be a rete tuple
this.right = (ReteTuple) handle.getObject();
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/conflict/TotalRecencyConflictResolver.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -19,7 +19,6 @@
import org.drools.reteoo.ReteTuple;
import org.drools.spi.Activation;
import org.drools.spi.ConflictResolver;
-import org.drools.spi.Tuple;
/**
* A conflict resolver that compares the total recency of a tuple when
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/event/AgendaEventListener.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/event/AgendaEventListener.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/event/AgendaEventListener.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -34,10 +34,10 @@
void afterActivationFired(AfterActivationFiredEvent event,
WorkingMemory workingMemory);
-
+
void agendaGroupPopped(AgendaGroupPoppedEvent event,
WorkingMemory workingMemory);
-
+
void agendaGroupPushed(AgendaGroupPushedEvent event,
- WorkingMemory workingMemory);
+ WorkingMemory workingMemory);
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/event/AgendaEventSupport.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/event/AgendaEventSupport.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/event/AgendaEventSupport.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -65,7 +65,7 @@
}
public void fireActivationCreated(final Activation activation,
- WorkingMemory workingMemory) {
+ final WorkingMemory workingMemory) {
if ( this.listeners.isEmpty() ) {
return;
}
@@ -79,7 +79,7 @@
}
public void fireActivationCancelled(final Activation activation,
- WorkingMemory workingMemory) {
+ final WorkingMemory workingMemory) {
if ( this.listeners.isEmpty() ) {
return;
}
@@ -93,7 +93,7 @@
}
public void fireBeforeActivationFired(final Activation activation,
- WorkingMemory workingMemory) {
+ final WorkingMemory workingMemory) {
if ( this.listeners.isEmpty() ) {
return;
}
@@ -115,33 +115,33 @@
for ( int i = 0, size = this.listeners.size(); i < size; i++ ) {
((AgendaEventListener) this.listeners.get( i )).afterActivationFired( event,
- workingMemory );
+ this.workingMemory );
}
}
-
- public void fireAgendaGroupPopped(AgendaGroup agendaGroup) {
+
+ public void fireAgendaGroupPopped(final AgendaGroup agendaGroup) {
if ( this.listeners.isEmpty() ) {
return;
}
- final AgendaGroupPoppedEvent event = new AgendaGroupPoppedEvent(agendaGroup);
+ final AgendaGroupPoppedEvent event = new AgendaGroupPoppedEvent( agendaGroup );
for ( int i = 0, size = this.listeners.size(); i < size; i++ ) {
((AgendaEventListener) this.listeners.get( i )).agendaGroupPopped( event,
- workingMemory );
- }
+ this.workingMemory );
+ }
}
-
- public void fireAgendaGroupPushed(AgendaGroup agendaGroup) {
+
+ public void fireAgendaGroupPushed(final AgendaGroup agendaGroup) {
if ( this.listeners.isEmpty() ) {
return;
}
- final AgendaGroupPushedEvent event = new AgendaGroupPushedEvent(agendaGroup);
+ final AgendaGroupPushedEvent event = new AgendaGroupPushedEvent( agendaGroup );
for ( int i = 0, size = this.listeners.size(); i < size; i++ ) {
((AgendaEventListener) this.listeners.get( i )).agendaGroupPushed( event,
- workingMemory );
- }
+ this.workingMemory );
+ }
}
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/event/DebugAgendaEventListener.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/event/DebugAgendaEventListener.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/event/DebugAgendaEventListener.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -26,32 +26,32 @@
}
public void activationCreated(final ActivationCreatedEvent event,
- WorkingMemory workingMemory) {
+ final WorkingMemory workingMemory) {
System.err.println( event );
}
public void activationCancelled(final ActivationCancelledEvent event,
- WorkingMemory workingMemory) {
+ final WorkingMemory workingMemory) {
System.err.println( event );
}
public void beforeActivationFired(final BeforeActivationFiredEvent event,
- WorkingMemory workingMemory) {
+ final WorkingMemory workingMemory) {
System.err.println( event );
}
public void afterActivationFired(final AfterActivationFiredEvent event,
- WorkingMemory workingMemory) {
+ final WorkingMemory workingMemory) {
System.err.println( event );
}
- public void agendaGroupPopped(AgendaGroupPoppedEvent event,
- WorkingMemory workingMemory) {
+ public void agendaGroupPopped(final AgendaGroupPoppedEvent event,
+ final WorkingMemory workingMemory) {
System.err.println( event );
}
- public void agendaGroupPushed(AgendaGroupPushedEvent event,
- WorkingMemory workingMemory) {
+ public void agendaGroupPushed(final AgendaGroupPushedEvent event,
+ final WorkingMemory workingMemory) {
System.err.println( event );
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/event/DefaultAgendaEventListener.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/event/DefaultAgendaEventListener.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/event/DefaultAgendaEventListener.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -26,32 +26,32 @@
}
public void activationCreated(final ActivationCreatedEvent event,
- WorkingMemory workingMemory) {
+ final WorkingMemory workingMemory) {
// intentionally left blank
}
public void activationCancelled(final ActivationCancelledEvent event,
- WorkingMemory workingMemory) {
+ final WorkingMemory workingMemory) {
// intentionally left blank
}
public void beforeActivationFired(final BeforeActivationFiredEvent event,
- WorkingMemory workingMemory) {
+ final WorkingMemory workingMemory) {
// intentionally left blank
}
public void afterActivationFired(final AfterActivationFiredEvent event,
- WorkingMemory workingMemory) {
+ final WorkingMemory workingMemory) {
// intentionally left blank
}
-
- public void agendaGroupPopped(AgendaGroupPoppedEvent event,
- WorkingMemory workingMemory) {
+
+ public void agendaGroupPopped(final AgendaGroupPoppedEvent event,
+ final WorkingMemory workingMemory) {
// intentionally left blank
}
- public void agendaGroupPushed(AgendaGroupPushedEvent event,
- WorkingMemory workingMemory) {
+ public void agendaGroupPushed(final AgendaGroupPushedEvent event,
+ final WorkingMemory workingMemory) {
// intentionally left blank
- }
+ }
}
\ No newline at end of file
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/facttemplates/FactTemplateFieldExtractor.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -27,7 +27,7 @@
public Object getValue(final Object object) {
return ((Fact) object).getFieldValue( this.fieldIndex );
}
-
+
public int getIndex() {
return this.fieldIndex;
}
@@ -67,16 +67,18 @@
public short getShortValue(final Object object) {
return ((Number) ((Fact) object).getFieldValue( this.fieldIndex )).shortValue();
}
-
+
public Method getNativeReadMethod() {
try {
- return this.getClass().getDeclaredMethod( "getValue", new Class[] { Object.class } );
- } catch ( Exception e ) {
- throw new RuntimeDroolsException("This is a bug. Please report to development team: "+e.getMessage(), e);
+ return this.getClass().getDeclaredMethod( "getValue",
+ new Class[]{Object.class} );
+ } catch ( final Exception e ) {
+ throw new RuntimeDroolsException( "This is a bug. Please report to development team: " + e.getMessage(),
+ e );
}
}
-
- public int getHashCode(Object object) {
+
+ public int getHashCode(final Object object) {
return getValue( object ).hashCode();
}
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/AccumulateNode.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -116,7 +116,7 @@
memory.getTupleMemory().add( leftTuple );
final List matchingObjects = new ArrayList();
-
+
final Iterator it = memory.getFactHandleMemory().iterator( leftTuple );
this.constraints.updateFromTuple( workingMemory,
leftTuple );
@@ -141,20 +141,21 @@
}
}
if ( isAllowed ) {
- this.resultBinder.updateFromTuple( workingMemory, leftTuple );
+ this.resultBinder.updateFromTuple( workingMemory,
+ leftTuple );
if ( this.resultBinder.isAllowedCachedLeft( result ) ) {
final InternalFactHandle handle = workingMemory.getFactHandleFactory().newFactHandle( result );
memory.getCreatedHandles().put( leftTuple,
handle,
false );
- sink.propagateAssertTuple( leftTuple,
+ this.sink.propagateAssertTuple( leftTuple,
handle,
context,
workingMemory );
}
}
-
+
}
/**
@@ -244,24 +245,23 @@
}
}
- public void updateSink(TupleSink sink,
- PropagationContext context,
- InternalWorkingMemory workingMemory) {
+ public void updateSink(final TupleSink sink,
+ final PropagationContext context,
+ final InternalWorkingMemory workingMemory) {
final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
-
+
final Iterator it = memory.getCreatedHandles().iterator();
- for ( ObjectEntry entry = (ObjectEntry) it.next(); entry != null; entry = (ObjectEntry) it.next()) {
- sink.assertTuple( new ReteTuple( (ReteTuple)entry.getKey(),
- (InternalFactHandle) entry.getValue()),
+ for ( ObjectEntry entry = (ObjectEntry) it.next(); entry != null; entry = (ObjectEntry) it.next() ) {
+ sink.assertTuple( new ReteTuple( (ReteTuple) entry.getKey(),
+ (InternalFactHandle) entry.getValue() ),
context,
workingMemory );
}
}
-
+
public String toString() {
return "[ " + this.getClass().getName() + "(" + this.id + ") ]";
}
-
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/AlphaNode.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -65,8 +65,8 @@
* @param objectSource
*/
public AlphaNode(final int id,
- final AlphaNodeFieldConstraint constraint,
- final ObjectSource objectSource) {
+ final AlphaNodeFieldConstraint constraint,
+ final ObjectSource objectSource) {
this( id,
constraint,
objectSource,
@@ -87,11 +87,13 @@
* @param hasMemory true if node shall be configured with local memory. False otherwise.
*/
public AlphaNode(final int id,
- final AlphaNodeFieldConstraint constraint,
- final ObjectSource objectSource,
- final boolean hasMemory,
- final int alphaNodeHashingThreshold) {
- super( id, objectSource, alphaNodeHashingThreshold );
+ final AlphaNodeFieldConstraint constraint,
+ final ObjectSource objectSource,
+ final boolean hasMemory,
+ final int alphaNodeHashingThreshold) {
+ super( id,
+ objectSource,
+ alphaNodeHashingThreshold );
this.constraint = constraint;
setHasMemory( hasMemory );
}
@@ -143,8 +145,8 @@
false );
}
this.sink.propagateAssertObject( handle,
- context,
- workingMemory );
+ context,
+ workingMemory );
}
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/BetaMemory.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -4,13 +4,15 @@
import org.drools.util.ObjectHashMap;
-public class BetaMemory implements Serializable {
+public class BetaMemory
+ implements
+ Serializable {
private static final long serialVersionUID = -4648029105678562600L;
- private TupleMemory tupleMemory;
- private FactHandleMemory factHandleMemory;
- private ObjectHashMap createdHandles;
+ private TupleMemory tupleMemory;
+ private FactHandleMemory factHandleMemory;
+ private ObjectHashMap createdHandles;
public BetaMemory(final TupleMemory tupleMemory,
final FactHandleMemory objectMemory) {
@@ -25,11 +27,11 @@
public TupleMemory getTupleMemory() {
return this.tupleMemory;
}
-
+
public ObjectHashMap getCreatedHandles() {
- if(createdHandles == null) {
- createdHandles = new ObjectHashMap();
+ if ( this.createdHandles == null ) {
+ this.createdHandles = new ObjectHashMap();
}
- return createdHandles;
+ return this.createdHandles;
}
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/BetaNode.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -223,10 +223,7 @@
final BetaNode other = (BetaNode) object;
- return this.getClass() == other.getClass() &&
- this.leftInput.equals( other.leftInput ) &&
- this.rightInput.equals( other.rightInput ) &&
- this.constraints.equals( other.constraints );
+ return this.getClass() == other.getClass() && this.leftInput.equals( other.leftInput ) && this.rightInput.equals( other.rightInput ) && this.constraints.equals( other.constraints );
}
/**
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/CollectNode.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -146,14 +146,15 @@
}
}
if ( isAllowed ) {
- this.resultsBinder.updateFromTuple( workingMemory, leftTuple );
+ this.resultsBinder.updateFromTuple( workingMemory,
+ leftTuple );
if ( this.resultsBinder.isAllowedCachedLeft( result ) ) {
final InternalFactHandle handle = workingMemory.getFactHandleFactory().newFactHandle( result );
memory.getCreatedHandles().put( leftTuple,
handle,
false );
- sink.propagateAssertTuple( leftTuple,
+ this.sink.propagateAssertTuple( leftTuple,
handle,
context,
workingMemory );
@@ -246,16 +247,16 @@
}
}
- public void updateSink(TupleSink sink,
- PropagationContext context,
- InternalWorkingMemory workingMemory) {
+ public void updateSink(final TupleSink sink,
+ final PropagationContext context,
+ final InternalWorkingMemory workingMemory) {
final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
-
+
final Iterator it = memory.getCreatedHandles().iterator();
- for ( ObjectEntry entry = (ObjectEntry) it.next(); entry != null; entry = (ObjectEntry) it.next()) {
- sink.assertTuple( new ReteTuple( (ReteTuple)entry.getKey(),
- (InternalFactHandle) entry.getValue()),
+ for ( ObjectEntry entry = (ObjectEntry) it.next(); entry != null; entry = (ObjectEntry) it.next() ) {
+ sink.assertTuple( new ReteTuple( (ReteTuple) entry.getKey(),
+ (InternalFactHandle) entry.getValue() ),
context,
workingMemory );
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/CompositeObjectSinkAdapter.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -25,29 +25,30 @@
implements
ObjectSinkPropagator {
-// /** You can override this property via a system property (eg -Ddrools.hashThreshold=4) */
-// public static final String HASH_THRESHOLD_SYSTEM_PROPERTY = "drools.hashThreshold";
-//
-// /** The threshold for when hashing kicks in */
-// public static final int THRESHOLD_TO_HASH = Integer.parseInt( System.getProperty( HASH_THRESHOLD_SYSTEM_PROPERTY,
-// "3" ) );
+ // /** You can override this property via a system property (eg -Ddrools.hashThreshold=4) */
+ // public static final String HASH_THRESHOLD_SYSTEM_PROPERTY = "drools.hashThreshold";
+ //
+ // /** The threshold for when hashing kicks in */
+ // public static final int THRESHOLD_TO_HASH = Integer.parseInt( System.getProperty( HASH_THRESHOLD_SYSTEM_PROPERTY,
+ // "3" ) );
- private static final long serialVersionUID = 320L;
- ObjectSinkNodeList otherSinks;
- ObjectSinkNodeList hashableSinks;
+ private static final long serialVersionUID = 320L;
+ ObjectSinkNodeList otherSinks;
+ ObjectSinkNodeList hashableSinks;
- LinkedList hashedFieldIndexes;
+ LinkedList hashedFieldIndexes;
- ObjectHashMap hashedSinkMap;
+ ObjectHashMap hashedSinkMap;
- private HashKey hashKey;
-
- private final int alphaNodeHashingThreshold;
+ private HashKey hashKey;
+ private final int alphaNodeHashingThreshold;
+
public CompositeObjectSinkAdapter() {
- this(3);
+ this( 3 );
}
- public CompositeObjectSinkAdapter(int alphaNodeHashingThreshold) {
+
+ public CompositeObjectSinkAdapter(final int alphaNodeHashingThreshold) {
this.hashKey = new HashKey();
this.alphaNodeHashingThreshold = alphaNodeHashingThreshold;
}
@@ -66,7 +67,7 @@
final FieldIndex fieldIndex = registerFieldIndex( index,
literalConstraint.getFieldExtractor() );
- if ( fieldIndex.getCount() >= alphaNodeHashingThreshold ) {
+ if ( fieldIndex.getCount() >= this.alphaNodeHashingThreshold ) {
if ( !fieldIndex.isHashed() ) {
hashSinks( fieldIndex );
}
@@ -110,9 +111,10 @@
final FieldIndex fieldIndex = unregisterFieldIndex( index );
if ( fieldIndex.isHashed() ) {
- this.hashKey.setValue( index, value );
+ this.hashKey.setValue( index,
+ value );
this.hashedSinkMap.remove( this.hashKey );
- if ( fieldIndex.getCount() <= alphaNodeHashingThreshold - 1 ) {
+ if ( fieldIndex.getCount() <= this.alphaNodeHashingThreshold - 1 ) {
// we have less than three so unhash
unHashSinks( fieldIndex );
}
@@ -174,19 +176,19 @@
public void unHashSinks(final FieldIndex fieldIndex) {
final int index = fieldIndex.getIndex();
- List sinks = new ArrayList();
+ final List sinks = new ArrayList();
//iterate twice as custom iterator is immutable
- Iterator mapIt = this.hashedSinkMap.iterator();
+ final Iterator mapIt = this.hashedSinkMap.iterator();
for ( ObjectHashMap.ObjectEntry e = (ObjectHashMap.ObjectEntry) mapIt.next(); e != null; ) {
sinks.add( e.getValue() );
e = (ObjectHashMap.ObjectEntry) mapIt.next();
}
- for ( java.util.Iterator iter = sinks.iterator(); iter.hasNext(); ) {
- AlphaNode sink = (AlphaNode) iter.next();
- final AlphaNode alphaNode = (AlphaNode) sink;
+ for ( final java.util.Iterator iter = sinks.iterator(); iter.hasNext(); ) {
+ final AlphaNode sink = (AlphaNode) iter.next();
+ final AlphaNode alphaNode = sink;
final AlphaNodeFieldConstraint fieldConstraint = alphaNode.getConstraint();
final LiteralConstraint literalConstraint = (LiteralConstraint) fieldConstraint;
final Evaluator evaluator = literalConstraint.getEvaluator();
@@ -287,7 +289,9 @@
// this field is hashed so set the existing hashKey and see if there is a sink for it
final int index = fieldIndex.getIndex();
final FieldExtractor extractor = fieldIndex.getFieldExtactor();
- this.hashKey.setValue( index, object, extractor );
+ this.hashKey.setValue( index,
+ object,
+ extractor );
final ObjectSink sink = (ObjectSink) this.hashedSinkMap.get( this.hashKey );
if ( sink != null ) {
// The sink exists so propagate
@@ -334,7 +338,9 @@
final int index = fieldIndex.getIndex();
final FieldExtractor extractor = fieldIndex.getFieldExtactor();
- this.hashKey.setValue( index, object, extractor );
+ this.hashKey.setValue( index,
+ object,
+ extractor );
final ObjectSink sink = (ObjectSink) this.hashedSinkMap.get( this.hashKey );
if ( sink != null ) {
// The sink exists so propagate
@@ -401,9 +407,9 @@
public int size() {
int size = 0;
- size += ((otherSinks != null) ? otherSinks.size() : 0);
- size += ((hashableSinks != null) ? hashableSinks.size() : 0);
- size += ((hashedSinkMap != null) ? hashedSinkMap.size() : 0);
+ size += ((this.otherSinks != null) ? this.otherSinks.size() : 0);
+ size += ((this.hashableSinks != null) ? this.hashableSinks.size() : 0);
+ size += ((this.hashedSinkMap != null) ? this.hashedSinkMap.size() : 0);
return size;
}
@@ -411,86 +417,92 @@
implements
Serializable {
private static final long serialVersionUID = 1949191240975565186L;
-
- private static final byte OBJECT = 1;
- private static final byte LONG = 2;
- private static final byte DOUBLE = 3;
- private static final byte BOOL = 4;
+ private static final byte OBJECT = 1;
+ private static final byte LONG = 2;
+ private static final byte DOUBLE = 3;
+ private static final byte BOOL = 4;
+
private int index;
-
+
private byte type;
private Object ovalue;
private long lvalue;
private boolean bvalue;
private double dvalue;
-
+
private int hashCode;
-
+
public HashKey() {
}
public HashKey(final int index,
- final FieldValue value ) {
- this.setValue( index, value );
+ final FieldValue value) {
+ this.setValue( index,
+ value );
}
public HashKey(final int index,
final Object value,
final Extractor extractor) {
- this.setValue( index, value, extractor );
+ this.setValue( index,
+ value,
+ extractor );
}
public int getIndex() {
return this.index;
}
- public void setValue(final int index, final Object value, final Extractor extractor) {
+ public void setValue(final int index,
+ final Object value,
+ final Extractor extractor) {
this.index = index;
- ValueType vtype = extractor.getValueType();
- if( vtype.isBoolean() ) {
+ final ValueType vtype = extractor.getValueType();
+ if ( vtype.isBoolean() ) {
this.bvalue = extractor.getBooleanValue( value );
this.type = BOOL;
this.setHashCode( this.bvalue ? 1231 : 1237 );
- } else if( vtype.isIntegerNumber() ) {
+ } else if ( vtype.isIntegerNumber() ) {
this.lvalue = extractor.getLongValue( value );
this.type = LONG;
- this.setHashCode( (int) ( this.lvalue ^ ( this.lvalue >>> 32 ) ) );
- } else if( vtype.isFloatNumber() ) {
+ this.setHashCode( (int) (this.lvalue ^ (this.lvalue >>> 32)) );
+ } else if ( vtype.isFloatNumber() ) {
this.dvalue = extractor.getDoubleValue( value );
this.type = DOUBLE;
- long temp = Double.doubleToLongBits( this.dvalue );
- this.setHashCode( (int) ( temp ^ ( temp >>> 32 )));
+ final long temp = Double.doubleToLongBits( this.dvalue );
+ this.setHashCode( (int) (temp ^ (temp >>> 32)) );
} else {
this.ovalue = extractor.getValue( value );
this.type = OBJECT;
this.setHashCode( this.ovalue.hashCode() );
}
}
-
- public void setValue(final int index, final FieldValue value) {
+
+ public void setValue(final int index,
+ final FieldValue value) {
this.index = index;
- if( value.isBooleanField() ) {
+ if ( value.isBooleanField() ) {
this.bvalue = value.getBooleanValue();
this.type = BOOL;
this.setHashCode( this.bvalue ? 1231 : 1237 );
- } else if( value.isIntegerNumberField() ) {
+ } else if ( value.isIntegerNumberField() ) {
this.lvalue = value.getLongValue();
this.type = LONG;
- this.setHashCode( (int) ( this.lvalue ^ ( this.lvalue >>> 32 ) ) );
- } else if( value.isFloatNumberField() ) {
+ this.setHashCode( (int) (this.lvalue ^ (this.lvalue >>> 32)) );
+ } else if ( value.isFloatNumberField() ) {
this.dvalue = value.getDoubleValue();
this.type = DOUBLE;
- long temp = Double.doubleToLongBits( this.dvalue );
- this.setHashCode( (int) ( temp ^ ( temp >>> 32 )));
+ final long temp = Double.doubleToLongBits( this.dvalue );
+ this.setHashCode( (int) (temp ^ (temp >>> 32)) );
} else {
this.ovalue = value.getValue();
this.type = OBJECT;
this.setHashCode( this.ovalue.hashCode() );
}
}
-
- private void setHashCode(int hashSeed) {
+
+ private void setHashCode(final int hashSeed) {
final int PRIME = 31;
int result = 1;
result = PRIME * result + hashSeed;
@@ -499,81 +511,81 @@
}
public boolean getBooleanValue() {
- switch( this.type ) {
- case BOOL:
+ switch ( this.type ) {
+ case BOOL :
return this.bvalue;
- case OBJECT:
- if( this.ovalue instanceof Boolean ) {
+ case OBJECT :
+ if ( this.ovalue instanceof Boolean ) {
return ((Boolean) this.ovalue).booleanValue();
- } else if( this.ovalue instanceof String ){
+ } else if ( this.ovalue instanceof String ) {
return Boolean.valueOf( (String) this.ovalue ).booleanValue();
} else {
- throw new ClassCastException( "Can't convert "+this.ovalue.getClass()+" to a boolean value.");
+ throw new ClassCastException( "Can't convert " + this.ovalue.getClass() + " to a boolean value." );
}
- case LONG:
- throw new ClassCastException( "Can't convert long to a boolean value.");
- case DOUBLE:
- throw new ClassCastException( "Can't convert double to a boolean value.");
-
+ case LONG :
+ throw new ClassCastException( "Can't convert long to a boolean value." );
+ case DOUBLE :
+ throw new ClassCastException( "Can't convert double to a boolean value." );
+
}
return false;
}
-
+
public long getLongValue() {
- switch( this.type ) {
- case BOOL:
+ switch ( this.type ) {
+ case BOOL :
return this.bvalue ? 1 : 0;
- case OBJECT:
- if( this.ovalue instanceof Number ) {
+ case OBJECT :
+ if ( this.ovalue instanceof Number ) {
return ((Number) this.ovalue).longValue();
- } else if( this.ovalue instanceof String ){
+ } else if ( this.ovalue instanceof String ) {
return Long.parseLong( (String) this.ovalue );
} else {
- throw new ClassCastException( "Can't convert "+this.ovalue.getClass()+" to a long value.");
+ throw new ClassCastException( "Can't convert " + this.ovalue.getClass() + " to a long value." );
}
- case LONG:
+ case LONG :
return this.lvalue;
- case DOUBLE:
+ case DOUBLE :
return (long) this.dvalue;
-
+
}
return 0;
}
-
+
public double getDoubleValue() {
- switch( this.type ) {
- case BOOL:
+ switch ( this.type ) {
+ case BOOL :
return this.bvalue ? 1 : 0;
- case OBJECT:
- if( this.ovalue instanceof Number ) {
+ case OBJECT :
+ if ( this.ovalue instanceof Number ) {
return ((Number) this.ovalue).doubleValue();
- } else if( this.ovalue instanceof String ){
+ } else if ( this.ovalue instanceof String ) {
return Double.parseDouble( (String) this.ovalue );
} else {
- throw new ClassCastException( "Can't convert "+this.ovalue.getClass()+" to a double value.");
+ throw new ClassCastException( "Can't convert " + this.ovalue.getClass() + " to a double value." );
}
- case LONG:
+ case LONG :
return this.lvalue;
- case DOUBLE:
+ case DOUBLE :
return this.dvalue;
}
return 0;
}
-
+
public Object getObjectValue() {
- switch( this.type ) {
- case BOOL:
+ switch ( this.type ) {
+ case BOOL :
return this.bvalue ? Boolean.TRUE : Boolean.FALSE;
- case OBJECT:
+ case OBJECT :
return this.ovalue;
- case LONG:
+ case LONG :
return new Long( this.lvalue );
- case DOUBLE:
+ case DOUBLE :
return new Double( this.dvalue );
}
return null;
}
-
+
public int hashCode() {
return this.hashCode;
}
@@ -581,19 +593,19 @@
public boolean equals(final Object object) {
final HashKey other = (HashKey) object;
- switch( this.type ) {
- case BOOL:
- return ( this.index == other.index ) && ( this.bvalue == other.getBooleanValue() );
- case LONG:
- return ( this.index == other.index ) && ( this.lvalue == other.getLongValue() );
- case DOUBLE:
- return ( this.index == other.index ) && ( this.dvalue == other.getDoubleValue() );
- case OBJECT:
- Object otherValue = other.getObjectValue();
- if( ( this.ovalue instanceof Number ) && ( otherValue instanceof Number )) {
- return ( this.index == other.index ) && ( ( ( Number ) this.ovalue ).doubleValue() == ( ( Number ) otherValue ).doubleValue() );
+ switch ( this.type ) {
+ case BOOL :
+ return (this.index == other.index) && (this.bvalue == other.getBooleanValue());
+ case LONG :
+ return (this.index == other.index) && (this.lvalue == other.getLongValue());
+ case DOUBLE :
+ return (this.index == other.index) && (this.dvalue == other.getDoubleValue());
+ case OBJECT :
+ final Object otherValue = other.getObjectValue();
+ if ( (this.ovalue instanceof Number) && (otherValue instanceof Number) ) {
+ return (this.index == other.index) && (((Number) this.ovalue).doubleValue() == ((Number) otherValue).doubleValue());
}
- return ( this.index == other.index ) && ( this.ovalue.equals( otherValue ) );
+ return (this.index == other.index) && (this.ovalue.equals( otherValue ));
}
return false;
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/EmptyObjectSinkAdapter.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/EmptyObjectSinkAdapter.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/EmptyObjectSinkAdapter.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -7,12 +7,12 @@
public class EmptyObjectSinkAdapter
implements
ObjectSinkPropagator {
- private static final EmptyObjectSinkAdapter instance = new EmptyObjectSinkAdapter();
-
- public static EmptyObjectSinkAdapter getInstance() {
- return instance;
- }
-
+ private static final EmptyObjectSinkAdapter instance = new EmptyObjectSinkAdapter();
+
+ public static EmptyObjectSinkAdapter getInstance() {
+ return instance;
+ }
+
private EmptyObjectSinkAdapter() {
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/EmptyTupleSinkAdapter.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/EmptyTupleSinkAdapter.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/EmptyTupleSinkAdapter.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -7,13 +7,13 @@
public class EmptyTupleSinkAdapter
implements
TupleSinkPropagator {
-
- private static final EmptyTupleSinkAdapter instance = new EmptyTupleSinkAdapter();
-
- public static final EmptyTupleSinkAdapter getInstance() {
- return instance;
- }
+ private static final EmptyTupleSinkAdapter instance = new EmptyTupleSinkAdapter();
+
+ public static final EmptyTupleSinkAdapter getInstance() {
+ return instance;
+ }
+
private EmptyTupleSinkAdapter() {
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/EvalConditionNode.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -59,10 +59,10 @@
/** The source of incoming <code>Tuples</code>. */
private final TupleSource tupleSource;
-
- private TupleSinkNode previousTupleSinkNode;
- private TupleSinkNode nextTupleSinkNode;
+ private TupleSinkNode previousTupleSinkNode;
+ private TupleSinkNode nextTupleSinkNode;
+
// ------------------------------------------------------------
// Constructors
// ------------------------------------------------------------
@@ -77,8 +77,8 @@
* @param eval
*/
public EvalConditionNode(final int id,
- final TupleSource tupleSource,
- final EvalCondition eval) {
+ final TupleSource tupleSource,
+ final EvalCondition eval) {
super( id );
this.condition = eval;
this.tupleSource = tupleSource;
@@ -157,8 +157,8 @@
final TupleHashTable memory = (TupleHashTable) workingMemory.getNodeMemory( this );
// can we improve that?
- ReteTuple memTuple = memory.remove( tuple );
- if ( memTuple != null ) {
+ final ReteTuple memTuple = memory.remove( tuple );
+ if ( memTuple != null ) {
this.sink.propagateRetractTuple( memTuple,
context,
workingMemory );
@@ -213,8 +213,8 @@
}
}
- public void remove(BaseNode node,
- InternalWorkingMemory[] workingMemories) {
+ public void remove(final BaseNode node,
+ final InternalWorkingMemory[] workingMemories) {
if ( !node.isInUse() ) {
removeTupleSink( (TupleSink) node );
}
@@ -229,7 +229,6 @@
}
-
/**
* Returns the next node
* @return
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ExistsNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ExistsNode.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ExistsNode.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -217,7 +217,7 @@
final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
// Must use the tuple in memory as it has the tuple matches count
- final ReteTuple tuple = (ReteTuple) memory.getTupleMemory().remove( leftTuple );
+ final ReteTuple tuple = memory.getTupleMemory().remove( leftTuple );
if ( tuple == null ) {
return;
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/FromNode.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -54,7 +54,7 @@
final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
memory.getTupleMemory().add( leftTuple );
- LinkedList list = new LinkedList();
+ final LinkedList list = new LinkedList();
this.betaConstraints.updateFromTuple( workingMemory,
leftTuple );
@@ -102,13 +102,13 @@
final InternalWorkingMemory workingMemory) {
final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
- ReteTuple tuple = (ReteTuple) memory.getTupleMemory().remove( leftTuple );
+ final ReteTuple tuple = memory.getTupleMemory().remove( leftTuple );
- LinkedList list = (LinkedList) memory.getCreatedHandles().remove( tuple );
+ final LinkedList list = (LinkedList) memory.getCreatedHandles().remove( tuple );
// if tuple was propagated
if ( list != null ) {
for ( LinkedListEntry entry = (LinkedListEntry) list.getFirst(); entry != null; entry = (LinkedListEntry) entry.getNext() ) {
- InternalFactHandle handle = (InternalFactHandle) entry.getObject();
+ final InternalFactHandle handle = (InternalFactHandle) entry.getObject();
this.sink.propagateRetractTuple( leftTuple,
handle,
context,
@@ -154,20 +154,20 @@
workingMemories );
}
- public void updateSink(TupleSink sink,
- PropagationContext context,
- InternalWorkingMemory workingMemory) {
+ public void updateSink(final TupleSink sink,
+ final PropagationContext context,
+ final InternalWorkingMemory workingMemory) {
final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
- Iterator tupleIter = memory.getTupleMemory().iterator();
+ final Iterator tupleIter = memory.getTupleMemory().iterator();
for ( ReteTuple tuple = (ReteTuple) tupleIter.next(); tuple != null; tuple = (ReteTuple) tupleIter.next() ) {
- LinkedList list = (LinkedList) memory.getCreatedHandles().remove( tuple );
+ final LinkedList list = (LinkedList) memory.getCreatedHandles().remove( tuple );
if ( list == null ) {
continue;
}
for ( LinkedListEntry entry = (LinkedListEntry) list.getFirst(); entry != null; entry = (LinkedListEntry) entry.getNext() ) {
- InternalFactHandle handle = (InternalFactHandle) entry.getObject();
+ final InternalFactHandle handle = (InternalFactHandle) entry.getObject();
this.sink.propagateRetractTuple( tuple,
handle,
context,
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/InitialFactImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/InitialFactImpl.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/InitialFactImpl.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -49,7 +49,7 @@
return true;
}
- if ( object == null || !(object instanceof InitialFactImpl ) ) {
+ if ( object == null || !(object instanceof InitialFactImpl) ) {
return false;
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/JoinNode.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -67,17 +67,17 @@
* The right input <code>TupleSource</code>.
*/
public JoinNode(final int id,
- final TupleSource leftInput,
- final ObjectSource rightInput) {
+ final TupleSource leftInput,
+ final ObjectSource rightInput) {
super( id,
leftInput,
rightInput );
}
public JoinNode(final int id,
- final TupleSource leftInput,
- final ObjectSource rightInput,
- final BetaConstraints binder) {
+ final TupleSource leftInput,
+ final ObjectSource rightInput,
+ final BetaConstraints binder) {
super( id,
leftInput,
rightInput,
@@ -109,14 +109,15 @@
memory.getTupleMemory().add( leftTuple );
final Iterator it = memory.getFactHandleMemory().iterator( leftTuple );
- this.constraints.updateFromTuple( workingMemory, leftTuple );
+ this.constraints.updateFromTuple( workingMemory,
+ leftTuple );
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 );
+ handle,
+ context,
+ workingMemory );
}
}
}
@@ -146,14 +147,15 @@
memory.getFactHandleMemory().add( handle );
- final Iterator it = memory.getTupleMemory().iterator(handle);
- this.constraints.updateFromFactHandle( workingMemory, handle );
+ final Iterator it = memory.getTupleMemory().iterator( handle );
+ this.constraints.updateFromFactHandle( workingMemory,
+ handle );
for ( ReteTuple tuple = (ReteTuple) it.next(); tuple != null; tuple = (ReteTuple) it.next() ) {
if ( this.constraints.isAllowedCachedRight( tuple ) ) {
this.sink.propagateAssertTuple( tuple,
- handle,
- context,
- workingMemory );
+ handle,
+ context,
+ workingMemory );
}
}
}
@@ -177,14 +179,15 @@
return;
}
- final Iterator it = memory.getTupleMemory().iterator(handle);
- this.constraints.updateFromFactHandle( workingMemory, handle );
+ final Iterator it = memory.getTupleMemory().iterator( handle );
+ this.constraints.updateFromFactHandle( workingMemory,
+ handle );
for ( ReteTuple tuple = (ReteTuple) it.next(); tuple != null; tuple = (ReteTuple) it.next() ) {
if ( this.constraints.isAllowedCachedRight( tuple ) ) {
this.sink.propagateRetractTuple( tuple,
- handle,
- context,
- workingMemory );
+ handle,
+ context,
+ workingMemory );
}
}
}
@@ -205,20 +208,21 @@
final PropagationContext context,
final InternalWorkingMemory workingMemory) {
final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
- final ReteTuple tuple = (ReteTuple) memory.getTupleMemory().remove( leftTuple );
+ final ReteTuple tuple = memory.getTupleMemory().remove( leftTuple );
if ( tuple == null ) {
return;
}
final Iterator it = memory.getFactHandleMemory().iterator( leftTuple );
- this.constraints.updateFromTuple( workingMemory, leftTuple );
+ this.constraints.updateFromTuple( workingMemory,
+ leftTuple );
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.propagateRetractTuple( leftTuple,
- handle,
- context,
- workingMemory );
+ handle,
+ context,
+ workingMemory );
}
}
}
@@ -235,7 +239,8 @@
final Iterator tupleIter = memory.getTupleMemory().iterator();
for ( ReteTuple tuple = (ReteTuple) tupleIter.next(); tuple != null; tuple = (ReteTuple) tupleIter.next() ) {
final Iterator objectIter = memory.getFactHandleMemory().iterator( tuple );
- this.constraints.updateFromTuple( workingMemory, tuple );
+ this.constraints.updateFromTuple( workingMemory,
+ tuple );
for ( FactEntry entry = (FactEntry) objectIter.next(); entry != null; entry = (FactEntry) objectIter.next() ) {
final InternalFactHandle handle = entry.getFactHandle();
if ( this.constraints.isAllowedCachedLeft( handle.getObject() ) ) {
@@ -250,7 +255,7 @@
public String toString() {
ObjectSource source = this.rightInput;
- while ( !(source instanceof ObjectTypeNode ) ) {
+ while ( !(source instanceof ObjectTypeNode) ) {
source = source.objectSource;
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/LeftInputAdapterNode.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -16,8 +16,6 @@
* limitations under the License.
*/
-import java.util.Map;
-
import org.drools.RuleBaseConfiguration;
import org.drools.common.BaseNode;
import org.drools.common.InternalFactHandle;
@@ -106,7 +104,6 @@
// return array;
// }
-
/* (non-Javadoc)
* @see org.drools.reteoo.BaseNode#attach()
*/
@@ -173,9 +170,9 @@
if ( this.hasMemory ) {
final FactHashTable memory = (FactHashTable) workingMemory.getNodeMemory( this );
propagate = memory.remove( handle );
- }
+ }
- if( propagate ) {
+ if ( propagate ) {
this.sink.createAndPropagateRetractTuple( handle,
context,
workingMemory );
@@ -190,8 +187,8 @@
final FactHashTable memory = (FactHashTable) workingMemory.getNodeMemory( this );
final Iterator it = memory.iterator();
for ( final FactEntry entry = (FactEntry) it.next(); entry != null; it.next() ) {
- final InternalFactHandle handle = (InternalFactHandle) entry.getFactHandle();
- sink.assertTuple( new ReteTuple(handle),
+ final InternalFactHandle handle = entry.getFactHandle();
+ sink.assertTuple( new ReteTuple( handle ),
context,
workingMemory );
}
@@ -263,7 +260,7 @@
return true;
}
- if ( object == null || !( object instanceof LeftInputAdapterNode ) ) {
+ if ( object == null || !(object instanceof LeftInputAdapterNode) ) {
return false;
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/MemoryVisitor.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -11,7 +11,6 @@
import org.drools.util.Iterator;
import org.drools.util.ObjectHashMap;
import org.drools.util.ReflectiveVisitor;
-import org.drools.util.TupleHashTable;
import org.drools.util.FactHandleIndexHashTable.FieldIndexEntry;
import org.drools.util.ObjectHashMap.ObjectEntry;
@@ -176,20 +175,20 @@
checkTupleMemory( memory.getTupleMemory() );
}
-// private void checkObjectHashMap(final ObjectHashMap map) {
-// final Entry[] entries = map.getTable();
-// int count = 0;
-// for ( int i = 0, length = entries.length; i < length; i++ ) {
-// if ( entries[i] != null ) {
-// count++;
-// }
-// }
-//
-// System.out.println( "ObjectHashMap: " + indent() + map.size() + ":" + count );
-// if ( map.size() != count ) {
-// System.out.println( indent() + "error" );
-// }
-// }
+ // private void checkObjectHashMap(final ObjectHashMap map) {
+ // final Entry[] entries = map.getTable();
+ // int count = 0;
+ // for ( int i = 0, length = entries.length; i < length; i++ ) {
+ // if ( entries[i] != null ) {
+ // count++;
+ // }
+ // }
+ //
+ // System.out.println( "ObjectHashMap: " + indent() + map.size() + ":" + count );
+ // if ( map.size() != count ) {
+ // System.out.println( indent() + "error" );
+ // }
+ // }
private void checkObjectHashTable(final FactHandleMemory memory) {
if ( memory instanceof FactHashTable ) {
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/NotNode.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -211,7 +211,7 @@
final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
// Must use the tuple in memory as it has the tuple matches count
- final ReteTuple tuple = (ReteTuple) memory.getTupleMemory().remove( leftTuple );
+ final ReteTuple tuple = memory.getTupleMemory().remove( leftTuple );
if ( tuple == null ) {
return;
}
@@ -243,7 +243,7 @@
public String toString() {
ObjectSource source = this.rightInput;
- while ( !(source instanceof ObjectTypeNode ) ) {
+ while ( !(source instanceof ObjectTypeNode) ) {
source = source.objectSource;
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectSink.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -30,7 +30,9 @@
* @author <a href="mailto:bob at werken.com">Bob McWhirter</a>
*
*/
-public interface ObjectSink extends Sink {
+public interface ObjectSink
+ extends
+ Sink {
/**
* Assert a new <code>FactHandleImpl</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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectSinkPropagator.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -6,7 +6,9 @@
import org.drools.common.InternalWorkingMemory;
import org.drools.spi.PropagationContext;
-public interface ObjectSinkPropagator extends Serializable {
+public interface ObjectSinkPropagator
+ extends
+ Serializable {
public void propagateAssertObject(InternalFactHandle handle,
PropagationContext context,
InternalWorkingMemory workingMemory);
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectSource.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -21,8 +21,6 @@
import org.drools.common.BaseNode;
import org.drools.common.DefaultFactHandle;
import org.drools.common.InternalWorkingMemory;
-import org.drools.rule.Declaration;
-import org.drools.spi.Constraint;
import org.drools.spi.PropagationContext;
/**
@@ -50,8 +48,8 @@
protected ObjectSource objectSource;
- private int alphaNodeHashingThreshold;
-
+ private int alphaNodeHashingThreshold;
+
// ------------------------------------------------------------
// Constructors
// ------------------------------------------------------------
@@ -64,7 +62,7 @@
ObjectSource(final int id) {
this( id,
null,
- 3 );
+ 3 );
}
/**
@@ -74,7 +72,7 @@
*/
ObjectSource(final int id,
final ObjectSource objectSource,
- int alphaNodeHashingThreshold) {
+ final int alphaNodeHashingThreshold) {
super( id );
this.objectSource = objectSource;
this.alphaNodeHashingThreshold = alphaNodeHashingThreshold;
@@ -98,7 +96,7 @@
if ( this.sink == EmptyObjectSinkAdapter.getInstance() ) {
this.sink = new SingleObjectSinkAdapter( objectSink );
} else if ( this.sink instanceof SingleObjectSinkAdapter ) {
- final CompositeObjectSinkAdapter sinkAdapter = new CompositeObjectSinkAdapter(alphaNodeHashingThreshold);
+ final CompositeObjectSinkAdapter sinkAdapter = new CompositeObjectSinkAdapter( this.alphaNodeHashingThreshold );
sinkAdapter.addObjectSink( this.sink.getSinks()[0] );
sinkAdapter.addObjectSink( objectSink );
this.sink = sinkAdapter;
@@ -114,19 +112,19 @@
* The <code>ObjectSink</code> to remove
*/
protected void removeObjectSink(final ObjectSink objectSink) {
- if ( this.sink == EmptyObjectSinkAdapter.getInstance() ){
- throw new IllegalArgumentException( "Cannot remove a sink, when the list of sinks is null" );
+ if ( this.sink == EmptyObjectSinkAdapter.getInstance() ) {
+ throw new IllegalArgumentException( "Cannot remove a sink, when the list of sinks is null" );
}
-
+
if ( this.sink instanceof SingleObjectSinkAdapter ) {
this.sink = EmptyObjectSinkAdapter.getInstance();
- } else {
- CompositeObjectSinkAdapter sinkAdapter = ( CompositeObjectSinkAdapter ) this.sink;
+ } else {
+ final CompositeObjectSinkAdapter sinkAdapter = (CompositeObjectSinkAdapter) this.sink;
sinkAdapter.removeObjectSink( objectSink );
if ( sinkAdapter.size() == 1 ) {
this.sink = new SingleObjectSinkAdapter( sinkAdapter.getSinks()[0] );
}
- }
+ }
}
public abstract void updateSink(ObjectSink sink,
@@ -136,5 +134,5 @@
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectTypeNode.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -73,10 +73,10 @@
private final ObjectType objectType;
/** The parent Rete node */
- private final Rete rete;
+ private final Rete rete;
- protected boolean skipOnModify = false;
-
+ protected boolean skipOnModify = false;
+
// ------------------------------------------------------------
// Constructors
// ------------------------------------------------------------
@@ -94,10 +94,12 @@
final ObjectType objectType,
final Rete rete,
final int alphaNodeHashingThreshold) {
- super( id, null, alphaNodeHashingThreshold );
+ super( id,
+ null,
+ alphaNodeHashingThreshold );
this.rete = rete;
this.objectType = objectType;
- setHasMemory( true );
+ setHasMemory( true );
}
// ------------------------------------------------------------
@@ -141,7 +143,7 @@
public void assertObject(final InternalFactHandle handle,
final PropagationContext context,
final InternalWorkingMemory workingMemory) {
- final FactHashTable memory = (FactHashTable) workingMemory.getNodeMemory( this );
+ final FactHashTable memory = (FactHashTable) workingMemory.getNodeMemory( this );
// checks if shadow is enabled
if ( this.objectType.isShadowEnabled() ) {
@@ -154,28 +156,29 @@
// we need to check if the shadow proxy matches the current object type
// because in a class hirarchy it may happen that the shadow proxy does not
// match a class down the hirarchy. See: JBRULES-696.
- if( this.objectType.matches( handle.getObject() ) ) {
+ if ( this.objectType.matches( handle.getObject() ) ) {
((ShadowProxy) handle.getObject()).updateProxy();
} else {
// replaces the old shadow proxy for a more specialized version of it
- ShadowProxy old = (ShadowProxy)handle.getObject();
+ final ShadowProxy old = (ShadowProxy) handle.getObject();
handle.setObject( this.objectType.getShadow( old.getShadowedObject() ) );
handle.setShadowFact( true );
// we MUST copy state from one proxy to the other as we are in a dynamic rules engine
// and new rules with different object types may be added at any moment
- ShadowProxyHelper.copyState( old, (ShadowProxy)handle.getObject() );
+ ShadowProxyHelper.copyState( old,
+ (ShadowProxy) handle.getObject() );
}
}
}
-
- if (context.getType() == PropagationContext.MODIFICATION && this.skipOnModify && context.getDormantActivations() == 0 ) {
+
+ if ( context.getType() == PropagationContext.MODIFICATION && this.skipOnModify && context.getDormantActivations() == 0 ) {
// we do this after the shadowproxy update, just so that its up to date for the future
return;
- }
+ }
memory.add( handle,
- false );
+ false );
this.sink.propagateAssertObject( handle,
context,
@@ -197,12 +200,12 @@
final PropagationContext context,
final InternalWorkingMemory workingMemory) {
- if (context.getType() == PropagationContext.MODIFICATION && this.skipOnModify && context.getDormantActivations() == 0 ) {
+ if ( context.getType() == PropagationContext.MODIFICATION && this.skipOnModify && context.getDormantActivations() == 0 ) {
return;
- }
-
+ }
+
final FactHashTable memory = (FactHashTable) workingMemory.getNodeMemory( this );
- memory.remove( handle );
+ memory.remove( handle );
this.sink.propagateRetractObject( handle,
context,
@@ -294,7 +297,7 @@
return true;
}
- if ( object == null || !(object instanceof ObjectTypeNode ) ) {
+ if ( object == null || !(object instanceof ObjectTypeNode) ) {
return false;
}
@@ -319,7 +322,6 @@
this.skipOnModify = canSkipOnModify( this.sink.getSinks() );
}
-
/**
* Checks if a modify action on this object type may
* be skipped because no constraint is applied to it
@@ -327,7 +329,7 @@
* @param sinks
* @return
*/
- private boolean canSkipOnModify( Sink[] sinks ) {
+ private boolean canSkipOnModify(final Sink[] sinks) {
// If we have no alpha or beta node with constraints on this ObjectType, we can just skip modifies
boolean hasConstraints = false;
for ( int i = 0; i < sinks.length && !hasConstraints; i++ ) {
@@ -335,31 +337,31 @@
hasConstraints = this.usesDeclaration( ((AlphaNode) sinks[i]).getConstraint() );
} else if ( sinks[i] instanceof BetaNode && ((BetaNode) sinks[i]).getConstraints().length > 0 ) {
hasConstraints = this.usesDeclaration( ((BetaNode) sinks[i]).getConstraints() );
- }
- if( !hasConstraints && sinks[i] instanceof ObjectSource ) {
- hasConstraints = this.canSkipOnModify( ((ObjectSource)sinks[i]).getSinkPropagator().getSinks() );
+ }
+ if ( !hasConstraints && sinks[i] instanceof ObjectSource ) {
+ hasConstraints = this.canSkipOnModify( ((ObjectSource) sinks[i]).getSinkPropagator().getSinks() );
} else if ( sinks[i] instanceof TupleSource ) {
- hasConstraints = this.canSkipOnModify( ((TupleSource)sinks[i]).getSinkPropagator().getSinks() );
+ hasConstraints = this.canSkipOnModify( ((TupleSource) sinks[i]).getSinkPropagator().getSinks() );
}
}
// Can only skip if we have no constraints
- return !hasConstraints;
+ return !hasConstraints;
}
-
- private boolean usesDeclaration( Constraint[] constraints ) {
+
+ private boolean usesDeclaration(final Constraint[] constraints) {
boolean usesDecl = false;
- for( int i = 0; !usesDecl && i < constraints.length; i++ ) {
+ for ( int i = 0; !usesDecl && i < constraints.length; i++ ) {
usesDecl = this.usesDeclaration( constraints[i] );
}
return usesDecl;
}
- private boolean usesDeclaration( Constraint constraint ) {
+ private boolean usesDeclaration(final Constraint constraint) {
boolean usesDecl = false;
- Declaration[] declarations = constraint.getRequiredDeclarations();
- for( int j = 0; !usesDecl && j < declarations.length; j++ ) {
- usesDecl = ( declarations[j].getColumn().getObjectType() == this.objectType );
+ final Declaration[] declarations = constraint.getRequiredDeclarations();
+ for ( int j = 0; !usesDecl && j < declarations.length; j++ ) {
+ usesDecl = (declarations[j].getColumn().getObjectType() == this.objectType);
}
return usesDecl;
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/QueryTerminalNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/QueryTerminalNode.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/QueryTerminalNode.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -168,7 +168,7 @@
* @return the subrule
*/
public GroupElement getSubrule() {
- return subrule;
+ return this.subrule;
}
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/Rete.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -142,11 +142,11 @@
ObjectTypeNode[] cachedNodes;
if ( object instanceof ShadowProxy ) {
- cachedNodes = (ObjectTypeNode[]) memory.get( object.getClass().getSuperclass() );
+ cachedNodes = (ObjectTypeNode[]) memory.get( object.getClass().getSuperclass() );
} else {
- cachedNodes = (ObjectTypeNode[]) memory.get( object.getClass() );
+ cachedNodes = (ObjectTypeNode[]) memory.get( object.getClass() );
}
-
+
// cached might have been cleared, so recalculate matching nodes
if ( cachedNodes == null ) {
cachedNodes = getMatchingNodes( object );
@@ -239,7 +239,7 @@
return true;
}
- if ( object == null || !( object instanceof Rete ) ) {
+ if ( object == null || !(object instanceof Rete) ) {
return false;
}
@@ -252,12 +252,12 @@
final InternalWorkingMemory workingMemory) {
// JBRULES-612: the cache MUST be invalidated when a new
// node type is added to the network
- ObjectHashMap memory = (ObjectHashMap) workingMemory.getNodeMemory( this );
+ final ObjectHashMap memory = (ObjectHashMap) workingMemory.getNodeMemory( this );
memory.clear();
-
+
final ObjectTypeNode node = (ObjectTypeNode) sink;
- Iterator it = workingMemory.getFactHandleMap().iterator();
- for ( ObjectEntry entry = ( ObjectEntry ) it.next(); entry != null; entry = ( ObjectEntry ) it.next() ) {
+ final Iterator it = workingMemory.getFactHandleMap().iterator();
+ for ( ObjectEntry entry = (ObjectEntry) it.next(); entry != null; entry = (ObjectEntry) it.next() ) {
final InternalFactHandle handle = (InternalFactHandle) entry.getValue();
if ( node.matches( handle.getObject() ) ) {
node.assertObject( handle,
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteTuple.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -160,7 +160,7 @@
}
// A ReteTuple is only the same if it has the same hashCode, factId and parent
- if (( other == null ) || ( this.hashCode != other.hashCode )) {
+ if ( (other == null) || (this.hashCode != other.hashCode) ) {
return false;
}
@@ -181,9 +181,9 @@
}
public int size() {
- return this.index+1;
+ return this.index + 1;
}
-
+
/**
* Returns the ReteTuple that contains the "elements"
* first elements in this tuple.
@@ -199,11 +199,11 @@
* @return a ReteTuple containing the "elements" first elements
* of this tuple or null if "elements" is greater than size;
*/
- public ReteTuple getSubTuple( int elements ) {
+ public ReteTuple getSubTuple(final int elements) {
ReteTuple entry = this;
- if( elements < this.size() ) {
- int lastindex = elements-1;
-
+ if ( elements < this.size() ) {
+ final int lastindex = elements - 1;
+
while ( entry.index != lastindex ) {
entry = entry.parent;
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteooBuilder.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -59,7 +59,7 @@
private Map rules;
private transient ReteooRuleBuilder ruleBuilder;
-
+
private IdGenerator idGenerator;
// ------------------------------------------------------------
@@ -76,7 +76,7 @@
this.rules = new HashMap();
//Set to 1 as Rete node is set to 0
- this.idGenerator = new IdGenerator(1);
+ this.idGenerator = new IdGenerator( 1 );
this.ruleBuilder = new ReteooRuleBuilder();
}
@@ -112,8 +112,10 @@
* @throws InvalidPatternException
*/
void addRule(final Rule rule) throws InvalidPatternException {
- List terminals = this.ruleBuilder.addRule( rule, this.ruleBase, this.attachedNodes, this.idGenerator );
-
+ final List terminals = this.ruleBuilder.addRule( rule,
+ this.ruleBase,
+ this.attachedNodes,
+ this.idGenerator );
this.rules.put( rule,
terminals.toArray( new BaseNode[terminals.size()] ) );
@@ -136,26 +138,27 @@
this.workingMemories );
}
}
-
- public static class IdGenerator implements Serializable {
+ public static class IdGenerator
+ implements
+ Serializable {
+
private static final long serialVersionUID = -5909710713463187779L;
- private int nextId;
-
- public IdGenerator( int firstId ) {
+ private int nextId;
+
+ public IdGenerator(final int firstId) {
this.nextId = firstId;
}
-
+
public int getNextId() {
return this.nextId++;
}
-
+
public void releaseLastId() {
this.nextId--;
}
-
+
}
-
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteooRuleBase.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -248,8 +248,10 @@
protected void removeRule(final Rule rule) {
this.reteooBuilder.removeRule( rule );
}
-
- private static class InitialFactHandleDummyObject implements Serializable {
+
+ private static class InitialFactHandleDummyObject
+ implements
+ Serializable {
private static final long serialVersionUID = 1L;
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteooWorkingMemory.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -85,17 +85,17 @@
List list = null;
if ( node == null ) {
- org.drools.rule.Package[] pkgs = this.ruleBase.getPackages();
- for( int i = 0; i < pkgs.length; i++ ) {
- Rule rule = pkgs[i].getRule( query );
- if( ( rule != null ) && ( rule instanceof Query ) ) {
+ final org.drools.rule.Package[] pkgs = this.ruleBase.getPackages();
+ for ( int i = 0; i < pkgs.length; i++ ) {
+ final Rule rule = pkgs[i].getRule( query );
+ if ( (rule != null) && (rule instanceof Query) ) {
queryObj = (Query) rule;
break;
}
}
retractObject( handle );
- if( queryObj == null ) {
- throw new IllegalArgumentException("Query '"+query+"' does not exist");
+ if ( queryObj == null ) {
+ throw new IllegalArgumentException( "Query '" + query + "' does not exist" );
}
list = Collections.EMPTY_LIST;
} else {
@@ -151,9 +151,9 @@
public void propagate() {
final PropagationContext context = new PropagationContextImpl( ReteooWorkingMemory.this.propagationIdCounter++,
- PropagationContext.ASSERTION,
- this.ruleOrigin,
- this.activationOrigin );
+ PropagationContext.ASSERTION,
+ this.ruleOrigin,
+ this.activationOrigin );
ReteooWorkingMemory.this.ruleBase.assertObject( this.factHandle,
this.factHandle.getObject(),
context,
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/RightInputAdapterNode.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -65,7 +65,7 @@
/**
* Creates and return the node memory
*/
- public Object createMemory(RuleBaseConfiguration config) {
+ public Object createMemory(final RuleBaseConfiguration config) {
return new ObjectHashMap();
}
@@ -84,7 +84,7 @@
final PropagationContext context,
final InternalWorkingMemory workingMemory) {
- ObjectHashMap memory = (ObjectHashMap) workingMemory.getNodeMemory( this );
+ final ObjectHashMap memory = (ObjectHashMap) workingMemory.getNodeMemory( this );
// creating a dummy fact handle to wrap the tuple
final InternalFactHandle handle = workingMemory.getFactHandleFactory().newFactHandle( tuple );
@@ -106,7 +106,7 @@
final PropagationContext context,
final InternalWorkingMemory workingMemory) {
- ObjectHashMap memory = (ObjectHashMap) workingMemory.getNodeMemory( this );
+ final ObjectHashMap memory = (ObjectHashMap) workingMemory.getNodeMemory( this );
// retrieve handle from memory
final InternalFactHandle handle = (InternalFactHandle) memory.remove( tuple );
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/RuleTerminalNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/RuleTerminalNode.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/RuleTerminalNode.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -139,8 +139,8 @@
//check if the rule is effective
if ( !this.rule.isEffective() ) {
return;
- }
-
+ }
+
// if the current Rule is no-loop and the origin rule is the same and its the same set of facts (tuple) then return
if ( context.getType() == PropagationContext.MODIFICATION ) {
if ( this.rule.getNoLoop() && this.rule.equals( context.getRuleOrigin() ) && context.getActivationOrigin().getTuple().equals( tuple ) ) {
@@ -148,7 +148,7 @@
}
} else if ( this.rule.getNoLoop() && this.rule.equals( context.getRuleOrigin() ) ) {
return;
- }
+ }
//we only have to clone the head fact to make sure the graph is not affected during consequence reads after a modify
final ReteTuple cloned = new ReteTuple( tuple );
@@ -234,14 +234,15 @@
// do not add the activation if the rule is "lock-on-active" and the AgendaGroup is active
// we must check the context to determine if its a new tuple or an exist re-activated tuple as part of the retract
if ( context.getType() == PropagationContext.MODIFICATION ) {
- if ( this.rule.isLockOnActive() && agendaGroup.isActivate() && context.removeRetractedTuple( this.rule, tuple ) == null ) {
+ if ( this.rule.isLockOnActive() && agendaGroup.isActivate() && context.removeRetractedTuple( this.rule,
+ tuple ) == null ) {
// This rule is locked and active, do not allow new tuples to activate
return;
}
} else if ( this.rule.isLockOnActive() && agendaGroup.isActivate() ) {
return;
}
-
+
agendaGroup.add( item );
} else {
//There is a RuleFlowNode so add it there, instead of the Agenda
@@ -254,18 +255,19 @@
// do not add the activation if the rule is "lock-on-active" and the RuleFlowGroup is active
// we must check the context to determine if its a new tuple or an exist re-activated tuple as part of the retract
if ( context.getType() == PropagationContext.MODIFICATION ) {
- if ( this.rule.isLockOnActive() && memory.getRuleFlowGroup().isActive() && context.removeRetractedTuple( this.rule, tuple ) == null ) {
+ if ( this.rule.isLockOnActive() && memory.getRuleFlowGroup().isActive() && context.removeRetractedTuple( this.rule,
+ tuple ) == null ) {
// This rule is locked and active, do not allow new tuples to activate
return;
}
- } else if ( this.rule.isLockOnActive() && memory.getRuleFlowGroup().isActive() ) {
+ } else if ( this.rule.isLockOnActive() && memory.getRuleFlowGroup().isActive() ) {
return;
- }
-
+ }
+
((InternalRuleFlowGroup) memory.getRuleFlowGroup()).addActivation( item );
-
- }
+ }
+
tuple.setActivation( item );
memory.getTupleMemory().add( tuple );
@@ -285,23 +287,24 @@
final PropagationContext context,
final InternalWorkingMemory workingMemory) {
final TerminalNodeMemory memory = (TerminalNodeMemory) workingMemory.getNodeMemory( this );
- final ReteTuple tuple = (ReteTuple) memory.getTupleMemory().remove( leftTuple );
+ final ReteTuple tuple = memory.getTupleMemory().remove( leftTuple );
if ( tuple == null ) {
- // tuple should only be null if it was asserted and reached a no-loop causing it to exit early
+ // tuple should only be null if it was asserted and reached a no-loop causing it to exit early
// before being added to the node memory and an activation created and attached
- return;
- }
-
+ return;
+ }
+
final Activation activation = tuple.getActivation();
if ( activation.isActivated() ) {
if ( this.rule.isLockOnActive() && context.getType() == PropagationContext.MODIFICATION ) {
- context.addRetractedTuple( this.rule, tuple );
+ context.addRetractedTuple( this.rule,
+ tuple );
}
-
+
activation.remove();
if ( activation.getActivationGroupNode() != null ) {
- activation.getActivationGroupNode().getActivationGroup().removeActivation( activation );
+ activation.getActivationGroupNode().getActivationGroup().removeActivation( activation );
}
if ( activation.getRuleFlowGroupNode() != null ) {
@@ -357,7 +360,7 @@
final TerminalNodeMemory memory = (TerminalNodeMemory) workingMemory.getNodeMemory( this );
final Iterator it = memory.getTupleMemory().iterator();
for ( ReteTuple tuple = (ReteTuple) it.next(); tuple != null; tuple = (ReteTuple) it.next() ) {
- final Activation activation = (Activation) tuple.getActivation();
+ final Activation activation = tuple.getActivation();
if ( activation.isActivated() ) {
activation.remove();
@@ -476,10 +479,10 @@
}
public RuleFlowGroup getRuleFlowGroup() {
- return ruleFlowGroup;
+ return this.ruleFlowGroup;
}
- public void setRuleFlowGroup(RuleFlowGroup ruleFlowGroup) {
+ public void setRuleFlowGroup(final RuleFlowGroup ruleFlowGroup) {
this.ruleFlowGroup = ruleFlowGroup;
}
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/TupleSink.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -32,7 +32,8 @@
*/
interface TupleSink
extends
- Serializable, Sink {
+ Serializable,
+ Sink {
/**
* Assert a new <code>ReteTuple</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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/TupleSinkPropagator.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -6,7 +6,9 @@
import org.drools.common.InternalWorkingMemory;
import org.drools.spi.PropagationContext;
-public interface TupleSinkPropagator extends Serializable {
+public interface TupleSinkPropagator
+ extends
+ Serializable {
public void propagateAssertTuple(ReteTuple tuple,
InternalFactHandle handle,
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/TupleSource.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -91,10 +91,10 @@
* The <code>TupleSink</code> to remove
*/
protected void removeTupleSink(final TupleSink tupleSink) {
- if ( this.sink == EmptyTupleSinkAdapter.getInstance()){
- throw new IllegalArgumentException( "Cannot remove a sink, when the list of sinks is null" );
+ if ( this.sink == EmptyTupleSinkAdapter.getInstance() ) {
+ throw new IllegalArgumentException( "Cannot remove a sink, when the list of sinks is null" );
}
-
+
if ( this.sink instanceof SingleTupleSinkAdapter ) {
this.sink = EmptyTupleSinkAdapter.getInstance();
} else {
@@ -109,7 +109,7 @@
public TupleSinkPropagator getSinkPropagator() {
return this.sink;
}
-
+
public abstract void updateSink(TupleSink sink,
PropagationContext context,
InternalWorkingMemory workingMemory);
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/AccumulateBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/AccumulateBuilder.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/AccumulateBuilder.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -41,15 +41,15 @@
/**
* @inheritDoc
*/
- public void build(BuildContext context,
- BuildUtils utils,
- RuleConditionElement rce) {
- Accumulate accumulate = (Accumulate) rce;
+ public void build(final BuildContext context,
+ final BuildUtils utils,
+ final RuleConditionElement rce) {
+ final Accumulate accumulate = (Accumulate) rce;
final Column sourceColumn = accumulate.getSourceColumn();
// get builder for the column
- ReteooComponentBuilder builder = utils.getBuilderFor( sourceColumn );
+ final ReteooComponentBuilder builder = utils.getBuilderFor( sourceColumn );
// builds the source column
builder.build( context,
@@ -100,8 +100,8 @@
/**
* @inheritDoc
*/
- public boolean requiresLeftActivation(BuildUtils utils,
- RuleConditionElement rce) {
+ public boolean requiresLeftActivation(final BuildUtils utils,
+ final RuleConditionElement rce) {
return true;
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/BuildContext.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/BuildContext.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/BuildContext.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -88,13 +88,13 @@
* @return the currentColumnOffset
*/
public int getCurrentColumnOffset() {
- return currentColumnOffset;
+ return this.currentColumnOffset;
}
/**
* @param currentColumnOffset the currentColumnOffset to set
*/
- public void setCurrentColumnOffset(int currentColumnIndex) {
+ public void setCurrentColumnOffset(final int currentColumnIndex) {
this.currentColumnOffset = currentColumnIndex;
}
@@ -102,13 +102,13 @@
* @return the objectSource
*/
public ObjectSource getObjectSource() {
- return objectSource;
+ return this.objectSource;
}
/**
* @param objectSource the objectSource to set
*/
- public void setObjectSource(ObjectSource objectSource) {
+ public void setObjectSource(final ObjectSource objectSource) {
this.objectSource = objectSource;
}
@@ -116,13 +116,13 @@
* @return the objectType
*/
public Map getObjectType() {
- return objectType;
+ return this.objectType;
}
/**
* @param objectType the objectType to set
*/
- public void setObjectType(Map objectType) {
+ public void setObjectType(final Map objectType) {
this.objectType = objectType;
}
@@ -130,13 +130,13 @@
* @return the tupleSource
*/
public TupleSource getTupleSource() {
- return tupleSource;
+ return this.tupleSource;
}
/**
* @param tupleSource the tupleSource to set
*/
- public void setTupleSource(TupleSource tupleSource) {
+ public void setTupleSource(final TupleSource tupleSource) {
this.tupleSource = tupleSource;
}
@@ -155,7 +155,7 @@
* @param candidate
* @return
*/
- public BaseNode getNodeFromCache(BaseNode candidate) {
+ public BaseNode getNodeFromCache(final BaseNode candidate) {
return (BaseNode) this.attachedNodes.get( candidate );
}
@@ -163,7 +163,7 @@
* Adds given node to node cache
* @param candidate
*/
- public void addNodeToCache(BaseNode node) {
+ public void addNodeToCache(final BaseNode node) {
this.attachedNodes.put( node,
node );
}
@@ -205,7 +205,7 @@
* Adds the rce to the build stack
* @param rce
*/
- public void push(RuleConditionElement rce) {
+ public void push(final RuleConditionElement rce) {
this.buildstack.addLast( rce );
}
@@ -237,13 +237,13 @@
* @return the betaconstraints
*/
public BetaConstraints getBetaconstraints() {
- return betaconstraints;
+ return this.betaconstraints;
}
/**
* @param betaconstraints the betaconstraints to set
*/
- public void setBetaconstraints(BetaConstraints betaconstraints) {
+ public void setBetaconstraints(final BetaConstraints betaconstraints) {
this.betaconstraints = betaconstraints;
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/BuildUtils.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/BuildUtils.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/BuildUtils.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -44,7 +44,7 @@
*/
public class BuildUtils {
- private Map componentBuilders = new HashMap();
+ private final Map componentBuilders = new HashMap();
/**
* Adds the given builder for the given target to the builders map
@@ -52,8 +52,8 @@
* @param target
* @param builder
*/
- public void addBuilder(Class target,
- ReteooComponentBuilder builder) {
+ public void addBuilder(final Class target,
+ final ReteooComponentBuilder builder) {
this.componentBuilders.put( target,
builder );
}
@@ -64,7 +64,7 @@
* @param target
* @return returns null if not found
*/
- public ReteooComponentBuilder getBuilderFor(RuleConditionElement target) {
+ public ReteooComponentBuilder getBuilderFor(final RuleConditionElement target) {
return (ReteooComponentBuilder) this.componentBuilders.get( target.getClass() );
}
@@ -83,7 +83,7 @@
public BaseNode attachNode(final BuildContext context,
final BaseNode candidate) {
// checks if node is in the cache
- BaseNode node = (BaseNode) context.getNodeFromCache( candidate );
+ BaseNode node = context.getNodeFromCache( candidate );
// if node sharing is enabled and node was found in the cache
if ( (node != null) && isSharingEnabledForNode( context,
@@ -124,8 +124,8 @@
* @param node
* @return
*/
- private boolean isSharingEnabledForNode(BuildContext context,
- BaseNode node) {
+ private boolean isSharingEnabledForNode(final BuildContext context,
+ final BaseNode node) {
if ( node instanceof TupleSource ) {
return context.getRuleBase().getConfiguration().isShareBetaNodes();
} else if ( node instanceof ObjectSource ) {
@@ -182,10 +182,10 @@
final Declaration[] declarations) throws InvalidPatternException {
final List list = new ArrayList();
for ( int i = 0, length = declarations.length; i < length; i++ ) {
- for ( ListIterator it = context.stackIterator(); it.hasPrevious(); ) {
- RuleConditionElement rce = (RuleConditionElement) it.previous();
- Declaration decl = rce.resolveDeclaration( declarations[i].getIdentifier() );
- if ( decl == null || decl.getColumn().getOffset() > declarations[i].getColumn().getOffset()) {
+ for ( final ListIterator it = context.stackIterator(); it.hasPrevious(); ) {
+ final RuleConditionElement rce = (RuleConditionElement) it.previous();
+ final Declaration decl = rce.resolveDeclaration( declarations[i].getIdentifier() );
+ if ( decl == null || decl.getColumn().getOffset() > declarations[i].getColumn().getOffset() ) {
list.add( declarations[i].getIdentifier() );
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/CollectBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/CollectBuilder.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/CollectBuilder.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -41,16 +41,16 @@
/**
* @inheritDoc
*/
- public void build(BuildContext context,
- BuildUtils utils,
- RuleConditionElement rce) {
+ public void build(final BuildContext context,
+ final BuildUtils utils,
+ final RuleConditionElement rce) {
- Collect collect = (Collect) rce;
+ final Collect collect = (Collect) rce;
final Column sourceColumn = collect.getSourceColumn();
// get builder for the column
- ReteooComponentBuilder builder = utils.getBuilderFor( sourceColumn );
+ final ReteooComponentBuilder builder = utils.getBuilderFor( sourceColumn );
// builds the source column
builder.build( context,
@@ -101,8 +101,8 @@
/**
* @inheritDoc
*/
- public boolean requiresLeftActivation(BuildUtils utils,
- RuleConditionElement rce) {
+ public boolean requiresLeftActivation(final BuildUtils utils,
+ final RuleConditionElement rce) {
return true;
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/ColumnBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/ColumnBuilder.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/ColumnBuilder.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -46,15 +46,15 @@
/**
* @inheritDoc
*/
- public void build(BuildContext context,
- BuildUtils utils,
- RuleConditionElement rce) {
+ public void build(final BuildContext context,
+ final BuildUtils utils,
+ final RuleConditionElement rce) {
- Column column = (Column) rce;
+ final Column column = (Column) rce;
context.setBetaconstraints( this.attachColumn( context,
utils,
- (Column) column ) );
+ column ) );
}
@@ -64,7 +64,7 @@
// Set column offset to the appropriate value
column.setOffset( context.getCurrentColumnOffset() );
-
+
context.incrementCurrentColumnOffset();
// Attach alpha nodes
@@ -107,7 +107,7 @@
}
final Constraint constraint = (Constraint) object;
- Declaration[] declarations = constraint.getRequiredDeclarations();
+ final Declaration[] declarations = constraint.getRequiredDeclarations();
boolean isAlphaConstraint = true;
for ( int i = 0; isAlphaConstraint && i < declarations.length; i++ ) {
@@ -148,13 +148,13 @@
final Class previousClass = ((ClassObjectType) entry.getKey()).getClassType();
if ( thisClass.isAssignableFrom( previousClass ) ) {
columns = (List) entry.getValue();
- for( Iterator columnsIt = columns.iterator(); columnsIt.hasNext(); ) {
+ for ( final Iterator columnsIt = columns.iterator(); columnsIt.hasNext(); ) {
betaConstraints.add( new InstanceNotEqualsConstraint( (Column) columnsIt.next() ) );
}
}
}
columns = (List) context.getObjectType().get( column.getObjectType() );
- if( columns == null ) {
+ if ( columns == null ) {
columns = new ArrayList();
}
columns.add( column );
@@ -168,7 +168,8 @@
/**
* @inheritDoc
*/
- public boolean requiresLeftActivation( BuildUtils utils, RuleConditionElement rce ) {
+ public boolean requiresLeftActivation(final BuildUtils utils,
+ final RuleConditionElement rce) {
return false;
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/EvalBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/EvalBuilder.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/EvalBuilder.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -32,9 +32,9 @@
/**
* @inheritDoc
*/
- public void build(BuildContext context,
- BuildUtils utils,
- RuleConditionElement rce) {
+ public void build(final BuildContext context,
+ final BuildUtils utils,
+ final RuleConditionElement rce) {
final EvalCondition eval = (EvalCondition) rce;
utils.checkUnboundDeclarations( context,
@@ -49,8 +49,8 @@
/**
* @inheritDoc
*/
- public boolean requiresLeftActivation(BuildUtils utils,
- RuleConditionElement rce) {
+ public boolean requiresLeftActivation(final BuildUtils utils,
+ final RuleConditionElement rce) {
return true;
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/ForallBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/ForallBuilder.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/ForallBuilder.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -36,36 +36,36 @@
/**
* @inheritDoc
*/
- public void build(BuildContext context,
- BuildUtils utils,
- RuleConditionElement rce) {
- Forall forall = (Forall) rce;
-
+ public void build(final BuildContext context,
+ final BuildUtils utils,
+ final RuleConditionElement rce) {
+ final Forall forall = (Forall) rce;
+
// forall can be translated into
// not( baseColumn and not( <remaining_columns>+ ) )
// so we just do that:
-
- GroupElement and = GroupElementFactory.newAndInstance();
+
+ final GroupElement and = GroupElementFactory.newAndInstance();
and.addChild( forall.getBaseColumn() );
-
- GroupElement not2 = GroupElementFactory.newNotInstance();
- if( forall.getRemainingColumns().size() == 1 ) {
+
+ final GroupElement not2 = GroupElementFactory.newNotInstance();
+ if ( forall.getRemainingColumns().size() == 1 ) {
not2.addChild( (Column) forall.getRemainingColumns().get( 0 ) );
and.addChild( not2 );
- } else if( forall.getRemainingColumns().size() > 1 ) {
- GroupElement and2 = GroupElementFactory.newAndInstance();
- for( Iterator it = forall.getRemainingColumns().iterator(); it.hasNext(); ) {
+ } else if ( forall.getRemainingColumns().size() > 1 ) {
+ final GroupElement and2 = GroupElementFactory.newAndInstance();
+ for ( final Iterator it = forall.getRemainingColumns().iterator(); it.hasNext(); ) {
and2.addChild( (Column) it.next() );
}
not2.addChild( and2 );
and.addChild( not2 );
}
- GroupElement not = GroupElementFactory.newNotInstance();
+ final GroupElement not = GroupElementFactory.newNotInstance();
not.addChild( and );
// get builder for the CEs
- ReteooComponentBuilder builder = utils.getBuilderFor( not );
+ final ReteooComponentBuilder builder = utils.getBuilderFor( not );
// builds the CEs
builder.build( context,
@@ -73,12 +73,11 @@
not );
}
-
/**
* @inheritDoc
*/
- public boolean requiresLeftActivation(BuildUtils utils,
- RuleConditionElement rce) {
+ public boolean requiresLeftActivation(final BuildUtils utils,
+ final RuleConditionElement rce) {
return true;
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/FromBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/FromBuilder.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/FromBuilder.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -41,13 +41,13 @@
/* (non-Javadoc)
* @see org.drools.reteoo.builder.ReteooComponentBuilder#build(org.drools.reteoo.builder.BuildContext, org.drools.reteoo.builder.BuildUtils, org.drools.rule.RuleConditionElement)
*/
- public void build(BuildContext context,
- BuildUtils utils,
- RuleConditionElement rce) {
- From from = (From) rce;
+ public void build(final BuildContext context,
+ final BuildUtils utils,
+ final RuleConditionElement rce) {
+ final From from = (From) rce;
final Column column = from.getColumn();
-
+
// setting and incrementing column offset as appropriate
column.setOffset( context.getCurrentColumnOffset() );
context.incrementCurrentColumnOffset();
@@ -89,8 +89,8 @@
/**
* @inheritDoc
*/
- public boolean requiresLeftActivation(BuildUtils utils,
- RuleConditionElement rce) {
+ public boolean requiresLeftActivation(final BuildUtils utils,
+ final RuleConditionElement rce) {
return true;
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/GroupElementBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/GroupElementBuilder.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/GroupElementBuilder.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -43,28 +43,28 @@
implements
ReteooComponentBuilder {
- private Map geBuilders = new HashMap();
+ private final Map geBuilders = new HashMap();
public GroupElementBuilder() {
- geBuilders.put( GroupElement.AND,
+ this.geBuilders.put( GroupElement.AND,
new AndBuilder() );
- geBuilders.put( GroupElement.OR,
+ this.geBuilders.put( GroupElement.OR,
new OrBuilder() );
- geBuilders.put( GroupElement.NOT,
+ this.geBuilders.put( GroupElement.NOT,
new NotBuilder() );
- geBuilders.put( GroupElement.EXISTS,
+ this.geBuilders.put( GroupElement.EXISTS,
new ExistsBuilder() );
}
/**
* @inheritDoc
*/
- public void build(BuildContext context,
- BuildUtils utils,
- RuleConditionElement rce) {
- GroupElement ge = (GroupElement) rce;
+ public void build(final BuildContext context,
+ final BuildUtils utils,
+ final RuleConditionElement rce) {
+ final GroupElement ge = (GroupElement) rce;
- ReteooComponentBuilder builder = (ReteooComponentBuilder) geBuilders.get( ge.getType() );
+ final ReteooComponentBuilder builder = (ReteooComponentBuilder) this.geBuilders.get( ge.getType() );
builder.build( context,
utils,
@@ -74,11 +74,11 @@
/**
* @inheritDoc
*/
- public boolean requiresLeftActivation(BuildUtils utils,
- RuleConditionElement rce) {
- GroupElement ge = (GroupElement) rce;
+ public boolean requiresLeftActivation(final BuildUtils utils,
+ final RuleConditionElement rce) {
+ final GroupElement ge = (GroupElement) rce;
- ReteooComponentBuilder builder = (ReteooComponentBuilder) geBuilders.get( ge.getType() );
+ final ReteooComponentBuilder builder = (ReteooComponentBuilder) this.geBuilders.get( ge.getType() );
return builder.requiresLeftActivation( utils,
rce );
@@ -95,18 +95,18 @@
* selecting and calling the build procedure for each one
*
*/
- public void build(BuildContext context,
- BuildUtils utils,
- RuleConditionElement rce) {
+ public void build(final BuildContext context,
+ final BuildUtils utils,
+ final RuleConditionElement rce) {
- GroupElement ge = (GroupElement) rce;
+ final GroupElement ge = (GroupElement) rce;
// iterate over each child and build it
- for ( Iterator it = ge.getChildren().iterator(); it.hasNext(); ) {
+ for ( final Iterator it = ge.getChildren().iterator(); it.hasNext(); ) {
- RuleConditionElement child = (RuleConditionElement) it.next();
+ final RuleConditionElement child = (RuleConditionElement) it.next();
- ReteooComponentBuilder builder = utils.getBuilderFor( child );
+ final ReteooComponentBuilder builder = utils.getBuilderFor( child );
builder.build( context,
utils,
@@ -136,9 +136,9 @@
}
}
- public boolean requiresLeftActivation(BuildUtils utils,
- RuleConditionElement rce) {
- GroupElement and = (GroupElement) rce;
+ public boolean requiresLeftActivation(final BuildUtils utils,
+ final RuleConditionElement rce) {
+ final GroupElement and = (GroupElement) rce;
// need to check this because in the case of an empty rule, the root AND
// will have no child
@@ -146,8 +146,8 @@
return true;
}
- RuleConditionElement child = (RuleConditionElement) and.getChildren().get( 0 );
- ReteooComponentBuilder builder = utils.getBuilderFor( child );
+ final RuleConditionElement child = (RuleConditionElement) and.getChildren().get( 0 );
+ final ReteooComponentBuilder builder = utils.getBuilderFor( child );
return builder.requiresLeftActivation( utils,
child );
@@ -161,14 +161,14 @@
/**
* @inheritDoc
*/
- public void build(BuildContext context,
- BuildUtils utils,
- RuleConditionElement rce) {
+ public void build(final BuildContext context,
+ final BuildUtils utils,
+ final RuleConditionElement rce) {
throw new RuntimeDroolsException( "BUG: Can't build a rete network with an inner OR group element" );
}
- public boolean requiresLeftActivation(BuildUtils utils,
- RuleConditionElement rce) {
+ public boolean requiresLeftActivation(final BuildUtils utils,
+ final RuleConditionElement rce) {
throw new RuntimeDroolsException( "BUG: Can't build a rete network with an inner OR group element" );
}
}
@@ -185,20 +185,20 @@
* If it is a column, a simple NotNode is added to the rulebase
* If it is a group element, than a subnetwork must be created
*/
- public void build(BuildContext context,
- BuildUtils utils,
- RuleConditionElement rce) {
- GroupElement not = (GroupElement) rce;
+ public void build(final BuildContext context,
+ final BuildUtils utils,
+ final RuleConditionElement rce) {
+ final GroupElement not = (GroupElement) rce;
// NOT must save some context info to restore it later
- int currentColumnIndex = context.getCurrentColumnOffset();
- TupleSource tupleSource = context.getTupleSource();
+ final int currentColumnIndex = context.getCurrentColumnOffset();
+ final TupleSource tupleSource = context.getTupleSource();
// get child
- RuleConditionElement child = (RuleConditionElement) not.getChildren().get( 0 );
+ final RuleConditionElement child = (RuleConditionElement) not.getChildren().get( 0 );
// get builder for child
- ReteooComponentBuilder builder = utils.getBuilderFor( child );
+ final ReteooComponentBuilder builder = utils.getBuilderFor( child );
// builds the child
builder.build( context,
@@ -217,8 +217,8 @@
context.setTupleSource( tupleSource );
// create a tuple start equals constraint and set it in the context
- TupleStartEqualsConstraint constraint = TupleStartEqualsConstraint.getInstance();
- List predicates = new ArrayList();
+ final TupleStartEqualsConstraint constraint = TupleStartEqualsConstraint.getInstance();
+ final List predicates = new ArrayList();
predicates.add( constraint );
context.setBetaconstraints( utils.createBetaNodeConstraint( context,
predicates ) );
@@ -240,8 +240,8 @@
context.setCurrentColumnOffset( currentColumnIndex );
}
- public boolean requiresLeftActivation(BuildUtils utils,
- RuleConditionElement rce) {
+ public boolean requiresLeftActivation(final BuildUtils utils,
+ final RuleConditionElement rce) {
return true;
}
}
@@ -258,20 +258,20 @@
* If it is a column, a simple ExistsNode is added to the rulebase
* If it is a group element, than a subnetwork must be created
*/
- public void build(BuildContext context,
- BuildUtils utils,
- RuleConditionElement rce) {
- GroupElement exists = (GroupElement) rce;
+ public void build(final BuildContext context,
+ final BuildUtils utils,
+ final RuleConditionElement rce) {
+ final GroupElement exists = (GroupElement) rce;
// EXISTS must save some context info to restore it later
- int currentColumnIndex = context.getCurrentColumnOffset();
- TupleSource tupleSource = context.getTupleSource();
+ final int currentColumnIndex = context.getCurrentColumnOffset();
+ final TupleSource tupleSource = context.getTupleSource();
// get child
- RuleConditionElement child = (RuleConditionElement) exists.getChildren().get( 0 );
+ final RuleConditionElement child = (RuleConditionElement) exists.getChildren().get( 0 );
// get builder for child
- ReteooComponentBuilder builder = utils.getBuilderFor( child );
+ final ReteooComponentBuilder builder = utils.getBuilderFor( child );
// builds the child
builder.build( context,
@@ -290,8 +290,8 @@
context.setTupleSource( tupleSource );
// create a tuple start equals constraint and set it in the context
- TupleStartEqualsConstraint constraint = TupleStartEqualsConstraint.getInstance();
- List predicates = new ArrayList();
+ final TupleStartEqualsConstraint constraint = TupleStartEqualsConstraint.getInstance();
+ final List predicates = new ArrayList();
predicates.add( constraint );
context.setBetaconstraints( utils.createBetaNodeConstraint( context,
predicates ) );
@@ -316,8 +316,8 @@
/**
* @inheritDoc
*/
- public boolean requiresLeftActivation(BuildUtils utils,
- RuleConditionElement rce) {
+ public boolean requiresLeftActivation(final BuildUtils utils,
+ final RuleConditionElement rce) {
return true;
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/ReteooComponentBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/ReteooComponentBuilder.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/ReteooComponentBuilder.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -24,15 +24,17 @@
* @author etirelli
*/
public interface ReteooComponentBuilder {
-
+
/**
* Builds and attach if needed the given RuleConditionalElement
*
* @param context current build context
* @param rce
*/
- public void build( BuildContext context, BuildUtils utils, RuleConditionElement rce );
-
+ public void build(BuildContext context,
+ BuildUtils utils,
+ RuleConditionElement rce);
+
/**
* A boolean function that indicates if the builder requires a previous left
* (tuple) activation in order to corretly build the given component.
@@ -48,6 +50,7 @@
*
* @return true if a tuple source is required, false otherwise.
*/
- public boolean requiresLeftActivation( BuildUtils utils, RuleConditionElement rce );
+ public boolean requiresLeftActivation(BuildUtils utils,
+ RuleConditionElement rce);
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/ReteooRuleBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/ReteooRuleBuilder.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/ReteooRuleBuilder.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -58,19 +58,19 @@
public ReteooRuleBuilder() {
this.utils = new BuildUtils();
- utils.addBuilder( GroupElement.class,
+ this.utils.addBuilder( GroupElement.class,
new GroupElementBuilder() );
- utils.addBuilder( Column.class,
+ this.utils.addBuilder( Column.class,
new ColumnBuilder() );
- utils.addBuilder( EvalCondition.class,
+ this.utils.addBuilder( EvalCondition.class,
new EvalBuilder() );
- utils.addBuilder( From.class,
+ this.utils.addBuilder( From.class,
new FromBuilder() );
- utils.addBuilder( Collect.class,
+ this.utils.addBuilder( Collect.class,
new CollectBuilder() );
- utils.addBuilder( Accumulate.class,
+ this.utils.addBuilder( Accumulate.class,
new AccumulateBuilder() );
- utils.addBuilder( Forall.class,
+ this.utils.addBuilder( Forall.class,
new ForallBuilder() );
}
@@ -103,11 +103,11 @@
for ( int i = 0; i < subrules.length; i++ ) {
// creates a clean build context for each subrule
- BuildContext context = new BuildContext( rulebase,
+ final BuildContext context = new BuildContext( rulebase,
attachedNodes,
idGenerator );
// adds subrule
- TerminalNode node = this.addSubRule( context,
+ final TerminalNode node = this.addSubRule( context,
subrules[i],
rule );
@@ -119,7 +119,7 @@
return nodes;
}
- private TerminalNode addSubRule(BuildContext context,
+ private TerminalNode addSubRule(final BuildContext context,
final GroupElement subrule,
final Rule rule) throws InvalidPatternException {
@@ -131,10 +131,10 @@
}
// gets the appropriate builder
- ReteooComponentBuilder builder = this.utils.getBuilderFor( subrule );
+ final ReteooComponentBuilder builder = this.utils.getBuilderFor( subrule );
// checks if an initial-fact is needed
- if ( builder.requiresLeftActivation( utils,
+ if ( builder.requiresLeftActivation( this.utils,
subrule ) ) {
this.addInitialFactColumn( context,
subrule,
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/AbstractCompositeRestriction.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -80,13 +80,13 @@
public static class CompositeContextEntry
implements
ContextEntry {
- public ContextEntry[] contextEntries;
+ public ContextEntry[] contextEntries;
- private ContextEntry entry;
+ private ContextEntry entry;
- public CompositeContextEntry(Restriction[] restrictions) {
- ContextEntry[] contextEntries = new ContextEntry[restrictions.length];
- for(int i = 0; i < restrictions.length; i++) {
+ public CompositeContextEntry(final Restriction[] restrictions) {
+ final ContextEntry[] contextEntries = new ContextEntry[restrictions.length];
+ for ( int i = 0; i < restrictions.length; i++ ) {
contextEntries[i] = restrictions[i].getContextEntry();
}
}
@@ -99,17 +99,19 @@
this.entry = entry;
}
- public void updateFromFactHandle(InternalWorkingMemory workingMemory,
- InternalFactHandle handle) {
- for(int i = 0, length = contextEntries.length ; i < length; i++) {
- contextEntries[i].updateFromFactHandle( workingMemory, handle );
+ public void updateFromFactHandle(final InternalWorkingMemory workingMemory,
+ final InternalFactHandle handle) {
+ for ( int i = 0, length = this.contextEntries.length; i < length; i++ ) {
+ this.contextEntries[i].updateFromFactHandle( workingMemory,
+ handle );
}
}
- public void updateFromTuple(InternalWorkingMemory workingMemory,
- ReteTuple tuple) {
- for(int i = 0, length = contextEntries.length ; i < length; i++) {
- contextEntries[i].updateFromTuple( workingMemory, tuple );
+ public void updateFromTuple(final InternalWorkingMemory workingMemory,
+ final ReteTuple tuple) {
+ for ( int i = 0, length = this.contextEntries.length; i < length; i++ ) {
+ this.contextEntries[i].updateFromTuple( workingMemory,
+ tuple );
}
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/Accumulate.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -121,7 +121,7 @@
/**
* @inheritDoc
*/
- public Declaration resolveDeclaration(String identifier) {
+ public Declaration resolveDeclaration(final String identifier) {
return (Declaration) this.sourceColumn.getInnerDeclarations().get( identifier );
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/AndCompositeRestriction.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -13,9 +13,9 @@
super( restriction );
}
- public boolean isAllowed(Extractor extractor,
- Object object,
- InternalWorkingMemory workingMemory) {
+ public boolean isAllowed(final Extractor extractor,
+ final Object object,
+ final InternalWorkingMemory workingMemory) {
for ( int i = 0, ilength = this.restrictions.length; i < ilength; i++ ) {
if ( !this.restrictions[i].isAllowed( extractor,
object,
@@ -26,8 +26,8 @@
return true;
}
- public boolean isAllowedCachedLeft(ContextEntry context,
- Object object) {
+ public boolean isAllowedCachedLeft(final ContextEntry context,
+ final Object object) {
for ( int i = 0, ilength = this.restrictions.length; i < ilength; i++ ) {
if ( !this.restrictions[i].isAllowedCachedLeft( this.contextEntry.contextEntries[i],
object ) ) {
@@ -37,8 +37,8 @@
return true;
}
- public boolean isAllowedCachedRight(ReteTuple tuple,
- ContextEntry context) {
+ public boolean isAllowedCachedRight(final ReteTuple tuple,
+ final ContextEntry context) {
for ( int i = 0, ilength = this.restrictions.length; i < ilength; i++ ) {
if ( !this.restrictions[i].isAllowedCachedRight( tuple,
this.contextEntry.contextEntries[i] ) ) {
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/Collect.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -69,7 +69,7 @@
e );
}
}
-
+
public Map getInnerDeclarations() {
return this.sourceColumn.getInnerDeclarations();
}
@@ -81,7 +81,7 @@
/**
* @inheritDoc
*/
- public Declaration resolveDeclaration(String identifier) {
+ public Declaration resolveDeclaration(final String identifier) {
return (Declaration) this.sourceColumn.getInnerDeclarations().get( identifier );
}
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/Column.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -69,26 +69,30 @@
this.index = index;
this.offset = offset;
this.objectType = objectType;
- if ( identifier != null && ( ! identifier.equals( "" ) ) ) {
+ if ( identifier != null && (!identifier.equals( "" )) ) {
this.declaration = new Declaration( identifier,
new ColumnExtractor( objectType ),
this );
- this.declarations = new HashMap(2); // default to avoid immediate resize
- this.declarations.put( this.declaration.getIdentifier(), this.declaration );
+ this.declarations = new HashMap( 2 ); // default to avoid immediate resize
+ this.declarations.put( this.declaration.getIdentifier(),
+ this.declaration );
} else {
this.declaration = null;
}
}
-
+
public Object clone() {
- String identifier = (this.declaration != null) ? this.declaration.getIdentifier() : null;
- Column clone = new Column( this.index, this.objectType, identifier );
+ final String identifier = (this.declaration != null) ? this.declaration.getIdentifier() : null;
+ final Column clone = new Column( this.index,
+ this.objectType,
+ identifier );
- for( Iterator it = this.constraints.iterator(); it.hasNext(); ) {
- Object constr = it.next();
- if( constr instanceof Declaration ) {
- Declaration decl = (Declaration) constr;
- clone.addDeclaration( decl.getIdentifier(), decl.getExtractor() );
+ for ( final Iterator it = this.constraints.iterator(); it.hasNext(); ) {
+ final Object constr = it.next();
+ if ( constr instanceof Declaration ) {
+ final Declaration decl = (Declaration) constr;
+ clone.addDeclaration( decl.getIdentifier(),
+ decl.getExtractor() );
} else {
clone.addConstraint( (Constraint) constr );
}
@@ -120,10 +124,11 @@
extractor,
this );
this.constraints.add( declaration );
- if( this.declarations == null ) {
- this.declarations = new HashMap(2); // default to avoid immediate resize
+ if ( this.declarations == null ) {
+ this.declarations = new HashMap( 2 ); // default to avoid immediate resize
}
- this.declarations.put( declaration.getIdentifier(), declaration );
+ this.declarations.put( declaration.getIdentifier(),
+ declaration );
return declaration;
}
@@ -149,25 +154,26 @@
public int getOffset() {
return this.offset;
}
-
+
public void setOffset(final int offset) {
this.offset = offset;
}
public Map getInnerDeclarations() {
- return ( this.declarations != null ) ? this.declarations : Collections.EMPTY_MAP;
+ return (this.declarations != null) ? this.declarations : Collections.EMPTY_MAP;
}
public Map getOuterDeclarations() {
- return ( this.declarations != null ) ? this.declarations : Collections.EMPTY_MAP;
+ return (this.declarations != null) ? this.declarations : Collections.EMPTY_MAP;
}
-
- public Declaration resolveDeclaration( String identifier ) {
- return ( this.declarations != null ) ? (Declaration) this.declarations.get( identifier ) : null;
+
+ public Declaration resolveDeclaration(final String identifier) {
+ return (this.declarations != null) ? (Declaration) this.declarations.get( identifier ) : null;
}
public String toString() {
- return "Column type='" + ((this.objectType == null) ? "null" : this.objectType.toString()) + "', index='" + this.index + "', offset='" + this.getOffset() + "', identifer='" + ((this.declaration == null) ? "" : this.declaration.toString()) + "'";
+ return "Column type='" + ((this.objectType == null) ? "null" : this.objectType.toString()) + "', index='" + this.index + "', offset='" + this.getOffset() + "', identifer='" + ((this.declaration == null) ? "" : this.declaration.toString())
+ + "'";
}
public int hashCode() {
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/CompositePackageClassLoader.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/CompositePackageClassLoader.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/CompositePackageClassLoader.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -48,7 +48,7 @@
protected synchronized Class loadClass(final String name,
final boolean resolve) throws ClassNotFoundException {
Class clazz = findLoadedClass( name );
-
+
if ( clazz == null ) {
clazz = compositeFastFindClass( name );
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/ConditionalElement.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/ConditionalElement.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/ConditionalElement.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -16,11 +16,10 @@
* limitations under the License.
*/
-
public abstract class ConditionalElement
implements
RuleConditionElement {
-
+
public abstract Object clone();
-
+
}
\ 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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/ContextEntry.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -6,14 +6,18 @@
import org.drools.common.InternalWorkingMemory;
import org.drools.reteoo.ReteTuple;
-public interface ContextEntry extends Serializable {
+public interface ContextEntry
+ extends
+ Serializable {
public ContextEntry getNext();
public void setNext(ContextEntry entry);
- public void updateFromTuple(InternalWorkingMemory workingMemory, ReteTuple tuple);
+ public void updateFromTuple(InternalWorkingMemory workingMemory,
+ ReteTuple tuple);
- public void updateFromFactHandle(InternalWorkingMemory workingMemory, InternalFactHandle handle);
+ public void updateFromFactHandle(InternalWorkingMemory workingMemory,
+ 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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/Declaration.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -156,41 +156,42 @@
return this.extractor.getValue( object );
}
- public char getCharValue(Object object) {
+ public char getCharValue(final Object object) {
return this.extractor.getCharValue( object );
}
- public int getIntValue(Object object) {
+ public int getIntValue(final Object object) {
return this.extractor.getIntValue( object );
}
- public byte getByteValue(Object object) {
+ public byte getByteValue(final Object object) {
return this.extractor.getByteValue( object );
}
- public short getShortValue(Object object) {
+ public short getShortValue(final Object object) {
return this.extractor.getShortValue( object );
}
- public long getLongValue(Object object) {
+ public long getLongValue(final Object object) {
return this.extractor.getLongValue( object );
}
- public float getFloatValue(Object object) {
+ public float getFloatValue(final Object object) {
return this.extractor.getFloatValue( object );
}
- public double getDoubleValue(Object object) {
+ public double getDoubleValue(final Object object) {
return this.extractor.getDoubleValue( object );
}
- public boolean getBooleanValue(Object object) {
+ public boolean getBooleanValue(final Object object) {
return this.extractor.getBooleanValue( object );
}
- public int getHashCode(Object object) {
+ public int getHashCode(final Object object) {
return this.extractor.getHashCode( object );
}
+
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
public String toString() {
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/EvalCondition.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/EvalCondition.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/EvalCondition.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -121,13 +121,12 @@
public Map getOuterDeclarations() {
return Collections.EMPTY_MAP;
}
-
+
/**
* @inheritDoc
*/
- public Declaration resolveDeclaration(String identifier) {
- return (Declaration) null;
+ public Declaration resolveDeclaration(final String identifier) {
+ return null;
}
-
};
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/Forall.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/Forall.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/Forall.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -31,21 +31,24 @@
public class Forall extends ConditionalElement {
private static final long serialVersionUID = -5993305516857875971L;
-
+
// forall base column
- private Column baseColumn;
+ private Column baseColumn;
// foral remaining columns
- private List remainingColumns;
-
+ private List remainingColumns;
+
public Forall() {
- this(null, new ArrayList(1));
+ this( null,
+ new ArrayList( 1 ) );
}
-
- public Forall(Column baseColumn) {
- this( baseColumn, new ArrayList(1) );
+
+ public Forall(final Column baseColumn) {
+ this( baseColumn,
+ new ArrayList( 1 ) );
}
- public Forall(Column baseColumn, List remainingColumns) {
+ public Forall(final Column baseColumn,
+ final List remainingColumns) {
this.baseColumn = baseColumn;
this.remainingColumns = remainingColumns;
}
@@ -54,7 +57,8 @@
* @see org.drools.rule.ConditionalElement#clone()
*/
public Object clone() {
- return new Forall(this.baseColumn, new ArrayList(this.remainingColumns));
+ return new Forall( this.baseColumn,
+ new ArrayList( this.remainingColumns ) );
}
/**
@@ -62,9 +66,9 @@
* since it negates the remaining columns
*/
public Map getInnerDeclarations() {
- Map inner = new HashMap(this.baseColumn.getOuterDeclarations());
- for( Iterator it = this.remainingColumns.iterator(); it.hasNext(); ) {
- inner.putAll( ((Column)it.next()).getOuterDeclarations() );
+ final Map inner = new HashMap( this.baseColumn.getOuterDeclarations() );
+ for ( final Iterator it = this.remainingColumns.iterator(); it.hasNext(); ) {
+ inner.putAll( ((Column) it.next()).getOuterDeclarations() );
}
return inner;
}
@@ -79,7 +83,7 @@
/**
* Forall can only resolve declarations from its base column
*/
- public Declaration resolveDeclaration(String identifier) {
+ public Declaration resolveDeclaration(final String identifier) {
return (Declaration) this.getInnerDeclarations().get( identifier );
}
@@ -87,13 +91,13 @@
* @return the baseColumn
*/
public Column getBaseColumn() {
- return baseColumn;
+ return this.baseColumn;
}
/**
* @param baseColumn the baseColumn to set
*/
- public void setBaseColumn(Column baseColumn) {
+ public void setBaseColumn(final Column baseColumn) {
this.baseColumn = baseColumn;
}
@@ -101,21 +105,21 @@
* @return the remainingColumns
*/
public List getRemainingColumns() {
- return remainingColumns;
+ return this.remainingColumns;
}
/**
* @param remainingColumns the remainingColumns to set
*/
- public void setRemainingColumns(List remainingColumns) {
+ public void setRemainingColumns(final List remainingColumns) {
this.remainingColumns = remainingColumns;
}
-
+
/**
* Adds one more column to the list of remaining columns
* @param column
*/
- public void addRemainingColumn( Column column ) {
+ public void addRemainingColumn(final Column column) {
this.remainingColumns.add( column );
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/From.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -11,9 +11,9 @@
private static final long serialVersionUID = -2640290731776949513L;
- private Column column;
+ private Column column;
- private DataProvider dataProvider;
+ private DataProvider dataProvider;
public From(final Column column,
final DataProvider dataProvider) {
@@ -41,12 +41,12 @@
public Map getOuterDeclarations() {
return this.column.getOuterDeclarations();
}
-
+
/**
* @inheritDoc
*/
- public Declaration resolveDeclaration(String identifier) {
+ public Declaration resolveDeclaration(final String identifier) {
return (Declaration) this.column.getInnerDeclarations().get( identifier );
}
-
+
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/GroupElement.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/GroupElement.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/GroupElement.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -42,7 +42,7 @@
this( AND );
}
- public GroupElement(Type type) {
+ public GroupElement(final Type type) {
this.type = type;
}
@@ -66,10 +66,12 @@
* @param index
* @param rce
*/
- public void addChild(int index, RuleConditionElement rce) {
- this.children.add( index, rce );
+ public void addChild(final int index,
+ final RuleConditionElement rce) {
+ this.children.add( index,
+ rce );
}
-
+
public List getChildren() {
return this.children;
}
@@ -91,7 +93,7 @@
/**
* @inheritDoc
*/
- public Declaration resolveDeclaration(String identifier) {
+ public Declaration resolveDeclaration(final String identifier) {
return (Declaration) this.type.getInnerDeclarations( this.children ).get( identifier );
}
@@ -104,12 +106,12 @@
*/
public void pack() {
// we must clone, since we want to iterate only over the original list
- Object[] clone = this.children.toArray();
+ final Object[] clone = this.children.toArray();
for ( int i = 0; i < clone.length; i++ ) {
// if child is also a group element, there may be
// some possible clean up / optimizations to be done
if ( clone[i] instanceof GroupElement ) {
- GroupElement childGroup = (GroupElement) clone[i];
+ final GroupElement childGroup = (GroupElement) clone[i];
childGroup.pack( this );
}
}
@@ -117,9 +119,9 @@
// if after packing, this is an AND or OR GE with a single
// child GE, then clone child into current node eliminating child
if ( (this.isAnd() || this.isOr()) && (this.children.size() == 1) ) {
- Object child = this.getChildren().get( 0 );
+ final Object child = this.getChildren().get( 0 );
if ( child instanceof GroupElement ) {
- GroupElement group = (GroupElement) child;
+ final GroupElement group = (GroupElement) child;
this.type = group.getType();
this.children.clear();
this.children.addAll( group.getChildren() );
@@ -130,7 +132,7 @@
/**
* @param parent
*/
- private void pack(GroupElement parent) {
+ private void pack(final GroupElement parent) {
if ( this.children.size() == 0 ) {
// if there is no child, just remove this node
parent.children.remove( this );
@@ -148,13 +150,13 @@
int index = parent.getChildren().indexOf( this );
parent.getChildren().remove( this );
// for each child, pack it and add it to parent
- for ( Iterator childIt = this.children.iterator(); childIt.hasNext(); ) {
- Object child = childIt.next();
+ for ( final Iterator childIt = this.children.iterator(); childIt.hasNext(); ) {
+ final Object child = childIt.next();
// we must keep the order, so add in the same place were parent was before
parent.getChildren().add( index++,
child );
if ( child instanceof GroupElement ) {
- int previousSize = parent.getChildren().size();
+ final int previousSize = parent.getChildren().size();
((GroupElement) child).pack( parent );
// in case the child also added elements to the parent,
// we need to compensate
@@ -165,10 +167,10 @@
// if current node has a single child, then move it to parent and pack it
} else if ( (!this.isExists()) && (this.children.size() == 1) ) {
// we must keep the order so, save index
- int index = parent.getChildren().indexOf( this );
+ final int index = parent.getChildren().indexOf( this );
parent.getChildren().remove( this );
- Object child = this.children.get( 0 );
+ final Object child = this.children.get( 0 );
parent.getChildren().add( index,
child );
@@ -266,10 +268,10 @@
}
public Type getType() {
- return type;
+ return this.type;
}
- public void setType(Type type) {
+ public void setType(final Type type) {
this.type = type;
}
@@ -342,17 +344,17 @@
/**
* @inheritDoc
*/
- public Map getInnerDeclarations(List children) {
+ public Map getInnerDeclarations(final List children) {
Map declarations = null;
if ( children.isEmpty() ) {
declarations = Collections.EMPTY_MAP;
} else if ( children.size() == 1 ) {
- RuleConditionElement re = (RuleConditionElement) children.get( 0 );
+ final RuleConditionElement re = (RuleConditionElement) children.get( 0 );
declarations = re.getOuterDeclarations();
} else {
declarations = new HashMap();
- for ( Iterator it = children.iterator(); it.hasNext(); ) {
+ for ( final Iterator it = children.iterator(); it.hasNext(); ) {
declarations.putAll( ((RuleConditionElement) it.next()).getOuterDeclarations() );
}
}
@@ -362,17 +364,17 @@
/**
* @inheritDoc
*/
- public Map getOuterDeclarations(List children) {
+ public Map getOuterDeclarations(final List children) {
Map declarations = null;
if ( children.isEmpty() ) {
declarations = Collections.EMPTY_MAP;
} else if ( children.size() == 1 ) {
- RuleConditionElement re = (RuleConditionElement) children.get( 0 );
+ final RuleConditionElement re = (RuleConditionElement) children.get( 0 );
declarations = re.getOuterDeclarations();
} else {
declarations = new HashMap();
- for ( Iterator it = children.iterator(); it.hasNext(); ) {
+ for ( final Iterator it = children.iterator(); it.hasNext(); ) {
declarations.putAll( ((RuleConditionElement) it.next()).getOuterDeclarations() );
}
}
@@ -406,7 +408,7 @@
return false;
}
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if ( !(obj instanceof AndType) ) {
return false;
}
@@ -449,7 +451,7 @@
return true;
}
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if ( !(obj instanceof OrType) ) {
return false;
}
@@ -494,11 +496,11 @@
/**
* @inheritDoc
*/
- public Map getOuterDeclarations(List children) {
+ public Map getOuterDeclarations(final List children) {
return Collections.EMPTY_MAP;
}
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if ( !(obj instanceof NotType) ) {
return false;
}
@@ -543,11 +545,11 @@
/**
* @inheritDoc
*/
- public Map getOuterDeclarations(List children) {
+ public Map getOuterDeclarations(final List children) {
return Collections.EMPTY_MAP;
}
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if ( !(obj instanceof ExistsType) ) {
return false;
}
@@ -563,5 +565,4 @@
}
}
-
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/GroupElementFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/GroupElementFactory.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/GroupElementFactory.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -22,9 +22,10 @@
* @author etirelli
*/
public class GroupElementFactory {
-
- private GroupElementFactory() {}
-
+
+ private GroupElementFactory() {
+ }
+
public static GroupElement newAndInstance() {
return new GroupElement( GroupElement.AND );
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/LiteralRestriction.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -94,7 +94,7 @@
final int PRIME = 31;
int result = 1;
result = PRIME * result + this.evaluator.hashCode();
- result = PRIME * result + ( ( this.field.getValue() != null ) ? this.field.getValue().hashCode() : 0 );
+ result = PRIME * result + ((this.field.getValue() != null) ? this.field.getValue().hashCode() : 0);
return result;
}
@@ -111,7 +111,7 @@
}
public ContextEntry getContextEntry() {
- return contextEntry;
+ return this.contextEntry;
}
private static class LiteralContextEntry
@@ -121,7 +121,7 @@
public Object object;
public ContextEntry next;
- public LiteralContextEntry(FieldExtractor extractor) {
+ public LiteralContextEntry(final FieldExtractor extractor) {
this.extractor = extractor;
}
@@ -137,17 +137,17 @@
return this.next;
}
- public void setNext(ContextEntry entry) {
+ public void setNext(final ContextEntry entry) {
this.next = entry;
}
- public void updateFromFactHandle(InternalWorkingMemory workingMemory,
- InternalFactHandle handle) {
+ public void updateFromFactHandle(final InternalWorkingMemory workingMemory,
+ final InternalFactHandle handle) {
this.object = handle.getObject();
}
- public void updateFromTuple(InternalWorkingMemory workingMemory,
- ReteTuple tuple) {
+ public void updateFromTuple(final InternalWorkingMemory workingMemory,
+ final ReteTuple tuple) {
// nothing to do
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/LogicTransformer.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/LogicTransformer.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/LogicTransformer.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -71,8 +71,8 @@
}
public GroupElement[] transform(final GroupElement and) throws InvalidPatternException {
- GroupElement cloned = (GroupElement) and.clone();
-
+ final GroupElement cloned = (GroupElement) and.clone();
+
processTree( cloned );
cloned.pack();
@@ -81,13 +81,13 @@
if ( cloned.isAnd() ) {
// Yes, so just return it
ands = new GroupElement[]{cloned};
- } else if( cloned.isOr() ){
+ } else if ( cloned.isOr() ) {
// it is an OR, so each child is an AND branch
ands = new GroupElement[cloned.getChildren().size()];
int i = 0;
- for( Iterator it = cloned.getChildren().iterator(); it.hasNext(); ) {
- RuleConditionElement branch = (RuleConditionElement) it.next();
- if( ( branch instanceof GroupElement ) && (((GroupElement)branch).isAnd()) ){
+ for ( final Iterator it = cloned.getChildren().iterator(); it.hasNext(); ) {
+ final RuleConditionElement branch = (RuleConditionElement) it.next();
+ if ( (branch instanceof GroupElement) && (((GroupElement) branch).isAnd()) ) {
ands[i++] = (GroupElement) branch;
} else {
ands[i] = GroupElementFactory.newAndInstance();
@@ -97,7 +97,7 @@
}
} else {
// no, so just wrap into an AND
- GroupElement wrapper = GroupElementFactory.newAndInstance();
+ final GroupElement wrapper = GroupElementFactory.newAndInstance();
wrapper.addChild( cloned );
ands = new GroupElement[]{wrapper};
}
@@ -120,10 +120,10 @@
void processTree(final GroupElement ce) throws InvalidPatternException {
boolean hasChildOr = false;
-
+
// first we eliminicate any redundancy
ce.pack();
-
+
for ( final ListIterator it = ce.getChildren().listIterator(); it.hasNext(); ) {
final Object object = it.next();
if ( object instanceof GroupElement ) {
@@ -142,7 +142,7 @@
}
void applyOrTransformation(final GroupElement parent) throws InvalidPatternException {
- Transformation transformation = (Transformation) this.orTransformations.get( parent.getType() );
+ final Transformation transformation = (Transformation) this.orTransformations.get( parent.getType() );
if ( transformation == null ) {
throw new RuntimeException( "applyOrTransformation could not find transformation for parent '" + parent.getType() + "' and child 'OR'" );
@@ -186,20 +186,20 @@
Transformation {
public void transform(final GroupElement parent) throws InvalidPatternException {
- List orsList = new ArrayList();
+ final List orsList = new ArrayList();
// must keep order, so, using array
- Object[] others = new Object[parent.getChildren().size()];
+ final Object[] others = new Object[parent.getChildren().size()];
// first we split children as OR or not OR
int permutations = 1;
int index = 0;
- for ( Iterator it = parent.getChildren().iterator(); it.hasNext(); ) {
- Object child = it.next();
+ for ( final Iterator it = parent.getChildren().iterator(); it.hasNext(); ) {
+ final Object child = it.next();
if ( (child instanceof GroupElement) && ((GroupElement) child).isOr() ) {
permutations *= ((GroupElement) child).getChildren().size();
orsList.add( child );
} else {
- others[index] = child ;
+ others[index] = child;
}
index++;
}
@@ -209,18 +209,19 @@
parent.getChildren().clear();
// prepare arrays and indexes to calculate permutation
- GroupElement[] ors = (GroupElement[]) orsList.toArray( new GroupElement[orsList.size()] );
- int[] indexes = new int[ors.length];
+ final GroupElement[] ors = (GroupElement[]) orsList.toArray( new GroupElement[orsList.size()] );
+ final int[] indexes = new int[ors.length];
// now we know how many permutations we will have, so create it
for ( int i = 1; i <= permutations; i++ ) {
- GroupElement and = GroupElementFactory.newAndInstance();
+ final GroupElement and = GroupElementFactory.newAndInstance();
// create the actual permutations
int mod = 1;
for ( int j = ors.length - 1; j >= 0; j-- ) {
// we must insert at the beggining to keep the order
- and.getChildren().add( 0, ors[j].getChildren().get( indexes[j] ) );
+ and.getChildren().add( 0,
+ ors[j].getChildren().get( indexes[j] ) );
if ( (i % mod) == 0 ) {
indexes[j] = (indexes[j] + 1) % ors[j].getChildren().size();
}
@@ -229,10 +230,11 @@
// elements originally outside OR will be in every permutation, so add them
// in their original position
- for( int j = 0; j < others.length; j++ ) {
- if( others[j] != null ) {
+ for ( int j = 0; j < others.length; j++ ) {
+ if ( others[j] != null ) {
// always add clone of them to avoid offset conflicts in declarations
- and.getChildren().add( j, ((RuleConditionElement) others[j]).clone() );
+ and.getChildren().add( j,
+ ((RuleConditionElement) others[j]).clone() );
}
}
parent.addChild( and );
@@ -277,11 +279,11 @@
* we know an Exists only ever has one child, and the previous algorithm
* has confirmed the child is an OR
*/
- GroupElement or = (GroupElement) parent.getChildren().get( 0 );
+ final GroupElement or = (GroupElement) parent.getChildren().get( 0 );
parent.setType( GroupElement.OR );
parent.getChildren().clear();
- for ( Iterator it = or.getChildren().iterator(); it.hasNext(); ) {
- GroupElement newExists = GroupElementFactory.newExistsInstance();
+ for ( final Iterator it = or.getChildren().iterator(); it.hasNext(); ) {
+ final GroupElement newExists = GroupElementFactory.newExistsInstance();
newExists.addChild( (RuleConditionElement) it.next() );
parent.addChild( newExists );
}
@@ -324,11 +326,11 @@
* we know a Not only ever has one child, and the previous algorithm
* has confirmed the child is an OR
*/
- GroupElement or = (GroupElement) parent.getChildren().get( 0 );
+ final GroupElement or = (GroupElement) parent.getChildren().get( 0 );
parent.setType( GroupElement.AND );
parent.getChildren().clear();
- for ( Iterator it = or.getChildren().iterator(); it.hasNext(); ) {
- GroupElement newNot = GroupElementFactory.newNotInstance();
+ for ( final Iterator it = or.getChildren().iterator(); it.hasNext(); ) {
+ final GroupElement newNot = GroupElementFactory.newNotInstance();
newNot.addChild( (RuleConditionElement) it.next() );
parent.addChild( newNot );
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/MultiRestrictionFieldConstraint.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/MultiRestrictionFieldConstraint.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/MultiRestrictionFieldConstraint.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -9,7 +9,8 @@
public class MultiRestrictionFieldConstraint
implements
- AlphaNodeFieldConstraint, BetaNodeFieldConstraint {
+ AlphaNodeFieldConstraint,
+ BetaNodeFieldConstraint {
/**
*
@@ -58,23 +59,27 @@
return this.extractor.equals( other.extractor ) && this.restrictions.equals( other.restrictions );
}
- public boolean isAllowed(Object object,
- InternalWorkingMemory workingMemory) {
- return this.restrictions.isAllowed( extractor, object, workingMemory );
+ public boolean isAllowed(final Object object,
+ final InternalWorkingMemory workingMemory) {
+ return this.restrictions.isAllowed( this.extractor,
+ object,
+ workingMemory );
}
public ContextEntry getContextEntry() {
return this.restrictions.getContextEntry();
}
- public boolean isAllowedCachedLeft(ContextEntry context,
- Object object) {
- return this.restrictions.isAllowedCachedLeft( context, object );
+ public boolean isAllowedCachedLeft(final ContextEntry context,
+ final Object object) {
+ return this.restrictions.isAllowedCachedLeft( context,
+ object );
}
- public boolean isAllowedCachedRight(ReteTuple tuple,
- ContextEntry context) {
- return this.restrictions.isAllowedCachedRight( tuple, context );
+ public boolean isAllowedCachedRight(final ReteTuple tuple,
+ final ContextEntry context) {
+ return this.restrictions.isAllowedCachedRight( tuple,
+ context );
}
}
\ No newline at end of file
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/OrCompositeRestriction.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -13,9 +13,9 @@
super( restriction );
}
- public boolean isAllowed(Extractor extractor,
- Object object,
- InternalWorkingMemory workingMemory) {
+ public boolean isAllowed(final Extractor extractor,
+ final Object object,
+ final InternalWorkingMemory workingMemory) {
for ( int i = 0, ilength = this.restrictions.length; i < ilength; i++ ) {
if ( this.restrictions[i].isAllowed( extractor,
object,
@@ -26,8 +26,8 @@
return false;
}
- public boolean isAllowedCachedLeft(ContextEntry context,
- Object object) {
+ public boolean isAllowedCachedLeft(final ContextEntry context,
+ final Object object) {
for ( int i = 0, ilength = this.restrictions.length; i < ilength; i++ ) {
if ( this.restrictions[i].isAllowedCachedLeft( this.contextEntry.contextEntries[i],
object ) ) {
@@ -37,8 +37,8 @@
return false;
}
- public boolean isAllowedCachedRight(ReteTuple tuple,
- ContextEntry context) {
+ public boolean isAllowedCachedRight(final ReteTuple tuple,
+ final ContextEntry context) {
for ( int i = 0, ilength = this.restrictions.length; i < ilength; i++ ) {
if ( this.restrictions[i].isAllowedCachedRight( tuple,
this.contextEntry.contextEntries[i] ) ) {
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/PackageCompilationData.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -296,7 +296,7 @@
final Class clazz = findLoadedClass( name );
if ( clazz == null ) {
- final byte[] clazzBytes = read( convertClassToResourcePath(name) );
+ final byte[] clazzBytes = read( convertClassToResourcePath( name ) );
if ( clazzBytes != null ) {
return defineClass( name,
clazzBytes,
@@ -349,37 +349,40 @@
return new ByteArrayInputStream( bytes );
} else {
InputStream input = this.getParent().getResourceAsStream( name );
- if( input == null ){
+ if ( input == null ) {
input = super.getResourceAsStream( name );
}
return input;
}
}
}
-
+
/**
* Please do not use - internal
* org/my/Class.xxx -> org.my.Class
*/
- public static String convertResourceToClassName( final String pResourceName ) {
- return stripExtension(pResourceName).replace('/', '.');
+ public static String convertResourceToClassName(final String pResourceName) {
+ return stripExtension( pResourceName ).replace( '/',
+ '.' );
}
/**
* Please do not use - internal
* org.my.Class -> org/my/Class.class
*/
- public static String convertClassToResourcePath( final String pName ) {
- return pName.replace('.', '/') + ".class";
+ public static String convertClassToResourcePath(final String pName) {
+ return pName.replace( '.',
+ '/' ) + ".class";
}
/**
* Please do not use - internal
* org/my/Class.xxx -> org/my/Class
*/
- public static String stripExtension( final String pResourceName ) {
- final int i = pResourceName.lastIndexOf('.');
- final String withoutExtension = pResourceName.substring(0, i);
+ public static String stripExtension(final String pResourceName) {
+ final int i = pResourceName.lastIndexOf( '.' );
+ final String withoutExtension = pResourceName.substring( 0,
+ i );
return withoutExtension;
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/PredicateConstraint.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -68,16 +68,24 @@
} else {
this.previousDeclarations = previousDeclarations;
}
-
+
if ( localDeclarations == null ) {
this.localDeclarations = PredicateConstraint.EMPTY_DECLARATIONS;
} else {
this.localDeclarations = localDeclarations;
}
-
- this.requiredDeclarations = new Declaration[ this.previousDeclarations.length + this.localDeclarations.length ];
- System.arraycopy( this.previousDeclarations, 0, this.requiredDeclarations, 0, this.previousDeclarations.length );
- System.arraycopy( this.localDeclarations, 0, this.requiredDeclarations, this.previousDeclarations.length, this.localDeclarations.length );
+
+ this.requiredDeclarations = new Declaration[this.previousDeclarations.length + this.localDeclarations.length];
+ System.arraycopy( this.previousDeclarations,
+ 0,
+ this.requiredDeclarations,
+ 0,
+ this.previousDeclarations.length );
+ System.arraycopy( this.localDeclarations,
+ 0,
+ this.requiredDeclarations,
+ this.previousDeclarations.length,
+ this.localDeclarations.length );
}
public Declaration[] getRequiredDeclarations() {
@@ -101,7 +109,7 @@
}
public String toString() {
- return "[PredicateConstraint previousDeclarations=" + this.previousDeclarations + " localDeclarations=" + this.localDeclarations+ "]";
+ return "[PredicateConstraint previousDeclarations=" + this.previousDeclarations + " localDeclarations=" + this.localDeclarations + "]";
}
public int hashCode() {
@@ -154,46 +162,46 @@
return new PredicateContextEntry();
}
- public boolean isAllowed(Object object,
- InternalWorkingMemory workingMemory) {
+ public boolean isAllowed(final Object object,
+ final InternalWorkingMemory workingMemory) {
try {
return this.expression.evaluate( object,
null,
- previousDeclarations,
- localDeclarations,
+ this.previousDeclarations,
+ this.localDeclarations,
workingMemory );
- } catch ( Exception e ) {
+ } catch ( final Exception e ) {
throw new RuntimeDroolsException( "Exception executing predicate " + this.expression,
e );
}
}
- public boolean isAllowedCachedLeft(ContextEntry context,
- Object object) {
+ public boolean isAllowedCachedLeft(final ContextEntry context,
+ final Object object) {
try {
- PredicateContextEntry ctx = (PredicateContextEntry) context;
+ final PredicateContextEntry ctx = (PredicateContextEntry) context;
return this.expression.evaluate( object,
ctx.leftTuple,
- previousDeclarations,
- localDeclarations,
+ this.previousDeclarations,
+ this.localDeclarations,
ctx.workingMemory );
- } catch ( Exception e ) {
+ } catch ( final Exception e ) {
e.printStackTrace();
throw new RuntimeDroolsException( "Exception executing predicate " + this.expression,
e );
}
}
- public boolean isAllowedCachedRight(ReteTuple tuple,
- ContextEntry context) {
+ public boolean isAllowedCachedRight(final ReteTuple tuple,
+ final ContextEntry context) {
try {
- PredicateContextEntry ctx = (PredicateContextEntry) context;
+ final PredicateContextEntry ctx = (PredicateContextEntry) context;
return this.expression.evaluate( ctx.rightObject,
tuple,
- previousDeclarations,
- localDeclarations,
+ this.previousDeclarations,
+ this.localDeclarations,
ctx.workingMemory );
- } catch ( Exception e ) {
+ } catch ( final Exception e ) {
throw new RuntimeDroolsException( "Exception executing predicate " + this.expression,
e );
}
@@ -203,8 +211,8 @@
implements
ContextEntry {
- private static final long serialVersionUID = 4217315252579887635L;
-
+ private static final long serialVersionUID = 4217315252579887635L;
+
public ReteTuple leftTuple;
public Object rightObject;
public InternalWorkingMemory workingMemory;
@@ -222,14 +230,14 @@
this.entry = entry;
}
- public void updateFromFactHandle(InternalWorkingMemory workingMemory,
- InternalFactHandle handle) {
+ public void updateFromFactHandle(final InternalWorkingMemory workingMemory,
+ final InternalFactHandle handle) {
this.workingMemory = workingMemory;
this.rightObject = handle.getObject();
}
- public void updateFromTuple(InternalWorkingMemory workingMemory,
- ReteTuple tuple) {
+ public void updateFromTuple(final InternalWorkingMemory workingMemory,
+ final ReteTuple tuple) {
this.workingMemory = workingMemory;
this.leftTuple = tuple;
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/ReturnValueConstraint.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -91,49 +91,45 @@
return this.restriction.getContextEntry();
}
- public boolean isAllowed(Object object,
- InternalWorkingMemory workingMemory) {
+ public boolean isAllowed(final Object object,
+ final InternalWorkingMemory workingMemory) {
try {
return this.restriction.isAllowed( this.fieldExtractor,
object,
null,
workingMemory );
- } catch ( Exception e ) {
- throw new RuntimeDroolsException( "Exception executing ReturnValue constraint " + this.restriction +
- " : "+e.getMessage(),
+ } catch ( final Exception e ) {
+ throw new RuntimeDroolsException( "Exception executing ReturnValue constraint " + this.restriction + " : " + e.getMessage(),
e );
}
}
- public boolean isAllowedCachedLeft(ContextEntry context,
- Object object) {
+ public boolean isAllowedCachedLeft(final ContextEntry context,
+ final Object object) {
try {
- ReturnValueContextEntry ctx = (ReturnValueContextEntry) context;
+ final ReturnValueContextEntry ctx = (ReturnValueContextEntry) context;
return this.restriction.isAllowed( this.fieldExtractor,
object,
ctx.getTuple(),
ctx.getWorkingMemory() );
- } catch ( Exception e ) {
- throw new RuntimeDroolsException( "Exception executing ReturnValue constraint " + this.restriction +
- " : "+e.getMessage(),
+ } catch ( final Exception e ) {
+ throw new RuntimeDroolsException( "Exception executing ReturnValue constraint " + this.restriction + " : " + e.getMessage(),
e );
}
}
- public boolean isAllowedCachedRight(ReteTuple tuple,
- ContextEntry context) {
+ public boolean isAllowedCachedRight(final ReteTuple tuple,
+ final ContextEntry context) {
try {
- ReturnValueContextEntry ctx = (ReturnValueContextEntry) context;
+ final ReturnValueContextEntry ctx = (ReturnValueContextEntry) context;
return this.restriction.isAllowed( this.fieldExtractor,
ctx.getObject(),
tuple,
ctx.getWorkingMemory() );
- } catch ( Exception e ) {
- throw new RuntimeDroolsException( "Exception executing ReturnValue constraint " + this.restriction +
- " : "+e.getMessage(),
+ } catch ( final Exception e ) {
+ throw new RuntimeDroolsException( "Exception executing ReturnValue constraint " + this.restriction + " : " + e.getMessage(),
e );
}
}
-
}
\ No newline at end of file
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/ReturnValueRestriction.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -85,9 +85,17 @@
previousDeclarations,
localDeclarations );
- this.requiredDeclarations = new Declaration[ previousDeclarations.length + localDeclarations.length ];
- System.arraycopy( this.previousDeclarations, 0, this.requiredDeclarations, 0, this.previousDeclarations.length );
- System.arraycopy( this.localDeclarations, 0, this.requiredDeclarations, this.previousDeclarations.length, this.localDeclarations.length );
+ this.requiredDeclarations = new Declaration[previousDeclarations.length + localDeclarations.length];
+ System.arraycopy( this.previousDeclarations,
+ 0,
+ this.requiredDeclarations,
+ 0,
+ this.previousDeclarations.length );
+ System.arraycopy( this.localDeclarations,
+ 0,
+ this.requiredDeclarations,
+ this.previousDeclarations.length,
+ this.localDeclarations.length );
}
public Declaration[] getRequiredDeclarations() {
@@ -131,19 +139,19 @@
}
}
- public boolean isAllowed(Extractor extractor,
- 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)" );
}
- public boolean isAllowedCachedLeft(ContextEntry context,
- Object object) {
+ public boolean isAllowedCachedLeft(final ContextEntry context,
+ final Object object) {
throw new UnsupportedOperationException( "does not support method call isAllowed(Object object, InternalWorkingMemory workingMemoiry)" );
}
- public boolean isAllowedCachedRight(ReteTuple tuple,
- ContextEntry context) {
+ public boolean isAllowedCachedRight(final ReteTuple tuple,
+ final ContextEntry context) {
throw new UnsupportedOperationException( "does not support method call isAllowed(Object object, InternalWorkingMemory workingMemoiry)" );
}
@@ -209,8 +217,8 @@
implements
ContextEntry {
- private static final long serialVersionUID = 3563817867979321431L;
-
+ private static final long serialVersionUID = 3563817867979321431L;
+
public FieldExtractor fieldExtractor;
public Object object;
public ReteTuple leftTuple;
@@ -220,9 +228,9 @@
private ContextEntry entry;
- public ReturnValueContextEntry(FieldExtractor fieldExtractor,
- Declaration[] previousDeclarations,
- Declaration[] localDeclarations) {
+ public ReturnValueContextEntry(final FieldExtractor fieldExtractor,
+ final Declaration[] previousDeclarations,
+ final Declaration[] localDeclarations) {
this.fieldExtractor = fieldExtractor;
this.previousDeclarations = previousDeclarations;
this.localDeclarations = localDeclarations;
@@ -236,14 +244,14 @@
this.entry = entry;
}
- public void updateFromFactHandle(InternalWorkingMemory workingMemory,
- InternalFactHandle handle) {
+ public void updateFromFactHandle(final InternalWorkingMemory workingMemory,
+ final InternalFactHandle handle) {
this.workingMemory = workingMemory;
this.object = handle.getObject();
}
- public void updateFromTuple(InternalWorkingMemory workingMemory,
- ReteTuple tuple) {
+ public void updateFromTuple(final InternalWorkingMemory workingMemory,
+ final ReteTuple tuple) {
this.workingMemory = workingMemory;
this.leftTuple = tuple;
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/Rule.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/Rule.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/Rule.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -45,7 +45,7 @@
/**
*
*/
- private static final long serialVersionUID = 320;
+ private static final long serialVersionUID = 320;
/** */
// ------------------------------------------------------------
@@ -84,16 +84,16 @@
private boolean autoFocus;
private String activationGroup;
-
- private String ruleFlowGroup;
-
+
+ private String ruleFlowGroup;
+
private boolean lockOnActive;
/** indicates that the rule is semantically correct. */
private boolean semanticallyValid;
-
+
private Calendar dateEffective;
-
+
private Calendar dateExpires;
private boolean enabled;
@@ -117,7 +117,7 @@
this.agendaGroup = agendaGroup;
this.lhsRoot = GroupElementFactory.newAndInstance();
this.semanticallyValid = true;
- this.enabled = true;
+ this.enabled = true;
}
/**
@@ -129,11 +129,15 @@
*/
public Rule(final String name,
final String agendaGroup) {
- this( name, null, agendaGroup );
+ this( name,
+ null,
+ agendaGroup );
}
public Rule(final String name) {
- this( name, null, AgendaGroup.MAIN );
+ this( name,
+ null,
+ AgendaGroup.MAIN );
}
/**
@@ -254,23 +258,25 @@
* This uses the dateEffective, dateExpires and enabled flag to decide this.
*/
public boolean isEffective() {
- if (!enabled) return false;
- if (this.dateEffective == null && this.dateExpires == null) {
+ if ( !this.enabled ) {
+ return false;
+ }
+ if ( this.dateEffective == null && this.dateExpires == null ) {
return true;
} else {
- Calendar now = Calendar.getInstance();
- if (this.dateEffective != null && this.dateExpires != null) {
+ final Calendar now = Calendar.getInstance();
+ if ( this.dateEffective != null && this.dateExpires != null ) {
return (now.after( this.dateEffective ) && now.before( this.dateExpires ));
- } else if (this.dateEffective != null) {
+ } else if ( this.dateEffective != null ) {
return (now.after( this.dateEffective ));
} else {
return (now.before( this.dateExpires ));
}
-
+
}
-
+
}
-
+
public void setNoLoop(final boolean noLoop) {
this.noLoop = noLoop;
}
@@ -290,18 +296,16 @@
public void setActivationGroup(final String activationGroup) {
this.activationGroup = activationGroup;
}
-
-
public String getRuleFlowGroup() {
- return ruleFlowGroup;
- }
+ return this.ruleFlowGroup;
+ }
- public void setRuleFlowGroup(String ruleFlowGroup) {
- this.ruleFlowGroup = ruleFlowGroup;
- }
+ public void setRuleFlowGroup(final String ruleFlowGroup) {
+ this.ruleFlowGroup = ruleFlowGroup;
+ }
- /**
+ /**
* Retrieve a parameter <code>Declaration</code> by identifier.
*
* @param identifier
@@ -311,21 +315,19 @@
* the <code>identifier</code>.
*/
public Declaration getDeclaration(final String identifier) {
- if ( dirty || (this.declarations == null) ) {
+ if ( this.dirty || (this.declarations == null) ) {
this.declarations = this.lhsRoot.getOuterDeclarations();
this.declarationArray = (Declaration[]) this.declarations.values().toArray( new Declaration[this.declarations.values().size()] );
this.dirty = false;
}
return (Declaration) this.declarations.get( identifier );
}
-
-
public boolean isLockOnActive() {
- return lockOnActive;
+ return this.lockOnActive;
}
- public void setLockOnActive(boolean lockOnActive) {
+ public void setLockOnActive(final boolean lockOnActive) {
this.lockOnActive = lockOnActive;
}
@@ -337,7 +339,7 @@
* <i>root fact objects</i>.
*/
public Declaration[] getDeclarations() {
- if ( dirty || (this.declarationArray == null) ) {
+ if ( this.dirty || (this.declarationArray == null) ) {
this.declarations = this.lhsRoot.getOuterDeclarations();
this.declarationArray = (Declaration[]) this.declarations.values().toArray( new Declaration[this.declarations.values().size()] );
this.dirty = false;
@@ -368,7 +370,7 @@
return this.lhsRoot;
}
- public void setLhs( GroupElement lhsRoot ) {
+ public void setLhs(final GroupElement lhsRoot) {
this.dirty = true;
this.lhsRoot = lhsRoot;
}
@@ -486,22 +488,22 @@
* Sets the date from which this rule takes effect (can include time to the millisecond).
* @param effectiveDate
*/
- public void setDateEffective(Calendar effectiveDate) {
- this.dateEffective = effectiveDate;
+ public void setDateEffective(final Calendar effectiveDate) {
+ this.dateEffective = effectiveDate;
}
/**
* Sets the date after which the rule will no longer apply (can include time to the millisecond).
* @param expiresDate
*/
- public void setDateExpires(Calendar expiresDate) {
- this.dateExpires = expiresDate;
+ public void setDateExpires(final Calendar expiresDate) {
+ this.dateExpires = expiresDate;
}
/**
* A rule is enabled by default. This can explicitly disable it in which case it will never activate.
*/
- public void setEnabled(boolean b) {
- this.enabled = b;
+ public void setEnabled(final boolean b) {
+ this.enabled = b;
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/RuleConditionElement.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/RuleConditionElement.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/RuleConditionElement.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -26,7 +26,8 @@
*/
public interface RuleConditionElement
extends
- RuleComponent, Cloneable {
+ RuleComponent,
+ Cloneable {
/**
* Returns a Map of declarations that are
@@ -43,7 +44,7 @@
* @return
*/
public Map getOuterDeclarations();
-
+
/**
* Resolves the given identifier in the current scope and
* returns the Declaration object for the declaration.
@@ -52,13 +53,12 @@
* @param identifier
* @return
*/
- public Declaration resolveDeclaration( String identifier );
-
+ public Declaration resolveDeclaration(String identifier);
+
/**
* Returns a clone from itself
* @return
*/
public Object clone();
-
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/VariableConstraint.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -60,8 +60,8 @@
return this.restriction.getEvaluator();
}
- public boolean isAllowed(Object object,
- InternalWorkingMemory workingMemory) {
+ public boolean isAllowed(final Object object,
+ final InternalWorkingMemory workingMemory) {
return this.restriction.isAllowed( this.fieldExtractor,
object,
workingMemory );
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/VariableRestriction.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -30,14 +30,14 @@
implements
Restriction {
- private static final long serialVersionUID = 320;
+ private static final long serialVersionUID = 320;
- private final Declaration declaration;
+ private final Declaration declaration;
- private final Declaration[] requiredDeclarations;
+ private final Declaration[] requiredDeclarations;
- private final Evaluator evaluator;
-
+ private final Evaluator evaluator;
+
private final VariableContextEntry contextEntry;
public VariableRestriction(final FieldExtractor fieldExtractor,
@@ -60,7 +60,10 @@
public boolean isAllowed(final Extractor extractor,
final Object object,
final InternalWorkingMemory workingMemoiry) {
- return this.evaluator.evaluate( this.contextEntry.extractor, object, this.contextEntry.declaration.getExtractor(), object );
+ return this.evaluator.evaluate( this.contextEntry.extractor,
+ object,
+ this.contextEntry.declaration.getExtractor(),
+ object );
}
public boolean isAllowedCachedLeft(final ContextEntry context,
@@ -105,8 +108,8 @@
return this.declaration.equals( other.declaration ) && this.evaluator.equals( other.evaluator ) && Arrays.equals( this.requiredDeclarations,
other.requiredDeclarations );
}
-
- private final VariableContextEntry createContextEntry(FieldExtractor fieldExtractor) {
+
+ private final VariableContextEntry createContextEntry(final FieldExtractor fieldExtractor) {
if ( fieldExtractor.getValueType().isBoolean() ) {
return new BooleanVariableContextEntry( fieldExtractor,
this.declaration );
@@ -136,7 +139,7 @@
public ContextEntry entry;
public VariableContextEntry(final FieldExtractor extractor,
- final Declaration declaration) {
+ final Declaration declaration) {
this.extractor = extractor;
this.declaration = declaration;
}
@@ -170,8 +173,8 @@
public static class ObjectVariableContextEntry extends VariableContextEntry {
private static final long serialVersionUID = 3607107040739298581L;
- public Object left;
- public Object right;
+ public Object left;
+ public Object right;
public ObjectVariableContextEntry(final FieldExtractor extractor,
final Declaration declaration) {
@@ -196,8 +199,8 @@
private static final long serialVersionUID = -5316792696755228175L;
- public long left;
- public long right;
+ public long left;
+ public long right;
public LongVariableContextEntry(final FieldExtractor extractor,
final Declaration declaration) {
@@ -222,8 +225,8 @@
private static final long serialVersionUID = 6996094205302851397L;
- public double left;
- public double right;
+ public double left;
+ public double right;
public DoubleVariableContextEntry(final FieldExtractor extractor,
final Declaration declaration) {
@@ -247,8 +250,8 @@
public static class BooleanVariableContextEntry extends VariableContextEntry {
private static final long serialVersionUID = -7664012658143075200L;
- public boolean left;
- public boolean right;
+ public boolean left;
+ public boolean right;
public BooleanVariableContextEntry(final FieldExtractor extractor,
final Declaration declaration) {
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/core/IProcess.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/core/IProcess.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/core/IProcess.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,4 +1,5 @@
package org.drools.ruleflow.common.core;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -32,45 +33,49 @@
* @param id the id of the process
*/
void setId(String id);
+
/**
* Returns the id of this process.
* @return the id of this process
*/
String getId();
-
+
/**
* Sets the name of this process.
* @param name the name of this process
*/
void setName(String name);
+
/**
* Returns the name of this process.
* If no name is specified, null is returned.
* @return the name of this process
*/
String getName();
-
+
/**
* Sets the version of this process.
* @param version the version of this process
*/
void setVersion(String version);
+
/**
* Returns the version of this process.
* If no version is specified, null is returned.
* @return the version of this process
*/
String getVersion();
-
+
/**
* Sets the type of this process.
* @param type the type of this process
*/
void setType(String type);
+
/**
* Returns the type of this process.
* @return the type of this process
*/
String getType();
-
+
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/core/impl/Process.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/core/impl/Process.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/core/impl/Process.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,4 +1,5 @@
package org.drools.ruleflow.common.core.impl;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -24,55 +25,57 @@
*
* @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
*/
-public class Process implements IProcess, Serializable {
+public class Process
+ implements
+ IProcess,
+ Serializable {
private static final long serialVersionUID = 3904955335549399096L;
-
- private String id;
- private String name;
- private String version;
- private String type;
-
- public void setId(String id) {
+
+ private String id;
+ private String name;
+ private String version;
+ private String type;
+
+ public void setId(final String id) {
this.id = id;
}
-
+
public String getId() {
- return id;
+ return this.id;
}
-
- public void setName(String name) {
+
+ public void setName(final String name) {
this.name = name;
}
-
+
public String getName() {
- return name;
+ return this.name;
}
- public void setVersion(String version) {
+ public void setVersion(final String version) {
this.version = version;
}
public String getVersion() {
- return version;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public boolean equals(Object o) {
- if (o instanceof Process) {
- return ((Process) o).getName().equals(name)
- && ((Process) o).getVersion().equals(version);
- }
- return false;
- }
-
- public int hashCode() {
- return name.hashCode() + 3*version.hashCode();
+ return this.version;
}
+
+ public String getType() {
+ return this.type;
+ }
+
+ public void setType(final String type) {
+ this.type = type;
+ }
+
+ public boolean equals(final Object o) {
+ if ( o instanceof Process ) {
+ return ((Process) o).getName().equals( this.name ) && ((Process) o).getVersion().equals( this.version );
+ }
+ return false;
+ }
+
+ public int hashCode() {
+ return this.name.hashCode() + 3 * this.version.hashCode();
+ }
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/datatype/IDataType.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/datatype/IDataType.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/datatype/IDataType.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,4 +1,5 @@
package org.drools.ruleflow.common.datatype;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -22,12 +23,13 @@
*
* @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
*/
-public interface IDataType extends Serializable {
-
-
- /**
- * Returns true if the given value is a valid value of this data type.
- */
- boolean verifyDataType(Object value);
-
+public interface IDataType
+ extends
+ Serializable {
+
+ /**
+ * Returns true if the given value is a valid value of this data type.
+ */
+ boolean verifyDataType(Object value);
+
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/datatype/IDataTypeFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/datatype/IDataTypeFactory.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/datatype/IDataTypeFactory.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,4 +1,5 @@
package org.drools.ruleflow.common.datatype;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -21,7 +22,7 @@
* @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
*/
public interface IDataTypeFactory {
-
+
IDataType createDataType();
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/datatype/impl/InstanceDataTypeFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/datatype/impl/InstanceDataTypeFactory.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/datatype/impl/InstanceDataTypeFactory.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,4 +1,5 @@
package org.drools.ruleflow.common.datatype.impl;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -23,26 +24,30 @@
*
* @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
*/
-public class InstanceDataTypeFactory implements IDataTypeFactory {
-
- private Class dataTypeClass;
+public class InstanceDataTypeFactory
+ implements
+ IDataTypeFactory {
+
+ private Class dataTypeClass;
private IDataType instance;
-
- public InstanceDataTypeFactory(Class dataTypeClass) {
+
+ public InstanceDataTypeFactory(final Class dataTypeClass) {
this.dataTypeClass = dataTypeClass;
}
-
+
public IDataType createDataType() {
- if (instance == null) {
+ if ( this.instance == null ) {
try {
- instance = (IDataType) dataTypeClass.newInstance();
- } catch (IllegalAccessException e) {
- throw new RuntimeException("Could not create data type for class " + dataTypeClass, e);
- } catch (InstantiationException e) {
- throw new RuntimeException("Could not create data type for class " + dataTypeClass, e);
+ this.instance = (IDataType) this.dataTypeClass.newInstance();
+ } catch ( final IllegalAccessException e ) {
+ throw new RuntimeException( "Could not create data type for class " + this.dataTypeClass,
+ e );
+ } catch ( final InstantiationException e ) {
+ throw new RuntimeException( "Could not create data type for class " + this.dataTypeClass,
+ e );
}
}
- return instance;
+ return this.instance;
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/datatype/impl/NewInstanceDataTypeFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/datatype/impl/NewInstanceDataTypeFactory.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/datatype/impl/NewInstanceDataTypeFactory.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,4 +1,5 @@
package org.drools.ruleflow.common.datatype.impl;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -23,21 +24,25 @@
*
* @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
*/
-public class NewInstanceDataTypeFactory implements IDataTypeFactory {
-
+public class NewInstanceDataTypeFactory
+ implements
+ IDataTypeFactory {
+
private Class dataTypeClass;
-
- public NewInstanceDataTypeFactory(Class dataTypeClass) {
+
+ public NewInstanceDataTypeFactory(final Class dataTypeClass) {
this.dataTypeClass = dataTypeClass;
}
-
+
public IDataType createDataType() {
try {
- return (IDataType) dataTypeClass.newInstance();
- } catch (IllegalAccessException e) {
- throw new RuntimeException("Could not create data type for class " + dataTypeClass, e);
- } catch (InstantiationException e) {
- throw new RuntimeException("Could not create data type for class " + dataTypeClass, e);
+ return (IDataType) this.dataTypeClass.newInstance();
+ } catch ( final IllegalAccessException e ) {
+ throw new RuntimeException( "Could not create data type for class " + this.dataTypeClass,
+ e );
+ } catch ( final InstantiationException e ) {
+ throw new RuntimeException( "Could not create data type for class " + this.dataTypeClass,
+ e );
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/datatype/impl/type/BooleanDataType.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/datatype/impl/type/BooleanDataType.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/datatype/impl/type/BooleanDataType.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,4 +1,5 @@
package org.drools.ruleflow.common.datatype.impl.type;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -22,14 +23,16 @@
*
* @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
*/
-public final class BooleanDataType implements IDataType {
-
+public final class BooleanDataType
+ implements
+ IDataType {
+
private static final long serialVersionUID = 3617855257384989752L;
-
- public boolean verifyDataType(Object value) {
- if (value instanceof Boolean) {
- return true;
- }
+
+ public boolean verifyDataType(final Object value) {
+ if ( value instanceof Boolean ) {
+ return true;
+ }
return false;
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/datatype/impl/type/FloatDataType.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/datatype/impl/type/FloatDataType.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/datatype/impl/type/FloatDataType.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,4 +1,5 @@
package org.drools.ruleflow.common.datatype.impl.type;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -22,17 +23,19 @@
*
* @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
*/
-public final class FloatDataType implements IDataType {
+public final class FloatDataType
+ implements
+ IDataType {
private static final long serialVersionUID = 3257008760991069747L;
- public boolean verifyDataType(Object value) {
- if (value instanceof Float) {
- return true;
- } else if (value == null) {
- return true;
- } else {
- return false;
- }
+ public boolean verifyDataType(final Object value) {
+ if ( value instanceof Float ) {
+ return true;
+ } else if ( value == null ) {
+ return true;
+ } else {
+ return false;
+ }
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/datatype/impl/type/IntegerDataType.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/datatype/impl/type/IntegerDataType.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/datatype/impl/type/IntegerDataType.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,4 +1,5 @@
package org.drools.ruleflow.common.datatype.impl.type;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -22,17 +23,19 @@
*
* @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
*/
-public class IntegerDataType implements IDataType {
+public class IntegerDataType
+ implements
+ IDataType {
private static final long serialVersionUID = 3256443611980838707L;
- public boolean verifyDataType(Object value) {
- if (value instanceof Integer) {
- return true;
- } else if (value == null) {
- return true;
- } else {
- return false;
- }
+ public boolean verifyDataType(final Object value) {
+ if ( value instanceof Integer ) {
+ return true;
+ } else if ( value == null ) {
+ return true;
+ } else {
+ return false;
+ }
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/datatype/impl/type/ListDataType.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/datatype/impl/type/ListDataType.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/datatype/impl/type/ListDataType.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,4 +1,5 @@
package org.drools.ruleflow.common.datatype.impl.type;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -27,32 +28,35 @@
*
* @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
*/
-public class ListDataType implements IDataType, Serializable {
-
+public class ListDataType
+ implements
+ IDataType,
+ Serializable {
+
private static final long serialVersionUID = 3689069551774415161L;
- private IDataType dataType;
-
- public void setDataType(IDataType dataType) {
+ private IDataType dataType;
+
+ public void setDataType(final IDataType dataType) {
this.dataType = dataType;
}
-
+
public IDataType getDataType() {
- return dataType;
+ return this.dataType;
}
- public boolean verifyDataType(Object value) {
- if (value == null) {
- return true;
- }
- if (value instanceof List) {
- for (Iterator it = ((List) value).iterator(); it.hasNext(); ) {
- if (!dataType.verifyDataType(it.next())) {
+ public boolean verifyDataType(final Object value) {
+ if ( value == null ) {
+ return true;
+ }
+ if ( value instanceof List ) {
+ for ( final Iterator it = ((List) value).iterator(); it.hasNext(); ) {
+ if ( !this.dataType.verifyDataType( it.next() ) ) {
return false;
}
}
return true;
- }
- return false;
+ }
+ return false;
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/datatype/impl/type/StringDataType.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/datatype/impl/type/StringDataType.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/datatype/impl/type/StringDataType.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,4 +1,5 @@
package org.drools.ruleflow.common.datatype.impl.type;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -22,17 +23,19 @@
*
* @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
*/
-public class StringDataType implements IDataType {
+public class StringDataType
+ implements
+ IDataType {
private static final long serialVersionUID = 3258416135924758834L;
- public boolean verifyDataType(Object value) {
- if (value instanceof String) {
- return true;
- } else if (value == null) {
- return true;
- } else {
- return false;
- }
+ public boolean verifyDataType(final Object value) {
+ if ( value instanceof String ) {
+ return true;
+ } else if ( value == null ) {
+ return true;
+ } else {
+ return false;
+ }
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/datatype/impl/type/UndefinedDataType.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/datatype/impl/type/UndefinedDataType.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/datatype/impl/type/UndefinedDataType.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,4 +1,5 @@
package org.drools.ruleflow.common.datatype.impl.type;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -22,22 +23,24 @@
*
* @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
*/
-public final class UndefinedDataType implements IDataType {
-
- private static final long serialVersionUID = 3690196546763699768L;
+public final class UndefinedDataType
+ implements
+ IDataType {
+
+ private static final long serialVersionUID = 3690196546763699768L;
private static UndefinedDataType instance;
-
+
public static UndefinedDataType getInstance() {
- if (instance == null) {
+ if ( instance == null ) {
instance = new UndefinedDataType();
}
return instance;
}
- public boolean verifyDataType(Object value) {
- if (value == null) {
- return true;
- }
- return false;
+ public boolean verifyDataType(final Object value) {
+ if ( value == null ) {
+ return true;
+ }
+ return false;
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/instance/IProcessInstance.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/instance/IProcessInstance.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/instance/IProcessInstance.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,4 +1,5 @@
package org.drools.ruleflow.common.instance;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -26,21 +27,26 @@
*
* @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
*/
-public interface IProcessInstance extends Serializable {
+public interface IProcessInstance
+ extends
+ Serializable {
- int STATE_PENDING = 0;
- int STATE_ACTIVE = 1;
- int STATE_COMPLETED = 2;
- int STATE_ABORTED = 3;
- int STATE_SUSPENDED = 4;
+ int STATE_PENDING = 0;
+ int STATE_ACTIVE = 1;
+ int STATE_COMPLETED = 2;
+ int STATE_ABORTED = 3;
+ int STATE_SUSPENDED = 4;
- void setId(long id);
+ void setId(long id);
+
long getId();
-
+
void setProcess(IProcess process);
+
IProcess getProcess();
-
+
void setState(int state);
+
int getState();
-
+
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/instance/impl/ProcessInstance.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/instance/impl/ProcessInstance.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/instance/impl/ProcessInstance.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,4 +1,5 @@
package org.drools.ruleflow.common.instance.impl;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -23,44 +24,46 @@
*
* @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
*/
-public abstract class ProcessInstance implements IProcessInstance {
+public abstract class ProcessInstance
+ implements
+ IProcessInstance {
- private long id;
+ private long id;
private IProcess process;
- private int state = STATE_PENDING;
-
- public void setId(long id) {
+ private int state = STATE_PENDING;
+
+ public void setId(final long id) {
this.id = id;
}
-
+
public long getId() {
- return id;
+ return this.id;
}
-
- public void setProcess(IProcess process) {
+
+ public void setProcess(final IProcess process) {
this.process = process;
}
-
+
public IProcess getProcess() {
- return process;
+ return this.process;
}
-
- public void setState(int state) {
+
+ public void setState(final int state) {
this.state = state;
}
-
+
public int getState() {
- return state;
+ return this.state;
}
-
+
public String toString() {
- StringBuffer b = new StringBuffer("ProcessInstance ");
- b.append(getId());
- b.append(" [processId=");
- b.append(process.getId());
- b.append(",state=");
- b.append(state);
- b.append("]");
- return b.toString();
+ final StringBuffer b = new StringBuffer( "ProcessInstance " );
+ b.append( getId() );
+ b.append( " [processId=" );
+ b.append( this.process.getId() );
+ b.append( ",state=" );
+ b.append( this.state );
+ b.append( "]" );
+ return b.toString();
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/IConnection.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/IConnection.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/IConnection.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,4 +1,5 @@
package org.drools.ruleflow.core;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -21,31 +22,31 @@
* @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
*/
public interface IConnection {
-
- /**
- * The connection type
- */
- int TYPE_NORMAL = 1;
- int TYPE_ABORT = 2;
-
- /**
- * Returns the from node of the connection.
- * @return the from node of the connection.
- */
- INode getFrom();
/**
+ * The connection type
+ */
+ int TYPE_NORMAL = 1;
+ int TYPE_ABORT = 2;
+
+ /**
+ * Returns the from node of the connection.
+ * @return the from node of the connection.
+ */
+ INode getFrom();
+
+ /**
* Returns the to node of the connection
* @return the to node of the connection
*/
- INode getTo();
+ INode getTo();
/**
* Returns the connection type
* @return the connection type
*/
int getType();
-
+
/**
* Destroys the connection. This method also removes the
* connection on the <code>to</code> and <code>from</code> nodes.
@@ -53,5 +54,5 @@
* an <code>IllegalStateException</code>.
*/
void terminate();
-
+
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/IConstraint.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/IConstraint.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/IConstraint.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,4 +1,5 @@
package org.drools.ruleflow.core;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -23,24 +24,24 @@
*/
public interface IConstraint {
- /**
- * Typically this method returns the constraint
- * @return the constraint
- */
- String getConstraint();
-
- /**
- * Method for setting the constraint
- * @param constraint the constraint
- */
+ /**
+ * Typically this method returns the constraint
+ * @return the constraint
+ */
+ String getConstraint();
+
+ /**
+ * Method for setting the constraint
+ * @param constraint the constraint
+ */
void setConstraint(String constraint);
-
+
/**
* Returns the name of the constraint
* @return the name of the constraint
*/
String getName();
-
+
/**
* Sets the name of the constraint
* @param name the name of the constraint
@@ -53,12 +54,12 @@
* @return the priority of the constraint
*/
int getPriority();
-
+
/**
* Method for setting the priority of the constraint
*
* @param priority the priority of the constraint
*/
void setPriority(int priority);
-
+
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/IEndNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/IEndNode.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/IEndNode.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,4 +1,5 @@
package org.drools.ruleflow.core;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -15,19 +16,20 @@
* limitations under the License.
*/
-
/**
* Represents an end node in a RuleFlow.
* An end node has one incoming and no outgoing connections.
*
* @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
*/
-public interface IEndNode extends INode {
-
- /**
- * Convenience method for returning the incoming <code>IConnection</code>.
- * @return the incoming <code>IConnection</code>
- */
+public interface IEndNode
+ extends
+ INode {
+
+ /**
+ * Convenience method for returning the incoming <code>IConnection</code>.
+ * @return the incoming <code>IConnection</code>
+ */
IConnection getFrom();
-
+
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/IJoin.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/IJoin.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/IJoin.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,4 +1,5 @@
package org.drools.ruleflow.core;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -24,41 +25,42 @@
*
* @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
*/
-public interface IJoin extends INode {
-
+public interface IJoin
+ extends
+ INode {
+
int TYPE_UNDEFINED = 0;
/**
* The outgoing connection of a join of this type is triggered
* when all its incoming connections have been triggered.
- */
- int TYPE_AND = 1;
+ */
+ int TYPE_AND = 1;
/**
* The outgoing connection of a join of this type is triggered
* when one of its incoming connections has been triggered.
- */
- int TYPE_XOR = 2;
-
+ */
+ int TYPE_XOR = 2;
+
/**
* Sets the type of the join.
*
* @param type The type of the join
* @throws IllegalArgumentException if type is null
*/
- void setType(int type);
-
+ void setType(int type);
+
/**
* Returns the type of the join.
*
* @return the type of the join.
- */
+ */
int getType();
-
+
/**
* Convenience method for returning the outgoing connection of the join
*
* @return the outgoing connection of the join
*/
IConnection getTo();
-
-
+
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/INode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/INode.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/INode.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,4 +1,5 @@
package org.drools.ruleflow.core;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -23,46 +24,48 @@
*
* @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
*/
-public interface INode extends Serializable {
-
- /**
- * Returns the id of the node
- *
- * @return the id of the node
- */
+public interface INode
+ extends
+ Serializable {
+
+ /**
+ * Returns the id of the node
+ *
+ * @return the id of the node
+ */
long getId();
-
+
/**
* Method for setting the id of the node
*
* @param id the id of the node
*/
void setId(long id);
-
+
/**
* Returns the name of the node
*
* @return the name of the node
*/
String getName();
-
+
/**
* Method for setting the name of the node
*
* @param name the name of the node
*/
void setName(String name);
-
+
/**
* Returns the incoming connections
* @return the incoming connections
*/
List getIncomingConnections();
-
+
/**
* Returns the outgoing connections
* @return the outgoing connections
*/
List getOutgoingConnections();
-
+
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/IRuleFlowProcess.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/IRuleFlowProcess.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/IRuleFlowProcess.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,4 +1,5 @@
package org.drools.ruleflow.core;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -24,23 +25,24 @@
*
* @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
*/
-public interface IRuleFlowProcess extends IProcess {
-
- /**
- * Returns the start node of this RuleFlow process.
- *
- * @return the start node
- */
+public interface IRuleFlowProcess
+ extends
+ IProcess {
+
+ /**
+ * Returns the start node of this RuleFlow process.
+ *
+ * @return the start node
+ */
IStartNode getStart();
-
-
+
/**
* Returns the nodes of this RuleFlow process.
*
* @return the nodes of this RuleFlow process
*/
INode[] getNodes();
-
+
/**
* Returns the node with the given id
*
@@ -49,16 +51,16 @@
* @throws IllegalArgumentException if an unknown id is passed
*/
INode getNode(long id);
-
- /**
- * Method for adding a node to this RuleFlow process.
- * Note that the node will get an id unique for this process.
- *
- * @param node the node to be added
- * @throws IllegalArgumentException if <code>node</code> is null
- */
+
+ /**
+ * Method for adding a node to this RuleFlow process.
+ * Note that the node will get an id unique for this process.
+ *
+ * @param node the node to be added
+ * @throws IllegalArgumentException if <code>node</code> is null
+ */
void addNode(INode node);
-
+
/**
* Method for removing a node from this RuleFlow process
*
@@ -66,14 +68,14 @@
* @throws IllegalArgumentException if <code>node</code> is null or unknown
*/
void removeNode(INode node);
-
+
/**
* Returns the global variables used in this RuleFlow process
*
* @return a list of variables of this RuleFlow process
*/
List getVariables();
-
+
/**
* Sets the global variables used in this RuleFlow process
*
@@ -81,7 +83,7 @@
* @throws IllegalArugmentException if <code>variables</code> is null
*/
void setVariables(List variables);
-
+
/**
* Returns the names of the global variables used in this RuleFlow process
*
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/IRuleFlowProcessValidationError.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/IRuleFlowProcessValidationError.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/IRuleFlowProcessValidationError.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,4 +1,5 @@
package org.drools.ruleflow.core;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -22,24 +23,24 @@
*/
public interface IRuleFlowProcessValidationError {
- String NO_PROCESS_NAME = "RuleFlow process has no name.";
- String NO_PROCESS_ID = "RuleFlow process has no id.";
- String NO_START_NODE = "RuleFlow process has no start node.";
- String START_NODE_WITHOUT_OUTGOING_NODES = "Start node has no outgoing connection.";
- String END_NODE_HAS_NO_INCOMING_CONNECTIONS = "End node has no incoming connection.";
- String NO_END_NODE = "No end node found.";
- String RULE_SET_NODE_WITHOUT_INCOMING_CONNECTIONS = "RuleSet node has no incoming connection.";
- String RULE_SET_NODE_WITHOUT_OUTGOING_CONNECTIONS = "RuleSet node has no outgoing connection.";
- String RULE_SET_NODE_WITHOUT_RULE_SET_GROUP = "RuleSet node has no ruleflow-group specified.";
- String SPLIT_WITHOUT_TYPE = "Split node has no type.";
- String SPLIT_WITHOUT_INCOMING_CONNECTION = "Split node has no incoming connection.";
- String SPLIT_NOT_ENOUGH_OUTGOING_CONNECTIONS = "Split node does not have enough outgoing connections.";
- String SPLIT_OUTGOING_CONNECTION_WITHOUT_CONSTRAINT = "An outgoing connection of a split node has no constraint.";
- String JOIN_WITHOUT_TYPE = "Join node has no type.";
- String JOIN_NOT_ENOUGH_INCOMING_CONNECTIONS = "Join node does not have enough incoming connections.";
- String JOIN_WITHOUT_OUTGOING_CONNECTION = "Join node has no outgoing connection.";
- String VARIABLE_WITHOUT_TYPE = "A variable has no type.";
- String ALL_NODES_CONNECTED_TO_START = "A node is not connected to the start node.";
-
- String getType();
+ String NO_PROCESS_NAME = "RuleFlow process has no name.";
+ String NO_PROCESS_ID = "RuleFlow process has no id.";
+ String NO_START_NODE = "RuleFlow process has no start node.";
+ String START_NODE_WITHOUT_OUTGOING_NODES = "Start node has no outgoing connection.";
+ String END_NODE_HAS_NO_INCOMING_CONNECTIONS = "End node has no incoming connection.";
+ String NO_END_NODE = "No end node found.";
+ String RULE_SET_NODE_WITHOUT_INCOMING_CONNECTIONS = "RuleSet node has no incoming connection.";
+ String RULE_SET_NODE_WITHOUT_OUTGOING_CONNECTIONS = "RuleSet node has no outgoing connection.";
+ String RULE_SET_NODE_WITHOUT_RULE_SET_GROUP = "RuleSet node has no ruleflow-group specified.";
+ String SPLIT_WITHOUT_TYPE = "Split node has no type.";
+ String SPLIT_WITHOUT_INCOMING_CONNECTION = "Split node has no incoming connection.";
+ String SPLIT_NOT_ENOUGH_OUTGOING_CONNECTIONS = "Split node does not have enough outgoing connections.";
+ String SPLIT_OUTGOING_CONNECTION_WITHOUT_CONSTRAINT = "An outgoing connection of a split node has no constraint.";
+ String JOIN_WITHOUT_TYPE = "Join node has no type.";
+ String JOIN_NOT_ENOUGH_INCOMING_CONNECTIONS = "Join node does not have enough incoming connections.";
+ String JOIN_WITHOUT_OUTGOING_CONNECTION = "Join node has no outgoing connection.";
+ String VARIABLE_WITHOUT_TYPE = "A variable has no type.";
+ String ALL_NODES_CONNECTED_TO_START = "A node is not connected to the start node.";
+
+ String getType();
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/IRuleFlowProcessValidator.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/IRuleFlowProcessValidator.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/IRuleFlowProcessValidator.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,4 +1,5 @@
package org.drools.ruleflow.core;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -21,7 +22,7 @@
* @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
*/
public interface IRuleFlowProcessValidator {
-
+
IRuleFlowProcessValidationError[] validateProcess(IRuleFlowProcess process);
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/IRuleSetNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/IRuleSetNode.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/IRuleSetNode.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,4 +1,5 @@
package org.drools.ruleflow.core;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -20,28 +21,30 @@
*
* @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
*/
-public interface IRuleSetNode extends INode {
-
+public interface IRuleSetNode
+ extends
+ INode {
+
/**
* Returns the incoming connection of the RuleSetNode.
*
* @return the incoming connection of the RuleSetNode.
*/
IConnection getFrom();
-
+
/**
* Returns the outgoing connection of the RuleSetNode.
*
* @return the outgoing connection of the RuleSetNode.
*/
IConnection getTo();
-
+
/**
* Returns the ruleflow-group of the RuleSetNode.
*
* @return the ruleflow-group of the RuleSetNode.
*/
- String getRuleFlowGroup();
+ String getRuleFlowGroup();
/**
* Sets the ruleflow-group of the RuleSetNode.
@@ -49,5 +52,5 @@
* @param ruleFlowGroup The ruleflow-group of the RuleSetNode
* @throws IllegalArgumentException if type is null
*/
- void setRuleFlowGroup(String ruleFlowGroup);
+ void setRuleFlowGroup(String ruleFlowGroup);
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/ISplit.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/ISplit.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/ISplit.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,4 +1,5 @@
package org.drools.ruleflow.core;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -26,48 +27,50 @@
*
* @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
*/
-public interface ISplit extends INode {
-
- int TYPE_UNDEFINED = 0;
+public interface ISplit
+ extends
+ INode {
+
+ int TYPE_UNDEFINED = 0;
/**
* All outgoing connections of a split of this type are triggered
* when its incoming connection has been triggered. A split of this
* type should have no constraints linked to any of its outgoing
* connections.
- */
- int TYPE_AND = 1;
+ */
+ int TYPE_AND = 1;
/**
* Exactly one outgoing connection of a split of this type is triggered
* when its incoming connection has been triggered. Which connection
* is based on the constraints associated with each of the connections:
* the connection with the highest priority whose constraint is satisfied
* is triggered.
- */
- int TYPE_XOR = 2;
+ */
+ int TYPE_XOR = 2;
/**
* One or multiple outgoing connections of a split of this type are
* triggered when its incoming connection has been triggered. Which
* connections is based on the constraints associated with each of the
* connections: all connections whose constraint is satisfied are
* triggered.
- */
- int TYPE_OR = 3;
-
- /**
+ */
+ int TYPE_OR = 3;
+
+ /**
* Sets the type of the split.
*
* @param type The type of the split
* @throws IllegalArgumentException if type is null
- */
+ */
void setType(int type);
-
+
/**
* Returns the type of the split.
*
* @return the type of the split.
- */
+ */
int getType();
-
+
/**
* Returns the corresponding constraint of the given outgoing connection
*
@@ -79,7 +82,7 @@
* on a split with split type of something else than XOR or OR
*/
IConstraint getConstraint(IConnection connection);
-
+
/**
* Method for setting a constraint corresponding to the given
* outgoing connection
@@ -91,8 +94,9 @@
* @throws UnsupportedOperationException if the split type is
* something else than XOR or OR
*/
- void setConstraint(IConnection connection, IConstraint constraint);
-
+ void setConstraint(IConnection connection,
+ IConstraint constraint);
+
/**
* Returns the constraints of the split.
*
@@ -102,12 +106,12 @@
* on a split with split type of something else than XOR or OR
*/
Map getConstraints();
-
+
/**
* Convenience method for returning the incoming connection of the split.
*
* @return the incoming connection ot the split.
*/
IConnection getFrom();
-
+
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/IStartNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/IStartNode.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/IStartNode.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,4 +1,5 @@
package org.drools.ruleflow.core;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -21,12 +22,14 @@
*
* @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
*/
-public interface IStartNode extends INode {
+public interface IStartNode
+ extends
+ INode {
- /**
- * Convenience method for returning the outgoing <code>IConnection</code>.
- * @return the outgoing <code>IConnection</code>
- */
+ /**
+ * Convenience method for returning the outgoing <code>IConnection</code>.
+ * @return the outgoing <code>IConnection</code>
+ */
IConnection getTo();
-
+
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/IVariable.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/IVariable.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/IVariable.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,4 +1,5 @@
package org.drools.ruleflow.core;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -27,14 +28,17 @@
* @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
*/
public interface IVariable {
-
+
String getName();
+
void setName(String name);
-
+
IDataType getType();
+
void setType(IDataType type);
-
- Serializable getValue();
+
+ Serializable getValue();
+
void setValue(Serializable value);
-
+
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/Connection.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/Connection.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/Connection.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,4 +1,5 @@
package org.drools.ruleflow.core.impl;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -25,17 +26,20 @@
*
* @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
*/
-public class Connection implements IConnection, Serializable {
-
+public class Connection
+ implements
+ IConnection,
+ Serializable {
+
private static final long serialVersionUID = 320L;
- private int type;
- private Node from;
- private Node to;
-
+ private int type;
+ private Node from;
+ private Node to;
+
private Connection() {
}
-
+
/**
* Creates a new connection, given a from node, a to node
* and a type.
@@ -44,64 +48,65 @@
* @param to The to node
* @param type The connection type
*/
- public Connection(INode from, INode to, int type) {
- if (from == null) {
- throw new IllegalArgumentException("From node is null!");
- }
- if (to == null) {
- throw new IllegalArgumentException("To node is null!");
- }
- if (from.equals(to)) {
- throw new IllegalArgumentException("To and from nodes are the same!");
- }
- this.from = (Node) from;
+ public Connection(final INode from,
+ final INode to,
+ final int type) {
+ if ( from == null ) {
+ throw new IllegalArgumentException( "From node is null!" );
+ }
+ if ( to == null ) {
+ throw new IllegalArgumentException( "To node is null!" );
+ }
+ if ( from.equals( to ) ) {
+ throw new IllegalArgumentException( "To and from nodes are the same!" );
+ }
+ this.from = (Node) from;
this.to = (Node) to;
this.type = type;
- this.from.addOutgoingConnection(this);
- this.to.addIncomingConnection(this);
+ this.from.addOutgoingConnection( this );
+ this.to.addIncomingConnection( this );
}
-
+
public synchronized void terminate() {
- from.removeOutgoingConnection(this);
- to.removeIncomingConnection(this);
- type = 0;
- from = null;
- to = null;
+ this.from.removeOutgoingConnection( this );
+ this.to.removeIncomingConnection( this );
+ this.type = 0;
+ this.from = null;
+ this.to = null;
}
public INode getFrom() {
- return from;
+ return this.from;
}
-
+
public INode getTo() {
- return to;
+ return this.to;
}
-
+
public int getType() {
- return type;
+ return this.type;
}
-
- public boolean equals(Object object) {
- if (object instanceof Connection) {
- Connection connection = (Connection) object;
- return type == connection.getType() && getFrom().equals(connection.getFrom())
- && getTo().equals(connection.getTo());
+
+ public boolean equals(final Object object) {
+ if ( object instanceof Connection ) {
+ final Connection connection = (Connection) object;
+ return this.type == connection.getType() && getFrom().equals( connection.getFrom() ) && getTo().equals( connection.getTo() );
}
return false;
}
-
+
public int hashCode() {
- return getFrom().hashCode() + 3*getTo().hashCode() + 5*getType();
+ return getFrom().hashCode() + 3 * getTo().hashCode() + 5 * getType();
}
-
+
public String toString() {
- StringBuffer sb = new StringBuffer("Connection ");
- sb.append(getFrom());
- sb.append(" - ");
- sb.append(getTo());
- sb.append(" [type=");
- sb.append(getType());
- sb.append("]");
- return sb.toString();
+ final StringBuffer sb = new StringBuffer( "Connection " );
+ sb.append( getFrom() );
+ sb.append( " - " );
+ sb.append( getTo() );
+ sb.append( " [type=" );
+ sb.append( getType() );
+ sb.append( "]" );
+ return sb.toString();
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/Constraint.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/Constraint.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/Constraint.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,4 +1,5 @@
package org.drools.ruleflow.core.impl;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -24,39 +25,42 @@
*
* @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
*/
-public class Constraint implements IConstraint, Serializable {
+public class Constraint
+ implements
+ IConstraint,
+ Serializable {
private static final long serialVersionUID = 3257849861633422902L;
- private String name;
- private String constraint;
- private int priority;
-
+ private String name;
+ private String constraint;
+ private int priority;
+
public String getConstraint() {
- return constraint;
+ return this.constraint;
}
-
- public void setConstraint(String constraint) {
+
+ public void setConstraint(final String constraint) {
this.constraint = constraint;
}
-
+
public String getName() {
- return name;
+ return this.name;
}
-
- public void setName(String name) {
+
+ public void setName(final String name) {
this.name = name;
}
-
+
public String toString() {
- return name;
+ return this.name;
}
-
+
public int getPriority() {
- return priority;
+ return this.priority;
}
-
- public void setPriority(int priority) {
+
+ public void setPriority(final int priority) {
this.priority = priority;
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/EndNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/EndNode.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/EndNode.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,4 +1,5 @@
package org.drools.ruleflow.core.impl;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -25,30 +26,32 @@
*
* @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
*/
-public class EndNode extends Node implements IEndNode {
-
+public class EndNode extends Node
+ implements
+ IEndNode {
+
private static final long serialVersionUID = 3906930075512484153L;
-
+
public IConnection getFrom() {
- List list = getIncomingConnections();
- if (list.size() > 0) {
- return (IConnection) list.get(0);
- }
- return null;
+ final List list = getIncomingConnections();
+ if ( list.size() > 0 ) {
+ return (IConnection) list.get( 0 );
+ }
+ return null;
}
-
- protected void validateAddIncomingConnection(IConnection connection) {
- super.validateAddIncomingConnection(connection);
- if (getIncomingConnections().size() > 0) {
- throw new IllegalArgumentException("An end node cannot have more than one incoming connection");
+
+ protected void validateAddIncomingConnection(final IConnection connection) {
+ super.validateAddIncomingConnection( connection );
+ if ( getIncomingConnections().size() > 0 ) {
+ throw new IllegalArgumentException( "An end node cannot have more than one incoming connection" );
}
}
- protected void validateAddOutgoingConnection(IConnection connection) {
- throw new UnsupportedOperationException("An end node does not have an outgoing connection");
+ protected void validateAddOutgoingConnection(final IConnection connection) {
+ throw new UnsupportedOperationException( "An end node does not have an outgoing connection" );
}
- protected void validateRemoveOutgoingConnection(IConnection connection) {
- throw new UnsupportedOperationException("An end node does not have an outgoing connection");
+ protected void validateRemoveOutgoingConnection(final IConnection connection) {
+ throw new UnsupportedOperationException( "An end node does not have an outgoing connection" );
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/Join.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/Join.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/Join.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,4 +1,5 @@
package org.drools.ruleflow.core.impl;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -23,40 +24,41 @@
*
* @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
*/
-public class Join extends Node implements IJoin {
-
+public class Join extends Node
+ implements
+ IJoin {
+
private static final long serialVersionUID = 3257004367155573815L;
- private int type;
-
+ private int type;
+
public Join() {
- this.type = TYPE_UNDEFINED;
+ this.type = TYPE_UNDEFINED;
}
-
- public void setType(int type) {
- this.type = type;
+
+ public void setType(final int type) {
+ this.type = type;
}
-
+
public int getType() {
- return type;
+ return this.type;
}
-
+
public IConnection getTo() {
- if (getOutgoingConnections().size() > 0) {
- return (IConnection) getOutgoingConnections().get(0);
- }
- return null;
- }
+ if ( getOutgoingConnections().size() > 0 ) {
+ return (IConnection) getOutgoingConnections().get( 0 );
+ }
+ return null;
+ }
- protected void validateAddOutgoingConnection(IConnection connection) {
- super.validateAddOutgoingConnection(connection);
- if (connection.getType() != IConnection.TYPE_NORMAL) {
- throw new IllegalArgumentException("Unknown connection type :" + connection.getType()
- + ", only NORMAL is allowed as outgoing connection.");
+ protected void validateAddOutgoingConnection(final IConnection connection) {
+ super.validateAddOutgoingConnection( connection );
+ if ( connection.getType() != IConnection.TYPE_NORMAL ) {
+ throw new IllegalArgumentException( "Unknown connection type :" + connection.getType() + ", only NORMAL is allowed as outgoing connection." );
}
- if (getOutgoingConnections().size() > 0) {
- throw new IllegalArgumentException("A join cannot have more than one outgoing connection");
+ if ( getOutgoingConnections().size() > 0 ) {
+ throw new IllegalArgumentException( "A join cannot have more than one outgoing connection" );
}
}
-
+
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/Node.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/Node.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/Node.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,4 +1,5 @@
package org.drools.ruleflow.core.impl;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -28,154 +29,155 @@
*
* @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
*/
-public abstract class Node implements INode, Serializable {
-
+public abstract class Node
+ implements
+ INode,
+ Serializable {
+
protected static final Node[] EMPTY_NODE_ARRAY = new Node[0];
-
- private long id;
- private String name;
- private List incomingConnections;
- private List outgoingConnections;
-
+
+ private long id;
+ private String name;
+ private List incomingConnections;
+ private List outgoingConnections;
+
public Node() {
this.id = -1;
- incomingConnections = new ArrayList();
- outgoingConnections = new ArrayList();
+ this.incomingConnections = new ArrayList();
+ this.outgoingConnections = new ArrayList();
}
-
+
public long getId() {
- return id;
+ return this.id;
}
-
- public void setId(long id) {
+
+ public void setId(final long id) {
this.id = id;
}
-
+
public String getName() {
- return name;
+ return this.name;
}
-
- public void setName(String name) {
+
+ public void setName(final String name) {
this.name = name;
}
-
+
public List getIncomingConnections() {
- return Collections.unmodifiableList(incomingConnections);
+ return Collections.unmodifiableList( this.incomingConnections );
}
-
+
public List getOutgoingConnections() {
- return Collections.unmodifiableList(outgoingConnections);
+ return Collections.unmodifiableList( this.outgoingConnections );
}
-
- protected void addIncomingConnection(IConnection connection) {
- validateAddIncomingConnection(connection);
- incomingConnections.add(connection);
+
+ protected void addIncomingConnection(final IConnection connection) {
+ validateAddIncomingConnection( connection );
+ this.incomingConnections.add( connection );
}
-
+
/**
- * This method validates whether the given connection can be added. If the
- * connection cannot be added, an IllegalArgumentException is thrown.
- * <p>
- *
- * @param connection
- * the incoming connection to be added
- * @throws IllegalArgumentException
- * is thrown if the connection is null, or if a connection is
- * added twice. If subclasses want to change the rules for
- * adding incoming connections the
- * <code>validateAddIncomingConnection(IConnection connection)</code>
- * should be overridden.
- */
- protected void validateAddIncomingConnection(IConnection connection) {
- if (connection == null) {
- throw new IllegalArgumentException("Connection cannot be null");
- }
- if (incomingConnections.contains(connection)) {
- throw new IllegalArgumentException("Connection is already added");
- }
+ * This method validates whether the given connection can be added. If the
+ * connection cannot be added, an IllegalArgumentException is thrown.
+ * <p>
+ *
+ * @param connection
+ * the incoming connection to be added
+ * @throws IllegalArgumentException
+ * is thrown if the connection is null, or if a connection is
+ * added twice. If subclasses want to change the rules for
+ * adding incoming connections the
+ * <code>validateAddIncomingConnection(IConnection connection)</code>
+ * should be overridden.
+ */
+ protected void validateAddIncomingConnection(final IConnection connection) {
+ if ( connection == null ) {
+ throw new IllegalArgumentException( "Connection cannot be null" );
+ }
+ if ( this.incomingConnections.contains( connection ) ) {
+ throw new IllegalArgumentException( "Connection is already added" );
+ }
}
-
- protected void addOutgoingConnection(IConnection connection) {
- validateAddOutgoingConnection(connection);
- outgoingConnections.add(connection);
+
+ protected void addOutgoingConnection(final IConnection connection) {
+ validateAddOutgoingConnection( connection );
+ this.outgoingConnections.add( connection );
}
-
+
/**
- * This method validates whether the given connection can be added. If the
- * connection cannot be added, an IllegalArgumentException is thrown.
- * <p>
- *
- * @param connection
- * the outgoin connection to be added
- * @throws IllegalArgumentException
- * is thrown if the connection is null, or if a connection is
- * added twice. If subclasses want to change the rules for
- * adding outgoing connections the
- * <code>validateAddIncomingConnection(IConnection connection)</code>
- * should be overridden.
- */
- protected void validateAddOutgoingConnection(IConnection connection) {
- if (connection == null) {
- throw new IllegalArgumentException("Connection cannot be null");
- }
- if (outgoingConnections.contains(connection)) {
- throw new IllegalArgumentException("Connection is already added");
- }
+ * This method validates whether the given connection can be added. If the
+ * connection cannot be added, an IllegalArgumentException is thrown.
+ * <p>
+ *
+ * @param connection
+ * the outgoin connection to be added
+ * @throws IllegalArgumentException
+ * is thrown if the connection is null, or if a connection is
+ * added twice. If subclasses want to change the rules for
+ * adding outgoing connections the
+ * <code>validateAddIncomingConnection(IConnection connection)</code>
+ * should be overridden.
+ */
+ protected void validateAddOutgoingConnection(final IConnection connection) {
+ if ( connection == null ) {
+ throw new IllegalArgumentException( "Connection cannot be null" );
+ }
+ if ( this.outgoingConnections.contains( connection ) ) {
+ throw new IllegalArgumentException( "Connection is already added" );
+ }
}
-
- protected void removeIncomingConnection(IConnection connection) {
- validateRemoveIncomingConnection(connection);
- incomingConnections.remove(connection);
+
+ protected void removeIncomingConnection(final IConnection connection) {
+ validateRemoveIncomingConnection( connection );
+ this.incomingConnections.remove( connection );
}
-
+
/**
- * This method validates whether the given connection can be removed
- * <p>
- *
- * @param connection
- * the incoming connection
- * @throws IllegalArgumentException
- * is thrown if connectin is null, or unknown. If subclasses
- * want to change the rules for removing incoming connections
- * the
- * <code>validateRemoveIncomingConnection(IConnection connection)</code>
- * should be overridden.
- */
- protected void validateRemoveIncomingConnection(IConnection connection) {
- if (connection == null) {
- throw new IllegalArgumentException("Connection is null");
- }
- if (!incomingConnections.contains(connection)) {
- throw new IllegalArgumentException("Given connection <"
- + connection + "> is not part of the incoming connections");
- }
+ * This method validates whether the given connection can be removed
+ * <p>
+ *
+ * @param connection
+ * the incoming connection
+ * @throws IllegalArgumentException
+ * is thrown if connectin is null, or unknown. If subclasses
+ * want to change the rules for removing incoming connections
+ * the
+ * <code>validateRemoveIncomingConnection(IConnection connection)</code>
+ * should be overridden.
+ */
+ protected void validateRemoveIncomingConnection(final IConnection connection) {
+ if ( connection == null ) {
+ throw new IllegalArgumentException( "Connection is null" );
+ }
+ if ( !this.incomingConnections.contains( connection ) ) {
+ throw new IllegalArgumentException( "Given connection <" + connection + "> is not part of the incoming connections" );
+ }
}
-
- protected void removeOutgoingConnection(IConnection connection) {
- validateRemoveOutgoingConnection(connection);
- outgoingConnections.remove(connection);
+
+ protected void removeOutgoingConnection(final IConnection connection) {
+ validateRemoveOutgoingConnection( connection );
+ this.outgoingConnections.remove( connection );
}
-
+
/**
- * This method validates whether the given connection can be removed
- * <p>
- *
- * @param connection
- * the outgoing connection
- * @throws IllegalArgumentException
- * is thrown if connectin is null, or unknown. If subclasses
- * want to change the rules for removing outgoing connections
- * the
- * <code>validateRemoveOutgoingConnection(IConnection connection)</code>
- * should be overridden.
- */
- protected void validateRemoveOutgoingConnection(IConnection connection) {
- if (connection == null) {
- throw new IllegalArgumentException("Connection is null");
- }
- if (!outgoingConnections.contains(connection)) {
- throw new IllegalArgumentException("Given connection <"
- + connection + "> is not part of the outgoing connections");
- }
+ * This method validates whether the given connection can be removed
+ * <p>
+ *
+ * @param connection
+ * the outgoing connection
+ * @throws IllegalArgumentException
+ * is thrown if connectin is null, or unknown. If subclasses
+ * want to change the rules for removing outgoing connections
+ * the
+ * <code>validateRemoveOutgoingConnection(IConnection connection)</code>
+ * should be overridden.
+ */
+ protected void validateRemoveOutgoingConnection(final IConnection connection) {
+ if ( connection == null ) {
+ throw new IllegalArgumentException( "Connection is null" );
+ }
+ if ( !this.outgoingConnections.contains( connection ) ) {
+ throw new IllegalArgumentException( "Given connection <" + connection + "> is not part of the outgoing connections" );
+ }
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/RuleFlowProcess.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/RuleFlowProcess.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/RuleFlowProcess.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,4 +1,5 @@
package org.drools.ruleflow.core.impl;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -33,101 +34,101 @@
*
* @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
*/
-public class RuleFlowProcess extends Process implements IRuleFlowProcess {
-
- public static final String RULEFLOW_TYPE = "RuleFlow";
+public class RuleFlowProcess extends Process
+ implements
+ IRuleFlowProcess {
- private static final long serialVersionUID = 3257005445309609272L;
+ public static final String RULEFLOW_TYPE = "RuleFlow";
- private Map nodes;
- private List variables;
- private long lastNodeId;
-
+ private static final long serialVersionUID = 3257005445309609272L;
+
+ private Map nodes;
+ private List variables;
+ private long lastNodeId;
+
public RuleFlowProcess() {
super();
- setType(RULEFLOW_TYPE);
- nodes = new HashMap();
- variables = new ArrayList();
+ setType( RULEFLOW_TYPE );
+ this.nodes = new HashMap();
+ this.variables = new ArrayList();
}
-
+
public IStartNode getStart() {
- for (Iterator it = nodes.values().iterator(); it.hasNext(); ) {
- INode node = (INode) it.next();
- if (node instanceof IStartNode) {
- return (IStartNode) node;
- }
- }
- return null;
+ for ( final Iterator it = this.nodes.values().iterator(); it.hasNext(); ) {
+ final INode node = (INode) it.next();
+ if ( node instanceof IStartNode ) {
+ return (IStartNode) node;
+ }
+ }
+ return null;
}
-
+
public INode[] getNodes() {
- return (INode[]) nodes.values().toArray(new INode[nodes.size()]);
+ return (INode[]) this.nodes.values().toArray( new INode[this.nodes.size()] );
}
-
- public INode getNode(long id) {
- Long idLong = new Long(id);
- if (!nodes.containsKey(idLong)) {
- throw new IllegalArgumentException("Unknown node id: " + id);
- }
- return (INode) nodes.get(idLong);
- }
-
-
- private IEndNode getEnd() {
- for (Iterator it = nodes.values().iterator(); it.hasNext(); ) {
- INode node = (INode) it.next();
- if (node instanceof IEndNode) {
- return (IEndNode) node;
- }
- }
- return null;
+
+ public INode getNode(final long id) {
+ final Long idLong = new Long( id );
+ if ( !this.nodes.containsKey( idLong ) ) {
+ throw new IllegalArgumentException( "Unknown node id: " + id );
+ }
+ return (INode) this.nodes.get( idLong );
}
-
- public void removeNode(INode node) {
- if (node == null) {
- throw new IllegalArgumentException("Node is null");
- }
- INode n = (INode) nodes.remove(new Long(node.getId()));
- if (n == null) {
- throw new IllegalArgumentException("Unknown node: " + node);
+
+ private IEndNode getEnd() {
+ for ( final Iterator it = this.nodes.values().iterator(); it.hasNext(); ) {
+ final INode node = (INode) it.next();
+ if ( node instanceof IEndNode ) {
+ return (IEndNode) node;
+ }
}
+ return null;
}
-
+
+ public void removeNode(final INode node) {
+ if ( node == null ) {
+ throw new IllegalArgumentException( "Node is null" );
+ }
+ final INode n = (INode) this.nodes.remove( new Long( node.getId() ) );
+ if ( n == null ) {
+ throw new IllegalArgumentException( "Unknown node: " + node );
+ }
+ }
+
public List getVariables() {
- return variables;
+ return this.variables;
}
-
- public void setVariables(List variables) {
- if (variables == null) {
- throw new IllegalArgumentException("Variables is null");
- }
+
+ public void setVariables(final List variables) {
+ if ( variables == null ) {
+ throw new IllegalArgumentException( "Variables is null" );
+ }
this.variables = variables;
}
- public String[] getVariableNames() {
- String[] result = new String[variables.size()];
- for (int i = 0; i < variables.size(); i++) {
- result[i] = ((IVariable) variables.get(i)).getName();
+ public String[] getVariableNames() {
+ final String[] result = new String[this.variables.size()];
+ for ( int i = 0; i < this.variables.size(); i++ ) {
+ result[i] = ((IVariable) this.variables.get( i )).getName();
}
return result;
}
- public void addNode(INode node) {
- validateAddNode(node);
- if (!nodes.containsValue(node)) {
- node.setId(++lastNodeId);
- nodes.put(new Long(node.getId()), node);
- }
+ public void addNode(final INode node) {
+ validateAddNode( node );
+ if ( !this.nodes.containsValue( node ) ) {
+ node.setId( ++this.lastNodeId );
+ this.nodes.put( new Long( node.getId() ),
+ node );
+ }
}
-
- private void validateAddNode(INode node) {
- if ((node instanceof IStartNode) && (getStart() != null)) {
- throw new IllegalArgumentException(
- "A ruleflow process cannot have more than one start node!");
- }
- if ((node instanceof IEndNode) && (getEnd() != null)) {
- throw new IllegalArgumentException(
- "A ruleflow process cannot have more than one end node!");
- }
- }
+
+ private void validateAddNode(final INode node) {
+ if ( (node instanceof IStartNode) && (getStart() != null) ) {
+ throw new IllegalArgumentException( "A ruleflow process cannot have more than one start node!" );
+ }
+ if ( (node instanceof IEndNode) && (getEnd() != null) ) {
+ throw new IllegalArgumentException( "A ruleflow process cannot have more than one end node!" );
+ }
+ }
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/RuleFlowProcessValidationError.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/RuleFlowProcessValidationError.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/RuleFlowProcessValidationError.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,4 +1,5 @@
package org.drools.ruleflow.core.impl;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -22,20 +23,21 @@
*
* @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
*/
-public class RuleFlowProcessValidationError implements
- IRuleFlowProcessValidationError {
+public class RuleFlowProcessValidationError
+ implements
+ IRuleFlowProcessValidationError {
- private String type;
-
- public RuleFlowProcessValidationError(String type) {
- this.type = type;
- }
-
- public String toString() {
- return type;
- }
+ private String type;
- public String getType() {
- return type;
- }
+ public RuleFlowProcessValidationError(final String type) {
+ this.type = type;
+ }
+
+ public String toString() {
+ return this.type;
+ }
+
+ public String getType() {
+ return this.type;
+ }
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/RuleFlowProcessValidator.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/RuleFlowProcessValidator.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/RuleFlowProcessValidator.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,4 +1,5 @@
package org.drools.ruleflow.core.impl;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -25,183 +26,170 @@
import org.drools.ruleflow.core.IEndNode;
import org.drools.ruleflow.core.IJoin;
import org.drools.ruleflow.core.INode;
+import org.drools.ruleflow.core.IRuleFlowProcess;
+import org.drools.ruleflow.core.IRuleFlowProcessValidationError;
+import org.drools.ruleflow.core.IRuleFlowProcessValidator;
import org.drools.ruleflow.core.IRuleSetNode;
import org.drools.ruleflow.core.ISplit;
import org.drools.ruleflow.core.IStartNode;
import org.drools.ruleflow.core.IVariable;
-import org.drools.ruleflow.core.IRuleFlowProcess;
-import org.drools.ruleflow.core.IRuleFlowProcessValidationError;
-import org.drools.ruleflow.core.IRuleFlowProcessValidator;
/**
* Default implementation of a RuleFlow validator.
*
* @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
*/
-public class RuleFlowProcessValidator implements IRuleFlowProcessValidator {
-
+public class RuleFlowProcessValidator
+ implements
+ IRuleFlowProcessValidator {
+
private static RuleFlowProcessValidator instance;
-
+
private RuleFlowProcessValidator() {
}
-
+
public static RuleFlowProcessValidator getInstance() {
- if (instance == null) {
+ if ( instance == null ) {
instance = new RuleFlowProcessValidator();
}
return instance;
}
-
- public IRuleFlowProcessValidationError[] validateProcess(IRuleFlowProcess process) {
- List errors = new ArrayList();
-
- if (process.getName() == null) {
- errors.add(new RuleFlowProcessValidationError(
- IRuleFlowProcessValidationError.NO_PROCESS_NAME));
+
+ public IRuleFlowProcessValidationError[] validateProcess(final IRuleFlowProcess process) {
+ final List errors = new ArrayList();
+
+ if ( process.getName() == null ) {
+ errors.add( new RuleFlowProcessValidationError( IRuleFlowProcessValidationError.NO_PROCESS_NAME ) );
}
-
- if (process.getId() == null || "".equals(process.getId())) {
- errors.add(new RuleFlowProcessValidationError(
- IRuleFlowProcessValidationError.NO_PROCESS_ID));
+
+ if ( process.getId() == null || "".equals( process.getId() ) ) {
+ errors.add( new RuleFlowProcessValidationError( IRuleFlowProcessValidationError.NO_PROCESS_ID ) );
}
-
+
// check start node of process
- if (process.getStart() == null) {
- errors.add(new RuleFlowProcessValidationError(
- IRuleFlowProcessValidationError.NO_START_NODE));
+ if ( process.getStart() == null ) {
+ errors.add( new RuleFlowProcessValidationError( IRuleFlowProcessValidationError.NO_START_NODE ) );
}
-
+
boolean startNodeFound = false;
boolean endNodeFound = false;
- INode[] nodes = process.getNodes();
- for (int i = 0; i < nodes.length; i++) {
- INode node = nodes[i];
- if (node instanceof IStartNode) {
- IStartNode startNode = (IStartNode) node;
+ final INode[] nodes = process.getNodes();
+ for ( int i = 0; i < nodes.length; i++ ) {
+ final INode node = nodes[i];
+ if ( node instanceof IStartNode ) {
+ final IStartNode startNode = (IStartNode) node;
startNodeFound = true;
- if (startNode.getTo() == null) {
- errors.add(new RuleFlowProcessValidationError(
- IRuleFlowProcessValidationError.START_NODE_WITHOUT_OUTGOING_NODES));
+ if ( startNode.getTo() == null ) {
+ errors.add( new RuleFlowProcessValidationError( IRuleFlowProcessValidationError.START_NODE_WITHOUT_OUTGOING_NODES ) );
}
- } else if (node instanceof IEndNode) {
- IEndNode endNode = (IEndNode) node;
- endNodeFound = true;
- if (endNode.getFrom() == null) {
- errors.add(new RuleFlowProcessValidationError(
- IRuleFlowProcessValidationError.END_NODE_HAS_NO_INCOMING_CONNECTIONS));
+ } else if ( node instanceof IEndNode ) {
+ final IEndNode endNode = (IEndNode) node;
+ endNodeFound = true;
+ if ( endNode.getFrom() == null ) {
+ errors.add( new RuleFlowProcessValidationError( IRuleFlowProcessValidationError.END_NODE_HAS_NO_INCOMING_CONNECTIONS ) );
}
- } else if (node instanceof IRuleSetNode) {
- IRuleSetNode ruleSetNode = (IRuleSetNode) node;
- if (ruleSetNode.getFrom() == null) {
- errors.add(new RuleFlowProcessValidationError(
- IRuleFlowProcessValidationError.RULE_SET_NODE_WITHOUT_INCOMING_CONNECTIONS));
+ } else if ( node instanceof IRuleSetNode ) {
+ final IRuleSetNode ruleSetNode = (IRuleSetNode) node;
+ if ( ruleSetNode.getFrom() == null ) {
+ errors.add( new RuleFlowProcessValidationError( IRuleFlowProcessValidationError.RULE_SET_NODE_WITHOUT_INCOMING_CONNECTIONS ) );
}
-
- if (ruleSetNode.getTo() == null) {
- errors.add(new RuleFlowProcessValidationError(
- IRuleFlowProcessValidationError.RULE_SET_NODE_WITHOUT_OUTGOING_CONNECTIONS));
+
+ if ( ruleSetNode.getTo() == null ) {
+ errors.add( new RuleFlowProcessValidationError( IRuleFlowProcessValidationError.RULE_SET_NODE_WITHOUT_OUTGOING_CONNECTIONS ) );
}
- String ruleFlowGroup = ruleSetNode.getRuleFlowGroup();
- if (ruleFlowGroup == null || "".equals(ruleFlowGroup)) {
- errors.add(new RuleFlowProcessValidationError(
- IRuleFlowProcessValidationError.RULE_SET_NODE_WITHOUT_RULE_SET_GROUP));
+ final String ruleFlowGroup = ruleSetNode.getRuleFlowGroup();
+ if ( ruleFlowGroup == null || "".equals( ruleFlowGroup ) ) {
+ errors.add( new RuleFlowProcessValidationError( IRuleFlowProcessValidationError.RULE_SET_NODE_WITHOUT_RULE_SET_GROUP ) );
}
- } else if (node instanceof ISplit) {
- ISplit split = (ISplit) node;
- if (split.getType() == ISplit.TYPE_UNDEFINED) {
- errors.add(new RuleFlowProcessValidationError(
- IRuleFlowProcessValidationError.SPLIT_WITHOUT_TYPE));
+ } else if ( node instanceof ISplit ) {
+ final ISplit split = (ISplit) node;
+ if ( split.getType() == ISplit.TYPE_UNDEFINED ) {
+ errors.add( new RuleFlowProcessValidationError( IRuleFlowProcessValidationError.SPLIT_WITHOUT_TYPE ) );
}
- if (split.getFrom() == null) {
- errors.add(new RuleFlowProcessValidationError(
- IRuleFlowProcessValidationError.SPLIT_WITHOUT_INCOMING_CONNECTION));
+ if ( split.getFrom() == null ) {
+ errors.add( new RuleFlowProcessValidationError( IRuleFlowProcessValidationError.SPLIT_WITHOUT_INCOMING_CONNECTION ) );
}
- if (split.getOutgoingConnections().size() < 2) {
- errors.add(new RuleFlowProcessValidationError(
- IRuleFlowProcessValidationError.SPLIT_NOT_ENOUGH_OUTGOING_CONNECTIONS));
+ if ( split.getOutgoingConnections().size() < 2 ) {
+ errors.add( new RuleFlowProcessValidationError( IRuleFlowProcessValidationError.SPLIT_NOT_ENOUGH_OUTGOING_CONNECTIONS ) );
}
- if (split.getType() == ISplit.TYPE_XOR || split.getType() == ISplit.TYPE_OR) {
- for (Iterator it = split.getOutgoingConnections().iterator(); it.hasNext(); ) {
- IConnection connection = (IConnection) it.next();
- if (split.getConstraint(connection) == null) {
- errors.add(new RuleFlowProcessValidationError(
- IRuleFlowProcessValidationError.SPLIT_OUTGOING_CONNECTION_WITHOUT_CONSTRAINT));
- }
- }
+ if ( split.getType() == ISplit.TYPE_XOR || split.getType() == ISplit.TYPE_OR ) {
+ for ( final Iterator it = split.getOutgoingConnections().iterator(); it.hasNext(); ) {
+ final IConnection connection = (IConnection) it.next();
+ if ( split.getConstraint( connection ) == null ) {
+ errors.add( new RuleFlowProcessValidationError( IRuleFlowProcessValidationError.SPLIT_OUTGOING_CONNECTION_WITHOUT_CONSTRAINT ) );
+ }
+ }
}
- } else if (node instanceof IJoin) {
- IJoin join = (IJoin) node;
- if (join.getType() == IJoin.TYPE_UNDEFINED) {
- errors.add(new RuleFlowProcessValidationError(
- IRuleFlowProcessValidationError.JOIN_WITHOUT_TYPE));
+ } else if ( node instanceof IJoin ) {
+ final IJoin join = (IJoin) node;
+ if ( join.getType() == IJoin.TYPE_UNDEFINED ) {
+ errors.add( new RuleFlowProcessValidationError( IRuleFlowProcessValidationError.JOIN_WITHOUT_TYPE ) );
}
- if (join.getIncomingConnections().size() < 2) {
- errors.add(new RuleFlowProcessValidationError(
- IRuleFlowProcessValidationError.JOIN_NOT_ENOUGH_INCOMING_CONNECTIONS));
+ if ( join.getIncomingConnections().size() < 2 ) {
+ errors.add( new RuleFlowProcessValidationError( IRuleFlowProcessValidationError.JOIN_NOT_ENOUGH_INCOMING_CONNECTIONS ) );
}
- if (join.getTo() == null) {
- errors.add(new RuleFlowProcessValidationError(
- IRuleFlowProcessValidationError.JOIN_WITHOUT_OUTGOING_CONNECTION));
+ if ( join.getTo() == null ) {
+ errors.add( new RuleFlowProcessValidationError( IRuleFlowProcessValidationError.JOIN_WITHOUT_OUTGOING_CONNECTION ) );
}
}
}
- if (!startNodeFound) {
- errors.add(new RuleFlowProcessValidationError(
- IRuleFlowProcessValidationError.NO_START_NODE));
+ if ( !startNodeFound ) {
+ errors.add( new RuleFlowProcessValidationError( IRuleFlowProcessValidationError.NO_START_NODE ) );
}
- if (!endNodeFound) {
- errors.add(new RuleFlowProcessValidationError(
- IRuleFlowProcessValidationError.NO_END_NODE));
+ if ( !endNodeFound ) {
+ errors.add( new RuleFlowProcessValidationError( IRuleFlowProcessValidationError.NO_END_NODE ) );
}
- for (Iterator it = process.getVariables().iterator(); it.hasNext(); ) {
- IVariable variable = (IVariable) it.next();
- if (variable.getType() == null) {
- errors.add(new RuleFlowProcessValidationError(
- IRuleFlowProcessValidationError.VARIABLE_WITHOUT_TYPE));
+ for ( final Iterator it = process.getVariables().iterator(); it.hasNext(); ) {
+ final IVariable variable = (IVariable) it.next();
+ if ( variable.getType() == null ) {
+ errors.add( new RuleFlowProcessValidationError( IRuleFlowProcessValidationError.VARIABLE_WITHOUT_TYPE ) );
}
}
-
- checkAllNodesConnectedToStart(process, errors);
-
- return (IRuleFlowProcessValidationError[]) errors.toArray(new IRuleFlowProcessValidationError[errors.size()]);
+
+ checkAllNodesConnectedToStart( process,
+ errors );
+
+ return (IRuleFlowProcessValidationError[]) errors.toArray( new IRuleFlowProcessValidationError[errors.size()] );
}
- private void checkAllNodesConnectedToStart(
- IRuleFlowProcess process,
- List errors) {
- Map processNodes = new HashMap();
- INode[] nodes = process.getNodes();
- for (int i = 0; i < nodes.length; i++) {
- INode node = nodes[i];
- processNodes.put(node, Boolean.FALSE);
- }
-
- INode start = process.getStart();
- if (start != null) {
- processNode(start, processNodes);
- }
-
- for (Iterator it = processNodes.keySet().iterator(); it.hasNext(); ) {
- INode node = (INode) it.next();
- if (Boolean.FALSE.equals(processNodes.get(node))) {
- errors.add(new RuleFlowProcessValidationError(
- IRuleFlowProcessValidationError.ALL_NODES_CONNECTED_TO_START));
- }
- }
- }
-
- private void processNode(INode node, Map nodes) {
- if (!nodes.containsKey(node)) {
- throw new IllegalStateException("A process node is connected with "
- + "a node that does not belong to the process.");
- }
- Boolean prevValue = (Boolean) nodes.put(node, Boolean.TRUE);
- if (prevValue == Boolean.FALSE) {
- for (Iterator it = node.getOutgoingConnections().iterator(); it.hasNext(); ) {
- IConnection connection = (IConnection) it.next();
- processNode(connection.getTo(), nodes);
- }
+ private void checkAllNodesConnectedToStart(final IRuleFlowProcess process,
+ final List errors) {
+ final Map processNodes = new HashMap();
+ final INode[] nodes = process.getNodes();
+ for ( int i = 0; i < nodes.length; i++ ) {
+ final INode node = nodes[i];
+ processNodes.put( node,
+ Boolean.FALSE );
}
- }
-
+
+ final INode start = process.getStart();
+ if ( start != null ) {
+ processNode( start,
+ processNodes );
+ }
+
+ for ( final Iterator it = processNodes.keySet().iterator(); it.hasNext(); ) {
+ final INode node = (INode) it.next();
+ if ( Boolean.FALSE.equals( processNodes.get( node ) ) ) {
+ errors.add( new RuleFlowProcessValidationError( IRuleFlowProcessValidationError.ALL_NODES_CONNECTED_TO_START ) );
+ }
+ }
+ }
+
+ private void processNode(final INode node,
+ final Map nodes) {
+ if ( !nodes.containsKey( node ) ) {
+ throw new IllegalStateException( "A process node is connected with " + "a node that does not belong to the process." );
+ }
+ final Boolean prevValue = (Boolean) nodes.put( node,
+ Boolean.TRUE );
+ if ( prevValue == Boolean.FALSE ) {
+ for ( final Iterator it = node.getOutgoingConnections().iterator(); it.hasNext(); ) {
+ final IConnection connection = (IConnection) it.next();
+ processNode( connection.getTo(),
+ nodes );
+ }
+ }
+ }
+
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/RuleSetNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/RuleSetNode.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/RuleSetNode.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,4 +1,5 @@
package org.drools.ruleflow.core.impl;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -26,53 +27,53 @@
*
* @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
*/
-public class RuleSetNode extends Node implements IRuleSetNode {
-
+public class RuleSetNode extends Node
+ implements
+ IRuleSetNode {
+
private static final long serialVersionUID = 3257285846544691769L;
- private String ruleFlowGroup;
-
- public void setRuleFlowGroup(String ruleFlowGroup) {
+ private String ruleFlowGroup;
+
+ public void setRuleFlowGroup(final String ruleFlowGroup) {
this.ruleFlowGroup = ruleFlowGroup;
}
-
+
public String getRuleFlowGroup() {
- return ruleFlowGroup;
+ return this.ruleFlowGroup;
}
-
+
public IConnection getFrom() {
- List list = getIncomingConnections();
- if (list.size() > 0) {
- return (IConnection) list.get(0);
- }
- return null;
+ final List list = getIncomingConnections();
+ if ( list.size() > 0 ) {
+ return (IConnection) list.get( 0 );
+ }
+ return null;
}
-
+
public IConnection getTo() {
- List list = getOutgoingConnections();
- if (list.size() > 0) {
- return (IConnection) list.get(0);
- }
- return null;
+ final List list = getOutgoingConnections();
+ if ( list.size() > 0 ) {
+ return (IConnection) list.get( 0 );
+ }
+ return null;
}
-
- protected void validateAddIncomingConnection(IConnection connection) {
- super.validateAddIncomingConnection(connection);
- if (getIncomingConnections().size() > 0) {
- throw new IllegalArgumentException(
- "A RuleSetNode cannot have more than one incoming node");
- }
- }
- protected void validateAddOutgoingConnection(IConnection connection) {
- super.validateAddOutgoingConnection(connection);
- for (Iterator it = getOutgoingConnections().iterator(); it.hasNext(); ) {
- IConnection conn = (IConnection) it.next();
- if (conn.getType() == connection.getType()) {
- throw new IllegalArgumentException(
- "A RuleSetNode can have at most one outgoing node");
- }
- }
+ protected void validateAddIncomingConnection(final IConnection connection) {
+ super.validateAddIncomingConnection( connection );
+ if ( getIncomingConnections().size() > 0 ) {
+ throw new IllegalArgumentException( "A RuleSetNode cannot have more than one incoming node" );
+ }
}
-
+
+ protected void validateAddOutgoingConnection(final IConnection connection) {
+ super.validateAddOutgoingConnection( connection );
+ for ( final Iterator it = getOutgoingConnections().iterator(); it.hasNext(); ) {
+ final IConnection conn = (IConnection) it.next();
+ if ( conn.getType() == connection.getType() ) {
+ throw new IllegalArgumentException( "A RuleSetNode can have at most one outgoing node" );
+ }
+ }
+ }
+
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/Split.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/Split.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/Split.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,4 +1,5 @@
package org.drools.ruleflow.core.impl;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -30,102 +31,100 @@
*
* @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
*/
-public class Split extends Node implements ISplit {
-
+public class Split extends Node
+ implements
+ ISplit {
+
private static final long serialVersionUID = 3258413949669159736L;
- private int type;
- private Map constraints;
-
+ private int type;
+ private Map constraints;
+
public Split() {
- type = TYPE_UNDEFINED;
- constraints = new HashMap();
+ this.type = TYPE_UNDEFINED;
+ this.constraints = new HashMap();
}
-
- public Split(int type) {
- this.type = type;
- constraints = new HashMap();
+
+ public Split(final int type) {
+ this.type = type;
+ this.constraints = new HashMap();
}
-
- public void setType(int type) {
+
+ public void setType(final int type) {
this.type = type;
}
-
+
public int getType() {
- return type;
+ return this.type;
}
-
- public IConstraint getConstraint(IConnection connection) {
- if (connection == null) {
- throw new IllegalArgumentException("connection is null");
- }
-
- // dirty hack because keys were entered wrong
- // probably caused by xstreams
- HashMap newMap = new HashMap();
- for (Iterator it = constraints.entrySet().iterator(); it.hasNext(); ) {
- Entry entry = (Entry) it.next();
- newMap.put(entry.getKey(), entry.getValue());
- }
- constraints = newMap;
-
- if (type == TYPE_OR || type == TYPE_XOR) {
- return (IConstraint) constraints.get(connection);
- }
- throw new UnsupportedOperationException("Constraints are "
- + "only supported with XOR or OR split types, not with: "
- + getType());
+
+ public IConstraint getConstraint(final IConnection connection) {
+ if ( connection == null ) {
+ throw new IllegalArgumentException( "connection is null" );
+ }
+
+ // dirty hack because keys were entered wrong
+ // probably caused by xstreams
+ final HashMap newMap = new HashMap();
+ for ( final Iterator it = this.constraints.entrySet().iterator(); it.hasNext(); ) {
+ final Entry entry = (Entry) it.next();
+ newMap.put( entry.getKey(),
+ entry.getValue() );
+ }
+ this.constraints = newMap;
+
+ if ( this.type == TYPE_OR || this.type == TYPE_XOR ) {
+ return (IConstraint) this.constraints.get( connection );
+ }
+ throw new UnsupportedOperationException( "Constraints are " + "only supported with XOR or OR split types, not with: " + getType() );
}
-
- public void setConstraint(IConnection connection, IConstraint constraint) {
- if (type == TYPE_OR || type == TYPE_XOR) {
- if (connection == null) {
- throw new IllegalArgumentException("connection is null");
- }
- if (!getOutgoingConnections().contains(connection)) {
- throw new IllegalArgumentException("connection is unknown:" + connection);
- }
- constraints.put(connection, constraint);
- } else {
- throw new UnsupportedOperationException("Constraints are "
- + "only supported with XOR or OR split types, not with type:"
- + getType());
- }
+
+ public void setConstraint(final IConnection connection,
+ final IConstraint constraint) {
+ if ( this.type == TYPE_OR || this.type == TYPE_XOR ) {
+ if ( connection == null ) {
+ throw new IllegalArgumentException( "connection is null" );
+ }
+ if ( !getOutgoingConnections().contains( connection ) ) {
+ throw new IllegalArgumentException( "connection is unknown:" + connection );
+ }
+ this.constraints.put( connection,
+ constraint );
+ } else {
+ throw new UnsupportedOperationException( "Constraints are " + "only supported with XOR or OR split types, not with type:" + getType() );
+ }
}
-
+
public Map getConstraints() {
- if (type == TYPE_OR || type == TYPE_XOR) {
- return Collections.unmodifiableMap(constraints);
- }
- throw new UnsupportedOperationException("Constraints are "
- + "only supported with XOR or OR split types, not with: "
- + getType());
+ if ( this.type == TYPE_OR || this.type == TYPE_XOR ) {
+ return Collections.unmodifiableMap( this.constraints );
+ }
+ throw new UnsupportedOperationException( "Constraints are " + "only supported with XOR or OR split types, not with: " + getType() );
}
-
+
public IConnection getFrom() {
- if (getIncomingConnections().size() > 0) {
- return (IConnection) getIncomingConnections().get(0);
- }
- return null;
+ if ( getIncomingConnections().size() > 0 ) {
+ return (IConnection) getIncomingConnections().get( 0 );
+ }
+ return null;
}
-
- protected void validateAddIncomingConnection(IConnection connection) {
- super.validateAddIncomingConnection(connection);
- if (getIncomingConnections().size() > 0) {
- throw new IllegalArgumentException("A split cannot have more than one incoming connection");
+
+ protected void validateAddIncomingConnection(final IConnection connection) {
+ super.validateAddIncomingConnection( connection );
+ if ( getIncomingConnections().size() > 0 ) {
+ throw new IllegalArgumentException( "A split cannot have more than one incoming connection" );
}
}
-
- protected void validateAddOutgoingConnection(IConnection connection) {
- super.validateAddOutgoingConnection(connection);
- if (connection.getType() != IConnection.TYPE_NORMAL) {
- throw new IllegalArgumentException("Unknown connection type :" + connection.getType()
- + ", only NORMAL is allowed as outgoing connection.");
- }
+
+ protected void validateAddOutgoingConnection(final IConnection connection) {
+ super.validateAddOutgoingConnection( connection );
+ if ( connection.getType() != IConnection.TYPE_NORMAL ) {
+ throw new IllegalArgumentException( "Unknown connection type :" + connection.getType() + ", only NORMAL is allowed as outgoing connection." );
+ }
}
-
- public void removeOutgoingConnection(IConnection connection) {
- super.removeOutgoingConnection(connection);
- constraints.remove(connection);
+
+ public void removeOutgoingConnection(final IConnection connection) {
+ super.removeOutgoingConnection( connection );
+ this.constraints.remove( connection );
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/StartNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/StartNode.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/StartNode.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,4 +1,5 @@
package org.drools.ruleflow.core.impl;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -25,35 +26,33 @@
*
* @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
*/
-public class StartNode extends Node implements IStartNode {
+public class StartNode extends Node
+ implements
+ IStartNode {
private static final long serialVersionUID = 3257564005806782517L;
-
+
public IConnection getTo() {
- List list = getOutgoingConnections();
- if (list.size() > 0) {
- return (IConnection) list.get(0);
- }
- return null;
+ final List list = getOutgoingConnections();
+ if ( list.size() > 0 ) {
+ return (IConnection) list.get( 0 );
+ }
+ return null;
}
-
- protected void validateAddOutgoingConnection(IConnection connection) {
- super.validateAddOutgoingConnection(connection);
- if (getOutgoingConnections().size() > 0) {
- throw new IllegalArgumentException(
- "A start node cannot have more than one outgoing connection");
+
+ protected void validateAddOutgoingConnection(final IConnection connection) {
+ super.validateAddOutgoingConnection( connection );
+ if ( getOutgoingConnections().size() > 0 ) {
+ throw new IllegalArgumentException( "A start node cannot have more than one outgoing connection" );
}
}
-
- protected void validateAddIncomingConnection(IConnection connection) {
- throw new UnsupportedOperationException(
- "A start node does not have an incoming connection");
+ protected void validateAddIncomingConnection(final IConnection connection) {
+ throw new UnsupportedOperationException( "A start node does not have an incoming connection" );
}
- protected void validateRemoveIncomingConnection(IConnection connection) {
- throw new UnsupportedOperationException(
- "A start node does not have an incoming connection");
+ protected void validateRemoveIncomingConnection(final IConnection connection) {
+ throw new UnsupportedOperationException( "A start node does not have an incoming connection" );
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/Variable.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/Variable.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/Variable.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,4 +1,5 @@
package org.drools.ruleflow.core.impl;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -26,55 +27,58 @@
*
* @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
*/
-public class Variable implements IVariable, Serializable {
+public class Variable
+ implements
+ IVariable,
+ Serializable {
private static final long serialVersionUID = 320L;
- private String name;
- private IDataType type;
- private Serializable value;
-
+ private String name;
+ private IDataType type;
+ private Serializable value;
+
public Variable() {
- type = UndefinedDataType.getInstance();
+ this.type = UndefinedDataType.getInstance();
}
-
+
public String getName() {
- return name;
+ return this.name;
}
-
- public void setName(String name) {
+
+ public void setName(final String name) {
this.name = name;
}
-
+
public IDataType getType() {
- return type;
+ return this.type;
}
-
- public void setType(IDataType type) {
- if (type == null) {
- throw new IllegalArgumentException("type is null");
- }
+
+ public void setType(final IDataType type) {
+ if ( type == null ) {
+ throw new IllegalArgumentException( "type is null" );
+ }
this.type = type;
}
-
+
public Serializable getValue() {
- return value;
+ return this.value;
}
-
- public void setValue(Serializable value) {
- if (this.type.verifyDataType(value)) {
- this.value = value;
- } else {
- StringBuffer sb = new StringBuffer();
- sb.append("Value <");
- sb.append(value);
- sb.append("> is not valid for datatype: ");
- sb.append(type);
- throw new IllegalArgumentException(sb.toString());
- }
+
+ public void setValue(final Serializable value) {
+ if ( this.type.verifyDataType( value ) ) {
+ this.value = value;
+ } else {
+ final StringBuffer sb = new StringBuffer();
+ sb.append( "Value <" );
+ sb.append( value );
+ sb.append( "> is not valid for datatype: " );
+ sb.append( this.type );
+ throw new IllegalArgumentException( sb.toString() );
+ }
}
-
+
public String toString() {
- return name;
+ return this.name;
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/IRuleFlowNodeInstance.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/IRuleFlowNodeInstance.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/IRuleFlowNodeInstance.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,4 +1,5 @@
package org.drools.ruleflow.instance;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -24,21 +25,21 @@
* @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
*/
public interface IRuleFlowNodeInstance {
-
- void setId(long id);
- long getId();
-
- void setNodeId(long nodeId);
+ void setId(long id);
- long getNodeId();
+ long getId();
- void setProcessInstance(IRuleFlowProcessInstance processInstance);
+ void setNodeId(long nodeId);
- IRuleFlowProcessInstance getProcessInstance();
+ long getNodeId();
- void trigger(IRuleFlowNodeInstance from);
-
- void triggerCompleted();
-
+ void setProcessInstance(IRuleFlowProcessInstance processInstance);
+
+ IRuleFlowProcessInstance getProcessInstance();
+
+ void trigger(IRuleFlowNodeInstance from);
+
+ void triggerCompleted();
+
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/IRuleFlowProcessInstance.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/IRuleFlowProcessInstance.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/IRuleFlowProcessInstance.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,4 +1,5 @@
package org.drools.ruleflow.instance;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -29,24 +30,26 @@
*
* @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
*/
-public interface IRuleFlowProcessInstance extends IProcessInstance {
-
- IRuleFlowProcess getRuleFlowProcess();
-
- void addNodeInstance(IRuleFlowNodeInstance nodeInstance);
+public interface IRuleFlowProcessInstance
+ extends
+ IProcessInstance {
- void removeNodeInstance(IRuleFlowNodeInstance nodeInstance);
+ IRuleFlowProcess getRuleFlowProcess();
- Collection getNodeInstances();
+ void addNodeInstance(IRuleFlowNodeInstance nodeInstance);
- IRuleFlowNodeInstance getFirstNodeInstance(long nodeId);
-
- void setAgenda(Agenda agenda);
-
- Agenda getAgenda();
-
- IRuleFlowNodeInstance getNodeInstance(INode node);
-
- void start();
-
+ void removeNodeInstance(IRuleFlowNodeInstance nodeInstance);
+
+ Collection getNodeInstances();
+
+ IRuleFlowNodeInstance getFirstNodeInstance(long nodeId);
+
+ void setAgenda(Agenda agenda);
+
+ Agenda getAgenda();
+
+ IRuleFlowNodeInstance getNodeInstance(INode node);
+
+ void start();
+
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/EndNodeInstance.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/EndNodeInstance.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/EndNodeInstance.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,4 +1,5 @@
package org.drools.ruleflow.instance.impl;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -25,12 +26,12 @@
*/
public class EndNodeInstance extends RuleFlowNodeInstance {
- public void trigger(IRuleFlowNodeInstance from) {
- getProcessInstance().setState(IProcessInstance.STATE_COMPLETED);
- }
+ public void trigger(final IRuleFlowNodeInstance from) {
+ getProcessInstance().setState( IProcessInstance.STATE_COMPLETED );
+ }
- public void triggerCompleted() {
- // this should never occur
- throw new IllegalArgumentException("End nodes cannot be completed.");
- }
+ public void triggerCompleted() {
+ // this should never occur
+ throw new IllegalArgumentException( "End nodes cannot be completed." );
+ }
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/RuleFlowJoinInstance.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/RuleFlowJoinInstance.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/RuleFlowJoinInstance.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,4 +1,5 @@
package org.drools.ruleflow.instance.impl;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -29,59 +30,63 @@
*
* @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
*/
-public class RuleFlowJoinInstance extends RuleFlowNodeInstance implements IRuleFlowNodeInstance {
+public class RuleFlowJoinInstance extends RuleFlowNodeInstance
+ implements
+ IRuleFlowNodeInstance {
- private Map triggers = new HashMap();
-
- protected IJoin getJoinNode() {
- return (IJoin) getNode();
- }
-
- public void trigger(IRuleFlowNodeInstance from) {
- IJoin join = getJoinNode();
- switch (join.getType()) {
- case IJoin.TYPE_XOR:
- triggerCompleted();
- break;
- case IJoin.TYPE_AND:
- INode node = getProcessInstance().getRuleFlowProcess().getNode(from.getNodeId());
- Integer count = (Integer) triggers.get(node);
- if (count == null) {
- triggers.put(node, new Integer(1));
- } else {
- triggers.put(node, new Integer(count.intValue() + 1));
- }
- checkActivation();
- break;
- default:
- throw new IllegalArgumentException("Illegal join type " + join.getType());
- }
- }
+ private final Map triggers = new HashMap();
- private void checkActivation() {
- // check whether all parent nodes have been triggered
- for (Iterator it = getJoinNode().getIncomingConnections().iterator(); it.hasNext(); ) {
- IConnection connection = (IConnection) it.next();
- if (triggers.get(connection.getFrom()) == null) {
- return;
+ protected IJoin getJoinNode() {
+ return (IJoin) getNode();
+ }
+
+ public void trigger(final IRuleFlowNodeInstance from) {
+ final IJoin join = getJoinNode();
+ switch ( join.getType() ) {
+ case IJoin.TYPE_XOR :
+ triggerCompleted();
+ break;
+ case IJoin.TYPE_AND :
+ final INode node = getProcessInstance().getRuleFlowProcess().getNode( from.getNodeId() );
+ final Integer count = (Integer) this.triggers.get( node );
+ if ( count == null ) {
+ this.triggers.put( node,
+ new Integer( 1 ) );
+ } else {
+ this.triggers.put( node,
+ new Integer( count.intValue() + 1 ) );
+ }
+ checkActivation();
+ break;
+ default :
+ throw new IllegalArgumentException( "Illegal join type " + join.getType() );
+ }
+ }
+
+ private void checkActivation() {
+ // check whether all parent nodes have been triggered
+ for ( final Iterator it = getJoinNode().getIncomingConnections().iterator(); it.hasNext(); ) {
+ final IConnection connection = (IConnection) it.next();
+ if ( this.triggers.get( connection.getFrom() ) == null ) {
+ return;
}
}
// if true, decrease trigger count for all parents and trigger children
- for (Iterator it = getJoinNode().getIncomingConnections().iterator(); it.hasNext(); ) {
- IConnection connection = (IConnection) it.next();
- Integer count = (Integer) triggers.get(connection.getFrom());
- if (count.intValue() == 1) {
- triggers.remove(connection.getFrom());
+ for ( final Iterator it = getJoinNode().getIncomingConnections().iterator(); it.hasNext(); ) {
+ final IConnection connection = (IConnection) it.next();
+ final Integer count = (Integer) this.triggers.get( connection.getFrom() );
+ if ( count.intValue() == 1 ) {
+ this.triggers.remove( connection.getFrom() );
} else {
- triggers.put(connection.getFrom(), new Integer(count.intValue() - 1));
+ this.triggers.put( connection.getFrom(),
+ new Integer( count.intValue() - 1 ) );
}
}
triggerCompleted();
- }
-
- public void triggerCompleted() {
- getProcessInstance().getNodeInstance(
- getJoinNode().getTo().getTo()).trigger(this);
- }
+ }
+ public void triggerCompleted() {
+ getProcessInstance().getNodeInstance( getJoinNode().getTo().getTo() ).trigger( this );
+ }
+
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/RuleFlowNodeInstance.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/RuleFlowNodeInstance.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/RuleFlowNodeInstance.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,4 +1,5 @@
package org.drools.ruleflow.instance.impl;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -24,37 +25,39 @@
*
* @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
*/
-public abstract class RuleFlowNodeInstance implements IRuleFlowNodeInstance {
+public abstract class RuleFlowNodeInstance
+ implements
+ IRuleFlowNodeInstance {
- private long id;
- private long nodeId;
- private IRuleFlowProcessInstance processInstance;
+ private long id;
+ private long nodeId;
+ private IRuleFlowProcessInstance processInstance;
- public void setId(long id) {
- this.id = id;
- }
-
- public long getId() {
- return id;
- }
-
- public void setNodeId(long nodeId) {
+ public void setId(final long id) {
+ this.id = id;
+ }
+
+ public long getId() {
+ return this.id;
+ }
+
+ public void setNodeId(final long nodeId) {
this.nodeId = nodeId;
}
-
+
public long getNodeId() {
- return nodeId;
+ return this.nodeId;
}
-
- public void setProcessInstance(IRuleFlowProcessInstance processInstance) {
+
+ public void setProcessInstance(final IRuleFlowProcessInstance processInstance) {
this.processInstance = processInstance;
}
-
- public IRuleFlowProcessInstance getProcessInstance() {
- return processInstance;
+
+ public IRuleFlowProcessInstance getProcessInstance() {
+ return this.processInstance;
}
-
+
protected INode getNode() {
- return processInstance.getRuleFlowProcess().getNode(nodeId);
+ return this.processInstance.getRuleFlowProcess().getNode( this.nodeId );
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/RuleFlowProcessInstance.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/RuleFlowProcessInstance.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/RuleFlowProcessInstance.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,4 +1,5 @@
package org.drools.ruleflow.instance.impl;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -39,102 +40,102 @@
*
* @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
*/
-public class RuleFlowProcessInstance extends ProcessInstance implements IRuleFlowProcessInstance {
-
- private static final long serialVersionUID = -6760756665603399413L;
-
- private Agenda agenda;
- private List nodeInstances = new ArrayList();
-
- public IRuleFlowProcess getRuleFlowProcess() {
- return (IRuleFlowProcess) getProcess();
- }
+public class RuleFlowProcessInstance extends ProcessInstance
+ implements
+ IRuleFlowProcessInstance {
- public void addNodeInstance(IRuleFlowNodeInstance nodeInstance) {
- nodeInstances.add(nodeInstance);
- nodeInstance.setProcessInstance(this);
+ private static final long serialVersionUID = -6760756665603399413L;
+
+ private Agenda agenda;
+ private final List nodeInstances = new ArrayList();
+
+ public IRuleFlowProcess getRuleFlowProcess() {
+ return (IRuleFlowProcess) getProcess();
}
-
- public void removeNodeInstance(IRuleFlowNodeInstance nodeInstance) {
- nodeInstances.remove(nodeInstance);
+
+ public void addNodeInstance(final IRuleFlowNodeInstance nodeInstance) {
+ this.nodeInstances.add( nodeInstance );
+ nodeInstance.setProcessInstance( this );
}
-
+
+ public void removeNodeInstance(final IRuleFlowNodeInstance nodeInstance) {
+ this.nodeInstances.remove( nodeInstance );
+ }
+
public Collection getNodeInstances() {
- return Collections.unmodifiableCollection(nodeInstances);
+ return Collections.unmodifiableCollection( this.nodeInstances );
}
-
- public IRuleFlowNodeInstance getFirstNodeInstance(long nodeId) {
- for (Iterator iterator = nodeInstances.iterator(); iterator.hasNext(); ) {
- IRuleFlowNodeInstance nodeInstance = (IRuleFlowNodeInstance) iterator.next();
- if (nodeInstance.getNodeId() == nodeId) {
+
+ public IRuleFlowNodeInstance getFirstNodeInstance(final long nodeId) {
+ for ( final Iterator iterator = this.nodeInstances.iterator(); iterator.hasNext(); ) {
+ final IRuleFlowNodeInstance nodeInstance = (IRuleFlowNodeInstance) iterator.next();
+ if ( nodeInstance.getNodeId() == nodeId ) {
return nodeInstance;
}
}
return null;
}
-
- public Agenda getAgenda() {
- return agenda;
- }
- public void setAgenda(Agenda agenda) {
- this.agenda = agenda;
- }
+ public Agenda getAgenda() {
+ return this.agenda;
+ }
- public IRuleFlowNodeInstance getNodeInstance(INode node) {
- if (node instanceof IRuleSetNode) {
- IRuleFlowNodeInstance result = (IRuleFlowNodeInstance)
- agenda.getRuleFlowGroup(((IRuleSetNode) node).getRuleFlowGroup());
- result.setNodeId(node.getId());
- addNodeInstance(result);
- return result;
- } else if (node instanceof ISplit) {
- IRuleFlowNodeInstance result = getFirstNodeInstance(node.getId());
- if (result == null) {
- result = new RuleFlowSplitInstance();
- result.setNodeId(node.getId());
- addNodeInstance(result);
- return result;
- }
- } else if (node instanceof IJoin) {
- IRuleFlowNodeInstance result = getFirstNodeInstance(node.getId());
- if (result == null) {
- result = new RuleFlowJoinInstance();
- result.setNodeId(node.getId());
- addNodeInstance(result);
- }
- return result;
- } else if (node instanceof IStartNode) {
- IRuleFlowNodeInstance result = new StartNodeInstance();
- result.setNodeId(node.getId());
- addNodeInstance(result);
- return result;
- } else if (node instanceof IEndNode) {
- IRuleFlowNodeInstance result = new EndNodeInstance();
- result.setNodeId(node.getId());
- addNodeInstance(result);
- return result;
- }
- throw new IllegalArgumentException("Illegal node type: " + node.getClass());
- }
-
- public void start() {
- if (getState() != IProcessInstance.STATE_PENDING) {
- throw new IllegalArgumentException(
- "A process instance can only be started once");
- }
- setState(IProcessInstance.STATE_ACTIVE);
- getNodeInstance(getRuleFlowProcess().getStart()).trigger(null);
- }
-
- public String toString() {
- StringBuffer sb = new StringBuffer("RuleFlowProcessInstance");
- sb.append(getId());
- sb.append(" [processId=");
- sb.append(getProcess().getId());
- sb.append(",state=");
- sb.append(getState());
- sb.append("]");
- return sb.toString();
+ public void setAgenda(final Agenda agenda) {
+ this.agenda = agenda;
}
+
+ public IRuleFlowNodeInstance getNodeInstance(final INode node) {
+ if ( node instanceof IRuleSetNode ) {
+ final IRuleFlowNodeInstance result = (IRuleFlowNodeInstance) this.agenda.getRuleFlowGroup( ((IRuleSetNode) node).getRuleFlowGroup() );
+ result.setNodeId( node.getId() );
+ addNodeInstance( result );
+ return result;
+ } else if ( node instanceof ISplit ) {
+ IRuleFlowNodeInstance result = getFirstNodeInstance( node.getId() );
+ if ( result == null ) {
+ result = new RuleFlowSplitInstance();
+ result.setNodeId( node.getId() );
+ addNodeInstance( result );
+ return result;
+ }
+ } else if ( node instanceof IJoin ) {
+ IRuleFlowNodeInstance result = getFirstNodeInstance( node.getId() );
+ if ( result == null ) {
+ result = new RuleFlowJoinInstance();
+ result.setNodeId( node.getId() );
+ addNodeInstance( result );
+ }
+ return result;
+ } else if ( node instanceof IStartNode ) {
+ final IRuleFlowNodeInstance result = new StartNodeInstance();
+ result.setNodeId( node.getId() );
+ addNodeInstance( result );
+ return result;
+ } else if ( node instanceof IEndNode ) {
+ final IRuleFlowNodeInstance result = new EndNodeInstance();
+ result.setNodeId( node.getId() );
+ addNodeInstance( result );
+ return result;
+ }
+ throw new IllegalArgumentException( "Illegal node type: " + node.getClass() );
+ }
+
+ public void start() {
+ if ( getState() != IProcessInstance.STATE_PENDING ) {
+ throw new IllegalArgumentException( "A process instance can only be started once" );
+ }
+ setState( IProcessInstance.STATE_ACTIVE );
+ getNodeInstance( getRuleFlowProcess().getStart() ).trigger( null );
+ }
+
+ public String toString() {
+ final StringBuffer sb = new StringBuffer( "RuleFlowProcessInstance" );
+ sb.append( getId() );
+ sb.append( " [processId=" );
+ sb.append( getProcess().getId() );
+ sb.append( ",state=" );
+ sb.append( getState() );
+ sb.append( "]" );
+ return sb.toString();
+ }
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/RuleFlowSequenceNodeInstance.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/RuleFlowSequenceNodeInstance.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/RuleFlowSequenceNodeInstance.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,4 +1,5 @@
package org.drools.ruleflow.instance.impl;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -25,17 +26,16 @@
*/
public class RuleFlowSequenceNodeInstance extends RuleFlowNodeInstance {
- protected IRuleSetNode getRuleSetNode() {
- return (IRuleSetNode) getNode();
- }
-
- public void trigger(IRuleFlowNodeInstance from) {
- getProcessInstance().getAgenda()
- .activateRuleFlowGroup(getRuleSetNode().getRuleFlowGroup());
- }
+ protected IRuleSetNode getRuleSetNode() {
+ return (IRuleSetNode) getNode();
+ }
- public void triggerCompleted() {
- getProcessInstance().getNodeInstance(getRuleSetNode().getTo().getTo()).trigger(this);
- }
+ public void trigger(final IRuleFlowNodeInstance from) {
+ getProcessInstance().getAgenda().activateRuleFlowGroup( getRuleSetNode().getRuleFlowGroup() );
+ }
+ public void triggerCompleted() {
+ getProcessInstance().getNodeInstance( getRuleSetNode().getTo().getTo() ).trigger( this );
+ }
+
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/RuleFlowSplitInstance.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/RuleFlowSplitInstance.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/RuleFlowSplitInstance.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,4 +1,5 @@
package org.drools.ruleflow.instance.impl;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -27,30 +28,32 @@
*
* @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
*/
-public class RuleFlowSplitInstance extends RuleFlowNodeInstance implements IRuleFlowNodeInstance {
+public class RuleFlowSplitInstance extends RuleFlowNodeInstance
+ implements
+ IRuleFlowNodeInstance {
- protected ISplit getSplitNode() {
- return (ISplit) getNode();
- }
-
- public void trigger(IRuleFlowNodeInstance from) {
- ISplit split = getSplitNode();
- switch (split.getType()) {
- case ISplit.TYPE_AND:
- List outgoing = split.getOutgoingConnections();
- for (Iterator iterator = outgoing.iterator(); iterator.hasNext(); ) {
- IConnection connection = (IConnection) iterator.next();
- getProcessInstance().getNodeInstance(connection.getTo()).trigger(this);
- }
- break;
- default:
- throw new IllegalArgumentException("Illegal split type " + split.getType());
- }
- }
+ protected ISplit getSplitNode() {
+ return (ISplit) getNode();
+ }
- public void triggerCompleted() {
- // TODO Auto-generated method stub
-
- }
+ public void trigger(final IRuleFlowNodeInstance from) {
+ final ISplit split = getSplitNode();
+ switch ( split.getType() ) {
+ case ISplit.TYPE_AND :
+ final List outgoing = split.getOutgoingConnections();
+ for ( final Iterator iterator = outgoing.iterator(); iterator.hasNext(); ) {
+ final IConnection connection = (IConnection) iterator.next();
+ getProcessInstance().getNodeInstance( connection.getTo() ).trigger( this );
+ }
+ break;
+ default :
+ throw new IllegalArgumentException( "Illegal split type " + split.getType() );
+ }
+ }
+ public void triggerCompleted() {
+ // TODO Auto-generated method stub
+
+ }
+
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/StartNodeInstance.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/StartNodeInstance.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/StartNodeInstance.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,4 +1,5 @@
package org.drools.ruleflow.instance.impl;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -25,15 +26,15 @@
*/
public class StartNodeInstance extends RuleFlowNodeInstance {
- public void trigger(IRuleFlowNodeInstance from) {
- triggerCompleted();
- }
-
- public IStartNode getStartNode() {
- return (IStartNode) getNode();
- }
+ public void trigger(final IRuleFlowNodeInstance from) {
+ triggerCompleted();
+ }
- public void triggerCompleted() {
- getProcessInstance().getNodeInstance(getStartNode().getTo().getTo()).trigger(this);
- }
+ public IStartNode getStartNode() {
+ return (IStartNode) getNode();
+ }
+
+ public void triggerCompleted() {
+ getProcessInstance().getNodeInstance( getStartNode().getTo().getTo() ).trigger( this );
+ }
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/Activation.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/Activation.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/Activation.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -34,14 +34,16 @@
* @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 Activation extends Serializable {
+public interface Activation
+ extends
+ Serializable {
/**
* Retrieve the <code>Rule</code> that was activated.
*
* @return The rule.
*/
Rule getRule();
-
+
/**
* Retrieve the subrule that was activated.
*
@@ -82,14 +84,14 @@
public boolean isActivated();
public void setActivated(boolean activated);
-
+
public AgendaGroup getAgendaGroup();
public ActivationGroupNode getActivationGroupNode();
public void setActivationGroupNode(ActivationGroupNode activationGroupNode);
-
+
public RuleFlowGroupNode getRuleFlowGroupNode();
-
+
public void setRuleFlowGroupNode(RuleFlowGroupNode ruleFlowGroupNode);
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/ActivationGroup.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/ActivationGroup.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/ActivationGroup.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -2,7 +2,6 @@
import java.util.Iterator;
-
public interface ActivationGroup {
public String getName();
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/AgendaGroup.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -56,7 +56,7 @@
* int value for the total number of activations
*/
public int size();
-
+
public boolean isActivate();
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/ColumnExtractor.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -41,9 +41,9 @@
public Object getValue(final Object object) {
// need to use instanceof because an object may be created in nodes like accumulate and from
// where no shadow is applied
- return ( object instanceof ShadowProxy ) ? ((ShadowProxy)object).getShadowedObject() : object;
+ return (object instanceof ShadowProxy) ? ((ShadowProxy) object).getShadowedObject() : object;
}
-
+
public ObjectType getObjectType() {
return this.objectType;
}
@@ -119,28 +119,30 @@
public Method getNativeReadMethod() {
try {
- return this.getClass().getDeclaredMethod( "getValue", new Class[] { Object.class } );
- } catch ( Exception e ) {
- throw new RuntimeDroolsException("This is a bug. Please report to development team: "+e.getMessage(), e);
+ return this.getClass().getDeclaredMethod( "getValue",
+ new Class[]{Object.class} );
+ } catch ( final Exception e ) {
+ throw new RuntimeDroolsException( "This is a bug. Please report to development team: " + e.getMessage(),
+ e );
}
}
- public int getHashCode(Object object) {
+ public int getHashCode(final Object object) {
return getValue( object ).hashCode();
}
-
+
public int hashCode() {
return this.objectType.hashCode();
}
-
- public boolean equals(Object obj) {
- if( this == obj ) {
+
+ public boolean equals(final Object obj) {
+ if ( this == obj ) {
return true;
}
- if( ! ( obj instanceof ColumnExtractor ) ) {
+ if ( !(obj instanceof ColumnExtractor) ) {
return false;
}
- ColumnExtractor other = (ColumnExtractor) obj;
+ final ColumnExtractor other = (ColumnExtractor) obj;
return this.objectType.equals( other.objectType );
}
}
\ 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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/DataProvider.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -3,7 +3,6 @@
import java.util.Iterator;
import org.drools.WorkingMemory;
-import org.drools.reteoo.ReteTuple;
import org.drools.rule.Declaration;
public interface DataProvider {
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/DeclarationScopeResolver.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/DeclarationScopeResolver.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/DeclarationScopeResolver.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -15,17 +15,19 @@
* @author etirelli
*/
public class DeclarationScopeResolver {
- private static final Stack EMPTY_STACK = new Stack( );
- private Map[] maps;
- private Stack buildStack;
+ private static final Stack EMPTY_STACK = new Stack();
+ private Map[] maps;
+ private Stack buildStack;
- public DeclarationScopeResolver(final Map[] maps ) {
- this( maps, EMPTY_STACK );
+ public DeclarationScopeResolver(final Map[] maps) {
+ this( maps,
+ EMPTY_STACK );
}
- public DeclarationScopeResolver(final Map[] maps, final Stack buildStack ) {
+ public DeclarationScopeResolver(final Map[] maps,
+ final Stack buildStack) {
this.maps = maps;
- if( buildStack == null ) {
+ if ( buildStack == null ) {
this.buildStack = EMPTY_STACK;
} else {
this.buildStack = buildStack;
@@ -33,9 +35,9 @@
}
public Class getType(final String name) {
- for( int i = this.buildStack.size()-1; i >= 0; i-- ) {
- Declaration declaration = ( Declaration ) (( RuleConditionElement ) this.buildStack.get( i )).getInnerDeclarations().get( name );
- if( declaration != null ) {
+ for ( int i = this.buildStack.size() - 1; i >= 0; i-- ) {
+ final Declaration declaration = (Declaration) ((RuleConditionElement) this.buildStack.get( i )).getInnerDeclarations().get( name );
+ if ( declaration != null ) {
return declaration.getExtractor().getExtractToClass();
}
}
@@ -51,21 +53,25 @@
}
return null;
}
-
- public Declaration getDeclaration( final String name ) {
+
+ public Declaration getDeclaration(final String name) {
// it may be a local bound variable
- for( int i = this.buildStack.size()-1; i >= 0; i-- ) {
- Declaration declaration = ( Declaration ) (( RuleConditionElement ) this.buildStack.get( i )).getInnerDeclarations().get( name );
- if( declaration != null ) {
+ for ( int i = this.buildStack.size() - 1; i >= 0; i-- ) {
+ final Declaration declaration = (Declaration) ((RuleConditionElement) this.buildStack.get( i )).getInnerDeclarations().get( name );
+ if ( declaration != null ) {
return declaration;
}
}
// it may be a global or something
for ( int i = 0, length = this.maps.length; i < length; i++ ) {
if ( this.maps[i].containsKey( (name) ) ) {
- GlobalExtractor global = new GlobalExtractor( name, this.maps[i]);
- Column dummy = new Column(0, global.getObjectType());
- Declaration declaration = new Declaration(name, global, dummy);
+ final GlobalExtractor global = new GlobalExtractor( name,
+ this.maps[i] );
+ final Column dummy = new Column( 0,
+ global.getObjectType() );
+ final Declaration declaration = new Declaration( name,
+ global,
+ dummy );
return declaration;
}
}
@@ -73,9 +79,9 @@
}
public boolean available(final String name) {
- for( int i = this.buildStack.size()-1; i >= 0; i-- ) {
- Declaration declaration = ( Declaration ) (( RuleConditionElement ) this.buildStack.get( i )).getInnerDeclarations().get( name );
- if( declaration != null ) {
+ for ( int i = this.buildStack.size() - 1; i >= 0; i-- ) {
+ final Declaration declaration = (Declaration) ((RuleConditionElement) this.buildStack.get( i )).getInnerDeclarations().get( name );
+ if ( declaration != null ) {
return true;
}
}
@@ -86,18 +92,18 @@
}
return false;
}
-
- public boolean isDuplicated( final String name ) {
+
+ public boolean isDuplicated(final String name) {
for ( int i = 0, length = this.maps.length; i < length; i++ ) {
if ( this.maps[i].containsKey( (name) ) ) {
return true;
}
}
- for( int i = this.buildStack.size()-1; i >= 0; i-- ) {
- RuleConditionElement rce = ( RuleConditionElement ) this.buildStack.get( i );
- Declaration declaration = ( Declaration ) rce.getInnerDeclarations().get( name );
- if( declaration != null ) {
- if( ( rce instanceof GroupElement ) && ( (GroupElement)rce).isOr() ) {
+ for ( int i = this.buildStack.size() - 1; i >= 0; i-- ) {
+ final RuleConditionElement rce = (RuleConditionElement) this.buildStack.get( i );
+ final Declaration declaration = (Declaration) rce.getInnerDeclarations().get( name );
+ if ( declaration != null ) {
+ if ( (rce instanceof GroupElement) && ((GroupElement) rce).isOr() ) {
// if it is an OR and it is duplicated, we can stop looking for duplication now
// as it is a separate logical branch
return false;
@@ -107,7 +113,7 @@
}
return false;
}
-
+
/**
* Return all declarations scoped to the current
* RuleConditionElement in the build stack
@@ -115,8 +121,8 @@
* @return
*/
public Map getDeclarations() {
- Map declarations = new HashMap();
- for( int i = 0; i < this.buildStack.size(); i++ ) {
+ final Map declarations = new HashMap();
+ for ( int i = 0; i < this.buildStack.size(); i++ ) {
// this may be optimized in the future to only re-add elements at
// scope breaks, like "NOT" and "EXISTS"
declarations.putAll( ((RuleConditionElement) this.buildStack.get( i )).getInnerDeclarations() );
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/Evaluator.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/Evaluator.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/Evaluator.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -46,7 +46,7 @@
public boolean evaluate(Extractor extractor,
Object object1,
FieldValue value);
-
+
public boolean evaluate(Extractor leftExtractor,
Object left,
Extractor rightExtractor,
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/Extractor.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/Extractor.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/Extractor.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -46,9 +46,9 @@
public ValueType getValueType();
public Class getExtractToClass();
-
+
public Method getNativeReadMethod();
-
+
public int getHashCode(Object object);
}
\ No newline at end of file
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/FieldValue.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -39,13 +39,13 @@
public double getDoubleValue();
public boolean getBooleanValue();
-
+
public boolean isBooleanField();
-
+
public boolean isIntegerNumberField();
-
+
public boolean isFloatNumberField();
-
+
public boolean isObjectField();
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/GlobalExtractor.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/GlobalExtractor.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/GlobalExtractor.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -33,19 +33,21 @@
Extractor {
private static final long serialVersionUID = -756967384190918798L;
- private String key;
+ private final String key;
private Map map;
private ObjectType objectType;
- public GlobalExtractor(final String key, final Map map) {
+ public GlobalExtractor(final String key,
+ final Map map) {
+ this.key = key;
this.map = map;
this.objectType = new ClassObjectType( Object.class );
}
public Object getValue(final Object object) {
- return this.map.get( key );
+ return this.map.get( this.key );
}
-
+
public ObjectType getObjectType() {
return this.objectType;
}
@@ -59,8 +61,8 @@
}
public boolean getBooleanValue(final Object object) {
- Object value = this.map.get( this.key );
- if( value != null ) {
+ final Object value = this.map.get( this.key );
+ if ( value != null ) {
if ( value instanceof Boolean ) {
return ((Boolean) value).booleanValue();
}
@@ -70,8 +72,8 @@
}
public byte getByteValue(final Object object) {
- Object value = this.map.get( this.key );
- if( value != null ) {
+ final Object value = this.map.get( this.key );
+ if ( value != null ) {
if ( value instanceof Number ) {
return ((Number) value).byteValue();
}
@@ -81,8 +83,8 @@
}
public char getCharValue(final Object object) {
- Object value = this.map.get( this.key );
- if( value != null ) {
+ final Object value = this.map.get( this.key );
+ if ( value != null ) {
if ( value instanceof Character ) {
return ((Character) value).charValue();
}
@@ -92,8 +94,8 @@
}
public double getDoubleValue(final Object object) {
- Object value = this.map.get( this.key );
- if( value != null ) {
+ final Object value = this.map.get( this.key );
+ if ( value != null ) {
if ( value instanceof Number ) {
return ((Number) value).doubleValue();
}
@@ -103,8 +105,8 @@
}
public float getFloatValue(final Object object) {
- Object value = this.map.get( this.key );
- if( value != null ) {
+ final Object value = this.map.get( this.key );
+ if ( value != null ) {
if ( value instanceof Number ) {
return ((Number) value).floatValue();
}
@@ -114,8 +116,8 @@
}
public int getIntValue(final Object object) {
- Object value = this.map.get( this.key );
- if( value != null ) {
+ final Object value = this.map.get( this.key );
+ if ( value != null ) {
if ( value instanceof Number ) {
return ((Number) value).intValue();
}
@@ -125,8 +127,8 @@
}
public long getLongValue(final Object object) {
- Object value = this.map.get( this.key );
- if( value != null ) {
+ final Object value = this.map.get( this.key );
+ if ( value != null ) {
if ( value instanceof Number ) {
return ((Number) value).longValue();
}
@@ -136,8 +138,8 @@
}
public short getShortValue(final Object object) {
- Object value = this.map.get( this.key );
- if( value != null ) {
+ final Object value = this.map.get( this.key );
+ if ( value != null ) {
if ( value instanceof Number ) {
return ((Number) value).shortValue();
}
@@ -148,31 +150,33 @@
public Method getNativeReadMethod() {
try {
- return this.getClass().getDeclaredMethod( "getValue", new Class[] { Object.class } );
- } catch ( Exception e ) {
- throw new RuntimeDroolsException("This is a bug. Please report to development team: "+e.getMessage(), e);
+ return this.getClass().getDeclaredMethod( "getValue",
+ new Class[]{Object.class} );
+ } catch ( final Exception e ) {
+ throw new RuntimeDroolsException( "This is a bug. Please report to development team: " + e.getMessage(),
+ e );
}
}
- public int getHashCode(Object object) {
- Object value = this.map.get( this.key );
+ public int getHashCode(final Object object) {
+ final Object value = this.map.get( this.key );
return value != null ? value.hashCode() : 0;
}
-
+
public int hashCode() {
return this.objectType.hashCode();
}
-
- public boolean equals(Object obj) {
- if( this == obj ) {
+
+ public boolean equals(final Object obj) {
+ if ( this == obj ) {
return true;
}
- if( ! ( obj instanceof GlobalExtractor ) ) {
+ if ( !(obj instanceof GlobalExtractor) ) {
return false;
}
- GlobalExtractor other = (GlobalExtractor) obj;
- Object value = this.map.get( this.key );
- Object othervalue = other.map.get( this.key );
+ final GlobalExtractor other = (GlobalExtractor) obj;
+ final Object value = this.map.get( this.key );
+ final Object othervalue = other.map.get( this.key );
return value == null ? othervalue == null : value.equals( othervalue );
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/JavaFact.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/JavaFact.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/JavaFact.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -4,15 +4,15 @@
import org.drools.base.JavaFactRegistryEntry;
public interface JavaFact {
- public JavaFactRegistryEntry[] listWorkingMemories();
+ public JavaFactRegistryEntry[] listWorkingMemories();
- public boolean register(final WorkingMemory workingMemory);
+ public boolean register(final WorkingMemory workingMemory);
- public void unregisterAll();
+ public void unregisterAll();
- public boolean unregister(final WorkingMemory workingMemory);
+ public boolean unregister(final WorkingMemory workingMemory);
- public boolean isRegistered(final WorkingMemory workingMemory);
+ public boolean isRegistered(final WorkingMemory workingMemory);
- public int[] getChanges();
+ public int[] getChanges();
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/KnowledgeHelper.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/KnowledgeHelper.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/KnowledgeHelper.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -39,7 +39,9 @@
* @author <a href="mailto:bob at werken.com">bob mcwhirter </a>
* @author <a href="mailto:mproctor at codehaus.org">mark proctor</a>
*/
-public interface KnowledgeHelper extends Serializable {
+public interface KnowledgeHelper
+ extends
+ Serializable {
/**
* Asserts an object, notice that it does not return the FactHandle
*
@@ -117,7 +119,7 @@
void setFocus(String focus);
void setFocus(AgendaGroup focus);
-
- public Declaration getDeclaration(String identifier);
+ public Declaration getDeclaration(String identifier);
+
}
\ No newline at end of file
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/PropagationContext.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -17,11 +17,8 @@
*/
import java.io.Serializable;
-import java.util.HashMap;
-
import org.drools.reteoo.ReteTuple;
import org.drools.rule.Rule;
-import org.drools.util.TupleHashTable;
public interface PropagationContext
extends
@@ -40,15 +37,17 @@
public Activation getActivationOrigin();
public int getType();
-
+
public int getActiveActivations();
-
- public int getDormantActivations();
-
- public void addRetractedTuple(Rule rule, ReteTuple tuple);
-
- public ReteTuple removeRetractedTuple(Rule rule, ReteTuple tuple);
-
- public void clearRetractedTuples();
+ public int getDormantActivations();
+
+ public void addRetractedTuple(Rule rule,
+ ReteTuple tuple);
+
+ public ReteTuple removeRetractedTuple(Rule rule,
+ ReteTuple tuple);
+
+ public void clearRetractedTuples();
+
}
\ No newline at end of file
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/Restriction.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -21,7 +21,7 @@
public boolean isAllowedCachedRight(ReteTuple tuple,
ContextEntry context);
-
+
public ContextEntry getContextEntry();
-
+
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/RuleFlowGroup.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/RuleFlowGroup.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/RuleFlowGroup.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,4 +1,5 @@
package org.drools.spi;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -18,19 +19,19 @@
import java.util.Iterator;
public interface RuleFlowGroup {
-
+
String getName();
-
+
public Iterator iterator();
boolean isEmpty();
-
+
int size();
-
+
boolean isActive();
boolean isAutoDeactivate();
-
+
/**
* Sets the auto-deactivate status of this RuleFlowGroup.
* If this is set to true, an active RuleFlowGroup automatically
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/Tuple.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/Tuple.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/Tuple.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -32,7 +32,9 @@
* @author <a href="mailto:bob at werken.com">Bob McWhirter</a>
*
*/
-public interface Tuple extends Serializable {
+public interface Tuple
+ extends
+ Serializable {
/**
* Returns the <code>FactHandle</code> for the given column index. If the column is empty
* It returns null.
@@ -62,7 +64,7 @@
* @return
*/
long getRecency();
-
+
/**
* Returns the size of this tuple in number of elements (columns)
* @return
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/AbstractBaseLinkedListNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/AbstractBaseLinkedListNode.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/AbstractBaseLinkedListNode.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -30,9 +30,9 @@
private static final long serialVersionUID = 320L;
- private LinkedListNode previous;
+ private LinkedListNode previous;
- private LinkedListNode next;
+ private LinkedListNode next;
/**
* Empty Constructor
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/AbstractHashTable.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -38,7 +38,7 @@
this.table = new Entry[capacity];
this.comparator = EqualityEquals.getInstance();
}
-
+
public Iterator iterator() {
if ( this.iterator == null ) {
this.iterator = new HashTableIterator( this );
@@ -368,16 +368,16 @@
public boolean equals(final Object object) {
return (object == this) || (this.handle == ((FactEntry) object).handle);
}
-
+
public String toString() {
- return "FactEntry( handle="+this.handle+" hashcode="+this.hashCode+" next="+this.next+" )";
+ return "FactEntry( handle=" + this.handle + " hashcode=" + this.hashCode + " next=" + this.next + " )";
}
}
public static class FieldIndex {
- FieldExtractor extractor;
- Declaration declaration;
- public Evaluator evaluator;
+ FieldExtractor extractor;
+ Declaration declaration;
+ public Evaluator evaluator;
public FieldIndex(final FieldExtractor extractor,
final Declaration declaration,
@@ -524,8 +524,8 @@
public boolean equal(final Object right,
final ReteTuple tuple) {
- Object left1 = tuple.get( this.index0.declaration ).getObject();
- Object left2 = tuple.get( this.index1.declaration ).getObject();
+ final Object left1 = tuple.get( this.index0.declaration ).getObject();
+ final Object left2 = tuple.get( this.index1.declaration ).getObject();
return this.index0.evaluator.evaluate( this.index0.declaration.getExtractor(),
left1,
@@ -538,11 +538,11 @@
public boolean equal(final ReteTuple tuple1,
final ReteTuple tuple2) {
- Object object11 = tuple1.get( this.index0.declaration ).getObject();
- Object object12 = tuple2.get( this.index0.declaration ).getObject();
+ final Object object11 = tuple1.get( this.index0.declaration ).getObject();
+ final Object object12 = tuple2.get( this.index0.declaration ).getObject();
- Object object21 = tuple1.get( this.index1.declaration ).getObject();
- Object object22 = tuple2.get( this.index1.declaration ).getObject();
+ final Object object21 = tuple1.get( this.index1.declaration ).getObject();
+ final Object object22 = tuple2.get( this.index1.declaration ).getObject();
return this.index0.evaluator.evaluate( this.index0.declaration.getExtractor(),
object11,
@@ -614,9 +614,9 @@
public boolean equal(final Object right,
final ReteTuple tuple) {
- Object left1 = tuple.get( this.index0.declaration ).getObject();
- Object left2 = tuple.get( this.index1.declaration ).getObject();
- Object left3 = tuple.get( this.index2.declaration ).getObject();
+ final Object left1 = tuple.get( this.index0.declaration ).getObject();
+ final Object left2 = tuple.get( this.index1.declaration ).getObject();
+ final Object left3 = tuple.get( this.index2.declaration ).getObject();
return this.index0.evaluator.evaluate( this.index0.declaration.getExtractor(),
left1,
@@ -627,17 +627,17 @@
right ) && this.index2.evaluator.evaluate( this.index2.declaration.getExtractor(),
left3,
this.index2.extractor,
- right );
+ right );
}
public boolean equal(final ReteTuple tuple1,
final ReteTuple tuple2) {
- Object object11 = tuple1.get( this.index0.declaration ).getObject();
- Object object12 = tuple2.get( this.index0.declaration ).getObject();
- Object object21 = tuple1.get( this.index1.declaration ).getObject();
- Object object22 = tuple2.get( this.index1.declaration ).getObject();
- Object object31 = tuple1.get( this.index2.declaration ).getObject();
- Object object32 = tuple2.get( this.index2.declaration ).getObject();
+ final Object object11 = tuple1.get( this.index0.declaration ).getObject();
+ final Object object12 = tuple2.get( this.index0.declaration ).getObject();
+ final Object object21 = tuple1.get( this.index1.declaration ).getObject();
+ final Object object22 = tuple2.get( this.index1.declaration ).getObject();
+ final Object object31 = tuple1.get( this.index2.declaration ).getObject();
+ final Object object32 = tuple2.get( this.index2.declaration ).getObject();
return this.index0.evaluator.evaluate( this.index0.declaration.getExtractor(),
object11,
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/Entry.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/Entry.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/Entry.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -5,7 +5,9 @@
import java.io.Serializable;
-public interface Entry extends Serializable {
+public interface Entry
+ extends
+ Serializable {
public void setNext(Entry next);
public Entry getNext();
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/FactHandleIndexHashTable.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/FactHandleIndexHashTable.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/FactHandleIndexHashTable.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -11,9 +11,9 @@
implements
FactHandleMemory {
- private static final long serialVersionUID = -6033183838054653227L;
+ private static final long serialVersionUID = -6033183838054653227L;
- public static final int PRIME = 31;
+ public static final int PRIME = 31;
private int startResult;
@@ -30,8 +30,8 @@
}
public FactHandleIndexHashTable(final int capacity,
- final float loadFactor,
- final FieldIndex[] index) {
+ final float loadFactor,
+ final FieldIndex[] index) {
super( capacity,
loadFactor );
@@ -45,7 +45,7 @@
throw new IllegalArgumentException( "FieldIndexHashTable cannot use an index[] of length 0" );
case 1 :
this.index = new SingleIndex( index,
- this.startResult);
+ this.startResult );
break;
case 2 :
this.index = new DoubleCompositeIndex( index,
@@ -80,7 +80,7 @@
public Entry getBucket(final Object object) {
final int hashCode = this.index.hashCodeOf( object );
final int index = indexOf( hashCode,
- this.table.length );
+ this.table.length );
return this.table[index];
}
@@ -131,9 +131,9 @@
final Object object = handle.getObject();
//this.index.setCachedValue( object );
final int hashCode = this.index.hashCodeOf( object );
-
+
final int index = indexOf( hashCode,
- this.table.length );
+ 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
@@ -170,7 +170,7 @@
final int hashCode = this.index.hashCodeOf( object );
final int index = indexOf( hashCode,
- this.table.length );
+ this.table.length );
FieldIndexEntry current = (FieldIndexEntry) this.table[index];
while ( current != null ) {
@@ -189,7 +189,7 @@
final int hashCode = this.index.hashCodeOf( tuple );
final int index = indexOf( hashCode,
- this.table.length );
+ this.table.length );
FieldIndexEntry entry = (FieldIndexEntry) this.table[index];
while ( entry != null ) {
@@ -216,7 +216,7 @@
final int hashCode = this.index.hashCodeOf( object );
final int index = indexOf( hashCode,
- this.table.length );
+ this.table.length );
FieldIndexEntry entry = (FieldIndexEntry) this.table[index];
while ( entry != null ) {
@@ -249,10 +249,10 @@
Entry {
private static final long serialVersionUID = -577270475161063671L;
- private Entry next;
- private FactEntry first;
- private final int hashCode;
- private Index index;
+ private Entry next;
+ private FactEntry first;
+ private final int hashCode;
+ private Index index;
public FieldIndexEntry(final Index index,
final int hashCode) {
@@ -336,9 +336,9 @@
final FieldIndexEntry other = (FieldIndexEntry) object;
return this.hashCode == other.hashCode && this.index == other.index;
}
-
+
public String toString() {
- return "FieldIndexEntry( hashCode="+hashCode+" first="+this.first+" )";
+ return "FieldIndexEntry( hashCode=" + this.hashCode + " first=" + this.first + " )";
}
}
}
\ 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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/FactHashTable.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -6,7 +6,6 @@
import org.drools.common.InternalFactHandle;
import org.drools.reteoo.FactHandleMemory;
import org.drools.reteoo.ReteTuple;
-import org.drools.util.ObjectHashMap.ObjectEntry;
public class FactHashTable extends AbstractHashTable
implements
@@ -37,7 +36,7 @@
final boolean checkExists) {
final int hashCode = this.comparator.hashCodeOf( handle );
final int index = indexOf( hashCode,
- this.table.length );
+ this.table.length );
// scan the linked entries to see if it exists
if ( checkExists ) {
@@ -52,7 +51,7 @@
// We aren't checking the key exists, or it didn't find the key
final FactEntry entry = new FactEntry( handle,
- hashCode );
+ hashCode );
entry.next = this.table[index];
this.table[index] = entry;
@@ -65,7 +64,7 @@
public boolean contains(final InternalFactHandle handle) {
final int hashCode = this.comparator.hashCodeOf( handle );
final int index = indexOf( hashCode,
- this.table.length );
+ this.table.length );
FactEntry current = (FactEntry) this.table[index];
while ( current != null ) {
@@ -80,7 +79,7 @@
public boolean remove(final InternalFactHandle handle) {
final int hashCode = this.comparator.hashCodeOf( handle );
final int index = indexOf( hashCode,
- this.table.length );
+ this.table.length );
FactEntry previous = (FactEntry) this.table[index];
FactEntry current = previous;
@@ -105,11 +104,11 @@
public Entry getBucket(final Object object) {
final int hashCode = this.comparator.hashCodeOf( object );
final int index = indexOf( hashCode,
- this.table.length );
+ this.table.length );
return this.table[index];
}
-
+
public boolean isIndexed() {
return false;
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/Iterator.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/Iterator.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/Iterator.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -2,6 +2,8 @@
import java.io.Serializable;
-public interface Iterator extends Serializable {
+public interface Iterator
+ extends
+ Serializable {
public Entry next();
}
\ 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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/LinkedList.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -45,15 +45,15 @@
public class LinkedList
implements
Serializable {
- private static final long serialVersionUID = 320;
+ private static final long serialVersionUID = 320;
- private LinkedListNode firstNode;
- private LinkedListNode lastNode;
+ private LinkedListNode firstNode;
+ private LinkedListNode lastNode;
- private int size;
+ private int size;
private LinkedListIterator iterator;
-
+
/**
* Construct an empty <code>LinkedList</code>
*/
@@ -94,11 +94,11 @@
} else if ( this.lastNode == node ) {
removeLast();
} else {
- node.getPrevious().setNext( node.getNext() );
- ((LinkedListNode)node.getNext()).setPrevious( node.getPrevious() );
- this.size--;
- node.setPrevious( null );
- node.setNext( null );
+ node.getPrevious().setNext( node.getNext() );
+ (node.getNext()).setPrevious( node.getPrevious() );
+ this.size--;
+ node.setPrevious( null );
+ node.setNext( null );
}
}
@@ -132,7 +132,7 @@
return null;
}
final LinkedListNode node = this.firstNode;
- this.firstNode = (LinkedListNode) node.getNext();
+ this.firstNode = node.getNext();
node.setNext( null );
if ( this.firstNode != null ) {
this.firstNode.setPrevious( null );
@@ -157,11 +157,11 @@
newNode.setNext( node );
this.firstNode = newNode;
} else if ( existingNode == this.lastNode ) {
- existingNode.setNext(newNode);
- newNode.setPrevious( existingNode );
- this.lastNode = newNode;
+ existingNode.setNext( newNode );
+ newNode.setPrevious( existingNode );
+ this.lastNode = newNode;
} else {
- ((LinkedListNode)existingNode.getNext()).setPrevious( newNode );
+ (existingNode.getNext()).setPrevious( newNode );
newNode.setNext( existingNode.getNext() );
existingNode.setNext( newNode );
newNode.setPrevious( existingNode );
@@ -219,7 +219,7 @@
public int hashCode() {
final int PRIME = 31;
int result = 1;
- for ( LinkedListNode node = this.firstNode; node != null; node = (LinkedListNode)node.getNext() ) {
+ for ( LinkedListNode node = this.firstNode; node != null; node = node.getNext() ) {
result = PRIME * result + node.hashCode();
}
return result;
@@ -240,7 +240,7 @@
return false;
}
- for ( LinkedListNode thisNode = this.firstNode, otherNode = other.firstNode; thisNode != null && otherNode != null; thisNode = (LinkedListNode)thisNode.getNext(), otherNode = (LinkedListNode)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;
}
@@ -252,76 +252,83 @@
this.iterator.reset( this );
return this.iterator;
}
-
+
public java.util.Iterator javaUtilIterator() {
return new JavaUtilIterator( this );
}
-
+
/**
* Returns a list iterator
* @return
*/
- public class LinkedListIterator implements Serializable {
- private LinkedList list;
+ public class LinkedListIterator
+ implements
+ Serializable {
+ private LinkedList list;
private LinkedListNode current;
-
- public void reset( LinkedList list) {
+
+ public void reset(final LinkedList list) {
this.list = list;
this.current = this.list.firstNode;
}
-
+
public LinkedListNode next() {
- if( this.current == null ){
+ if ( this.current == null ) {
return null;
}
- LinkedListNode node = this.current;
- current = current.getNext();
+ final LinkedListNode node = this.current;
+ this.current = this.current.getNext();
return node;
}
}
-
- public static class JavaUtilIterator implements java.util.Iterator, Serializable {
- private LinkedList list;
- private LinkedListNode currentNode;
- private LinkedListNode nextNode;
- private boolean immutable;
- public JavaUtilIterator(LinkedList list) {
- this(list, true);
- }
+ public static class JavaUtilIterator
+ implements
+ java.util.Iterator,
+ Serializable {
+ private LinkedList list;
+ private LinkedListNode currentNode;
+ private LinkedListNode nextNode;
+ private boolean immutable;
- public JavaUtilIterator(LinkedList list, boolean immutable) {
- this.list = list;
- this.nextNode = this.list.getFirst();
- this.immutable = immutable;
- }
+ public JavaUtilIterator(final LinkedList list) {
+ this( list,
+ true );
+ }
- public boolean hasNext() {
- return (this.nextNode != null);
- }
+ public JavaUtilIterator(final LinkedList list,
+ final boolean immutable) {
+ this.list = list;
+ this.nextNode = this.list.getFirst();
+ this.immutable = immutable;
+ }
- public Object next() {
- this.currentNode = this.nextNode;
- if ( this.currentNode != null ) {
- this.nextNode = this.currentNode.getNext();
- } else {
- throw new NoSuchElementException( "No more elements to return" );
- }
- return this.currentNode;
- }
+ public boolean hasNext() {
+ return (this.nextNode != null);
+ }
- public void remove() {
- if ( this.immutable ) {
- throw new UnsupportedOperationException( "This Iterator is immutable, you cannot call remove()" );
- }
+ public Object next() {
+ this.currentNode = this.nextNode;
+ if ( this.currentNode != null ) {
+ this.nextNode = this.currentNode.getNext();
+ } else {
+ throw new NoSuchElementException( "No more elements to return" );
+ }
+ return this.currentNode;
+ }
- if ( this.currentNode != null ) {
- this.list.remove( this.currentNode );
- this.currentNode = null;
- } else {
- throw new IllegalStateException( "No item to remove. Call next() before calling remove()." );
- }
- }
- }
+ public void remove() {
+ if ( this.immutable ) {
+ throw new UnsupportedOperationException( "This Iterator is immutable, you cannot call remove()" );
+ }
+ if ( this.currentNode != null ) {
+ this.list.remove( this.currentNode );
+ this.currentNode = null;
+ } else {
+ throw new IllegalStateException( "No item to remove. Call next() before calling remove()." );
+ }
+ }
+ }
+
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/LinkedListEntry.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -24,7 +24,7 @@
public class LinkedListEntry extends AbstractBaseLinkedListNode {
private static final long serialVersionUID = 4631711292464775664L;
- private Object object;
+ private Object object;
public LinkedListEntry(final Object object) {
this.object = object;
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/ObjectHashMap.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -26,8 +26,9 @@
}
public void clear() {
- this.table = new Entry[Math.min( this.table.length, 16 )];
- this.threshold = (int) ( this.table.length * this.loadFactor );
+ this.table = new Entry[Math.min( this.table.length,
+ 16 )];
+ this.threshold = (int) (this.table.length * this.loadFactor);
}
public Object put(final Object key,
@@ -35,14 +36,14 @@
final boolean checkExists) {
final int hashCode = this.comparator.hashCodeOf( key );
final int index = indexOf( hashCode,
- this.table.length );
+ 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 && this.comparator.equal( key,
- current.key ) ) {
+ current.key ) ) {
final Object oldValue = current.value;
current.value = value;
return oldValue;
@@ -53,8 +54,8 @@
// We aren't checking the key exists, or it didn't find the key
final ObjectEntry entry = new ObjectEntry( key,
- value,
- hashCode );
+ value,
+ hashCode );
entry.next = this.table[index];
this.table[index] = entry;
@@ -67,12 +68,12 @@
public Object get(final Object key) {
final int hashCode = this.comparator.hashCodeOf( key );
final int index = indexOf( hashCode,
- this.table.length );
+ this.table.length );
ObjectEntry current = (ObjectEntry) this.table[index];
while ( current != null ) {
if ( hashCode == current.hashCode && this.comparator.equal( key,
- current.key ) ) {
+ current.key ) ) {
return current.value;
}
current = (ObjectEntry) current.getNext();
@@ -83,14 +84,14 @@
public Object remove(final Object key) {
final int hashCode = this.comparator.hashCodeOf( key );
final int index = indexOf( hashCode,
- this.table.length );
+ this.table.length );
ObjectEntry previous = (ObjectEntry) this.table[index];
ObjectEntry current = previous;
while ( current != null ) {
final ObjectEntry next = (ObjectEntry) current.getNext();
if ( hashCode == current.hashCode && this.comparator.equal( key,
- current.key ) ) {
+ current.key ) ) {
if ( previous == current ) {
this.table[index] = next;
} else {
@@ -109,7 +110,7 @@
public Entry getBucket(final Object object) {
final int hashCode = this.comparator.hashCodeOf( object );
final int index = indexOf( hashCode,
- this.table.length );
+ this.table.length );
return this.table[index];
}
@@ -120,13 +121,13 @@
private static final long serialVersionUID = -2589987113898296555L;
- private Object key;
+ private Object key;
- private Object value;
+ private Object value;
- private int hashCode;
+ private int hashCode;
- private Entry next;
+ private Entry next;
public ObjectEntry(final Object key,
final Object value,
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/TupleHashTable.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -7,7 +7,9 @@
import org.drools.reteoo.ReteTuple;
import org.drools.reteoo.TupleMemory;
-public class TupleHashTable extends AbstractHashTable implements TupleMemory {
+public class TupleHashTable extends AbstractHashTable
+ implements
+ TupleMemory {
public TupleHashTable() {
this( 16,
0.75f );
@@ -18,15 +20,15 @@
super( capacity,
loadFactor );
}
-
+
public Iterator iterator(final InternalFactHandle handle) {
return iterator();
- }
+ }
public void add(final ReteTuple tuple) {
final int hashCode = tuple.hashCode();
final int index = indexOf( hashCode,
- this.table.length );
+ this.table.length );
tuple.setNext( this.table[index] );
this.table[index] = tuple;
@@ -39,7 +41,7 @@
public ReteTuple get(final ReteTuple tuple) {
final int hashCode = tuple.hashCode();
final int index = indexOf( hashCode,
- this.table.length );
+ this.table.length );
ReteTuple current = (ReteTuple) this.table[index];
while ( current != null ) {
@@ -54,7 +56,7 @@
public ReteTuple remove(final ReteTuple tuple) {
final int hashCode = tuple.hashCode();
final int index = indexOf( hashCode,
- this.table.length );
+ this.table.length );
ReteTuple previous = (ReteTuple) this.table[index];
ReteTuple current = previous;
@@ -79,7 +81,7 @@
public Entry getBucket(final Object object) {
final int hashCode = object.hashCode();
final int index = indexOf( hashCode,
- this.table.length );
+ this.table.length );
return this.table[index];
}
@@ -87,7 +89,7 @@
public boolean contains(final ReteTuple tuple) {
return (get( tuple ) != null);
}
-
+
public boolean isIndexed() {
return false;
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/TupleIndexHashTable.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/TupleIndexHashTable.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/TupleIndexHashTable.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -11,18 +11,18 @@
implements
TupleMemory {
- private static final long serialVersionUID = -6214772340195061306L;
+ private static final long serialVersionUID = -6214772340195061306L;
- public static final int PRIME = 31;
+ public static final int PRIME = 31;
- private int startResult;
+ private int startResult;
- private FieldIndexHashTableIterator tupleValueIterator;
+ private FieldIndexHashTableIterator tupleValueIterator;
private FieldIndexHashTableFullIterator tupleValueFullIterator;
- private int factSize;
+ private int factSize;
- private Index index;
+ private Index index;
public TupleIndexHashTable(final FieldIndex[] index) {
this( 16,
@@ -63,12 +63,12 @@
public Iterator iterator() {
if ( this.tupleValueFullIterator == null ) {
- this.tupleValueFullIterator = new FieldIndexHashTableFullIterator(this);
+ this.tupleValueFullIterator = new FieldIndexHashTableFullIterator( this );
}
this.tupleValueFullIterator.reset();
return this.tupleValueFullIterator;
}
-
+
public Iterator iterator(final InternalFactHandle handle) {
if ( this.tupleValueIterator == null ) {
this.tupleValueIterator = new FieldIndexHashTableIterator();
@@ -144,7 +144,7 @@
if ( this.row == this.length ) {
return null;
}
- this.entry = ( this.table[this.row] != null ) ? ((FieldIndexEntry) this.table[this.row]).first : null ;
+ this.entry = (this.table[this.row] != null) ? ((FieldIndexEntry) this.table[this.row]).first : null;
}
} else {
this.entry = this.entry.getNext();
@@ -192,7 +192,7 @@
final FieldIndexEntry next = (FieldIndexEntry) current.next;
if ( current.matches( tuple,
hashCode ) ) {
- ReteTuple old = current.remove( tuple );
+ final ReteTuple old = current.remove( tuple );
this.factSize--;
// If the FactEntryIndex is empty, then remove it from the hash table
if ( current.first == null ) {
@@ -230,7 +230,7 @@
}
public FieldIndexEntry get(final InternalFactHandle handle) {
- Object object = handle.getObject();
+ final Object object = handle.getObject();
final int hashCode = this.index.hashCodeOf( handle.getObject() );
final int index = indexOf( hashCode,
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/asm/ClassFieldInspector.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -73,7 +73,7 @@
includeFinalMethods );
} else {
processClassWithoutByteCode( clazz,
- includeFinalMethods );
+ includeFinalMethods );
}
}
@@ -117,22 +117,20 @@
}
}
- private void processClassWithoutByteCode(Class clazz,
+ private void processClassWithoutByteCode(final Class clazz,
final boolean includeFinalMethods) {
- Method[] methods = clazz.getMethods();
+ final Method[] methods = clazz.getMethods();
for ( int i = 0; i < methods.length; i++ ) {
//only want public methods that start with 'get' or 'is'
//and have no args, and return a value
final int mask = includeFinalMethods ? Modifier.PUBLIC : Modifier.PUBLIC | Modifier.FINAL;
- if ( (( methods[i].getModifiers() & mask ) == Modifier.PUBLIC ) &&
- ( methods[i].getParameterTypes().length == 0) &&
- ( !methods[i].getName().equals( "<init>" )) &&
- //( !methods[i].getName().equals( "<clinit>" )) &&
+ if ( ((methods[i].getModifiers() & mask) == Modifier.PUBLIC) && (methods[i].getParameterTypes().length == 0) && (!methods[i].getName().equals( "<init>" )) &&
+ //( !methods[i].getName().equals( "<clinit>" )) &&
(methods[i].getReturnType() != void.class) ) {
- final int fieldIndex = this.methods.size();
- addToMapping( methods[i],
- fieldIndex );
+ final int fieldIndex = this.methods.size();
+ addToMapping( methods[i],
+ fieldIndex );
}
}
}
@@ -220,11 +218,11 @@
final int index,
final String fieldName) {
this.fieldNames.put( fieldName,
- new Integer( index ) );
+ new Integer( index ) );
this.fieldTypes.put( fieldName,
- method.getReturnType() );
+ method.getReturnType() );
this.methodNames.put( fieldName,
- method );
+ method );
this.methods.add( method );
}
@@ -263,9 +261,8 @@
//and have no args, and return a value
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.equals( "<clinit>" ) ) */) {// && ( name.startsWith("get") || name.startsWith("is") ) ) {
+ if ( desc.startsWith( "()" ) && (!name.equals( "<init>" )) /*&&
+ ( ! name.equals( "<clinit>" ) ) */) {// && ( name.startsWith("get") || name.startsWith("is") ) ) {
try {
final Method method = this.clazz.getMethod( name,
(Class[]) null );
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/Objenesis.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/Objenesis.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/Objenesis.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -9,21 +9,21 @@
*/
public interface Objenesis {
- /**
- * Will create a new object without any constructor being called
- *
- * @param clazz Class to instantiate
- * @return New instance of clazz
- */
- Object newInstance(Class clazz);
+ /**
+ * Will create a new object without any constructor being called
+ *
+ * @param clazz Class to instantiate
+ * @return New instance of clazz
+ */
+ Object newInstance(Class clazz);
- /**
- * Will pick the best instantiator for the provided class. If you need to create a lot of
- * instances from the same class, it is way more efficient to create them from the same
- * ObjectInstantiator than calling {@link #newInstance(Class)}.
- *
- * @param clazz Class to instantiate
- * @return Instantiator dedicated to the class
- */
- ObjectInstantiator getInstantiatorOf(Class clazz);
+ /**
+ * Will pick the best instantiator for the provided class. If you need to create a lot of
+ * instances from the same class, it is way more efficient to create them from the same
+ * ObjectInstantiator than calling {@link #newInstance(Class)}.
+ *
+ * @param clazz Class to instantiate
+ * @return Instantiator dedicated to the class
+ */
+ ObjectInstantiator getInstantiatorOf(Class clazz);
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/ObjenesisBase.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/ObjenesisBase.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/ObjenesisBase.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -2,8 +2,6 @@
import java.util.HashMap;
import java.util.Map;
-import java.util.WeakHashMap;
-
import org.objenesis.instantiator.ObjectInstantiator;
import org.objenesis.strategy.InstantiatorStrategy;
@@ -13,70 +11,74 @@
*
* @author Henri Tremblay
*/
-public class ObjenesisBase implements Objenesis {
+public class ObjenesisBase
+ implements
+ Objenesis {
- /** Strategy used by this Objenesi implementation to create classes */
- protected final InstantiatorStrategy strategy;
+ /** Strategy used by this Objenesi implementation to create classes */
+ protected final InstantiatorStrategy strategy;
- /** Strategy cache. Key = Class, Value = InstantiatorStrategy */
- protected Map cache;
+ /** Strategy cache. Key = Class, Value = InstantiatorStrategy */
+ protected Map cache;
- /**
- * Constructor allowing to pick a strategy and using cache
- *
- * @param strategy Strategy to use
- */
- public ObjenesisBase(InstantiatorStrategy strategy) {
- this(strategy, true);
- }
+ /**
+ * Constructor allowing to pick a strategy and using cache
+ *
+ * @param strategy Strategy to use
+ */
+ public ObjenesisBase(final InstantiatorStrategy strategy) {
+ this( strategy,
+ true );
+ }
- /**
- * Flexible constructor allowing to pick the strategy and if caching should be used
- *
- * @param strategy Strategy to use
- * @param useCache If {@link ObjectInstantiator}s should be cached
- */
- public ObjenesisBase(InstantiatorStrategy strategy, boolean useCache) {
- if(strategy == null) {
- throw new IllegalArgumentException("A strategy can't be null");
- }
- this.strategy = strategy;
- this.cache = useCache ? new HashMap() : null;
- }
+ /**
+ * Flexible constructor allowing to pick the strategy and if caching should be used
+ *
+ * @param strategy Strategy to use
+ * @param useCache If {@link ObjectInstantiator}s should be cached
+ */
+ public ObjenesisBase(final InstantiatorStrategy strategy,
+ final boolean useCache) {
+ if ( strategy == null ) {
+ throw new IllegalArgumentException( "A strategy can't be null" );
+ }
+ this.strategy = strategy;
+ this.cache = useCache ? new HashMap() : null;
+ }
- public String toString() {
- return getClass().getName() + " using " + strategy.getClass().getName()
- + (cache == null ? " without" : " with") + " caching";
- }
+ public String toString() {
+ return getClass().getName() + " using " + this.strategy.getClass().getName() + (this.cache == null ? " without" : " with") + " caching";
+ }
- /**
- * Will create a new object without any constructor being called
- *
- * @param clazz Class to instantiate
- * @return New instance of clazz
- */
- public Object newInstance(Class clazz) {
- return getInstantiatorOf(clazz).newInstance();
- }
+ /**
+ * Will create a new object without any constructor being called
+ *
+ * @param clazz Class to instantiate
+ * @return New instance of clazz
+ */
+ public Object newInstance(final Class clazz) {
+ return getInstantiatorOf( clazz ).newInstance();
+ }
- /**
- * Will pick the best instantiator for the provided class. If you need to create a lot of
- * instances from the same class, it is way more efficient to create them from the same
- * ObjectInstantiator than calling {@link #newInstance(Class)}.
- *
- * @param clazz Class to instantiate
- * @return Instantiator dedicated to the class
- */
- public synchronized ObjectInstantiator getInstantiatorOf(Class clazz) {
- if(cache == null) {
- return strategy.newInstantiatorOf(clazz);
- }
- ObjectInstantiator instantiator = (ObjectInstantiator) cache.get(clazz.getName());
- if(instantiator == null) {
- instantiator = strategy.newInstantiatorOf(clazz);
- cache.put(clazz.getName(), instantiator);
- }
- return instantiator;
- }
+ /**
+ * Will pick the best instantiator for the provided class. If you need to create a lot of
+ * instances from the same class, it is way more efficient to create them from the same
+ * ObjectInstantiator than calling {@link #newInstance(Class)}.
+ *
+ * @param clazz Class to instantiate
+ * @return Instantiator dedicated to the class
+ */
+ public synchronized ObjectInstantiator getInstantiatorOf(final Class clazz) {
+ if ( this.cache == null ) {
+ return this.strategy.newInstantiatorOf( clazz );
+ }
+ ObjectInstantiator instantiator = (ObjectInstantiator) this.cache.get( clazz.getName() );
+ if ( instantiator == null ) {
+ instantiator = this.strategy.newInstantiatorOf( clazz );
+ this.cache.put( clazz.getName(),
+ instantiator );
+ }
+ return instantiator;
+ }
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/ObjenesisException.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/ObjenesisException.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/ObjenesisException.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -9,34 +9,34 @@
*/
public class ObjenesisException extends RuntimeException {
- private static final boolean jdk14 = (Double.parseDouble(System
- .getProperty("java.specification.version")) > 1.3);
+ private static final boolean jdk14 = (Double.parseDouble( System.getProperty( "java.specification.version" ) ) > 1.3);
- /**
- * @param msg Error message
- */
- public ObjenesisException(String msg) {
- super(msg);
- }
+ /**
+ * @param msg Error message
+ */
+ public ObjenesisException(final String msg) {
+ super( msg );
+ }
- /**
- * @param cause Wrapped exception. The message will be the one of the cause.
- */
- public ObjenesisException(Throwable cause) {
- super(cause == null ? null : cause.toString());
- if(jdk14) {
- initCause(cause);
- }
- }
+ /**
+ * @param cause Wrapped exception. The message will be the one of the cause.
+ */
+ public ObjenesisException(final Throwable cause) {
+ super( cause == null ? null : cause.toString() );
+ if ( jdk14 ) {
+ initCause( cause );
+ }
+ }
- /**
- * @param msg Error message
- * @param cause Wrapped exception
- */
- public ObjenesisException(String msg, Throwable cause) {
- super(msg);
- if(jdk14) {
- initCause(cause);
- }
- }
+ /**
+ * @param msg Error message
+ * @param cause Wrapped exception
+ */
+ public ObjenesisException(final String msg,
+ final Throwable cause) {
+ super( msg );
+ if ( jdk14 ) {
+ initCause( cause );
+ }
+ }
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/ObjenesisHelper.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/ObjenesisHelper.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/ObjenesisHelper.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -11,55 +11,55 @@
*/
public final class ObjenesisHelper {
- private static final Objenesis OBJENESIS_STD = new ObjenesisStd();
+ private static final Objenesis OBJENESIS_STD = new ObjenesisStd();
- private static final Objenesis OBJENESIS_SERIALIZER = new ObjenesisSerializer();
+ private static final Objenesis OBJENESIS_SERIALIZER = new ObjenesisSerializer();
- private ObjenesisHelper() {
- }
+ private ObjenesisHelper() {
+ }
- /**
- * Will create a new object without any constructor being called
- *
- * @param clazz Class to instantiate
- * @return New instance of clazz
- */
- public static final Object newInstance(Class clazz) {
- return OBJENESIS_STD.newInstance(clazz);
- }
+ /**
+ * Will create a new object without any constructor being called
+ *
+ * @param clazz Class to instantiate
+ * @return New instance of clazz
+ */
+ public static final Object newInstance(final Class clazz) {
+ return OBJENESIS_STD.newInstance( clazz );
+ }
- /**
- * Will create an object just like it's done by ObjectInputStream.readObject (the default
- * constructor of the first non serializable class will be called)
- *
- * @param clazz Class to instantiate
- * @return New instance of clazz
- */
- public static final Serializable newSerializableInstance(Class clazz) {
- return (Serializable) OBJENESIS_SERIALIZER.newInstance(clazz);
- }
+ /**
+ * Will create an object just like it's done by ObjectInputStream.readObject (the default
+ * constructor of the first non serializable class will be called)
+ *
+ * @param clazz Class to instantiate
+ * @return New instance of clazz
+ */
+ public static final Serializable newSerializableInstance(final Class clazz) {
+ return (Serializable) OBJENESIS_SERIALIZER.newInstance( clazz );
+ }
- /**
- * Will pick the best instantiator for the provided class. If you need to create a lot of
- * instances from the same class, it is way more efficient to create them from the same
- * ObjectInstantiator than calling {@link #newInstance(Class)}.
- *
- * @param clazz Class to instantiate
- * @return Instantiator dedicated to the class
- */
- public static final ObjectInstantiator getInstantiatorOf(Class clazz) {
- return OBJENESIS_STD.getInstantiatorOf(clazz);
- }
+ /**
+ * Will pick the best instantiator for the provided class. If you need to create a lot of
+ * instances from the same class, it is way more efficient to create them from the same
+ * ObjectInstantiator than calling {@link #newInstance(Class)}.
+ *
+ * @param clazz Class to instantiate
+ * @return Instantiator dedicated to the class
+ */
+ public static final ObjectInstantiator getInstantiatorOf(final Class clazz) {
+ return OBJENESIS_STD.getInstantiatorOf( clazz );
+ }
- /**
- * Same as {@link #getInstantiatorOf(Class)} but providing an instantiator emulating
- * ObjectInputStream.readObject behavior.
- *
- * @see #newSerializableInstance(Class)
- * @param clazz Class to instantiate
- * @return Instantiator dedicated to the class
- */
- public static final ObjectInstantiator getSerializableObjectInstantiatorOf(Class clazz) {
- return OBJENESIS_SERIALIZER.getInstantiatorOf(clazz);
- }
+ /**
+ * Same as {@link #getInstantiatorOf(Class)} but providing an instantiator emulating
+ * ObjectInputStream.readObject behavior.
+ *
+ * @see #newSerializableInstance(Class)
+ * @param clazz Class to instantiate
+ * @return Instantiator dedicated to the class
+ */
+ public static final ObjectInstantiator getSerializableObjectInstantiatorOf(final Class clazz) {
+ return OBJENESIS_SERIALIZER.getInstantiatorOf( clazz );
+ }
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/ObjenesisSerializer.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/ObjenesisSerializer.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/ObjenesisSerializer.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -9,20 +9,21 @@
*/
public class ObjenesisSerializer extends ObjenesisBase {
- /**
- * Default constructor using the {@link org.objenesis.strategy.SerializingInstantiatorStrategy}
- */
- public ObjenesisSerializer() {
- super(new SerializingInstantiatorStrategy());
- }
+ /**
+ * Default constructor using the {@link org.objenesis.strategy.SerializingInstantiatorStrategy}
+ */
+ public ObjenesisSerializer() {
+ super( new SerializingInstantiatorStrategy() );
+ }
- /**
- * Instance using the {@link org.objenesis.strategy.SerializingInstantiatorStrategy} with or without caching
- * {@link org.objenesis.instantiator.ObjectInstantiator}s
- *
- * @param useCache If {@link org.objenesis.instantiator.ObjectInstantiator}s should be cached
- */
- public ObjenesisSerializer(boolean useCache) {
- super(new SerializingInstantiatorStrategy(), useCache);
- }
+ /**
+ * Instance using the {@link org.objenesis.strategy.SerializingInstantiatorStrategy} with or without caching
+ * {@link org.objenesis.instantiator.ObjectInstantiator}s
+ *
+ * @param useCache If {@link org.objenesis.instantiator.ObjectInstantiator}s should be cached
+ */
+ public ObjenesisSerializer(final boolean useCache) {
+ super( new SerializingInstantiatorStrategy(),
+ useCache );
+ }
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/ObjenesisStd.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/ObjenesisStd.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/ObjenesisStd.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -9,20 +9,21 @@
*/
public class ObjenesisStd extends ObjenesisBase {
- /**
- * Default constructor using the {@link org.objenesis.strategy.StdInstantiatorStrategy}
- */
- public ObjenesisStd() {
- super(new StdInstantiatorStrategy());
- }
+ /**
+ * Default constructor using the {@link org.objenesis.strategy.StdInstantiatorStrategy}
+ */
+ public ObjenesisStd() {
+ super( new StdInstantiatorStrategy() );
+ }
- /**
- * Instance using the {@link org.objenesis.strategy.StdInstantiatorStrategy} with or without
- * caching {@link org.objenesis.instantiator.ObjectInstantiator}s
- *
- * @param useCache If {@link org.objenesis.instantiator.ObjectInstantiator}s should be cached
- */
- public ObjenesisStd(boolean useCache) {
- super(new StdInstantiatorStrategy(), useCache);
- }
+ /**
+ * Instance using the {@link org.objenesis.strategy.StdInstantiatorStrategy} with or without
+ * caching {@link org.objenesis.instantiator.ObjectInstantiator}s
+ *
+ * @param useCache If {@link org.objenesis.instantiator.ObjectInstantiator}s should be cached
+ */
+ public ObjenesisStd(final boolean useCache) {
+ super( new StdInstantiatorStrategy(),
+ useCache );
+ }
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/NullInstantiator.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/NullInstantiator.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/NullInstantiator.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -5,12 +5,14 @@
*
* @author Henri Tremblay
*/
-public class NullInstantiator implements ObjectInstantiator {
+public class NullInstantiator
+ implements
+ ObjectInstantiator {
- /**
- * @return Always null
- */
- public Object newInstance() {
- return null;
- }
+ /**
+ * @return Always null
+ */
+ public Object newInstance() {
+ return null;
+ }
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/ObjectInstantiator.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/ObjectInstantiator.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/ObjectInstantiator.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -5,12 +5,12 @@
*/
public interface ObjectInstantiator {
- /**
- * Returns a new instance of an object. The returned object's class is defined by the
- * implementation.
- *
- * @return A new instance of an object.
- */
- Object newInstance();
+ /**
+ * Returns a new instance of an object. The returned object's class is defined by the
+ * implementation.
+ *
+ * @return A new instance of an object.
+ */
+ Object newInstance();
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/SerializationInstantiatorHelper.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/SerializationInstantiatorHelper.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/SerializationInstantiatorHelper.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -9,25 +9,25 @@
*/
public class SerializationInstantiatorHelper {
- /**
- * Returns the first non-serializable superclass of a given class. According to Java Object
- * Serialization Specification, objects read from a stream are initialized by calling an
- * accessible no-arg constructor from the first non-serializable superclass in the object's
- * hierarchy, allowing the state of non-serializable fields to be correctly initialized.
- *
- * @param type Serializable class for which the first non-serializable superclass is to be found
- * @return The first non-serializable superclass of 'type'.
- * @see java.io.Serializable
- */
- public static Class getNonSerializableSuperClass(Class type) {
- Class result = type;
- while(Serializable.class.isAssignableFrom(result)) {
- result = result.getSuperclass();
- if(result == null) {
- throw new Error("Bad class hierarchy: No non-serializable parents");
- }
- }
- return result;
+ /**
+ * Returns the first non-serializable superclass of a given class. According to Java Object
+ * Serialization Specification, objects read from a stream are initialized by calling an
+ * accessible no-arg constructor from the first non-serializable superclass in the object's
+ * hierarchy, allowing the state of non-serializable fields to be correctly initialized.
+ *
+ * @param type Serializable class for which the first non-serializable superclass is to be found
+ * @return The first non-serializable superclass of 'type'.
+ * @see java.io.Serializable
+ */
+ public static Class getNonSerializableSuperClass(final Class type) {
+ Class result = type;
+ while ( Serializable.class.isAssignableFrom( result ) ) {
+ result = result.getSuperclass();
+ if ( result == null ) {
+ throw new Error( "Bad class hierarchy: No non-serializable parents" );
+ }
+ }
+ return result;
- }
+ }
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/basic/AccessibleInstantiator.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/basic/AccessibleInstantiator.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/basic/AccessibleInstantiator.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -9,10 +9,10 @@
*/
public class AccessibleInstantiator extends ConstructorInstantiator {
- public AccessibleInstantiator(Class type) {
- super(type);
- if(constructor != null) {
- constructor.setAccessible(true);
- }
- }
+ public AccessibleInstantiator(final Class type) {
+ super( type );
+ if ( this.constructor != null ) {
+ this.constructor.setAccessible( true );
+ }
+ }
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/basic/ConstructorInstantiator.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/basic/ConstructorInstantiator.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/basic/ConstructorInstantiator.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -11,26 +11,26 @@
*
* @see ObjectInstantiator
*/
-public class ConstructorInstantiator implements ObjectInstantiator {
+public class ConstructorInstantiator
+ implements
+ ObjectInstantiator {
- protected Constructor constructor;
+ protected Constructor constructor;
- public ConstructorInstantiator(Class type) {
- try {
- constructor = type.getDeclaredConstructor((Class[]) null);
- }
- catch(Exception e) {
- throw new ObjenesisException(e);
- }
- }
+ public ConstructorInstantiator(final Class type) {
+ try {
+ this.constructor = type.getDeclaredConstructor( (Class[]) null );
+ } catch ( final Exception e ) {
+ throw new ObjenesisException( e );
+ }
+ }
- public Object newInstance() {
- try {
- return constructor.newInstance((Object[]) null);
- }
- catch(Exception e) {
- throw new ObjenesisException(e);
- }
- }
+ public Object newInstance() {
+ try {
+ return this.constructor.newInstance( (Object[]) null );
+ } catch ( final Exception e ) {
+ throw new ObjenesisException( e );
+ }
+ }
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/basic/NewInstanceInstantiator.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/basic/NewInstanceInstantiator.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/basic/NewInstanceInstantiator.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -9,21 +9,22 @@
*
* @see ObjectInstantiator
*/
-public class NewInstanceInstantiator implements ObjectInstantiator {
+public class NewInstanceInstantiator
+ implements
+ ObjectInstantiator {
- private final Class type;
+ private final Class type;
- public NewInstanceInstantiator(Class type) {
- this.type = type;
- }
+ public NewInstanceInstantiator(final Class type) {
+ this.type = type;
+ }
- public Object newInstance() {
- try {
- return type.newInstance();
- }
- catch(Exception e) {
- throw new ObjenesisException(e);
- }
- }
+ public Object newInstance() {
+ try {
+ return this.type.newInstance();
+ } catch ( final Exception e ) {
+ throw new ObjenesisException( e );
+ }
+ }
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/basic/ObjectInputStreamInstantiator.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/basic/ObjectInputStreamInstantiator.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/basic/ObjectInputStreamInstantiator.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -23,142 +23,148 @@
* @author Leonardo Mesquita
* @see org.objenesis.instantiator.ObjectInstantiator
*/
-public class ObjectInputStreamInstantiator implements ObjectInstantiator {
- private static class MockStream extends InputStream {
+public class ObjectInputStreamInstantiator
+ implements
+ ObjectInstantiator {
+ private static class MockStream extends InputStream {
- private int pointer;
- private byte[] data;
- private int sequence;
- private static final int[] NEXT = new int[] {1, 2, 2};
- private byte[][] buffers;
+ private int pointer;
+ private byte[] data;
+ private int sequence;
+ private static final int[] NEXT = new int[]{1, 2, 2};
+ private byte[][] buffers;
- private final byte[] FIRST_DATA;
- private static byte[] HEADER;
- private static byte[] REPEATING_DATA;
+ private final byte[] FIRST_DATA;
+ private static byte[] HEADER;
+ private static byte[] REPEATING_DATA;
- static {
- initialize();
- }
+ static {
+ initialize();
+ }
- private static void initialize() {
- try {
- ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
- DataOutputStream dout = new DataOutputStream(byteOut);
- dout.writeShort(ObjectStreamConstants.STREAM_MAGIC);
- dout.writeShort(ObjectStreamConstants.STREAM_VERSION);
- HEADER = byteOut.toByteArray();
+ private static void initialize() {
+ try {
+ ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
+ DataOutputStream dout = new DataOutputStream( byteOut );
+ dout.writeShort( ObjectStreamConstants.STREAM_MAGIC );
+ dout.writeShort( ObjectStreamConstants.STREAM_VERSION );
+ HEADER = byteOut.toByteArray();
- byteOut = new ByteArrayOutputStream();
- dout = new DataOutputStream(byteOut);
+ byteOut = new ByteArrayOutputStream();
+ dout = new DataOutputStream( byteOut );
- dout.writeByte(ObjectStreamConstants.TC_OBJECT);
- dout.writeByte(ObjectStreamConstants.TC_REFERENCE);
- dout.writeInt(ObjectStreamConstants.baseWireHandle);
- REPEATING_DATA = byteOut.toByteArray();
- }
- catch(IOException e) {
- throw new Error("IOException: " + e.getMessage());
- }
+ dout.writeByte( ObjectStreamConstants.TC_OBJECT );
+ dout.writeByte( ObjectStreamConstants.TC_REFERENCE );
+ dout.writeInt( ObjectStreamConstants.baseWireHandle );
+ REPEATING_DATA = byteOut.toByteArray();
+ } catch ( final IOException e ) {
+ throw new Error( "IOException: " + e.getMessage() );
+ }
- }
+ }
- public MockStream(Class clazz) {
- this.pointer = 0;
- this.sequence = 0;
- this.data = HEADER;
+ public MockStream(final Class clazz) {
+ this.pointer = 0;
+ this.sequence = 0;
+ this.data = HEADER;
- // (byte) TC_OBJECT
- // (byte) TC_CLASSDESC
- // (short length)
- // (byte * className.length)
- // (long)serialVersionUID
- // (byte) SC_SERIALIZABLE
- // (short)0 <fields>
- // TC_ENDBLOCKDATA
- // TC_NULL
- ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
- DataOutputStream dout = new DataOutputStream(byteOut);
- try {
- dout.writeByte(ObjectStreamConstants.TC_OBJECT);
- dout.writeByte(ObjectStreamConstants.TC_CLASSDESC);
- dout.writeUTF(clazz.getName());
- dout.writeLong(ObjectStreamClass.lookup(clazz).getSerialVersionUID());
- dout.writeByte(ObjectStreamConstants.SC_SERIALIZABLE);
- dout.writeShort((short) 0); // Zero fields
- dout.writeByte(ObjectStreamConstants.TC_ENDBLOCKDATA);
- dout.writeByte(ObjectStreamConstants.TC_NULL);
- }
- catch(IOException e) {
- throw new Error("IOException: " + e.getMessage());
- }
- this.FIRST_DATA = byteOut.toByteArray();
- buffers = new byte[][] {HEADER, FIRST_DATA, REPEATING_DATA};
- }
+ // (byte) TC_OBJECT
+ // (byte) TC_CLASSDESC
+ // (short length)
+ // (byte * className.length)
+ // (long)serialVersionUID
+ // (byte) SC_SERIALIZABLE
+ // (short)0 <fields>
+ // TC_ENDBLOCKDATA
+ // TC_NULL
+ final ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
+ final DataOutputStream dout = new DataOutputStream( byteOut );
+ try {
+ dout.writeByte( ObjectStreamConstants.TC_OBJECT );
+ dout.writeByte( ObjectStreamConstants.TC_CLASSDESC );
+ dout.writeUTF( clazz.getName() );
+ dout.writeLong( ObjectStreamClass.lookup( clazz ).getSerialVersionUID() );
+ dout.writeByte( ObjectStreamConstants.SC_SERIALIZABLE );
+ dout.writeShort( (short) 0 ); // Zero fields
+ dout.writeByte( ObjectStreamConstants.TC_ENDBLOCKDATA );
+ dout.writeByte( ObjectStreamConstants.TC_NULL );
+ } catch ( final IOException e ) {
+ throw new Error( "IOException: " + e.getMessage() );
+ }
+ this.FIRST_DATA = byteOut.toByteArray();
+ this.buffers = new byte[][]{HEADER, this.FIRST_DATA, REPEATING_DATA};
+ }
- private void advanceBuffer() {
- pointer = 0;
- sequence = NEXT[sequence];
- data = buffers[sequence];
- }
+ private void advanceBuffer() {
+ this.pointer = 0;
+ this.sequence = NEXT[this.sequence];
+ this.data = this.buffers[this.sequence];
+ }
- public int read() throws IOException {
- int result = data[pointer++];
- if(pointer >= data.length) {
- advanceBuffer();
- }
+ public int read() throws IOException {
+ final int result = this.data[this.pointer++];
+ if ( this.pointer >= this.data.length ) {
+ advanceBuffer();
+ }
- return result;
- }
+ return result;
+ }
- public int available() throws IOException {
- return Integer.MAX_VALUE;
- }
+ public int available() throws IOException {
+ return Integer.MAX_VALUE;
+ }
- public int read(byte[] b, int off, int len) throws IOException {
- int left = len;
- int remaining = data.length - pointer;
+ public int read(final byte[] b,
+ int off,
+ final int len) throws IOException {
+ int left = len;
+ int remaining = this.data.length - this.pointer;
- while(remaining <= left) {
- System.arraycopy(data, pointer, b, off, remaining);
- off += remaining;
- left -= remaining;
- advanceBuffer();
- remaining = data.length - pointer;
- }
- if(left > 0) {
- System.arraycopy(data, pointer, b, off, left);
- pointer += left;
- }
+ while ( remaining <= left ) {
+ System.arraycopy( this.data,
+ this.pointer,
+ b,
+ off,
+ remaining );
+ off += remaining;
+ left -= remaining;
+ advanceBuffer();
+ remaining = this.data.length - this.pointer;
+ }
+ if ( left > 0 ) {
+ System.arraycopy( this.data,
+ this.pointer,
+ b,
+ off,
+ left );
+ this.pointer += left;
+ }
- return len;
- }
- }
+ return len;
+ }
+ }
- private ObjectInputStream inputStream;
+ private ObjectInputStream inputStream;
- public ObjectInputStreamInstantiator(Class clazz) {
- if(Serializable.class.isAssignableFrom(clazz)) {
- try {
- this.inputStream = new ObjectInputStream(new MockStream(clazz));
- }
- catch(IOException e) {
- throw new Error("IOException: " + e.getMessage());
- }
- }
- else {
- throw new ObjenesisException(new NotSerializableException(clazz+" not serializable"));
- }
- }
+ public ObjectInputStreamInstantiator(final Class clazz) {
+ if ( Serializable.class.isAssignableFrom( clazz ) ) {
+ try {
+ this.inputStream = new ObjectInputStream( new MockStream( clazz ) );
+ } catch ( final IOException e ) {
+ throw new Error( "IOException: " + e.getMessage() );
+ }
+ } else {
+ throw new ObjenesisException( new NotSerializableException( clazz + " not serializable" ) );
+ }
+ }
- public Object newInstance() {
- try {
- return inputStream.readObject();
- }
- catch(ClassNotFoundException e) {
- throw new Error("ClassNotFoundException: " + e.getMessage());
- }
- catch(Exception e) {
- throw new ObjenesisException(e);
- }
- }
+ public Object newInstance() {
+ try {
+ return this.inputStream.readObject();
+ } catch ( final ClassNotFoundException e ) {
+ throw new Error( "ClassNotFoundException: " + e.getMessage() );
+ } catch ( final Exception e ) {
+ throw new ObjenesisException( e );
+ }
+ }
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/basic/ObjectStreamClassInstantiator.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/basic/ObjectStreamClassInstantiator.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/basic/ObjectStreamClassInstantiator.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -16,39 +16,40 @@
* @see ObjectInstantiator
* @see java.io.Serializable
*/
-public class ObjectStreamClassInstantiator implements ObjectInstantiator {
+public class ObjectStreamClassInstantiator
+ implements
+ ObjectInstantiator {
- private static Method newInstanceMethod;
+ private static Method newInstanceMethod;
- private static void initialize() {
- if(newInstanceMethod == null) {
- try {
- newInstanceMethod = ObjectStreamClass.class.getDeclaredMethod("newInstance",
- new Class[] {});
- newInstanceMethod.setAccessible(true);
- }
- catch(Exception e) {
- throw new ObjenesisException(e);
- }
- }
- }
+ private static void initialize() {
+ if ( newInstanceMethod == null ) {
+ try {
+ newInstanceMethod = ObjectStreamClass.class.getDeclaredMethod( "newInstance",
+ new Class[]{} );
+ newInstanceMethod.setAccessible( true );
+ } catch ( final Exception e ) {
+ throw new ObjenesisException( e );
+ }
+ }
+ }
- private ObjectStreamClass objStreamClass;
+ private ObjectStreamClass objStreamClass;
- public ObjectStreamClassInstantiator(Class type) {
- initialize();
- objStreamClass = ObjectStreamClass.lookup(type);
- }
+ public ObjectStreamClassInstantiator(final Class type) {
+ initialize();
+ this.objStreamClass = ObjectStreamClass.lookup( type );
+ }
- public Object newInstance() {
-
- try {
- return newInstanceMethod.invoke(objStreamClass, new Object[] {});
- }
- catch(Exception e) {
- throw new ObjenesisException(e);
- }
-
- }
+ public Object newInstance() {
+ try {
+ return newInstanceMethod.invoke( this.objStreamClass,
+ new Object[]{} );
+ } catch ( final Exception e ) {
+ throw new ObjenesisException( e );
+ }
+
+ }
+
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/gcj/GCJInstantiator.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/gcj/GCJInstantiator.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/gcj/GCJInstantiator.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -10,16 +10,16 @@
* @see org.objenesis.instantiator.ObjectInstantiator
*/
public class GCJInstantiator extends GCJInstantiatorBase {
- public GCJInstantiator(Class type) {
- super(type);
- }
+ public GCJInstantiator(final Class type) {
+ super( type );
+ }
- public Object newInstance() {
- try {
- return newObjectMethod.invoke(dummyStream, new Object[] {type, Object.class});
- }
- catch(Exception e) {
- throw new ObjenesisException(e);
- }
- }
+ public Object newInstance() {
+ try {
+ return newObjectMethod.invoke( dummyStream,
+ new Object[]{this.type, Object.class} );
+ } catch ( final Exception e ) {
+ throw new ObjenesisException( e );
+ }
+ }
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/gcj/GCJInstantiatorBase.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/gcj/GCJInstantiatorBase.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/gcj/GCJInstantiatorBase.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -14,36 +14,37 @@
*
* @author Leonardo Mesquita
*/
-public abstract class GCJInstantiatorBase implements ObjectInstantiator {
- protected static Method newObjectMethod = null;
- protected static ObjectInputStream dummyStream;
+public abstract class GCJInstantiatorBase
+ implements
+ ObjectInstantiator {
+ protected static Method newObjectMethod = null;
+ protected static ObjectInputStream dummyStream;
- private static class DummyStream extends ObjectInputStream {
- public DummyStream() throws IOException {
- super();
- }
- }
+ private static class DummyStream extends ObjectInputStream {
+ public DummyStream() throws IOException {
+ super();
+ }
+ }
- private static void initialize() {
- if(newObjectMethod == null) {
- try {
- newObjectMethod = ObjectInputStream.class.getDeclaredMethod("newObject", new Class[] {
- Class.class, Class.class});
- newObjectMethod.setAccessible(true);
- dummyStream = new DummyStream();
- }
- catch(Exception e) {
- throw new ObjenesisException(e);
- }
- }
- }
+ private static void initialize() {
+ if ( newObjectMethod == null ) {
+ try {
+ newObjectMethod = ObjectInputStream.class.getDeclaredMethod( "newObject",
+ new Class[]{Class.class, Class.class} );
+ newObjectMethod.setAccessible( true );
+ dummyStream = new DummyStream();
+ } catch ( final Exception e ) {
+ throw new ObjenesisException( e );
+ }
+ }
+ }
- protected final Class type;
+ protected final Class type;
- public GCJInstantiatorBase(Class type) {
- this.type = type;
- initialize();
- }
+ public GCJInstantiatorBase(final Class type) {
+ this.type = type;
+ initialize();
+ }
- public abstract Object newInstance();
+ public abstract Object newInstance();
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/gcj/GCJSerializationInstantiator.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/gcj/GCJSerializationInstantiator.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/gcj/GCJSerializationInstantiator.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -12,20 +12,20 @@
* @see org.objenesis.instantiator.ObjectInstantiator
*/
public class GCJSerializationInstantiator extends GCJInstantiatorBase {
- private Class superType;
+ private Class superType;
- public GCJSerializationInstantiator(Class type) {
- super(type);
- this.superType = SerializationInstantiatorHelper.getNonSerializableSuperClass(type);
- }
+ public GCJSerializationInstantiator(final Class type) {
+ super( type );
+ this.superType = SerializationInstantiatorHelper.getNonSerializableSuperClass( type );
+ }
- public Object newInstance() {
- try {
- return newObjectMethod.invoke(dummyStream, new Object[] {type, superType});
- }
- catch(Exception e) {
- throw new ObjenesisException(e);
- }
- }
+ public Object newInstance() {
+ try {
+ return newObjectMethod.invoke( dummyStream,
+ new Object[]{this.type, this.superType} );
+ } catch ( final Exception e ) {
+ throw new ObjenesisException( e );
+ }
+ }
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/jrockit/JRockit131Instantiator.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/jrockit/JRockit131Instantiator.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/jrockit/JRockit131Instantiator.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -26,58 +26,56 @@
* @author Leonardo Mesquita
* @see org.objenesis.instantiator.ObjectInstantiator
*/
-public class JRockit131Instantiator implements ObjectInstantiator {
+public class JRockit131Instantiator
+ implements
+ ObjectInstantiator {
- private Constructor mungedConstructor;
+ private Constructor mungedConstructor;
- private static Method newConstructorForSerializationMethod;
+ private static Method newConstructorForSerializationMethod;
- private static void initialize() {
- if(newConstructorForSerializationMethod == null) {
- Class cl;
- try {
- cl = Class.forName("COM.jrockit.reflect.MemberAccess");
- newConstructorForSerializationMethod = cl.getDeclaredMethod(
- "newConstructorForSerialization", new Class[] {Constructor.class, Class.class});
- newConstructorForSerializationMethod.setAccessible(true);
- }
- catch(Exception e) {
- throw new ObjenesisException(e);
- }
- }
- }
+ private static void initialize() {
+ if ( newConstructorForSerializationMethod == null ) {
+ Class cl;
+ try {
+ cl = Class.forName( "COM.jrockit.reflect.MemberAccess" );
+ newConstructorForSerializationMethod = cl.getDeclaredMethod( "newConstructorForSerialization",
+ new Class[]{Constructor.class, Class.class} );
+ newConstructorForSerializationMethod.setAccessible( true );
+ } catch ( final Exception e ) {
+ throw new ObjenesisException( e );
+ }
+ }
+ }
- public JRockit131Instantiator(Class type) {
- initialize();
+ public JRockit131Instantiator(final Class type) {
+ initialize();
- if(newConstructorForSerializationMethod != null) {
+ if ( newConstructorForSerializationMethod != null ) {
- Constructor javaLangObjectConstructor;
+ Constructor javaLangObjectConstructor;
- try {
- javaLangObjectConstructor = Object.class.getConstructor((Class[]) null);
- }
- catch(NoSuchMethodException e) {
- throw new Error("Cannot find constructor for java.lang.Object!");
- }
+ try {
+ javaLangObjectConstructor = Object.class.getConstructor( (Class[]) null );
+ } catch ( final NoSuchMethodException e ) {
+ throw new Error( "Cannot find constructor for java.lang.Object!" );
+ }
- try {
- mungedConstructor = (Constructor) newConstructorForSerializationMethod.invoke(null,
- new Object[] {javaLangObjectConstructor, type});
- }
- catch(Exception e) {
- throw new ObjenesisException(e);
- }
- }
+ try {
+ this.mungedConstructor = (Constructor) newConstructorForSerializationMethod.invoke( null,
+ new Object[]{javaLangObjectConstructor, type} );
+ } catch ( final Exception e ) {
+ throw new ObjenesisException( e );
+ }
+ }
- }
+ }
- public Object newInstance() {
- try {
- return mungedConstructor.newInstance((Object[]) null);
- }
- catch(Exception e) {
- throw new ObjenesisException(e);
- }
- }
+ public Object newInstance() {
+ try {
+ return this.mungedConstructor.newInstance( (Object[]) null );
+ } catch ( final Exception e ) {
+ throw new ObjenesisException( e );
+ }
+ }
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/jrockit/JRockitLegacyInstantiator.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/jrockit/JRockitLegacyInstantiator.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/jrockit/JRockitLegacyInstantiator.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -28,37 +28,38 @@
* @see org.objenesis.instantiator.ObjectInstantiator
* @see org.objenesis.instantiator.sun.SunReflectionFactoryInstantiator
*/
-public class JRockitLegacyInstantiator implements ObjectInstantiator {
- private static Method safeAllocObjectMethod = null;
+public class JRockitLegacyInstantiator
+ implements
+ ObjectInstantiator {
+ private static Method safeAllocObjectMethod = null;
- private static void initialize() {
- if(safeAllocObjectMethod == null) {
- Class memSystem;
- try {
- memSystem = Class.forName("jrockit.vm.MemSystem");
- safeAllocObjectMethod = memSystem.getDeclaredMethod("safeAllocObject",
- new Class[] {Class.class});
- safeAllocObjectMethod.setAccessible(true);
- }
- catch(Exception e) {
- throw new ObjenesisException(e);
- }
- }
- }
+ private static void initialize() {
+ if ( safeAllocObjectMethod == null ) {
+ Class memSystem;
+ try {
+ memSystem = Class.forName( "jrockit.vm.MemSystem" );
+ safeAllocObjectMethod = memSystem.getDeclaredMethod( "safeAllocObject",
+ new Class[]{Class.class} );
+ safeAllocObjectMethod.setAccessible( true );
+ } catch ( final Exception e ) {
+ throw new ObjenesisException( e );
+ }
+ }
+ }
- private Class type;
+ private Class type;
- public JRockitLegacyInstantiator(Class type) {
- initialize();
- this.type = type;
- }
+ public JRockitLegacyInstantiator(final Class type) {
+ initialize();
+ this.type = type;
+ }
- public Object newInstance() {
- try {
- return safeAllocObjectMethod.invoke(null, new Object[] {type});
- }
- catch(Exception e) {
- throw new ObjenesisException(e);
- }
- }
+ public Object newInstance() {
+ try {
+ return safeAllocObjectMethod.invoke( null,
+ new Object[]{this.type} );
+ } catch ( final Exception e ) {
+ throw new ObjenesisException( e );
+ }
+ }
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/sun/Sun13Instantiator.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/sun/Sun13Instantiator.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/sun/Sun13Instantiator.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -10,17 +10,17 @@
* @see org.objenesis.instantiator.ObjectInstantiator
*/
public class Sun13Instantiator extends Sun13InstantiatorBase {
- public Sun13Instantiator(Class type) {
- super(type);
- }
+ public Sun13Instantiator(final Class type) {
+ super( type );
+ }
- public Object newInstance() {
- try {
- return allocateNewObjectMethod.invoke(null, new Object[] {type, Object.class});
- }
- catch(Exception e) {
- throw new ObjenesisException(e);
- }
- }
+ public Object newInstance() {
+ try {
+ return allocateNewObjectMethod.invoke( null,
+ new Object[]{this.type, Object.class} );
+ } catch ( final Exception e ) {
+ throw new ObjenesisException( e );
+ }
+ }
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/sun/Sun13InstantiatorBase.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/sun/Sun13InstantiatorBase.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/sun/Sun13InstantiatorBase.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -12,29 +12,30 @@
*
* @author Leonardo Mesquita
*/
-public abstract class Sun13InstantiatorBase implements ObjectInstantiator {
- protected static Method allocateNewObjectMethod = null;
+public abstract class Sun13InstantiatorBase
+ implements
+ ObjectInstantiator {
+ protected static Method allocateNewObjectMethod = null;
- private static void initialize() {
- if(allocateNewObjectMethod == null) {
- try {
- allocateNewObjectMethod = ObjectInputStream.class.getDeclaredMethod(
- "allocateNewObject", new Class[] {Class.class, Class.class});
- allocateNewObjectMethod.setAccessible(true);
- }
- catch(Exception e) {
- throw new ObjenesisException(e);
- }
- }
- }
+ private static void initialize() {
+ if ( allocateNewObjectMethod == null ) {
+ try {
+ allocateNewObjectMethod = ObjectInputStream.class.getDeclaredMethod( "allocateNewObject",
+ new Class[]{Class.class, Class.class} );
+ allocateNewObjectMethod.setAccessible( true );
+ } catch ( final Exception e ) {
+ throw new ObjenesisException( e );
+ }
+ }
+ }
- protected final Class type;
+ protected final Class type;
- public Sun13InstantiatorBase(Class type) {
- this.type = type;
- initialize();
- }
+ public Sun13InstantiatorBase(final Class type) {
+ this.type = type;
+ initialize();
+ }
- public abstract Object newInstance();
+ public abstract Object newInstance();
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/sun/Sun13SerializationInstantiator.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/sun/Sun13SerializationInstantiator.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/sun/Sun13SerializationInstantiator.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -12,20 +12,20 @@
* @see org.objenesis.instantiator.ObjectInstantiator
*/
public class Sun13SerializationInstantiator extends Sun13InstantiatorBase {
- private final Class superType;
+ private final Class superType;
- public Sun13SerializationInstantiator(Class type) {
- super(type);
- this.superType = SerializationInstantiatorHelper.getNonSerializableSuperClass(type);
- }
+ public Sun13SerializationInstantiator(final Class type) {
+ super( type );
+ this.superType = SerializationInstantiatorHelper.getNonSerializableSuperClass( type );
+ }
- public Object newInstance() {
- try {
- return allocateNewObjectMethod.invoke(null, new Object[] {type, superType});
- }
- catch(Exception e) {
- throw new ObjenesisException(e);
- }
- }
+ public Object newInstance() {
+ try {
+ return allocateNewObjectMethod.invoke( null,
+ new Object[]{this.type, this.superType} );
+ } catch ( final Exception e ) {
+ throw new ObjenesisException( e );
+ }
+ }
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/sun/SunReflectionFactoryInstantiator.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/sun/SunReflectionFactoryInstantiator.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/sun/SunReflectionFactoryInstantiator.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -15,32 +15,32 @@
*
* @see ObjectInstantiator
*/
-public class SunReflectionFactoryInstantiator implements ObjectInstantiator {
+public class SunReflectionFactoryInstantiator
+ implements
+ ObjectInstantiator {
- private final Constructor mungedConstructor;
+ private final Constructor mungedConstructor;
- public SunReflectionFactoryInstantiator(Class type) {
+ public SunReflectionFactoryInstantiator(final Class type) {
- ReflectionFactory reflectionFactory = ReflectionFactory.getReflectionFactory();
- Constructor javaLangObjectConstructor;
+ final ReflectionFactory reflectionFactory = ReflectionFactory.getReflectionFactory();
+ Constructor javaLangObjectConstructor;
- try {
- javaLangObjectConstructor = Object.class.getConstructor((Class[]) null);
- }
- catch(NoSuchMethodException e) {
- throw new Error("Cannot find constructor for java.lang.Object!");
- }
- mungedConstructor = reflectionFactory.newConstructorForSerialization(type,
- javaLangObjectConstructor);
- mungedConstructor.setAccessible(true);
- }
+ try {
+ javaLangObjectConstructor = Object.class.getConstructor( (Class[]) null );
+ } catch ( final NoSuchMethodException e ) {
+ throw new Error( "Cannot find constructor for java.lang.Object!" );
+ }
+ this.mungedConstructor = reflectionFactory.newConstructorForSerialization( type,
+ javaLangObjectConstructor );
+ this.mungedConstructor.setAccessible( true );
+ }
- public Object newInstance() {
- try {
- return mungedConstructor.newInstance((Object[]) null);
- }
- catch(Exception e) {
- throw new ObjenesisException(e);
- }
- }
+ public Object newInstance() {
+ try {
+ return this.mungedConstructor.newInstance( (Object[]) null );
+ } catch ( final Exception e ) {
+ throw new ObjenesisException( e );
+ }
+ }
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/sun/SunReflectionFactorySerializationInstantiator.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/sun/SunReflectionFactorySerializationInstantiator.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/instantiator/sun/SunReflectionFactorySerializationInstantiator.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -18,40 +18,39 @@
*
* @see ObjectInstantiator
*/
-public class SunReflectionFactorySerializationInstantiator implements ObjectInstantiator {
+public class SunReflectionFactorySerializationInstantiator
+ implements
+ ObjectInstantiator {
- private final Constructor mungedConstructor;
+ private final Constructor mungedConstructor;
- public SunReflectionFactorySerializationInstantiator(Class type) {
-
- Class nonSerializableAncestor = SerializationInstantiatorHelper.getNonSerializableSuperClass(type);
- ReflectionFactory reflectionFactory = ReflectionFactory.getReflectionFactory();
- Constructor nonSerializableAncestorConstructor;
- try {
- nonSerializableAncestorConstructor = nonSerializableAncestor
- .getConstructor((Class[]) null);
- }
- catch(NoSuchMethodException e) {
- /**
- * @todo (Henri) I think we should throw a NotSerializableException just to put the same
- * message a ObjectInputStream. Otherwise, the user won't know if the null returned
- * if a "Not serializable", a "No default constructor on ancestor" or a "Exception in
- * constructor"
- */
- throw new ObjenesisException(new NotSerializableException(type+" has no suitable superclass constructor"));
- }
+ public SunReflectionFactorySerializationInstantiator(final Class type) {
- mungedConstructor = reflectionFactory.newConstructorForSerialization(type,
- nonSerializableAncestorConstructor);
- mungedConstructor.setAccessible(true);
- }
+ final Class nonSerializableAncestor = SerializationInstantiatorHelper.getNonSerializableSuperClass( type );
+ final ReflectionFactory reflectionFactory = ReflectionFactory.getReflectionFactory();
+ Constructor nonSerializableAncestorConstructor;
+ try {
+ nonSerializableAncestorConstructor = nonSerializableAncestor.getConstructor( (Class[]) null );
+ } catch ( final NoSuchMethodException e ) {
+ /**
+ * @todo (Henri) I think we should throw a NotSerializableException just to put the same
+ * message a ObjectInputStream. Otherwise, the user won't know if the null returned
+ * if a "Not serializable", a "No default constructor on ancestor" or a "Exception in
+ * constructor"
+ */
+ throw new ObjenesisException( new NotSerializableException( type + " has no suitable superclass constructor" ) );
+ }
- public Object newInstance() {
- try {
- return mungedConstructor.newInstance((Object[]) null);
- }
- catch(Exception e) {
- throw new ObjenesisException(e);
- }
- }
+ this.mungedConstructor = reflectionFactory.newConstructorForSerialization( type,
+ nonSerializableAncestorConstructor );
+ this.mungedConstructor.setAccessible( true );
+ }
+
+ public Object newInstance() {
+ try {
+ return this.mungedConstructor.newInstance( (Object[]) null );
+ } catch ( final Exception e ) {
+ throw new ObjenesisException( e );
+ }
+ }
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/strategy/BaseInstantiatorStrategy.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/strategy/BaseInstantiatorStrategy.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/strategy/BaseInstantiatorStrategy.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -5,29 +5,31 @@
*
* @author Henri Tremblay
*/
-public abstract class BaseInstantiatorStrategy implements InstantiatorStrategy {
+public abstract class BaseInstantiatorStrategy
+ implements
+ InstantiatorStrategy {
- /** JVM_NAME prefix for JRockit */
- protected static final String JROCKIT = "BEA";
+ /** JVM_NAME prefix for JRockit */
+ protected static final String JROCKIT = "BEA";
- /** JVM_NAME prefix for GCJ */
- protected static final String GNU = "GNU libgcj";
+ /** JVM_NAME prefix for GCJ */
+ protected static final String GNU = "GNU libgcj";
- /** JVM_NAME prefix for Sun Java HotSpot */
- protected static final String SUN = "Java HotSpot";
+ /** JVM_NAME prefix for Sun Java HotSpot */
+ protected static final String SUN = "Java HotSpot";
- /** JVM version */
- protected static final String VM_VERSION = System.getProperty("java.runtime.version");
+ /** JVM version */
+ protected static final String VM_VERSION = System.getProperty( "java.runtime.version" );
- /** JVM version */
- protected static final String VM_INFO = System.getProperty("java.vm.info");
+ /** JVM version */
+ protected static final String VM_INFO = System.getProperty( "java.vm.info" );
- /** Vendor version */
- protected static final String VENDOR_VERSION = System.getProperty("java.vm.version");
+ /** Vendor version */
+ protected static final String VENDOR_VERSION = System.getProperty( "java.vm.version" );
- /** Vendor name */
- protected static final String VENDOR = System.getProperty("java.vm.vendor");
+ /** Vendor name */
+ protected static final String VENDOR = System.getProperty( "java.vm.vendor" );
- /** JVM name */
- protected static final String JVM_NAME = System.getProperty("java.vm.name");
+ /** JVM name */
+ protected static final String JVM_NAME = System.getProperty( "java.vm.name" );
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/strategy/InstantiatorStrategy.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/strategy/InstantiatorStrategy.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/strategy/InstantiatorStrategy.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -7,11 +7,11 @@
*/
public interface InstantiatorStrategy {
- /**
- * Create a dedicated instantiator for the given class
- *
- * @param type Class that will be instantiate
- * @return Dedicated instantiator
- */
- ObjectInstantiator newInstantiatorOf(Class type);
+ /**
+ * Create a dedicated instantiator for the given class
+ *
+ * @param type Class that will be instantiate
+ * @return Dedicated instantiator
+ */
+ ObjectInstantiator newInstantiatorOf(Class type);
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/strategy/SerializingInstantiatorStrategy.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/strategy/SerializingInstantiatorStrategy.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/strategy/SerializingInstantiatorStrategy.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -25,26 +25,25 @@
*/
public class SerializingInstantiatorStrategy extends BaseInstantiatorStrategy {
- /**
- * Return an {@link ObjectInstantiator} allowing to create instance following the java
- * serialization framework specifications.
- *
- * @param type Class to instantiate
- * @return The ObjectInstantiator for the class
- */
- public ObjectInstantiator newInstantiatorOf(Class type) {
- if(!Serializable.class.isAssignableFrom(type)) {
- throw new ObjenesisException(new NotSerializableException(type+" not serializable"));
- }
- if(JVM_NAME.startsWith(SUN)) {
- if(VM_VERSION.startsWith("1.3")) {
- return new Sun13SerializationInstantiator(type);
- }
- }
- else if(JVM_NAME.startsWith(GNU)) {
- return new GCJSerializationInstantiator(type);
- }
- return new ObjectStreamClassInstantiator(type);
- }
+ /**
+ * Return an {@link ObjectInstantiator} allowing to create instance following the java
+ * serialization framework specifications.
+ *
+ * @param type Class to instantiate
+ * @return The ObjectInstantiator for the class
+ */
+ public ObjectInstantiator newInstantiatorOf(final Class type) {
+ if ( !Serializable.class.isAssignableFrom( type ) ) {
+ throw new ObjenesisException( new NotSerializableException( type + " not serializable" ) );
+ }
+ if ( JVM_NAME.startsWith( SUN ) ) {
+ if ( VM_VERSION.startsWith( "1.3" ) ) {
+ return new Sun13SerializationInstantiator( type );
+ }
+ } else if ( JVM_NAME.startsWith( GNU ) ) {
+ return new GCJSerializationInstantiator( type );
+ }
+ return new ObjectStreamClassInstantiator( type );
+ }
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/strategy/StdInstantiatorStrategy.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/strategy/StdInstantiatorStrategy.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/objenesis/strategy/StdInstantiatorStrategy.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -22,46 +22,43 @@
*/
public class StdInstantiatorStrategy extends BaseInstantiatorStrategy {
- /**
- * Return an {@link ObjectInstantiator} allowing to create instance without any constructor being
- * called.
- *
- * @param type Class to instantiate
- * @return The ObjectInstantiator for the class
- */
- public ObjectInstantiator newInstantiatorOf(Class type) {
+ /**
+ * Return an {@link ObjectInstantiator} allowing to create instance without any constructor being
+ * called.
+ *
+ * @param type Class to instantiate
+ * @return The ObjectInstantiator for the class
+ */
+ public ObjectInstantiator newInstantiatorOf(final Class type) {
- if(JVM_NAME.startsWith(SUN)) {
- if(VM_VERSION.startsWith("1.3")) {
- return new Sun13Instantiator(type);
- }
- }
- else if(JVM_NAME.startsWith(JROCKIT)) {
- if(VM_VERSION.startsWith("1.3")) {
- return new JRockit131Instantiator(type);
- }
- else if(VM_VERSION.startsWith("1.4")) {
- // JRockit vendor version will be RXX where XX is the version
- // Versions prior to 26 need special handling
- // From R26 on, java.vm.version starts with R
- if(!VENDOR_VERSION.startsWith("R")) {
- // On R25.1 and R25.2, ReflectionFactory should work. Otherwise, we must use the
- // Legacy instantiator.
- if(VM_INFO == null || !VM_INFO.startsWith("R25.1") || !VM_INFO.startsWith("R25.2")) {
- return new JRockitLegacyInstantiator(type);
- }
+ if ( JVM_NAME.startsWith( SUN ) ) {
+ if ( VM_VERSION.startsWith( "1.3" ) ) {
+ return new Sun13Instantiator( type );
}
- }
- }
- else if(JVM_NAME.startsWith(GNU)) {
- return new GCJInstantiator(type);
- }
+ } else if ( JVM_NAME.startsWith( JROCKIT ) ) {
+ if ( VM_VERSION.startsWith( "1.3" ) ) {
+ return new JRockit131Instantiator( type );
+ } else if ( VM_VERSION.startsWith( "1.4" ) ) {
+ // JRockit vendor version will be RXX where XX is the version
+ // Versions prior to 26 need special handling
+ // From R26 on, java.vm.version starts with R
+ if ( !VENDOR_VERSION.startsWith( "R" ) ) {
+ // On R25.1 and R25.2, ReflectionFactory should work. Otherwise, we must use the
+ // Legacy instantiator.
+ if ( VM_INFO == null || !VM_INFO.startsWith( "R25.1" ) || !VM_INFO.startsWith( "R25.2" ) ) {
+ return new JRockitLegacyInstantiator( type );
+ }
+ }
+ }
+ } else if ( JVM_NAME.startsWith( GNU ) ) {
+ return new GCJInstantiator( type );
+ }
- // Fallback instantiator, should work with:
- // - Java Hotspot version 1.4 and higher
- // - JRockit 1.4-R26 and higher
- // - IBM and Hitachi JVMs
- // ... might works for others so we just give it a try
- return new SunReflectionFactoryInstantiator(type);
- }
+ // Fallback instantiator, should work with:
+ // - Java Hotspot version 1.4 and higher
+ // - JRockit 1.4-R26 and higher
+ // - IBM and Hitachi JVMs
+ // ... might works for others so we just give it a try
+ return new SunReflectionFactoryInstantiator( type );
+ }
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/codehaus/jfdi/interpreter/ClassTypeResolverTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/codehaus/jfdi/interpreter/ClassTypeResolverTest.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/codehaus/jfdi/interpreter/ClassTypeResolverTest.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -14,101 +14,144 @@
*
*/
public class ClassTypeResolverTest extends TestCase {
-
+
public void testResolvePrimtiveTypes() throws Exception {
- ClassTypeResolver resolver = new ClassTypeResolver();
- assertEquals(boolean.class, resolver.resolveType("boolean"));
- assertEquals(double.class, resolver.resolveType("double"));
- assertEquals(float.class, resolver.resolveType("float"));
- assertEquals(int.class, resolver.resolveType("int"));
- assertEquals(char.class, resolver.resolveType("char"));
- assertEquals(long.class, resolver.resolveType("long"));
- assertEquals(byte.class, resolver.resolveType("byte"));
- assertEquals(short.class, resolver.resolveType("short"));
+ final ClassTypeResolver resolver = new ClassTypeResolver();
+ assertEquals( boolean.class,
+ resolver.resolveType( "boolean" ) );
+ assertEquals( double.class,
+ resolver.resolveType( "double" ) );
+ assertEquals( float.class,
+ resolver.resolveType( "float" ) );
+ assertEquals( int.class,
+ resolver.resolveType( "int" ) );
+ assertEquals( char.class,
+ resolver.resolveType( "char" ) );
+ assertEquals( long.class,
+ resolver.resolveType( "long" ) );
+ assertEquals( byte.class,
+ resolver.resolveType( "byte" ) );
+ assertEquals( short.class,
+ resolver.resolveType( "short" ) );
}
-
+
public void testResolveArrayOfPrimitiveTypes() throws Exception {
- ClassTypeResolver resolver = new ClassTypeResolver();
- assertEquals(boolean[].class, resolver.resolveType("boolean[]"));
- assertEquals(double[].class, resolver.resolveType("double[]"));
- assertEquals(float[].class, resolver.resolveType("float[]"));
- assertEquals(int[].class, resolver.resolveType("int[]"));
- assertEquals(char[].class, resolver.resolveType("char[]"));
- assertEquals(long[].class, resolver.resolveType("long[]"));
- assertEquals(byte[].class, resolver.resolveType("byte[]"));
- assertEquals(short[].class, resolver.resolveType("short[]"));
+ final ClassTypeResolver resolver = new ClassTypeResolver();
+ assertEquals( boolean[].class,
+ resolver.resolveType( "boolean[]" ) );
+ assertEquals( double[].class,
+ resolver.resolveType( "double[]" ) );
+ assertEquals( float[].class,
+ resolver.resolveType( "float[]" ) );
+ assertEquals( int[].class,
+ resolver.resolveType( "int[]" ) );
+ assertEquals( char[].class,
+ resolver.resolveType( "char[]" ) );
+ assertEquals( long[].class,
+ resolver.resolveType( "long[]" ) );
+ assertEquals( byte[].class,
+ resolver.resolveType( "byte[]" ) );
+ assertEquals( short[].class,
+ resolver.resolveType( "short[]" ) );
}
-
+
public void testResolveMultidimensionnalArrayOfPrimitiveTypes() throws Exception {
- ClassTypeResolver resolver = new ClassTypeResolver();
- assertEquals(int[][].class, resolver.resolveType("int[][]"));
- assertEquals(int[][][].class, resolver.resolveType("int[][][]"));
- assertEquals(int[][][][].class, resolver.resolveType("int[][][][]"));
+ final ClassTypeResolver resolver = new ClassTypeResolver();
+ assertEquals( int[][].class,
+ resolver.resolveType( "int[][]" ) );
+ assertEquals( int[][][].class,
+ resolver.resolveType( "int[][][]" ) );
+ assertEquals( int[][][][].class,
+ resolver.resolveType( "int[][][][]" ) );
}
-
+
public void testResolveObjectNotFromImport() throws Exception {
- ClassTypeResolver resolver = new ClassTypeResolver();
- assertEquals(String.class, resolver.resolveType("String"));
- assertEquals(String.class, resolver.resolveType("java.lang.String"));
+ final ClassTypeResolver resolver = new ClassTypeResolver();
+ assertEquals( String.class,
+ resolver.resolveType( "String" ) );
+ assertEquals( String.class,
+ resolver.resolveType( "java.lang.String" ) );
try {
- assertEquals(Cheese.class, resolver.resolveType("Cheese"));
- fail("Should raise a ClassNotFoundException");
- } catch ( ClassNotFoundException e ) {
+ assertEquals( Cheese.class,
+ resolver.resolveType( "Cheese" ) );
+ fail( "Should raise a ClassNotFoundException" );
+ } catch ( final ClassNotFoundException e ) {
// success
}
- assertEquals(Cheese.class, resolver.resolveType("org.drools.Cheese"));
+ assertEquals( Cheese.class,
+ resolver.resolveType( "org.drools.Cheese" ) );
}
-
+
public void testResolveObjectFromImport() throws Exception {
- ClassTypeResolver resolver = new ClassTypeResolver(new ArrayList());
- resolver.addImport("org.drools.Cheese");
- assertEquals(String.class, resolver.resolveType("String"));
- assertEquals(String.class, resolver.resolveType("java.lang.String"));
- assertEquals(Cheese.class, resolver.resolveType("Cheese"));
- assertEquals(Cheese.class, resolver.resolveType("org.drools.Cheese"));
+ final ClassTypeResolver resolver = new ClassTypeResolver( new ArrayList() );
+ resolver.addImport( "org.drools.Cheese" );
+ assertEquals( String.class,
+ resolver.resolveType( "String" ) );
+ assertEquals( String.class,
+ resolver.resolveType( "java.lang.String" ) );
+ assertEquals( Cheese.class,
+ resolver.resolveType( "Cheese" ) );
+ assertEquals( Cheese.class,
+ resolver.resolveType( "org.drools.Cheese" ) );
}
-
+
public void testResolveArrayOfObjectsNotFromImport() throws Exception {
- ClassTypeResolver resolver = new ClassTypeResolver();
- assertEquals(String[].class, resolver.resolveType("String[]"));
- assertEquals(String[].class, resolver.resolveType("java.lang.String[]"));
+ final ClassTypeResolver resolver = new ClassTypeResolver();
+ assertEquals( String[].class,
+ resolver.resolveType( "String[]" ) );
+ assertEquals( String[].class,
+ resolver.resolveType( "java.lang.String[]" ) );
try {
- assertEquals(Cheese[].class, resolver.resolveType("Cheese[]"));
- fail("Should raise a ClassNotFoundException");
- } catch ( ClassNotFoundException e ) {
+ assertEquals( Cheese[].class,
+ resolver.resolveType( "Cheese[]" ) );
+ fail( "Should raise a ClassNotFoundException" );
+ } catch ( final ClassNotFoundException e ) {
// success
}
- assertEquals(Cheese[].class, resolver.resolveType("org.drools.Cheese[]"));
+ assertEquals( Cheese[].class,
+ resolver.resolveType( "org.drools.Cheese[]" ) );
}
-
+
public void testResolveArrayOfObjectsFromImport() throws Exception {
- ClassTypeResolver resolver = new ClassTypeResolver(new ArrayList());
- resolver.addImport("org.drools.Cheese");
- assertEquals(String[].class, resolver.resolveType("String[]"));
- assertEquals(String[].class, resolver.resolveType("java.lang.String[]"));
- assertEquals(Cheese[].class, resolver.resolveType("Cheese[]"));
- assertEquals(Cheese[].class, resolver.resolveType("org.drools.Cheese[]"));
+ final ClassTypeResolver resolver = new ClassTypeResolver( new ArrayList() );
+ resolver.addImport( "org.drools.Cheese" );
+ assertEquals( String[].class,
+ resolver.resolveType( "String[]" ) );
+ assertEquals( String[].class,
+ resolver.resolveType( "java.lang.String[]" ) );
+ assertEquals( Cheese[].class,
+ resolver.resolveType( "Cheese[]" ) );
+ assertEquals( Cheese[].class,
+ resolver.resolveType( "org.drools.Cheese[]" ) );
}
-
+
public void testResolveMultidimensionnalArrayOfObjectsNotFromImport() throws Exception {
- ClassTypeResolver resolver = new ClassTypeResolver();
- assertEquals(String[][].class, resolver.resolveType("String[][]"));
- assertEquals(String[][].class, resolver.resolveType("java.lang.String[][]"));
+ final ClassTypeResolver resolver = new ClassTypeResolver();
+ assertEquals( String[][].class,
+ resolver.resolveType( "String[][]" ) );
+ assertEquals( String[][].class,
+ resolver.resolveType( "java.lang.String[][]" ) );
try {
- assertEquals(Cheese[][].class, resolver.resolveType("Cheese[][]"));
- fail("Should raise a ClassNotFoundException");
- } catch ( ClassNotFoundException e ) {
+ assertEquals( Cheese[][].class,
+ resolver.resolveType( "Cheese[][]" ) );
+ fail( "Should raise a ClassNotFoundException" );
+ } catch ( final ClassNotFoundException e ) {
// success
}
- assertEquals(Cheese[][].class, resolver.resolveType("org.drools.Cheese[][]"));
+ assertEquals( Cheese[][].class,
+ resolver.resolveType( "org.drools.Cheese[][]" ) );
}
-
+
public void testResolveMultidimensionnalArrayOfObjectsFromImport() throws Exception {
- ClassTypeResolver resolver = new ClassTypeResolver(new ArrayList());
- resolver.addImport("org.drools.Cheese");
- assertEquals(String[][].class, resolver.resolveType("String[][]"));
- assertEquals(String[][].class, resolver.resolveType("java.lang.String[][]"));
- assertEquals(Cheese[][].class, resolver.resolveType("Cheese[][]"));
- assertEquals(Cheese[][].class, resolver.resolveType("org.drools.Cheese[][]"));
+ final ClassTypeResolver resolver = new ClassTypeResolver( new ArrayList() );
+ resolver.addImport( "org.drools.Cheese" );
+ assertEquals( String[][].class,
+ resolver.resolveType( "String[][]" ) );
+ assertEquals( String[][].class,
+ resolver.resolveType( "java.lang.String[][]" ) );
+ assertEquals( Cheese[][].class,
+ resolver.resolveType( "Cheese[][]" ) );
+ assertEquals( Cheese[][].class,
+ resolver.resolveType( "org.drools.Cheese[][]" ) );
}
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/Cheese.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -23,18 +23,17 @@
public class Cheese
implements
CheeseInterface {
-
+
public static String staticString;
-
+
static {
staticString = "Cheese is tasty";
}
-
-
- private String type;
-
- private int price;
+ private String type;
+
+ private int price;
+
public Cheese() {
}
@@ -43,7 +42,7 @@
this.type = type;
this.price = price;
}
-
+
public static String getStaticString() {
return staticString;
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/Person.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/Person.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/Person.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,11 +1,12 @@
package org.drools;
public class Person {
-
+
private String name;
- private int age;
-
- public Person( String name, int age ) {
+ private int age;
+
+ public Person(final String name,
+ final int age) {
this.name = name;
this.age = age;
}
@@ -14,13 +15,13 @@
* @return the age
*/
public int getAge() {
- return age;
+ return this.age;
}
/**
* @param age the age to set
*/
- public void setAge(int age) {
+ public void setAge(final int age) {
this.age = age;
}
@@ -28,15 +29,14 @@
* @return the name
*/
public String getName() {
- return name;
+ return this.name;
}
/**
* @param name the name to set
*/
- public void setName(String name) {
+ public void setName(final String name) {
this.name = name;
}
-
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/RuleBaseFactoryTest.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -30,7 +30,8 @@
assertTrue( !"".equals( ((InternalRuleBase) rb).getId() ) );
assertNotNull( ((InternalRuleBase) rb).getId() );
- final RuleBase rb2 = RuleBaseFactory.newRuleBase( RuleBase.RETEOO, null );
+ final RuleBase rb2 = RuleBaseFactory.newRuleBase( RuleBase.RETEOO,
+ null );
assertTrue( rb2 instanceof org.drools.reteoo.ReteooRuleBase );
assertNotSame( rb2,
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/BaseClassFieldExtractorFactoryTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/BaseClassFieldExtractorFactoryTest.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/BaseClassFieldExtractorFactoryTest.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -39,7 +39,7 @@
assertEquals( 1,
ex.getIndex() );
assertEquals( 42,
- ((Number)ex.getValue( new TestBean() )).intValue() );
+ ((Number) ex.getValue( new TestBean() )).intValue() );
}
@@ -71,7 +71,7 @@
public void testSelfReference() throws Exception {
final FieldExtractor ex = ClassFieldExtractorFactory.getClassFieldExtractor( BeanInherit.class,
"this" );
- TestBean bean = new TestBean();
+ final TestBean bean = new TestBean();
assertEquals( bean,
ex.getValue( bean ) );
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/DelegateJavaFactHandlerTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/DelegateJavaFactHandlerTest.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/DelegateJavaFactHandlerTest.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -8,117 +8,133 @@
import org.drools.WorkingMemory;
public class DelegateJavaFactHandlerTest extends TestCase {
-
+
public void test1Entry() throws Exception {
- DelegateJavaFactHandler handler = new DelegateJavaFactHandler();
-
- Field field = handler.getClass().getDeclaredField( "entries" );
+ final DelegateJavaFactHandler handler = new DelegateJavaFactHandler();
+
+ final Field field = handler.getClass().getDeclaredField( "entries" );
field.setAccessible( true );
-
- WorkingMemory wm1 = RuleBaseFactory.newRuleBase().newWorkingMemory();
+
+ final WorkingMemory wm1 = RuleBaseFactory.newRuleBase().newWorkingMemory();
handler.register( wm1 );
-
- JavaFactRegistryEntry[] entries = ( JavaFactRegistryEntry[] ) field.get( handler );
- assertEquals( 1, entries.length );
-
- assertTrue( handler.isRegistered( wm1 ));
-
- assertEquals(1, handler.listWorkingMemories().length );
- assertSame( wm1, handler.listWorkingMemories()[0].getWorkingMemory() );
-
- WorkingMemory wm2 = RuleBaseFactory.newRuleBase().newWorkingMemory();
- assertFalse( handler.isRegistered( wm2 ));
-
+
+ JavaFactRegistryEntry[] entries = (JavaFactRegistryEntry[]) field.get( handler );
+ assertEquals( 1,
+ entries.length );
+
+ assertTrue( handler.isRegistered( wm1 ) );
+
+ assertEquals( 1,
+ handler.listWorkingMemories().length );
+ assertSame( wm1,
+ handler.listWorkingMemories()[0].getWorkingMemory() );
+
+ final WorkingMemory wm2 = RuleBaseFactory.newRuleBase().newWorkingMemory();
+ assertFalse( handler.isRegistered( wm2 ) );
+
handler.unregister( wm1 );
- assertFalse( handler.isRegistered( wm1 ));
- entries = ( JavaFactRegistryEntry[] ) field.get( handler );
- assertNull( entries );
+ assertFalse( handler.isRegistered( wm1 ) );
+ entries = (JavaFactRegistryEntry[]) field.get( handler );
+ assertNull( entries );
}
-
+
public void test2Entries() throws Exception {
- DelegateJavaFactHandler handler = new DelegateJavaFactHandler();
-
- Field field = handler.getClass().getDeclaredField( "entries" );
+ final DelegateJavaFactHandler handler = new DelegateJavaFactHandler();
+
+ final Field field = handler.getClass().getDeclaredField( "entries" );
field.setAccessible( true );
-
- WorkingMemory wm1 = RuleBaseFactory.newRuleBase().newWorkingMemory();
- WorkingMemory wm2 = RuleBaseFactory.newRuleBase().newWorkingMemory();
+
+ final WorkingMemory wm1 = RuleBaseFactory.newRuleBase().newWorkingMemory();
+ final WorkingMemory wm2 = RuleBaseFactory.newRuleBase().newWorkingMemory();
handler.register( wm1 );
handler.register( wm2 );
-
- JavaFactRegistryEntry[] entries = ( JavaFactRegistryEntry[] ) field.get( handler );
- assertEquals( 2, entries.length );
-
- assertTrue( handler.isRegistered( wm1 ));
- assertTrue( handler.isRegistered( wm2 ));
-
- assertEquals(2, handler.listWorkingMemories().length );
- assertSame( wm1, handler.listWorkingMemories()[0].getWorkingMemory() );
- assertSame( wm2, handler.listWorkingMemories()[1].getWorkingMemory() );
-
+
+ JavaFactRegistryEntry[] entries = (JavaFactRegistryEntry[]) field.get( handler );
+ assertEquals( 2,
+ entries.length );
+
+ assertTrue( handler.isRegistered( wm1 ) );
+ assertTrue( handler.isRegistered( wm2 ) );
+
+ assertEquals( 2,
+ handler.listWorkingMemories().length );
+ assertSame( wm1,
+ handler.listWorkingMemories()[0].getWorkingMemory() );
+ assertSame( wm2,
+ handler.listWorkingMemories()[1].getWorkingMemory() );
+
handler.unregister( wm1 );
- assertFalse( handler.isRegistered( wm1 ));
- entries = ( JavaFactRegistryEntry[] ) field.get( handler );
- assertEquals( 1, entries.length );
-
+ assertFalse( handler.isRegistered( wm1 ) );
+ entries = (JavaFactRegistryEntry[]) field.get( handler );
+ assertEquals( 1,
+ entries.length );
+
handler.unregister( wm2 );
- assertFalse( handler.isRegistered( wm2 ));
- entries = ( JavaFactRegistryEntry[] ) field.get( handler );
- assertNull( entries );
-
+ assertFalse( handler.isRegistered( wm2 ) );
+ entries = (JavaFactRegistryEntry[]) field.get( handler );
+ assertNull( entries );
+
// check revererse
handler.register( wm1 );
- handler.register( wm2 );
-
+ handler.register( wm2 );
+
handler.unregister( wm2 );
- assertFalse( handler.isRegistered( wm2 ));
- entries = ( JavaFactRegistryEntry[] ) field.get( handler );
- assertEquals( 1, entries.length );
-
+ assertFalse( handler.isRegistered( wm2 ) );
+ entries = (JavaFactRegistryEntry[]) field.get( handler );
+ assertEquals( 1,
+ entries.length );
+
handler.unregister( wm1 );
- assertFalse( handler.isRegistered( wm1 ));
- entries = ( JavaFactRegistryEntry[] ) field.get( handler );
- assertNull( entries );
- }
-
+ assertFalse( handler.isRegistered( wm1 ) );
+ entries = (JavaFactRegistryEntry[]) field.get( handler );
+ assertNull( entries );
+ }
+
public void test3Entries() throws Exception {
- DelegateJavaFactHandler handler = new DelegateJavaFactHandler();
-
- Field field = handler.getClass().getDeclaredField( "entries" );
+ final DelegateJavaFactHandler handler = new DelegateJavaFactHandler();
+
+ final Field field = handler.getClass().getDeclaredField( "entries" );
field.setAccessible( true );
-
- WorkingMemory wm1 = RuleBaseFactory.newRuleBase().newWorkingMemory();
- WorkingMemory wm2 = RuleBaseFactory.newRuleBase().newWorkingMemory();
- WorkingMemory wm3 = RuleBaseFactory.newRuleBase().newWorkingMemory();
+
+ final WorkingMemory wm1 = RuleBaseFactory.newRuleBase().newWorkingMemory();
+ final WorkingMemory wm2 = RuleBaseFactory.newRuleBase().newWorkingMemory();
+ final WorkingMemory wm3 = RuleBaseFactory.newRuleBase().newWorkingMemory();
handler.register( wm1 );
handler.register( wm2 );
handler.register( wm3 );
-
- JavaFactRegistryEntry[] entries = ( JavaFactRegistryEntry[] ) field.get( handler );
- assertEquals( 3, entries.length );
-
- assertTrue( handler.isRegistered( wm1 ));
- assertTrue( handler.isRegistered( wm2 ));
- assertTrue( handler.isRegistered( wm3 ));
-
- assertEquals(3, handler.listWorkingMemories().length );
- assertSame( wm1, handler.listWorkingMemories()[0].getWorkingMemory() );
- assertSame( wm2, handler.listWorkingMemories()[1].getWorkingMemory() );
- assertSame( wm3, handler.listWorkingMemories()[2].getWorkingMemory() );
-
+
+ JavaFactRegistryEntry[] entries = (JavaFactRegistryEntry[]) field.get( handler );
+ assertEquals( 3,
+ entries.length );
+
+ assertTrue( handler.isRegistered( wm1 ) );
+ assertTrue( handler.isRegistered( wm2 ) );
+ assertTrue( handler.isRegistered( wm3 ) );
+
+ assertEquals( 3,
+ handler.listWorkingMemories().length );
+ assertSame( wm1,
+ handler.listWorkingMemories()[0].getWorkingMemory() );
+ assertSame( wm2,
+ handler.listWorkingMemories()[1].getWorkingMemory() );
+ assertSame( wm3,
+ handler.listWorkingMemories()[2].getWorkingMemory() );
+
handler.unregister( wm2 );
- assertFalse( handler.isRegistered( wm2 ));
- entries = ( JavaFactRegistryEntry[] ) field.get( handler );
- assertEquals( 2, entries.length );
-
+ assertFalse( handler.isRegistered( wm2 ) );
+ entries = (JavaFactRegistryEntry[]) field.get( handler );
+ assertEquals( 2,
+ entries.length );
+
handler.unregister( wm1 );
- assertFalse( handler.isRegistered( wm1 ));
- entries = ( JavaFactRegistryEntry[] ) field.get( handler );
- assertEquals( 1, entries.length );
-
+ assertFalse( handler.isRegistered( wm1 ) );
+ entries = (JavaFactRegistryEntry[]) field.get( handler );
+ assertEquals( 1,
+ entries.length );
+
handler.unregister( wm3 );
- assertFalse( handler.isRegistered( wm3 ));
- entries = ( JavaFactRegistryEntry[] ) field.get( handler );
- assertNull( entries );
- }
+ assertFalse( handler.isRegistered( wm3 ) );
+ entries = (JavaFactRegistryEntry[]) field.get( handler );
+ assertNull( entries );
+ }
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/EvaluatorFactoryTest.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -213,7 +213,7 @@
*/
private void runEvaluatorTest(final Object[][] data,
final ValueType valueType) {
- Extractor extractor = new MockExtractor();
+ final Extractor extractor = new MockExtractor();
for ( int i = 0; i < data.length; i++ ) {
final Object[] row = data[i];
final Evaluator evaluator = valueType.getEvaluator( Operator.determineOperator( (String) row[1] ) );
@@ -247,10 +247,10 @@
* @param evaluator
*/
private void checkEvaluatorMethodWithFieldValue(final ValueType valueType,
- Extractor extractor,
+ final Extractor extractor,
final Object[] row,
final Evaluator evaluator) {
- FieldValue value = FieldFactory.getFieldValue( row[2],
+ final FieldValue value = FieldFactory.getFieldValue( row[2],
valueType );
final boolean result = evaluator.evaluate( extractor,
row[0],
@@ -273,10 +273,10 @@
* @param evaluator
*/
private void checkEvaluatorMethodCachedRight(final ValueType valueType,
- Extractor extractor,
+ final Extractor extractor,
final Object[] row,
final Evaluator evaluator) {
- VariableContextEntry context = this.getContextEntry( (FieldExtractor) extractor,
+ final VariableContextEntry context = this.getContextEntry( (FieldExtractor) extractor,
valueType,
row );
final boolean result = evaluator.evaluateCachedRight( context,
@@ -299,10 +299,10 @@
* @param evaluator
*/
private void checkEvaluatorMethodCachedLeft(final ValueType valueType,
- Extractor extractor,
+ final Extractor extractor,
final Object[] row,
final Evaluator evaluator) {
- VariableContextEntry context = this.getContextEntry( (FieldExtractor) extractor,
+ final VariableContextEntry context = this.getContextEntry( (FieldExtractor) extractor,
valueType,
row );
final boolean result = evaluator.evaluateCachedLeft( context,
@@ -325,7 +325,7 @@
* @param evaluator
*/
private void checkEvaluatorMethodWith2Extractors(final ValueType valueType,
- Extractor extractor,
+ final Extractor extractor,
final Object[] row,
final Evaluator evaluator) {
final boolean result = evaluator.evaluate( extractor,
@@ -343,14 +343,14 @@
}
}
- private VariableContextEntry getContextEntry(FieldExtractor extractor,
- ValueType valueType,
- Object[] row) {
- Declaration declaration = new Declaration( "test",
+ private VariableContextEntry getContextEntry(final FieldExtractor extractor,
+ final ValueType valueType,
+ final Object[] row) {
+ final Declaration declaration = new Declaration( "test",
extractor,
null );
if ( valueType.isIntegerNumber() || valueType.isChar() ) {
- LongVariableContextEntry context = new LongVariableContextEntry( extractor,
+ final LongVariableContextEntry context = new LongVariableContextEntry( extractor,
declaration );
if ( row[2] instanceof Character ) {
context.left = ((Character) row[2]).charValue();
@@ -361,19 +361,19 @@
}
return context;
} else if ( valueType.isBoolean() ) {
- BooleanVariableContextEntry context = new BooleanVariableContextEntry( extractor,
+ final BooleanVariableContextEntry context = new BooleanVariableContextEntry( extractor,
declaration );
context.left = ((Boolean) row[2]).booleanValue();
context.right = ((Boolean) row[0]).booleanValue();
return context;
} else if ( valueType.isFloatNumber() ) {
- DoubleVariableContextEntry context = new DoubleVariableContextEntry( extractor,
+ final DoubleVariableContextEntry context = new DoubleVariableContextEntry( extractor,
declaration );
context.left = ((Number) row[2]).doubleValue();
context.right = ((Number) row[0]).doubleValue();
return context;
} else {
- ObjectVariableContextEntry context = new ObjectVariableContextEntry( extractor,
+ final ObjectVariableContextEntry context = new ObjectVariableContextEntry( extractor,
declaration );
context.left = row[2];
context.right = row[0];
@@ -387,19 +387,19 @@
private static final long serialVersionUID = 2759666130893301563L;
- public boolean getBooleanValue(Object object) {
+ public boolean getBooleanValue(final Object object) {
return ((Boolean) object).booleanValue();
}
- public byte getByteValue(Object object) {
+ public byte getByteValue(final Object object) {
return ((Number) object).byteValue();
}
- public char getCharValue(Object object) {
+ public char getCharValue(final Object object) {
return ((Character) object).charValue();
}
- public double getDoubleValue(Object object) {
+ public double getDoubleValue(final Object object) {
return ((Number) object).doubleValue();
}
@@ -407,19 +407,19 @@
return null;
}
- public float getFloatValue(Object object) {
+ public float getFloatValue(final Object object) {
return ((Number) object).floatValue();
}
- public int getHashCode(Object object) {
+ public int getHashCode(final Object object) {
return 0;
}
- public int getIntValue(Object object) {
+ public int getIntValue(final Object object) {
return ((Number) object).intValue();
}
- public long getLongValue(Object object) {
+ public long getLongValue(final Object object) {
return ((Number) object).longValue();
}
@@ -427,11 +427,11 @@
return null;
}
- public short getShortValue(Object object) {
+ public short getShortValue(final Object object) {
return ((Number) object).shortValue();
}
- public Object getValue(Object object) {
+ public Object getValue(final Object object) {
return object;
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/FieldFactoryTest.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -11,7 +11,7 @@
public void testBigDecimal() {
final FieldValue val = FieldFactory.getFieldValue( "42.42",
- ValueType.BIG_DECIMAL_TYPE );
+ ValueType.BIG_DECIMAL_TYPE );
assertEquals( BigDecimal.class,
val.getValue().getClass() );
assertTrue( val.getValue().equals( new BigDecimal( "42.42" ) ) );
@@ -19,7 +19,7 @@
public void testBigInteger() {
final FieldValue val = FieldFactory.getFieldValue( "424242",
- ValueType.BIG_INTEGER_TYPE );
+ 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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/ShadowProxyFactoryTest.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -25,7 +25,7 @@
final String originalType = "stilton";
final int originalPrice = 15;
final Cheese cheese = new Cheese( originalType,
- originalPrice );
+ originalPrice );
// creating proxy
final Class proxy = ShadowProxyFactory.getProxy( Cheese.class );
@@ -36,11 +36,13 @@
cheeseProxy.getType() );
Assert.assertEquals( originalPrice,
cheeseProxy.getPrice() );
- Assert.assertSame( cheese, ((ShadowProxy)cheeseProxy).getShadowedObject() );
-
+ Assert.assertSame( cheese,
+ ((ShadowProxy) cheeseProxy).getShadowedObject() );
+
// proxy must recongnize the original object on equals()/hashcode() calls
//Assert.assertEquals( cheeseProxy.hashCode(), cheese.hashCode() );
- Assert.assertEquals( cheeseProxy, cheese );
+ Assert.assertEquals( cheeseProxy,
+ cheese );
// changing original values
final String actualType = "rotten stilton";
@@ -86,7 +88,7 @@
final String originalType = "stilton";
final int originalPrice = 15;
final Cheese cheese = new Cheese( originalType,
- originalPrice );
+ originalPrice );
// creating proxy
final Class proxy = ShadowProxyFactory.getProxy( CheeseInterface.class );
@@ -97,7 +99,8 @@
cheeseProxy.getType() );
Assert.assertEquals( originalPrice,
cheeseProxy.getPrice() );
- Assert.assertSame( cheese, ((ShadowProxy)cheeseProxy).getShadowedObject() );
+ Assert.assertSame( cheese,
+ ((ShadowProxy) cheeseProxy).getShadowedObject() );
// changing original values
final String actualType = "rotten stilton";
@@ -149,7 +152,8 @@
// proxy is proxying the values
Assert.assertEquals( list,
listProxy );
- Assert.assertSame( list, ((ShadowProxy)listProxy).getShadowedObject() );
+ Assert.assertSame( list,
+ ((ShadowProxy) listProxy).getShadowedObject() );
} catch ( final Exception e ) {
fail( "Error: " + e.getMessage() );
@@ -162,93 +166,103 @@
final String originalType = "stilton";
final int originalPrice = 15;
final Cheese cheese = new Cheese( originalType,
- originalPrice );
+ originalPrice );
// creating proxy
final Class proxy = ShadowProxyFactory.getProxy( Cheese.class );
final Cheese cheeseProxy1 = (Cheese) proxy.getConstructor( new Class[]{Cheese.class} ).newInstance( new Object[]{cheese} );
final Cheese cheeseProxy2 = (Cheese) proxy.getConstructor( new Class[]{Cheese.class} ).newInstance( new Object[]{cheese} );
- int cheesehash = cheeseHashCode( cheese );
- Assert.assertEquals( cheeseProxy1, cheeseProxy2 );
- Assert.assertEquals( cheeseProxy2, cheeseProxy1 );
- Assert.assertEquals( cheesehash, cheeseProxy1.hashCode() );
-
+ final int cheesehash = cheeseHashCode( cheese );
+ Assert.assertEquals( cheeseProxy1,
+ cheeseProxy2 );
+ Assert.assertEquals( cheeseProxy2,
+ cheeseProxy1 );
+ Assert.assertEquals( cheesehash,
+ cheeseProxy1.hashCode() );
+
// changing original values
final String actualType = "rotten stilton";
final int actualPrice = 1;
cheese.setType( actualType );
cheese.setPrice( actualPrice );
- Assert.assertEquals( cheesehash, cheeseProxy1.hashCode() );
-
+ Assert.assertEquals( cheesehash,
+ cheeseProxy1.hashCode() );
+
// updating proxy1
((ShadowProxy) cheeseProxy1).updateProxy();
-
- Assert.assertEquals( cheeseHashCode( cheese ), cheeseProxy1.hashCode() );
+ Assert.assertEquals( cheeseHashCode( cheese ),
+ cheeseProxy1.hashCode() );
+
// now they are different
Assert.assertFalse( cheeseProxy1.equals( cheeseProxy2 ) );
Assert.assertFalse( cheeseProxy2.equals( cheeseProxy1 ) );
-
+
// updating proxy2
((ShadowProxy) cheeseProxy2).updateProxy();
// now they are equal again
- Assert.assertEquals( cheeseProxy1, cheeseProxy2 );
- Assert.assertEquals( cheeseProxy2, cheeseProxy1 );
-
+ Assert.assertEquals( cheeseProxy1,
+ cheeseProxy2 );
+ Assert.assertEquals( cheeseProxy2,
+ cheeseProxy1 );
+
} catch ( final Exception e ) {
fail( "Error: " + e.getMessage() );
}
}
-// TODO: find a new way to test hashcode
-// public void testEqualsHashCodeForClass2() {
-// try {
-// // creating original object
-// final TestBean bean = new TestBean();
-//
-// // creating proxy
-// final Class proxy = ShadowProxyFactory.getProxy( TestBean.class );
-// final TestBean beanProxy1 = (TestBean) proxy.getConstructor( new Class[]{TestBean.class} ).newInstance( new Object[]{bean} );
-// final TestBean beanProxy2 = (TestBean) proxy.getConstructor( new Class[]{TestBean.class} ).newInstance( new Object[]{bean} );
-//
-// Assert.assertEquals( beanProxy1, beanProxy2 );
-// Assert.assertEquals( beanProxy2, beanProxy1 );
-// Assert.assertEquals( -130900686 , beanProxy1.hashCode() );
-//
-// } catch ( final Exception e ) {
-// fail( "Error: " + e.getMessage() );
-// }
-// }
+ // TODO: find a new way to test hashcode
+ // public void testEqualsHashCodeForClass2() {
+ // try {
+ // // creating original object
+ // final TestBean bean = new TestBean();
+ //
+ // // creating proxy
+ // final Class proxy = ShadowProxyFactory.getProxy( TestBean.class );
+ // final TestBean beanProxy1 = (TestBean) proxy.getConstructor( new Class[]{TestBean.class} ).newInstance( new Object[]{bean} );
+ // final TestBean beanProxy2 = (TestBean) proxy.getConstructor( new Class[]{TestBean.class} ).newInstance( new Object[]{bean} );
+ //
+ // Assert.assertEquals( beanProxy1, beanProxy2 );
+ // Assert.assertEquals( beanProxy2, beanProxy1 );
+ // Assert.assertEquals( -130900686 , beanProxy1.hashCode() );
+ //
+ // } catch ( final Exception e ) {
+ // fail( "Error: " + e.getMessage() );
+ // }
+ // }
- private int cheeseHashCode(Cheese cheese) {
+ private int cheeseHashCode(final Cheese cheese) {
final int PRIME = 31;
int result = 1;
result = PRIME * result + ((cheese.getType() == null) ? 0 : cheese.getType().hashCode());
result = PRIME * result + cheese.getPrice();
return result;
}
-
+
public void testClassWithStaticMethod() {
try {
// creating original object
final String originalType = "stilton";
final int originalPrice = 15;
final Cheese cheese = new Cheese( originalType,
- originalPrice );
+ originalPrice );
// creating proxy
final Class proxy = ShadowProxyFactory.getProxy( Cheese.class );
final Cheese cheeseProxy1 = (Cheese) proxy.getConstructor( new Class[]{Cheese.class} ).newInstance( new Object[]{cheese} );
final Cheese cheeseProxy2 = (Cheese) proxy.getConstructor( new Class[]{Cheese.class} ).newInstance( new Object[]{cheese} );
- int cheesehash = cheeseHashCode( cheese );
- Assert.assertEquals( cheeseProxy1, cheeseProxy2 );
- Assert.assertEquals( cheeseProxy2, cheeseProxy1 );
- Assert.assertEquals( cheesehash, cheeseProxy1.hashCode() );
-
+ final int cheesehash = cheeseHashCode( cheese );
+ Assert.assertEquals( cheeseProxy1,
+ cheeseProxy2 );
+ Assert.assertEquals( cheeseProxy2,
+ cheeseProxy1 );
+ Assert.assertEquals( cheesehash,
+ cheeseProxy1.hashCode() );
+
} catch ( final Exception e ) {
e.printStackTrace();
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/TestBean.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -20,18 +20,18 @@
*/
public class TestBean {
- private final String name = "michael";
- private final int age = 42;
+ private final String name = "michael";
+ private final int age = 42;
- private boolean booleanAttr = true;
- private byte byteAttr = 1;
- private char charAttr = 'a';
- private short shortAttr = 3;
- private int intAttr = 4;
- private long longAttr = 5;
- private float floatAttr = 6.0f;
- private double doubleAttr = 7.0;
- private List listAttr = Collections.EMPTY_LIST;
+ private final boolean booleanAttr = true;
+ private final byte byteAttr = 1;
+ private final char charAttr = 'a';
+ private final short shortAttr = 3;
+ private final int intAttr = 4;
+ private final long longAttr = 5;
+ private final float floatAttr = 6.0f;
+ private final double doubleAttr = 7.0;
+ private final List listAttr = Collections.EMPTY_LIST;
public String getName() {
return this.name;
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/extractors/ByteClassFieldExtractorTest.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -91,7 +91,7 @@
public void testGetValue() {
try {
- Assert.assertEquals( 1 ,
+ Assert.assertEquals( 1,
((Number) this.extractor.getValue( this.bean )).byteValue() );
} 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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/extractors/CharClassFieldExtractorTest.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -63,7 +63,7 @@
public void testGetIntValue() {
try {
Assert.assertEquals( 'a',
- (int) this.extractor.getIntValue( this.bean ) );
+ this.extractor.getIntValue( this.bean ) );
} catch ( final Exception e ) {
fail( "Should not throw exception" );
}
@@ -90,7 +90,7 @@
public void testGetValue() {
try {
Assert.assertEquals( 'a',
- ((Number)this.extractor.getValue( this.bean )).intValue() );
+ ((Number) this.extractor.getValue( this.bean )).intValue() );
} 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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/extractors/IntClassFieldExtractorTest.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -94,7 +94,7 @@
public void testGetValue() {
try {
Assert.assertEquals( IntClassFieldExtractorTest.VALUE,
- ((Number)this.extractor.getValue( this.bean )).intValue() );
+ ((Number) this.extractor.getValue( this.bean )).intValue() );
} 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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/extractors/ShortClassFieldExtractorTest.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -94,7 +94,7 @@
public void testGetValue() {
try {
Assert.assertEquals( ShortClassFieldExtractorTest.VALUE,
- ((Number)this.extractor.getValue( this.bean )).shortValue() );
+ ((Number) this.extractor.getValue( this.bean )).shortValue() );
} catch ( final Exception e ) {
fail( "Should not throw an exception" );
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/event/AgendaEventSupportTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/event/AgendaEventSupportTest.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/event/AgendaEventSupportTest.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -30,7 +30,6 @@
import org.drools.base.FieldFactory;
import org.drools.base.ValueType;
import org.drools.base.evaluators.Operator;
-import org.drools.reteoo.AlphaNode;
import org.drools.rule.Column;
import org.drools.rule.LiteralConstraint;
import org.drools.rule.Rule;
@@ -51,44 +50,46 @@
}
public void testAgendaEventListener() throws Exception {
- RuleBase rb = RuleBaseFactory.newRuleBase();
-
+ final RuleBase rb = RuleBaseFactory.newRuleBase();
+
// create a simpe package with one rule to test the events
- Package pkg = new Package( "org.drools.test" );
- Rule rule = new Rule("test1");
+ final Package pkg = new Package( "org.drools.test" );
+ final Rule rule = new Rule( "test1" );
rule.setAgendaGroup( "test group" );
- ClassObjectType cheeseObjectType = new ClassObjectType( Cheese.class );
- Column column = new Column(0, cheeseObjectType);
-
- ClassFieldExtractor extractor = new ClassFieldExtractor( Cheese.class,
- "type" );
+ final ClassObjectType cheeseObjectType = new ClassObjectType( Cheese.class );
+ final Column column = new Column( 0,
+ cheeseObjectType );
- FieldValue field = FieldFactory.getFieldValue( "cheddar" );
+ final ClassFieldExtractor extractor = new ClassFieldExtractor( Cheese.class,
+ "type" );
- Evaluator evaluator = ValueType.STRING_TYPE.getEvaluator( Operator.EQUAL );
+ final FieldValue field = FieldFactory.getFieldValue( "cheddar" );
- LiteralConstraint constraint = new LiteralConstraint( extractor,
- evaluator,
- field );
+ final Evaluator evaluator = ValueType.STRING_TYPE.getEvaluator( Operator.EQUAL );
+
+ final LiteralConstraint constraint = new LiteralConstraint( extractor,
+ evaluator,
+ field );
column.addConstraint( constraint );
rule.addPattern( column );
-
- rule.setConsequence(new Consequence() {
- public void evaluate(KnowledgeHelper knowledgeHelper, WorkingMemory workingMemory) throws Exception {
- }
- });
- pkg.addRule(rule);
- rb.addPackage(pkg);
-
+
+ rule.setConsequence( new Consequence() {
+ public void evaluate(final KnowledgeHelper knowledgeHelper,
+ final WorkingMemory workingMemory) throws Exception {
+ }
+ } );
+ pkg.addRule( rule );
+ rb.addPackage( pkg );
+
// create a new working memory and add an AgendaEventListener
- WorkingMemory wm = rb.newWorkingMemory();
+ final WorkingMemory wm = rb.newWorkingMemory();
final List agendaList = new ArrayList();
- AgendaEventListener agendaEventListener = new AgendaEventListener() {
+ final AgendaEventListener agendaEventListener = new AgendaEventListener() {
public void activationCancelled(ActivationCancelledEvent event,
WorkingMemory workingMemory) {
agendaList.add( event );
-
+
}
public void activationCreated(ActivationCreatedEvent event,
@@ -114,56 +115,70 @@
public void beforeActivationFired(BeforeActivationFiredEvent event,
WorkingMemory workingMemory) {
agendaList.add( event );
- }
- };
+ }
+ };
wm.addEventListener( agendaEventListener );
-
+
// assert the cheese fact
- Cheese cheddar = new Cheese( "cheddar", 15 );
+ final Cheese cheddar = new Cheese( "cheddar",
+ 15 );
FactHandle cheddarHandle = wm.assertObject( cheddar );
-
+
// should be one ActivationCreatedEvent
- assertEquals( 1, agendaList.size() );
- ActivationCreatedEvent createdEvent = ( ActivationCreatedEvent ) agendaList.get( 0 );
- assertSame( cheddar, createdEvent.getActivation().getTuple().get( 0 ).getObject() );
+ assertEquals( 1,
+ agendaList.size() );
+ ActivationCreatedEvent createdEvent = (ActivationCreatedEvent) agendaList.get( 0 );
+ assertSame( cheddar,
+ createdEvent.getActivation().getTuple().get( 0 ).getObject() );
agendaList.clear();
-
+
// modify results in a ActivationCancelledEvent and an ActivationCreatedEvent, note the object is always resolvable
cheddar.setPrice( 14 );
- wm.modifyObject( cheddarHandle, cheddar);
- assertEquals( 2, agendaList.size() );
- ActivationCancelledEvent cancelledEvent = ( ActivationCancelledEvent ) agendaList.get( 0 );
- assertSame( cheddar, cancelledEvent.getActivation().getTuple().get( 0 ).getObject() );
- createdEvent = ( ActivationCreatedEvent ) agendaList.get( 1 );
- assertSame( cheddar, createdEvent.getActivation().getTuple().get( 0 ).getObject() );
- agendaList.clear();
-
+ wm.modifyObject( cheddarHandle,
+ cheddar );
+ assertEquals( 2,
+ agendaList.size() );
+ ActivationCancelledEvent cancelledEvent = (ActivationCancelledEvent) agendaList.get( 0 );
+ assertSame( cheddar,
+ cancelledEvent.getActivation().getTuple().get( 0 ).getObject() );
+ createdEvent = (ActivationCreatedEvent) agendaList.get( 1 );
+ assertSame( cheddar,
+ createdEvent.getActivation().getTuple().get( 0 ).getObject() );
+ agendaList.clear();
+
// retract results in a ActivationCancelledEvent, noe the object is not resolveable now as it no longer exists
wm.retractObject( cheddarHandle );
- assertEquals( 1, agendaList.size() );
- cancelledEvent = ( ActivationCancelledEvent ) agendaList.get( 0 );
+ assertEquals( 1,
+ agendaList.size() );
+ cancelledEvent = (ActivationCancelledEvent) agendaList.get( 0 );
assertNull( cancelledEvent.getActivation().getTuple().get( 0 ).getObject() );
-
+
// re-assert the fact so we can test the agenda group events
cheddarHandle = wm.assertObject( cheddar );
agendaList.clear();
-
+
// setFocus results in an AgendaGroupPushedEvent
wm.setFocus( "test group" );
- assertEquals( 1, agendaList.size() );
- AgendaGroupPushedEvent pushedEvent = ( AgendaGroupPushedEvent ) agendaList.get( 0 );
- assertEquals( "test group", pushedEvent.getAgendaGroup().getName() );
+ assertEquals( 1,
+ agendaList.size() );
+ final AgendaGroupPushedEvent pushedEvent = (AgendaGroupPushedEvent) agendaList.get( 0 );
+ assertEquals( "test group",
+ pushedEvent.getAgendaGroup().getName() );
agendaList.clear();
-
+
// fireAllRules results in a BeforeActivationFiredEvent and an AfterActivationFiredEvent
// the AgendaGroup becomes empty, which results in a popped event.
wm.fireAllRules();
- assertEquals( 3, agendaList.size() );
- BeforeActivationFiredEvent beforeEvent = ( BeforeActivationFiredEvent ) agendaList.get( 0 );
- assertSame( cheddar, beforeEvent.getActivation().getTuple().get( 0 ).getObject() );
- AfterActivationFiredEvent afterEvent = ( AfterActivationFiredEvent ) agendaList.get( 1 );
- assertSame( cheddar, afterEvent.getActivation().getTuple().get( 0 ).getObject() );
- AgendaGroupPoppedEvent poppedEvent = ( AgendaGroupPoppedEvent ) agendaList.get( 2 );
- assertEquals( "test group", poppedEvent.getAgendaGroup().getName() );
+ assertEquals( 3,
+ agendaList.size() );
+ final BeforeActivationFiredEvent beforeEvent = (BeforeActivationFiredEvent) agendaList.get( 0 );
+ assertSame( cheddar,
+ beforeEvent.getActivation().getTuple().get( 0 ).getObject() );
+ final AfterActivationFiredEvent afterEvent = (AfterActivationFiredEvent) agendaList.get( 1 );
+ assertSame( cheddar,
+ afterEvent.getActivation().getTuple().get( 0 ).getObject() );
+ final AgendaGroupPoppedEvent poppedEvent = (AgendaGroupPoppedEvent) agendaList.get( 2 );
+ assertEquals( "test group",
+ poppedEvent.getAgendaGroup().getName() );
}
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/event/WorkingMemoryEventSupportTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/event/WorkingMemoryEventSupportTest.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/event/WorkingMemoryEventSupportTest.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -37,11 +37,11 @@
}
public void testWorkingMemoryEventListener() {
- RuleBase rb = RuleBaseFactory.newRuleBase();
- WorkingMemory wm = rb.newWorkingMemory();
+ final RuleBase rb = RuleBaseFactory.newRuleBase();
+ final WorkingMemory wm = rb.newWorkingMemory();
final List wmList = new ArrayList();
- WorkingMemoryEventListener workingMemoryListener = new WorkingMemoryEventListener() {
+ final WorkingMemoryEventListener workingMemoryListener = new WorkingMemoryEventListener() {
public void objectAsserted(ObjectAssertedEvent event) {
wmList.add( event );
@@ -59,25 +59,25 @@
wm.addEventListener( workingMemoryListener );
- Cheese stilton = new Cheese( "stilton",
+ final Cheese stilton = new Cheese( "stilton",
15 );
- Cheese cheddar = new Cheese( "cheddar",
+ final Cheese cheddar = new Cheese( "cheddar",
17 );
- FactHandle stiltonHandle = wm.assertObject( stilton );
+ final FactHandle stiltonHandle = wm.assertObject( stilton );
- ObjectAssertedEvent oae = (ObjectAssertedEvent) wmList.get( 0 );
+ final ObjectAssertedEvent oae = (ObjectAssertedEvent) wmList.get( 0 );
assertSame( stiltonHandle,
oae.getFactHandle() );
wm.modifyObject( stiltonHandle,
stilton );
- ObjectModifiedEvent ome = (ObjectModifiedEvent) wmList.get( 1 );
+ final ObjectModifiedEvent ome = (ObjectModifiedEvent) wmList.get( 1 );
assertSame( stiltonHandle,
ome.getFactHandle() );
wm.retractObject( stiltonHandle );
- ObjectRetractedEvent ore = (ObjectRetractedEvent) wmList.get( 2 );
+ final ObjectRetractedEvent ore = (ObjectRetractedEvent) wmList.get( 2 );
assertSame( stiltonHandle,
ore.getFactHandle() );
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/ReteooMannersTest.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -23,10 +23,8 @@
import org.drools.RuleBase;
import org.drools.RuleBaseFactory;
import org.drools.WorkingMemory;
-import org.drools.common.InternalWorkingMemory;
import org.drools.event.AfterActivationFiredEvent;
import org.drools.event.DefaultAgendaEventListener;
-import org.drools.reteoo.MemoryVisitor;
public class ReteooMannersTest extends BaseMannersTest {
@@ -87,8 +85,8 @@
// Thread.sleep( 2000 );
// }
-// final MemoryVisitor visitor = new MemoryVisitor( (InternalWorkingMemory) workingMemory );
-// visitor.visit( ruleBase );
+ // final MemoryVisitor visitor = new MemoryVisitor( (InternalWorkingMemory) workingMemory );
+ // visitor.visit( ruleBase );
// final ReteooJungViewer viewer = new ReteooJungViewer(ruleBase);
//
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/facttemplates/FactTemplateFieldExtractorTest.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -12,20 +12,20 @@
final Package pkg = new Package( "org.store" );
final FieldTemplate cheeseName = new FieldTemplateImpl( "name",
- 0,
- String.class );
+ 0,
+ String.class );
final FieldTemplate cheesePrice = new FieldTemplateImpl( "price",
- 1,
- Integer.class );
+ 1,
+ Integer.class );
final FieldTemplate[] fields = new FieldTemplate[]{cheeseName, cheesePrice};
final FactTemplate cheese = new FactTemplateImpl( pkg,
- "Cheese",
- fields );
+ "Cheese",
+ fields );
final Extractor extractName = new FactTemplateFieldExtractor( cheese,
- 0 );
+ 0 );
final Extractor extractPrice = new FactTemplateFieldExtractor( cheese,
- 1 );
+ 1 );
final Fact stilton = cheese.createFact( 10 );
stilton.setFieldValue( "name",
@@ -56,21 +56,21 @@
final Package pkg = new Package( "org.store" );
final FieldTemplate cheeseName = new FieldTemplateImpl( "name",
- 0,
- String.class );
+ 0,
+ String.class );
final FieldTemplate cheesePrice = new FieldTemplateImpl( "price",
- 1,
- Integer.class );
+ 1,
+ Integer.class );
final FieldTemplate[] fields = new FieldTemplate[]{cheeseName, cheesePrice};
final FactTemplate cheese = new FactTemplateImpl( pkg,
- "Cheese",
- fields );
+ "Cheese",
+ fields );
final Extractor extractName = new FactTemplateFieldExtractor( cheese,
- 0 );
+ 0 );
final Column column = new Column( 0,
- new FactTemplateObjectType( cheese ) );
+ new FactTemplateObjectType( cheese ) );
final Declaration declaration = new Declaration( "typeOfCheese",
extractName,
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/facttemplates/FactTemplateTest.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -8,15 +8,15 @@
public void testFieldsAndGetters() {
final Package pkg = new Package( "org.store" );
final FieldTemplate cheeseName = new FieldTemplateImpl( "name",
- 0,
- String.class );
+ 0,
+ String.class );
final FieldTemplate cheesePrice = new FieldTemplateImpl( "price",
- 1,
- Integer.class );
+ 1,
+ Integer.class );
final FieldTemplate[] fields = new FieldTemplate[]{cheeseName, cheesePrice};
final FactTemplate cheese = new FactTemplateImpl( pkg,
- "Cheese",
- fields );
+ "Cheese",
+ fields );
assertEquals( "org.store",
cheese.getPackage().getName() );
@@ -50,24 +50,24 @@
// Create cheese1 with name and price fields
final FieldTemplate cheeseName = new FieldTemplateImpl( "name",
- 0,
- String.class );
+ 0,
+ String.class );
final FieldTemplate cheesePrice = new FieldTemplateImpl( "price",
- 1,
- Integer.class );
+ 1,
+ Integer.class );
final FieldTemplate[] fields1 = new FieldTemplate[]{cheeseName, cheesePrice};
final FactTemplate cheese1 = new FactTemplateImpl( pkg,
- "Cheese",
- fields1 );
+ "Cheese",
+ fields1 );
// Create cheese2 with type and price fields
final FieldTemplate cheeseType = new FieldTemplateImpl( "type",
- 0,
- String.class );
+ 0,
+ String.class );
final FieldTemplate[] fields2 = new FieldTemplate[]{cheeseType, cheesePrice};
final FactTemplate cheese2 = new FactTemplateImpl( pkg,
- "Cheese",
- fields2 );
+ "Cheese",
+ fields2 );
assertNotSame( cheese1,
cheese2 );
@@ -78,15 +78,15 @@
// create cheese3 with name and price fields, using new instances
final FieldTemplate cheeseName2 = new FieldTemplateImpl( "name",
- 0,
- String.class );
+ 0,
+ String.class );
final FieldTemplate cheesePrice2 = new FieldTemplateImpl( "price",
- 1,
- Integer.class );
+ 1,
+ Integer.class );
final FieldTemplate[] fields3 = new FieldTemplate[]{cheeseName2, cheesePrice2};
final FactTemplate cheese3 = new FactTemplateImpl( pkg,
- "Cheese",
- fields3 );
+ "Cheese",
+ fields3 );
assertNotSame( cheese1,
cheese3 );
@@ -101,15 +101,15 @@
public void testFacts() {
final Package pkg = new Package( "org.store" );
final FieldTemplate cheeseName = new FieldTemplateImpl( "name",
- 0,
- String.class );
+ 0,
+ String.class );
final FieldTemplate cheesePrice = new FieldTemplateImpl( "price",
- 1,
- Integer.class );
+ 1,
+ Integer.class );
final FieldTemplate[] fields1 = new FieldTemplate[]{cheeseName, cheesePrice};
final FactTemplate cheese1 = new FactTemplateImpl( pkg,
- "Cheese",
- fields1 );
+ "Cheese",
+ fields1 );
final Fact stilton1 = cheese1.createFact( 10 );
stilton1.setFieldValue( "name",
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/facttemplates/FieldTemplateTest.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -7,8 +7,8 @@
public class FieldTemplateTest extends TestCase {
public void testFieldTemplate() {
final FieldTemplate cheeseName = new FieldTemplateImpl( "name",
- 5,
- String.class );
+ 5,
+ String.class );
assertEquals( "name",
cheeseName.getName() );
assertEquals( ValueType.STRING_TYPE,
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/AccumulateNodeTest.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -15,8 +15,6 @@
*/
package org.drools.reteoo;
-import java.util.List;
-
import junit.framework.Assert;
import org.drools.DroolsTestCase;
@@ -33,7 +31,6 @@
import org.drools.spi.MockConstraint;
import org.drools.spi.ObjectType;
import org.drools.spi.PropagationContext;
-import org.drools.spi.Tuple;
/**
* A test case for AccumulateNode
@@ -75,10 +72,10 @@
final ObjectType srcObjType = new ClassObjectType( String.class );
final Column sourceColumn = new Column( 0,
- srcObjType );
+ srcObjType );
final ObjectType resultObjType = new ClassObjectType( String.class );
final Column resultColumn = new Column( 1,
- resultObjType );
+ resultObjType );
this.accumulate = new Accumulate( sourceColumn,
resultColumn,
new Declaration[0],
@@ -173,7 +170,7 @@
Assert.assertTrue( "An empty matching objects list should be propagated",
this.accumulator.getMatchingObjects().isEmpty() );
- TupleMemory memory = this.memory.getTupleMemory();
+ final TupleMemory memory = this.memory.getTupleMemory();
assertTrue( memory.contains( tuple0 ) );
assertTrue( memory.contains( tuple1 ) );
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/AgendaTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/AgendaTest.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/AgendaTest.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -523,7 +523,7 @@
// When both the rule is lock-on-active and the agenda group is active, activations should be ignored
rule.setLockOnActive( true );
- agendaGroup.setActive( true );
+ agendaGroup.setActive( true );
node.assertTuple( tuple,
context,
workingMemory );
@@ -532,19 +532,19 @@
agendaGroup.size() );
// lock-on-active is now false so activation should propagate
- rule.setLockOnActive( false );
+ rule.setLockOnActive( false );
node.assertTuple( tuple,
context,
- workingMemory );
+ workingMemory );
assertEquals( 1,
agendaGroup.size() );
-
+
// even if lock-on-active is true, unless the agenda group is active the activation will still propagate
- rule.setLockOnActive( true );
- agendaGroup.setActive( false );
+ rule.setLockOnActive( true );
+ agendaGroup.setActive( false );
node.assertTuple( tuple,
context,
- workingMemory );
+ workingMemory );
assertEquals( 2,
agendaGroup.size() );
}
@@ -1274,7 +1274,7 @@
assertEquals( 0,
agenda.agendaSize() );
}
-
+
public void testRuleFlowGroupLockOnActive() {
final RuleBase ruleBase = RuleBaseFactory.newRuleBase();
@@ -1284,15 +1284,15 @@
// create the agendaGroup
//final AgendaGroupImpl agendaGroup = new AgendaGroupImpl( "agendaGroup" );
//agenda.addAgendaGroup( agendaGroup );
-
- final RuleFlowGroupImpl ruleFlowGroup = ( RuleFlowGroupImpl ) agenda.getRuleFlowGroup( "rule-flow-group-0" );
+ final RuleFlowGroupImpl ruleFlowGroup = (RuleFlowGroupImpl) agenda.getRuleFlowGroup( "rule-flow-group-0" );
+
final ReteTuple tuple = new ReteTuple( new DefaultFactHandle( 1,
"cheese" ) );
// create a rule for the agendaGroup
- final Rule rule = new Rule( "test-rule" );
- rule.setRuleFlowGroup( "rule-flow-group-0" );
+ final Rule rule = new Rule( "test-rule" );
+ rule.setRuleFlowGroup( "rule-flow-group-0" );
final RuleTerminalNode node = new RuleTerminalNode( 2,
new MockTupleSource( 2 ),
rule,
@@ -1305,7 +1305,7 @@
// When both the rule is lock-on-active and the agenda group is active, activations should be ignored
rule.setLockOnActive( true );
- ruleFlowGroup.setActive( true );
+ ruleFlowGroup.setActive( true );
node.assertTuple( tuple,
context,
workingMemory );
@@ -1314,22 +1314,21 @@
ruleFlowGroup.size() );
// lock-on-active is now false so activation should propagate
- rule.setLockOnActive( false );
+ rule.setLockOnActive( false );
node.assertTuple( tuple,
context,
- workingMemory );
+ workingMemory );
assertEquals( 1,
ruleFlowGroup.size() );
-
+
// even if lock-on-active is true, unless the agenda group is active the activation will still propagate
- rule.setLockOnActive( true );
- ruleFlowGroup.setActive( false );
+ rule.setLockOnActive( true );
+ ruleFlowGroup.setActive( false );
node.assertTuple( tuple,
context,
- workingMemory );
+ workingMemory );
assertEquals( 2,
ruleFlowGroup.size() );
}
-
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/AlphaNodeTest.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -77,7 +77,7 @@
constraint,
source,
true,
- 3); // has memory
+ 3 ); // has memory
final MockObjectSink sink = new MockObjectSink();
alphaNode.addObjectSink( sink );
@@ -158,7 +158,7 @@
constraint,
source,
false,
- 3); // no memory
+ 3 ); // no memory
final MockObjectSink sink = new MockObjectSink();
alphaNode.addObjectSink( sink );
@@ -304,7 +304,7 @@
constraint,
source,
true,
- 3); // has memory
+ 3 ); // has memory
final MockObjectSink sink = new MockObjectSink();
alphaNode.addObjectSink( sink );
@@ -465,7 +465,7 @@
constraint,
source,
true,
- 3); // has memory
+ 3 ); // has memory
alphaNode.attach();
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/BetaNodeTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/BetaNodeTest.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/BetaNodeTest.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -42,21 +42,35 @@
* Test method for {@link org.drools.reteoo.BetaNode#equals(java.lang.Object)}.
*/
public void testEqualsObject() {
- TupleSource ts = new MockTupleSource(1);
- ObjectSource os = new MockObjectSource(2);
-
- BetaNode j1 = new JoinNode(1, ts, os);
- BetaNode j2 = new JoinNode(2, ts, os);
- BetaNode n1 = new NotNode(3, ts, os);
- BetaNode n2 = new NotNode(4, ts, os);
-
- assertEquals( j1, j1);
- assertEquals( j2, j2);
- assertEquals( j1, j2);
- assertEquals( n1, n1);
- assertEquals( n2, n2);
- assertEquals( n1, n2);
-
+ final TupleSource ts = new MockTupleSource( 1 );
+ final ObjectSource os = new MockObjectSource( 2 );
+
+ final BetaNode j1 = new JoinNode( 1,
+ ts,
+ os );
+ final BetaNode j2 = new JoinNode( 2,
+ ts,
+ os );
+ final BetaNode n1 = new NotNode( 3,
+ ts,
+ os );
+ final BetaNode n2 = new NotNode( 4,
+ ts,
+ os );
+
+ assertEquals( j1,
+ j1 );
+ assertEquals( j2,
+ j2 );
+ assertEquals( j1,
+ j2 );
+ assertEquals( n1,
+ n1 );
+ assertEquals( n2,
+ n2 );
+ assertEquals( n1,
+ n2 );
+
assertFalse( j1.equals( n1 ) );
assertFalse( j1.equals( n2 ) );
assertFalse( n1.equals( j1 ) );
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/CollectNodeTest.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -69,10 +69,10 @@
final ObjectType srcObjType = new ClassObjectType( String.class );
final Column sourceColumn = new Column( 0,
- srcObjType );
+ srcObjType );
final ObjectType resultObjType = new ClassObjectType( LinkedList.class );
final Column resultColumn = new Column( 1,
- resultObjType );
+ resultObjType );
this.collect = new Collect( sourceColumn,
resultColumn );
@@ -100,7 +100,9 @@
}
public void testUpdateNewNode() {
- this.node.updateSink( this.sink, this.context, this.workingMemory );
+ this.node.updateSink( this.sink,
+ this.context,
+ this.workingMemory );
Assert.assertEquals( "No tuple should be propagated",
0,
this.sink.getAsserted().size() );
@@ -119,7 +121,9 @@
final MockTupleSink otherSink = new MockTupleSink();
this.node.addTupleSink( otherSink );
- this.node.updateSink( otherSink, this.context, this.workingMemory );
+ this.node.updateSink( otherSink,
+ this.context,
+ this.workingMemory );
Assert.assertEquals( "Two tuples should have been propagated",
2,
@@ -154,8 +158,8 @@
Assert.assertTrue( "An empty collection should be propagated",
((Collection) ((DefaultFactHandle) ((Tuple) ((Object[]) this.sink.getAsserted().get( 1 ))[0]).get( 1 )).getObject()).isEmpty() );
- assertTrue( this.memory.getTupleMemory().contains( tuple0 ));
- assertTrue( this.memory.getTupleMemory().contains( tuple1 ));
+ assertTrue( this.memory.getTupleMemory().contains( tuple0 ) );
+ assertTrue( this.memory.getTupleMemory().contains( tuple1 ) );
Assert.assertEquals( "Two tuples should have been propagated",
2,
@@ -199,8 +203,8 @@
2,
((Collection) ((DefaultFactHandle) ((Tuple) ((Object[]) this.sink.getAsserted().get( 1 ))[0]).get( 1 )).getObject()).size() );
- assertTrue( this.memory.getTupleMemory().contains( tuple0 ));
- assertTrue( this.memory.getTupleMemory().contains( tuple1 ));
+ assertTrue( this.memory.getTupleMemory().contains( tuple0 ) );
+ assertTrue( this.memory.getTupleMemory().contains( tuple1 ) );
Assert.assertEquals( "Two tuples should have been propagated",
2,
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/CompositeObjectSinkAdapterTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/CompositeObjectSinkAdapterTest.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/CompositeObjectSinkAdapterTest.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -17,189 +17,217 @@
public class CompositeObjectSinkAdapterTest extends TestCase {
- public int la;
- public int blah;
+ public int la;
+ public int blah;
public String wah;
-
+ public void testBeta() {
+ final CompositeObjectSinkAdapter ad = new CompositeObjectSinkAdapter();
+ final MockBetaNode beta = new MockBetaNode( 0,
+ null,
+ null );
+ ad.addObjectSink( beta );
+ assertEquals( 1,
+ ad.getSinks().length );
+ assertEquals( beta,
+ ad.getSinks()[0] );
+ assertEquals( 1,
+ ad.otherSinks.size() );
+ assertEquals( beta,
+ ad.otherSinks.getFirst() );
- public void testBeta() {
- CompositeObjectSinkAdapter ad = new CompositeObjectSinkAdapter();
- MockBetaNode beta = new MockBetaNode(0, null, null);
- ad.addObjectSink( beta );
- assertEquals(1, ad.getSinks().length);
- assertEquals(beta, ad.getSinks()[0]);
-
- assertEquals(1, ad.otherSinks.size());
- assertEquals(beta, ad.otherSinks.getFirst());
-
- assertNull(ad.hashableSinks);
- assertNull(ad.hashedFieldIndexes);
- assertNull(ad.hashedSinkMap);
-
+ assertNull( ad.hashableSinks );
+ assertNull( ad.hashedFieldIndexes );
+ assertNull( ad.hashedSinkMap );
+
ad.removeObjectSink( beta );
- assertNull(ad.otherSinks);
- assertEquals(0, ad.getSinks().length);
+ assertNull( ad.otherSinks );
+ assertEquals( 0,
+ ad.getSinks().length );
}
-
-
+
public void testAlphaWithPredicate() {
- CompositeObjectSinkAdapter ad = new CompositeObjectSinkAdapter();
- AlphaNode al = new AlphaNode(0, new PredicateConstraint(null, null), null);
+ final CompositeObjectSinkAdapter ad = new CompositeObjectSinkAdapter();
+ final AlphaNode al = new AlphaNode( 0,
+ new PredicateConstraint( null,
+ null ),
+ null );
ad.addObjectSink( al );
-
- assertEquals(1, ad.getSinks().length);
- assertEquals(1, ad.otherSinks.size());
- assertEquals(al, ad.otherSinks.getFirst());
-
+
+ assertEquals( 1,
+ ad.getSinks().length );
+ assertEquals( 1,
+ ad.otherSinks.size() );
+ assertEquals( al,
+ ad.otherSinks.getFirst() );
+
ad.removeObjectSink( al );
- assertEquals(0, ad.getSinks().length);
- assertNull(ad.otherSinks);
-
+ assertEquals( 0,
+ ad.getSinks().length );
+ assertNull( ad.otherSinks );
+
}
-
+
public void testSingleAlpha() {
-
- CompositeObjectSinkAdapter ad = new CompositeObjectSinkAdapter();
- LiteralConstraint lit = new LiteralConstraint(new MockExtractor(),
- StringFactory.getInstance().getEvaluator( Operator.EQUAL ),
- new ObjectFieldImpl("stilton"));
- AlphaNode al = new AlphaNode(0, lit, new MockObjectSource(0) );
-
+
+ final CompositeObjectSinkAdapter ad = new CompositeObjectSinkAdapter();
+ final LiteralConstraint lit = new LiteralConstraint( new MockExtractor(),
+ StringFactory.getInstance().getEvaluator( Operator.EQUAL ),
+ new ObjectFieldImpl( "stilton" ) );
+ final AlphaNode al = new AlphaNode( 0,
+ lit,
+ new MockObjectSource( 0 ) );
+
ad.addObjectSink( al );
-
- assertNull(ad.otherSinks);
- assertNotNull(ad.hashedFieldIndexes);
- assertEquals(1, ad.hashableSinks.size());
- assertEquals(al, ad.getSinks()[0]);
-
-
+
+ assertNull( ad.otherSinks );
+ assertNotNull( ad.hashedFieldIndexes );
+ assertEquals( 1,
+ ad.hashableSinks.size() );
+ assertEquals( al,
+ ad.getSinks()[0] );
+
ad.removeObjectSink( al );
- assertNull(ad.otherSinks);
- assertNull(ad.hashableSinks);
-
-
+ assertNull( ad.otherSinks );
+ assertNull( ad.hashableSinks );
+
}
-
+
public void testDoubleAlphaWithBeta() {
-
- CompositeObjectSinkAdapter ad = new CompositeObjectSinkAdapter();
- LiteralConstraint lit = new LiteralConstraint(new MockExtractor(),
- StringFactory.getInstance().getEvaluator( Operator.EQUAL ),
- new ObjectFieldImpl("stilton"));
- AlphaNode al = new AlphaNode(0, lit, new MockObjectSource(0) );
-
+
+ final CompositeObjectSinkAdapter ad = new CompositeObjectSinkAdapter();
+ final LiteralConstraint lit = new LiteralConstraint( new MockExtractor(),
+ StringFactory.getInstance().getEvaluator( Operator.EQUAL ),
+ new ObjectFieldImpl( "stilton" ) );
+ final AlphaNode al = new AlphaNode( 0,
+ lit,
+ new MockObjectSource( 0 ) );
+
ad.addObjectSink( al );
-
- assertNull(ad.otherSinks);
- assertNotNull(ad.hashedFieldIndexes);
- assertEquals(1, ad.hashableSinks.size());
- assertEquals(al, ad.getSinks()[0]);
-
- LiteralConstraint lit2 = new LiteralConstraint(new MockExtractor(),
- StringFactory.getInstance().getEvaluator( Operator.EQUAL ),
- new ObjectFieldImpl("cheddar"));
- AlphaNode al2 = new AlphaNode(1, lit2, new MockObjectSource(0) );
-
+ assertNull( ad.otherSinks );
+ assertNotNull( ad.hashedFieldIndexes );
+ assertEquals( 1,
+ ad.hashableSinks.size() );
+ assertEquals( al,
+ ad.getSinks()[0] );
+
+ final LiteralConstraint lit2 = new LiteralConstraint( new MockExtractor(),
+ StringFactory.getInstance().getEvaluator( Operator.EQUAL ),
+ new ObjectFieldImpl( "cheddar" ) );
+ final AlphaNode al2 = new AlphaNode( 1,
+ lit2,
+ new MockObjectSource( 0 ) );
+
ad.addObjectSink( al2 );
-
- assertNull(ad.otherSinks);
- assertEquals(2, ad.hashableSinks.size());
- assertEquals(al, ad.getSinks()[0]);
- assertEquals(al2, ad.getSinks()[1]);
-
+
+ assertNull( ad.otherSinks );
+ assertEquals( 2,
+ ad.hashableSinks.size() );
+ assertEquals( al,
+ ad.getSinks()[0] );
+ assertEquals( al2,
+ ad.getSinks()[1] );
+
//add a beta, just for good measure, make sure it leaves others alone
- MockBetaNode beta = new MockBetaNode(0, null, null);
+ final MockBetaNode beta = new MockBetaNode( 0,
+ null,
+ null );
ad.addObjectSink( beta );
- assertNotNull(ad.otherSinks);
- assertEquals(2, ad.hashableSinks.size());
+ assertNotNull( ad.otherSinks );
+ assertEquals( 2,
+ ad.hashableSinks.size() );
-
- assertEquals(1, ad.otherSinks.size());
- assertEquals(beta, ad.otherSinks.getFirst());
-
+ assertEquals( 1,
+ ad.otherSinks.size() );
+ assertEquals( beta,
+ ad.otherSinks.getFirst() );
+
ad.removeObjectSink( beta );
- assertNull(ad.otherSinks);
- assertEquals(2, ad.hashableSinks.size());
-
- }
-
-
+ assertNull( ad.otherSinks );
+ assertEquals( 2,
+ ad.hashableSinks.size() );
+
+ }
+
public void testTripleAlpha() {
- CompositeObjectSinkAdapter ad = new CompositeObjectSinkAdapter();
- LiteralConstraint lit = new LiteralConstraint(new MockExtractor(),
- StringFactory.getInstance().getEvaluator( Operator.EQUAL ),
- new ObjectFieldImpl("stilton"));
- AlphaNode al = new AlphaNode(0, lit, new MockObjectSource(0) );
-
+ final CompositeObjectSinkAdapter ad = new CompositeObjectSinkAdapter();
+ final LiteralConstraint lit = new LiteralConstraint( new MockExtractor(),
+ StringFactory.getInstance().getEvaluator( Operator.EQUAL ),
+ new ObjectFieldImpl( "stilton" ) );
+ final AlphaNode al = new AlphaNode( 0,
+ lit,
+ new MockObjectSource( 0 ) );
+
ad.addObjectSink( al );
-
- assertNull(ad.otherSinks);
- assertNotNull(ad.hashedFieldIndexes);
- assertEquals(1, ad.hashableSinks.size());
- assertEquals(al, ad.getSinks()[0]);
-
- LiteralConstraint lit2 = new LiteralConstraint(new MockExtractor(),
- StringFactory.getInstance().getEvaluator( Operator.EQUAL ),
- new ObjectFieldImpl("cheddar"));
- AlphaNode al2 = new AlphaNode(1, lit2, new MockObjectSource(1) );
-
+ assertNull( ad.otherSinks );
+ assertNotNull( ad.hashedFieldIndexes );
+ assertEquals( 1,
+ ad.hashableSinks.size() );
+ assertEquals( al,
+ ad.getSinks()[0] );
+
+ final LiteralConstraint lit2 = new LiteralConstraint( new MockExtractor(),
+ StringFactory.getInstance().getEvaluator( Operator.EQUAL ),
+ new ObjectFieldImpl( "cheddar" ) );
+ final AlphaNode al2 = new AlphaNode( 1,
+ lit2,
+ new MockObjectSource( 1 ) );
+
ad.addObjectSink( al2 );
-
- assertNull(ad.hashedSinkMap);
- assertEquals(2, ad.hashableSinks.size());
-
- LiteralConstraint lit3 = new LiteralConstraint(new MockExtractor(),
- StringFactory.getInstance().getEvaluator( Operator.EQUAL ),
- new ObjectFieldImpl("stinky"));
- AlphaNode al3 = new AlphaNode(1, lit3, new MockObjectSource(2) );
+
+ assertNull( ad.hashedSinkMap );
+ assertEquals( 2,
+ ad.hashableSinks.size() );
+
+ final LiteralConstraint lit3 = new LiteralConstraint( new MockExtractor(),
+ StringFactory.getInstance().getEvaluator( Operator.EQUAL ),
+ new ObjectFieldImpl( "stinky" ) );
+ final AlphaNode al3 = new AlphaNode( 1,
+ lit3,
+ new MockObjectSource( 2 ) );
ad.addObjectSink( al3 );
-
+
//this should now be nicely hashed.
- assertNotNull( ad.hashedSinkMap );
- assertNull(ad.hashableSinks);
-
-
-
+ assertNotNull( ad.hashedSinkMap );
+ assertNull( ad.hashableSinks );
+
//now remove one, check the hashing is undone
ad.removeObjectSink( al2 );
- assertNotNull(ad.hashableSinks);
- assertEquals(2, ad.hashableSinks.size());
- assertNull(ad.hashedSinkMap);
-
-
+ assertNotNull( ad.hashableSinks );
+ assertEquals( 2,
+ ad.hashableSinks.size() );
+ assertNull( ad.hashedSinkMap );
+
}
-
-
-
-
-
- static class MockExtractor implements FieldExtractor {
+ static class MockExtractor
+ implements
+ FieldExtractor {
+
public int getIndex() {
// Auto-generated method stub
return 0;
}
- public boolean getBooleanValue(Object object) {
+ public boolean getBooleanValue(final Object object) {
// Auto-generated method stub
return false;
}
- public byte getByteValue(Object object) {
+ public byte getByteValue(final Object object) {
// Auto-generated method stub
return 0;
}
- public char getCharValue(Object object) {
+ public char getCharValue(final Object object) {
// Auto-generated method stub
return 0;
}
- public double getDoubleValue(Object object) {
+ public double getDoubleValue(final Object object) {
// Auto-generated method stub
return 0;
}
@@ -209,17 +237,17 @@
return null;
}
- public float getFloatValue(Object object) {
+ public float getFloatValue(final Object object) {
// Auto-generated method stub
return 0;
}
- public int getIntValue(Object object) {
+ public int getIntValue(final Object object) {
// Auto-generated method stub
return 0;
}
- public long getLongValue(Object object) {
+ public long getLongValue(final Object object) {
// Auto-generated method stub
return 0;
}
@@ -229,12 +257,12 @@
return null;
}
- public short getShortValue(Object object) {
+ public short getShortValue(final Object object) {
// Auto-generated method stub
return 0;
}
- public Object getValue(Object object) {
+ public Object getValue(final Object object) {
// Auto-generated method stub
return null;
}
@@ -244,58 +272,57 @@
return null;
}
- public int getHashCode(Object object) {
+ public int getHashCode(final Object object) {
return 0;
}
-
+
}
-
+
static class MockBetaNode extends BetaNode {
-
- MockBetaNode(int id,
- TupleSource leftInput,
- ObjectSource rightInput) {
+ MockBetaNode(final int id,
+ final TupleSource leftInput,
+ final ObjectSource rightInput) {
super( id,
leftInput,
rightInput );
// Auto-generated constructor stub
}
- public void updateSink(TupleSink sink,
- PropagationContext context,
- InternalWorkingMemory workingMemory) {
+ public void updateSink(final TupleSink sink,
+ final PropagationContext context,
+ final InternalWorkingMemory workingMemory) {
// Auto-generated method stub
-
+
}
- public void assertTuple(ReteTuple tuple,
- PropagationContext context,
- InternalWorkingMemory workingMemory) {
+ public void assertTuple(final ReteTuple tuple,
+ final PropagationContext context,
+ final InternalWorkingMemory workingMemory) {
// Auto-generated method stub
-
+
}
- public void retractTuple(ReteTuple tuple,
- PropagationContext context,
- InternalWorkingMemory workingMemory) {
+ public void retractTuple(final ReteTuple tuple,
+ final PropagationContext context,
+ final InternalWorkingMemory workingMemory) {
// Auto-generated method stub
-
+
}
- public void assertObject(InternalFactHandle handle,
- PropagationContext context,
- InternalWorkingMemory workingMemory) {
+ public void assertObject(final InternalFactHandle handle,
+ final PropagationContext context,
+ final InternalWorkingMemory workingMemory) {
// Auto-generated method stub
-
+
}
- public void retractObject(InternalFactHandle handle,
- PropagationContext context,
- InternalWorkingMemory workingMemory) {
+ public void retractObject(final InternalFactHandle handle,
+ final PropagationContext context,
+ final InternalWorkingMemory workingMemory) {
// Auto-generated method stub
-
+
}
-
+
}
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/CrossProductTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/CrossProductTest.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/CrossProductTest.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -37,7 +37,7 @@
private Package pkg;
private WorkingMemory workingMemory;
private List values;
-
+
protected void setUp() throws Exception {
super.setUp();
final ObjectType list1ObjectType = new ClassObjectType( String.class );
@@ -58,7 +58,7 @@
final Declaration s1Declaration = rule.getDeclaration( "s1" );
final Declaration s2Declaration = rule.getDeclaration( "s2" );
- values = new ArrayList();
+ this.values = new ArrayList();
rule.setConsequence( new Consequence() {
@@ -71,52 +71,50 @@
final WorkingMemory workingMemory) throws Exception {
final String s1 = (String) knowledgeHelper.get( s1Declaration );
final String s2 = (String) knowledgeHelper.get( s2Declaration );
- values.add( new String[]{s1, s2} );
+ CrossProductTest.this.values.add( new String[]{s1, s2} );
}
} );
- pkg = new Package( "org.drools" );
- pkg.addRule( rule );
+ this.pkg = new Package( "org.drools" );
+ this.pkg.addRule( rule );
}
-
+
public void testNotRemoveIdentities() throws Exception {
// Default is remove identity FALSE
final RuleBase ruleBase = RuleBaseFactory.newRuleBase();
- ruleBase.addPackage( pkg );
+ ruleBase.addPackage( this.pkg );
- workingMemory = ruleBase.newWorkingMemory();
- workingMemory.assertObject( "F1" );
- workingMemory.assertObject( "F2" );
- workingMemory.assertObject( "F3" );
- workingMemory.assertObject( "F4" );
+ this.workingMemory = ruleBase.newWorkingMemory();
+ this.workingMemory.assertObject( "F1" );
+ this.workingMemory.assertObject( "F2" );
+ this.workingMemory.assertObject( "F3" );
+ this.workingMemory.assertObject( "F4" );
- workingMemory.fireAllRules();
+ this.workingMemory.fireAllRules();
// A full cross product is 16, this is just 12
assertEquals( 16,
- values.size() );
+ this.values.size() );
}
-
+
public void testRemoveIdentities() throws Exception {
- System.setProperty( "drools.removeIdentities", "true" );
+ System.setProperty( "drools.removeIdentities",
+ "true" );
final RuleBase ruleBase = RuleBaseFactory.newRuleBase();
- ruleBase.addPackage( pkg );
+ ruleBase.addPackage( this.pkg );
- workingMemory = ruleBase.newWorkingMemory();
- workingMemory.assertObject( "F1" );
- workingMemory.assertObject( "F2" );
- workingMemory.assertObject( "F3" );
- workingMemory.assertObject( "F4" );
+ this.workingMemory = ruleBase.newWorkingMemory();
+ this.workingMemory.assertObject( "F1" );
+ this.workingMemory.assertObject( "F2" );
+ this.workingMemory.assertObject( "F3" );
+ this.workingMemory.assertObject( "F4" );
- workingMemory.fireAllRules();
+ this.workingMemory.fireAllRules();
// A full cross product is 16, this is just 12
assertEquals( 12,
- values.size() );
+ this.values.size() );
}
-
-
-
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/EvalConditionNodeTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/EvalConditionNodeTest.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/EvalConditionNodeTest.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -22,7 +22,6 @@
import org.drools.common.DefaultFactHandle;
import org.drools.common.PropagationContextImpl;
import org.drools.spi.PropagationContext;
-import org.drools.util.LinkedList;
import org.drools.util.TupleHashTable;
public class EvalConditionNodeTest extends DroolsTestCase {
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/ExistsNodeTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/ExistsNodeTest.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/ExistsNodeTest.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -62,13 +62,14 @@
this.workingMemory = new ReteooWorkingMemory( 1,
(ReteooRuleBase) RuleBaseFactory.newRuleBase() );
- RuleBaseConfiguration configuration = new RuleBaseConfiguration();
-
+ final RuleBaseConfiguration configuration = new RuleBaseConfiguration();
+
// string1Declaration is bound to column 3
this.node = new ExistsNode( 15,
- new MockTupleSource( 5 ),
- new MockObjectSource( 8 ),
- new DefaultBetaConstraints( new BetaNodeFieldConstraint[] { this.constraint }, configuration ) );
+ new MockTupleSource( 5 ),
+ new MockObjectSource( 8 ),
+ new DefaultBetaConstraints( new BetaNodeFieldConstraint[]{this.constraint},
+ configuration ) );
this.sink = new MockTupleSink();
this.node.addTupleSink( this.sink );
@@ -119,7 +120,6 @@
assertEquals( new ReteTuple( f0 ),
((Object[]) this.sink.getAsserted().get( 0 ))[0] );
-
// assert tuple, will have matches, so propagate
final DefaultFactHandle f2 = (DefaultFactHandle) this.workingMemory.assertObject( new Cheese( "gouda",
10 ) );
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/FromNodeTest.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -153,7 +153,8 @@
final RuleBaseConfiguration configuration = new RuleBaseConfiguration();
configuration.setIndexRightBetaMemory( false );
configuration.setIndexLeftBetaMemory( false );
- final BetaConstraints betaConstraints = new SingleBetaConstraints( variableConstraint, configuration );
+ final BetaConstraints betaConstraints = new SingleBetaConstraints( variableConstraint,
+ configuration );
final List list = new ArrayList();
final Cheese cheese1 = new Cheese( "cheddar",
@@ -244,7 +245,7 @@
ValueType.STRING_TYPE.getEvaluator( Operator.EQUAL ),
field );
- List list = new ArrayList();
+ final List list = new ArrayList();
final Cheese cheese1 = new Cheese( "stilton",
5 );
final Cheese cheese2 = new Cheese( "stilton",
@@ -281,10 +282,12 @@
assertEquals( 2,
((LinkedList) memory.getCreatedHandles().get( tuple )).size() );
- InternalFactHandle handle1 = (InternalFactHandle) ((LinkedListEntry)((LinkedList) memory.getCreatedHandles().get( tuple )).getFirst()).getObject();
- InternalFactHandle handle2 = (InternalFactHandle) ((LinkedListEntry)((LinkedList) memory.getCreatedHandles().get( tuple )).getLast()).getObject();
- assertEquals( handle1.getObject(), cheese1 );
- assertEquals( handle2.getObject(), cheese2 );
+ final InternalFactHandle handle1 = (InternalFactHandle) ((LinkedListEntry) ((LinkedList) memory.getCreatedHandles().get( tuple )).getFirst()).getObject();
+ final InternalFactHandle handle2 = (InternalFactHandle) ((LinkedListEntry) ((LinkedList) memory.getCreatedHandles().get( tuple )).getLast()).getObject();
+ assertEquals( handle1.getObject(),
+ cheese1 );
+ assertEquals( handle2.getObject(),
+ cheese2 );
from.retractTuple( tuple,
context,
@@ -294,7 +297,6 @@
assertNull( memory.getFactHandleMemory() );
}
-
public static class MockDataProvider
implements
DataProvider {
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/JoinNodeTest.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -60,13 +60,14 @@
this.tupleSource = new MockTupleSource( 4 );
this.objectSource = new MockObjectSource( 4 );
this.sink = new MockTupleSink();
-
- RuleBaseConfiguration configuration = new RuleBaseConfiguration();
+ final RuleBaseConfiguration configuration = new RuleBaseConfiguration();
+
this.node = new JoinNode( 15,
this.tupleSource,
this.objectSource,
- new DefaultBetaConstraints( new BetaNodeFieldConstraint[]{this.constraint}, configuration ) );
+ new DefaultBetaConstraints( new BetaNodeFieldConstraint[]{this.constraint},
+ configuration ) );
this.node.addTupleSink( this.sink );
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/LeftInputAdapterNodeTest.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -257,7 +257,7 @@
assertFalse( map.contains( f0 ) );
assertNotSame( tuple,
- ((Object[]) sink.getRetracted().get( 0 ))[0] );
+ ((Object[]) sink.getRetracted().get( 0 ))[0] );
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/LogicalAssertionTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/LogicalAssertionTest.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/LogicalAssertionTest.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -51,9 +51,9 @@
final Rule rule1 = new Rule( "test-rule1" );
final RuleTerminalNode node = new RuleTerminalNode( 2,
- new MockTupleSource( 2 ),
- rule1,
- rule1.getLhs());
+ new MockTupleSource( 2 ),
+ rule1,
+ rule1.getLhs() );
final ReteooWorkingMemory workingMemory = (ReteooWorkingMemory) ruleBase.newWorkingMemory();
final InternalAgenda agenda = (InternalAgenda) workingMemory.getAgenda();
@@ -150,9 +150,9 @@
objectTypeNode.addObjectSink( sink );
final RuleTerminalNode node = new RuleTerminalNode( 2,
- new MockTupleSource( 2 ),
- rule1,
- rule1.getLhs() );
+ new MockTupleSource( 2 ),
+ rule1,
+ rule1.getLhs() );
final RuleBase ruleBase = RuleBaseFactory.newRuleBase();
final ReteooWorkingMemory workingMemory = (ReteooWorkingMemory) ruleBase.newWorkingMemory();
@@ -238,9 +238,9 @@
final MockObjectSink sink = new MockObjectSink();
objectTypeNode.addObjectSink( sink );
final RuleTerminalNode node = new RuleTerminalNode( 2,
- new MockTupleSource( 2 ),
- rule1,
- rule1.getLhs() );
+ new MockTupleSource( 2 ),
+ rule1,
+ rule1.getLhs() );
final RuleBase ruleBase = RuleBaseFactory.newRuleBase();
final ReteooWorkingMemory workingMemory = (ReteooWorkingMemory) ruleBase.newWorkingMemory();
@@ -372,9 +372,9 @@
final MockObjectSink sink = new MockObjectSink();
objectTypeNode.addObjectSink( sink );
final RuleTerminalNode node = new RuleTerminalNode( 2,
- new MockTupleSource( 2 ),
- rule1,
- rule1.getLhs() );
+ new MockTupleSource( 2 ),
+ rule1,
+ rule1.getLhs() );
final RuleBaseConfiguration conf = new RuleBaseConfiguration();
conf.setLogicalOverride( RuleBaseConfiguration.LogicalOverride.PRESERVE );
@@ -462,9 +462,9 @@
final MockObjectSink sink = new MockObjectSink();
objectTypeNode.addObjectSink( sink );
final RuleTerminalNode node = new RuleTerminalNode( 2,
- new MockTupleSource( 2 ),
- rule1,
- rule1.getLhs() );
+ new MockTupleSource( 2 ),
+ rule1,
+ rule1.getLhs() );
final RuleBase ruleBase = RuleBaseFactory.newRuleBase();
final ReteooWorkingMemory workingMemory = (ReteooWorkingMemory) ruleBase.newWorkingMemory();
@@ -507,9 +507,9 @@
// create the second activation to justify the "logical" fact
final Rule rule2 = new Rule( "test-rule2" );
final RuleTerminalNode node2 = new RuleTerminalNode( 4,
- new MockTupleSource( 3 ),
- rule2,
- rule2.getLhs() );
+ new MockTupleSource( 3 ),
+ rule2,
+ rule2.getLhs() );
rule2.setConsequence( consequence );
final DefaultFactHandle handle2 = new DefaultFactHandle( 2,
@@ -560,9 +560,9 @@
final MockObjectSink sink = new MockObjectSink();
objectTypeNode.addObjectSink( sink );
final RuleTerminalNode node = new RuleTerminalNode( 2,
- new MockTupleSource( 2 ),
- rule1,
- rule1.getLhs() );
+ new MockTupleSource( 2 ),
+ rule1,
+ rule1.getLhs() );
final ReteooWorkingMemory workingMemory = (ReteooWorkingMemory) ruleBase.newWorkingMemory();
final Agenda agenda = workingMemory.getAgenda();
@@ -598,9 +598,9 @@
// Create the second justifer
final Rule rule2 = new Rule( "test-rule2" );
final RuleTerminalNode node2 = new RuleTerminalNode( 4,
- new MockTupleSource( 3 ),
- rule2,
- rule2.getLhs() );
+ new MockTupleSource( 3 ),
+ rule2,
+ rule2.getLhs() );
rule2.setConsequence( consequence );
final DefaultFactHandle handle2 = new DefaultFactHandle( 2,
@@ -687,9 +687,9 @@
final MockObjectSink sink = new MockObjectSink();
objectTypeNode.addObjectSink( sink );
final RuleTerminalNode node = new RuleTerminalNode( 2,
- new MockTupleSource( 2 ),
- rule1,
- rule1.getLhs() );
+ new MockTupleSource( 2 ),
+ rule1,
+ rule1.getLhs() );
final RuleBase ruleBase = RuleBaseFactory.newRuleBase();
final ReteooWorkingMemory workingMemory = (ReteooWorkingMemory) ruleBase.newWorkingMemory();
@@ -781,14 +781,14 @@
final ObjectTypeNode objectTypeNode = new ObjectTypeNode( 0,
new ClassObjectType( String.class ),
rete,
- 3);
+ 3 );
objectTypeNode.attach();
final MockObjectSink sink = new MockObjectSink();
objectTypeNode.addObjectSink( sink );
final RuleTerminalNode node = new RuleTerminalNode( 2,
- new MockTupleSource( 2 ),
- rule1,
- rule1.getLhs() );
+ new MockTupleSource( 2 ),
+ rule1,
+ rule1.getLhs() );
final RuleBase ruleBase = RuleBaseFactory.newRuleBase();
final ReteooWorkingMemory workingMemory = (ReteooWorkingMemory) ruleBase.newWorkingMemory();
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/MockTupleSink.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -39,9 +39,9 @@
private final List asserted = new ArrayList();
private final List retracted = new ArrayList();
- private TupleSinkNode previousTupleSinkNode;
- private TupleSinkNode nextTupleSinkNode;
-
+ private TupleSinkNode previousTupleSinkNode;
+ private TupleSinkNode nextTupleSinkNode;
+
public MockTupleSink() {
super( 0 );
}
@@ -116,7 +116,7 @@
// TODO Auto-generated method stub
return Collections.EMPTY_LIST;
}
-
+
/**
* Returns the next node
* @return
@@ -151,6 +151,6 @@
*/
public void setPreviousTupleSinkNode(final TupleSinkNode previous) {
this.previousTupleSinkNode = previous;
- }
+ }
}
\ No newline at end of file
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/NotNodeTest.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -32,7 +32,6 @@
import org.drools.common.PropagationContextImpl;
import org.drools.rule.Rule;
import org.drools.spi.BetaNodeFieldConstraint;
-import org.drools.spi.AlphaNodeFieldConstraint;
import org.drools.spi.MockConstraint;
import org.drools.spi.PropagationContext;
@@ -61,13 +60,14 @@
this.workingMemory = new ReteooWorkingMemory( 1,
(ReteooRuleBase) RuleBaseFactory.newRuleBase() );
- RuleBaseConfiguration configuration = new RuleBaseConfiguration();
-
+ final RuleBaseConfiguration configuration = new RuleBaseConfiguration();
+
// string1Declaration is bound to column 3
this.node = new NotNode( 15,
new MockTupleSource( 5 ),
new MockObjectSource( 8 ),
- new DefaultBetaConstraints( new BetaNodeFieldConstraint[] { this.constraint }, configuration ) );
+ new DefaultBetaConstraints( new BetaNodeFieldConstraint[]{this.constraint},
+ configuration ) );
this.sink = new MockTupleSink();
this.node.addTupleSink( this.sink );
@@ -297,15 +297,16 @@
Assert.fail( "No exception should be raised in this procedure, but got: " + e.toString() );
}
}
-
public void testGetConstraints_ReturnsNullEvenWithEmptyBinder() {
- BetaConstraints nullConstraints = EmptyBetaConstraints.getInstance();
- NotNode notNode = new NotNode( 1,
- this.tupleSource,
- this.objectSource, nullConstraints);
- BetaNodeFieldConstraint[] constraints = notNode.getConstraints();
- assertEquals( 0, constraints.length );
+ final BetaConstraints nullConstraints = EmptyBetaConstraints.getInstance();
+ final NotNode notNode = new NotNode( 1,
+ this.tupleSource,
+ this.objectSource,
+ nullConstraints );
+ final BetaNodeFieldConstraint[] constraints = notNode.getConstraints();
+ assertEquals( 0,
+ constraints.length );
}
}
\ No newline at end of file
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/ObjectSourceTest.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -42,7 +42,8 @@
field.setAccessible( true );
ObjectSinkPropagator sink = (ObjectSinkPropagator) field.get( source );
- assertSame( EmptyObjectSinkAdapter.getInstance(), sink );
+ assertSame( EmptyObjectSinkAdapter.getInstance(),
+ sink );
final MockObjectSink sink1 = new MockObjectSink();
source.addObjectSink( sink1 );
@@ -85,6 +86,6 @@
assertSame( EmptyObjectSinkAdapter.getInstance(),
sink );
assertEquals( 0,
- 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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/ObjectTypeNodeTest.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -45,7 +45,7 @@
final ObjectTypeNode objectTypeNode = new ObjectTypeNode( 1,
objectType,
source,
- 3);
+ 3 );
assertEquals( 1,
objectTypeNode.getId() );
@@ -116,7 +116,7 @@
final ObjectTypeNode objectTypeNode = new ObjectTypeNode( 1,
new ClassObjectType( String.class ),
new Rete(),
- 3);
+ 3 );
final FactHashTable memory = (FactHashTable) workingMemory.getNodeMemory( objectTypeNode );
@@ -130,7 +130,7 @@
ObjectTypeNode objectTypeNode = new ObjectTypeNode( 1,
new ClassObjectType( String.class ),
source,
- 3);
+ 3 );
assertFalse( objectTypeNode.matches( new Object() ) );
assertFalse( objectTypeNode.matches( new Integer( 5 ) ) );
@@ -139,7 +139,7 @@
objectTypeNode = new ObjectTypeNode( 1,
new ClassObjectType( Object.class ),
source,
- 3);
+ 3 );
assertTrue( objectTypeNode.matches( new Object() ) );
assertTrue( objectTypeNode.matches( new Integer( 5 ) ) );
@@ -161,7 +161,7 @@
final ObjectTypeNode objectTypeNode = new ObjectTypeNode( 1,
new ClassObjectType( String.class ),
source,
- 3);
+ 3 );
final MockObjectSink sink = new MockObjectSink();
objectTypeNode.addObjectSink( sink );
@@ -213,7 +213,7 @@
final ObjectTypeNode objectTypeNode = new ObjectTypeNode( 1,
new ClassObjectType( String.class ),
source,
- 3);
+ 3 );
final MockObjectSink sink1 = new MockObjectSink();
objectTypeNode.addObjectSink( sink1 );
@@ -285,7 +285,7 @@
new ClassObjectType( Cheese.class,
shadowClass ),
source,
- 3);
+ 3 );
final MockObjectSink sink = new MockObjectSink();
objectTypeNode.addObjectSink( sink );
@@ -332,7 +332,7 @@
new ClassObjectType( Person.class,
shadowClass ),
source,
- 3);
+ 3 );
final MockObjectSink sink = new MockObjectSink();
objectTypeNode.addObjectSink( sink );
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/OtherwiseTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/OtherwiseTest.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/OtherwiseTest.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -1,7 +1,5 @@
package org.drools.reteoo;
-import java.util.Map;
-
import org.drools.Otherwise;
import org.drools.RuleBase;
import org.drools.RuleBaseFactory;
@@ -9,11 +7,9 @@
import org.drools.base.ClassObjectType;
import org.drools.base.ShadowProxyFactory;
import org.drools.base.TestBean;
-import org.drools.examples.manners.Context;
import org.drools.rule.Column;
import org.drools.rule.Package;
import org.drools.rule.Rule;
-import org.drools.rule.RuleConditionElement;
import org.drools.spi.Consequence;
import org.drools.spi.KnowledgeHelper;
@@ -27,106 +23,99 @@
public void testOneRuleFiringNoOtherwise() throws Exception {
final RuleBase ruleBase = RuleBaseFactory.newRuleBase( RuleBase.RETEOO );
-
- Package pkg = new Package( "Miss Manners" );
- Rule rule1 = getRule("rule1");
+
+ final Package pkg = new Package( "Miss Manners" );
+ final Rule rule1 = getRule( "rule1" );
pkg.addRule( rule1 );
-
- Rule ruleOtherwise = getOtherwise("rule2");
+
+ final Rule ruleOtherwise = getOtherwise( "rule2" );
pkg.addRule( ruleOtherwise );
-
+
ruleBase.addPackage( pkg );
-
+
final WorkingMemory workingMemory = ruleBase.newWorkingMemory();
workingMemory.assertObject( new TestBean() );
workingMemory.fireAllRules();
-
-
- assertTrue(((MockConsequence) rule1.getConsequence()).fired);
- assertFalse(((MockConsequence) ruleOtherwise.getConsequence()).fired);
-
+
+ assertTrue( ((MockConsequence) rule1.getConsequence()).fired );
+ assertFalse( ((MockConsequence) ruleOtherwise.getConsequence()).fired );
+
}
-
+
public void testTwoRulesFiringNoOtherwise() throws Exception {
final RuleBase ruleBase = RuleBaseFactory.newRuleBase( RuleBase.RETEOO );
-
- Package pkg = new Package( "Miss Manners" );
- Rule rule1 = getRule("rule1");
+
+ final Package pkg = new Package( "Miss Manners" );
+ final Rule rule1 = getRule( "rule1" );
pkg.addRule( rule1 );
- Rule rule2 = getRule("rule2");
+ final Rule rule2 = getRule( "rule2" );
pkg.addRule( rule2 );
-
- Rule ruleOtherwise = getOtherwise("ruleOtherwise");
+
+ final Rule ruleOtherwise = getOtherwise( "ruleOtherwise" );
pkg.addRule( ruleOtherwise );
-
+
ruleBase.addPackage( pkg );
-
+
final WorkingMemory workingMemory = ruleBase.newWorkingMemory();
workingMemory.assertObject( new TestBean() );
workingMemory.fireAllRules();
-
- assertFalse(((MockConsequence) ruleOtherwise.getConsequence()).fired);
- assertTrue(((MockConsequence) rule1.getConsequence()).fired);
- assertTrue(((MockConsequence) rule2.getConsequence()).fired);
-
+
+ assertFalse( ((MockConsequence) ruleOtherwise.getConsequence()).fired );
+ assertTrue( ((MockConsequence) rule1.getConsequence()).fired );
+ assertTrue( ((MockConsequence) rule2.getConsequence()).fired );
+
}
-
+
public void testOtherwiseFiringWithOneRule() throws Exception {
final RuleBase ruleBase = RuleBaseFactory.newRuleBase( RuleBase.RETEOO );
-
- Package pkg = new Package( "Miss Manners" );
- Rule rule1 = getRule("rule1");
+
+ final Package pkg = new Package( "Miss Manners" );
+ final Rule rule1 = getRule( "rule1" );
pkg.addRule( rule1 );
-
- Rule ruleOtherwise = getOtherwise("rule2");
+
+ final Rule ruleOtherwise = getOtherwise( "rule2" );
pkg.addRule( ruleOtherwise );
-
+
ruleBase.addPackage( pkg );
-
+
final WorkingMemory workingMemory = ruleBase.newWorkingMemory();
-
+
workingMemory.fireAllRules();
-
-
- assertFalse(((MockConsequence) rule1.getConsequence()).fired);
- assertTrue(((MockConsequence) ruleOtherwise.getConsequence()).fired);
-
+
+ assertFalse( ((MockConsequence) rule1.getConsequence()).fired );
+ assertTrue( ((MockConsequence) ruleOtherwise.getConsequence()).fired );
+
}
-
+
public void testOtherwiseFiringMultipleRules() throws Exception {
final RuleBase ruleBase = RuleBaseFactory.newRuleBase( RuleBase.RETEOO );
-
- Package pkg = new Package( "Miss Manners" );
- Rule rule1 = getRule("rule1");
+
+ final Package pkg = new Package( "Miss Manners" );
+ final Rule rule1 = getRule( "rule1" );
pkg.addRule( rule1 );
- Rule rule2 = getRule("rule2");
+ final Rule rule2 = getRule( "rule2" );
pkg.addRule( rule2 );
-
- Rule ruleOtherwise1 = getOtherwise("other1");
+
+ final Rule ruleOtherwise1 = getOtherwise( "other1" );
pkg.addRule( ruleOtherwise1 );
- Rule ruleOtherwise2 = getOtherwise("other2");
+ final Rule ruleOtherwise2 = getOtherwise( "other2" );
pkg.addRule( ruleOtherwise2 );
-
-
ruleBase.addPackage( pkg );
-
+
final WorkingMemory workingMemory = ruleBase.newWorkingMemory();
-
+
workingMemory.fireAllRules();
-
-
- assertFalse(((MockConsequence) rule1.getConsequence()).fired);
- assertFalse(((MockConsequence) rule2.getConsequence()).fired);
- assertTrue(((MockConsequence) ruleOtherwise1.getConsequence()).fired);
- assertTrue(((MockConsequence) ruleOtherwise2.getConsequence()).fired);
-
- }
+ assertFalse( ((MockConsequence) rule1.getConsequence()).fired );
+ assertFalse( ((MockConsequence) rule2.getConsequence()).fired );
+ assertTrue( ((MockConsequence) ruleOtherwise1.getConsequence()).fired );
+ assertTrue( ((MockConsequence) ruleOtherwise2.getConsequence()).fired );
-
- private Rule getOtherwise(String name) {
- Rule rule = new Rule( name );
+ }
+
+ private Rule getOtherwise(final String name) {
+ final Rule rule = new Rule( name );
final Column pat = new Column( 0,
new ClassObjectType( Otherwise.class,
ShadowProxyFactory.getProxy( Otherwise.class ) ) );
@@ -135,28 +124,30 @@
return rule;
}
- private Rule getRule(String name) {
- Rule rule = new Rule( name );
-
+ private Rule getRule(final String name) {
+ final Rule rule = new Rule( name );
+
final Column pat = new Column( 0,
- new ClassObjectType( TestBean.class,
- ShadowProxyFactory.getProxy( TestBean.class ) ) );
-
+ new ClassObjectType( TestBean.class,
+ ShadowProxyFactory.getProxy( TestBean.class ) ) );
+
rule.addPattern( pat );
- rule.setConsequence(new MockConsequence());
-
+ rule.setConsequence( new MockConsequence() );
+
return rule;
}
-
- static class MockConsequence implements Consequence {
+ static class MockConsequence
+ implements
+ Consequence {
+
public boolean fired = false;
-
- public void evaluate(KnowledgeHelper knowledgeHelper,
- WorkingMemory workingMemory) throws Exception {
- fired = true;
+
+ public void evaluate(final KnowledgeHelper knowledgeHelper,
+ final WorkingMemory workingMemory) throws Exception {
+ this.fired = true;
}
-
+
}
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/PropertyChangeListenerTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/PropertyChangeListenerTest.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/PropertyChangeListenerTest.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -19,7 +19,7 @@
final ObjectTypeNode objectTypeNode = new ObjectTypeNode( 1,
new ClassObjectType( State.class ),
rete,
- 3);
+ 3 );
objectTypeNode.attach();
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/QueryTerminalNodeTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/QueryTerminalNodeTest.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/QueryTerminalNodeTest.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -42,14 +42,14 @@
public class QueryTerminalNodeTest extends TestCase {
public void testQueryTerminalNode() {
final ReteooRuleBase ruleBase = (ReteooRuleBase) RuleBaseFactory.newRuleBase();
-
+
final Rete rete = ruleBase.getRete();
final ClassObjectType queryObjectType = new ClassObjectType( DroolsQuery.class );
final ObjectTypeNode queryObjectTypeNode = new ObjectTypeNode( 1,
queryObjectType,
rete,
- 3);
+ 3 );
queryObjectTypeNode.attach();
ClassFieldExtractor extractor = new ClassFieldExtractor( DroolsQuery.class,
@@ -75,7 +75,7 @@
final ObjectTypeNode cheeseObjectTypeNode = new ObjectTypeNode( 4,
cheeseObjectType,
rete,
- 3);
+ 3 );
cheeseObjectTypeNode.attach();
extractor = new ClassFieldExtractor( Cheese.class,
@@ -102,22 +102,23 @@
final QueryTerminalNode queryNode = new QueryTerminalNode( 7,
joinNode,
query,
- query.getLhs());
+ query.getLhs() );
queryNode.attach();
- final org.drools.rule.Package pkg = new org.drools.rule.Package("com.drools.test");
+ final org.drools.rule.Package pkg = new org.drools.rule.Package( "com.drools.test" );
pkg.addRule( query );
-
+
try {
- Field pkgField = ruleBase.getClass().getSuperclass().getDeclaredField( "pkgs" );
+ final Field pkgField = ruleBase.getClass().getSuperclass().getDeclaredField( "pkgs" );
pkgField.setAccessible( true );
- Map pkgs = (Map) pkgField.get( ruleBase );
- pkgs.put( pkg.getName(), pkg );
- } catch ( Exception e ) {
- Assert.fail("Should not throw any exception: "+e.getMessage());
+ final Map pkgs = (Map) pkgField.get( ruleBase );
+ pkgs.put( pkg.getName(),
+ pkg );
+ } catch ( final Exception e ) {
+ Assert.fail( "Should not throw any exception: " + e.getMessage() );
}
-
+
final WorkingMemory workingMemory = ruleBase.newWorkingMemory();
QueryResults results = workingMemory.getQueryResults( "query-1" );
@@ -156,13 +157,13 @@
assertEquals( 1,
result.size() );
assertEquals( stilton2,
- result.get( 0 ) );
+ result.get( 0 ) );
result = results.get( 1 );
assertEquals( 1,
result.size() );
assertEquals( stilton1,
- result.get( 0 ) );
+ result.get( 0 ) );
int i = 0;
for ( final Iterator it = results.iterator(); it.hasNext(); ) {
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/ReteTest.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -50,13 +50,13 @@
final ObjectTypeNode objectTypeNode = new ObjectTypeNode( 1,
new ClassObjectType( Object.class ),
rete,
- 3);
+ 3 );
objectTypeNode.attach();
final ObjectTypeNode stringTypeNode = new ObjectTypeNode( 2,
new ClassObjectType( String.class ),
rete,
- 3);
+ 3 );
stringTypeNode.attach();
final Field field = Rete.class.getDeclaredField( "objectTypeNodes" );
@@ -86,7 +86,7 @@
ObjectTypeNode objectTypeNode = new ObjectTypeNode( 1,
new ClassObjectType( List.class ),
rete,
- 3);
+ 3 );
objectTypeNode.attach();
MockObjectSink sink = new MockObjectSink();
objectTypeNode.addObjectSink( sink );
@@ -94,7 +94,7 @@
objectTypeNode = new ObjectTypeNode( 1,
new ClassObjectType( Collection.class ),
rete,
- 3);
+ 3 );
objectTypeNode.attach();
sink = new MockObjectSink();
objectTypeNode.addObjectSink( sink );
@@ -102,7 +102,7 @@
objectTypeNode = new ObjectTypeNode( 1,
new ClassObjectType( ArrayList.class ),
rete,
- 3);
+ 3 );
objectTypeNode.attach();
sink = new MockObjectSink();
objectTypeNode.addObjectSink( sink );
@@ -111,13 +111,19 @@
final DefaultFactHandle h1 = new DefaultFactHandle( 1,
new ArrayList() );
rete.assertObject( h1,
- new PropagationContextImpl(0, PropagationContext.ASSERTION, null, null),
+ new PropagationContextImpl( 0,
+ PropagationContext.ASSERTION,
+ null,
+ null ),
workingMemory );
// LinkedList matches two ObjectTypeNodes
h1.setObject( new LinkedList() );
rete.assertObject( h1,
- new PropagationContextImpl(0, PropagationContext.ASSERTION, null, null),
+ new PropagationContextImpl( 0,
+ PropagationContext.ASSERTION,
+ null,
+ null ),
workingMemory );
final ObjectHashMap map = (ObjectHashMap) workingMemory.getNodeMemory( rete );
@@ -144,7 +150,7 @@
final ObjectTypeNode objectTypeNode = new ObjectTypeNode( 1,
new ClassObjectType( List.class ),
rete,
- 3);
+ 3 );
objectTypeNode.attach();
final MockObjectSink sink1 = new MockObjectSink();
objectTypeNode.addObjectSink( sink1 );
@@ -168,7 +174,10 @@
list );
rete.assertObject( h2,
- new PropagationContextImpl(0, PropagationContext.ASSERTION, null, null),
+ new PropagationContextImpl( 0,
+ PropagationContext.ASSERTION,
+ null,
+ null ),
workingMemory );
final List asserted = sink1.getAsserted();
@@ -194,7 +203,7 @@
final ObjectTypeNode objectTypeNode = new ObjectTypeNode( 1,
new ClassObjectType( List.class ),
rete,
- 3);
+ 3 );
objectTypeNode.attach();
final MockObjectSink sink1 = new MockObjectSink();
objectTypeNode.addObjectSink( sink1 );
@@ -217,11 +226,17 @@
// need to assert first, to force it to build up the cache
rete.assertObject( h2,
- new PropagationContextImpl(0, PropagationContext.ASSERTION, null, null),
+ new PropagationContextImpl( 0,
+ PropagationContext.ASSERTION,
+ null,
+ null ),
workingMemory );
rete.retractObject( h2,
- new PropagationContextImpl(0, PropagationContext.ASSERTION, null, null),
+ new PropagationContextImpl( 0,
+ PropagationContext.ASSERTION,
+ null,
+ null ),
workingMemory );
final List retracted = sink1.getRetracted();
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/RuleFlowGroupTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/RuleFlowGroupTest.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/RuleFlowGroupTest.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -55,7 +55,7 @@
public class RuleFlowGroupTest extends DroolsTestCase {
- public void testRuleFlowGroup() {
+ public void testRuleFlowGroup() {
final RuleBase ruleBase = RuleBaseFactory.newRuleBase();
final ReteooWorkingMemory workingMemory = (ReteooWorkingMemory) ruleBase.newWorkingMemory();
@@ -121,53 +121,69 @@
null );
// nodes
- IStartNode start = new StartNode();
- IRuleSetNode ruleSet0 = new RuleSetNode();
- ruleSet0.setRuleFlowGroup("rule-flow-group-0");
- IRuleSetNode ruleSet1 = new RuleSetNode();
- ruleSet1.setRuleFlowGroup("rule-flow-group-1");
- IRuleSetNode ruleSet2 = new RuleSetNode();
- ruleSet2.setRuleFlowGroup("rule-flow-group-2");
- IRuleSetNode ruleSet3 = new RuleSetNode();
- ruleSet3.setRuleFlowGroup("rule-flow-group-3");
- ISplit split = new Split();
- split.setType(ISplit.TYPE_AND);
- IJoin join = new Join();
- join.setType(IJoin.TYPE_AND);
- IEndNode end = new EndNode();
+ final IStartNode start = new StartNode();
+ final IRuleSetNode ruleSet0 = new RuleSetNode();
+ ruleSet0.setRuleFlowGroup( "rule-flow-group-0" );
+ final IRuleSetNode ruleSet1 = new RuleSetNode();
+ ruleSet1.setRuleFlowGroup( "rule-flow-group-1" );
+ final IRuleSetNode ruleSet2 = new RuleSetNode();
+ ruleSet2.setRuleFlowGroup( "rule-flow-group-2" );
+ final IRuleSetNode ruleSet3 = new RuleSetNode();
+ ruleSet3.setRuleFlowGroup( "rule-flow-group-3" );
+ final ISplit split = new Split();
+ split.setType( ISplit.TYPE_AND );
+ final IJoin join = new Join();
+ join.setType( IJoin.TYPE_AND );
+ final IEndNode end = new EndNode();
// connections
- new Connection(start, ruleSet0, IConnection.TYPE_NORMAL);
- new Connection(ruleSet0, split, IConnection.TYPE_NORMAL);
- new Connection(split, ruleSet1, IConnection.TYPE_NORMAL);
- new Connection(split, ruleSet2, IConnection.TYPE_NORMAL);
- new Connection(ruleSet1, join, IConnection.TYPE_NORMAL);
- new Connection(ruleSet2, join, IConnection.TYPE_NORMAL);
- new Connection(join, ruleSet3, IConnection.TYPE_NORMAL);
- new Connection(ruleSet3, end, IConnection.TYPE_NORMAL);
-
+ new Connection( start,
+ ruleSet0,
+ IConnection.TYPE_NORMAL );
+ new Connection( ruleSet0,
+ split,
+ IConnection.TYPE_NORMAL );
+ new Connection( split,
+ ruleSet1,
+ IConnection.TYPE_NORMAL );
+ new Connection( split,
+ ruleSet2,
+ IConnection.TYPE_NORMAL );
+ new Connection( ruleSet1,
+ join,
+ IConnection.TYPE_NORMAL );
+ new Connection( ruleSet2,
+ join,
+ IConnection.TYPE_NORMAL );
+ new Connection( join,
+ ruleSet3,
+ IConnection.TYPE_NORMAL );
+ new Connection( ruleSet3,
+ end,
+ IConnection.TYPE_NORMAL );
+
// process
- IRuleFlowProcess process = new RuleFlowProcess();
- process.addNode(start);
- process.addNode(ruleSet0);
- process.addNode(ruleSet1);
- process.addNode(ruleSet2);
- process.addNode(ruleSet3);
- process.addNode(split);
- process.addNode(join);
- process.addNode(end);
+ final IRuleFlowProcess process = new RuleFlowProcess();
+ process.addNode( start );
+ process.addNode( ruleSet0 );
+ process.addNode( ruleSet1 );
+ process.addNode( ruleSet2 );
+ process.addNode( ruleSet3 );
+ process.addNode( split );
+ process.addNode( join );
+ process.addNode( end );
// proces instance
- IRuleFlowProcessInstance processInstance = new RuleFlowProcessInstance();
- processInstance.setAgenda(agenda);
- processInstance.setProcess(process);
+ final IRuleFlowProcessInstance processInstance = new RuleFlowProcessInstance();
+ processInstance.setAgenda( agenda );
+ processInstance.setProcess( process );
assertEquals( IProcessInstance.STATE_PENDING,
- processInstance.getState() );
-
+ processInstance.getState() );
+
final RuleFlowGroupImpl ruleFlowGroup0 = (RuleFlowGroupImpl) agenda.getRuleFlowGroup( "rule-flow-group-0" );
final RuleFlowGroupImpl ruleFlowGroup1 = (RuleFlowGroupImpl) agenda.getRuleFlowGroup( "rule-flow-group-1" );
final RuleFlowGroupImpl ruleFlowGroup2 = (RuleFlowGroupImpl) agenda.getRuleFlowGroup( "rule-flow-group-2" );
final RuleFlowGroupImpl ruleFlowGroup3 = (RuleFlowGroupImpl) agenda.getRuleFlowGroup( "rule-flow-group-3" );
-
+
final ReteTuple tuple0 = new ReteTuple( new DefaultFactHandle( 1,
"cheese" ) );
node0.assertTuple( tuple0,
@@ -193,10 +209,10 @@
workingMemory );
final ReteTuple tuple4 = new ReteTuple( new DefaultFactHandle( 1,
- "cheese" ) );
- node3.assertTuple( tuple4,
- context0,
- workingMemory );
+ "cheese" ) );
+ node3.assertTuple( tuple4,
+ context0,
+ workingMemory );
// RuleFlowGroups should be populated, but the agenda shouldn't
assertEquals( 2,
@@ -204,9 +220,9 @@
assertEquals( 1,
ruleFlowGroup1.size() );
assertEquals( 1,
- ruleFlowGroup2.size() );
+ ruleFlowGroup2.size() );
assertEquals( 1,
- ruleFlowGroup3.size() );
+ ruleFlowGroup3.size() );
assertEquals( 0,
agenda.agendaSize() );
@@ -214,7 +230,7 @@
// but should now also be in the Agenda
processInstance.start();
assertEquals( IProcessInstance.STATE_ACTIVE,
- processInstance.getState() );
+ processInstance.getState() );
assertEquals( 2,
ruleFlowGroup0.size() );
assertEquals( 2,
@@ -235,45 +251,45 @@
assertEquals( 1,
ruleFlowGroup1.size() );
assertEquals( 1,
- ruleFlowGroup2.size() );
+ ruleFlowGroup2.size() );
assertEquals( 2,
- agenda.agendaSize() );
+ agenda.agendaSize() );
// we set the salience higher on rule2, so it sould fire first and empty ruleFlowGroup2
agenda.fireNextItem( null );
assertEquals( 1,
ruleFlowGroup1.size() );
assertEquals( 0,
- ruleFlowGroup2.size() );
+ ruleFlowGroup2.size() );
assertEquals( 1,
agenda.agendaSize() );
-
+
// executing rule1, which should activate AND-join and thus group 3
agenda.fireNextItem( null );
assertEquals( 0,
- ruleFlowGroup0.size() );
+ ruleFlowGroup0.size() );
assertEquals( 0,
ruleFlowGroup1.size() );
assertEquals( 0,
- ruleFlowGroup2.size() );
+ ruleFlowGroup2.size() );
assertEquals( 1,
- ruleFlowGroup3.size() );
+ ruleFlowGroup3.size() );
assertEquals( 1,
- agenda.agendaSize() );
-
+ agenda.agendaSize() );
+
// executing rule3, and finishing execution
agenda.fireNextItem( null );
assertEquals( 0,
- ruleFlowGroup0.size() );
+ ruleFlowGroup0.size() );
assertEquals( 0,
ruleFlowGroup1.size() );
assertEquals( 0,
- ruleFlowGroup2.size() );
+ ruleFlowGroup2.size() );
assertEquals( 0,
- ruleFlowGroup3.size() );
+ ruleFlowGroup3.size() );
assertEquals( 0,
agenda.agendaSize() );
assertEquals( IProcessInstance.STATE_COMPLETED,
- processInstance.getState() );
+ processInstance.getState() );
}
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/SchedulerTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/SchedulerTest.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/SchedulerTest.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -44,9 +44,9 @@
final Rule rule = new Rule( "test-rule" );
final RuleTerminalNode node = new RuleTerminalNode( 1,
- new MockTupleSource( 2 ),
- rule,
- rule.getLhs());
+ new MockTupleSource( 2 ),
+ rule,
+ rule.getLhs() );
final List data = new ArrayList();
// add consequence
@@ -107,9 +107,9 @@
final Rule rule = new Rule( "test-rule" );
final RuleTerminalNode node = new RuleTerminalNode( 1,
- new MockTupleSource( 2 ),
- rule,
- rule.getLhs());
+ new MockTupleSource( 2 ),
+ rule,
+ rule.getLhs() );
final List data = new ArrayList();
/* 1/10th of a second */
@@ -186,9 +186,9 @@
final List data = new ArrayList();
final RuleTerminalNode node = new RuleTerminalNode( 1,
- new MockTupleSource( 2 ),
- rule,
- rule.getLhs());
+ new MockTupleSource( 2 ),
+ rule,
+ rule.getLhs() );
/* 1/10th of a second */
final Duration duration = new Duration() {
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/TupleSourceTest.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -36,7 +36,8 @@
field.setAccessible( true );
TupleSinkPropagator sink = (TupleSinkPropagator) field.get( source );
- assertSame( EmptyTupleSinkAdapter.getInstance(), sink );
+ assertSame( EmptyTupleSinkAdapter.getInstance(),
+ sink );
final MockTupleSink sink1 = new MockTupleSink();
source.addTupleSink( sink1 );
@@ -73,13 +74,13 @@
sink.getClass() );
assertEquals( 1,
sink.getSinks().length );
-
+
source.removeTupleSink( sink3 );
sink = (TupleSinkPropagator) field.get( source );
assertSame( EmptyTupleSinkAdapter.getInstance(),
sink );
assertEquals( 0,
- sink.getSinks().length );
+ sink.getSinks().length );
}
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/builder/ReteooRuleBuilderTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/builder/ReteooRuleBuilderTest.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/builder/ReteooRuleBuilderTest.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -21,7 +21,6 @@
import org.drools.WorkingMemory;
import org.drools.base.ClassObjectType;
-import org.drools.reteoo.JoinNode;
import org.drools.reteoo.ReteooBuilder;
import org.drools.reteoo.ReteooRuleBase;
import org.drools.reteoo.RuleTerminalNode;
@@ -49,8 +48,8 @@
protected void setUp() throws Exception {
super.setUp();
- builder = new ReteooRuleBuilder();
- rulebase = new ReteooRuleBase( "default" );
+ this.builder = new ReteooRuleBuilder();
+ this.rulebase = new ReteooRuleBase( "default" );
}
/* (non-Javadoc)
@@ -64,40 +63,42 @@
* Test method for {@link org.drools.reteoo.builder.ReteooRuleBuilder#addRule(org.drools.rule.Rule, org.drools.reteoo.ReteooRuleBase, java.util.Map, int)}.
*/
public void testAddRuleWithColumns() {
- Rule rule = new Rule( "only columns" );
- Column c1 = new Column( 0,
+ final Rule rule = new Rule( "only columns" );
+ final Column c1 = new Column( 0,
new ClassObjectType( String.class ) );
- Column c2 = new Column( 1,
+ final Column c2 = new Column( 1,
new ClassObjectType( String.class ) );
- Column c3 = new Column( 2,
+ final Column c3 = new Column( 2,
new ClassObjectType( String.class ) );
- GroupElement lhsroot = GroupElementFactory.newAndInstance();
+ final GroupElement lhsroot = GroupElementFactory.newAndInstance();
lhsroot.addChild( c1 );
lhsroot.addChild( c2 );
lhsroot.addChild( c3 );
rule.setLhs( lhsroot );
-
- Consequence consequence = new Consequence() {
+
+ final Consequence consequence = new Consequence() {
public void evaluate(KnowledgeHelper knowledgeHelper,
WorkingMemory workingMemory) throws Exception {
- System.out.println("Consequence!");
+ System.out.println( "Consequence!" );
}
-
+
};
-
+
rule.setConsequence( consequence );
- List terminals = this.builder.addRule( rule,
+ final List terminals = this.builder.addRule( rule,
this.rulebase,
new HashMap(),
- new ReteooBuilder.IdGenerator(1) );
-
- Assert.assertEquals( "Rule must have a single terminal node", 1, terminals.size() );
-
- RuleTerminalNode terminal = (RuleTerminalNode) terminals.get( 0 );
+ new ReteooBuilder.IdGenerator( 1 ) );
+ Assert.assertEquals( "Rule must have a single terminal node",
+ 1,
+ terminals.size() );
+
+ final RuleTerminalNode terminal = (RuleTerminalNode) terminals.get( 0 );
+
}
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/rule/ColumnTest.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -18,15 +18,15 @@
public void testDeclarationsObjectType() throws Exception {
final ObjectType type = new ClassObjectType( Cheese.class );
final Column col = new Column( 0,
- type,
- "foo" );
+ type,
+ "foo" );
final Declaration dec = col.getDeclaration();
final Extractor ext = dec.getExtractor();
assertEquals( Cheese.class,
ext.getExtractToClass() );
final Cheese stilton = new Cheese( "stilton",
- 42 );
+ 42 );
assertEquals( stilton,
dec.getValue( stilton ) );
@@ -37,21 +37,21 @@
final Package pkg = new Package( "org.store" );
final FieldTemplate cheeseName = new FieldTemplateImpl( "name",
- 0,
- String.class );
+ 0,
+ String.class );
final FieldTemplate cheesePrice = new FieldTemplateImpl( "price",
- 1,
- Integer.class );
+ 1,
+ Integer.class );
final FieldTemplate[] fields = new FieldTemplate[]{cheeseName, cheesePrice};
final FactTemplate cheese = new FactTemplateImpl( pkg,
- "Cheese",
- fields );
+ "Cheese",
+ fields );
final ObjectType type = new FactTemplateObjectType( cheese );
final Column col = new Column( 0,
- type,
- "foo" );
+ type,
+ "foo" );
final Declaration dec = col.getDeclaration();
final Extractor ext = dec.getExtractor();
assertEquals( Fact.class,
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/rule/DeclarationTest.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -34,7 +34,7 @@
"type" );
final Column column = new Column( 5,
- new ClassObjectType( Cheese.class ) );
+ new ClassObjectType( Cheese.class ) );
// Bind the extractor to a decleration
// Declarations know the column they derive their value from
@@ -51,7 +51,7 @@
assertSame( extractor,
declaration.getExtractor() );
- assertEquals( 5,
+ assertEquals( 5,
declaration.getColumn().getOffset() );
}
@@ -61,7 +61,7 @@
"type" );
final Column column = new Column( 5,
- new ClassObjectType( Cheese.class ) );
+ new ClassObjectType( Cheese.class ) );
// Bind the extractor to a decleration
// Declarations know the column they derive their value from
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/rule/FieldConstraintTest.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -213,9 +213,11 @@
tuple = new InstrumentedReteTuple( tuple,
f1 );
- PredicateContextEntry context = (PredicateContextEntry) constraint1.getContextEntry();
- context.updateFromTuple( workingMemory, tuple );
- assertTrue( constraint1.isAllowedCachedLeft( context, f1.getObject() ) );
+ final PredicateContextEntry context = (PredicateContextEntry) constraint1.getContextEntry();
+ context.updateFromTuple( workingMemory,
+ tuple );
+ assertTrue( constraint1.isAllowedCachedLeft( context,
+ f1.getObject() ) );
}
/**
@@ -239,7 +241,7 @@
"price" );
final Column column = new Column( 0,
- new ClassObjectType( Cheese.class ) );
+ new ClassObjectType( Cheese.class ) );
// Bind the extractor to a decleration
// Declarations know the column they derive their value form
@@ -253,27 +255,27 @@
*/
private static final long serialVersionUID = 5673999834006100045L;
- public FieldValue evaluate(Object object,
+ public FieldValue evaluate(Object object,
Tuple tuple, // ?price
Declaration[] previousDeclarations,
Declaration[] localDeclarations,
- WorkingMemory workingMemory) {
+ WorkingMemory workingMemory) {
int price = ((Number) previousDeclarations[0].getValue( workingMemory.getObject( tuple.get( previousDeclarations[0] ) ) )).intValue();
return FieldFactory.getFieldValue( 2 * price );
}
};
-
- ReturnValueRestriction restriction1 = new ReturnValueRestriction( priceExtractor,
- isDoubleThePrice,
- new Declaration[]{priceDeclaration},
- new Declaration[0],
- ValueType.INTEGER_TYPE.getEvaluator( Operator.EQUAL ) );
+ final ReturnValueRestriction restriction1 = new ReturnValueRestriction( priceExtractor,
+ isDoubleThePrice,
+ new Declaration[]{priceDeclaration},
+ new Declaration[0],
+ ValueType.INTEGER_TYPE.getEvaluator( Operator.EQUAL ) );
+
final ReturnValueConstraint constraint1 = new ReturnValueConstraint( priceExtractor,
restriction1 );
- ReturnValueRestriction restriction2 = new ReturnValueRestriction( priceExtractor,
+ final ReturnValueRestriction restriction2 = new ReturnValueRestriction( priceExtractor,
isDoubleThePrice,
new Declaration[]{priceDeclaration},
new Declaration[0],
@@ -294,20 +296,25 @@
tuple = new InstrumentedReteTuple( tuple,
f1 );
- ReturnValueContextEntry context1 = (ReturnValueContextEntry) constraint1.getContextEntry();
- context1.updateFromTuple( workingMemory, tuple );
- assertTrue( constraint1.isAllowedCachedLeft( context1, f1.getObject() ) );
+ final ReturnValueContextEntry context1 = (ReturnValueContextEntry) constraint1.getContextEntry();
+ context1.updateFromTuple( workingMemory,
+ tuple );
+ assertTrue( constraint1.isAllowedCachedLeft( context1,
+ f1.getObject() ) );
- ReturnValueContextEntry context2 = (ReturnValueContextEntry) constraint2.getContextEntry();
- context2.updateFromTuple( workingMemory, tuple );
- assertFalse( constraint2.isAllowedCachedLeft( context2, f1.getObject() ) );
+ final ReturnValueContextEntry context2 = (ReturnValueContextEntry) constraint2.getContextEntry();
+ context2.updateFromTuple( workingMemory,
+ tuple );
+ assertFalse( constraint2.isAllowedCachedLeft( context2,
+ f1.getObject() ) );
final Cheese cheddar2 = new Cheese( "cheddar",
11 );
final InternalFactHandle f2 = (InternalFactHandle) workingMemory.assertObject( cheddar2 );
- assertTrue( constraint2.isAllowedCachedLeft( context2, f2.getObject() ) );
+ assertTrue( constraint2.isAllowedCachedLeft( context2,
+ f2.getObject() ) );
}
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/rule/GroupElementTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/rule/GroupElementTest.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/rule/GroupElementTest.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -8,12 +8,12 @@
public class GroupElementTest extends TestCase {
public void testPackNestedAnd() {
- GroupElement and1 = GroupElementFactory.newAndInstance();
- Column column1 = new Column( 0,
+ final GroupElement and1 = GroupElementFactory.newAndInstance();
+ final Column column1 = new Column( 0,
null );
and1.addChild( column1 );
- Column column2 = new Column( 0,
+ final Column column2 = new Column( 0,
null );
and1.addChild( column2 );
@@ -24,7 +24,7 @@
assertSame( column2,
and1.getChildren().get( 1 ) );
- GroupElement and2 = GroupElementFactory.newAndInstance();
+ final GroupElement and2 = GroupElementFactory.newAndInstance();
and2.addChild( and1 );
and2.pack();
@@ -37,12 +37,12 @@
}
public void testPackNestedOr() {
- GroupElement or1 = GroupElementFactory.newOrInstance();
- Column column1 = new Column( 0,
+ final GroupElement or1 = GroupElementFactory.newOrInstance();
+ final Column column1 = new Column( 0,
null );
or1.addChild( column1 );
- Column column2 = new Column( 0,
+ final Column column2 = new Column( 0,
null );
or1.addChild( column2 );
@@ -53,7 +53,7 @@
assertSame( column2,
or1.getChildren().get( 1 ) );
- GroupElement or2 = GroupElementFactory.newOrInstance();
+ final GroupElement or2 = GroupElementFactory.newOrInstance();
or2.addChild( or1 );
or2.pack();
@@ -67,8 +67,8 @@
}
public void testPackNestedExists() {
- GroupElement exists1 = GroupElementFactory.newExistsInstance();
- Column column1 = new Column( 0,
+ final GroupElement exists1 = GroupElementFactory.newExistsInstance();
+ final Column column1 = new Column( 0,
null );
exists1.addChild( column1 );
@@ -77,7 +77,7 @@
assertSame( column1,
exists1.getChildren().get( 0 ) );
- GroupElement exists2 = GroupElementFactory.newExistsInstance();
+ final GroupElement exists2 = GroupElementFactory.newExistsInstance();
exists2.addChild( exists1 );
exists2.pack();
@@ -89,29 +89,29 @@
}
public void testAddMultipleChildsIntoNot() {
- GroupElement not = GroupElementFactory.newNotInstance();
+ final GroupElement not = GroupElementFactory.newNotInstance();
- Column column1 = new Column( 0,
+ final Column column1 = new Column( 0,
null );
try {
not.addChild( column1 );
- } catch ( RuntimeDroolsException rde ) {
+ } catch ( final RuntimeDroolsException rde ) {
Assert.fail( "Adding a single child is not supposed to throw Exception for NOT GE: " + rde.getMessage() );
}
- Column column2 = new Column( 0,
+ final Column column2 = new Column( 0,
null );
try {
not.addChild( column2 );
Assert.fail( "Adding a second child into a NOT GE should throw Exception" );
- } catch ( RuntimeDroolsException rde ) {
+ } catch ( final RuntimeDroolsException rde ) {
// everything is fine
}
}
public void testAddSingleBranchAnd() {
- GroupElement and1 = GroupElementFactory.newAndInstance();
- Column column = new Column( 0,
+ final GroupElement and1 = GroupElementFactory.newAndInstance();
+ final Column column = new Column( 0,
null );
and1.addChild( column );
assertEquals( 1,
@@ -119,7 +119,7 @@
assertSame( column,
and1.getChildren().get( 0 ) );
- GroupElement or1 = GroupElementFactory.newOrInstance();
+ final GroupElement or1 = GroupElementFactory.newOrInstance();
or1.addChild( and1 );
or1.pack();
@@ -130,8 +130,8 @@
}
public void testAddSingleBranchOr() {
- GroupElement or1 = GroupElementFactory.newOrInstance();
- Column column = new Column( 0,
+ final GroupElement or1 = GroupElementFactory.newOrInstance();
+ final Column column = new Column( 0,
null );
or1.addChild( column );
assertEquals( 1,
@@ -139,7 +139,7 @@
assertSame( column,
or1.getChildren().get( 0 ) );
- GroupElement and1 = GroupElementFactory.newAndInstance();
+ final GroupElement and1 = GroupElementFactory.newAndInstance();
and1.addChild( or1 );
and1.pack();
@@ -172,16 +172,16 @@
*
*/
public void testDeepNestedStructure() {
- GroupElement or1 = GroupElementFactory.newOrInstance();
- Column column1 = new Column( 0,
+ final GroupElement or1 = GroupElementFactory.newOrInstance();
+ final Column column1 = new Column( 0,
null );
or1.addChild( column1 );
- Column column2 = new Column( 0,
+ final Column column2 = new Column( 0,
null );
or1.addChild( column2 );
- GroupElement and1 = GroupElementFactory.newAndInstance();
+ final GroupElement and1 = GroupElementFactory.newAndInstance();
and1.addChild( or1 );
assertEquals( 1,
and1.getChildren().size() );
@@ -193,7 +193,7 @@
assertSame( column2,
or1.getChildren().get( 1 ) );
- GroupElement or2 = GroupElementFactory.newOrInstance();
+ final GroupElement or2 = GroupElementFactory.newOrInstance();
or2.addChild( and1 );
assertEquals( 1,
@@ -201,7 +201,7 @@
assertSame( and1,
or2.getChildren().get( 0 ) );
- GroupElement or3 = GroupElementFactory.newOrInstance();
+ final GroupElement or3 = GroupElementFactory.newOrInstance();
or3.addChild( or2 );
assertEquals( 1,
@@ -209,30 +209,31 @@
assertSame( or2,
or3.getChildren().get( 0 ) );
- GroupElement and2 = GroupElementFactory.newAndInstance();
+ final GroupElement and2 = GroupElementFactory.newAndInstance();
and2.addChild( or3 );
assertEquals( 1,
and2.getChildren().size() );
assertSame( or3,
and2.getChildren().get( 0 ) );
-
+
// Now pack the structure
and2.pack();
-
+
// and2 now is in fact transformed into an OR
- assertEquals( GroupElement.OR, and2.getType() );
-
+ assertEquals( GroupElement.OR,
+ and2.getType() );
+
assertEquals( 2,
and2.getChildren().size() );
-
+
assertSame( column1,
and2.getChildren().get( 0 ) );
assertSame( column2,
and2.getChildren().get( 1 ) );
}
-
+
/**
* This test tests deep nested structures, and shall transform this:
*
@@ -258,16 +259,16 @@
*
*/
public void testDeepNestedStructureWithMultipleElementsInRoot() {
- GroupElement or1 = GroupElementFactory.newOrInstance();
- Column column1 = new Column( 0,
+ final GroupElement or1 = GroupElementFactory.newOrInstance();
+ final Column column1 = new Column( 0,
null );
or1.addChild( column1 );
- Column column2 = new Column( 0,
+ final Column column2 = new Column( 0,
null );
or1.addChild( column2 );
- GroupElement and1 = GroupElementFactory.newAndInstance();
+ final GroupElement and1 = GroupElementFactory.newAndInstance();
and1.addChild( or1 );
assertEquals( 1,
and1.getChildren().size() );
@@ -279,7 +280,7 @@
assertSame( column2,
or1.getChildren().get( 1 ) );
- GroupElement or2 = GroupElementFactory.newOrInstance();
+ final GroupElement or2 = GroupElementFactory.newOrInstance();
or2.addChild( and1 );
assertEquals( 1,
@@ -287,7 +288,7 @@
assertSame( and1,
or2.getChildren().get( 0 ) );
- GroupElement or3 = GroupElementFactory.newOrInstance();
+ final GroupElement or3 = GroupElementFactory.newOrInstance();
or3.addChild( or2 );
assertEquals( 1,
@@ -295,10 +296,10 @@
assertSame( or2,
or3.getChildren().get( 0 ) );
- GroupElement and2 = GroupElementFactory.newAndInstance();
+ final GroupElement and2 = GroupElementFactory.newAndInstance();
and2.addChild( or3 );
- Column column3 = new Column( 0,
+ final Column column3 = new Column( 0,
null );
and2.addChild( column3 );
@@ -308,23 +309,22 @@
and2.getChildren().get( 0 ) );
assertSame( column3,
and2.getChildren().get( 1 ) );
-
+
// Now pack the structure
and2.pack();
-
+
// and2 now is in fact transformed into an OR
assertTrue( and2.isAnd() );
-
+
assertEquals( 2,
and2.getChildren().size() );
-
+
// order must be the same
assertSame( or1,
and2.getChildren().get( 0 ) );
assertSame( column3,
and2.getChildren().get( 1 ) );
-
assertEquals( 2,
or1.getChildren().size() );
assertSame( column1,
@@ -333,5 +333,5 @@
or1.getChildren().get( 1 ) );
}
-
+
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/rule/LogicTransformerTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/rule/LogicTransformerTest.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/rule/LogicTransformerTest.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -52,10 +52,16 @@
* </pre>
*/
public void testSingleOrAndOrTransformation() throws InvalidPatternException {
- final ObjectType type = new ClassObjectType(String.class);
- final Column a = new Column( 0, type, "a");
- final Column b = new Column( 1, type, "b");
- final Column c = new Column( 2, type, "c");
+ final ObjectType type = new ClassObjectType( String.class );
+ final Column a = new Column( 0,
+ type,
+ "a" );
+ final Column b = new Column( 1,
+ type,
+ "b" );
+ final Column c = new Column( 2,
+ type,
+ "c" );
final GroupElement or = GroupElementFactory.newOrInstance();
or.addChild( a );
@@ -122,13 +128,25 @@
* </pre>
*/
public void testMultipleOrAndOrTransformation() throws InvalidPatternException {
- final ObjectType type = new ClassObjectType(String.class);
- final Column a = new Column( 0, type, "a");
- final Column b = new Column( 1, type, "b");
- final Column c = new Column( 2, type, "c");
- final Column d = new Column( 3, type, "d");
- final Column e = new Column( 4, type, "e");
- final Column f = new Column( 5, type, "f");
+ final ObjectType type = new ClassObjectType( String.class );
+ final Column a = new Column( 0,
+ type,
+ "a" );
+ final Column b = new Column( 1,
+ type,
+ "b" );
+ final Column c = new Column( 2,
+ type,
+ "c" );
+ final Column d = new Column( 3,
+ type,
+ "d" );
+ final Column e = new Column( 4,
+ type,
+ "e" );
+ final Column f = new Column( 5,
+ type,
+ "f" );
final GroupElement parent = GroupElementFactory.newAndInstance();
final GroupElement or = GroupElementFactory.newOrInstance();
@@ -243,9 +261,13 @@
*
*/
public void testNotOrTransformation() throws InvalidPatternException {
- final ObjectType type = new ClassObjectType(String.class);
- final Column a = new Column( 0, type, "a");
- final Column b = new Column( 1, type, "b");
+ final ObjectType type = new ClassObjectType( String.class );
+ final Column a = new Column( 0,
+ type,
+ "a" );
+ final Column b = new Column( 1,
+ type,
+ "b" );
final GroupElement parent = GroupElementFactory.newNotInstance();
final GroupElement or = GroupElementFactory.newOrInstance();
@@ -261,8 +283,8 @@
parent.getChildren().size() );
// we must ensure order
- GroupElement b1 = (GroupElement) parent.getChildren().get( 0 );
- GroupElement b2 = (GroupElement) parent.getChildren().get( 1 );
+ final GroupElement b1 = (GroupElement) parent.getChildren().get( 0 );
+ final GroupElement b2 = (GroupElement) parent.getChildren().get( 1 );
assertTrue( b1.isNot() );
assertTrue( b2.isNot() );
@@ -299,9 +321,13 @@
* </pre>
*/
public void testExistOrTransformation() throws InvalidPatternException {
- final ObjectType type = new ClassObjectType(String.class);
- final Column a = new Column( 0, type, "a");
- final Column b = new Column( 1, type, "b");
+ final ObjectType type = new ClassObjectType( String.class );
+ final Column a = new Column( 0,
+ type,
+ "a" );
+ final Column b = new Column( 1,
+ type,
+ "b" );
final GroupElement parent = GroupElementFactory.newExistsInstance();
final GroupElement or = GroupElementFactory.newOrInstance();
@@ -317,8 +343,8 @@
parent.getChildren().size() );
// we must ensure order
- GroupElement b1 = (GroupElement) parent.getChildren().get( 0 );
- GroupElement b2 = (GroupElement) parent.getChildren().get( 1 );
+ final GroupElement b1 = (GroupElement) parent.getChildren().get( 0 );
+ final GroupElement b2 = (GroupElement) parent.getChildren().get( 1 );
assertTrue( b1.isExists() );
assertTrue( b2.isExists() );
@@ -335,11 +361,19 @@
}
public void testEliminateEmptyBranchesAndDuplications() throws InvalidRuleException {
- final ObjectType type = new ClassObjectType(String.class);
- final Column a = new Column( 0, type, "a");
- final Column b = new Column( 1, type, "b");
- final Column c = new Column( 2, type, "c");
- final Column d = new Column( 3, type, "d");
+ final ObjectType type = new ClassObjectType( String.class );
+ final Column a = new Column( 0,
+ type,
+ "a" );
+ final Column b = new Column( 1,
+ type,
+ "b" );
+ final Column c = new Column( 2,
+ type,
+ "c" );
+ final Column d = new Column( 3,
+ type,
+ "d" );
final GroupElement and1 = GroupElementFactory.newAndInstance();
and1.addChild( a );
@@ -354,7 +388,7 @@
final GroupElement or = GroupElementFactory.newOrInstance();
and1.addChild( or );
- GroupElement[] result = LogicTransformer.getInstance().transform( and1 );
+ final GroupElement[] result = LogicTransformer.getInstance().transform( and1 );
assertLength( 1,
result );
@@ -362,13 +396,13 @@
result[0].getChildren() );
// we must ensure order
assertEquals( a,
- result[0].getChildren().get( 0 ) );
+ result[0].getChildren().get( 0 ) );
assertEquals( b,
- result[0].getChildren().get( 1 ) );
+ result[0].getChildren().get( 1 ) );
assertEquals( c,
- result[0].getChildren().get( 2 ) );
+ result[0].getChildren().get( 2 ) );
assertEquals( d,
- result[0].getChildren().get( 3 ) );
+ result[0].getChildren().get( 3 ) );
}
@@ -420,15 +454,31 @@
public void testProcessTree() throws IOException,
ClassNotFoundException,
InvalidPatternException {
- final ObjectType type = new ClassObjectType(String.class);
- final Column a = new Column( 0, type, "a");
- final Column b = new Column( 1, type, "b");
- final Column c = new Column( 2, type, "c");
- final Column d = new Column( 3, type, "d");
- final Column e = new Column( 4, type, "e");
- final Column g = new Column( 5, type, "g");
- final Column h = new Column( 6, type, "h");
- final Column i = new Column( 7, type, "i");
+ final ObjectType type = new ClassObjectType( String.class );
+ final Column a = new Column( 0,
+ type,
+ "a" );
+ final Column b = new Column( 1,
+ type,
+ "b" );
+ final Column c = new Column( 2,
+ type,
+ "c" );
+ final Column d = new Column( 3,
+ type,
+ "d" );
+ final Column e = new Column( 4,
+ type,
+ "e" );
+ final Column g = new Column( 5,
+ type,
+ "g" );
+ final Column h = new Column( 6,
+ type,
+ "h" );
+ final Column i = new Column( 7,
+ type,
+ "i" );
final GroupElement and1 = GroupElementFactory.newAndInstance();
final GroupElement and2 = GroupElementFactory.newAndInstance();
@@ -459,7 +509,7 @@
root.addChild( and3 );
root.addChild( not3 );
- GroupElement[] result = LogicTransformer.getInstance().transform( root );
+ final GroupElement[] result = LogicTransformer.getInstance().transform( root );
// ----------------------------------------------------------------------------------
// Now construct the result tree so we can test root against what it
@@ -471,7 +521,8 @@
// Uncomment this when you need to output a new known correct tree
// result
- writeTree(result, "correct_processTree1.dat");
+ writeTree( result,
+ "correct_processTree1.dat" );
final ObjectInputStream ois = new ObjectInputStream( this.getClass().getResourceAsStream( "/correct_processTree1.dat" ) );
final GroupElement[] correctResultRoot = (GroupElement[]) ois.readObject();
@@ -484,15 +535,31 @@
}
public void testCloneable() {
- final ObjectType type = new ClassObjectType(String.class);
- final Column a = new Column( 0, type, "a");
- final Column b = new Column( 1, type, "b");
- final Column c = new Column( 2, type, "c");
- final Column d = new Column( 3, type, "d");
- final Column e = new Column( 4, type, "e");
- final Column f = new Column( 5, type, "f");
- final Column g = new Column( 6, type, "g");
- final Column h = new Column( 7, type, "h");
+ final ObjectType type = new ClassObjectType( String.class );
+ final Column a = new Column( 0,
+ type,
+ "a" );
+ final Column b = new Column( 1,
+ type,
+ "b" );
+ final Column c = new Column( 2,
+ type,
+ "c" );
+ final Column d = new Column( 3,
+ type,
+ "d" );
+ final Column e = new Column( 4,
+ type,
+ "e" );
+ final Column f = new Column( 5,
+ type,
+ "f" );
+ final Column g = new Column( 6,
+ type,
+ "g" );
+ final Column h = new Column( 7,
+ type,
+ "h" );
// Test against a known false tree
final GroupElement and = GroupElementFactory.newAndInstance();
@@ -572,15 +639,31 @@
public void testTransform() throws IOException,
ClassNotFoundException,
InvalidPatternException {
- final ObjectType type = new ClassObjectType(String.class);
- final Column a = new Column( 0, type, "a");
- final Column b = new Column( 1, type, "b");
- final Column c = new Column( 2, type, "c");
- final Column d = new Column( 3, type, "d");
- final Column e = new Column( 4, type, "e");
- final Column f = new Column( 5, type, "f");
- final Column g = new Column( 6, type, "g");
- final Column h = new Column( 7, type, "h");
+ final ObjectType type = new ClassObjectType( String.class );
+ final Column a = new Column( 0,
+ type,
+ "a" );
+ final Column b = new Column( 1,
+ type,
+ "b" );
+ final Column c = new Column( 2,
+ type,
+ "c" );
+ final Column d = new Column( 3,
+ type,
+ "d" );
+ final Column e = new Column( 4,
+ type,
+ "e" );
+ final Column f = new Column( 5,
+ type,
+ "f" );
+ final Column g = new Column( 6,
+ type,
+ "g" );
+ final Column h = new Column( 7,
+ type,
+ "h" );
final GroupElement and = GroupElementFactory.newAndInstance();
@@ -611,11 +694,12 @@
and2.addChild( or3 );
and.addChild( and2 );
- GroupElement[] ands = LogicTransformer.getInstance().transform( and );
+ final GroupElement[] ands = LogicTransformer.getInstance().transform( and );
// Uncomment this when you need to output a new known correct tree
// result
- writeTree(ands, "correct_transform1.dat");
+ writeTree( ands,
+ "correct_transform1.dat" );
// Now check the main tree
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/rule/RuleTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/rule/RuleTest.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/rule/RuleTest.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -10,88 +10,84 @@
public class RuleTest extends TestCase {
public void testDateEffective() {
- Rule rule = new Rule("myrule");
-
-
- assertTrue(rule.isEffective());
-
- Calendar earlier = Calendar.getInstance();
+ final Rule rule = new Rule( "myrule" );
+
+ assertTrue( rule.isEffective() );
+
+ final Calendar earlier = Calendar.getInstance();
earlier.setTimeInMillis( 10 );
-
- rule.setDateEffective(earlier);
-
- assertTrue(rule.isEffective());
-
- Calendar later = Calendar.getInstance();
+
+ rule.setDateEffective( earlier );
+
+ assertTrue( rule.isEffective() );
+
+ final Calendar later = Calendar.getInstance();
later.setTimeInMillis( later.getTimeInMillis() + 100000000 );
-
-
- assertTrue(later.after( Calendar.getInstance() ));
-
- rule.setDateEffective(later);
- assertFalse(rule.isEffective());
-
+
+ assertTrue( later.after( Calendar.getInstance() ) );
+
+ rule.setDateEffective( later );
+ assertFalse( rule.isEffective() );
+
}
-
- public void testDateExpires() throws Exception{
- Rule rule = new Rule("myrule");
-
-
- assertTrue(rule.isEffective());
-
- Calendar earlier = Calendar.getInstance();
+
+ public void testDateExpires() throws Exception {
+ final Rule rule = new Rule( "myrule" );
+
+ assertTrue( rule.isEffective() );
+
+ final Calendar earlier = Calendar.getInstance();
earlier.setTimeInMillis( 10 );
-
- rule.setDateExpires(earlier);
-
-
- assertFalse(rule.isEffective());
-
- Calendar later = Calendar.getInstance();
+
+ rule.setDateExpires( earlier );
+
+ assertFalse( rule.isEffective() );
+
+ final Calendar later = Calendar.getInstance();
later.setTimeInMillis( later.getTimeInMillis() + 100000000 );
-
- rule.setDateExpires(later);
- assertTrue(rule.isEffective());
-
+
+ rule.setDateExpires( later );
+ assertTrue( rule.isEffective() );
+
}
-
+
public void testDateEffectiveExpires() {
- Rule rule = new Rule("myrule");
+ final Rule rule = new Rule( "myrule" );
- Calendar past = Calendar.getInstance();
+ final Calendar past = Calendar.getInstance();
past.setTimeInMillis( 10 );
-
- Calendar future = Calendar.getInstance();
+
+ final Calendar future = Calendar.getInstance();
future.setTimeInMillis( future.getTimeInMillis() + 100000000 );
-
+
rule.setDateEffective( past );
rule.setDateExpires( future );
-
- assertTrue(rule.isEffective());
-
+
+ assertTrue( rule.isEffective() );
+
rule.setDateExpires( past );
- assertFalse(rule.isEffective());
-
+ assertFalse( rule.isEffective() );
+
rule.setDateExpires( future );
rule.setDateEffective( future );
-
- assertFalse(rule.isEffective());
-
+
+ assertFalse( rule.isEffective() );
+
}
-
+
public void testRuleEnabled() {
- Rule rule = new Rule("myrule");
- rule.setEnabled(false);
- assertFalse(rule.isEffective());
-
- Calendar past = Calendar.getInstance();
+ final Rule rule = new Rule( "myrule" );
+ rule.setEnabled( false );
+ assertFalse( rule.isEffective() );
+
+ final Calendar past = Calendar.getInstance();
past.setTimeInMillis( 10 );
-
+
rule.setDateEffective( past );
- assertFalse(rule.isEffective());
- rule.setEnabled(true);
-
- assertTrue(rule.isEffective());
+ assertFalse( rule.isEffective() );
+ rule.setEnabled( true );
+
+ assertTrue( rule.isEffective() );
}
-
+
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/spi/MockConstraint.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/spi/MockConstraint.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/spi/MockConstraint.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -49,33 +49,33 @@
public ContextEntry getContextEntry() {
return new ContextEntry() {
private static final long serialVersionUID = -6597931500771088767L;
- private ContextEntry next;
+ private ContextEntry next;
public ContextEntry getNext() {
- return next;
+ return this.next;
}
- public void setNext(ContextEntry entry) {
+ public void setNext(final ContextEntry entry) {
this.next = entry;
}
- public void updateFromFactHandle(InternalWorkingMemory workingMemory,
- InternalFactHandle handle) {
+ public void updateFromFactHandle(final InternalWorkingMemory workingMemory,
+ final InternalFactHandle handle) {
}
- public void updateFromTuple(InternalWorkingMemory workingMemory,
- ReteTuple tuple) {
+ public void updateFromTuple(final InternalWorkingMemory workingMemory,
+ final ReteTuple tuple) {
}
};
}
- public boolean isAllowedCachedLeft(ContextEntry context,
- Object object) {
+ public boolean isAllowedCachedLeft(final ContextEntry context,
+ final Object object) {
return this.isAllowed;
}
- public boolean isAllowedCachedRight(ReteTuple tuple,
- ContextEntry context) {
+ public boolean isAllowedCachedRight(final ReteTuple tuple,
+ final ContextEntry context) {
return this.isAllowed;
}
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/BinaryHeapPriorityQueueTest.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -55,16 +55,16 @@
final long elapsedDequeue = System.currentTimeMillis() - startDequeue;
-// System.out.println( "elapsedEnqueue = " + elapsedEnqueue );
-// System.out.println( "elapsedDequeue = " + elapsedDequeue );
+ // System.out.println( "elapsedEnqueue = " + elapsedEnqueue );
+ // System.out.println( "elapsedDequeue = " + elapsedDequeue );
}
public void testBasic() {
final Random random = new Random();
final List items = new LinkedList();
- final BinaryHeapQueue queue = new BinaryHeapQueue(NaturalComparator.INSTANCE,
- 100000 );
+ final BinaryHeapQueue queue = new BinaryHeapQueue( NaturalComparator.INSTANCE,
+ 100000 );
for ( int i = 0; i < 100000; ++i ) {
items.add( new LongQueueable( random.nextLong() ) );
@@ -90,7 +90,7 @@
final long elapsedDequeue = System.currentTimeMillis() - startDequeue;
-// System.out.println( "elapsedEnqueue = " + elapsedEnqueue );
-// System.out.println( "elapsedDequeue = " + elapsedDequeue );
+ // System.out.println( "elapsedEnqueue = " + elapsedEnqueue );
+ // System.out.println( "elapsedDequeue = " + elapsedDequeue );
}
}
\ No newline at end of file
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/FieldIndexEntryTest.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -17,15 +17,16 @@
public void testSingleEntry() {
final ClassFieldExtractor extractor = new ClassFieldExtractor( Cheese.class,
- "type" );
+ "type" );
final FieldIndex fieldIndex = new FieldIndex( extractor,
null,
- StringFactory.getInstance().getEvaluator( Operator.EQUAL ));
- final SingleIndex singleIndex = new SingleIndex(new FieldIndex[] { fieldIndex }, 1);
-
+ StringFactory.getInstance().getEvaluator( Operator.EQUAL ) );
+ final SingleIndex singleIndex = new SingleIndex( new FieldIndex[]{fieldIndex},
+ 1 );
+
final FieldIndexEntry index = new FieldIndexEntry( singleIndex,
- "stilton".hashCode() );
+ "stilton".hashCode() );
// Test initial construction
assertNull( index.getFirst() );
@@ -33,9 +34,9 @@
index.hashCode() );
final Cheese stilton1 = new Cheese( "stilton",
- 35 );
+ 35 );
final InternalFactHandle h1 = new DefaultFactHandle( 1,
- stilton1 );
+ stilton1 );
// test add
index.add( h1 );
@@ -59,23 +60,24 @@
public void testTwoEntries() {
final ClassFieldExtractor extractor = new ClassFieldExtractor( Cheese.class,
- "type" );
+ "type" );
final FieldIndex fieldIndex = new FieldIndex( extractor,
null,
- StringFactory.getInstance().getEvaluator( Operator.EQUAL ));
- final SingleIndex singleIndex = new SingleIndex(new FieldIndex[] { fieldIndex }, 1);
-
+ StringFactory.getInstance().getEvaluator( Operator.EQUAL ) );
+ final SingleIndex singleIndex = new SingleIndex( new FieldIndex[]{fieldIndex},
+ 1 );
+
final FieldIndexEntry index = new FieldIndexEntry( singleIndex,
- "stilton".hashCode() );
+ "stilton".hashCode() );
final Cheese stilton1 = new Cheese( "stilton",
- 35 );
+ 35 );
final InternalFactHandle h1 = new DefaultFactHandle( 1,
- stilton1 );
+ stilton1 );
final Cheese stilton2 = new Cheese( "stilton",
- 59 );
+ 59 );
final InternalFactHandle h2 = new DefaultFactHandle( 2,
- stilton2 );
+ stilton2 );
// test add
index.add( h1 );
@@ -109,27 +111,28 @@
public void testThreeEntries() {
final ClassFieldExtractor extractor = new ClassFieldExtractor( Cheese.class,
- "type" );
+ "type" );
final FieldIndex fieldIndex = new FieldIndex( extractor,
null,
- StringFactory.getInstance().getEvaluator( Operator.EQUAL ));
- final SingleIndex singleIndex = new SingleIndex(new FieldIndex[] { fieldIndex }, 1);
-
+ StringFactory.getInstance().getEvaluator( Operator.EQUAL ) );
+ final SingleIndex singleIndex = new SingleIndex( new FieldIndex[]{fieldIndex},
+ 1 );
+
final FieldIndexEntry index = new FieldIndexEntry( singleIndex,
- "stilton".hashCode() );
+ "stilton".hashCode() );
final Cheese stilton1 = new Cheese( "stilton",
- 35 );
+ 35 );
final InternalFactHandle h1 = new DefaultFactHandle( 1,
- stilton1 );
+ stilton1 );
final Cheese stilton2 = new Cheese( "stilton",
- 59 );
+ 59 );
final InternalFactHandle h2 = new DefaultFactHandle( 2,
- stilton2 );
+ stilton2 );
final Cheese stilton3 = new Cheese( "stilton",
- 59 );
+ 59 );
final InternalFactHandle h3 = new DefaultFactHandle( 3,
- stilton3 );
+ stilton3 );
// test add
index.add( h1 );
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/FieldIndexHashTableTest.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -30,7 +30,7 @@
"type" );
final Column column = new Column( 0,
- new ClassObjectType( Cheese.class ) );
+ new ClassObjectType( Cheese.class ) );
final Declaration declaration = new Declaration( "typeOfCheese",
extractor,
@@ -38,23 +38,23 @@
final FieldIndex fieldIndex = new FieldIndex( extractor,
declaration,
- StringFactory.getInstance().getEvaluator( Operator.EQUAL ));
+ StringFactory.getInstance().getEvaluator( Operator.EQUAL ) );
- final FactHandleIndexHashTable map = new FactHandleIndexHashTable( new FieldIndex[] { fieldIndex } );
+ final FactHandleIndexHashTable map = new FactHandleIndexHashTable( new FieldIndex[]{fieldIndex} );
final Cheese cheddar = new Cheese( "cheddar",
- 10 );
+ 10 );
final InternalFactHandle cheddarHandle1 = new DefaultFactHandle( 0,
- cheddar );
+ cheddar );
assertEquals( 0,
map.size() );
assertNull( map.get( new ReteTuple( cheddarHandle1 ) ) );
final Cheese stilton1 = new Cheese( "stilton",
- 35 );
+ 35 );
final InternalFactHandle stiltonHandle1 = new DefaultFactHandle( 1,
- stilton1 );
+ stilton1 );
map.add( stiltonHandle1 );
assertEquals( 1,
@@ -63,9 +63,9 @@
tablePopulationSize( map ) );
final Cheese stilton2 = new Cheese( "stilton",
- 80 );
+ 80 );
final InternalFactHandle stiltonHandle2 = new DefaultFactHandle( 2,
- stilton2 );
+ stilton2 );
final FieldIndexEntry stiltonEntry = map.get( new ReteTuple( stiltonHandle2 ) );
assertSame( stiltonHandle1,
@@ -78,7 +78,7 @@
"type" );
final Column column = new Column( 0,
- new ClassObjectType( Cheese.class ) );
+ new ClassObjectType( Cheese.class ) );
final Declaration declaration = new Declaration( "typeOfCheese",
extractor,
@@ -86,23 +86,23 @@
final FieldIndex fieldIndex = new FieldIndex( extractor,
declaration,
- StringFactory.getInstance().getEvaluator( Operator.EQUAL ));
+ StringFactory.getInstance().getEvaluator( Operator.EQUAL ) );
- final FactHandleIndexHashTable map = new FactHandleIndexHashTable( new FieldIndex[] { fieldIndex } );
+ final FactHandleIndexHashTable map = new FactHandleIndexHashTable( new FieldIndex[]{fieldIndex} );
assertEquals( 0,
map.size() );
final Cheese stilton1 = new Cheese( "stilton",
- 35 );
+ 35 );
final InternalFactHandle stiltonHandle1 = new DefaultFactHandle( 1,
- stilton1 );
+ stilton1 );
map.add( stiltonHandle1 );
final Cheese cheddar1 = new Cheese( "cheddar",
- 35 );
+ 35 );
final InternalFactHandle cheddarHandle1 = new DefaultFactHandle( 2,
- cheddar1 );
+ cheddar1 );
map.add( cheddarHandle1 );
assertEquals( 2,
@@ -111,18 +111,18 @@
tablePopulationSize( map ) );
final Cheese stilton2 = new Cheese( "stilton",
- 77 );
+ 77 );
final InternalFactHandle stiltonHandle2 = new DefaultFactHandle( 2,
- stilton2 );
+ stilton2 );
final FieldIndexEntry stiltonEntry = map.get( new ReteTuple( stiltonHandle2 ) );
assertSame( stiltonHandle1,
stiltonEntry.getFirst().getFactHandle() );
assertNull( stiltonEntry.getFirst().getNext() );
final Cheese cheddar2 = new Cheese( "cheddar",
- 5 );
+ 5 );
final InternalFactHandle cheddarHandle2 = new DefaultFactHandle( 2,
- cheddar2 );
+ cheddar2 );
final FieldIndexEntry cheddarEntry = map.get( new ReteTuple( cheddarHandle2 ) );
assertSame( cheddarHandle1,
cheddarEntry.getFirst().getFactHandle() );
@@ -134,7 +134,7 @@
"type" );
final Column column = new Column( 0,
- new ClassObjectType( Cheese.class ) );
+ new ClassObjectType( Cheese.class ) );
final Declaration declaration = new Declaration( "typeOfCheese",
extractor,
@@ -142,29 +142,29 @@
final FieldIndex fieldIndex = new FieldIndex( extractor,
declaration,
- StringFactory.getInstance().getEvaluator( Operator.EQUAL ));
+ StringFactory.getInstance().getEvaluator( Operator.EQUAL ) );
- final FactHandleIndexHashTable map = new FactHandleIndexHashTable( new FieldIndex[] { fieldIndex } );
+ final FactHandleIndexHashTable map = new FactHandleIndexHashTable( new FieldIndex[]{fieldIndex} );
assertEquals( 0,
map.size() );
final Cheese stilton1 = new Cheese( "stilton",
- 35 );
+ 35 );
final InternalFactHandle stiltonHandle1 = new DefaultFactHandle( 1,
- stilton1 );
+ stilton1 );
map.add( stiltonHandle1 );
final Cheese cheddar1 = new Cheese( "cheddar",
- 35 );
+ 35 );
final InternalFactHandle cheddarHandle1 = new DefaultFactHandle( 2,
- cheddar1 );
+ cheddar1 );
map.add( cheddarHandle1 );
final Cheese stilton2 = new Cheese( "stilton",
- 81 );
+ 81 );
final InternalFactHandle stiltonHandle2 = new DefaultFactHandle( 3,
- stilton2 );
+ stilton2 );
map.add( stiltonHandle2 );
assertEquals( 3,
@@ -174,9 +174,9 @@
// Check they are correctly chained to the same FieldIndexEntry
final Cheese stilton3 = new Cheese( "stilton",
- 89 );
+ 89 );
final InternalFactHandle stiltonHandle3 = new DefaultFactHandle( 4,
- stilton2 );
+ stilton2 );
final FieldIndexEntry stiltonEntry = map.get( new ReteTuple( stiltonHandle3 ) );
assertSame( stiltonHandle2,
@@ -190,7 +190,7 @@
"object" );
final Column column = new Column( 0,
- new ClassObjectType( TestClass.class ) );
+ new ClassObjectType( TestClass.class ) );
final Declaration declaration = new Declaration( "theObject",
extractor,
@@ -198,25 +198,24 @@
final FieldIndex fieldIndex = new FieldIndex( extractor,
declaration,
- ObjectFactory.getInstance().getEvaluator( Operator.EQUAL ));
+ ObjectFactory.getInstance().getEvaluator( Operator.EQUAL ) );
- final FactHandleIndexHashTable map = new FactHandleIndexHashTable( new FieldIndex[] { fieldIndex } );
+ final FactHandleIndexHashTable map = new FactHandleIndexHashTable( new FieldIndex[]{fieldIndex} );
-
final TestClass c1 = new TestClass( 0,
- new TestClass( 20,
- "stilton" ) );
+ new TestClass( 20,
+ "stilton" ) );
final InternalFactHandle ch1 = new DefaultFactHandle( 1,
- c1 );
+ c1 );
map.add( ch1 );
final TestClass c2 = new TestClass( 0,
- new TestClass( 20,
- "cheddar" ) );
+ new TestClass( 20,
+ "cheddar" ) );
final InternalFactHandle ch2 = new DefaultFactHandle( 2,
- c2 );
+ c2 );
map.add( ch2 );
// same hashcode, but different values, so it should result in a size of 2
@@ -237,7 +236,7 @@
"type" );
final Column column = new Column( 0,
- new ClassObjectType( Cheese.class ) );
+ new ClassObjectType( Cheese.class ) );
final Declaration declaration = new Declaration( "typeOfCheese",
extractor,
@@ -245,30 +244,29 @@
final FieldIndex fieldIndex = new FieldIndex( extractor,
declaration,
- StringFactory.getInstance().getEvaluator( Operator.EQUAL ));
+ StringFactory.getInstance().getEvaluator( Operator.EQUAL ) );
- final FactHandleIndexHashTable map = new FactHandleIndexHashTable( new FieldIndex[] { fieldIndex } );
+ final FactHandleIndexHashTable map = new FactHandleIndexHashTable( new FieldIndex[]{fieldIndex} );
-
assertEquals( 0,
map.size() );
final Cheese stilton1 = new Cheese( "stilton",
- 35 );
+ 35 );
final InternalFactHandle stiltonHandle1 = new DefaultFactHandle( 1,
- stilton1 );
+ stilton1 );
map.add( stiltonHandle1 );
final Cheese cheddar1 = new Cheese( "cheddar",
- 35 );
+ 35 );
final InternalFactHandle cheddarHandle1 = new DefaultFactHandle( 2,
- cheddar1 );
+ cheddar1 );
map.add( cheddarHandle1 );
final Cheese stilton2 = new Cheese( "stilton",
- 81 );
+ 81 );
final InternalFactHandle stiltonHandle2 = new DefaultFactHandle( 3,
- stilton2 );
+ stilton2 );
map.add( stiltonHandle2 );
assertEquals( 3,
@@ -304,7 +302,7 @@
"type" );
final Column column = new Column( 0,
- new ClassObjectType( Cheese.class ) );
+ new ClassObjectType( Cheese.class ) );
final Declaration declaration = new Declaration( "typeOfCheese",
extractor,
@@ -312,90 +310,90 @@
final FieldIndex fieldIndex = new FieldIndex( extractor,
declaration,
- StringFactory.getInstance().getEvaluator( Operator.EQUAL ));
+ StringFactory.getInstance().getEvaluator( Operator.EQUAL ) );
- final FactHandleIndexHashTable map = new FactHandleIndexHashTable( new FieldIndex[] { fieldIndex } );
+ final FactHandleIndexHashTable map = new FactHandleIndexHashTable( new FieldIndex[]{fieldIndex} );
assertEquals( 0,
map.size() );
final Cheese stilton1 = new Cheese( "stilton",
- 35 );
+ 35 );
map.add( new DefaultFactHandle( 1,
stilton1 ) );
final Cheese stilton2 = new Cheese( "stilton",
- 81 );
+ 81 );
map.add( new DefaultFactHandle( 2,
stilton2 ) );
final Cheese cheddar1 = new Cheese( "cheddar",
- 35 );
+ 35 );
map.add( new DefaultFactHandle( 3,
cheddar1 ) );
final Cheese cheddar2 = new Cheese( "cheddar",
- 38 );
+ 38 );
map.add( new DefaultFactHandle( 4,
cheddar2 ) );
final Cheese brie = new Cheese( "brie",
- 293 );
+ 293 );
map.add( new DefaultFactHandle( 5,
brie ) );
final Cheese mozerella = new Cheese( "mozerella",
- 15 );
+ 15 );
map.add( new DefaultFactHandle( 6,
mozerella ) );
final Cheese dolcelatte = new Cheese( "dolcelatte",
- 284 );
+ 284 );
map.add( new DefaultFactHandle( 7,
dolcelatte ) );
final Cheese camembert1 = new Cheese( "camembert",
- 924 );
+ 924 );
map.add( new DefaultFactHandle( 8,
camembert1 ) );
final Cheese camembert2 = new Cheese( "camembert",
- 765 );
+ 765 );
map.add( new DefaultFactHandle( 9,
camembert2 ) );
final Cheese redLeicestor = new Cheese( "red leicestor",
- 23 );
+ 23 );
map.add( new DefaultFactHandle( 10,
redLeicestor ) );
final Cheese wensleydale = new Cheese( "wensleydale",
- 20 );
+ 20 );
map.add( new DefaultFactHandle( 11,
wensleydale ) );
final Cheese edam = new Cheese( "edam",
- 12 );
+ 12 );
map.add( new DefaultFactHandle( 12,
edam ) );
final Cheese goude1 = new Cheese( "goude",
- 93 );
+ 93 );
map.add( new DefaultFactHandle( 13,
goude1 ) );
final Cheese goude2 = new Cheese( "goude",
- 88 );
+ 88 );
map.add( new DefaultFactHandle( 14,
goude2 ) );
final Cheese gruyere = new Cheese( "gruyere",
- 82 );
+ 82 );
map.add( new DefaultFactHandle( 15,
gruyere ) );
final Cheese emmental = new Cheese( "emmental",
- 98 );
+ 98 );
map.add( new DefaultFactHandle( 16,
emmental ) );
@@ -410,7 +408,7 @@
table.length );
final Cheese feta = new Cheese( "feta",
- 48 );
+ 48 );
map.add( new DefaultFactHandle( 2,
feta ) );
@@ -424,12 +422,12 @@
table.length );
final Cheese haloumi = new Cheese( "haloumi",
- 48 );
+ 48 );
map.add( new DefaultFactHandle( 2,
haloumi ) );
final Cheese chevre = new Cheese( "chevre",
- 48 );
+ 48 );
map.add( new DefaultFactHandle( 2,
chevre ) );
@@ -520,7 +518,7 @@
"type" );
final Column column = new Column( 0,
- new ClassObjectType( Cheese.class ) );
+ new ClassObjectType( Cheese.class ) );
final Declaration declaration = new Declaration( "typeOfCheese",
extractor,
@@ -528,14 +526,14 @@
final FieldIndex fieldIndex = new FieldIndex( extractor,
declaration,
- StringFactory.getInstance().getEvaluator( Operator.EQUAL ));
+ StringFactory.getInstance().getEvaluator( Operator.EQUAL ) );
- final FactHandleIndexHashTable map = new FactHandleIndexHashTable( new FieldIndex[] { fieldIndex } );
+ final FactHandleIndexHashTable map = new FactHandleIndexHashTable( new FieldIndex[]{fieldIndex} );
final Cheese stilton = new Cheese( "stilton",
- 55 );
+ 55 );
final InternalFactHandle stiltonHandle = new DefaultFactHandle( 2,
- stilton );
+ stilton );
final Iterator it = map.iterator( new ReteTuple( stiltonHandle ) );
for ( ObjectEntry entry = (ObjectEntry) it.next(); entry != null; entry = (ObjectEntry) it.next() ) {
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/ObjectHashMapTest.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -106,12 +106,12 @@
}
public void testStringData() {
- ObjectHashMap map = new ObjectHashMap();
+ final ObjectHashMap map = new ObjectHashMap();
assertNotNull( map );
- int count = 1000;
+ final int count = 1000;
for ( int idx = 0; idx < count; idx++ ) {
- String key = "key" + idx;
- String val = "value" + idx;
+ final String key = "key" + idx;
+ final String val = "value" + idx;
map.put( key,
val );
assertEquals( val,
@@ -120,12 +120,12 @@
}
public void testIntegerData() {
- ObjectHashMap map = new ObjectHashMap();
+ final ObjectHashMap map = new ObjectHashMap();
assertNotNull( map );
- int count = 1000;
+ final int count = 1000;
for ( int idx = 0; idx < count; idx++ ) {
- Integer key = new Integer( idx );
- Integer val = new Integer( idx );
+ final Integer key = new Integer( idx );
+ final Integer val = new Integer( idx );
map.put( key,
val );
assertEquals( val,
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/ObjectHashMapTest2.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/ObjectHashMapTest2.java 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/ObjectHashMapTest2.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -5,191 +5,206 @@
public class ObjectHashMapTest2 extends TestCase {
- public ObjectHashMapTest2() {
- super();
- }
-
- public void testJUHashmap() {
- java.util.HashMap map = new java.util.HashMap();
- assertNotNull(map);
- int count = 1000;
- for (int idx=0; idx < count; idx++) {
- String key = "key" + idx;
- String val = "value" + idx;
- map.put(key, val);
- assertEquals(val,map.get(key));
- }
- }
+ public ObjectHashMapTest2() {
+ super();
+ }
- public void testStringData() {
- ObjectHashMap map = new ObjectHashMap();
- assertNotNull(map);
- int count = 1000;
- for (int idx=0; idx < count; idx++) {
- String key = "key" + idx;
- String val = "value" + idx;
- map.put(key, val);
- assertEquals(val,map.get(key));
- }
- }
+ public void testJUHashmap() {
+ final java.util.HashMap map = new java.util.HashMap();
+ assertNotNull( map );
+ final int count = 1000;
+ for ( int idx = 0; idx < count; idx++ ) {
+ final String key = "key" + idx;
+ final String val = "value" + idx;
+ map.put( key,
+ val );
+ assertEquals( val,
+ map.get( key ) );
+ }
+ }
- public void testStringDataDupFalse() {
- ObjectHashMap map = new ObjectHashMap();
- assertNotNull(map);
- int count = 10000;
- for (int idx=0; idx < count; idx++) {
- String key = "key" + idx;
- String val = "value" + idx;
- map.put(key, val,false);
- assertEquals(val,map.get(key));
- }
- }
+ public void testStringData() {
+ final ObjectHashMap map = new ObjectHashMap();
+ assertNotNull( map );
+ final int count = 1000;
+ for ( int idx = 0; idx < count; idx++ ) {
+ final String key = "key" + idx;
+ final String val = "value" + idx;
+ map.put( key,
+ val );
+ assertEquals( val,
+ map.get( key ) );
+ }
+ }
- public void testIntegerData() {
- ObjectHashMap map = new ObjectHashMap();
- assertNotNull(map);
- int count = 1000;
- for (int idx=0; idx < count; idx++) {
- Integer key = new Integer(idx);
- Integer val = new Integer(idx);
- map.put(key, val);
- assertEquals(val,map.get(key));
- }
- }
-
- public void testJUHashMap1() {
- int count = 100000;
- java.util.HashMap map = new java.util.HashMap();
- assertNotNull(map);
- long start = System.currentTimeMillis();
- for (int idx=0; idx < count; idx++) {
- String key = "key" + idx;
- String strval = "value" + idx;
- map.put(key,strval);
- }
- long end = System.currentTimeMillis();
- System.out.println("java.util.HashMap put(key,value) ET - " + ((end-start)));
- }
-
- public void testStringData2() {
- int count = 100000;
- ObjectHashMap map = new ObjectHashMap();
- assertNotNull(map);
- long start = System.currentTimeMillis();
- for (int idx=0; idx < count; idx++) {
- String key = "key" + idx;
- String strval = "value" + idx;
- map.put(key,strval);
- }
- long end = System.currentTimeMillis();
- System.out.println("Custom ObjectHashMap put(key,value) ET - " + ((end-start)));
- }
-
+ public void testStringDataDupFalse() {
+ final ObjectHashMap map = new ObjectHashMap();
+ assertNotNull( map );
+ final int count = 10000;
+ for ( int idx = 0; idx < count; idx++ ) {
+ final String key = "key" + idx;
+ final String val = "value" + idx;
+ map.put( key,
+ val,
+ false );
+ assertEquals( val,
+ map.get( key ) );
+ }
+ }
+ public void testIntegerData() {
+ final ObjectHashMap map = new ObjectHashMap();
+ assertNotNull( map );
+ final int count = 1000;
+ for ( int idx = 0; idx < count; idx++ ) {
+ final Integer key = new Integer( idx );
+ final Integer val = new Integer( idx );
+ map.put( key,
+ val );
+ assertEquals( val,
+ map.get( key ) );
+ }
+ }
- public void testStringData3() {
- int count = 100000;
- ObjectHashMap map = new ObjectHashMap();
- assertNotNull(map);
- for (int idx=0; idx < count; idx++) {
- String key = "key" + idx;
- String strval = "value" + idx;
- map.put(key,strval);
- }
- long start = System.currentTimeMillis();
- for (int idx=0; idx < count; idx++) {
- String key = "key" + idx;
- map.get(key);
- }
- long end = System.currentTimeMillis();
- System.out.println("Custom ObjectHashMap get(key) ET - " + ((end-start)));
- }
-
- public void testJUHashMap2() {
- int count = 100000;
- java.util.HashMap map = new java.util.HashMap();
- assertNotNull(map);
- for (int idx=0; idx < count; idx++) {
- String key = "key" + idx;
- String strval = "value" + idx;
- map.put(key,strval);
- }
- long start = System.currentTimeMillis();
- for (int idx=0; idx < count; idx++) {
- String key = "key" + idx;
- map.get(key);
- }
- long end = System.currentTimeMillis();
- System.out.println("java.util.HashMap get(key) ET - " + ((end-start)));
- }
-
- public void testStringData4() {
- int count = 100000;
- ObjectHashMap map = new ObjectHashMap();
- assertNotNull(map);
- for (int idx=0; idx < count; idx++) {
- String key = "key" + idx;
- String strval = "value" + idx;
- map.put(key,strval);
- }
- long start = System.currentTimeMillis();
- org.drools.util.Iterator itr = map.iterator();
- Object val = null;
- while ( (val = itr.next()) != null) {
- val.hashCode();
- }
- long end = System.currentTimeMillis();
- System.out.println("Custom ObjectHashMap iterate ET - " + ((end-start)));
- }
+ public void testJUHashMap1() {
+ final int count = 100000;
+ final java.util.HashMap map = new java.util.HashMap();
+ assertNotNull( map );
+ final long start = System.currentTimeMillis();
+ for ( int idx = 0; idx < count; idx++ ) {
+ final String key = "key" + idx;
+ final String strval = "value" + idx;
+ map.put( key,
+ strval );
+ }
+ final long end = System.currentTimeMillis();
+ System.out.println( "java.util.HashMap put(key,value) ET - " + ((end - start)) );
+ }
- public void testJUHashMap3() {
- int count = 100000;
- java.util.HashMap map = new java.util.HashMap();
- assertNotNull(map);
- for (int idx=0; idx < count; idx++) {
- String key = "key" + idx;
- String strval = "value" + idx;
- map.put(key,strval);
- }
- long start = System.currentTimeMillis();
- java.util.Iterator itr = map.values().iterator();
- while ( itr.hasNext()) {
- itr.next().hashCode();
- }
- long end = System.currentTimeMillis();
- System.out.println("java.util.HashMap iterate ET - " + ((end-start)));
- }
-
- public void testStringData5() {
- int count = 100000;
- ObjectHashMap map = new ObjectHashMap();
- assertNotNull(map);
- long start = System.currentTimeMillis();
- for (int idx=0; idx < count; idx++) {
- String key = "key" + idx;
- String strval = "value" + idx;
- map.put(key,strval,false);
- }
- long end = System.currentTimeMillis();
- System.out.println("Custom ObjectHashMap dup false ET - " + ((end-start)));
- }
-
- public static void main(String[] args) {
- ObjectHashMapTest2 test = new ObjectHashMapTest2();
- int loop = 5;
- for (int idx=0; idx < loop; idx++) {
- test.testIntegerData();
- test.testStringData();
- test.testJUHashmap();
- test.testStringData2();
- test.testJUHashMap1();
- test.testStringData3();
- test.testJUHashMap2();
- test.testStringData4();
- test.testJUHashMap3();
- test.testStringData5();
- test.testStringDataDupFalse();
- System.out.println(" --------------- ");
- }
- }
+ public void testStringData2() {
+ final int count = 100000;
+ final ObjectHashMap map = new ObjectHashMap();
+ assertNotNull( map );
+ final long start = System.currentTimeMillis();
+ for ( int idx = 0; idx < count; idx++ ) {
+ final String key = "key" + idx;
+ final String strval = "value" + idx;
+ map.put( key,
+ strval );
+ }
+ final long end = System.currentTimeMillis();
+ System.out.println( "Custom ObjectHashMap put(key,value) ET - " + ((end - start)) );
+ }
+
+ public void testStringData3() {
+ final int count = 100000;
+ final ObjectHashMap map = new ObjectHashMap();
+ assertNotNull( map );
+ for ( int idx = 0; idx < count; idx++ ) {
+ final String key = "key" + idx;
+ final String strval = "value" + idx;
+ map.put( key,
+ strval );
+ }
+ final long start = System.currentTimeMillis();
+ for ( int idx = 0; idx < count; idx++ ) {
+ final String key = "key" + idx;
+ map.get( key );
+ }
+ final long end = System.currentTimeMillis();
+ System.out.println( "Custom ObjectHashMap get(key) ET - " + ((end - start)) );
+ }
+
+ public void testJUHashMap2() {
+ final int count = 100000;
+ final java.util.HashMap map = new java.util.HashMap();
+ assertNotNull( map );
+ for ( int idx = 0; idx < count; idx++ ) {
+ final String key = "key" + idx;
+ final String strval = "value" + idx;
+ map.put( key,
+ strval );
+ }
+ final long start = System.currentTimeMillis();
+ for ( int idx = 0; idx < count; idx++ ) {
+ final String key = "key" + idx;
+ map.get( key );
+ }
+ final long end = System.currentTimeMillis();
+ System.out.println( "java.util.HashMap get(key) ET - " + ((end - start)) );
+ }
+
+ public void testStringData4() {
+ final int count = 100000;
+ final ObjectHashMap map = new ObjectHashMap();
+ assertNotNull( map );
+ for ( int idx = 0; idx < count; idx++ ) {
+ final String key = "key" + idx;
+ final String strval = "value" + idx;
+ map.put( key,
+ strval );
+ }
+ final long start = System.currentTimeMillis();
+ final org.drools.util.Iterator itr = map.iterator();
+ Object val = null;
+ while ( (val = itr.next()) != null ) {
+ val.hashCode();
+ }
+ final long end = System.currentTimeMillis();
+ System.out.println( "Custom ObjectHashMap iterate ET - " + ((end - start)) );
+ }
+
+ public void testJUHashMap3() {
+ final int count = 100000;
+ final java.util.HashMap map = new java.util.HashMap();
+ assertNotNull( map );
+ for ( int idx = 0; idx < count; idx++ ) {
+ final String key = "key" + idx;
+ final String strval = "value" + idx;
+ map.put( key,
+ strval );
+ }
+ final long start = System.currentTimeMillis();
+ final java.util.Iterator itr = map.values().iterator();
+ while ( itr.hasNext() ) {
+ itr.next().hashCode();
+ }
+ final long end = System.currentTimeMillis();
+ System.out.println( "java.util.HashMap iterate ET - " + ((end - start)) );
+ }
+
+ public void testStringData5() {
+ final int count = 100000;
+ final ObjectHashMap map = new ObjectHashMap();
+ assertNotNull( map );
+ final long start = System.currentTimeMillis();
+ for ( int idx = 0; idx < count; idx++ ) {
+ final String key = "key" + idx;
+ final String strval = "value" + idx;
+ map.put( key,
+ strval,
+ false );
+ }
+ final long end = System.currentTimeMillis();
+ System.out.println( "Custom ObjectHashMap dup false ET - " + ((end - start)) );
+ }
+
+ public static void main(final String[] args) {
+ final ObjectHashMapTest2 test = new ObjectHashMapTest2();
+ final int loop = 5;
+ for ( int idx = 0; idx < loop; idx++ ) {
+ test.testIntegerData();
+ test.testStringData();
+ test.testJUHashmap();
+ test.testStringData2();
+ test.testJUHashMap1();
+ test.testStringData3();
+ test.testJUHashMap2();
+ test.testStringData4();
+ test.testJUHashMap3();
+ test.testStringData5();
+ test.testStringDataDupFalse();
+ System.out.println( " --------------- " );
+ }
+ }
}
\ No newline at end of file
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 2007-04-12 21:53:36 UTC (rev 10951)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/asm/ClassFieldInspectorTest.java 2007-04-12 23:10:10 UTC (rev 10952)
@@ -213,11 +213,11 @@
static class Person {
public static String aStaticString;
- private boolean happy;
- private String name;
- private int age;
- private String URI;
-
+ private boolean happy;
+ private String name;
+ private int age;
+ private String URI;
+
static {
aStaticString = "A static String";
}
More information about the jboss-svn-commits
mailing list