private FieldDoc getFieldDoc ( Configuration config , Tag tag , String name ) { if ( name == null || name . length ( ) == 0 ) { //Base case: no label. if ( tag . holder ( ) instanceof FieldDoc ) { return ( FieldDoc ) tag . holder ( ) ; } else { // If the value tag does not specify a parameter which is a valid field and // it is not used within the comments of a valid field, return null. return null ; } } StringTokenizer st = new StringTokenizer ( name , "#" ) ; String memberName = null ; ClassDoc cd = null ; if ( st . countTokens ( ) == 1 ) { //Case 2: @value in same class. Doc holder = tag . holder ( ) ; if ( holder instanceof MemberDoc ) { cd = ( ( MemberDoc ) holder ) . containingClass ( ) ; } else if ( holder instanceof ClassDoc ) { cd = ( ClassDoc ) holder ; } memberName = st . nextToken ( ) ; } else { //Case 3: @value in different class. cd = config . root . classNamed ( st . nextToken ( ) ) ; memberName = st . nextToken ( ) ; } if ( cd == null ) { return null ; } FieldDoc [ ] fields = cd . fields ( ) ; for ( int i = 0 ; i < fields . length ; i ++ ) { if ( fields [ i ] . name ( ) . equals ( memberName ) ) { return fields [ i ] ; } } return null ; }
Given the name of the field return the corresponding FieldDoc . Return null due to invalid use of value tag if the name is null or empty string and if the value tag is not used on a field .