001////////////////////////////////////////////////////////////////////////////////
002// checkstyle: Checks Java source code for adherence to a set of rules.
003// Copyright (C) 2001-2014  Oliver Burn
004//
005// This library is free software; you can redistribute it and/or
006// modify it under the terms of the GNU Lesser General Public
007// License as published by the Free Software Foundation; either
008// version 2.1 of the License, or (at your option) any later version.
009//
010// This library is distributed in the hope that it will be useful,
011// but WITHOUT ANY WARRANTY; without even the implied warranty of
012// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013// Lesser General Public License for more details.
014//
015// You should have received a copy of the GNU Lesser General Public
016// License along with this library; if not, write to the Free Software
017// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
018////////////////////////////////////////////////////////////////////////////////
019package com.puppycrawl.tools.checkstyle.checks.javadoc;
020
021import com.puppycrawl.tools.checkstyle.api.DetailNode;
022
023/**
024 *
025 * Implementation of DetailNode interface that is mutable.
026 *
027 * @author Baratali Izmailov
028 *
029 */
030public class JavadocNodeImpl implements DetailNode
031{
032    /**
033     * Node index among parent's children
034     */
035    private int index;
036
037    /**
038     * Node type
039     */
040    private int type;
041
042    /**
043     * Node's text content
044     */
045    private String text;
046
047    /**
048     * Line number
049     */
050    private int lineNumber;
051
052    /**
053     * Column number
054     */
055    private int columnNumber;
056
057    /**
058     * Array of child nodes
059     */
060    private DetailNode[] children;
061
062    /**
063     * Parent node
064     */
065    private DetailNode parent;
066
067    @Override
068    public int getType()
069    {
070        return type;
071    }
072
073    @Override
074    public String getText()
075    {
076        return text;
077    }
078
079    @Override
080    public int getLineNumber()
081    {
082        return lineNumber;
083    }
084
085    @Override
086    public int getColumnNumber()
087    {
088        return columnNumber;
089    }
090
091    @Override
092    public DetailNode[] getChildren()
093    {
094        return children;
095    }
096
097    @Override
098    public DetailNode getParent()
099    {
100        return parent;
101    }
102
103    @Override
104    public int getIndex()
105    {
106        return index;
107    }
108
109    public void setType(int type)
110    {
111        this.type = type;
112    }
113
114    public void setText(String text)
115    {
116        this.text = text;
117    }
118
119    public void setLineNumber(int lineNumber)
120    {
121        this.lineNumber = lineNumber;
122    }
123
124    public void setColumnNumber(int columnNumber)
125    {
126        this.columnNumber = columnNumber;
127    }
128
129    public void setChildren(DetailNode[] children)
130    {
131        this.children = children;
132    }
133
134    public void setParent(DetailNode parent)
135    {
136        this.parent = parent;
137    }
138
139    public void setIndex(int index)
140    {
141        this.index = index;
142    }
143
144    @Override
145    public String toString()
146    {
147        return JavadocUtils.getTokenName(getType())
148                + "[" + getLineNumber() + "x" + getColumnNumber() + "]";
149    }
150
151}