1、 Reference numberISO/IEC 19507:2012(E)ISO/IEC 2012 INTERNATIONAL STANDARD ISO/IEC19507First edition2012-04-15Information technology Object Management Group Object Constraint Language(OCL)Technologies de linformation Langage de contraintes orient-objet(OCL)de lOMG ISO/IEC 19507:2012(E)COPYRIGHT PROTE
2、CTED DOCUMENT ISO/IEC 2012 All rights reserved.Unless otherwise specified,no part of this publication may be reproduced or utilized in any form or by any means,electronic or mechanical,including photocopying and microfilm,without permission in writing from either ISO at the address below or ISOs mem
3、ber body in the country of the requester.ISO copyright office Case postale 56 CH-1211 Geneva 20 Tel.+41 22 749 01 11 Fax +41 22 749 09 47 E-mail copyrightiso.org Web www.iso.org Published in Switzerland ii ISO/IEC 2012 All rights reserved ISO/IEC 19507:2012(E)ISO/IEC 2012-All rights reservediii Tabl
4、e of Contents Foreword.ix Introduction.x1 Scope.12 Conformance.13 References.23.1 Normative References.23.2 Informative References.24 Terms and Definitions.35 Notational Conventions.36 Additional Information.36.1 Changes to Adopted OMG Specifications.36.2 Structure of the Specification.36.3 Acknowle
5、dgements.47 OCL Language Description.57.1 General.57.2 Why OCL?.5 7.2.1 Where to Use OCL.57.3 Introduction.6 7.3.1 Legend.6 7.3.2 Example Class Diagram.6 7.3.3 Character Set.77.4 Relation to the UML Metamodel.7 7.4.1 Self.7 7.4.2 Specifying the UML Context.7 7.4.3 Invariants.8 7.4.4 Pre-and Postcond
6、itions.8 7.4.5 Package Context.9 7.4.6 Operation Body Expression.9 7.4.7 Initial and Derived Values.9 7.4.8 Other Types of Expressions.107.5 Basic Values and Types.10 7.5.1 Types from the UML Model.11 7.5.2 Enumeration Types.11 7.5.3 Let Expressions.11 7.5.4 Additional operations/attributes through
7、definition expressions.12 7.5.5 Type Conformance.12ISO/IEC 19507:2012(E)iv ISO/IEC 2012-All rights reserved 7.5.6 Re-typing or Casting.13 7.5.7 Precedence Rules.14 7.5.8 Use of Infix Operators.14 7.5.9 Keywords.15 7.5.10 Comment.16 7.5.11 Invalid Values.167.6 Objects and Properties.16 7.6.1 Properti
8、es:Attributes.17 7.6.2 Properties:Operations.17 7.6.3 Properties:AssociationEnds and Navigation.18 7.6.4 Navigation to Association Classes.20 7.6.5 Navigation from Association Classes.21 7.6.6 Navigation through Qualified Associations.21 7.6.7 Using Pathnames for Packages.21 7.6.8 Accessing overridd
9、en properties of supertypes.22 7.6.9 Predefined properties on All Objects.22 7.6.10 Features on Classes Themselves.23 7.6.11 Collections.24 7.6.12 Collections of Collections.25 7.6.13 Collection Type Hierarchy and Type Conformance Rules.25 7.6.14 Previous Values in Postconditions.25 7.6.15 Tuples.26
10、7.7 Collection Operations.27 7.7.1 Select and Reject Operations.27 7.7.2 Collect Operation.28 7.7.3 ForAll Operation.29 7.7.4 Exists Operation.30 7.7.5 Closure Operation.30 7.7.6 Iterate Operation.317.8 Messages in OCL.32 7.8.1 Calling operations and sending signals.32 7.8.2 Accessing result values.
11、33 7.8.3 An example.337.9 Resolving Properties.348 Abstract Syntax.358.1 Introduction.358.2 The Types Package.35 8.2.1 Type Conformance.38 8.2.2 Operations and Well-formedness Rules for the Types Package.408.3 The Expressions Package.42 8.3.1 Expressions Core.43 8.3.2 FeatureCall Expressions.45 8.3.
12、3 If Expressions.47 8.3.4 Message Expressions.488.4 Literal Expressions.49 8.4.1 Let Expressions.52 8.4.2 Well-formedness Rules of the Expressions package.53 8.4.3 Additional Operations on UML metaclasses.60ISO/IEC 19507:2012(E)ISO/IEC 2012-All rights reservedv 8.4.4 Additional Operations on OCL Met
13、aclasses.62 8.4.5 Overview of class hierarchy of OCL Abstract Syntax metamodel.649 Concrete Syntax.659.1 General.659.2 Structure of the Concrete Syntax.659.3 A Note to Tool Builders.67 9.3.1 Parsing.67 9.3.2 Visibility.679.4 Concrete Syntax.67 9.4.1 ExpressionInOclCS.68 9.4.2 OclExpressionCS.68 9.4.
14、3 VariableExpCS.69 9.4.4 simpleNameCS.69 9.4.5 restrictedKeywordCS.70 9.4.6 unreservedSimpleNameCS.71 9.4.7 pathNameCS.71 9.4.8 LiteralExpCS.72 9.4.9 EnumLiteralExpCS.72 9.4.10 CollectionLiteralExpCS.73 9.4.11 CollectionTypeIdentifierCS.73 9.4.12 CollectionLiteralPartsCS.74 9.4.13 CollectionLiteralP
15、artCS.74 9.4.14 CollectionRangeCS.74 9.4.15 PrimitiveLiteralExpCS.75 9.4.16 TupleLiteralExpCS.76 9.4.17 UnlimitedNaturalLiteralExpCS.76 9.4.18 IntegerLiteralExpCS.76 9.4.19 RealLiteralExpCS.77 9.4.20 StringLiteralExpCS.77 9.4.21 BooleanLiteralExpCS.78 9.4.22 TypeLiteralExpCS.78 9.4.23 CallExpCS.79 9
16、.4.24 LoopExpCS.79 9.4.25 IteratorExpCS.80 9.4.26 IterateExpCS.83 9.4.27 VariableDeclarationCS.84 9.4.28 TypeCS.85 9.4.29 primitiveTypeCS.85 9.4.30 oclTypeCS.86 9.4.31 collectionTypeCS.86 9.4.32 tupleTypeCS.87 9.4.33 variableDeclarationListCS.87 9.4.34 FeatureCallExpCS.88 9.4.35 OperationCallExpCS.88 9.4.36 PropertyCallExpCS.91 9.4.37 NavigationCallExpCS.93 9.4.38 AssociationClassCallExpCS.93 9.4.39 isMarkedPreCS.94 9.4.40 argumentsCS.94ISO/IEC 19507:2012(E)vi ISO/IEC 2012-All rights reserved 9.