• DoctypeDeclaration{http://etl.sf.net/etl/doctype/0.2.1}:
    • systemId: "../grammars/AsyncEJ.g.etl"
  • TopLevelClassifier{http://etl.sf.net/2006/samples/ej/0.1}:
    • classifier:
      • InterfaceStatement{http://etl.sf.net/2006/samples/ej/0.1}:
        • documentation:
          • DocumentationLine{http://etl.sf.net/2006/samples/ej/0.1}:
            • text: /// This sample is based on async-objects framework
          • DocumentationLine{http://etl.sf.net/2006/samples/ej/0.1}:
            • text: /// sample asynchronous interface
          • DocumentationLine{http://etl.sf.net/2006/samples/ej/0.1}:
            • text: /// The interface demonstrate simple input stream
        • name:
          • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
            • value: ByteInput
        • contents:
          • EventualMethodStatement{http://etl.sf.net/2006/samples/ej/AsyncEJ/0.1}:
            • returnType:
              • PrimitiveType{http://etl.sf.net/2006/samples/ej/0.1}:
                • name: int
            • name:
              • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                • value: read
            • parameters:
              • Parameter{http://etl.sf.net/2006/samples/ej/0.1}:
                • classifier:
                  • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                    • value: DataBuffer
                • name:
                  • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                    • value: buffer
          • EventualMethodStatement{http://etl.sf.net/2006/samples/ej/AsyncEJ/0.1}:
            • returnType:
              • PrimitiveType{http://etl.sf.net/2006/samples/ej/0.1}:
                • name: void
            • name:
              • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                • value: close
  • TopLevelClassifier{http://etl.sf.net/2006/samples/ej/0.1}:
    • classifier:
      • ClassStatement{http://etl.sf.net/2006/samples/ej/0.1}:
        • documentation:
          • DocumentationLine{http://etl.sf.net/2006/samples/ej/0.1}:
            • text: /// sample asynchronous class
          • DocumentationLine{http://etl.sf.net/2006/samples/ej/0.1}:
            • text: /// The class demonstrate simple buffered input
        • name:
          • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
            • value: BufferedByteInputImpl
        • contents:
          • SupportsStatement{http://etl.sf.net/2006/samples/ej/0.1}:
            • supportedInterfaces:
              • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                • value: ByteInput
          • FieldStatement{http://etl.sf.net/2006/samples/ej/0.1}:
            • visibilityModifier:
              • Modifier{http://etl.sf.net/2006/samples/ej/0.1}:
                • value: private
            • classifier:
              • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                • value: DataBuffer
            • variables:
              • Variable{http://etl.sf.net/2006/samples/ej/0.1}:
                • name:
                  • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                    • value: data
          • FieldStatement{http://etl.sf.net/2006/samples/ej/0.1}:
            • visibilityModifier:
              • Modifier{http://etl.sf.net/2006/samples/ej/0.1}:
                • value: private
            • finalModifier:
              • Modifier{http://etl.sf.net/2006/samples/ej/0.1}:
                • value: final
            • classifier:
              • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                • value: ByteInput
            • variables:
              • Variable{http://etl.sf.net/2006/samples/ej/0.1}:
                • name:
                  • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                    • value: proxiedStream
          • FieldStatement{http://etl.sf.net/2006/samples/ej/0.1}:
            • visibilityModifier:
              • Modifier{http://etl.sf.net/2006/samples/ej/0.1}:
                • value: private
            • finalModifier:
              • Modifier{http://etl.sf.net/2006/samples/ej/0.1}:
                • value: final
            • classifier:
              • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                • value: RequestQueue
            • variables:
              • Variable{http://etl.sf.net/2006/samples/ej/0.1}:
                • name:
                  • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                    • value: requests
                • initialValue:
                  • NewOp{http://etl.sf.net/2006/samples/ej/0.1}:
                    • classifier:
                      • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                        • value: RequestQueue
          • FieldStatement{http://etl.sf.net/2006/samples/ej/0.1}:
            • visibilityModifier:
              • Modifier{http://etl.sf.net/2006/samples/ej/0.1}:
                • value: private
            • classifier:
              • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                • value: Throwable
            • variables:
              • Variable{http://etl.sf.net/2006/samples/ej/0.1}:
                • name:
                  • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                    • value: problem
          • FieldStatement{http://etl.sf.net/2006/samples/ej/0.1}:
            • visibilityModifier:
              • Modifier{http://etl.sf.net/2006/samples/ej/0.1}:
                • value: private
            • classifier:
              • PrimitiveType{http://etl.sf.net/2006/samples/ej/0.1}:
                • name: boolean
            • variables:
              • Variable{http://etl.sf.net/2006/samples/ej/0.1}:
                • name:
                  • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                    • value: isClosed
                • initialValue:
                  • BooleanLiteral{http://etl.sf.net/2006/samples/ej/0.1}:
                    • value: false
          • FieldStatement{http://etl.sf.net/2006/samples/ej/0.1}:
            • visibilityModifier:
              • Modifier{http://etl.sf.net/2006/samples/ej/0.1}:
                • value: private
            • classifier:
              • PrimitiveType{http://etl.sf.net/2006/samples/ej/0.1}:
                • name: boolean
            • variables:
              • Variable{http://etl.sf.net/2006/samples/ej/0.1}:
                • name:
                  • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                    • value: eofReached
                • initialValue:
                  • BooleanLiteral{http://etl.sf.net/2006/samples/ej/0.1}:
                    • value: false
          • ConstructorStatement{http://etl.sf.net/2006/samples/ej/0.1}:
            • visibilityModifier:
              • Modifier{http://etl.sf.net/2006/samples/ej/0.1}:
                • value: public
            • name:
              • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                • value: ABufferedInputStream
            • parameters:
              • Parameter{http://etl.sf.net/2006/samples/ej/0.1}:
                • classifier:
                  • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                    • value: AInputStream
                • name:
                  • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                    • value: proxiedStream
            • parameters:
              • Parameter{http://etl.sf.net/2006/samples/ej/0.1}:
                • classifier:
                  • PrimitiveType{http://etl.sf.net/2006/samples/ej/0.1}:
                    • name: int
                • name:
                  • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                    • value: size
            • body:
              • MethodBlock{http://etl.sf.net/2006/samples/ej/0.1}:
                • content:
                  • ExpressionStatement{http://etl.sf.net/2006/samples/ej/0.1}:
                    • expression:
                      • AssignmentOp{http://etl.sf.net/2006/samples/ej/0.1}:
                        • leftHandSide:
                          • AccessOp{http://etl.sf.net/2006/samples/ej/0.1}:
                            • accessed:
                              • ThisReference{http://etl.sf.net/2006/samples/ej/0.1}:
                                • name: this
                            • feature:
                              • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                • value: data
                        • value:
                          • NewOp{http://etl.sf.net/2006/samples/ej/0.1}:
                            • classifier:
                              • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                • value: DataBuffer
                            • args:
                              • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                • value: size
                  • ExpressionStatement{http://etl.sf.net/2006/samples/ej/0.1}:
                    • expression:
                      • AssignmentOp{http://etl.sf.net/2006/samples/ej/0.1}:
                        • leftHandSide:
                          • AccessOp{http://etl.sf.net/2006/samples/ej/0.1}:
                            • accessed:
                              • ThisReference{http://etl.sf.net/2006/samples/ej/0.1}:
                                • name: this
                            • feature:
                              • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                • value: proxiedStream
                        • value:
                          • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                            • value: proxiedStream
          • EventualMethodStatement{http://etl.sf.net/2006/samples/ej/AsyncEJ/0.1}:
            • documentation:
              • DocumentationLine{http://etl.sf.net/2006/samples/ej/0.1}:
                • text: /// read some bytes in buffer
              • DocumentationLine{http://etl.sf.net/2006/samples/ej/0.1}:
                • text: /// @param buffer a buffer
              • DocumentationLine{http://etl.sf.net/2006/samples/ej/0.1}:
                • text: /// @returns Promise for buffer that is passed to stream
            • visibilityModifier:
              • Modifier{http://etl.sf.net/2006/samples/ej/0.1}:
                • value: public
            • returnType:
              • PrimitiveType{http://etl.sf.net/2006/samples/ej/0.1}:
                • name: int
            • name:
              • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                • value: read
            • parameters:
              • Parameter{http://etl.sf.net/2006/samples/ej/0.1}:
                • finalModifier:
                  • Modifier{http://etl.sf.net/2006/samples/ej/0.1}:
                    • value: final
                • classifier:
                  • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                    • value: DataBuffer
                • name:
                  • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                    • value: buffer
            • body:
              • MethodBlock{http://etl.sf.net/2006/samples/ej/0.1}:
                • content:
                  • IfStatement{http://etl.sf.net/2006/samples/ej/0.1}:
                    • ifThenPart:
                      • IfThenPart{http://etl.sf.net/2006/samples/ej/0.1}:
                        • condition:
                          • ApplyRoundOp{http://etl.sf.net/2006/samples/ej/0.1}:
                            • functor:
                              • AccessOp{http://etl.sf.net/2006/samples/ej/0.1}:
                                • accessed:
                                  • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                    • value: requests
                                • feature:
                                  • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                    • value: tryStartRequest
                        • body:
                          • MethodBlock{http://etl.sf.net/2006/samples/ej/0.1}:
                            • content:
                              • ReturnStatement{http://etl.sf.net/2006/samples/ej/0.1}:
                                • value:
                                  • WhenOp{http://etl.sf.net/2006/samples/ej/AsyncEJ/0.1}:
                                    • parameter:
                                      • Parameter{http://etl.sf.net/2006/samples/ej/0.1}:
                                        • classifier:
                                          • PrimitiveType{http://etl.sf.net/2006/samples/ej/0.1}:
                                            • name: int
                                        • name:
                                          • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                            • value: rc
                                    • value:
                                      • ApplyRoundOp{http://etl.sf.net/2006/samples/ej/0.1}:
                                        • functor:
                                          • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                            • value: performRead
                                        • args:
                                          • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                            • value: buffer
                                    • body:
                                      • MethodBlock{http://etl.sf.net/2006/samples/ej/0.1}:
                                        • content:
                                          • ReturnStatement{http://etl.sf.net/2006/samples/ej/0.1}:
                                            • value:
                                              • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                                • value: rc
                                    • finallyPart:
                                      • MethodBlock{http://etl.sf.net/2006/samples/ej/0.1}:
                                        • content:
                                          • ExpressionStatement{http://etl.sf.net/2006/samples/ej/0.1}:
                                            • expression:
                                              • ApplyRoundOp{http://etl.sf.net/2006/samples/ej/0.1}:
                                                • functor:
                                                  • AccessOp{http://etl.sf.net/2006/samples/ej/0.1}:
                                                    • accessed:
                                                      • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                                        • value: requests
                                                    • feature:
                                                      • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                                        • value: endRequest
                    • elsePart:
                      • MethodBlock{http://etl.sf.net/2006/samples/ej/0.1}:
                        • content:
                          • ReturnStatement{http://etl.sf.net/2006/samples/ej/0.1}:
                            • value:
                              • WhenOp{http://etl.sf.net/2006/samples/ej/AsyncEJ/0.1}:
                                • value:
                                  • ApplyRoundOp{http://etl.sf.net/2006/samples/ej/0.1}:
                                    • functor:
                                      • EventualSendOp{http://etl.sf.net/2006/samples/ej/AsyncEJ/0.1}:
                                        • target:
                                          • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                            • value: requests
                                        • message:
                                          • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                            • value: startRequest
                                • body:
                                  • MethodBlock{http://etl.sf.net/2006/samples/ej/0.1}:
                                    • content:
                                      • ReturnStatement{http://etl.sf.net/2006/samples/ej/0.1}:
                                        • value:
                                          • ApplyRoundOp{http://etl.sf.net/2006/samples/ej/0.1}:
                                            • functor:
                                              • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                                • value: performRead
                                            • args:
                                              • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                                • value: buffer
                                • finallyPart:
                                  • MethodBlock{http://etl.sf.net/2006/samples/ej/0.1}:
                                    • content:
                                      • ExpressionStatement{http://etl.sf.net/2006/samples/ej/0.1}:
                                        • expression:
                                          • ApplyRoundOp{http://etl.sf.net/2006/samples/ej/0.1}:
                                            • functor:
                                              • AccessOp{http://etl.sf.net/2006/samples/ej/0.1}:
                                                • accessed:
                                                  • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                                    • value: requests
                                                • feature:
                                                  • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                                    • value: endRequest
          • EventualMethodStatement{http://etl.sf.net/2006/samples/ej/AsyncEJ/0.1}:
            • documentation:
              • DocumentationLine{http://etl.sf.net/2006/samples/ej/0.1}:
                • text: /// read some bytes in buffer
              • DocumentationLine{http://etl.sf.net/2006/samples/ej/0.1}:
                • text: /// @param buffer a input buffer
              • DocumentationLine{http://etl.sf.net/2006/samples/ej/0.1}:
                • text: /// @returns Promise that resolves to int that indicate amount of bytes read
            • visibilityModifier:
              • Modifier{http://etl.sf.net/2006/samples/ej/0.1}:
                • value: private
            • returnType:
              • PrimitiveType{http://etl.sf.net/2006/samples/ej/0.1}:
                • name: int
            • name:
              • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                • value: performRead
            • parameters:
              • Parameter{http://etl.sf.net/2006/samples/ej/0.1}:
                • finalModifier:
                  • Modifier{http://etl.sf.net/2006/samples/ej/0.1}:
                    • value: final
                • classifier:
                  • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                    • value: DataBuffer
                • name:
                  • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                    • value: buffer
            • body:
              • MethodBlock{http://etl.sf.net/2006/samples/ej/0.1}:
                • content:
                  • IfStatement{http://etl.sf.net/2006/samples/ej/0.1}:
                    • ifThenPart:
                      • IfThenPart{http://etl.sf.net/2006/samples/ej/0.1}:
                        • condition:
                          • LessThenOp{http://etl.sf.net/2006/samples/ej/0.1}:
                            • value1:
                              • ApplyRoundOp{http://etl.sf.net/2006/samples/ej/0.1}:
                                • functor:
                                  • AccessOp{http://etl.sf.net/2006/samples/ej/0.1}:
                                    • accessed:
                                      • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                        • value: buffer
                                    • feature:
                                      • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                        • value: availableForPut
                            • value2:
                              • IntegerLiteral{http://etl.sf.net/2006/samples/ej/0.1}:
                                • value: 1
                        • body:
                          • MethodBlock{http://etl.sf.net/2006/samples/ej/0.1}:
                            • content:
                              • ThrowStatement{http://etl.sf.net/2006/samples/ej/0.1}:
                                • exception:
                                  • NewOp{http://etl.sf.net/2006/samples/ej/0.1}:
                                    • classifier:
                                      • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                        • value: IllegalArgumentException
                                    • args:
                                      • PlusOp{http://etl.sf.net/2006/samples/ej/0.1}:
                                        • summands:
                                          • StringLiteral{http://etl.sf.net/2006/samples/ej/0.1}:
                                            • value: "cannot put data into buffer with capacity "
                                        • summands:
                                          • ApplyRoundOp{http://etl.sf.net/2006/samples/ej/0.1}:
                                            • functor:
                                              • AccessOp{http://etl.sf.net/2006/samples/ej/0.1}:
                                                • accessed:
                                                  • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                                    • value: buffer
                                                • feature:
                                                  • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                                    • value: availableForPut
                  • IfStatement{http://etl.sf.net/2006/samples/ej/0.1}:
                    • ifThenPart:
                      • IfThenPart{http://etl.sf.net/2006/samples/ej/0.1}:
                        • condition:
                          • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                            • value: eofReached
                        • body:
                          • MethodBlock{http://etl.sf.net/2006/samples/ej/0.1}:
                            • content:
                              • ReturnStatement{http://etl.sf.net/2006/samples/ej/0.1}:
                                • value:
                                  • UnaryMinusOp{http://etl.sf.net/2006/samples/ej/0.1}:
                                    • value:
                                      • IntegerLiteral{http://etl.sf.net/2006/samples/ej/0.1}:
                                        • value: 1
                  • IfStatement{http://etl.sf.net/2006/samples/ej/0.1}:
                    • ifThenPart:
                      • IfThenPart{http://etl.sf.net/2006/samples/ej/0.1}:
                        • condition:
                          • NotEqualOp{http://etl.sf.net/2006/samples/ej/0.1}:
                            • value1:
                              • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                • value: problem
                            • value2:
                              • NullReference{http://etl.sf.net/2006/samples/ej/0.1}:
                                • value: null
                        • body:
                          • MethodBlock{http://etl.sf.net/2006/samples/ej/0.1}:
                            • content:
                              • ThrowStatement{http://etl.sf.net/2006/samples/ej/0.1}:
                                • exception:
                                  • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                    • value: problem
                  • IfStatement{http://etl.sf.net/2006/samples/ej/0.1}:
                    • ifThenPart:
                      • IfThenPart{http://etl.sf.net/2006/samples/ej/0.1}:
                        • condition:
                          • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                            • value: isClosed
                        • body:
                          • MethodBlock{http://etl.sf.net/2006/samples/ej/0.1}:
                            • content:
                              • ThrowStatement{http://etl.sf.net/2006/samples/ej/0.1}:
                                • exception:
                                  • NewOp{http://etl.sf.net/2006/samples/ej/0.1}:
                                    • classifier:
                                      • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                        • value: IllegalStateException
                                    • args:
                                      • StringLiteral{http://etl.sf.net/2006/samples/ej/0.1}:
                                        • value: "the stream is already closed"
                  • IfStatement{http://etl.sf.net/2006/samples/ej/0.1}:
                    • ifThenPart:
                      • IfThenPart{http://etl.sf.net/2006/samples/ej/0.1}:
                        • condition:
                          • ApplyRoundOp{http://etl.sf.net/2006/samples/ej/0.1}:
                            • functor:
                              • AccessOp{http://etl.sf.net/2006/samples/ej/0.1}:
                                • accessed:
                                  • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                    • value: data
                                • feature:
                                  • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                    • value: isEmpty
                        • body:
                          • MethodBlock{http://etl.sf.net/2006/samples/ej/0.1}:
                            • content:
                              • ReturnStatement{http://etl.sf.net/2006/samples/ej/0.1}:
                                • value:
                                  • WhenOp{http://etl.sf.net/2006/samples/ej/AsyncEJ/0.1}:
                                    • parameter:
                                      • Parameter{http://etl.sf.net/2006/samples/ej/0.1}:
                                        • classifier:
                                          • PrimitiveType{http://etl.sf.net/2006/samples/ej/0.1}:
                                            • name: int
                                        • name:
                                          • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                            • value: readBytes
                                    • value:
                                      • ApplyRoundOp{http://etl.sf.net/2006/samples/ej/0.1}:
                                        • functor:
                                          • EventualSendOp{http://etl.sf.net/2006/samples/ej/AsyncEJ/0.1}:
                                            • target:
                                              • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                                • value: proxiedStream
                                            • message:
                                              • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                                • value: read
                                        • args:
                                          • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                            • value: data
                                    • body:
                                      • MethodBlock{http://etl.sf.net/2006/samples/ej/0.1}:
                                        • content:
                                          • IfStatement{http://etl.sf.net/2006/samples/ej/0.1}:
                                            • ifThenPart:
                                              • IfThenPart{http://etl.sf.net/2006/samples/ej/0.1}:
                                                • condition:
                                                  • EqualOp{http://etl.sf.net/2006/samples/ej/0.1}:
                                                    • value1:
                                                      • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                                        • value: readBytes
                                                    • value2:
                                                      • UnaryMinusOp{http://etl.sf.net/2006/samples/ej/0.1}:
                                                        • value:
                                                          • IntegerLiteral{http://etl.sf.net/2006/samples/ej/0.1}:
                                                            • value: 1
                                                • body:
                                                  • MethodBlock{http://etl.sf.net/2006/samples/ej/0.1}:
                                                    • content:
                                                      • ExpressionStatement{http://etl.sf.net/2006/samples/ej/0.1}:
                                                        • expression:
                                                          • AssignmentOp{http://etl.sf.net/2006/samples/ej/0.1}:
                                                            • leftHandSide:
                                                              • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                                                • value: eofReached
                                                            • value:
                                                              • BooleanLiteral{http://etl.sf.net/2006/samples/ej/0.1}:
                                                                • value: true
                                          • ReturnStatement{http://etl.sf.net/2006/samples/ej/0.1}:
                                            • value:
                                              • ApplyRoundOp{http://etl.sf.net/2006/samples/ej/0.1}:
                                                • functor:
                                                  • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                                    • value: performRead
                                                • args:
                                                  • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                                    • value: buffer
                                    • catchPart:
                                      • CatchPart{http://etl.sf.net/2006/samples/ej/0.1}:
                                        • specification:
                                          • Parameter{http://etl.sf.net/2006/samples/ej/0.1}:
                                            • classifier:
                                              • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                                • value: Throwable
                                            • name:
                                              • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                                • value: t
                                        • body:
                                          • MethodBlock{http://etl.sf.net/2006/samples/ej/0.1}:
                                            • content:
                                              • ExpressionStatement{http://etl.sf.net/2006/samples/ej/0.1}:
                                                • expression:
                                                  • AssignmentOp{http://etl.sf.net/2006/samples/ej/0.1}:
                                                    • leftHandSide:
                                                      • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                                        • value: problem
                                                    • value:
                                                      • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                                        • value: t
                                              • ThrowStatement{http://etl.sf.net/2006/samples/ej/0.1}:
                                                • exception:
                                                  • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                                    • value: t
                    • elsePart:
                      • MethodBlock{http://etl.sf.net/2006/samples/ej/0.1}:
                        • content:
                          • ReturnStatement{http://etl.sf.net/2006/samples/ej/0.1}:
                            • value:
                              • ApplyRoundOp{http://etl.sf.net/2006/samples/ej/0.1}:
                                • functor:
                                  • AccessOp{http://etl.sf.net/2006/samples/ej/0.1}:
                                    • accessed:
                                      • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                        • value: buffer
                                    • feature:
                                      • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                        • value: transferFrom
                                • args:
                                  • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                    • value: data
          • EventualMethodStatement{http://etl.sf.net/2006/samples/ej/AsyncEJ/0.1}:
            • documentation:
              • DocumentationLine{http://etl.sf.net/2006/samples/ej/0.1}:
                • text: /// close stream
              • DocumentationLine{http://etl.sf.net/2006/samples/ej/0.1}:
                • text: /// @returns a promise that resolves to null or breaks with exception.
            • visibilityModifier:
              • Modifier{http://etl.sf.net/2006/samples/ej/0.1}:
                • value: public
            • returnType:
              • PrimitiveType{http://etl.sf.net/2006/samples/ej/0.1}:
                • name: void
            • name:
              • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                • value: close
            • body:
              • MethodBlock{http://etl.sf.net/2006/samples/ej/0.1}:
                • content:
                  • IfStatement{http://etl.sf.net/2006/samples/ej/0.1}:
                    • ifThenPart:
                      • IfThenPart{http://etl.sf.net/2006/samples/ej/0.1}:
                        • condition:
                          • ApplyRoundOp{http://etl.sf.net/2006/samples/ej/0.1}:
                            • functor:
                              • AccessOp{http://etl.sf.net/2006/samples/ej/0.1}:
                                • accessed:
                                  • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                    • value: requests
                                • feature:
                                  • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                    • value: tryStartRequest
                        • body:
                          • MethodBlock{http://etl.sf.net/2006/samples/ej/0.1}:
                            • content:
                              • ReturnStatement{http://etl.sf.net/2006/samples/ej/0.1}:
                                • value:
                                  • WhenOp{http://etl.sf.net/2006/samples/ej/AsyncEJ/0.1}:
                                    • value:
                                      • ApplyRoundOp{http://etl.sf.net/2006/samples/ej/0.1}:
                                        • functor:
                                          • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                            • value: performClose
                                    • body:
                                      • MethodBlock{http://etl.sf.net/2006/samples/ej/0.1}:
                                        • content:
                                          • ReturnStatement{http://etl.sf.net/2006/samples/ej/0.1}:
                                      • finallyPart:
                                        • MethodBlock{http://etl.sf.net/2006/samples/ej/0.1}:
                                          • content:
                                            • ExpressionStatement{http://etl.sf.net/2006/samples/ej/0.1}:
                                              • expression:
                                                • ApplyRoundOp{http://etl.sf.net/2006/samples/ej/0.1}:
                                                  • functor:
                                                    • AccessOp{http://etl.sf.net/2006/samples/ej/0.1}:
                                                      • accessed:
                                                        • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                                          • value: requests
                                                      • feature:
                                                        • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                                          • value: endRequest
                      • elsePart:
                        • MethodBlock{http://etl.sf.net/2006/samples/ej/0.1}:
                          • content:
                            • ReturnStatement{http://etl.sf.net/2006/samples/ej/0.1}:
                              • value:
                                • WhenOp{http://etl.sf.net/2006/samples/ej/AsyncEJ/0.1}:
                                  • value:
                                    • ApplyRoundOp{http://etl.sf.net/2006/samples/ej/0.1}:
                                      • functor:
                                        • EventualSendOp{http://etl.sf.net/2006/samples/ej/AsyncEJ/0.1}:
                                          • target:
                                            • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                              • value: requests
                                          • message:
                                            • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                              • value: startRequest
                                  • body:
                                    • MethodBlock{http://etl.sf.net/2006/samples/ej/0.1}:
                                      • content:
                                        • ReturnStatement{http://etl.sf.net/2006/samples/ej/0.1}:
                                          • value:
                                            • ApplyRoundOp{http://etl.sf.net/2006/samples/ej/0.1}:
                                              • functor:
                                                • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                                  • value: performClose
                                  • finallyPart:
                                    • MethodBlock{http://etl.sf.net/2006/samples/ej/0.1}:
                                      • content:
                                        • ExpressionStatement{http://etl.sf.net/2006/samples/ej/0.1}:
                                          • expression:
                                            • ApplyRoundOp{http://etl.sf.net/2006/samples/ej/0.1}:
                                              • functor:
                                                • AccessOp{http://etl.sf.net/2006/samples/ej/0.1}:
                                                  • accessed:
                                                    • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                                      • value: requests
                                                  • feature:
                                                    • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                                      • value: endRequest
            • EventualMethodStatement{http://etl.sf.net/2006/samples/ej/AsyncEJ/0.1}:
              • documentation:
                • DocumentationLine{http://etl.sf.net/2006/samples/ej/0.1}:
                  • text: /// close stream
                • DocumentationLine{http://etl.sf.net/2006/samples/ej/0.1}:
                  • text: /// @returns a promise that resolves to null or breaks with exception.
              • visibilityModifier:
                • Modifier{http://etl.sf.net/2006/samples/ej/0.1}:
                  • value: private
              • returnType:
                • PrimitiveType{http://etl.sf.net/2006/samples/ej/0.1}:
                  • name: void
              • name:
                • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                  • value: performClose
              • body:
                • MethodBlock{http://etl.sf.net/2006/samples/ej/0.1}:
                  • content:
                    • IfStatement{http://etl.sf.net/2006/samples/ej/0.1}:
                      • ifThenPart:
                        • IfThenPart{http://etl.sf.net/2006/samples/ej/0.1}:
                          • condition:
                            • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                              • value: isClosed
                          • body:
                            • MethodBlock{http://etl.sf.net/2006/samples/ej/0.1}:
                              • content:
                                • ThrowStatement{http://etl.sf.net/2006/samples/ej/0.1}:
                                  • exception:
                                    • NewOp{http://etl.sf.net/2006/samples/ej/0.1}:
                                      • classifier:
                                        • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                          • value: IllegalStateException
                                      • args:
                                        • StringLiteral{http://etl.sf.net/2006/samples/ej/0.1}:
                                          • value: "the stream is already closed"
                      • elsePart:
                        • MethodBlock{http://etl.sf.net/2006/samples/ej/0.1}:
                          • content:
                            • ExpressionStatement{http://etl.sf.net/2006/samples/ej/0.1}:
                              • expression:
                                • AssignmentOp{http://etl.sf.net/2006/samples/ej/0.1}:
                                  • leftHandSide:
                                    • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                      • value: isClosed
                                  • value:
                                    • BooleanLiteral{http://etl.sf.net/2006/samples/ej/0.1}:
                                      • value: true
                            • ReturnStatement{http://etl.sf.net/2006/samples/ej/0.1}:
                              • value:
                                • ApplyRoundOp{http://etl.sf.net/2006/samples/ej/0.1}:
                                  • functor:
                                    • EventualSendOp{http://etl.sf.net/2006/samples/ej/AsyncEJ/0.1}:
                                      • target:
                                        • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                          • value: proxiedStream
                                      • message:
                                        • Identifier{http://etl.sf.net/2006/samples/ej/0.1}:
                                          • value: close
         1: doctype "../grammars/AsyncEJ.g.etl";
         2: /// This sample is based on async-objects framework
         3: 
         4: /// sample asynchronous interface
         5: /// The interface demonstrate simple input stream
         6: interface ByteInput {
         7: 	on int read(DataBuffer buffer);
         8: 	on void close();
         9: };
        10: 
        11: /// sample asynchronous class
        12: /// The class demonstrate simple buffered input
        13: class BufferedByteInputImpl {
        14: 	supports ByteInput;
        15: 	var private DataBuffer data;
        16: 	var private final ByteInput proxiedStream;
        17: 	var private final RequestQueue requests = new RequestQueue();
        18: 	var private Throwable problem;
        19: 	var private boolean isClosed = false;
        20: 	var private boolean eofReached = false;
        21: 
        22: 	maker public ABufferedInputStream(AInputStream proxiedStream, int size) {
        23: 		this.data = new DataBuffer(size);
        24: 		this.proxiedStream = proxiedStream;
        25: 	};
        26: 
        27: 	/// read some bytes in buffer
        28: 	/// @param buffer a buffer
        29: 	/// @returns Promise for buffer that is passed to stream
        30: 	on public int read(final DataBuffer buffer) {
        31: 		if(requests.tryStartRequest()) {
        32: 			return when(var int rc = performRead(buffer)) {
        33: 					return rc;
        34: 				} finally {
        35: 					requests.endRequest();
        36: 				};
        37: 		} else {
        38: 			return when(requests<-startRequest()) {
        39: 					return performRead(buffer);
        40: 				} finally {
        41: 					requests.endRequest();
        42: 				};
        43: 		};
        44: 	};
        45: 
        46: 	/// read some bytes in buffer
        47: 	/// @param buffer a input buffer
        48: 	/// @returns Promise that resolves to int that indicate amount of bytes read
        49: 	on private int performRead(final DataBuffer buffer) {
        50: 		if(buffer.availableForPut() < 1) {
        51: 		      throw new IllegalArgumentException("cannot put data into buffer with capacity "+buffer.availableForPut());
        52: 		};
        53: 		if(eofReached) {
        54: 			return -1;
        55: 		};
        56: 		if(problem != null) {
        57: 			throw problem;
        58: 		};
        59: 		if(isClosed) {
        60: 			throw new IllegalStateException("the stream is already closed");
        61: 		};
        62: 		if(data.isEmpty()) {
        63: 			return when(var int readBytes = proxiedStream<-read(data)) {
        64: 				if(readBytes == -1) {
        65: 					eofReached = true;
        66: 				};
        67: 				// something is read or eof reached
        68: 				return performRead(buffer);
        69: 			} catch (Throwable t) {
        70: 				problem = t;
        71: 				throw t;
        72: 			};
        73: 		} else {
        74: 			return buffer.transferFrom(data);
        75: 		};
        76: 	};
        77: 
        78: 
        79: 	/// close stream
        80: 	/// @returns a promise that resolves to null or breaks with exception.
        81: 	on public void close() {
        82: 		if(requests.tryStartRequest()) {
        83: 			return when(performClose()) {
        84: 					return;
        85: 				} finally {
        86: 					requests.endRequest();
        87: 				};
        88: 		} else {
        89: 			return when(requests<-startRequest()) {
        90: 					return performClose();
        91: 				} finally {
        92: 					requests.endRequest();
        93: 				};
        94: 		};
        95: 	};
        96: 
        97: 	/// close stream
        98: 	/// @returns a promise that resolves to null or breaks with exception.
        99: 	on private void performClose() {
       100: 		if(isClosed) {
       101: 			throw new IllegalStateException("the stream is already closed");
       102: 		} else {
       103: 			isClosed = true;
       104: 			return proxiedStream<-close();
       105: 		};
       106: 	};
       107: };