001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.parsers.creole.ast;
016    
017    import com.liferay.portal.parsers.creole.visitor.ASTVisitor;
018    
019    /**
020     * @author Miguel Pastor
021     */
022    public class HeadingNode
023            extends BaseParentableNode implements Comparable<HeadingNode> {
024    
025            public HeadingNode(int level) {
026                    _level = level;
027            }
028    
029            public HeadingNode(CollectionNode collectionNode, int level) {
030                    super(collectionNode);
031    
032                    _level = level;
033            }
034    
035            @Override
036            public void accept(ASTVisitor astVisitor) {
037                    astVisitor.visit(this);
038            }
039    
040            public int compareTo(HeadingNode headingNode) {
041                    if (_level < headingNode.getLevel()) {
042                            return -1;
043                    }
044                    else if (_level > headingNode.getLevel()) {
045                            return 1;
046                    }
047                    else {
048                            return 0;
049                    }
050            }
051    
052            public int getLevel() {
053                    return _level;
054            }
055    
056            public void setLevel(int level) {
057                    _level = level;
058            }
059    
060            private int _level;
061    
062    }