<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; import org . eclipse . jdt . core . compiler . InvalidInputException ; import org . eclipse . jdt . internal . compiler . parser . Scanner ; import org . eclipse . jdt . internal . compiler . parser . ScannerHelper ; import org . eclipse . jdt . internal . compiler . parser . TerminalTokens ; public class CharacterLiteral extends Expression { public static final SimplePropertyDescriptor ESCAPED_VALUE_PROPERTY = new SimplePropertyDescriptor ( CharacterLiteral . class , "escapedValue" , String . class , MANDATORY ) ; private static final List PROPERTY_DESCRIPTORS ; static { List properyList = new ArrayList ( 2 ) ; createPropertyList ( CharacterLiteral . class , properyList ) ; addProperty ( ESCAPED_VALUE_PROPERTY , properyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( properyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private String escapedValue = "'X'" ; CharacterLiteral ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final Object internalGetSetObjectProperty ( SimplePropertyDescriptor property , boolean get , Object value ) { if ( property == ESCAPED_VALUE_PROPERTY ) { if ( get ) { return getEscapedValue ( ) ; } else { setEscapedValue ( ( String ) value ) ; return null ; } } return super . internalGetSetObjectProperty ( property , get , value ) ; } final int getNodeType0 ( ) { return CHARACTER_LITERAL ; } ASTNode clone0 ( AST target ) { CharacterLiteral result = new CharacterLiteral ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setEscapedValue ( getEscapedValue ( ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { visitor . visit ( this ) ; visitor . endVisit ( this ) ; } public String getEscapedValue ( ) { return this . escapedValue ; } public void setEscapedValue ( String value ) { if ( value == null ) { throw new IllegalArgumentException ( ) ; } Scanner scanner = this . ast . scanner ; char [ ] source = value . toCharArray ( ) ; scanner . setSource ( source ) ; scanner . resetTo ( 0 , source . length ) ; try { int tokenType = scanner . getNextToken ( ) ; switch ( tokenType ) { case TerminalTokens . TokenNameCharacterLiteral : break ; default : throw new IllegalArgumentException ( ) ; } } catch ( InvalidInputException e ) { throw new IllegalArgumentException ( ) ; } preValueChange ( ESCAPED_VALUE_PROPERTY ) ; this . escapedValue = value ; postValueChange ( ESCAPED_VALUE_PROPERTY ) ; } void internalSetEscapedValue ( String value ) { preValueChange ( ESCAPED_VALUE_PROPERTY ) ; this . escapedValue = value ; postValueChange ( ESCAPED_VALUE_PROPERTY ) ; } public char charValue ( ) { Scanner scanner = this . ast . scanner ; char [ ] source = this . escapedValue . toCharArray ( ) ; scanner . setSource ( source ) ; scanner . resetTo ( 0 , source . length ) ; int firstChar = scanner . getNextChar ( ) ; int secondChar = scanner . getNextChar ( ) ; if ( firstChar == - 1 || firstChar != '\'' ) { throw new IllegalArgumentException ( "" ) ; } char value = ( char ) secondChar ; int nextChar = scanner . getNextChar ( ) ; if ( secondChar == '\\' ) { if ( nextChar == - 1 ) { throw new IllegalArgumentException ( "" ) ; } switch ( nextChar ) { case 'b' : value = '\b' ; break ; case 't' : value = '\t' ; break ; case 'n' : value = '\n' ; break ; case 'f' : value = '\f' ; break ; case 'r' : value = '\r' ; break ; case '\"' : value = '\"' ; break ; case '\'' : value = '\'' ; break ; case '\\' : value = '\\' ; break ; default : try { if ( ScannerHelper . isDigit ( ( char ) nextChar ) ) { int number = ScannerHelper . getNumericValue ( ( char ) nextChar ) ; nextChar = scanner . getNextChar ( ) ; if ( nextChar == - 1 ) { throw new IllegalArgumentException ( "" ) ; } if ( nextChar != '\'' ) { if ( ! ScannerHelper . isDigit ( ( char ) nextChar ) ) { throw new IllegalArgumentException ( "" ) ; } number = ( number * 8 ) + ScannerHelper . getNumericValue ( ( char ) nextChar ) ; nextChar = scanner . getNextChar ( ) ; if ( nextChar == - 1 ) { throw new IllegalArgumentException ( "" ) ; } if ( nextChar != '\'' ) { if ( ! ScannerHelper . isDigit ( ( char ) nextChar ) ) { throw new IllegalArgumentException ( "" ) ; } number = ( number * 8 ) + ScannerHelper . getNumericValue ( ( char ) nextChar ) ; } } return ( char ) number ; } else { throw new IllegalArgumentException ( "" ) ; } } catch ( InvalidInputException e ) { throw new IllegalArgumentException ( "" ) ; } } nextChar = scanner . getNextChar ( ) ; if ( nextChar == - 1 ) { throw new IllegalArgumentException ( "" ) ; } } if ( nextChar == - 1 || nextChar != '\'' ) { throw new IllegalArgumentException ( "" ) ; } return value ; } public void setCharValue ( char value ) { StringBuffer b = new StringBuffer ( 3 ) ; b . append ( '\'' ) ; switch ( value ) { case '\b' : b . append ( "\\b" ) ; break ; case '\t' : b . append ( "\\t" ) ; break ; case '\n' : b . append ( "\\n" ) ; break ; case '\f' : b . append ( "\\f" ) ; break ; case '\r' : b . append ( "\\r" ) ; break ; case '\"' : b . append ( "\\\"" ) ; break ; case '\'' : b . append ( "\\'" ) ; break ; case '\\' : b . append ( "\\\\" ) ; break ; case '\0' : b . append ( "\\0" ) ; break ; case '\1' : b . append ( "\\1" ) ; break ; case '\2' : b . append ( "\\2" ) ; break ; case '\3' : b . append ( "\\3" ) ; break ; case '\4' : b . append ( "\\4" ) ; break ; case '\5' : b . append ( "\\5" ) ; break ; case '\6' : b . append ( "\\6" ) ; break ; case '\7' : b . append ( "\\7" ) ; break ; default : b . append ( value ) ; } b . append ( '\'' ) ; setEscapedValue ( b . toString ( ) ) ; } int memSize ( ) { int size = BASE_NODE_SIZE + 1 * 4 + stringSize ( this . escapedValue ) ; return size ; } int treeSize ( ) { return memSize ( ) ; } } </s>