xquery/XQuery__UntypedAtomicToBooleanCast.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Mon, 02 Jul 2018 08:46:01 +0200
changeset 305 bad21c4f64bf
parent 296 ea3dbc023c80
permissions -rw-r--r--
Tagged Smalltalk/X 8.0.0

"{ Package: 'stx:goodies/xmlsuite/xquery' }"

"{ NameSpace: XQuery }"

UntypedAtomicToAnyAtomicTypeCast subclass:#UntypedAtomicToBooleanCast
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'XQuery-TypeCasting'
!


!UntypedAtomicToBooleanCast methodsFor:'casting'!

cast
    | value bValue |
    self checkLexicalForm .
    value := atomicValue nodeId.

    ((value = 'true') or: [value = '1']) ifTrue:
    [
        bValue := true.
    ] 
    ifFalse: 
    [
        self assert: ((value = 'false') or: [value = '0']) message: 'unsupported value for boolean'.
        bValue := false.
    ].

    ^ AtomicItem withValue: bValue asType: anotherType typeName.

    "Created: / 17-11-2009 / 16:27:13 / Jan Kurs <kursj1@fel.cvut.cz>"
! !

!UntypedAtomicToBooleanCast class methodsFor:'documentation'!

version_SVN
    ^ '$Id$'
! !