<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 . TerminalTokens ; public class StringLiteral extends Expression { public static final SimplePropertyDescriptor ESCAPED_VALUE_PROPERTY = new SimplePropertyDescriptor ( StringLiteral . class , "escapedValue" , String . class , MANDATORY ) ; private static final List PROPERTY_DESCRIPTORS ; static { List propertyList = new ArrayList ( 2 ) ; createPropertyList ( StringLiteral . class , propertyList ) ; addProperty ( ESCAPED_VALUE_PROPERTY , propertyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( propertyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private String escapedValue = "\"\"" ; StringLiteral ( 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 STRING_LITERAL ; } ASTNode clone0 ( AST target ) { StringLiteral result = new StringLiteral ( 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 token ) { if ( token == null ) { throw new IllegalArgumentException ( "" ) ; } Scanner scanner = this . ast . scanner ; char [ ] source = token . toCharArray ( ) ; scanner . setSource ( source ) ; scanner . resetTo ( 0 , source . length ) ; try { int tokenType = scanner . getNextToken ( ) ; switch ( tokenType ) { case TerminalTokens . TokenNameStringLiteral : break ; default : throw new IllegalArgumentException ( "" + token + "<" ) ; } } catch ( InvalidInputException e ) { throw new IllegalArgumentException ( "" + token + "<" ) ; } preValueChange ( ESCAPED_VALUE_PROPERTY ) ; this . escapedValue = token ; postValueChange ( ESCAPED_VALUE_PROPERTY ) ; } void internalSetEscapedValue ( String token ) { preValueChange ( ESCAPED_VALUE_PROPERTY ) ; this . escapedValue = token ; postValueChange ( ESCAPED_VALUE_PROPERTY ) ; } public String getLiteralValue ( ) { String s = getEscapedValue ( ) ; int len = s . length ( ) ; if ( len < 2 || s . charAt ( 0 ) != '\"' || s . charAt ( len - 1 ) != '\"' ) { throw new IllegalArgumentException ( ) ; } Scanner scanner = this . ast . scanner ; char [ ] source = s . toCharArray ( ) ; scanner . setSource ( source ) ; scanner . resetTo ( 0 , source . length ) ; try { int tokenType = scanner . getNextToken ( ) ; switch ( tokenType ) { case TerminalTokens . TokenNameStringLiteral : return scanner . getCurrentStringLiteral ( ) ; default : throw new IllegalArgumentException ( ) ; } } catch ( InvalidInputException e ) { throw new IllegalArgumentException ( ) ; } } public void setLiteralValue ( String value ) { if ( value == null ) { throw new IllegalArgumentException ( ) ; } int len = value . length ( ) ; StringBuffer b = new StringBuffer ( len + 2 ) ; b . append ( "\"" ) ; for ( int i = 0 ; i < len ; i ++ ) { char c = value . charAt ( i ) ; switch ( c ) { 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 '\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 ( c ) ; } } b . append ( "\"" ) ; setEscapedValue ( b . toString ( ) ) ; } int memSize ( ) { int size = BASE_NODE_SIZE + 1 * 4 + stringSize ( this . escapedValue ) ; return size ; } int treeSize ( ) { return memSize ( ) ; } } </s>