// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/kpdus/jad.html
// Decompiler options: packimports(3) deadcode 
// Source File Name:   SerialFieldTagImpl.java

package com.sun.tools.javadoc;

import com.sun.javadoc.*;

// Referenced classes of package com.sun.tools.javadoc:
//            TagImpl, Comment, DocEnv, FieldDocImpl, 
//            MemberDocImpl, DocImpl

class SerialFieldTagImpl extends TagImpl
    implements SerialFieldTag, Comparable
{

    private void parseSerialFieldString()
    {
        int i = text.length();
        int j;
        for(j = 0; j < i && Character.isWhitespace(text.charAt(j)); j++);
        int k = j;
        int l = j;
        if(!Character.isJavaIdentifierStart(text.charAt(j)))
        {
            docenv().warning(holder, "tag.serialField.illegal_character", "" + text.charAt(j), text);
            return;
        }
        for(; j < i && Character.isJavaIdentifierPart(text.charAt(j)); j++);
        if(j < i && !Character.isWhitespace(text.charAt(j)))
        {
            docenv().warning(holder, "tag.serialField.illegal_character", "" + text.charAt(j), text);
            return;
        }
        l = j;
        fieldName = text.substring(k, l);
        for(; j < i && Character.isWhitespace(text.charAt(j)); j++);
        k = j;
        l = j;
        for(; j < i && !Character.isWhitespace(text.charAt(j)); j++);
        if(j < i && !Character.isWhitespace(text.charAt(j)))
        {
            docenv().warning(holder, "tag.serialField.illegal_character", "" + text.charAt(j), text);
            return;
        }
        l = j;
        fieldType = text.substring(k, l);
        for(; j < i && Character.isWhitespace(text.charAt(j)); j++);
        description = text.substring(j);
    }

    public ClassDoc fieldTypeDoc()
    {
        if(fieldTypeDoc == null && containingClass != null)
            fieldTypeDoc = containingClass.findClass(fieldType);
        return fieldTypeDoc;
    }

    FieldDocImpl getMatchingField()
    {
        return matchingField;
    }

    void mapToFieldDocImpl(FieldDocImpl fielddocimpl)
    {
        matchingField = fielddocimpl;
    }

    public int compareTo(Object obj)
    {
        return key().compareTo(((SerialFieldTagImpl)obj).key());
    }

    public String description()
    {
        if(description.length() == 0 && matchingField != null)
        {
            Comment comment = matchingField.comment();
            if(comment != null)
                return comment.commentText();
        }
        return description;
    }

    public String fieldName()
    {
        return fieldName;
    }

    public String fieldType()
    {
        return fieldType;
    }

    String key()
    {
        return fieldName;
    }

    public String kind()
    {
        return "@serialField";
    }

    public String toString()
    {
        return name + ":" + text;
    }

    SerialFieldTagImpl(DocImpl docimpl, String s, String s1)
    {
        TagImpl(docimpl, s, s1);
        parseSerialFieldString();
        if(docimpl instanceof MemberDoc)
            containingClass = ((MemberDocImpl)docimpl).containingClass();
    }

    private String fieldName;
    private String fieldType;
    private String description;
    private ClassDoc containingClass;
    private ClassDoc fieldTypeDoc;
    private FieldDocImpl matchingField;
}
