| The Unified Modeling Language (UML) is a common visual modeling language for specifying, visualizing, documenting the artifacts of the software systems. As a part of the UML standard, the Object Constraint Language (OCL) is applied to state the model's constraints and their interrelation unambiguously. OCL is a declarative language, and also is a formal language.Three common OCL constraints added to model are precondition, postcondition, and invariant. Precondition describes the acceptable values of the input parameter and model's state when the operation is invoked. Postcondition has to be true after operation's execution, and it is used to check operation's resultant values and model's states when the operation has been fulfilled. Invariant is the rules which always hold true in the attribute's life period. Constraint verification is demanded in order to assure the constraint's validity in the running program. Detecting constraints violation during runtime can prove to be useful to software system's development, especially to large software system and embedded real-time system's development.The target is to declare necessary constraints for model, and to obtain the codes that can detect constraint violation during runtime, thus, precondition code pattern, postcondition code pattern, invariant code pattern need to be designed respectively. The code patterns describe the way in which the executable Java codes equivalent of OCL statements (namely, OCL-Java codes) have to be inserted into the Java program. The code patterns can throw corresponding exception when having detected constraint violated during program's runtime.The research constructed the system's model applying UML tool, and declared some necessary constraints for the model based on the OCL theory, consequently, had acquired rigorous system model. In the Java program equivalent of the model, which was brought by applying UML tool's automated code generation, OCL constraints only appear in the comments, the research accomplished the extracting of the constrains in the program. Because OCL is not a programming language, and OCL constraints cannot be executed directly, due to Java as a target language, OCL constraints must to be transformed into executable Java codes (namely, OCL-Java codes). Therefore, the research expounded the implementation of OCL constraint transforming into OCL-Java code. In order to detect the constraints violated during runtime, OCL-Java code need to be inserted into the Java program, sequentially constraint verification can be... |