<s> package org . eclipse . jdt . internal . core . jdom ; import org . eclipse . jdt . core . Flags ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . core . jdom . * ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; import org . eclipse . jdt . internal . core . util . CharArrayBuffer ; abstract class DOMMember extends DOMNode implements IDOMMember { protected int fFlags = 0 ; protected String fComment = null ; protected int [ ] fCommentRange ; protected char [ ] fModifiers = null ; protected int [ ] fModifierRange ; DOMMember ( ) { } DOMMember ( char [ ] document , int [ ] sourceRange , String name , int [ ] nameRange , int [ ] commentRange , int flags , int [ ] modifierRange ) { super ( document , sourceRange , name , nameRange ) ; this . fFlags = flags ; this . fComment = null ; this . fCommentRange = commentRange ; this . fModifierRange = modifierRange ; setHasComment ( commentRange [ 0 ] >= 0 ) ; } protected void appendFragmentedContents ( CharArrayBuffer buffer ) { if ( isDetailed ( ) ) { appendMemberHeaderFragment ( buffer ) ; appendMemberDeclarationContents ( buffer ) ; appendMemberBodyContents ( buffer ) ; } else { appendSimpleContents ( buffer ) ; } } protected abstract void appendMemberBodyContents ( CharArrayBuffer buffer ) ; protected abstract void appendMemberDeclarationContents ( CharArrayBuffer buffer ) ; protected void appendMemberHeaderFragment ( CharArrayBuffer buffer ) { int spaceStart , spaceEnd ; if ( hasComment ( ) ) { spaceStart = this . fSourceRange [ 0 ] ; spaceEnd = this . fCommentRange [ 0 ] ; if ( spaceEnd > 0 ) { buffer . append ( this . fDocument , spaceStart , spaceEnd - spaceStart ) ; } } String fragment = getComment ( ) ; if ( fragment != null ) { buffer . append ( fragment ) ; } if ( this . fCommentRange [ 1 ] >= 0 ) { spaceStart = this . fCommentRange [ 1 ] + 1 ; } else { spaceStart = this . fSourceRange [ 0 ] ; } if ( this . fModifierRange [ 0 ] >= 0 ) { spaceEnd = this . fModifierRange [ 0 ] - 1 ; } else { spaceEnd = getMemberDeclarationStartPosition ( ) - 1 ; } if ( spaceEnd >= spaceStart ) { buffer . append ( this . fDocument , spaceStart , spaceEnd + 1 - spaceStart ) ; } buffer . append ( getModifiersText ( ) ) ; } protected abstract void appendSimpleContents ( CharArrayBuffer buffer ) ; protected String [ ] appendString ( String [ ] list , String element ) { String [ ] copy = new String [ list . length + 1 ] ; System . arraycopy ( list , 0 , copy , 0 , list . length ) ; copy [ list . length ] = element ; return copy ; } protected char [ ] generateFlags ( ) { char [ ] flags = Flags . toString ( getFlags ( ) ) . toCharArray ( ) ; if ( flags . length == 0 ) { return flags ; } else { return CharOperation . concat ( flags , new char [ ] { ' ' } ) ; } } public String getComment ( ) { becomeDetailed ( ) ; if ( hasComment ( ) ) { if ( this . fComment != null ) { return this . fComment ; } else { return new String ( this . fDocument , this . fCommentRange [ 0 ] , this . fCommentRange [ 1 ] + 1 - this . fCommentRange [ 0 ] ) ; } } else { return null ; } } public int getFlags ( ) { return this . fFlags ; } protected abstract int getMemberDeclarationStartPosition ( ) ; protected char [ ] getModifiersText ( ) { if ( this . fModifiers == null ) { if ( this . fModifierRange [ 0 ] < 0 ) { return null ; } else { return CharOperation . subarray ( this . fDocument , this . fModifierRange [ 0 ] , this . fModifierRange [ 1 ] + 1 ) ; } } else { return this . fModifiers ; } } protected boolean hasBody ( ) { return getMask ( MASK_HAS_BODY ) ; } protected boolean hasComment ( ) { return getMask ( MASK_HAS_COMMENT ) ; } protected void offset ( int offset ) { super . offset ( offset ) ; offsetRange ( this . fCommentRange , offset ) ; offsetRange ( this . fModifierRange , offset ) ; } public void setComment ( String comment ) { becomeDetailed ( ) ; this . fComment = comment ; fragment ( ) ; setHasComment ( comment != null ) ; if ( comment != null && comment . indexOf ( "@deprecated" ) >= 0 ) { this . fFlags = this . fFlags | ClassFileConstants . AccDeprecated ; return ; } this . fFlags = this . fFlags & ( ~ ClassFileConstants . AccDeprecated ) ; } public void setFlags ( int flags ) { becomeDetailed ( ) ; if ( Flags . isDeprecated ( this . fFlags ) ) { this . fFlags = flags | ClassFileConstants . AccDeprecated ; } else { this . fFlags = flags & ( ~ ClassFileConstants . AccDeprecated ) ; } fragment ( ) ; this . fModifiers = generateFlags ( ) ; } protected void setHasBody ( boolean hasBody ) { setMask ( MASK_HAS_BODY , hasBody ) ; } protected void setHasComment ( boolean hasComment ) { setMask ( MASK_HAS_COMMENT , hasComment ) ; } protected void setStartPosition ( int start ) { if ( this . fCommentRange [ 0 ] >= 0 ) { this . fCommentRange [ 0 ] = start ; } super . setStartPosition ( start ) ; } protected void shareContents ( DOMNode node ) { super . shareContents ( node ) ; DOMMember member = ( DOMMember ) node ; this . fComment = member . fComment ; this . fCommentRange = rangeCopy ( member . fCommentRange ) ; this . fFlags = member . fFlags ; this . fModifiers = member . fModifiers ; this . fModifierRange = rangeCopy ( member . fModifierRange ) ; } } </s>