relaxng/trunk/RNG__XSToken.st
changeset 0 5057afe1ec87
equal deleted inserted replaced
-1:000000000000 0:5057afe1ec87
       
     1 "{ Package: 'stx:goodies/xmlsuite/relaxng' }"
       
     2 
       
     3 "{ NameSpace: RNG }"
       
     4 
       
     5 DataType subclass:#XSToken
       
     6 	instanceVariableNames:''
       
     7 	classVariableNames:''
       
     8 	poolDictionaries:''
       
     9 	category:'Relax NG-XS Data types'
       
    10 !
       
    11 
       
    12 
       
    13 !XSToken class methodsFor:'accessing'!
       
    14 
       
    15 typename
       
    16     "Superclass says that I am responsible to implement this method"
       
    17 
       
    18     ^'token'
       
    19 
       
    20     "Created: / 13-05-2005 / 11:13:55 / masca"
       
    21 ! !
       
    22 
       
    23 !XSToken class methodsFor:'private'!
       
    24 
       
    25 ensureIsToken:aString
       
    26 
       
    27 
       
    28     | foundSpace |
       
    29     (aString trimSeparators = aString) ifFalse:[DataConversionError raiseErrorString:'Token must not contain trailing spaces'].
       
    30     foundSpace := false.
       
    31     aString do:[:c|
       
    32         c = Character lf ifTrue:[DataConversionError raiseErrorString:'Token must not contain linefeed'].
       
    33         c = Character return ifTrue:[DataConversionError raiseErrorString:'Token must not contain carrige return'].
       
    34         c = Character tab ifTrue:[DataConversionError raiseErrorString:'Token must not contain tab'].
       
    35         c = Character space ifTrue:[
       
    36             foundSpace 
       
    37                 ifTrue:[DataConversionError raiseErrorString:'Token must not contain sequences of two or more spaces']
       
    38                 ifFalse:[foundSpace := true]                
       
    39         ] ifFalse:[
       
    40             foundSpace := false
       
    41         ]
       
    42     ].
       
    43     ^aString
       
    44 
       
    45     "Created: / 13-05-2005 / 11:27:09 / masca"
       
    46 ! !
       
    47 
       
    48 !XSToken methodsFor:'instance creation'!
       
    49 
       
    50 createObjectFromString:aString 
       
    51 
       
    52     ^(self class ensureIsToken:aString) asSymbol
       
    53 
       
    54     "Created: / 13-05-2005 / 11:13:55 / masca"
       
    55     "Modified: / 16-05-2005 / 14:20:59 / masca"
       
    56 !
       
    57 
       
    58 createStringFromObject:aSymbol
       
    59 
       
    60 
       
    61     ^(self class ensureIsToken:aSymbol asString)
       
    62 
       
    63     "Created: / 13-05-2005 / 11:13:55 / masca"
       
    64 ! !
       
    65 
       
    66 !XSToken class methodsFor:'documentation'!
       
    67 
       
    68 version
       
    69     ^ '$Header: /opt/data/cvs/stx/goodies/xmlsuite/relaxng/RNG__XSToken.st,v 1.1.1.1 2005-11-01 22:07:17 vranyj1 Exp $'
       
    70 ! !